Java Code Examples for javafx.scene.image.ImageView#setTranslateX()

The following examples show how to use javafx.scene.image.ImageView#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: View.java    From FXTutorials with MIT License 6 votes vote down vote up
public View(Controller controller) {
    this.controller = controller;

    setPrefSize(635 * 2, 500);

    Image image = new Image("http://cdn.ndtv.com/tech/windows_10_startmenu_cropped.jpg");
    ImageView originalView = new ImageView(image);

    ImageView modifiedView = new ImageView();
    modifiedView.setTranslateX(635);

    TextField field = new TextField("Enter message");
    field.setTranslateY(454);
    field.setOnAction(e -> controller.onEncode());

    Button btnDecode = new Button("DECODE");
    btnDecode.setTranslateX(635);
    btnDecode.setTranslateY(454);
    btnDecode.setOnAction(e -> controller.onDecode());

    controller.injectUI(originalView, modifiedView, field);

    getChildren().addAll(originalView, modifiedView, field, btnDecode);
}
 
Example 2
Source File: NodeMenuItem.java    From PDF4Teachers with Apache License 2.0 5 votes vote down vote up
public void setImage(ImageView image){
    Pane pane = new Pane();
    if(fat){
        pane.setStyle("-fx-padding: 7 0 7 10;"); // top - right - bottom - left
        image.setTranslateY(7);
    }else{ pane.setStyle("-fx-padding: 3 0 3 10;"); // top - right - bottom - left
        image.setTranslateY(3);
    } image.setTranslateX(10);

    pane.getChildren().add(image);
    getNode().getChildren().set(1, pane);
}
 
Example 3
Source File: Bat.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public Bat() {
    height = (int)CENTER.getHeight() - Config.SHADOW_HEIGHT; 
    Group group = new Group();
    leftImageView = new ImageView();
    leftImageView.setImage(LEFT);
    centerImageView = new ImageView();
    centerImageView.setImage(CENTER);
    centerImageView.setTranslateX(LEFT.getWidth());
    rightImageView = new ImageView();
    rightImageView.setImage(RIGHT);
    changeSize(DEFAULT_SIZE);
    group.getChildren().addAll(leftImageView, centerImageView, rightImageView);
    getChildren().add(group);
    setMouseTransparent(true);
}
 
Example 4
Source File: Bat.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public Bat() {
    height = (int)CENTER.getHeight() - Config.SHADOW_HEIGHT; 
    Group group = new Group();
    leftImageView = new ImageView();
    leftImageView.setImage(LEFT);
    centerImageView = new ImageView();
    centerImageView.setImage(CENTER);
    centerImageView.setTranslateX(LEFT.getWidth());
    rightImageView = new ImageView();
    rightImageView.setImage(RIGHT);
    changeSize(DEFAULT_SIZE);
    group.getChildren().addAll(leftImageView, centerImageView, rightImageView);
    getChildren().add(group);
    setMouseTransparent(true);
}
 
Example 5
Source File: Bat.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Bat() {
    height = (int)CENTER.getHeight() - Config.SHADOW_HEIGHT; 
    Group group = new Group();
    leftImageView = new ImageView();
    leftImageView.setImage(LEFT);
    centerImageView = new ImageView();
    centerImageView.setImage(CENTER);
    centerImageView.setTranslateX(LEFT.getWidth());
    rightImageView = new ImageView();
    rightImageView.setImage(RIGHT);
    changeSize(DEFAULT_SIZE);
    group.getChildren().addAll(leftImageView, centerImageView, rightImageView);
    getChildren().add(group);
    setMouseTransparent(true);
}
 
Example 6
Source File: FxIconBuilder.java    From FxDock with Apache License 2.0 5 votes vote down vote up
/** add image */
public void image(byte[] bytes)
{
	ImageView v = new ImageView();
	v.setImage(new Image(new ByteArrayInputStream(bytes)));
	applyNodeProperties(v);
	v.setTranslateX(xtranslate + xorigin);
	v.setTranslateY(ytranslate + yorigin);
	
	elements.add(v);
}
 
Example 7
Source File: Splash.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
Splash() {
    state = STATE_SHOW_TITLE;
    stateArg = 0;
    initTimeline();
    background = new ImageView();
    background.setFocusTraversable(true);
    background.setImage(Config.getImages().get(Config.IMAGE_BACKGROUND));
    background.setFitWidth(Config.SCREEN_WIDTH);
    background.setFitHeight(Config.SCREEN_HEIGHT);
    background.setOnMousePressed(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            Main.getMainFrame().startGame();
        }
    });
    background.setOnKeyPressed(new EventHandler<KeyEvent>() {
        public void handle(KeyEvent ke) {
            Main.getMainFrame().startGame();
        }
    });
    brick = new ImageView();
    brick.setImage(Config.getImages().get(Config.IMAGE_SPLASH_BRICK));
    brick.setTranslateX(-1000);
    brick.setTranslateY(brick.getImage().getHeight());
    brickShadow = new ImageView();
    brickShadow.setImage(Config.getImages().get(Config.IMAGE_SPLASH_BRICKSHADOW));
    brickShadow.setTranslateX(-1000);
    breaker = new ImageView();
    breaker.setImage(Config.getImages().get(Config.IMAGE_SPLASH_BREAKER));
    breaker.setTranslateX(-1000);
    breaker.setTranslateY(brick.getTranslateY() + brick.getImage().getHeight() * 5 / 4);
    breakerShadow = new ImageView();
    breakerShadow.setImage(Config.getImages().get(Config.IMAGE_SPLASH_BREAKERSHADOW));
    breakerShadow.setTranslateX(-1000);
    strike = new ImageView();
    strike.setImage(Config.getImages().get(Config.IMAGE_SPLASH_STRIKE));
    strike.setTranslateY(brick.getTranslateY() -
        (strike.getImage().getHeight() - brick.getImage().getHeight()) / 2);
    strike.setVisible(false);
    pressanykey = new ImageView();
    pressanykey.setImage(Config.getImages().get(Config.IMAGE_SPLASH_PRESSANYKEY));
    pressanykey.setTranslateX((Config.SCREEN_WIDTH - pressanykey.getImage().getWidth()) / 2);
    double y = breaker.getTranslateY() + breaker.getImage().getHeight();
    pressanykey.setTranslateY(y + (Config.SCREEN_HEIGHT - y) / 2);
    pressanykey.setOpacity(0);
    strikeShadow = new ImageView();
    strikeShadow.setImage(Config.getImages().get(Config.IMAGE_SPLASH_STRIKESHADOW));
    strikeShadow.setTranslateX(-1000);
    pressanykeyShadow = new ImageView();
    pressanykeyShadow.setImage(Config.getImages().get(Config.IMAGE_SPLASH_PRESSANYKEYSHADOW));
    pressanykeyShadow.setTranslateX(-1000);
    sun = new ImageView();
    sun.setImage(Config.getImages().get(Config.IMAGE_SPLASH_SUN));
    sun.setTranslateX(-1000);
    NODES = new ImageView[] {brick, breaker, strike, pressanykey};
    NODES_SHADOWS = new ImageView[] {brickShadow, breakerShadow, strikeShadow, pressanykeyShadow};
    Group group = new Group();
    group.getChildren().add(background);
    group.getChildren().addAll(NODES_SHADOWS);
    group.getChildren().addAll(NODES);
    group.getChildren().add(sun);
    getChildren().add(group);
}
 
