Java Code Examples for javafx.scene.Group#setTranslateX()

The following examples show how to use javafx.scene.Group#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: CloseIcon.java    From FxDock with Apache License 2.0 6 votes vote down vote up
public CloseIcon(double size)
{
	super(size);
	
	double r = 0.4 * size;
	double w = 0.075 * size;
	double d = 0.3 * size;
	
	FxPath p = new FxPath();
	p.setStrokeLineCap(StrokeLineCap.ROUND);
	p.setStroke(Color.BLACK);
	p.setStrokeWidth(w);
	p.moveto(-d, -d);
	p.lineto(d, d);
	p.moveto(d, -d);
	p.lineto(-d, d);
	
	Group g = new Group(p);
	g.setTranslateX(size * 0.5);
	g.setTranslateY(size * 0.5);
	
	add(g);
}
 
Example 2
Source File: Main.java    From quantumjava with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Group createHelpNode() {
    Label help1 = new Label(); //"Pressing X, H or C will\n activate/deactivate the gates");
    help1.textProperty().bind(helpTextProperty);
    help1.setStyle("-fx-background-color: white;-fx-font-size: 1.3em;");

    Group answer = new Group();
    answer.getChildren().addAll(help1);
    answer.setTranslateY((VERTICAL_CELLS-1) * CELL_SIZE);
    answer.setTranslateX((HORIZONTAL_CELLS-3)* CELL_SIZE);
    return answer;

}
 
Example 3
Source File: DataViewerSample.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
private static Pane getDemoPane() {
    final Rectangle rect = new Rectangle(-130, -40, 80, 80);
    rect.setFill(Color.BLUE);
    final Circle circle = new Circle(0, 0, 40);
    circle.setFill(Color.GREEN);
    final Polygon triangle = new Polygon(60, -40, 120, 0, 50, 40);
    triangle.setFill(Color.RED);

    final Group group = new Group(rect, circle, triangle);
    group.setTranslateX(300);
    group.setTranslateY(200);

    final RotateTransition rotateTransition = new RotateTransition(Duration.millis(4000), group);
    rotateTransition.setByAngle(3.0 * 360);
    rotateTransition.setCycleCount(Animation.INDEFINITE);
    rotateTransition.setAutoReverse(true);
    rotateTransition.play();

    final RotateTransition rotateTransition1 = new RotateTransition(Duration.millis(1000), rect);
    rotateTransition1.setByAngle(360);
    rotateTransition1.setCycleCount(Animation.INDEFINITE);
    rotateTransition1.setAutoReverse(false);
    rotateTransition1.play();

    final RotateTransition rotateTransition2 = new RotateTransition(Duration.millis(1000), triangle);
    rotateTransition2.setByAngle(360);
    rotateTransition2.setCycleCount(Animation.INDEFINITE);
    rotateTransition2.setAutoReverse(false);
    rotateTransition2.play();
    group.setManaged(true);

    HBox.setHgrow(group, Priority.ALWAYS);
    final HBox box = new HBox(group);
    VBox.setVgrow(box, Priority.ALWAYS);
    box.setId("demoPane");
    return box;
}
 
Example 4
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 5
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 6
Source File: ClearIcon.java    From FxDock with Apache License 2.0 5 votes vote down vote up
public ClearIcon(double size)
{
	super(size);
	
	double r = 0.4 * size;
	double w = 0.075 * size;
	double d = 0.14 * size;
	
	Circle c = new Circle(0, 0, r);
	c.setFill(null);
	c.setStrokeWidth(0);
	c.setStroke(null);
	c.setFill(Color.LIGHTGRAY);
	
	FxPath p = new FxPath();
	p.setStrokeLineCap(StrokeLineCap.SQUARE);
	p.setStroke(Color.WHITE);
	p.setStrokeWidth(w);
	p.moveto(-d, -d);
	p.lineto(d, d);
	p.moveto(d, -d);
	p.lineto(-d, d);
	
	Group g = new Group(c, p);
	g.setTranslateX(size * 0.5);
	g.setTranslateY(size * 0.5);
	
	add(g);
}
 
