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

The following examples show how to use javafx.scene.shape.Rectangle#setTranslateX() . 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: StarsComponent.java    From FXGLGames with MIT License 6 votes vote down vote up
private void respawn(Rectangle star) {
    star.setWidth(random(0.5f, 2.5f));
    star.setHeight(random(0.5f, 2.5f));
    star.setArcWidth(random(0.5f, 2.5f));
    star.setArcHeight(random(0.5f, 2.5f));

    star.setFill(Color.color(
            random(0.75, 1.0),
            random(0.75, 1.0),
            random(0.75, 1.0),
            random(0.5f, 1.0f)
    ));

    star.setTranslateX(random(0, FXGL.getAppWidth()));
    star.setTranslateY(-random(10, FXGL.getAppHeight()));
}
 
Example 2
Source File: StarsComponent.java    From FXGLGames with MIT License 6 votes vote down vote up
private void respawn(Rectangle star) {
    star.setWidth(random(0.5f, 2.5f));
    star.setHeight(random(0.5f, 2.5f));
    star.setArcWidth(random(0.5f, 2.5f));
    star.setArcHeight(random(0.5f, 2.5f));

    star.setFill(Color.color(
            random(0.75, 1.0),
            random(0.75, 1.0),
            random(0.75, 1.0),
            random(0.5f, 1.0f)
    ));

    star.setTranslateX(random(0, FXGL.getAppWidth()));
    star.setTranslateY(-random(10, FXGL.getAppHeight()));
}
 
Example 3
Source File: PauseTransitionSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public PauseTransitionSample() {
    super(400,150);
    // create rectangle
    Rectangle rect = new Rectangle(-25,-25,50, 50);
    rect.setArcHeight(15);
    rect.setArcWidth(15);
    rect.setFill(Color.CRIMSON);
    rect.setTranslateX(50);
    rect.setTranslateY(75);
    getChildren().add(rect);
    
    animation = SequentialTransitionBuilder.create()
        .node(rect)
        .children(
            TranslateTransitionBuilder.create()
                .duration(Duration.seconds(2))
                .fromX(50)
                .toX(200)
                .build(),
            PauseTransitionBuilder.create()
                .duration(Duration.seconds(2))
                .build(),
            TranslateTransitionBuilder.create()
                .duration(Duration.seconds(2))
                .fromX(200)
                .toX(350)
                .build()
        )
        .cycleCount(Timeline.INDEFINITE)
        .autoReverse(true)
        .build();                
}
 
Example 4
Source File: Main.java    From FXTutorials with MIT License 5 votes vote down vote up
private Node createEntity(int x, int y, int w, int h, Color color) {
    Rectangle entity = new Rectangle(w, h);
    entity.setTranslateX(x);
    entity.setTranslateY(y);
    entity.setFill(color);
    entity.getProperties().put("alive", true);

    gameRoot.getChildren().add(entity);
    return entity;
}
 
Example 5
Source File: CubeWorld.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
private void buildPanels(double size) {
    //@SMP TODO might be easier to just replace the Rectangle side panels with really flat Box 3D objects
    x1AxisRectangle = new Rectangle(size, size, panelWallColor);
    x2AxisRectangle = new Rectangle(size, size, panelWallColor);
    y1AxisRectangle = new Rectangle(size, size, panelWallColor);
    y2AxisRectangle = new Rectangle(size, size, panelWallColor);
    z1AxisRectangle = new Rectangle(size, size, panelFloorColor);
    z2AxisRectangle = new Rectangle(size, size, panelCeilingColor);

    x1AxisRectangle.setTranslateX(-size / 2);
    x1AxisRectangle.setTranslateY(-size / 2);
    x1AxisRectangle.setTranslateZ(-size / 2);
    x2AxisRectangle.setTranslateX(-size / 2);
    x2AxisRectangle.setTranslateY(-size / 2);
    x2AxisRectangle.setTranslateZ(size / 2);
    getChildren().addAll(x1AxisRectangle, x2AxisRectangle);

    y2AxisRectangle.setTranslateY(-size / 2);
    y2AxisRectangle.setRotationAxis(Rotate.Y_AXIS);
    y2AxisRectangle.setRotate(89.9);
    y1AxisRectangle.setTranslateX(-size);
    y1AxisRectangle.setTranslateY(-size / 2);
    y1AxisRectangle.setRotationAxis(Rotate.Y_AXIS);
    y1AxisRectangle.setRotate(89.9);
    getChildren().addAll(y1AxisRectangle, y2AxisRectangle);

    z1AxisRectangle.setTranslateX(-size / 2);
    z1AxisRectangle.setRotationAxis(Rotate.X_AXIS);
    z1AxisRectangle.setRotate(89.9);
    z2AxisRectangle.setTranslateX(-size / 2);
    z2AxisRectangle.setTranslateY(-size);
    z2AxisRectangle.setRotationAxis(Rotate.X_AXIS);
    z2AxisRectangle.setRotate(89.9);
    getChildren().addAll(z1AxisRectangle, z2AxisRectangle);
}
 
