Java Code Examples for javafx.scene.text.Text#setTranslateY()
The following examples show how to use
javafx.scene.text.Text#setTranslateY() .
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: KeyStrokeMotion.java From marathonv5 with Apache License 2.0 | 7 votes |
private void createLetter(String c) { final Text letter = new Text(c); letter.setFill(Color.BLACK); letter.setFont(FONT_DEFAULT); letter.setTextOrigin(VPos.TOP); letter.setTranslateX((getWidth() - letter.getBoundsInLocal().getWidth()) / 2); letter.setTranslateY((getHeight() - letter.getBoundsInLocal().getHeight()) / 2); getChildren().add(letter); // over 3 seconds move letter to random position and fade it out final Timeline timeline = new Timeline(); timeline.getKeyFrames().add( new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { // we are done remove us from scene getChildren().remove(letter); } }, new KeyValue(letter.translateXProperty(), getRandom(0.0f, getWidth() - letter.getBoundsInLocal().getWidth()),INTERPOLATOR), new KeyValue(letter.translateYProperty(), getRandom(0.0f, getHeight() - letter.getBoundsInLocal().getHeight()),INTERPOLATOR), new KeyValue(letter.opacityProperty(), 0f) )); timeline.play(); }
Example 2
Source File: KeyStrokeMotion.java From marathonv5 with Apache License 2.0 | 6 votes |
private void createLetter(String c) { final Text letter = new Text(c); letter.setFill(Color.BLACK); letter.setFont(FONT_DEFAULT); letter.setTextOrigin(VPos.TOP); letter.setTranslateX((getWidth() - letter.getBoundsInLocal().getWidth()) / 2); letter.setTranslateY((getHeight() - letter.getBoundsInLocal().getHeight()) / 2); getChildren().add(letter); // over 3 seconds move letter to random position and fade it out final Timeline timeline = new Timeline(); timeline.getKeyFrames().add( new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { // we are done remove us from scene getChildren().remove(letter); } }, new KeyValue(letter.translateXProperty(), getRandom(0.0f, getWidth() - letter.getBoundsInLocal().getWidth()),INTERPOLATOR), new KeyValue(letter.translateYProperty(), getRandom(0.0f, getHeight() - letter.getBoundsInLocal().getHeight()),INTERPOLATOR), new KeyValue(letter.opacityProperty(), 0f) )); timeline.play(); }
Example 3
Source File: TowerDefenseApp.java From FXGLGames with MIT License | 6 votes |
private void onEnemyKilled(EnemyKilledEvent event) { levelEnemies--; if (levelEnemies == 0) { gameOver(); } Entity enemy = event.getEnemy(); Point2D position = enemy.getPosition(); Text xMark = getUIFactory().newText("X", Color.RED, 24); xMark.setTranslateX(position.getX()); xMark.setTranslateY(position.getY() + 20); getGameScene().addGameView(new GameView(xMark, 1000)); }
Example 4
Source File: IOSApp.java From mars-sim with GNU General Public License v3.0 | 6 votes |
private Parent createContent() { Pane root = new Pane(); root.setPrefSize(300, 300); Rectangle bg = new Rectangle(300, 300); ToggleSwitch toggle = new ToggleSwitch(); toggle.setTranslateX(100); toggle.setTranslateY(100); Text text = new Text(); text.setFont(Font.font(18)); text.setFill(Color.WHITE); text.setTranslateX(100); text.setTranslateY(200); text.textProperty().bind(Bindings.when(toggle.switchedOnProperty()).then("ON").otherwise("OFF")); root.getChildren().addAll(toggle, text); return root; }
Example 5
Source File: TowerDefenseApp.java From FXGLGames with MIT License | 6 votes |
private void onEnemyKilled(EnemyKilledEvent event) { levelEnemies--; if (levelEnemies == 0) { gameOver(); } Entity enemy = event.getEnemy(); Point2D position = enemy.getPosition(); Text xMark = getUIFactory().newText("X", Color.RED, 24); xMark.setTranslateX(position.getX()); xMark.setTranslateY(position.getY() + 20); getGameScene().addGameView(new GameView(xMark, 1000)); }
Example 6
Source File: IOSApp.java From FXTutorials with MIT License | 6 votes |
private Parent createContent() { Pane root = new Pane(); root.setPrefSize(300, 300); Rectangle bg = new Rectangle(300, 300); ToggleSwitch toggle = new ToggleSwitch(); toggle.setTranslateX(100); toggle.setTranslateY(100); Text text = new Text(); text.setFont(Font.font(18)); text.setFill(Color.WHITE); text.setTranslateX(100); text.setTranslateY(200); text.textProperty().bind(Bindings.when(toggle.switchedOnProperty()).then("ON").otherwise("OFF")); root.getChildren().addAll(toggle, text); return root; }
Example 7
Source File: FlappyBirdApp.java From FXGLGames with MIT License | 5 votes |
@Override protected void initUI() { Text uiScore = new Text(""); uiScore.setFont(Font.font(72)); uiScore.setTranslateX(getAppWidth() - 200); uiScore.setTranslateY(50); uiScore.fillProperty().bind(getop("stageColor")); uiScore.textProperty().bind(getip("score").asString()); addUINode(uiScore); Group dpadView = getInput().createVirtualDpadView(); addUINode(dpadView, 0, 625); }
Example 8
Source File: FlappyBirdApp.java From FXGLGames with MIT License | 5 votes |
@Override protected void initUI() { Text uiScore = new Text(""); uiScore.setFont(Font.font(72)); uiScore.setTranslateX(getAppWidth() - 200); uiScore.setTranslateY(50); uiScore.fillProperty().bind(getop("stageColor")); uiScore.textProperty().bind(getip("score").asString()); addUINode(uiScore); Group dpadView = getInput().createVirtualDpadView(); addUINode(dpadView, 0, 625); }
Example 9
Source File: GeoWarsApp.java From FXGLGames with MIT License | 5 votes |
@Override protected void initUI() { Text scoreText = getUIFactoryService().newText("", Color.WHITE, 28); scoreText.setTranslateX(60); scoreText.setTranslateY(70); scoreText.textProperty().bind(getip("score").asString()); scoreText.setStroke(Color.GOLD); Text multText = getUIFactoryService().newText("", Color.WHITE, 28); multText.setTranslateX(60); multText.setTranslateY(90); multText.textProperty().bind(getip("multiplier").asString("x %d")); var livesText = getUIFactoryService().newText("", Color.WHITE, 24.0); livesText.setTranslateX(60); livesText.setTranslateY(110); livesText.textProperty().bind(getip("lives").asString("Lives: %d")); getGameScene().addUINodes(multText, scoreText, livesText); Text beware = getUIFactoryService().newText("Beware! Seekers get smarter every spawn!", Color.AQUA, 38); addUINode(beware); centerText(beware); animationBuilder() .duration(Duration.seconds(2)) .autoReverse(true) .repeat(2) .fadeIn(beware) .buildAndPlay(); }
Example 10
Source File: SpaceRunnerApp.java From FXGLGames with MIT License | 5 votes |
private void nextLevel() { uiTextLevel.setVisible(false); inc("level", +1); level = new Level(); level.spawnNewWave(); Text textLevel = getUIFactory().newText("Level " + geti("level"), Color.WHITE, 22); textLevel.setEffect(new DropShadow(7, Color.BLACK)); textLevel.setOpacity(0); centerText(textLevel); textLevel.setTranslateY(250); addUINode(textLevel); animationBuilder() .interpolator(Interpolators.SMOOTH.EASE_OUT()) .duration(Duration.seconds(1.66)) .onFinished(() -> { animationBuilder() .duration(Duration.seconds(1.66)) .interpolator(Interpolators.EXPONENTIAL.EASE_IN()) .onFinished(() -> { removeUINode(textLevel); uiTextLevel.setVisible(true); }) .translate(textLevel) .from(new Point2D(textLevel.getTranslateX(), textLevel.getTranslateY())) .to(new Point2D(330, 540)) .buildAndPlay(); }) .fadeIn(textLevel) .buildAndPlay(); }
Example 11
Source File: StatusBarView.java From narjillos with MIT License | 5 votes |
public Node toNode(int ticksInLastSecond, String environmentStatistics, String performanceStatistics, Speed speed, Effects effects, String trackingStatus, boolean isBusy) { String message = "FPS: " + ticksInLastSecond + " / " + performanceStatistics + "\n" + environmentStatistics + "\n" + getSpeedMessage(speed, effects) + "\n" + "Mode: " + trackingStatus + "\n" + getBusyMessage(isBusy); Text result = new Text(message); result.setFont(Font.font("HelveticaNeue-Bold", 14)); result.setFill(speed.getViewColor()); result.setTranslateX(5); result.setTranslateY(15); return result; }
Example 12
Source File: SpaceRunnerApp.java From FXGLGames with MIT License | 5 votes |
private void nextLevel() { uiTextLevel.setVisible(false); inc("level", +1); level = new Level(); level.spawnNewWave(); Text textLevel = getUIFactory().newText("Level " + geti("level"), Color.WHITE, 22); textLevel.setEffect(new DropShadow(7, Color.BLACK)); textLevel.setOpacity(0); centerText(textLevel); textLevel.setTranslateY(250); addUINode(textLevel); animationBuilder() .interpolator(Interpolators.SMOOTH.EASE_OUT()) .duration(Duration.seconds(1.66)) .onFinished(() -> { animationBuilder() .duration(Duration.seconds(1.66)) .interpolator(Interpolators.EXPONENTIAL.EASE_IN()) .onFinished(() -> { removeUINode(textLevel); uiTextLevel.setVisible(true); }) .translate(textLevel) .from(new Point2D(textLevel.getTranslateX(), textLevel.getTranslateY())) .to(new Point2D(330, 540)) .buildAndPlay(); }) .fadeIn(textLevel) .buildAndPlay(); }
Example 13
Source File: CannonApp.java From FXGLGames with MIT License | 5 votes |
@Override protected void initUI() { Text scoreText = getUIFactory().newText("", Color.BLACK, 24); scoreText.setTranslateX(550); scoreText.setTranslateY(100); scoreText.textProperty().bind(getip("score").asString("Score: [%d]")); addUINode(scoreText); }
Example 14
Source File: Fx3DStageController.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
private void setMzAxis() { axes.getMzAxisLabels().getChildren().clear(); axes.getMzAxisTicks().getChildren().clear(); double mzDelta = (mzRange.upperEndpoint() - mzRange.lowerEndpoint()) / 7; double mzScaleValue = mzRange.lowerEndpoint(); Text mzLabel = new Text("m/z"); mzLabel.setRotationAxis(Rotate.X_AXIS); mzLabel.setRotate(-45); mzLabel.setTranslateX(SIZE / 2); mzLabel.setTranslateZ(-5); mzLabel.setTranslateY(8); axes.getMzAxisLabels().getChildren().add(mzLabel); for (int y = 0; y <= SIZE; y += SIZE / 7) { Line tickLineZ = new Line(0, 0, 0, 9); tickLineZ.setRotationAxis(Rotate.X_AXIS); tickLineZ.setRotate(-90); tickLineZ.setTranslateY(-4); tickLineZ.setTranslateX(y - 2); float roundOff = (float) (Math.round(mzScaleValue * 100.0) / 100.0); Text text = new Text("" + roundOff); text.setRotationAxis(Rotate.X_AXIS); text.setRotate(-45); text.setTranslateY(8); text.setTranslateX(y - 10); text.setTranslateZ(20); mzScaleValue += mzDelta; axes.getMzAxisTicks().getChildren().add(tickLineZ); axes.getMzAxisLabels().getChildren().add(text); } axes.getMzAxisLabels().setRotate(270); axes.getMzAxisLabels().setTranslateX(SIZE / 2 + SIZE / 30); axes.getMzAxisTicks().setTranslateX(SIZE / 2 + 10); axes.getMzAxisTicks().setTranslateY(-1); axes.getMzAxis().setTranslateX(SIZE); }
Example 15
Source File: Fx3DStageController.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
private void setMzAxis() { axes.getMzAxisLabels().getChildren().clear(); axes.getMzAxisTicks().getChildren().clear(); double mzDelta = (mzRange.upperEndpoint() - mzRange.lowerEndpoint()) / 7; double mzScaleValue = mzRange.lowerEndpoint(); Text mzLabel = new Text("m/z"); mzLabel.setRotationAxis(Rotate.X_AXIS); mzLabel.setRotate(-45); mzLabel.setTranslateX(SIZE / 2); mzLabel.setTranslateZ(-5); mzLabel.setTranslateY(8); axes.getMzAxisLabels().getChildren().add(mzLabel); for (int y = 0; y <= SIZE; y += SIZE / 7) { Line tickLineZ = new Line(0, 0, 0, 9); tickLineZ.setRotationAxis(Rotate.X_AXIS); tickLineZ.setRotate(-90); tickLineZ.setTranslateY(-4); tickLineZ.setTranslateX(y - 2); float roundOff = (float) (Math.round(mzScaleValue * 100.0) / 100.0); Text text = new Text("" + (float) roundOff); text.setRotationAxis(Rotate.X_AXIS); text.setRotate(-45); text.setTranslateY(8); text.setTranslateX(y - 10); text.setTranslateZ(20); mzScaleValue += mzDelta; axes.getMzAxisTicks().getChildren().add(tickLineZ); axes.getMzAxisLabels().getChildren().add(text); } axes.getMzAxisLabels().setRotate(270); axes.getMzAxisLabels().setTranslateX(SIZE / 2 + SIZE / 30); axes.getMzAxisTicks().setTranslateX(SIZE / 2 + 10); axes.getMzAxisTicks().setTranslateY(-1); axes.getMzAxis().setTranslateX(SIZE); }
Example 16
Source File: Civ6MenuItem.java From FXTutorials with MIT License | 5 votes |
public Civ6MenuItem(String name) { Polygon bg = new Polygon( 0, 0, 200, 0, 215, 15, 200, 30, 0, 30 ); bg.setStroke(Color.color(1, 1, 1, 0.75)); bg.setEffect(new GaussianBlur()); bg.fillProperty().bind( Bindings.when(pressedProperty()) .then(Color.color(0, 0, 0, 0.75)) .otherwise(Color.color(0, 0, 0, 0.25)) ); text = new Text(name); text.setTranslateX(5); text.setTranslateY(20); text.setFont(Font.loadFont(Civ6MenuApp.class.getResource("res/Penumbra-HalfSerif-Std_35114.ttf").toExternalForm(), 14)); text.setFill(Color.WHITE); text.effectProperty().bind( Bindings.when(hoverProperty()) .then(shadow) .otherwise(blur) ); getChildren().addAll(bg, text); }
Example 17
Source File: SlotMachineApp.java From FXGLGames with MIT License | 5 votes |
@Override protected void initUI() { Text textMoney = new Text(); textMoney.layoutBoundsProperty().addListener((observable, oldValue, newBounds) -> { textMoney.setTranslateX(getAppWidth() / 2 - newBounds.getWidth() / 2); }); textMoney.setTranslateY(50); textMoney.setFont(Font.font(36)); textMoney.setFill(Color.WHITE); textMoney.textProperty().bind(getGameState().intProperty("money").asString("$%d")); getGameScene().addUINode(textMoney); }
Example 18
Source File: Level.java From netbeans with Apache License 2.0 | 4 votes |
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 19
Source File: Level.java From marathonv5 with Apache License 2.0 | 4 votes |
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 20
Source File: Level.java From marathonv5 with Apache License 2.0 | 4 votes |
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); }