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

The following examples show how to use javafx.scene.shape.Circle#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: TranslateTransitionSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public TranslateTransitionSample() {
    super(400,40);
    Circle circle = new Circle(20, Color.CRIMSON);
    circle.setTranslateX(20);
    circle.setTranslateY(20);
    getChildren().add(circle);
    translateTransition = new TranslateTransition(Duration.seconds(4),circle);
    translateTransition.setFromX(20);
    translateTransition.setToX(380);
    translateTransition.setCycleCount(Timeline.INDEFINITE);
    translateTransition.setAutoReverse(true);        
    translateTransition = TranslateTransitionBuilder.create()
            .duration(Duration.seconds(4))
            .node(circle)
            .fromX(20)
            .toX(380)
            .cycleCount(Timeline.INDEFINITE)
            .autoReverse(true)
            .build();
}
 
Example 2
Source File: TranslateTransitionSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public TranslateTransitionSample() {
    super(400,40);
    Circle circle = new Circle(20, Color.CRIMSON);
    circle.setTranslateX(20);
    circle.setTranslateY(20);
    getChildren().add(circle);
    translateTransition = new TranslateTransition(Duration.seconds(4),circle);
    translateTransition.setFromX(20);
    translateTransition.setToX(380);
    translateTransition.setCycleCount(Timeline.INDEFINITE);
    translateTransition.setAutoReverse(true);        
    translateTransition = TranslateTransitionBuilder.create()
            .duration(Duration.seconds(4))
            .node(circle)
            .fromX(20)
            .toX(380)
            .cycleCount(Timeline.INDEFINITE)
            .autoReverse(true)
            .build();
}
 
Example 3
Source File: HangmanMain.java    From FXTutorials with MIT License 6 votes vote down vote up
public HangmanImage() {
    Circle head = new Circle(20);
    head.setTranslateX(SPINE_START_X);

    Line spine = new Line();
    spine.setStartX(SPINE_START_X);
    spine.setStartY(SPINE_START_Y);
    spine.setEndX(SPINE_END_X);
    spine.setEndY(SPINE_END_Y);

    Line leftArm = new Line();
    leftArm.setStartX(SPINE_START_X);
    leftArm.setStartY(SPINE_START_Y);
    leftArm.setEndX(SPINE_START_X + 40);
    leftArm.setEndY(SPINE_START_Y + 10);

    Line rightArm = new Line();
    rightArm.setStartX(SPINE_START_X);
    rightArm.setStartY(SPINE_START_Y);
    rightArm.setEndX(SPINE_START_X - 40);
    rightArm.setEndY(SPINE_START_Y + 10);

    Line leftLeg = new Line();
    leftLeg.setStartX(SPINE_END_X);
    leftLeg.setStartY(SPINE_END_Y);
    leftLeg.setEndX(SPINE_END_X + 25);
    leftLeg.setEndY(SPINE_END_Y + 50);

    Line rightLeg = new Line();
    rightLeg.setStartX(SPINE_END_X);
    rightLeg.setStartY(SPINE_END_Y);
    rightLeg.setEndX(SPINE_END_X - 25);
    rightLeg.setEndY(SPINE_END_Y + 50);

    getChildren().addAll(head, spine, leftArm, rightArm, leftLeg, rightLeg);
    lives.set(getChildren().size());
}
 