Example 6
Source File: AudioClipSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public static Group createRectangle(Color color, double tx, double ty, double sx, double sy) {
    Group squareGroup = new Group();
    Rectangle squareShape = new Rectangle(1.0, 1.0);
    squareShape.setFill(color);
    squareShape.setTranslateX(-0.5);
    squareShape.setTranslateY(-0.5);
    squareGroup.getChildren().add(squareShape);
    squareGroup.setTranslateX(tx);
    squareGroup.setTranslateY(ty);
    squareGroup.setScaleX(sx);
    squareGroup.setScaleY(sy);
    return squareGroup;
}
 
Example 7
Source File: RadialGlobalMenu.java    From RadialFx with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void computeBack() {
final Rectangle rect = new Rectangle();
rect.setWidth(widthProp.get());
rect.setHeight(heightProp.get());
rect.setTranslateX(widthProp.get() / -2.0);
rect.setTranslateY(heightProp.get() / -2.0);

final RadialGradient radialGradient = new RadialGradient(0, 0,
	widthProp.get() / 2.0, heightProp.get() / 2.0,
	widthProp.get() / 2.0, false, CycleMethod.NO_CYCLE, new Stop(0,
		Color.TRANSPARENT), new Stop(1, BACK_GRADIENT_COLOR));

rect.setFill(radialGradient);
backContainer.getChildren().setAll(rect);
   }
 
Example 8
Source File: TranslateSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public TranslateSample() {
    super(230, 220);

    //create 2 rectangles with different color
    Rectangle rect1 = new Rectangle(90, 90, Color.web("#ed4b00", 0.75));
    Rectangle rect2 = new Rectangle(90, 90, Color.web("#ed4b00", 0.5));

    //translate second one
    rect2.setTranslateX(140);

    // rectangle with adjustable translate
    Rectangle rect3 = new Rectangle(40, 130, 60, 60);
    rect3.setFill(Color.DODGERBLUE);
    rect3.setTranslateX(20);
    rect3.setTranslateY(10);

    //show the rectangles
    getChildren().addAll(rect2, rect1, rect3);

    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Translate X", rect3.translateXProperty(), 0d, 50d),
            new SimplePropertySheet.PropDesc("Translate Y", rect3.translateYProperty(), 0d, 50d)
    );
    // END REMOVE ME
    
    //create arrow
    Polygon polygon = createArrow();
    polygon.setLayoutX(110);
    polygon.setLayoutY(30);
    polygon.setRotate(90);

    getChildren().addAll(polygon);

}
 
Example 9
Source File: PauseTransitionSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public PauseTransitionSample() {
    super(400,150);
    // create rectangle
    Rectangle rect = new Rectangle(-25,-25,50, 50);
    rect.setArcHeight(15);
    rect.setArcWidth(15);
    rect.setFill(Color.CRIMSON);
    rect.setTranslateX(50);
    rect.setTranslateY(75);
    getChildren().add(rect);
    
    animation = SequentialTransitionBuilder.create()
        .node(rect)
        .children(
            TranslateTransitionBuilder.create()
                .duration(Duration.seconds(2))
                .fromX(50)
                .toX(200)
                .build(),
            PauseTransitionBuilder.create()
                .duration(Duration.seconds(2))
                .build(),
            TranslateTransitionBuilder.create()
                .duration(Duration.seconds(2))
                .fromX(200)
                .toX(350)
                .build()
        )
        .cycleCount(Timeline.INDEFINITE)
        .autoReverse(true)
        .build();                
}
 
