Javafx rotation [closed]










-1















I have an application in which I draw a rectangle and then turn it 90 degrees. In this case, I have a frame with which I can move my rectangle. But after I turned it (an example of 90 degrees), when the region moves up, the rectangle itself moves to the right. When rotating, what does the coordinate proxy of the shape itself turn?
Rotation code:



this.rotation.addListener((obs, old, fresh) -> 
Rotate rotate = new Rotate((double) fresh - (double) old,
x.getValue().doubleValue() + (width.getValue().doubleValue() / 2),
y.getValue().doubleValue() + (height.getValue().doubleValue() / 2));
shape.getTransforms().add(rotate);
rotate.angleProperty().bind(this.rotation);
);


enter image description here



enter image description here



enter image description here



When you rotate the rectangle, its coordinate axis rotates with it.
enter image description here



How to make it so that when you update the coordinate axis in the initial position?










share|improve this question















closed as unclear what you're asking by user1803551, cнŝdk, Unheilig, EdChum, Max Vollmer Nov 22 '18 at 12:27


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.













  • 3





    Can you include more details in your question. Like what is the parent of your Rectangle,. and a bit ENGLISH descriptions for your images. I am not sure about others, I cannot understand what you are trying to tell from 2nd and 3rd images. Please provide a Minimal, Complete, and Verifiable example

    – Sai Dandem
    Nov 14 '18 at 5:22











  • Unclear and no Minimal, Complete, and Verifiable example. What is "coordinate proxy"? What region moves up?

    – user1803551
    Nov 22 '18 at 6:48















-1















I have an application in which I draw a rectangle and then turn it 90 degrees. In this case, I have a frame with which I can move my rectangle. But after I turned it (an example of 90 degrees), when the region moves up, the rectangle itself moves to the right. When rotating, what does the coordinate proxy of the shape itself turn?
Rotation code:



this.rotation.addListener((obs, old, fresh) -> 
Rotate rotate = new Rotate((double) fresh - (double) old,
x.getValue().doubleValue() + (width.getValue().doubleValue() / 2),
y.getValue().doubleValue() + (height.getValue().doubleValue() / 2));
shape.getTransforms().add(rotate);
rotate.angleProperty().bind(this.rotation);
);


enter image description here



enter image description here



enter image description here



When you rotate the rectangle, its coordinate axis rotates with it.
enter image description here



How to make it so that when you update the coordinate axis in the initial position?










share|improve this question















closed as unclear what you're asking by user1803551, cнŝdk, Unheilig, EdChum, Max Vollmer Nov 22 '18 at 12:27


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.













  • 3





    Can you include more details in your question. Like what is the parent of your Rectangle,. and a bit ENGLISH descriptions for your images. I am not sure about others, I cannot understand what you are trying to tell from 2nd and 3rd images. Please provide a Minimal, Complete, and Verifiable example

    – Sai Dandem
    Nov 14 '18 at 5:22











  • Unclear and no Minimal, Complete, and Verifiable example. What is "coordinate proxy"? What region moves up?

    – user1803551
    Nov 22 '18 at 6:48













-1












-1








-1








I have an application in which I draw a rectangle and then turn it 90 degrees. In this case, I have a frame with which I can move my rectangle. But after I turned it (an example of 90 degrees), when the region moves up, the rectangle itself moves to the right. When rotating, what does the coordinate proxy of the shape itself turn?
Rotation code:



this.rotation.addListener((obs, old, fresh) -> 
Rotate rotate = new Rotate((double) fresh - (double) old,
x.getValue().doubleValue() + (width.getValue().doubleValue() / 2),
y.getValue().doubleValue() + (height.getValue().doubleValue() / 2));
shape.getTransforms().add(rotate);
rotate.angleProperty().bind(this.rotation);
);


enter image description here



enter image description here



enter image description here



When you rotate the rectangle, its coordinate axis rotates with it.
enter image description here



How to make it so that when you update the coordinate axis in the initial position?










share|improve this question
















I have an application in which I draw a rectangle and then turn it 90 degrees. In this case, I have a frame with which I can move my rectangle. But after I turned it (an example of 90 degrees), when the region moves up, the rectangle itself moves to the right. When rotating, what does the coordinate proxy of the shape itself turn?
Rotation code:



this.rotation.addListener((obs, old, fresh) -> 
Rotate rotate = new Rotate((double) fresh - (double) old,
x.getValue().doubleValue() + (width.getValue().doubleValue() / 2),
y.getValue().doubleValue() + (height.getValue().doubleValue() / 2));
shape.getTransforms().add(rotate);
rotate.angleProperty().bind(this.rotation);
);


enter image description here



enter image description here



enter image description here



When you rotate the rectangle, its coordinate axis rotates with it.
enter image description here



How to make it so that when you update the coordinate axis in the initial position?







java javafx






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 7:15







A1ex NS

















asked Nov 14 '18 at 4:43









A1ex NSA1ex NS

205




205




closed as unclear what you're asking by user1803551, cнŝdk, Unheilig, EdChum, Max Vollmer Nov 22 '18 at 12:27


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









closed as unclear what you're asking by user1803551, cнŝdk, Unheilig, EdChum, Max Vollmer Nov 22 '18 at 12:27


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









  • 3





    Can you include more details in your question. Like what is the parent of your Rectangle,. and a bit ENGLISH descriptions for your images. I am not sure about others, I cannot understand what you are trying to tell from 2nd and 3rd images. Please provide a Minimal, Complete, and Verifiable example

    – Sai Dandem
    Nov 14 '18 at 5:22











  • Unclear and no Minimal, Complete, and Verifiable example. What is "coordinate proxy"? What region moves up?

    – user1803551
    Nov 22 '18 at 6:48












  • 3





    Can you include more details in your question. Like what is the parent of your Rectangle,. and a bit ENGLISH descriptions for your images. I am not sure about others, I cannot understand what you are trying to tell from 2nd and 3rd images. Please provide a Minimal, Complete, and Verifiable example

    – Sai Dandem
    Nov 14 '18 at 5:22











  • Unclear and no Minimal, Complete, and Verifiable example. What is "coordinate proxy"? What region moves up?

    – user1803551
    Nov 22 '18 at 6:48







3




3





Can you include more details in your question. Like what is the parent of your Rectangle,. and a bit ENGLISH descriptions for your images. I am not sure about others, I cannot understand what you are trying to tell from 2nd and 3rd images. Please provide a Minimal, Complete, and Verifiable example

– Sai Dandem
Nov 14 '18 at 5:22





Can you include more details in your question. Like what is the parent of your Rectangle,. and a bit ENGLISH descriptions for your images. I am not sure about others, I cannot understand what you are trying to tell from 2nd and 3rd images. Please provide a Minimal, Complete, and Verifiable example

– Sai Dandem
Nov 14 '18 at 5:22













Unclear and no Minimal, Complete, and Verifiable example. What is "coordinate proxy"? What region moves up?

– user1803551
Nov 22 '18 at 6:48





Unclear and no Minimal, Complete, and Verifiable example. What is "coordinate proxy"? What region moves up?

– user1803551
Nov 22 '18 at 6:48












1 Answer
1






active

oldest

votes


















1














I don't truly understand your question but here is an example that demos rotating and moving a rectangle. Double click the rectangle to rotate it. (Double click is not perfect if clicking too fast.). Drag the rectangle to move it.



import javafx.application.Application;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.geometry.Point2D;
import javafx.scene.Scene;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.transform.Rotate;
import javafx.stage.Stage;

public class JavaFXApplication extends Application


final ObjectProperty<Point2D> mousePosition = new SimpleObjectProperty<>();

public static void main(String args)


Application.launch(args);


@Override
public void start(Stage primaryStage)

Rotate rotate = new Rotate();

Rectangle rectangle = new Rectangle(33, 100, Color.GREEN);
rectangle.setX((1200 / 2) - (33 / 2));
rectangle.setY((900 / 2) - (100 / 2));
rectangle.rotateProperty().bind(rotate.angleProperty());
rectangle.setOnMouseClicked((event) ->
if (event.getButton().equals(MouseButton.PRIMARY))
if (event.getClickCount() == 2)
System.out.println("Double Clicked!");
rotate.setAngle(rotate.getAngle() + 90);



);

rectangle.setOnMousePressed((MouseEvent event) ->
mousePosition.set(new Point2D(event.getSceneX(), event.getSceneY()));
);

rectangle.setOnMouseDragged((MouseEvent event) ->
double deltaX = event.getSceneX() - mousePosition.get().getX();
double deltaY = event.getSceneY() - mousePosition.get().getY();
rectangle.setLayoutX(rectangle.getLayoutX() + deltaX);
rectangle.setLayoutY(rectangle.getLayoutY() + deltaY);
mousePosition.set(new Point2D(event.getSceneX(), event.getSceneY()));
);