Example 7
Source File: FindIcon.java    From FxDock with Apache License 2.0 5 votes vote down vote up
public FindIcon(double size)
{
	super(size);
	
	double r = 0.3 * size;
	double w = 0.075 * size;
	double gap = 0.12 * size;
	double handle = 0.15 * size;

	Circle c = new Circle(0, 0, r);
	c.setFill(null);
	c.setStrokeWidth(w);
	c.setStroke(Color.BLACK);
	c.setFill(null);
	
	FxPath p = new FxPath();
	p.setStrokeLineCap(StrokeLineCap.SQUARE);
	p.setStroke(Color.BLACK);
	p.setStrokeWidth(w);
	p.moveto(r, 0);
	p.lineto(r + gap, 0);
	
	FxPath h = new FxPath();
	h.setStrokeLineCap(StrokeLineCap.ROUND);
	h.setStroke(Color.BLACK);
	h.setStrokeWidth(w * 2);
	h.moveto(r + gap, 0);
	h.lineto(r + gap + handle, 0);
	
	Group g = new Group(c, p, h);
	g.setRotate(135);
	g.setTranslateX(size * 0.30);
	g.setTranslateY(size * 0.54);
	
	add(g);
}
 
Example 8
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 9
Source File: Level.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
private void initInfoPanel() {
    infoPanel = new Group();
    roundCaption = new Text();
    roundCaption.setText("ROUND");
    roundCaption.setTextOrigin(VPos.TOP);
    roundCaption.setFill(Color.rgb(51, 102, 51));
    Font f = new Font("Impact", 18);
    roundCaption.setFont(f);
    roundCaption.setTranslateX(30);
    roundCaption.setTranslateY(128);
    round = new Text();
    round.setTranslateX(roundCaption.getTranslateX() +
        roundCaption.getBoundsInLocal().getWidth() + Config.INFO_TEXT_SPACE);
    round.setTranslateY(roundCaption.getTranslateY());
    round.setText(levelNumber + "");
    round.setTextOrigin(VPos.TOP);
    round.setFont(f);
    round.setFill(Color.rgb(0, 204, 102));
    scoreCaption = new Text();
    scoreCaption.setText("SCORE");
    scoreCaption.setFill(Color.rgb(51, 102, 51));
    scoreCaption.setTranslateX(30);
    scoreCaption.setTranslateY(164);
    scoreCaption.setTextOrigin(VPos.TOP);
    scoreCaption.setFont(f);
    score = new Text();
    score.setTranslateX(scoreCaption.getTranslateX() +
        scoreCaption.getBoundsInLocal().getWidth() + Config.INFO_TEXT_SPACE);
    score.setTranslateY(scoreCaption.getTranslateY());
    score.setFill(Color.rgb(0, 204, 102));
    score.setTextOrigin(VPos.TOP);
    score.setFont(f);
    score.setText("");
    livesCaption = new Text();
    livesCaption.setText("LIFE");
    livesCaption.setTranslateX(30);
    livesCaption.setTranslateY(200);
    livesCaption.setFill(Color.rgb(51, 102, 51));
    livesCaption.setTextOrigin(VPos.TOP);
    livesCaption.setFont(f);
    Color INFO_LEGEND_COLOR = Color.rgb(0, 114, 188);
    int infoWidth = Config.SCREEN_WIDTH - Config.FIELD_WIDTH;
    Rectangle black = new Rectangle();
    black.setWidth(infoWidth);
    black.setHeight(Config.SCREEN_HEIGHT);
    black.setFill(Color.BLACK);
    ImageView verLine = new ImageView();
    verLine.setImage(new Image(Level.class.getResourceAsStream(Config.IMAGE_DIR+"vline.png")));
    verLine.setTranslateX(3);
    ImageView logo = new ImageView();
    logo.setImage(Config.getImages().get(Config.IMAGE_LOGO));
    logo.setTranslateX(30);
    logo.setTranslateY(30);
    Text legend = new Text();
    legend.setTranslateX(30);
    legend.setTranslateY(310);
    legend.setText("LEGEND");
    legend.setFill(INFO_LEGEND_COLOR);
    legend.setTextOrigin(VPos.TOP);
    legend.setFont(new Font("Impact", 18));
    infoPanel.getChildren().addAll(black, verLine, logo, roundCaption,
            round, scoreCaption, score, livesCaption, legend);
    for (int i = 0; i < Bonus.COUNT; i++) {
        Bonus bonus = new Bonus(i);
        Text text = new Text();
        text.setTranslateX(100);
        text.setTranslateY(350 + i * 40);
        text.setText(Bonus.NAMES[i]);
        text.setFill(INFO_LEGEND_COLOR);
        text.setTextOrigin(VPos.TOP);
        text.setFont(new Font("Arial", 12));
        bonus.setTranslateX(30 + (820 - 750 - bonus.getWidth()) / 2);
        bonus.setTranslateY(text.getTranslateY() -
            (bonus.getHeight() - text.getBoundsInLocal().getHeight()) / 2);
        // Workaround JFXC-2379
        infoPanel.getChildren().addAll(bonus, text);
    }
    infoPanel.setTranslateX(Config.FIELD_WIDTH);
}
 