Example 10
Source File: AudioClipSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public static Group createRectangle(Color color, double tx, double ty, double sx, double sy) {
    Group squareGroup = new Group();
    Rectangle squareShape = new Rectangle(1.0, 1.0);
    squareShape.setFill(color);
    squareShape.setTranslateX(-0.5);
    squareShape.setTranslateY(-0.5);
    squareGroup.getChildren().add(squareShape);
    squareGroup.setTranslateX(tx);
    squareGroup.setTranslateY(ty);
    squareGroup.setScaleX(sx);
    squareGroup.setScaleY(sy);
    return squareGroup;
}
 
Example 11
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 12
Source File: TranslateSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public TranslateSample() {
    super(230, 220);

    //create 2 rectangles with different color
    Rectangle rect1 = new Rectangle(90, 90, Color.web("#ed4b00", 0.75));
    Rectangle rect2 = new Rectangle(90, 90, Color.web("#ed4b00", 0.5));

    //translate second one
    rect2.setTranslateX(140);

    // rectangle with adjustable translate
    Rectangle rect3 = new Rectangle(40, 130, 60, 60);
    rect3.setFill(Color.DODGERBLUE);
    rect3.setTranslateX(20);
    rect3.setTranslateY(10);

    //show the rectangles
    getChildren().addAll(rect2, rect1, rect3);

    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Translate X", rect3.translateXProperty(), 0d, 50d),
            new SimplePropertySheet.PropDesc("Translate Y", rect3.translateYProperty(), 0d, 50d)
    );
    // END REMOVE ME
    
    //create arrow
    Polygon polygon = createArrow();
    polygon.setLayoutX(110);
    polygon.setLayoutY(30);
    polygon.setRotate(90);

    getChildren().addAll(polygon);

}
 
Example 13
Source File: SequentialTransitionSample.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public SequentialTransitionSample() {
    super(400,100);
    // create rectangle
    Rectangle rect = new Rectangle(-25,-25,50, 50);
    rect.setArcHeight(15);
    rect.setArcWidth(15);
    rect.setFill(Color.CRIMSON);
    rect.setTranslateX(50);
    rect.setTranslateY(50);
    getChildren().add(rect);
    // create 4 transitions
    FadeTransition fadeTransition =
            FadeTransitionBuilder.create()
            .duration(Duration.seconds(1))
            .fromValue(1)
            .toValue(0.3)
            .cycleCount(2)
            .autoReverse(true)
            .build();
    TranslateTransition translateTransition =
            TranslateTransitionBuilder.create()
            .duration(Duration.seconds(2))
            .fromX(50)
            .toX(375)
            .cycleCount(2)
            .autoReverse(true)
            .build();       
    RotateTransition rotateTransition = 
            RotateTransitionBuilder.create()
            .duration(Duration.seconds(2))
            .byAngle(180)
            .cycleCount(4)
            .autoReverse(true)
            .build();
    ScaleTransition scaleTransition =
            ScaleTransitionBuilder.create()
            .duration(Duration.seconds(2))
            .toX(2)
            .toY(2)
            .cycleCount(2)
            .autoReverse(true)
            .build();
    // create sequential transition to do 4 transitions one after another       
    sequentialTransition = SequentialTransitionBuilder.create()
            .node(rect)
            .children(fadeTransition, translateTransition, rotateTransition,
                       scaleTransition)
            .cycleCount(Timeline.INDEFINITE)
            .autoReverse(true)
            .build();
}
 