Pane root = new Pane(rectangle);

Scene scene = new Scene(root, 1200, 900, Color.LIGHTGRAY);
primaryStage.setScene(scene);
primaryStage.setTitle("Path Transition Example");
primaryStage.show();







share|improve this answer























  • Thank you, I'll see later

    – A1ex NS
    Nov 15 '18 at 9:10

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














I don't truly understand your question but here is an example that demos rotating and moving a rectangle. Double click the rectangle to rotate it. (Double click is not perfect if clicking too fast.). Drag the rectangle to move it.



import javafx.application.Application;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.geometry.Point2D;
import javafx.scene.Scene;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.transform.Rotate;
import javafx.stage.Stage;

public class JavaFXApplication extends Application


final ObjectProperty<Point2D> mousePosition = new SimpleObjectProperty<>();

public static void main(String args)


Application.launch(args);


@Override
public void start(Stage primaryStage)

Rotate rotate = new Rotate();

Rectangle rectangle = new Rectangle(33, 100, Color.GREEN);
rectangle.setX((1200 / 2) - (33 / 2));
rectangle.setY((900 / 2) - (100 / 2));
rectangle.rotateProperty().bind(rotate.angleProperty());
rectangle.setOnMouseClicked((event) ->
if (event.getButton().equals(MouseButton.PRIMARY))
if (event.getClickCount() == 2)
System.out.println("Double Clicked!");
rotate.setAngle(rotate.getAngle() + 90);



);

rectangle.setOnMousePressed((MouseEvent event) ->
mousePosition.set(new Point2D(event.getSceneX(), event.getSceneY()));
);

rectangle.setOnMouseDragged((MouseEvent event) ->
double deltaX = event.getSceneX() - mousePosition.get().getX();
double deltaY = event.getSceneY() - mousePosition.get().getY();
rectangle.setLayoutX(rectangle.getLayoutX() + deltaX);
rectangle.setLayoutY(rectangle.getLayoutY() + deltaY);
mousePosition.set(new Point2D(event.getSceneX(), event.getSceneY()));
);

Pane root = new Pane(rectangle);

Scene scene = new Scene(root, 1200, 900, Color.LIGHTGRAY);
primaryStage.setScene(scene);
primaryStage.setTitle("Path Transition Example");
primaryStage.show();







share|improve this answer























  • Thank you, I'll see later

    – A1ex NS
    Nov 15 '18 at 9:10















1














I don't truly understand your question but here is an example that demos rotating and moving a rectangle. Double click the rectangle to rotate it. (Double click is not perfect if clicking too fast.). Drag the rectangle to move it.



import javafx.application.Application;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.geometry.Point2D;
import javafx.scene.Scene;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.transform.Rotate;
import javafx.stage.Stage;

public class JavaFXApplication extends Application


final ObjectProperty<Point2D> mousePosition = new SimpleObjectProperty<>();

public static void main(String args)


Application.launch(args);


@Override
public void start(Stage primaryStage)

Rotate rotate = new Rotate();

Rectangle rectangle = new Rectangle(33, 100, Color.GREEN);
rectangle.setX((1200 / 2) - (33 / 2));
rectangle.setY((900 / 2) - (100 / 2));
rectangle.rotateProperty().bind(rotate.angleProperty());
rectangle.setOnMouseClicked((event) ->
if (event.getButton().equals(MouseButton.PRIMARY))
if (event.getClickCount() == 2)
System.out.println("Double Clicked!");
rotate.setAngle(rotate.getAngle() + 90);



);

rectangle.setOnMousePressed((MouseEvent event) ->
mousePosition.set(new Point2D(event.getSceneX(), event.getSceneY()));
);

rectangle.setOnMouseDragged((MouseEvent event) ->
double deltaX = event.getSceneX() - mousePosition.get().getX();
double deltaY = event.getSceneY() - mousePosition.get().getY();
rectangle.setLayoutX(rectangle.getLayoutX() + deltaX);
rectangle.setLayoutY(rectangle.getLayoutY() + deltaY);
mousePosition.set(new Point2D(event.getSceneX(), event.getSceneY()));
);

Pane root = new Pane(rectangle);

Scene scene = new Scene(root, 1200, 900, Color.LIGHTGRAY);
primaryStage.setScene(scene);
primaryStage.setTitle("Path Transition Example");
primaryStage.show();







share|improve this answer























  • Thank you, I'll see later

    – A1ex NS
    Nov 15 '18 at 9:10













1












1








1







I don't truly understand your question but here is an example that demos rotating and moving a rectangle. Double click the rectangle to rotate it. (Double click is not perfect if clicking too fast.). Drag the rectangle to move it.



import javafx.application.Application;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.geometry.Point2D;
import javafx.scene.Scene;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.transform.Rotate;
import javafx.stage.Stage;

public class JavaFXApplication extends Application


final ObjectProperty<Point2D> mousePosition = new SimpleObjectProperty<>();

public static void main(String args)


Application.launch(args);


@Override
public void start(Stage primaryStage)

Rotate rotate = new Rotate();

Rectangle rectangle = new Rectangle(33, 100, Color.GREEN);
rectangle.setX((1200 / 2) - (33 / 2));
rectangle.setY((900 / 2) - (100 / 2));
rectangle.rotateProperty().bind(rotate.angleProperty());
rectangle.setOnMouseClicked((event) ->
if (event.getButton().equals(MouseButton.PRIMARY))
if (event.getClickCount() == 2)
System.out.println("Double Clicked!");
rotate.setAngle(rotate.getAngle() + 90);



);

rectangle.setOnMousePressed((MouseEvent event) ->
mousePosition.set(new Point2D(event.getSceneX(), event.getSceneY()));
);

rectangle.setOnMouseDragged((MouseEvent event) ->
double deltaX = event.getSceneX() - mousePosition.get().getX();
double deltaY = event.getSceneY() - mousePosition.get().getY();
rectangle.setLayoutX(rectangle.getLayoutX() + deltaX);
rectangle.setLayoutY(rectangle.getLayoutY() + deltaY);
mousePosition.set(new Point2D(event.getSceneX(), event.getSceneY()));
);

Pane root = new Pane(rectangle);

Scene scene = new Scene(root, 1200, 900, Color.LIGHTGRAY);
primaryStage.setScene(scene);
primaryStage.setTitle("Path Transition Example");
primaryStage.show();







share|improve this answer













I don't truly understand your question but here is an example that demos rotating and moving a rectangle. Double click the rectangle to rotate it. (Double click is not perfect if clicking too fast.). Drag the rectangle to move it.



import javafx.application.Application;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.geometry.Point2D;
import javafx.scene.Scene;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.transform.Rotate;
import javafx.stage.Stage;

public class JavaFXApplication extends Application


final ObjectProperty<Point2D> mousePosition = new SimpleObjectProperty<>();

public static void main(String args)


Application.launch(args);


@Override
public void start(Stage primaryStage)

Rotate rotate = new Rotate();

Rectangle rectangle = new Rectangle(33, 100, Color.GREEN);
rectangle.setX((1200 / 2) - (33 / 2));
rectangle.setY((900 / 2) - (100 / 2));
rectangle.rotateProperty().bind(rotate.angleProperty());
rectangle.setOnMouseClicked((event) ->
if (event.getButton().equals(MouseButton.PRIMARY))
if (event.getClickCount() == 2)
System.out.println("Double Clicked!");
rotate.setAngle(rotate.getAngle() + 90);



);

rectangle.setOnMousePressed((MouseEvent event) ->
mousePosition.set(new Point2D(event.getSceneX(), event.getSceneY()));
);

rectangle.setOnMouseDragged((MouseEvent event) ->
double deltaX = event.getSceneX() - mousePosition.get().getX();
double deltaY = event.getSceneY() - mousePosition.get().getY();
rectangle.setLayoutX(rectangle.getLayoutX() + deltaX);
rectangle.setLayoutY(rectangle.getLayoutY() + deltaY);
mousePosition.set(new Point2D(event.getSceneX(), event.getSceneY()));
);

Pane root = new Pane(rectangle);

Scene scene = new Scene(root, 1200, 900, Color.LIGHTGRAY);
primaryStage.setScene(scene);
primaryStage.setTitle("Path Transition Example");
primaryStage.show();








share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 14 '18 at 15:34









SedrickSedrick

6,35532039




6,35532039












  • Thank you, I'll see later

    – A1ex NS
    Nov 15 '18 at 9:10

















  • Thank you, I'll see later

    – A1ex NS
    Nov 15 '18 at 9:10
















Thank you, I'll see later

– A1ex NS
Nov 15 '18 at 9:10





Thank you, I'll see later

– A1ex NS
Nov 15 '18 at 9:10





Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo