Example usage for javafx.scene.image Image Image

List of usage examples for javafx.scene.image Image Image

Introduction

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

Prototype

Image(int width, int height) 

Source Link

Document

Package private internal constructor used only by WritableImage .

Usage

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    try {//from ww w .jav  a  2 s. c o m
        File file = new File("C:/Users/abc/myphoto.jpg");
        String localUrl = file.toURI().toURL().toString();
        // don't load in the background
        Image localImage = new Image(localUrl, false);

        String remoteUrl = "http://java2s.com/style/demo/Firefox.png";
        // load in the background
        Image remoteImage = new Image(remoteUrl, true);

        System.out.println(localUrl);
        System.out.println(remoteUrl);

    } catch (MalformedURLException ex) {
        // error
    }
}

From source file:newphotoboothui.FXMLShowcaseController.java

public void setPicture(int pictureNumber) {
    File file = new File(fotos[pictureNumber]);
    try {//from   w ww  .ja  v  a2  s  .com
        String localUrl = file.toURI().toURL().toString();
        Image localImage = new Image(localUrl, true);
        showCase.setImage(localImage);
    } catch (MalformedURLException ex) {
        Logger.getLogger(FXMLShowcaseController.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:org.sleuthkit.autopsy.imagegallery.datamodel.grouping.GroupSortBy.java

public Image getIcon() {
    if (icon == null) {
        if (StringUtils.isBlank(imageName) == false) {
            this.icon = new Image("org/sleuthkit/autopsy/imagegallery/images/" + imageName, true); //NON-NLS
        }/* w ww . j  a  va  2 s  . c  o m*/
    }
    return icon;
}

From source file:org.sleuthkit.autopsy.imageanalyzer.datamodel.DrawableAttribute.java

public Image getIcon() {
    if (icon == null) {
        if (StringUtils.isBlank(imageName) == false) {
            this.icon = new Image("org/sleuthkit/autopsy/imageanalyzer/images/" + imageName, true);
        }//from ww  w  .  jav  a 2  s .c om
    }
    return icon;
}

From source file:org.sleuthkit.autopsy.imagegallery.datamodel.DrawableAttribute.java

public Image getIcon() {
    if (icon == null) {
        if (StringUtils.isBlank(imageName) == false) {
            this.icon = new Image("org/sleuthkit/autopsy/imagegallery/images/" + imageName, true);
        }/*from   w ww  . ja va 2 s  .c om*/
    }
    return icon;
}

From source file:com.adr.mimame.PlatformList.java

public Image getCachedImage(String url) {

    if (url == null) {
        return null;
    } else if (!"http".equalsIgnoreCase(url.substring(0, 4)) && !"ftp".equalsIgnoreCase(url.substring(0, 3))) {
        // a local image
        return new Image(url, true);
    } else {//from   w w  w .j av a  2 s .  c  o  m
        // a remote image
        try {
            File cachedir = new File(mimamememuhome, "IMGCACHE");
            FileUtils.forceMkdir(cachedir);

            MessageDigest md = MessageDigest.getInstance("SHA-256");
            md.update(url.getBytes("UTF-8"));
            String cachefilename = Base64.getUrlEncoder().encodeToString(md.digest());
            File cachefile = new File(cachedir, cachefilename + ".png");
            File cachefilenull = new File(cachedir, cachefilename + ".null");

            if (cachefilenull.exists()) {
                return null;
            } else if (cachefile.exists()) {
                return new Image(cachefile.toURI().toURL().toString(), true);
            } else {
                Image img = new Image(url, true);
                img.progressProperty().addListener(
                        (ObservableValue<? extends Number> observable, Number oldValue, Number newValue) -> {
                            if (newValue.doubleValue() == 1.0) {
                                exec.execute(() -> {
                                    try {
                                        if (img.isError()) {
                                            cachefilenull.createNewFile();
                                        } else {
                                            ImageIO.write(SwingFXUtils.fromFXImage(img, null), "png",
                                                    cachefile);
                                        }
                                    } catch (IOException ex) {
                                        logger.log(Level.SEVERE, "Cannot save image cache.", ex);
                                    }
                                });
                            }
                        });
                return img;
            }
        } catch (IOException | NoSuchAlgorithmException ex) {
            logger.log(Level.SEVERE, "Cannot create image cache.", ex);
            return new Image(url);
        }
    }
}

From source file:org.sleuthkit.autopsy.timeline.datamodel.eventtype.WebTypes.java

private WebTypes(String displayName, String iconBase, BlackboardArtifact.Type artifactType,
        BlackboardAttribute.Type dateTimeAttributeType, Function<BlackboardArtifact, String> shortExtractor,
        Function<BlackboardArtifact, String> medExtractor, Function<BlackboardArtifact, String> longExtractor) {
    this.displayName = displayName;
    this.iconBase = iconBase;
    this.artifactType = artifactType;
    this.dateTimeAttributeType = dateTimeAttributeType;
    this.shortExtractor = shortExtractor;
    this.medExtractor = medExtractor;
    this.longExtractor = longExtractor;
    this.image = new Image("org/sleuthkit/autopsy/timeline/images/" + iconBase, true); // NON-NLS
}

From source file:org.sleuthkit.autopsy.timeline.events.type.WebTypes.java

private WebTypes(String displayName, String iconBase, BlackboardArtifact.ARTIFACT_TYPE artifactType,
        BlackboardAttribute.ATTRIBUTE_TYPE dateTimeAttributeType,
        BiFunction<BlackboardArtifact, Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute>, String> shortExtractor,
        BiFunction<BlackboardArtifact, Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute>, String> medExtractor,
        BiFunction<BlackboardArtifact, Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute>, String> longExtractor) {
    this.displayName = displayName;
    this.iconBase = iconBase;
    this.artifactType = artifactType;
    this.dateTimeAttributeType = dateTimeAttributeType;
    this.shortExtractor = shortExtractor;
    this.medExtractor = medExtractor;
    this.longExtractor = longExtractor;
    this.image = new Image("org/sleuthkit/autopsy/timeline/images/" + iconBase, true); // NON-NLS
}

From source file:org.sleuthkit.autopsy.timeline.events.type.MiscTypes.java

private MiscTypes(String displayName, String iconBase, BlackboardArtifact.ARTIFACT_TYPE artifactType,
        BlackboardAttribute.ATTRIBUTE_TYPE dateTimeAttributeType,
        BiFunction<BlackboardArtifact, Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute>, String> shortExtractor,
        BiFunction<BlackboardArtifact, Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute>, String> medExtractor,
        BiFunction<BlackboardArtifact, Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute>, String> longExtractor) {
    this.displayName = displayName;
    this.iconBase = iconBase;
    this.artifactType = artifactType;
    this.dateTimeAttributeType = dateTimeAttributeType;
    this.shortExtractor = shortExtractor;
    this.medExtractor = medExtractor;
    this.longExtractor = longExtractor;
    this.image = new Image("org/sleuthkit/autopsy/timeline/images/" + iconBase, true); // NON-NLS
}

From source file:org.sleuthkit.autopsy.timeline.datamodel.eventtype.MiscTypes.java

private MiscTypes(String displayName, String iconBase, BlackboardArtifact.Type artifactType,
        BlackboardAttribute.Type dateTimeAttributeType, Function<BlackboardArtifact, String> shortExtractor,
        Function<BlackboardArtifact, String> medExtractor, Function<BlackboardArtifact, String> longExtractor) {
    this.displayName = displayName;
    this.iconBase = iconBase;
    this.artifactType = artifactType;
    this.dateTimeAttributeType = dateTimeAttributeType;
    this.shortExtractor = shortExtractor;
    this.medExtractor = medExtractor;
    this.longExtractor = longExtractor;
    this.image = new Image("org/sleuthkit/autopsy/timeline/images/" + iconBase, true); // NON-NLS
}