Example usage for javafx.scene.image ImageView getStyleClass

List of usage examples for javafx.scene.image ImageView getStyleClass

Introduction

In this page you can find the example usage for javafx.scene.image ImageView getStyleClass.

Prototype

@Override
    public final ObservableList<String> getStyleClass() 

Source Link

Usage

From source file:ijfx.core.icon.DefaultFXIconService.java

@Override
public Node getIconAsNode(String iconPath) {

    if (iconPath == null) {
        return null;
    }//  w  w w . j  a  v a 2 s .  c o m
    if ("".equals(iconPath)) {
        return null;
    }

    if (fontawesomeIconEquivalent.containsKey(iconPath)) {
        return getIconAsNode(fontawesomeIconEquivalent.get(iconPath));
    } else if (iconPath.startsWith("fa:")) {
        try {
            return new FontAwesomeIconView(getIcon(iconPath));
        } catch (Exception e) {
            logger.log(Level.WARNING,
                    String.format("Couldn't load FA icon : %s", iconPath.substring(3).toUpperCase()));
            return new FontAwesomeIconView(FontAwesomeIcon.REMOVE);
        }
    } else {

        ImageView imageView = new ImageView(iconPath);
        imageView.getStyleClass().add("image-icon");
        return imageView;
    }

}

From source file:photobooth.views.ExplorerPane.java

private BorderPane createImageView(final File imageFile) {
    // DEFAULT_THUMBNAIL_WIDTH is a constant you need to define
    // The last two arguments are: preserveRatio, and use smooth (slower)
    // resizing/*ww  w  . j av  a 2  s  .com*/
    ExplorerPane explorerPane = this;
    ImageView imageView = null;
    BorderPane borderPane = new BorderPane();
    try {
        borderPane.setMaxSize(100, 100);
        borderPane.setMinSize(100, 100);
        FileInputStream fileInputStream = new FileInputStream(imageFile);
        final Image image = new Image(fileInputStream, 100, 100, true, true);
        imageView = new ImageView(image);
        fileInputStream.close();
        imageView.getStyleClass().add("image-view");
        borderPane.setCenter(imageView);
        //imageView.setFitWidth(80);
        imageView.setOnMouseClicked(new EventHandler<MouseEvent>() {

            @Override
            public void handle(MouseEvent mouseEvent) {

                if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) {

                    if (mouseEvent.getClickCount() == 1) {
                        Global.getInstance().setSceneRoot(LoadingPane.getInstance());

                        Platform.runLater(() -> {
                            new Thread(new Runnable() {

                                @Override
                                public void run() {
                                    ImagePane.getInstance().init(explorerPane, imageFile);
                                    Global.getInstance().setSceneRoot(ImagePane.getInstance());
                                }
                            }).start();
                        });

                    }
                }
            }
        });
    } catch (FileNotFoundException ex) {
        ex.printStackTrace();
    } catch (IOException ex) {
        Logger.getLogger(ExplorerPane.class.getName()).log(Level.SEVERE, null, ex);
    }
    return borderPane;
}