Example 4
Source File: JFXTimePickerContent.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
private StackPane createMinutesContent(LocalTime time) {
    // create minutes content
    StackPane minsPointer = new StackPane();
    Circle selectionCircle = new Circle(contentCircleRadius / 6);
    selectionCircle.fillProperty().bind(timePicker.defaultColorProperty());

    Circle minCircle = new Circle(selectionCircle.getRadius() / 8);
    minCircle.setFill(Color.rgb(255, 255, 255, 0.87));
    minCircle.setTranslateX(selectionCircle.getRadius() - minCircle.getRadius());
    minCircle.setVisible(time.getMinute() % 5 != 0);
    selectedMinLabel.textProperty().addListener((o, oldVal, newVal) -> {
        if (Integer.parseInt(newVal) % 5 == 0) {
            minCircle.setVisible(false);
        } else {
            minCircle.setVisible(true);
        }
    });


    double shift = 9;
    Line line = new Line(shift, 0, contentCircleRadius, 0);
    line.fillProperty().bind(timePicker.defaultColorProperty());
    line.strokeProperty().bind(line.fillProperty());
    line.setStrokeWidth(1.5);
    minsPointer.getChildren().addAll(line, selectionCircle, minCircle);
    StackPane.setAlignment(selectionCircle, Pos.CENTER_LEFT);
    StackPane.setAlignment(minCircle, Pos.CENTER_LEFT);


    Group pointerGroup = new Group();
    pointerGroup.getChildren().add(minsPointer);
    pointerGroup.setTranslateX((-contentCircleRadius + shift) / 2);
    minsPointerRotate = new Rotate(0, contentCircleRadius - shift, selectionCircle.getRadius());
    pointerGroup.getTransforms().add(minsPointerRotate);

    Pane clockLabelsContainer = new Pane();
    // inner circle radius
    double radius = contentCircleRadius - shift - selectionCircle.getRadius();
    for (int i = 0; i < 12; i++) {
        StackPane labelContainer = new StackPane();
        int val = ((i + 3) * 5) % 60;
        Label label = new Label(String.valueOf(unitConverter.toString(val)));
        label.setFont(Font.font(ROBOTO, FontWeight.BOLD, 12));
        // init label color
        label.setTextFill(val == time.getMinute() ?
            Color.rgb(255, 255, 255, 0.87) : Color.rgb(0, 0, 0, 0.87));
        selectedMinLabel.textProperty().addListener((o, oldVal, newVal) -> {
            if (Integer.parseInt(newVal) == Integer.parseInt(label.getText())) {
                label.setTextFill(Color.rgb(255, 255, 255, 0.87));
            } else {
                label.setTextFill(Color.rgb(0, 0, 0, 0.87));
            }
        });

        labelContainer.getChildren().add(label);
        double labelSize = (selectionCircle.getRadius() / Math.sqrt(2)) * 2;
        labelContainer.setMinSize(labelSize, labelSize);

        double angle = 2 * i * Math.PI / 12;
        double xOffset = radius * Math.cos(angle);
        double yOffset = radius * Math.sin(angle);
        final double startx = contentCircleRadius + xOffset;
        final double starty = contentCircleRadius + yOffset;
        labelContainer.setLayoutX(startx - labelContainer.getMinWidth() / 2);
        labelContainer.setLayoutY(starty - labelContainer.getMinHeight() / 2);

        // add label to the parent node
        clockLabelsContainer.getChildren().add(labelContainer);
    }

    minsPointerRotate.setAngle(180 + (time.getMinute() + 45) % 60 * Math.toDegrees(2 * Math.PI / 60));

    return new StackPane(pointerGroup, clockLabelsContainer);
}
 
Example 5
Source File: Connect4App.java    From FXTutorials with MIT License 5 votes vote down vote up
private Shape makeGrid() {
    Shape shape = new Rectangle((COLUMNS + 1) * TILE_SIZE, (ROWS + 1) * TILE_SIZE);

    for (int y = 0; y < ROWS; y++) {
        for (int x = 0; x < COLUMNS; x++) {
            Circle circle = new Circle(TILE_SIZE / 2);
            circle.setCenterX(TILE_SIZE / 2);
            circle.setCenterY(TILE_SIZE / 2);
            circle.setTranslateX(x * (TILE_SIZE + 5) + TILE_SIZE / 4);
            circle.setTranslateY(y * (TILE_SIZE + 5) + TILE_SIZE / 4);

            shape = Shape.subtract(shape, circle);
        }
    }

    Light.Distant light = new Light.Distant();
    light.setAzimuth(45.0);
    light.setElevation(30.0);

    Lighting lighting = new Lighting();
    lighting.setLight(light);
    lighting.setSurfaceScale(5.0);

    shape.setFill(Color.BLUE);
    shape.setEffect(lighting);

    return shape;
}
 
Example 6
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;
}