Java Code Examples for javafx.scene.shape.Rectangle#setLayoutY()

The following examples show how to use javafx.scene.shape.Rectangle#setLayoutY() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StopWatchSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private Rectangle createTic(double angle, double width, double height) {
    Rectangle rectangle = new Rectangle(-width / 2, -height / 2, width, height);
    rectangle.setFill(Color.rgb(10, 10, 10));
    rectangle.setRotate(angle);
    rectangle.setLayoutX(radius * Math.cos(Math.toRadians(angle)));
    rectangle.setLayoutY(radius * Math.sin(Math.toRadians(angle)));
    return rectangle;
}
 
Example 2
Source File: NodePropertiesSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public NodePropertiesSample() {
    super(300,100);
    //X position of node = X + LayoutX + TranslateX
    rectA = new Rectangle(50, 50, Color.LIGHTSALMON);
    //set position of node temporary (can be changed after)
    rectA.setTranslateX(10);

    rectB = new Rectangle(50, 50, Color.LIGHTGREEN);
    //set position of node when addinf to some layout
    rectB.setLayoutX(20);
    rectB.setLayoutY(10);

    rectC = new Rectangle(50, 50, Color.DODGERBLUE);
    //last posibility of setting X position of node
    rectC.setX(30);
    rectC.setY(20);

    //opacity of node can be set
    rectC.setOpacity(0.8);

    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Rectangle A translate X", rectA.translateXProperty(), 0d, 50d),
            new SimplePropertySheet.PropDesc("Rectangle B translate X", rectB.translateXProperty(), 0d, 50d),
            new SimplePropertySheet.PropDesc("Rectangle C translate X", rectC.translateXProperty(), 0d, 50d),
            new SimplePropertySheet.PropDesc("Rectangle A Opacity", rectA.opacityProperty(), 0d, 1d),
            new SimplePropertySheet.PropDesc("Rectangle B Opacity", rectB.opacityProperty(), 0d, 1d),
            new SimplePropertySheet.PropDesc("Rectangle C Opacity", rectC.opacityProperty(), 0d, 1d)
            );

    getChildren().add(createRadioButtons());
    // END REMOVE ME

    Group g = new Group(rectA, rectB, rectC);
    g.setLayoutX(160 + 35);
    getChildren().addAll(g);
}
 
Example 3
Source File: StopWatchSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private Rectangle createTic(double angle, double width, double height) {
    Rectangle rectangle = new Rectangle(-width / 2, -height / 2, width, height);
    rectangle.setFill(Color.rgb(10, 10, 10));
    rectangle.setRotate(angle);
    rectangle.setLayoutX(radius * Math.cos(Math.toRadians(angle)));
    rectangle.setLayoutY(radius * Math.sin(Math.toRadians(angle)));
    return rectangle;
}
 
Example 4
Source File: NodePropertiesSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public NodePropertiesSample() {
    super(300,100);
    //X position of node = X + LayoutX + TranslateX
    rectA = new Rectangle(50, 50, Color.LIGHTSALMON);
    //set position of node temporary (can be changed after)
    rectA.setTranslateX(10);

    rectB = new Rectangle(50, 50, Color.LIGHTGREEN);
    //set position of node when addinf to some layout
    rectB.setLayoutX(20);
    rectB.setLayoutY(10);

    rectC = new Rectangle(50, 50, Color.DODGERBLUE);
    //last posibility of setting X position of node
    rectC.setX(30);
    rectC.setY(20);

    //opacity of node can be set
    rectC.setOpacity(0.8);

    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Rectangle A translate X", rectA.translateXProperty(), 0d, 50d),
            new SimplePropertySheet.PropDesc("Rectangle B translate X", rectB.translateXProperty(), 0d, 50d),
            new SimplePropertySheet.PropDesc("Rectangle C translate X", rectC.translateXProperty(), 0d, 50d),
            new SimplePropertySheet.PropDesc("Rectangle A Opacity", rectA.opacityProperty(), 0d, 1d),
            new SimplePropertySheet.PropDesc("Rectangle B Opacity", rectB.opacityProperty(), 0d, 1d),
            new SimplePropertySheet.PropDesc("Rectangle C Opacity", rectC.opacityProperty(), 0d, 1d)
            );

    getChildren().add(createRadioButtons());
    // END REMOVE ME

    Group g = new Group(rectA, rectB, rectC);
    g.setLayoutX(160 + 35);
    getChildren().addAll(g);
}
 
Example 5
Source File: StopWatch.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Rectangle createTic(double angle, double width, double height) {
    Rectangle rectangle = new Rectangle(-width / 2, -height / 2, width, height);
    rectangle.setFill(Color.rgb(10, 10, 10));
    rectangle.setRotate(angle);
    rectangle.setLayoutX(radius * Math.cos(Math.toRadians(angle)));
    rectangle.setLayoutY(radius * Math.sin(Math.toRadians(angle)));
    return rectangle;
}
 
Example 6
Source File: MouseDragSnippet.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
private Node generate(double w, double h) {
	double rx = Math.random() * (w - 100);
	double ry = Math.random() * (h - 100);
	double rw = Math.random() * 90 + 10;
	double rh = Math.random() * 90 + 10;
	Rectangle rectangle = new Rectangle(0, 0, rw, rh);
	rectangle.setLayoutX(rx);
	rectangle.setLayoutY(ry);
	rectangle.setFill(
			new Color(Math.random(), Math.random(), Math.random(), 0.5));
	rectangle.setStroke(Color.TRANSPARENT);
	return rectangle;
}
 
Example 7
Source File: Callout.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
protected Animation buildSubtitleRectAnim(HBox mainTitleBackground, Rectangle subTitleRect) {

        // Small rectangle (prompt)
        // Calculate main title width and height upfront
        Rectangle2D mainTitleBounds = getBoundsUpfront(mainTitleBackground);

        double mainTitleWidth = mainTitleBounds.getWidth();
        double mainTitleHeight = mainTitleBounds.getHeight();

        // Position of the end
        Point2D endPointLL = calcEndPointOfLeaderLine();
        double x = endPointLL.getX();
        double y = endPointLL.getY();

        int direction = getEndLeaderLineDirection();
        if (direction == LEFT) {
            subTitleRect.setLayoutX( x + (subTitleRect.getWidth() * direction));
        } else {
            subTitleRect.setLayoutX( x );
        }


        subTitleRect.setLayoutY( y + (mainTitleHeight/2) + 2);

        return new Timeline(
                new KeyFrame(Duration.millis(1),
                        new KeyValue(subTitleRect.visibleProperty(), true),
                        new KeyValue(subTitleRect.heightProperty(), 0)), // show
                new KeyFrame(Duration.millis(300),
                        new KeyValue(subTitleRect.heightProperty(), 20)
                )
        );
    }
 
Example 8
Source File: Canvas.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
private void setVisibleSelectionBorder(final double x, final double y, final double w, final double h, final boolean ongoing) {
	final Rectangle rec = ongoing ? ongoingSelectionBorder : selectionBorder;
	rec.setLayoutX(x);
	rec.setLayoutY(y);
	rec.setWidth(w);
	rec.setHeight(h);
	rec.setVisible(true);
}