Example 14
Source File: ParallelTransitionSample.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public ParallelTransitionSample() {
    super(400,150);
    // create rectangle
    Rectangle rect = new Rectangle(-25,-25,50, 50);
    rect.setArcHeight(15);
    rect.setArcWidth(15);
    rect.setFill(Color.CRIMSON);
    rect.setTranslateX(50);
    rect.setTranslateY(75);
    getChildren().add(rect); 
    // create parallel transition to do all 4 transitions at the same time        
    parallelTransition = ParallelTransitionBuilder.create()
        .node(rect)
        .children(
            FadeTransitionBuilder.create()
                .duration(Duration.seconds(3))
                .node(rect)
                .fromValue(1)
                .toValue(0.3)
                .autoReverse(true)
                .build(),
            TranslateTransitionBuilder.create()
                .duration(Duration.seconds(2))
                .fromX(50)
                .toX(350)
                .cycleCount(2)
                .autoReverse(true)
                .build(),
            RotateTransitionBuilder.create()
                .duration(Duration.seconds(3))
                .byAngle(180)
                .cycleCount(4)
                .autoReverse(true)
                .build(),
            ScaleTransitionBuilder.create()
                .duration(Duration.seconds(2))
                .toX(2)
                .toY(2)
                .cycleCount(2)
                .autoReverse(true)
                .build()
        )
        .cycleCount(Timeline.INDEFINITE)
        .autoReverse(true)
        .build();
    
}
 
Example 15
Source File: ScaleSample.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public ScaleSample() {
    super(180,180);
    // simple rectangle
    Rectangle rect1 = new Rectangle(0, 25, 25, 25);
    rect1.setArcHeight(15);
    rect1.setArcWidth(15);
    rect1.setFill(Color.WHITE);
    rect1.setStroke(Color.DODGERBLUE);
    rect1.setStrokeWidth(3);
    
    Polygon arrow = createArrow();
    arrow.setLayoutX(46);
    arrow.setLayoutY(22);
    arrow.setRotate(90);
    
    // simple rectangle with scale 2 in X axis and 0.5 in Y
    Rectangle rect2 = new Rectangle(95, 25, 25, 25);
    rect2.setArcHeight(15);
    rect2.setArcWidth(15);
    rect2.setFill(Color.WHITE);
    rect2.setStroke(Color.DODGERBLUE);
    rect2.setStrokeWidth(3);
    rect2.setScaleX(2);
    rect2.setScaleY(0.5);
    // rectangle with adjustable scale
    Rectangle rect3 = new Rectangle(40, 130, 25, 25);
    rect3.setArcHeight(15);
    rect3.setArcWidth(15);
    rect3.setFill(Color.WHITE);
    rect3.setStroke(Color.DODGERBLUE);
    rect3.setStrokeWidth(3);
    rect3.setScaleX(6);
    rect3.setScaleY(0.5);
    rect3.setTranslateX(rect3.getTranslateX()+30);
    //getChildren().addAll(rect1, rect2, rect3);
    getChildren().addAll(rect1, arrow, rect2, rect3);
    
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Scale X", rect3.scaleXProperty(), 0.1d, 16d),
            new SimplePropertySheet.PropDesc("Scale Y", rect3.scaleYProperty(), 0.1d, 4d)
    );
    // END REMOVE ME
}
 
Example 16
Source File: ScaleSample.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public ScaleSample() {
    super(180,180);
    // simple rectangle
    Rectangle rect1 = new Rectangle(0, 25, 25, 25);
    rect1.setArcHeight(15);
    rect1.setArcWidth(15);
    rect1.setFill(Color.WHITE);
    rect1.setStroke(Color.DODGERBLUE);
    rect1.setStrokeWidth(3);
    
    Polygon arrow = createArrow();
    arrow.setLayoutX(46);
    arrow.setLayoutY(22);
    arrow.setRotate(90);
    
    // simple rectangle with scale 2 in X axis and 0.5 in Y
    Rectangle rect2 = new Rectangle(95, 25, 25, 25);
    rect2.setArcHeight(15);
    rect2.setArcWidth(15);
    rect2.setFill(Color.WHITE);
    rect2.setStroke(Color.DODGERBLUE);
    rect2.setStrokeWidth(3);
    rect2.setScaleX(2);
    rect2.setScaleY(0.5);
    // rectangle with adjustable scale
    Rectangle rect3 = new Rectangle(40, 130, 25, 25);
    rect3.setArcHeight(15);
    rect3.setArcWidth(15);
    rect3.setFill(Color.WHITE);
    rect3.setStroke(Color.DODGERBLUE);
    rect3.setStrokeWidth(3);
    rect3.setScaleX(6);
    rect3.setScaleY(0.5);
    rect3.setTranslateX(rect3.getTranslateX()+30);
    //getChildren().addAll(rect1, rect2, rect3);
    getChildren().addAll(rect1, arrow, rect2, rect3);
    
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Scale X", rect3.scaleXProperty(), 0.1d, 16d),
            new SimplePropertySheet.PropDesc("Scale Y", rect3.scaleYProperty(), 0.1d, 4d)
    );
    // END REMOVE ME
}
 