Example 8
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 9
Source File: Splash.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
Splash() {
    state = STATE_SHOW_TITLE;
    stateArg = 0;
    initTimeline();
    background = new ImageView();
    background.setFocusTraversable(true);
    background.setImage(Config.getImages().get(Config.IMAGE_BACKGROUND));
    background.setFitWidth(Config.SCREEN_WIDTH);
    background.setFitHeight(Config.SCREEN_HEIGHT);
    background.setOnMousePressed(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            Main.getMainFrame().startGame();
        }
    });
    background.setOnKeyPressed(new EventHandler<KeyEvent>() {
        public void handle(KeyEvent ke) {
            Main.getMainFrame().startGame();
        }
    });
    brick = new ImageView();
    brick.setImage(Config.getImages().get(Config.IMAGE_SPLASH_BRICK));
    brick.setTranslateX(-1000);
    brick.setTranslateY(brick.getImage().getHeight());
    brickShadow = new ImageView();
    brickShadow.setImage(Config.getImages().get(Config.IMAGE_SPLASH_BRICKSHADOW));
    brickShadow.setTranslateX(-1000);
    breaker = new ImageView();
    breaker.setImage(Config.getImages().get(Config.IMAGE_SPLASH_BREAKER));
    breaker.setTranslateX(-1000);
    breaker.setTranslateY(brick.getTranslateY() + brick.getImage().getHeight() * 5 / 4);
    breakerShadow = new ImageView();
    breakerShadow.setImage(Config.getImages().get(Config.IMAGE_SPLASH_BREAKERSHADOW));
    breakerShadow.setTranslateX(-1000);
    strike = new ImageView();
    strike.setImage(Config.getImages().get(Config.IMAGE_SPLASH_STRIKE));
    strike.setTranslateY(brick.getTranslateY() -
        (strike.getImage().getHeight() - brick.getImage().getHeight()) / 2);
    strike.setVisible(false);
    pressanykey = new ImageView();
    pressanykey.setImage(Config.getImages().get(Config.IMAGE_SPLASH_PRESSANYKEY));
    pressanykey.setTranslateX((Config.SCREEN_WIDTH - pressanykey.getImage().getWidth()) / 2);
    double y = breaker.getTranslateY() + breaker.getImage().getHeight();
    pressanykey.setTranslateY(y + (Config.SCREEN_HEIGHT - y) / 2);
    pressanykey.setOpacity(0);
    strikeShadow = new ImageView();
    strikeShadow.setImage(Config.getImages().get(Config.IMAGE_SPLASH_STRIKESHADOW));
    strikeShadow.setTranslateX(-1000);
    pressanykeyShadow = new ImageView();
    pressanykeyShadow.setImage(Config.getImages().get(Config.IMAGE_SPLASH_PRESSANYKEYSHADOW));
    pressanykeyShadow.setTranslateX(-1000);
    sun = new ImageView();
    sun.setImage(Config.getImages().get(Config.IMAGE_SPLASH_SUN));
    sun.setTranslateX(-1000);
    NODES = new ImageView[] {brick, breaker, strike, pressanykey};
    NODES_SHADOWS = new ImageView[] {brickShadow, breakerShadow, strikeShadow, pressanykeyShadow};
    Group group = new Group();
    group.getChildren().add(background);
    group.getChildren().addAll(NODES_SHADOWS);
    group.getChildren().addAll(NODES);
    group.getChildren().add(sun);
    getChildren().add(group);
}
 
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: Splash.java    From netbeans with Apache License 2.0 4 votes vote down vote up
Splash() {
    state = STATE_SHOW_TITLE;
    stateArg = 0;
    initTimeline();
    background = new ImageView();
    background.setFocusTraversable(true);
    background.setImage(Config.getImages().get(Config.IMAGE_BACKGROUND));
    background.setFitWidth(Config.SCREEN_WIDTH);
    background.setFitHeight(Config.SCREEN_HEIGHT);
    background.setOnMousePressed(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            Main.getMainFrame().startGame();
        }
    });
    background.setOnKeyPressed(new EventHandler<KeyEvent>() {
        public void handle(KeyEvent ke) {
            Main.getMainFrame().startGame();
        }
    });
    brick = new ImageView();
    brick.setImage(Config.getImages().get(Config.IMAGE_SPLASH_BRICK));
    brick.setTranslateX(-1000);
    brick.setTranslateY(brick.getImage().getHeight());
    brickShadow = new ImageView();
    brickShadow.setImage(Config.getImages().get(Config.IMAGE_SPLASH_BRICKSHADOW));
    brickShadow.setTranslateX(-1000);
    breaker = new ImageView();
    breaker.setImage(Config.getImages().get(Config.IMAGE_SPLASH_BREAKER));
    breaker.setTranslateX(-1000);
    breaker.setTranslateY(brick.getTranslateY() + brick.getImage().getHeight() * 5 / 4);
    breakerShadow = new ImageView();
    breakerShadow.setImage(Config.getImages().get(Config.IMAGE_SPLASH_BREAKERSHADOW));
    breakerShadow.setTranslateX(-1000);
    strike = new ImageView();
    strike.setImage(Config.getImages().get(Config.IMAGE_SPLASH_STRIKE));
    strike.setTranslateY(brick.getTranslateY() -
        (strike.getImage().getHeight() - brick.getImage().getHeight()) / 2);
    strike.setVisible(false);
    pressanykey = new ImageView();
    pressanykey.setImage(Config.getImages().get(Config.IMAGE_SPLASH_PRESSANYKEY));
    pressanykey.setTranslateX((Config.SCREEN_WIDTH - pressanykey.getImage().getWidth()) / 2);
    double y = breaker.getTranslateY() + breaker.getImage().getHeight();
    pressanykey.setTranslateY(y + (Config.SCREEN_HEIGHT - y) / 2);
    pressanykey.setOpacity(0);
    strikeShadow = new ImageView();
    strikeShadow.setImage(Config.getImages().get(Config.IMAGE_SPLASH_STRIKESHADOW));
    strikeShadow.setTranslateX(-1000);
    pressanykeyShadow = new ImageView();
    pressanykeyShadow.setImage(Config.getImages().get(Config.IMAGE_SPLASH_PRESSANYKEYSHADOW));
    pressanykeyShadow.setTranslateX(-1000);
    sun = new ImageView();
    sun.setImage(Config.getImages().get(Config.IMAGE_SPLASH_SUN));
    sun.setTranslateX(-1000);
    NODES = new ImageView[] {brick, breaker, strike, pressanykey};
    NODES_SHADOWS = new ImageView[] {brickShadow, breakerShadow, strikeShadow, pressanykeyShadow};
    Group group = new Group();
    group.getChildren().add(background);
    group.getChildren().addAll(NODES_SHADOWS);
    group.getChildren().addAll(NODES);
    group.getChildren().add(sun);
    getChildren().add(group);
}
 
