You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.
Hola, estoy medio trabado en la parte de implementar que la figura gire a la derecha. Estuve viendo en stackoverflow y otras paginas, y vi que existe una clase Rotate donde le podes indicar el angulo, pero los ejemplos que hay utilizan ya las clases Rectangle por ejemplo que tienen un metodo getTransforms y en mi caso hice una clase abstracta Figure. Se espera que utilizemos Rotate de alguna manera o tendria que hacer algo como un metodo abstracto rotate en Figure ?
Este es uno de los ejemplos que encontre para que se entienda a lo que me refiero
public class RotationExample extends Application {
public void start(Stage stage) {
//Creating a rectangle
Rectangle rect = new Rectangle(300, 100, 75, 75);
rect.setFill(Color.BLUEVIOLET);
rect.setStrokeWidth(5.0);
rect.setStroke(Color.BROWN);
//Setting the slider
Slider slider = new Slider(0, 360, 0);
slider.setShowTickLabels(true);
slider.setShowTickMarks(true);
slider.setMajorTickUnit(90);
slider.setBlockIncrement(10);
slider.setOrientation(Orientation.VERTICAL);
slider.setLayoutX(2);
slider.setLayoutY(195);
//creating the rotation transformation
Rotate rotate = new Rotate();
//Setting pivot points for the rotation
rotate.setPivotX(300);
rotate.setPivotY(100);
//Adding the transformation to rectangle
rect.getTransforms().addAll(rotate);
//Linking the transformation to the slider
slider.valueProperty().addListener(new ChangeListener() {
public void changed(ObservableValue <?extends Number>observable, Number oldValue, Number newValue){
//Setting the angle for the rotation
rotate.setAngle((double) newValue);
}
});
//Adding the transformation to the circle
rect.getTransforms().add(rotate);
//Creating the pane
BorderPane pane = new BorderPane();
pane.setRight(new VBox(new Label("Rotate"), slider));
pane.setCenter(rect);
//Preparing the scene
Scene scene = new Scene(pane, 600, 300);
stage.setTitle("Rotation Example");
stage.setScene(scene);
stage.show();
}
public static void main(String args[]){
launch(args);
}
}
The text was updated successfully, but these errors were encountered:
Hola.
No contestamos dudas sobre implementación así que no voy a comentar sobre el código.
Lo que si te puedo decir es que tienen que implementar ustedes la operación geométrica para girar una figura en el plano, haciendo las operaciones necesarias. La clase de JavaFX que mencionás no es compatible con tu figura.
Gracias Franco. Tengo otra duda, al apretar Girar D una vez la figura tiene que rotarse horizontalmente. Si apretamos girar D nuevamente tiene que volver a su posicion original, o hacemos que siga rotando?
Hola, estoy medio trabado en la parte de implementar que la figura gire a la derecha. Estuve viendo en stackoverflow y otras paginas, y vi que existe una clase Rotate donde le podes indicar el angulo, pero los ejemplos que hay utilizan ya las clases Rectangle por ejemplo que tienen un metodo getTransforms y en mi caso hice una clase abstracta Figure. Se espera que utilizemos Rotate de alguna manera o tendria que hacer algo como un metodo abstracto rotate en Figure ?
Este es uno de los ejemplos que encontre para que se entienda a lo que me refiero
public class RotationExample extends Application {
public void start(Stage stage) {
//Creating a rectangle
Rectangle rect = new Rectangle(300, 100, 75, 75);
rect.setFill(Color.BLUEVIOLET);
rect.setStrokeWidth(5.0);
rect.setStroke(Color.BROWN);
//Setting the slider
Slider slider = new Slider(0, 360, 0);
slider.setShowTickLabels(true);
slider.setShowTickMarks(true);
slider.setMajorTickUnit(90);
slider.setBlockIncrement(10);
slider.setOrientation(Orientation.VERTICAL);
slider.setLayoutX(2);
slider.setLayoutY(195);
//creating the rotation transformation
Rotate rotate = new Rotate();
//Setting pivot points for the rotation
rotate.setPivotX(300);
rotate.setPivotY(100);
//Adding the transformation to rectangle
rect.getTransforms().addAll(rotate);
//Linking the transformation to the slider
slider.valueProperty().addListener(new ChangeListener() {
public void changed(ObservableValue <?extends Number>observable, Number oldValue, Number newValue){
//Setting the angle for the rotation
rotate.setAngle((double) newValue);
}
});
//Adding the transformation to the circle
rect.getTransforms().add(rotate);
//Creating the pane
BorderPane pane = new BorderPane();
pane.setRight(new VBox(new Label("Rotate"), slider));
pane.setCenter(rect);
//Preparing the scene
Scene scene = new Scene(pane, 600, 300);
stage.setTitle("Rotation Example");
stage.setScene(scene);
stage.show();
}
public static void main(String args[]){
launch(args);
}
}
The text was updated successfully, but these errors were encountered: