Image tile = new Image("tile.png"); Group house = new Group(); house.setCache(true); house.setCacheHint(CacheHint.SPEED); Effect lighting = new Lighting(); for (int i = 0; i < houseWidth; i++) { // here is the critical part => don't do new ImageView(new Image("tile.png")) ImageView tileView = new ImageView(tile)); tileView.setEffect(lighting); tileView.setCache(true); tileView.setCacheHint(CacheHint.SPEED); house.add(tileView); }
/** * init the Image */ public void initImage() { // simple displays ImageView the image as is imageView = new ImageView(); imageView.setImage(getImage()); imageView.setSmooth(true); imageView.setCache(true); }
@Override public void cache(Pane node) { if (!cache.containsKey(node)) { SnapshotParameters snapShotparams = new SnapshotParameters(); snapShotparams.setFill(Color.TRANSPARENT); WritableImage temp = node.snapshot(snapShotparams, new WritableImage((int) node.getLayoutBounds().getWidth(), (int) node.getLayoutBounds().getHeight())); ImageView tempImage = new ImageView(temp); tempImage.setCache(true); tempImage.setCacheHint(CacheHint.SPEED); cache.put(node, new ArrayList<>(node.getChildren())); node.getChildren().setAll(tempImage); } }
// resizes the image to have width and height of 100 while preserving the ratio and using // higher quality filtering method; this ImageView is also cached to // improve performance ImageView iv2 =newImageView(); iv2.setImage(image); iv2.setFitHeight(100); iv2.setFitWidth(100); iv2.setPreserveRatio(true); iv2.setSmooth(true); iv2.setCache(true);
private void showDialog() { if (dialogContainer == null) { throw new RuntimeException("ERROR: JFXDialog container is not set!"); } if (isCacheContainer()) { tempContent = new ArrayList<>(dialogContainer.getChildren()); SnapshotParameters snapShotparams = new SnapshotParameters(); snapShotparams.setFill(Color.TRANSPARENT); WritableImage temp = dialogContainer.snapshot(snapShotparams, new WritableImage((int) dialogContainer.getWidth(), (int) dialogContainer.getHeight())); ImageView tempImage = new ImageView(temp); tempImage.setCache(true); tempImage.setCacheHint(CacheHint.SPEED); dialogContainer.getChildren().setAll(tempImage, this); } else { //prevent error if opening an already opened dialog dialogContainer.getChildren().remove(this); tempContent = null; dialogContainer.getChildren().add(this); } if (animation != null) { animation.play(); } else { setVisible(true); setOpacity(1); Event.fireEvent(JFXDialog.this, new JFXDialogEvent(JFXDialogEvent.OPENED)); } }
imgView.setPreserveRatio(true); imgView.setSmooth(true); imgView.setCache(true); setGraphic(imgView);
imageView.setCache(true); imageView.setCacheHint(CacheHint.SPEED);
); imageView.setCache(true); imageView.setCacheHint(CacheHint.SPEED);
@Override public void cache(Pane node) { if (!cache.containsKey(node)) { SnapshotParameters snapShotparams = new SnapshotParameters(); snapShotparams.setFill(Color.TRANSPARENT); WritableImage temp = node.snapshot(snapShotparams, new WritableImage((int) node.getLayoutBounds().getWidth(), (int) node.getLayoutBounds().getHeight())); ImageView tempImage = new ImageView(temp); tempImage.setCache(true); tempImage.setCacheHint(CacheHint.SPEED); cache.put(node, new ArrayList<>(node.getChildren())); node.getChildren().setAll(tempImage); } }
private void showDialog() { if (dialogContainer == null) { throw new RuntimeException("ERROR: JFXDialog container is not set!"); } if (isCacheContainer()) { tempContent = new ArrayList<>(dialogContainer.getChildren()); SnapshotParameters snapShotparams = new SnapshotParameters(); snapShotparams.setFill(Color.TRANSPARENT); WritableImage temp = dialogContainer.snapshot(snapShotparams, new WritableImage((int) dialogContainer.getWidth(), (int) dialogContainer.getHeight())); ImageView tempImage = new ImageView(temp); tempImage.setCache(true); tempImage.setCacheHint(CacheHint.SPEED); dialogContainer.getChildren().setAll(tempImage, this); } else { tempContent = null; dialogContainer.getChildren().add(this); } if (animation != null) { animation.play(); } else { setVisible(true); setOpacity(1); Event.fireEvent(JFXDialog.this, new JFXDialogEvent(JFXDialogEvent.OPENED)); } }