new progress , succeded in moving the node with the mouse still not
finished tho
This commit is contained in:
parent
895b20b680
commit
bb5e2ff401
@ -56,17 +56,16 @@ public class Piece extends Application{
|
|||||||
//Instantiating RotateTransition class to create the animation (rotation to the left)
|
//Instantiating RotateTransition class to create the animation (rotation to the left)
|
||||||
RotateTransition rotatelft = new RotateTransition();
|
RotateTransition rotatelft = new RotateTransition();
|
||||||
//setting attributes for the RotateTransition
|
//setting attributes for the RotateTransition
|
||||||
rotatelft.setByAngle(-90);
|
rotatelft.setByAngle(-90);// minus to rotate to the left
|
||||||
rotatelft.autoReverseProperty();
|
rotatelft.autoReverseProperty();
|
||||||
rotatelft.setDuration(Duration.millis(1000));
|
rotatelft.setDuration(Duration.millis(1000));
|
||||||
rotatelft.setNode(piece1);
|
rotatelft.setNode(piece1);
|
||||||
rotatelft.setAxis(Rotate.Z_AXIS);
|
rotatelft.setAxis(Rotate.Z_AXIS);
|
||||||
|
|
||||||
/* */
|
//Mouse events handling
|
||||||
|
piece1.setOnMousePressed(new EventHandler<MouseEvent>() {
|
||||||
piece1.setOnMousePressed(new EventHandler<MouseEvent>() {
|
|
||||||
@Override public void handle(MouseEvent mouseEvent) {
|
@Override public void handle(MouseEvent mouseEvent) {
|
||||||
// record a delta distance for the drag and drop operation.
|
// record a (x,y) distance for the drag and drop operation.
|
||||||
x = piece1.getLayoutX() - mouseEvent.getSceneX();
|
x = piece1.getLayoutX() - mouseEvent.getSceneX();
|
||||||
y = piece1.getLayoutY() - mouseEvent.getSceneY();
|
y = piece1.getLayoutY() - mouseEvent.getSceneY();
|
||||||
piece1.setCursor(Cursor.CLOSED_HAND);
|
piece1.setCursor(Cursor.CLOSED_HAND);
|
||||||
@ -96,9 +95,6 @@ public class Piece extends Application{
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
scene.setOnKeyPressed(new EventHandler<KeyEvent>() {
|
scene.setOnKeyPressed(new EventHandler<KeyEvent>() {
|
||||||
|
|
||||||
@ -115,23 +111,6 @@ public class Piece extends Application{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public void pressed(MouseEvent event, Polygon piece1) {
|
|
||||||
piece1.setFill(Color.AZURE);
|
|
||||||
int x = piece1.getLayoutX() - MouseEvent.getSceneX();
|
|
||||||
int y = piece1.getLayoutY() - MouseEvent.getSceneY();
|
|
||||||
piece1.setCursor(Cursor.MOVE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dragged(MouseEvent event, Polygon piece1) {
|
|
||||||
piece1.setLayoutX(event.getSceneX()+ x);
|
|
||||||
piece1.setLayoutY(event.getSceneY()+ y);
|
|
||||||
piece1.draw();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void released(MouseEvent event, Polygon piece1) {
|
|
||||||
piece1.setCursor(Cursor.HAND);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
launch(args);
|
launch(args);
|
||||||
|
Loading…
Reference in New Issue
Block a user