Example usage for javafx.scene.transform Rotate rotate

List of usage examples for javafx.scene.transform Rotate rotate

Introduction

In this page you can find the example usage for javafx.scene.transform Rotate rotate.

Prototype

public static Rotate rotate(double angle, double pivotX, double pivotY) 

Source Link

Document

Returns a Rotate object that rotates coordinates around a pivot point.

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Sample");
    stage.setWidth(300);//from   w  w w .  j  a v  a2  s  .com
    stage.setHeight(190);

    VBox vbox = new VBox();
    vbox.setLayoutX(20);
    vbox.setLayoutY(20);

    Rectangle rect = new Rectangle(50, 50, Color.RED);
    rect.getTransforms().add(new Rotate(45, 0, 0)); //

    vbox.getChildren().add(rect);
    vbox.setSpacing(10);
    ((Group) scene.getRoot()).getChildren().add(vbox);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Rectangle rect1 = new Rectangle(100, 50, Color.LIGHTGRAY);
    rect1.setStroke(Color.BLACK);

    Rectangle rect2 = new Rectangle(100, 50, Color.YELLOW);
    rect2.setStroke(Color.BLACK);

    Translate translate = new Translate(50, 10);
    Rotate rotate = new Rotate(30, 0, 0);
    Scale scale = new Scale(0.5, 0.5);
    Shear shear = new Shear(0.5, 0.5);
    rect2.getTransforms().addAll(translate, rotate, scale, shear);

    Pane root = new Pane(rect1, rect2);
    root.setPrefSize(200, 100);/*from  ww w  .ja va 2  s  . com*/
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.setTitle("");
    stage.show();
}