Example 10
Source File: Level.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
private void initInfoPanel() {
    infoPanel = new Group();
    roundCaption = new Text();
    roundCaption.setText("ROUND");
    roundCaption.setTextOrigin(VPos.TOP);
    roundCaption.setFill(Color.rgb(51, 102, 51));
    Font f = new Font("Impact", 18);
    roundCaption.setFont(f);
    roundCaption.setTranslateX(30);
    roundCaption.setTranslateY(128);
    round = new Text();
    round.setTranslateX(roundCaption.getTranslateX() +
        roundCaption.getBoundsInLocal().getWidth() + Config.INFO_TEXT_SPACE);
    round.setTranslateY(roundCaption.getTranslateY());
    round.setText(levelNumber + "");
    round.setTextOrigin(VPos.TOP);
    round.setFont(f);
    round.setFill(Color.rgb(0, 204, 102));
    scoreCaption = new Text();
    scoreCaption.setText("SCORE");
    scoreCaption.setFill(Color.rgb(51, 102, 51));
    scoreCaption.setTranslateX(30);
    scoreCaption.setTranslateY(164);
    scoreCaption.setTextOrigin(VPos.TOP);
    scoreCaption.setFont(f);
    score = new Text();
    score.setTranslateX(scoreCaption.getTranslateX() +
        scoreCaption.getBoundsInLocal().getWidth() + Config.INFO_TEXT_SPACE);
    score.setTranslateY(scoreCaption.getTranslateY());
    score.setFill(Color.rgb(0, 204, 102));
    score.setTextOrigin(VPos.TOP);
    score.setFont(f);
    score.setText("");
    livesCaption = new Text();
    livesCaption.setText("LIFE");
    livesCaption.setTranslateX(30);
    livesCaption.setTranslateY(200);
    livesCaption.setFill(Color.rgb(51, 102, 51));
    livesCaption.setTextOrigin(VPos.TOP);
    livesCaption.setFont(f);
    Color INFO_LEGEND_COLOR = Color.rgb(0, 114, 188);
    int infoWidth = Config.SCREEN_WIDTH - Config.FIELD_WIDTH;
    Rectangle black = new Rectangle();
    black.setWidth(infoWidth);
    black.setHeight(Config.SCREEN_HEIGHT);
    black.setFill(Color.BLACK);
    ImageView verLine = new ImageView();
    verLine.setImage(new Image(Level.class.getResourceAsStream(Config.IMAGE_DIR+"vline.png")));
    verLine.setTranslateX(3);
    ImageView logo = new ImageView();
    logo.setImage(Config.getImages().get(Config.IMAGE_LOGO));
    logo.setTranslateX(30);
    logo.setTranslateY(30);
    Text legend = new Text();
    legend.setTranslateX(30);
    legend.setTranslateY(310);
    legend.setText("LEGEND");
    legend.setFill(INFO_LEGEND_COLOR);
    legend.setTextOrigin(VPos.TOP);
    legend.setFont(new Font("Impact", 18));
    infoPanel.getChildren().addAll(black, verLine, logo, roundCaption,
            round, scoreCaption, score, livesCaption, legend);
    for (int i = 0; i < Bonus.COUNT; i++) {
        Bonus bonus = new Bonus(i);
        Text text = new Text();
        text.setTranslateX(100);
        text.setTranslateY(350 + i * 40);
        text.setText(Bonus.NAMES[i]);
        text.setFill(INFO_LEGEND_COLOR);
        text.setTextOrigin(VPos.TOP);
        text.setFont(new Font("Arial", 12));
        bonus.setTranslateX(30 + (820 - 750 - bonus.getWidth()) / 2);
        bonus.setTranslateY(text.getTranslateY() -
            (bonus.getHeight() - text.getBoundsInLocal().getHeight()) / 2);
        // Workaround JFXC-2379
        infoPanel.getChildren().addAll(bonus, text);
    }
    infoPanel.setTranslateX(Config.FIELD_WIDTH);
}
 
Example 11
Source File: Level.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void initInfoPanel() {
    infoPanel = new Group();
    roundCaption = new Text();
    roundCaption.setText("ROUND");
    roundCaption.setTextOrigin(VPos.TOP);
    roundCaption.setFill(Color.rgb(51, 102, 51));
    Font f = new Font("Impact", 18);
    roundCaption.setFont(f);
    roundCaption.setTranslateX(30);
    roundCaption.setTranslateY(128);
    round = new Text();
    round.setTranslateX(roundCaption.getTranslateX() +
        roundCaption.getBoundsInLocal().getWidth() + Config.INFO_TEXT_SPACE);
    round.setTranslateY(roundCaption.getTranslateY());
    round.setText(levelNumber + "");
    round.setTextOrigin(VPos.TOP);
    round.setFont(f);
    round.setFill(Color.rgb(0, 204, 102));
    scoreCaption = new Text();
    scoreCaption.setText("SCORE");
    scoreCaption.setFill(Color.rgb(51, 102, 51));
    scoreCaption.setTranslateX(30);
    scoreCaption.setTranslateY(164);
    scoreCaption.setTextOrigin(VPos.TOP);
    scoreCaption.setFont(f);
    score = new Text();
    score.setTranslateX(scoreCaption.getTranslateX() +
        scoreCaption.getBoundsInLocal().getWidth() + Config.INFO_TEXT_SPACE);
    score.setTranslateY(scoreCaption.getTranslateY());
    score.setFill(Color.rgb(0, 204, 102));
    score.setTextOrigin(VPos.TOP);
    score.setFont(f);
    score.setText("");
    livesCaption = new Text();
    livesCaption.setText("LIFE");
    livesCaption.setTranslateX(30);
    livesCaption.setTranslateY(200);
    livesCaption.setFill(Color.rgb(51, 102, 51));
    livesCaption.setTextOrigin(VPos.TOP);
    livesCaption.setFont(f);
    Color INFO_LEGEND_COLOR = Color.rgb(0, 114, 188);
    int infoWidth = Config.SCREEN_WIDTH - Config.FIELD_WIDTH;
    Rectangle black = new Rectangle();
    black.setWidth(infoWidth);
    black.setHeight(Config.SCREEN_HEIGHT);
    black.setFill(Color.BLACK);
    ImageView verLine = new ImageView();
    verLine.setImage(new Image(Level.class.getResourceAsStream(Config.IMAGE_DIR+"vline.png")));
    verLine.setTranslateX(3);
    ImageView logo = new ImageView();
    logo.setImage(Config.getImages().get(Config.IMAGE_LOGO));
    logo.setTranslateX(30);
    logo.setTranslateY(30);
    Text legend = new Text();
    legend.setTranslateX(30);
    legend.setTranslateY(310);
    legend.setText("LEGEND");
    legend.setFill(INFO_LEGEND_COLOR);
    legend.setTextOrigin(VPos.TOP);
    legend.setFont(new Font("Impact", 18));
    infoPanel.getChildren().addAll(black, verLine, logo, roundCaption,
            round, scoreCaption, score, livesCaption, legend);
    for (int i = 0; i < Bonus.COUNT; i++) {
        Bonus bonus = new Bonus(i);
        Text text = new Text();
        text.setTranslateX(100);
        text.setTranslateY(350 + i * 40);
        text.setText(Bonus.NAMES[i]);
        text.setFill(INFO_LEGEND_COLOR);
        text.setTextOrigin(VPos.TOP);
        text.setFont(new Font("Arial", 12));
        bonus.setTranslateX(30 + (820 - 750 - bonus.getWidth()) / 2);
        bonus.setTranslateY(text.getTranslateY() -
            (bonus.getHeight() - text.getBoundsInLocal().getHeight()) / 2);
        // Workaround JFXC-2379
        infoPanel.getChildren().addAll(bonus, text);
    }
    infoPanel.setTranslateX(Config.FIELD_WIDTH);
}
 
Example 12
Source File: StarIcon.java    From FxDock with Apache License 2.0 4 votes vote down vote up
public StarIcon(double size, Color fill)
{
	super(size);
	
	double rm = size * 0.4;
	double r0 = size * 0.15;
	double w = size * 0.0325;
	
	FxPath p = new FxPath();
	p.setStrokeLineCap(StrokeLineCap.ROUND);
	p.setStrokeLineJoin(StrokeLineJoin.ROUND);
	p.setStroke(Color.BLACK);
	p.setStrokeWidth(w);
	p.setFill(fill);

	for(int i=0; i<11; i++)
	{
		double a = Math.PI * i / 5;
		double r = CKit.isEven(i) ? rm : r0;
		double x = r * Math.cos(a);
		double y = r * Math.sin(a);
		
		switch(i)
		{
		case 0:
			p.moveto(x, y);
			break;
		case 10:
			p.close();
			break;
		default:
			p.lineto(x, y);
			break;
		}
	}
	
	Group g = new Group(p);
	g.setRotate(-90);
	g.setTranslateX(size * 0.5);
	g.setTranslateY(size * 0.5);
	
	add(g);
}