Example 17
Source File: RectangleSegmentHandlePart.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Updates the color of this part's visualization. If this handle part
 * represents a way or end point of an {@link Connection}, it's color will
 * be set to indicate whether the handle is connected to another part or
 * not.
 */
protected void updateColor() {
	// only update when bound to anchorage
	SetMultimap<IVisualPart<? extends Node>, String> anchorages = getAnchoragesUnmodifiable();
	if (getRoot() == null || anchorages.keySet().size() != 1) {
		return;
	}

	Rectangle visual = getVisual();
	// no need to update the color if we are invisible
	if (!visual.isVisible()) {
		return;
	}

	if (getSegmentParameter() == 0.5) {
		// move handle in the middle of a segment
		visual.setFill(getMoveFill());
	} else if (getSegmentParameter() != 0.0
			&& getSegmentParameter() != 1.0) {
		// quarter handles (creation)
		visual.setFill(getInsertFill());
		visual.setWidth(DEFAULT_LENGTH * 4d / 5d);
		visual.setHeight(DEFAULT_WIDTH * 4d / 5d);
		visual.setTranslateX(-DEFAULT_LENGTH / 2d + DEFAULT_LENGTH / 10d);
		visual.setTranslateY(-DEFAULT_WIDTH / 2d + DEFAULT_WIDTH / 10d);
	} else {
		visual.setTranslateX(-DEFAULT_LENGTH / 2);
		visual.setTranslateY(-DEFAULT_WIDTH / 2);
		visual.setWidth(DEFAULT_LENGTH);
		visual.setHeight(DEFAULT_WIDTH);
		// end point handles
		boolean connected = false;
		IVisualPart<? extends Node> targetPart = anchorages.keySet()
				.iterator().next();
		if (targetPart.getVisual() instanceof Connection) {
			Connection connection = (Connection) targetPart.getVisual();
			if (getSegmentIndex() + getSegmentParameter() == 0.0) {
				// handle at start point
				connected = connection.isStartConnected();
			} else if (getSegmentParameter()
					+ getSegmentIndex() == getSegmentsInScene().length) {
				// handle at end point
				connected = connection.isEndConnected();
			}
		}
		// update color according to connected state
		if (connected) {
			visual.setFill(getConnectedFill());
		} else {
			visual.setFill(getMoveFill());
		}
	}
}
 
Example 18
Source File: SequentialTransitionSample.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public SequentialTransitionSample() {
    super(400,100);
    // create rectangle
    Rectangle rect = new Rectangle(-25,-25,50, 50);
    rect.setArcHeight(15);
    rect.setArcWidth(15);
    rect.setFill(Color.CRIMSON);
    rect.setTranslateX(50);
    rect.setTranslateY(50);
    getChildren().add(rect);
    // create 4 transitions
    FadeTransition fadeTransition =
            FadeTransitionBuilder.create()
            .duration(Duration.seconds(1))
            .fromValue(1)
            .toValue(0.3)
            .cycleCount(2)
            .autoReverse(true)
            .build();
    TranslateTransition translateTransition =
            TranslateTransitionBuilder.create()
            .duration(Duration.seconds(2))
            .fromX(50)
            .toX(375)
            .cycleCount(2)
            .autoReverse(true)
            .build();       
    RotateTransition rotateTransition = 
            RotateTransitionBuilder.create()
            .duration(Duration.seconds(2))
            .byAngle(180)
            .cycleCount(4)
            .autoReverse(true)
            .build();
    ScaleTransition scaleTransition =
            ScaleTransitionBuilder.create()
            .duration(Duration.seconds(2))
            .toX(2)
            .toY(2)
            .cycleCount(2)
            .autoReverse(true)
            .build();
    // create sequential transition to do 4 transitions one after another       
    sequentialTransition = SequentialTransitionBuilder.create()
            .node(rect)
            .children(fadeTransition, translateTransition, rotateTransition,
                       scaleTransition)
            .cycleCount(Timeline.INDEFINITE)
            .autoReverse(true)
            .build();
}
 
Example 19
Source File: ParallelTransitionSample.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public ParallelTransitionSample() {
    super(400,150);
    // create rectangle
    Rectangle rect = new Rectangle(-25,-25,50, 50);
    rect.setArcHeight(15);
    rect.setArcWidth(15);
    rect.setFill(Color.CRIMSON);
    rect.setTranslateX(50);
    rect.setTranslateY(75);
    getChildren().add(rect); 
    // create parallel transition to do all 4 transitions at the same time        
    parallelTransition = ParallelTransitionBuilder.create()
        .node(rect)
        .children(
            FadeTransitionBuilder.create()
                .duration(Duration.seconds(3))
                .node(rect)
                .fromValue(1)
                .toValue(0.3)
                .autoReverse(true)
                .build(),
            TranslateTransitionBuilder.create()
                .duration(Duration.seconds(2))
                .fromX(50)
                .toX(350)
                .cycleCount(2)
                .autoReverse(true)
                .build(),
            RotateTransitionBuilder.create()
                .duration(Duration.seconds(3))
                .byAngle(180)
                .cycleCount(4)
                .autoReverse(true)
                .build(),
            ScaleTransitionBuilder.create()
                .duration(Duration.seconds(2))
                .toX(2)
                .toY(2)
                .cycleCount(2)
                .autoReverse(true)
                .build()
        )
        .cycleCount(Timeline.INDEFINITE)
        .autoReverse(true)
        .build();
    
}
 
Example 20
Source File: LoadingScreen.java    From FXTutorials with MIT License 4 votes vote down vote up
private Node makeSymbol() {
    Pane symbol = new Pane();

    GaussianBlur blur = new GaussianBlur(2.5);
    symbol.setEffect(blur);

    Rectangle top = new Rectangle(70, 5, Colors.LOADING_SYMBOL);
    top.setArcWidth(25);
    top.setArcHeight(25);

    Rectangle mid = new Rectangle(100, 5, Colors.LOADING_SYMBOL);
    mid.setArcWidth(25);
    mid.setArcHeight(25);

    Rectangle bot = new Rectangle(70, 5, Colors.LOADING_SYMBOL);
    bot.setArcWidth(25);
    bot.setArcHeight(25);

    top.setTranslateX(15);
    bot.setTranslateX(15);

    top.setTranslateY(10);
    mid.setTranslateY(10 + 10 + 5);
    bot.setTranslateY(10 + 10 + 5 + 10 + 5);

    Circle circle = new Circle(25, 25, 25, Color.BLACK);
    circle.setStroke(Colors.LOADING_SYMBOL);
    circle.setStrokeWidth(2);
    circle.setTranslateX(25);

    Circle circle2 = new Circle(25, 25, 25, Color.BLACK);
    circle2.setStroke(Colors.LOADING_SYMBOL);
    circle2.setStrokeWidth(1);
    circle2.setTranslateX(25);
    circle2.setRadius(2);

    Circle point = new Circle(25, 25, 25, Colors.LOADING_SYMBOL);
    point.setStroke(Colors.LOADING_SYMBOL);
    point.setStrokeWidth(1);
    point.setTranslateX(25);
    point.setRadius(1);

    KeyFrame frame = new KeyFrame(Duration.seconds(1),
            new KeyValue(circle2.radiusProperty(), 20));

    timeline.getKeyFrames().add(frame);
    timeline.setCycleCount(5);
    timeline.play();

    symbol.getChildren().addAll(top, mid, bot, circle, circle2, point);
    return symbol;
}