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

The following examples show how to use javafx.scene.image.ImageView#setImage() . 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: SuitStack.java    From Solitaire with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void gameStateChanged()
{
	if( GameModel.instance().isFoundationPileEmpty(aIndex))
	{
		getChildren().get(0).setVisible(false);
	}
	else
	{
		getChildren().get(0).setVisible(true);
		Card topCard = GameModel.instance().peekSuitStack(aIndex);
		ImageView image = (ImageView)getChildren().get(0);
		image.setImage(CardImages.getCard(topCard));
		aDragHandler.setCard(topCard);
	}
}
 
Example 2
Source File: ChooseTextureControl.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
/**
 * Reload.
 */
@FxThread
protected void reload() {

    final ImageChannelPreview textureTooltip = getTextureTooltip();
    final Label textureLabel = getTextureLabel();
    final ImageView preview = getTexturePreview();

    final Path textureFile = getTextureFile();

    if (textureFile == null) {
        textureLabel.setText(Messages.MATERIAL_MODEL_PROPERTY_CONTROL_NO_TEXTURE);
        preview.setImage(null);
        textureTooltip.clean();
        return;
    }

    final Path assetFile = notNull(getAssetFile(textureFile));

    textureLabel.setText(assetFile.toString());
    preview.setImage(IMAGE_MANAGER.getImagePreview(textureFile, 28, 28));
    textureTooltip.showImage(textureFile);
}
 
Example 3
Source File: SandboxModeView.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
private void startPlayMode(ActionEvent actionEvent) {
	sidebar.getChildren().setAll(getActionPromptView(), navigationPane);
	backButton.setVisible(false);
	playButton.setText("Stop");
	ImageView buttonGraphic = (ImageView) playButton.getGraphic();
	buttonGraphic.setImage(new Image(IconFactory.getImageUrl("ui/pause_icon.png")));
	playButton.setOnAction(this::stopPlayMode);
	NotificationProxy.sendNotification(GameNotification.START_PLAY_SANDBOX);
}
 
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: Controller.java    From PoE_Level_Buddy with MIT License 5 votes vote down vote up
public void gemRewardBackward(MouseEvent mouseEvent)
{
    if (mouseEvent.getSource() instanceof ImageView)
    {
        ImageView imgView = (ImageView) mouseEvent.getSource();

        if (mouseEvent.getEventType().equals(MouseEvent.MOUSE_ENTERED))
            imgView.setImage(new Image(getClass().getResource("ico/collapse1_hl.png").toString()));
        else if (mouseEvent.getEventType().equals(MouseEvent.MOUSE_EXITED))
            imgView.setImage(new Image(getClass().getResource("ico/collapse1.png").toString()));
        else if (mouseEvent.getEventType().equals(MouseEvent.MOUSE_CLICKED))
            setGemSelectionData(lastUsedPageHandler(false));
    }
}
 
Example 6
Source File: PlaylistsController.java    From MusicPlayer with MIT License 5 votes vote down vote up
void selectPlaylist(Playlist playlist) {
    // Displays the delete button only if the user has not selected one of the default playlists.
    if (playlist instanceof MostPlayedPlaylist || playlist instanceof RecentlyPlayedPlaylist) {
        deleteButton.setVisible(false);
    }

    // Sets the text on the play list title label.
    playlistTitleLabel.setText(playlist.getTitle());

    // Updates the currently selected play list.
    selectedPlaylist = playlist;

    // Retrieves the songs in the selected play list.
    ObservableList<Song> songs = playlist.getSongs();
    
    // Clears the song table.
    tableView.getSelectionModel().clearSelection();
    
    // Populates the song table with the playlist's songs.
    tableView.setItems(songs);

    Label message = new Label(selectedPlaylist.getPlaceholder());
    message.setTextAlignment(TextAlignment.CENTER);

    ImageView image = new ImageView();
    image.setFitHeight(150);
    image.setFitWidth(150);
    image.setImage(new Image(Resources.IMG + "playlistsIcon.png"));

    VBox placeholder = new VBox();
    placeholder.setAlignment(Pos.CENTER);
    placeholder.getChildren().addAll(image, message);
    VBox.setMargin(image, new Insets(0, 0, 50, 0));

    tableView.setPlaceholder(placeholder);
}
 
Example 7
Source File: Controller.java    From PoE_Level_Buddy with MIT License 5 votes vote down vote up
/**
 * Hides the options when pressed.
 */
public void optionsArrow(MouseEvent mouseEvent)
{
    if (mouseEvent.getSource() instanceof ImageView)
    {
        ImageView imgView = (ImageView) mouseEvent.getSource();

        if (mouseEvent.getEventType().equals(MouseEvent.MOUSE_ENTERED))
        {
            imgView.setImage(new Image(getClass().getResource("ico/collapse0_hl.png").toString()));
        }
        else if (mouseEvent.getEventType().equals(MouseEvent.MOUSE_EXITED))
        {
            imgView.setImage(new Image(getClass().getResource("ico/collapse0.png").toString()));
        }
        else if (mouseEvent.getEventType().equals(MouseEvent.MOUSE_CLICKED))
        {
            Settings.getINSTANCE().setBandits(comboBoxThatIsSelected());
            Settings.getINSTANCE().saveData();
            optionsAnchorPane.setVisible(false);
            optionsAnchorPaneMenu.setVisible(false);
            gemSelectorAnchorPane.setVisible(false);
            for (ImageView i : actArray)
                i.setVisible(false);
            inOptions = false;
            HelperZonePane.setVisible(true);
        }
    }
}
 
Example 8
Source File: TableImageFileCell.java    From MyBox with Apache License 2.0 5 votes vote down vote up
@Override
public TableCell<T, String> call(TableColumn<T, String> param) {
    final ImageView imageview = new ImageView();
    imageview.setPreserveRatio(true);
    imageview.setFitWidth(imageSize);
    imageview.setFitHeight(imageSize);
    TableCell<T, String> cell = new TableCell<T, String>() {
        @Override
        public void updateItem(String item, boolean empty) {
            super.updateItem(item, empty);
            if (empty || item == null) {
                setText(null);
                setGraphic(null);
                return;
            }
            try {
                File file = new File(item.toString());
                BufferedImage image = ImageIO.read(file);
                imageview.setImage(SwingFXUtils.toFXImage(image, null));
                setGraphic(imageview);
            } catch (Exception e) {
                setText(null);
                setGraphic(null);
            }
        }
    };
    return cell;
}
 
Example 9
Source File: WebDrawer.java    From Quelea with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void draw(Displayable displayable) {
    clear();
    if(displayable==null) {
        return;
    }
    d = (WebDisplayable) displayable;
    webView = d.getWebView();
    webEngine = d.getWebEngine();
    if (!getCanvas().isStageView()) {
        if (!d.getUrl().startsWith("http")) {
            d.setUrl("http://" + d.getUrl());
        } else {
            if (webEngine.getTitle() == null) {
                webEngine.load(d.getUrl());
            }
        }
        addWebView(webView);
    } else {
        ImageView imageView = getCanvas().getNewImageView();
        imageView.setFitWidth(getCanvas().getWidth());
        Image image = Utils.getImageFromColour(QueleaProperties.get().getStageBackgroundColor());
        imageView.setImage(image);
        getCanvas().getChildren().add(imageView);
    }

}
 
Example 10
Source File: WebFrame.java    From oim-fx with MIT License 5 votes vote down vote up
private void init() {
    
    VBox rootVBox = new VBox();
    
    this.setCenter(rootVBox);
   // this.setBackground("Resources/Images/Wallpaper/1.jpg");
    this.setTitle("登录");
    this.setWidth(380);
    this.setHeight(600);
    this.setRadius(10);
    
    StackPane u = new StackPane();
    u.setPrefSize(50, 100);
   // String hString = this.getClass().getResource("/resources/chat/index.html").toString();
    File file = new File("Resources/Images/Head/User/90_100.gif");
    
    String fullPath = file.getAbsolutePath();
    String htmlText = "<html><body> <lable>666</label>"
            + "<img src=\"file:/"+fullPath+"\" />"
            + "</body></html> ";
    System.out.println(htmlText);
    WebView webView = new WebView();
    webView.setContextMenuEnabled(false);
    WebEngine we = webView.getEngine();
    //we.load(hString);
    Image logoIamge = new Image(this.getClass().getResource("/resources/login/logo.png").toExternalForm(), true);
    ImageView logoImageView = new ImageView();
    logoImageView.setImage(logoIamge);
    we.loadContent(htmlText);
   // Document d = we.getDocument();
    // Element root = we.getDocument().getDocumentElement();
    // NodeList nl = root.getElementsByTagName("body");
    // Node node = nl.item(0);

    //node.appendChild(node);
    rootVBox.getChildren().add(u);
    rootVBox.getChildren().add(webView);
}
 
Example 11
Source File: HeadImageFrame.java    From oim-fx with MIT License 5 votes vote down vote up
private void init() {
	this.setCenter(rootPane);
	this.setTitle("组件测试");
	this.setWidth(380);
	this.setHeight(600);
	this.setRadius(10);

	VBox topBox = new VBox();
	topBox.setPrefHeight(50);
	rootPane.setTop(topBox);

	Image image = ImageBox.getImageClassPath("/images/head/101_100.gif");

	ImageNode imageButton = new ImageNode();

	imageButton.setImage(image);
	imageButton.setImageSize(80);
	imageButton.setImageRadius(20);
	imageButton.setGray(true);
	imageButton.setEffect(new DropShadow(20, Color.BLACK));

	ImageView imageView = new ImageView();
	imageView.setImage(image);

	StackPane stackPane = new StackPane();
	stackPane.getChildren().add(imageButton);
	stackPane.setStyle("-fx-background-color:rgba(150,120,210,1)");

	rootPane.setCenter(stackPane);
}
 
Example 12
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 13
Source File: StopWatchSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private void configureBackground() {
    ImageView imageView = new ImageView();
    Image image = loadImage();
    imageView.setImage(image);

    Circle circle1 = new Circle();
    circle1.setCenterX(140);
    circle1.setCenterY(140);
    circle1.setRadius(120);
    circle1.setFill(Color.TRANSPARENT);
    circle1.setStroke(Color.web("#0A0A0A"));
    circle1.setStrokeWidth(0.3);

    Circle circle2 = new Circle();
    circle2.setCenterX(140);
    circle2.setCenterY(140);
    circle2.setRadius(118);
    circle2.setFill(Color.TRANSPARENT);
    circle2.setStroke(Color.web("#0A0A0A"));
    circle2.setStrokeWidth(0.3);

    Circle circle3 = new Circle();
    circle3.setCenterX(140);
    circle3.setCenterY(140);
    circle3.setRadius(140);
    circle3.setFill(Color.TRANSPARENT);
    circle3.setStroke(Color.web("#818a89"));
    circle3.setStrokeWidth(1);

    Ellipse ellipse = new Ellipse(140, 95, 180, 95);
    Circle ellipseClip = new Circle(140, 140, 140);
    ellipse.setFill(Color.web("#535450"));
    ellipse.setStrokeWidth(0);
    GaussianBlur ellipseEffect = new GaussianBlur();
    ellipseEffect.setRadius(10);
    ellipse.setEffect(ellipseEffect);
    ellipse.setOpacity(0.1);
    ellipse.setClip(ellipseClip);
    background.getChildren().addAll(imageView, circle1, circle2, circle3, ellipse);
}
 
Example 14
Source File: StopWatch.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void configureBackground() {
    ImageView imageView = new ImageView();
    Image image = loadImage();
    imageView.setImage(image);

    Circle circle1 = new Circle();
    circle1.setCenterX(140);
    circle1.setCenterY(140);
    circle1.setRadius(120);
    circle1.setFill(Color.TRANSPARENT);
    circle1.setStroke(Color.web("#0A0A0A"));
    circle1.setStrokeWidth(0.3);

    Circle circle2 = new Circle();
    circle2.setCenterX(140);
    circle2.setCenterY(140);
    circle2.setRadius(118);
    circle2.setFill(Color.TRANSPARENT);
    circle2.setStroke(Color.web("#0A0A0A"));
    circle2.setStrokeWidth(0.3);

    Circle circle3 = new Circle();
    circle3.setCenterX(140);
    circle3.setCenterY(140);
    circle3.setRadius(140);
    circle3.setFill(Color.TRANSPARENT);
    circle3.setStroke(Color.web("#818a89"));
    circle3.setStrokeWidth(1);

    Ellipse ellipse = new Ellipse(140, 95, 180, 95);
    Circle ellipseClip = new Circle(140, 140, 140);
    ellipse.setFill(Color.web("#535450"));
    ellipse.setStrokeWidth(0);
    GaussianBlur ellipseEffect = new GaussianBlur();
    ellipseEffect.setRadius(10);
    ellipse.setEffect(ellipseEffect);
    ellipse.setOpacity(0.1);
    ellipse.setClip(ellipseClip);
    background.getChildren().addAll(imageView, circle1, circle2, circle3, ellipse);
}
 
Example 15
Source File: ModelImportDialog.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
protected boolean validate(@NotNull final VarTable vars) {

    final ImageView imageView = getImageView();

    if (!vars.has(PROP_FILE)) {
        imageView.setImage(null);
        return false;
    }

    final Path file = vars.get(PROP_FILE);

    if (!JmeFilePreviewManager.isModelFile(file)) {
        imageView.setImage(null);
        return false;
    }

    final Path renderedFile = getRenderedFile();
    if (renderedFile != null && file.equals(renderedFile)) {
        return super.validate(vars);
    }

    final int width = (int) imageView.getFitWidth();
    final int height = (int) imageView.getFitHeight();

    final JmeFilePreviewManager previewManager = JmeFilePreviewManager.getInstance();
    previewManager.showExternal(file, width, height);

    final ImageView sourceView = previewManager.getImageView();
    final ObjectProperty<Image> imageProperty = imageView.imageProperty();
    imageProperty.bind(sourceView.imageProperty());

    setRenderedFile(file);

    return super.validate(vars);
}
 
Example 16
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 17
Source File: dashOld.java    From Client with MIT License 4 votes vote down vote up
private void showSuccessToUI(String uniqueID, String status) throws Exception {
    for (Node eachNode : actionsVBox.getChildren()) {
        HBox eachRow = (HBox) eachNode;
        for (Node eachActionPane : eachRow.getChildren()) {
            Pane eachAction = (Pane) eachActionPane;
            String[] xxa = eachAction.getId().split("::");
            if (xxa[2].equals(uniqueID)) {
                if (!xxa[0].equals("folder")) {
                    Pane iconPane = (Pane) eachAction.getChildren().get(1);
                    ImageView icon = (ImageView) iconPane.getChildren().get(0);

                    if (status.equals("1")) {
                        icon.setImage(doneIcon);
                    } else if (status.equals("0")) {
                        icon.setImage(failedIcon);
                    }

                                                        /*ScaleTransition lol2 = new ScaleTransition(Duration.millis(450), eachAction);
                                                        lol2.setFromX(0.9);
                                                        lol2.setFromY(0.9);
                                                        lol2.setToX(1.0);
                                                        lol2.setToY(1.0);

                                                        FadeTransition lol3 = new FadeTransition(Duration.millis(450),eachAction);
                                                        lol3.setFromValue(0.7);
                                                        lol3.setToValue(1.0);

                                                        lol2.play();
                                                        lol3.play();*/

                    Platform.runLater(() -> eachAction.setDisable(false));
                    FadeIn lol = new FadeIn(iconPane);
                    lol.setOnFinished(event -> {
                        FadeOut lol2 = new FadeOut(iconPane);
                        lol2.setDelay(Duration.millis(200));
                        lol2.play();
                        lol2.setOnFinished(event1 -> {
                            iconPane.setOpacity(0.0);
                            eachAction.setDisable(false);
                        });
                    });
                    lol.setDelay(Duration.millis(100));
                    lol.play();
                    break;
                } else {
                    System.out.println("FAILED");
                }
            }
        }
    }
}
 
Example 18
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 19
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 20
Source File: Controller.java    From PoE_Level_Buddy with MIT License 4 votes vote down vote up
/**
 * Handles highlighting of act buttons.
 */
public void actButtonMouseOver(MouseEvent mouseEvent)
{
    if (mouseEvent.getSource() instanceof ImageView)
    {
        ImageView imgView = (ImageView) mouseEvent.getSource();

        int actNum = actNumParser(imgView.getId());

        if (mouseEvent.getEventType().equals(MouseEvent.MOUSE_ENTERED))
        {
            imgView.setImage(new Image(getClass().getResource("act_buttons/hl/act" + actNum + ".png").toString()));
        }
        else if (mouseEvent.getEventType().equals(MouseEvent.MOUSE_EXITED))
        {
            if (Flags.getINSTANCE().getCurrentActiveAct() != actNum)
            {
                imgView.setImage(new Image(getClass().getResource("act_buttons/act" + actNum + ".png").toString()));
            }
        }
        else if (mouseEvent.getEventType().equals(MouseEvent.MOUSE_CLICKED))
        {
            int actNumPrev = Flags.getINSTANCE().getCurrentActiveAct();

            if (actNum != actNumPrev || Flags.getINSTANCE().getActiveWindow() == 0)
            {
                imgView.setImage(new Image(getClass().getResource("act_buttons/hl/act" + actNum + ".png").toString()));
                actArray.get(actNumPrev-1).setImage(new Image(getClass().getResource("act_buttons/act" + actNumPrev + ".png").toString()));
                Flags.getINSTANCE().setCurrentActiveAct(actNum);

                // Activate the options for that specific act if inOptions.
                if (inOptions)
                {
                    //System.out.println("We should be loading gem selections now...");
                    // Set Quest Reward Data
                    if (actNum == 1)
                        setGemSelectionData(0);
                    else if (actNum == 2)
                        setGemSelectionData(4);
                    else if (actNum == 3)
                        setGemSelectionData(6);
                    else if (actNum == 4)
                        setGemSelectionData(8);

                    // Hide options
                    if (Flags.getINSTANCE().getActiveWindow() == 0)
                    {
                        optionsAnchorPane.setVisible(false);
                    }

                    gemSelectorAnchorPane.setVisible(true);
                }
            }
        }
    }
}