本文整理汇总了Java中javafx.scene.image.ImageView.setCache方法的典型用法代码示例。如果您正苦于以下问题:Java ImageView.setCache方法的具体用法?Java ImageView.setCache怎么用?Java ImageView.setCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.image.ImageView
的用法示例。
在下文中一共展示了ImageView.setCache方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createIv
import javafx.scene.image.ImageView; //导入方法依赖的package包/类
private ImageView createIv(double x, double y) {
ImageView iv = new ImageView();
iv.setImage(image);
iv.setSmooth(true);
iv.setPickOnBounds(true);
iv.setCache(true);
iv.setX(x);
iv.setY(y);
iv.setCursor(Cursor.HAND);
iv.setOnMouseDragged((t) -> {
ImageView i = (ImageView) (t.getSource());
i.setX(t.getSceneX()-size/2);
i.setY(t.getSceneY()-size/2);
});
iv.setOnMouseReleased((t) -> {
double newX = t.getSceneX();
double newY = t.getSceneY();
if(zones.isInZone(newX, newY, type)) {
iv.setVisible(false);
}
});
return iv;
}
示例2: addImageView
import javafx.scene.image.ImageView; //导入方法依赖的package包/类
private void addImageView(final Image i) {
try {
final String imageName = i.getUri().toURL().toString();
ImageView imageView = new ImageView(new javafx.scene.image.Image(imageName));
imageView.setSmooth(true);
imageView.setCache(true);
imageView.setCacheHint(CacheHint.SPEED);
imageView.setPreserveRatio(true);
imageView.setFitWidth(200);
Platform.runLater(() -> {
tilePane.getChildren().add(imageView);
});
} catch (MalformedURLException e) {
System.out.println("URL Conversion didn't work");
e.printStackTrace();
}
}
示例3: createImageView
import javafx.scene.image.ImageView; //导入方法依赖的package包/类
private ImageView createImageView(final File imageFile) {
try {
final Image img = new Image(new FileInputStream(imageFile), 120, 0, true, true);
imageView1 = new ImageView(img);
imageView1.setStyle("-fx-background-color: BLACK");
imageView1.setFitHeight(120);
imageView1.setPreserveRatio(true);
imageView1.setSmooth(true);
imageView1.setCache(true);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return imageView1;
}
示例4: newDir2
import javafx.scene.image.ImageView; //导入方法依赖的package包/类
public void newDir2() {
int j = 0; // Used to properly insert to grid when there are files other than an image
for (int i=0; i<fileList.length; i++) {
String path = "" + fileList[i];
if (fileList[i].getName().contains(".png") || fileList[i].getName().contains(".jpg")||
fileList[i].getName().contains(".gif") || fileList[i].getName().contains(".jpeg")) {
String title = "" + fileList[i];
pth = new Image("file://" + fileList[i]);
ImageView view = (ImageView) (tilePane.getChildren().get(j));
view.setImage(pth);
view.setCache(true);
final ImageView imgViewPoped = new ImageView("file://" + fileList[i]);
// image click actions
view.setOnMouseClicked(mouse -> {
MouseButton button = mouse.getButton();
if (mouse.getClickCount() == 2 && button == MouseButton.PRIMARY && !mouse.isConsumed()) {
mouse.consume();
txtDirPath.setText(path);
settings.setBackgroundInfo(path);
} else if (button == MouseButton.SECONDARY) {
displayImg(imgViewPoped, title);
}
});
j++;
} else {
System.out.println("Not an image file.");
}
}
}
示例5: initialize
import javafx.scene.image.ImageView; //导入方法依赖的package包/类
private void initialize() {
imageView = new ImageView();
imageView.setPreserveRatio(true);
imageView.setSmooth(true);
imageView.setCache(true);
imageViewExt = new ImageViewExt(imageView);
BorderPane root = new BorderPane(imageView);
imageView.fitWidthProperty().bind(widthProperty());
imageView.fitHeightProperty().bind(heightProperty());
Scene scene = new Scene(root);
scene.setFill(Color.BLACK);
setScene(scene);
}
示例6: buildItemCell
import javafx.scene.image.ImageView; //导入方法依赖的package包/类
private Node buildItemCell(SocialMediaItem item) {
HBox hbox = new HBox();
InputStream resource = item.getClass().getResourceAsStream("icon.png");
if (resource != null) {
ImageView sourceImage = new ImageView();
sourceImage.setFitHeight(18);
sourceImage.setPreserveRatio(true);
sourceImage.setSmooth(true);
sourceImage.setCache(true);
sourceImage.setImage(new Image(resource));
hbox.getChildren().add(sourceImage);
}
if (item.getImage() != null) {
HBox picture = new HBox();
picture.setPadding(new Insets(0, 10, 0, 0));
ImageView imageView = new ImageView(item.getImage());
imageView.setPreserveRatio(true);
imageView.setFitWidth(150);
picture.getChildren().add(imageView);
hbox.getChildren().add(picture);
}
Label text = new Label(item.getBody());
text.setFont(Font.font(null, 20));
text.setWrapText(true);
hbox.getChildren().add(text);
return hbox;
}