List of usage examples for javafx.scene.image ImageView setCache
public final void setCache(boolean value)
From source file:com.imesha.imageprocessor.controllers.MainController.java
/** * Show a given BufferedImage in the UI. * * @param bufferedImage The image to be shown in the UI * @param imageView The JavaFX ImageView element in which the BufferedImage to be shown. *///from w w w .j av a 2s . c om private static void showImageInUI(final BufferedImage bufferedImage, final ImageView imageView) { Platform.runLater(new Runnable() { public void run() { Image loadedImage = SwingFXUtils.toFXImage(bufferedImage, null); imageView.setImage(loadedImage); imageView.setPreserveRatio(true); imageView.setSmooth(true); imageView.setCache(true); } }); }
From source file:vkmanager.controller.PhotosDetailedController.java
public void showPhotosFromAlbum(VKPhotoAlbum album, int userId) { this.album = album; idForDownload = album.getId();/* w w w .j a v a 2 s .c o m*/ albumDescription.setText(album.getDescription()); photos = vkapi.getPhotosFromAlbum(idForDownload, userId); int i = 0; int j = 0; gridPaneDetailed.addRow(0); for (VKPhoto photo : photos) { Image photoThumbLink = new Image(photo.getLink_s()); ImageView photoThumb = new ImageView(photoThumbLink); photoThumb.setFitHeight(160); photoThumb.setFitWidth(240); photoThumb.setPreserveRatio(true); photoThumb.setSmooth(true); photoThumb.setCache(true); Button photoButt = new Button(); photoButt.setGraphic(photoThumb); photoButt.setStyle("-fx-background-color: white;"); photoButt.setMinSize(240, 160); photoButt.setAlignment(Pos.CENTER); BorderPane bp = new BorderPane(null, photoButt, null, null, null); gridPaneDetailed.add(bp, j, i); j++; if (j == 3) { i++; j = 0; gridPaneDetailed.addRow(i); } } }
From source file:TimeShift.Picture.java
private ImageView getImage() { ImageView imgView; String thmbFile = file.getParent() + "\\thmb\\" + FilenameUtils.getBaseName(file.getName()) + "_thmb.jpg"; imgView = new ImageView(new File(thmbFile).toURI().toString()); imgView.setPreserveRatio(true);// w w w . j a v a 2 s .c om imgView.setSmooth(true); imgView.setCache(true); return imgView; }
From source file:fruitproject.FruitProject.java
public void second(final String pfname) { final Stage st = new Stage(); Scene scene = null;/*ww w .j a v a 2s .co m*/ final GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); TableView tv = new TableView(); final TableColumn<Map, String> firstDataColumn = new TableColumn<>("Name"); final TableColumn<Map, String> secondDataColumn = new TableColumn<>("Amount"); final TableColumn<Map, String> thirdDataColumn = new TableColumn<>("Remove"); firstDataColumn.setMinWidth(130); secondDataColumn.setMinWidth(130); thirdDataColumn.setMinWidth(130); if (!pfname.equals("")) { firstDataColumn.setCellValueFactory(new MapValueFactory(Column1MapKey)); secondDataColumn.setCellValueFactory(new MapValueFactory(Column2MapKey)); thirdDataColumn.setCellValueFactory(new MapValueFactory(Column3MapKey)); rows = 0; tv = new TableView<>(generateDataInMap(pfname, addPairs)); } tv.getColumns().setAll(firstDataColumn, secondDataColumn, thirdDataColumn); // secondDataColumn.setCellFactory(TextFieldTableCell.forTableColumn()); ScrollPane sp = new ScrollPane(); sp.setMinWidth(400); sp.setHbarPolicy(ScrollBarPolicy.NEVER); sp.setContent(tv); grid.add(sp, 0, 3); final ComboBox comboBox = new ComboBox(); HBox hb1 = new HBox(); comboBox.setValue("FILE"); comboBox.getItems().addAll("Save this file", "Load a new file"); Button btnOk = new Button(); btnOk.setText("OK"); hb1.getChildren().addAll(comboBox, btnOk); hb1.setSpacing(10); grid.add(hb1, 0, 1); Label label1 = new Label("Title:"); final TextField tfFilename = new TextField(); tfFilename.setText(getTitle(pfname)); HBox hb = new HBox(); hb.getChildren().addAll(label1, tfFilename); hb.setSpacing(10); grid.add(hb, 0, 2); final Stage ps = new Stage(); final TableView tv1 = tv; btnOk.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { //System.out.println("Hello World!"); if (comboBox.getValue().equals("Load a new file")) { first(ps); st.close(); } else { PrintWriter pw = null; try { pw = new PrintWriter("abc.json"); BufferedWriter bw = new BufferedWriter(new FileWriter(pfname, false)); bw.write("{title:\"" + tfFilename.getText() + "\""); bw.write(",fruits:["); for (int i = 0; i < rows; i++) { bw.write("{name:\"" + String.valueOf(firstDataColumn.getCellData(i)) + "\",amount:" + String.valueOf(secondDataColumn.getCellData(i)) + "}"); if (i != rows - 1) bw.write(","); } bw.write("]}"); bw.close(); } catch (Exception e) { System.out.println(e.toString()); } } } }); Button btn = new Button(); btn.setText("New Fruit"); grid.add(btn, 1, 2); // TableView tv=new TableView(); // TableColumn Col1 = new TableColumn("Name"); // TableColumn Col2 = new TableColumn("Amount"); // TableColumn Col3 = new TableColumn("Remove"); // tv.getColumns().addAll(Col1, Col2, Col3); //sp.setFitToWidth(true); Image img = new Image("file:music.jpg"); ImageView iv2 = new ImageView(); iv2.setImage(img); iv2.setFitWidth(200); iv2.setPreserveRatio(true); iv2.setSmooth(true); iv2.setCache(true); grid.add(iv2, 1, 3); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { //System.out.println("Hello World!"); System.out.println(comboBox.valueProperty()); st.close(); third(pfname); } }); scene = new Scene(grid, 700, 450); st.setScene(scene); st.show(); }
From source file:calendarioSeries.vistas.MainViewController.java
public void populateImagenes() { Platform.runLater(new Runnable() { @Override//from w ww. java 2 s . c o m public void run() { imagenes.getChildren().clear(); for (Serie serie : series) { //System.out.println(serie.getLastVisto()); try { Image image = new Image(serie.getUrlImagen()); ImageView poster = new ImageView(); ContextMenu menu = new ContextMenu(); //String css = MainApp.class.getResource("resources/MainTheme.css").toExternalForm(); MenuItem delete = new MenuItem("Eliminar"); delete.setId(serie.getId()); delete.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { menu.hide(); MenuItem clicked = (MenuItem) event.getSource(); String toDelete = clicked.getId(); for (Serie serie : series) { if (serie.getId().equals(toDelete)) { series.remove(serie); populateImagenes(); showDetallesMes(mesActual); } } event.consume(); } }); menu.getItems().add(delete); poster.setId(serie.getTitulo()); poster.setImage(image); poster.setCache(true); // poster.setPreserveRatio(true); poster.setFitWidth(210); poster.setFitHeight(300); poster.setOnContextMenuRequested(new EventHandler<ContextMenuEvent>() { @Override public void handle(ContextMenuEvent event) { menu.show(poster, event.getScreenX(), event.getScreenY()); //menu.getScene().getRoot().getStylesheets().add(css); event.consume(); } }); poster.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (event.getButton() == MouseButton.PRIMARY) { try { //serieToPass = serie; sceneToPass = mainApp.scene; FXMLLoader loader = new FXMLLoader( getClass().getResource("DetailsSerieController.fxml")); Parent root = loader.load(); DetailsSerieController controller = loader.getController(); controller.setData(serie, series); controller.setMainApp(mainApp); Scene scene = new Scene(root); mainApp.primaryStage.setScene(scene); mainApp.primaryStage.show(); } catch (IOException ex) { ex.printStackTrace(); } } } }); imagenes.getChildren().add(poster); } catch (IllegalArgumentException e) { Image image = new Image("file:src/calendarioSeries/resources/no-image.png"); ImageView poster = new ImageView(); ContextMenu menu = new ContextMenu(); MenuItem delete = new MenuItem("Eliminar"); delete.setId(serie.getId()); delete.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { menu.hide(); MenuItem clicked = (MenuItem) event.getSource(); String toDelete = clicked.getId(); for (Serie serie : series) { if (serie.getId().equals(toDelete)) { series.remove(serie); populateImagenes(); showDetallesMes(mesActual); } } event.consume(); } }); menu.getItems().add(delete); poster.setId(serie.getTitulo()); poster.setImage(image); poster.setCache(true); //poster.setPreserveRatio(true); poster.setFitWidth(210); poster.setFitHeight(300); poster.setOnContextMenuRequested(new EventHandler<ContextMenuEvent>() { @Override public void handle(ContextMenuEvent event) { menu.show(poster, event.getScreenX(), event.getScreenY()); event.consume(); } }); Text text = new Text(serie.getTitulo()); text.getStyleClass().add("label"); StackPane pane = new StackPane(); pane.getChildren().addAll(poster, text); imagenes.getChildren().add(pane); } finally { rellenarArchivo(); } } } }); }