Example 12
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 13
Source File: HoverOverlayImageView.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
private void setImage(ImageView imageView, Image image) {
	imageView.setImage(image);
	// translate to center
	imageView.setTranslateX(-image.getWidth() / 2);
	imageView.setTranslateY(-image.getHeight() / 2);
}
 
Example 14
Source File: SplitFlap.java    From Enzo with Apache License 2.0 4 votes vote down vote up
private void initGraphics() {
    background = new ImageView(BACKGROUND);
    background.setFitWidth(DEFAULT_WIDTH);
    background.setFitHeight(DEFAULT_HEIGHT);
    background.setPreserveRatio(true);
    background.setSmooth(true);
    background.setCache(true);

    flap = new ImageView(FLAP);
    flap.setFitWidth(DEFAULT_WIDTH * 0.8461538462);
    flap.setFitHeight(DEFAULT_HEIGHT * 0.407960199);
    flap.setPreserveRatio(true);
    flap.setSmooth(true);
    flap.setTranslateX(DEFAULT_HEIGHT * 0.0447761194);
    flap.setTranslateY(DEFAULT_HEIGHT * 0.0447761194);
    flap.setCache(true);
    flap.setCacheHint(CacheHint.ROTATE);
    flap.getTransforms().add(rotateFlap);
    rotateFlap.setPivotY(DEFAULT_HEIGHT * 0.460199005);
    flap.setCache(true);
    flap.setCacheHint(CacheHint.SPEED);

    upperBackgroundText    = new Canvas();
    ctxUpperBackgroundText = upperBackgroundText.getGraphicsContext2D();
    ctxUpperBackgroundText.setTextBaseline(VPos.CENTER);
    ctxUpperBackgroundText.setTextAlign(TextAlignment.CENTER);

    lowerBackgroundText    = new Canvas();
    ctxLowerBackgroundText = lowerBackgroundText.getGraphicsContext2D();
    ctxLowerBackgroundText.setTextBaseline(VPos.CENTER);
    ctxLowerBackgroundText.setTextAlign(TextAlignment.CENTER);

    flapTextFront = new Canvas();
    flapTextFront.getTransforms().add(rotateFlap);
    ctxTextFront  = flapTextFront.getGraphicsContext2D();
    ctxTextFront.setTextBaseline(VPos.CENTER);
    ctxTextFront.setTextAlign(TextAlignment.CENTER);

    flapTextBack  = new Canvas();
    flapTextBack.getTransforms().add(rotateFlap);
    flapTextBack.setOpacity(0);

    ctxTextBack   = flapTextBack.getGraphicsContext2D();
    ctxTextBack.setTextBaseline(VPos.CENTER);
    ctxTextBack.setTextAlign(TextAlignment.CENTER);

    pane.getChildren().setAll(background,
                              upperBackgroundText,
                              lowerBackgroundText,
                              flap,
                              flapTextFront,
                              flapTextBack);

    getChildren().setAll(pane);
    resize();
}