Java Code Examples for javafx.scene.image.ImageView#setSmooth()
The following examples show how to use
javafx.scene.image.ImageView#setSmooth() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RoundImageViewSkin.java From dolphin-platform with Apache License 2.0 | 6 votes |
public RoundImageViewSkin(RoundImageView control) { super(control); imageView = new ImageView(); imageView.setPreserveRatio(true); imageView.setSmooth(true); circleClip = new Circle(); imageView.setClip(circleClip); overlayCircle = new Circle(); overlayCircle.getStyleClass().add("round-image-view-circle"); overlayCircle.setFill(Color.TRANSPARENT); getChildren().add(imageView); getChildren().add(overlayCircle); imageView.imageProperty().bind(getSkinnable().imageProperty()); getSkinnable().setMaxWidth(Region.USE_PREF_SIZE); getSkinnable().setMinWidth(Region.USE_PREF_SIZE); getSkinnable().setMaxHeight(Region.USE_PREF_SIZE); getSkinnable().setMinHeight(Region.USE_PREF_SIZE); }
Example 2
Source File: SlideThumbnail.java From Quelea with GNU General Public License v3.0 | 5 votes |
public SlideThumbnail(PresentationSlide slide, int num) { this.num = num; this.slide = slide; image = new ImageView(slide.getImage()); image.setFitWidth(QueleaProperties.get().getThumbnailSize()); image.setPreserveRatio(true); image.setSmooth(true); image.setCache(true); setTop(image); setCenter(new Label(Integer.toString(num))); }
Example 3
Source File: CountryLabel.java From VickyWarAnalyzer with MIT License | 5 votes |
public CountryLabel(Country country) { super(country.getOfficialName()); tag = country.getTag(); ImageView iv2 = new ImageView(country.getFlag()); iv2.setFitWidth(32); // 30 to 35 looks good iv2.setPreserveRatio(true); iv2.setSmooth(true); iv2.setCache(true); setGraphic(iv2); setContentDisplay(ContentDisplay.LEFT); }
Example 4
Source File: Loading.java From ApkToolPlus with Apache License 2.0 | 5 votes |
public Loading(URL imageUrl) { super(); // 设置背景颜色 setBackgroundColor(20,20,20,0.5f); contentBox = new VBox(); // 间隔 Region topRegion = new Region(); topRegion.setPrefHeight(20); contentBox.getChildren().add(topRegion); // gif动态图 imageView = new ImageView(); imageView.setSmooth(true); setImage(imageUrl); contentBox.getChildren().add(imageView); // 间隔 Region region = new Region(); region.setPrefHeight(15); contentBox.getChildren().add(region); // 提示信息 text = new Text(); text.setStyle("-fx-fill: white; -fx-font-size:24;"); contentBox.getChildren().add(text); // 设置内容居中 contentBox.alignmentProperty().set(Pos.CENTER); // 设置布局居中 setAlignment(contentBox,Pos.CENTER); getChildren().add(contentBox); }
Example 5
Source File: PictureRepresentation.java From phoebus with Eclipse Public License 1.0 | 5 votes |
@Override public ImageView createJFXNode() throws Exception { final ImageView iv = new ImageView(); iv.setSmooth(true); iv.getTransforms().addAll(translate, rotation); return iv; }
Example 6
Source File: ImagePropertiesSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public ImagePropertiesSample() { //we can set image properties directly during creation ImageView sample1 = new ImageView(new Image(url, 30, 70, false, true)); ImageView sample2 = new ImageView(new Image(url)); //image can be resized to preferred width sample2.setFitWidth(200); sample2.setPreserveRatio(true); ImageView sample3 = new ImageView(new Image(url)); //image can be resized to preferred height sample3.setFitHeight(20); sample3.setPreserveRatio(true); ImageView sample4 = new ImageView(new Image(url)); //one can resize image without preserving ratio between height and width sample4.setFitWidth(40); sample4.setFitHeight(80); sample4.setPreserveRatio(false); sample4.setSmooth(true); //the usage of the better filter ImageView sample5 = new ImageView(new Image(url)); sample5.setFitHeight(60); sample5.setPreserveRatio(true); //viewport is used for displaying the part of image Rectangle2D rectangle2D = new Rectangle2D(50, 200, 120, 60); sample5.setViewport(rectangle2D); //add the imageviews to layout HBox hBox = new HBox(); hBox.setSpacing(10); hBox.getChildren().addAll(sample1, sample3, sample4, sample5); //show the layout VBox vb = new VBox(10); vb.getChildren().addAll(hBox, sample2); getChildren().add(vb); }
Example 7
Source File: ImagePropertiesSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public ImagePropertiesSample() { //we can set image properties directly during creation ImageView sample1 = new ImageView(new Image(url, 30, 70, false, true)); ImageView sample2 = new ImageView(new Image(url)); //image can be resized to preferred width sample2.setFitWidth(200); sample2.setPreserveRatio(true); ImageView sample3 = new ImageView(new Image(url)); //image can be resized to preferred height sample3.setFitHeight(20); sample3.setPreserveRatio(true); ImageView sample4 = new ImageView(new Image(url)); //one can resize image without preserving ratio between height and width sample4.setFitWidth(40); sample4.setFitHeight(80); sample4.setPreserveRatio(false); sample4.setSmooth(true); //the usage of the better filter ImageView sample5 = new ImageView(new Image(url)); sample5.setFitHeight(60); sample5.setPreserveRatio(true); //viewport is used for displaying the part of image Rectangle2D rectangle2D = new Rectangle2D(50, 200, 120, 60); sample5.setViewport(rectangle2D); //add the imageviews to layout HBox hBox = new HBox(); hBox.setSpacing(10); hBox.getChildren().addAll(sample1, sample3, sample4, sample5); //show the layout VBox vb = new VBox(10); vb.getChildren().addAll(hBox, sample2); getChildren().add(vb); }
Example 8
Source File: EditingMultiBaseStyleLongCell.java From CPUSim with GNU General Public License v3.0 | 5 votes |
/** * updates the Long in the table cell * @param item used for the parent method * @param empty used for the parent method */ @Override public void updateItem(Long item, boolean empty) { super.updateItem(item, empty); if( styleInfo != null ) styleInfo.setFontAndBackground(this); if (empty || item == null) { setText(null); setGraphic(null); setTooltip(null); } else if (isEditing()) { if (textField != null) { textField.setText(formatString(prepareString(getString()))); } setText(null); setGraphic(textField); } else { setTooltipsAndCellSize(); setText(formatString(convertLong(Long.parseLong(getString())))); if(isReadOnlyRegisterValue()) { ImageView graphic = new ImageView(new Image("/images/icons/Lock.png")); graphic.setFitHeight(styleInfo == null ? this.getHeight() : Integer.parseInt(styleInfo.fontSize)); graphic.setSmooth(true); graphic.setPreserveRatio(true); graphic.setCache(true); setContentDisplay(ContentDisplay.RIGHT); setGraphic(graphic); } else setGraphic(null); } }
Example 9
Source File: ExtendedAnimatedFlowContainer.java From tools-ocr with GNU Lesser General Public License v3.0 | 5 votes |
/** * Creates a container with the given animation type and duration. * * @param duration the duration of the animation * @param animationProducer the {@link KeyFrame} instances that define the animation */ public ExtendedAnimatedFlowContainer(Duration duration, Function<AnimatedFlowContainer, List<KeyFrame>> animationProducer) { this.view = new StackPane(); this.duration = duration; this.animationProducer = animationProducer; placeholder = new ImageView(); placeholder.setPreserveRatio(true); placeholder.setSmooth(true); }
Example 10
Source File: PresentationControls.java From Quelea with GNU General Public License v3.0 | 5 votes |
private ImageView setImageView(Image image) { ImageView iv2 = new ImageView(); iv2.setImage(image); iv2.setPreserveRatio(true); iv2.setSmooth(true); iv2.setCache(true); return iv2; }
Example 11
Source File: ViewText.java From latexdraw with GNU General Public License v3.0 | 5 votes |
/** * Creates the view. * @param sh The model. */ ViewText(final Text sh, final LaTeXDataService data) { super(sh); text = new javafx.scene.text.Text(); compiledText = new ImageView(); compileTooltip = new Tooltip(null); this.latexData = data; // Scaling at 0.5 as the png produced by latex is zoomed x 2 (for a better rendering) compiledText.setScaleX(0.5); compiledText.setScaleY(0.5); compiledText.setVisible(false); compiledText.setSmooth(true); compiledText.setCache(true); compiledText.imageProperty().addListener((observable, oldValue, theImg) -> { if(theImg != null) { // Have to move the picture as it is zoomed compiledText.setX(-theImg.getWidth() / 4d); compiledText.setY(-(3d * theImg.getHeight()) / 4d); } }); textUpdate = (observable, oldValue, newValue) -> update(); model.textProperty().addListener(textUpdate); getChildren().add(text); getChildren().add(compiledText); setImageTextEnable(false); update(); bindTextPosition(); }
Example 12
Source File: MainToolbar.java From Quelea with GNU General Public License v3.0 | 5 votes |
private MenuItem getMenuItemFromImage(String uri, int width, int height, boolean preserveRatio, boolean smooth) { ImageView iv = new ImageView(new Image(QueleaProperties.get().getUseDarkTheme() ? uri.replace(".png", "-light.png") : uri, width, height, preserveRatio, smooth)); iv.setSmooth(true); iv.setFitWidth(24); iv.setFitHeight(24); return new MenuItem("", iv); }
Example 13
Source File: SlideThumbnail.java From Quelea with GNU General Public License v3.0 | 5 votes |
public SlideThumbnail(ImageGroupSlide slide, int num) { this.num = num; this.slide = slide; image = new ImageView(slide.getImage()); image.setFitWidth(QueleaProperties.get().getThumbnailSize()); image.setPreserveRatio(true); image.setSmooth(true); image.setCache(true); setTop(image); setCenter(new Label(Integer.toString(num))); }
Example 14
Source File: Pin.java From BlockMap with MIT License | 5 votes |
protected Node initTopGui() { ImageView img = new ImageView(type.image); img.setSmooth(false); button = new Button(null, img); button.getStyleClass().add("pin"); img.setPreserveRatio(true); button.setTooltip(new Tooltip(type.toString())); img.fitHeightProperty().bind(Bindings.createDoubleBinding(() -> button.getFont().getSize() * 2, button.fontProperty())); button.setOnAction(mouseEvent -> getInfo().show(button)); return wrapGui(button, position, viewport); }
Example 15
Source File: GuiController.java From BlockMap with MIT License | 5 votes |
/** * Recursive pre-order traversal of the pin type hierarchy tree. Generated items are added automatically. * * @param type * the current type to add * @param parent * the parent tree item to add this one to. <code>null</code> if {@code type} is the root type, in this case the generated tree * item will be used as root for the tree directly. * @param tree * the tree containing the items */ private void initPinCheckboxes(PinType type, CheckBoxTreeItem<PinType> parent, CheckTreeView<PinType> tree) { ImageView image = new ImageView(type.image); /* * The only way so set the size of an image relative to the text of the label is to bind its height to a font size. Since tree items don't * possess a fontProperty (it's hidden behind a cell factory implementation), we have to use the next best labeled node (pinBox in this * case). This will only work if we don't change any font sizes. */ image.fitHeightProperty().bind(Bindings.createDoubleBinding(() -> pinBox.getFont().getSize() * 1.5, pinBox.fontProperty())); image.setSmooth(true); image.setPreserveRatio(true); CheckBoxTreeItem<PinType> ret = new CheckBoxTreeItem<>(type, image); if (parent == null) tree.setRoot(ret); else parent.getChildren().add(ret); for (PinType sub : type.getChildren()) initPinCheckboxes(sub, ret, tree); ret.setExpanded(type.expandedByDefault); if (type.selectedByDefault) { pins.visiblePins.add(type); tree.getCheckModel().check(ret); } checkedPins.put(type, ret); }
Example 16
Source File: ScriptsDialog.java From phoebus with Eclipse Public License 1.0 | 4 votes |
private ImageView getScriptImage(ScriptItem item) { ImageView imageView = null; if (item != null) { final ScriptInfo info = item.getScriptInfo(); if (info != null) { final String path = info.getPath(); if (ScriptInfo.isEmbedded(path)) { if (ScriptInfo.isJavaScript(path)) imageView = JFXUtil.getIcon("javascript.png"); else if (ScriptInfo.isJython(path)) imageView = JFXUtil.getIcon("python.png"); else // It should never happen. imageView = JFXUtil.getIcon("unknown.png"); } else { if (ScriptInfo.isJavaScript(path)) imageView = JFXUtil.getIcon("file-javascript.png"); else if (ScriptInfo.isJython(path)) imageView = JFXUtil.getIcon("file-python.png"); else // It should never happen. imageView = JFXUtil.getIcon("file-unknown.png"); } } } if (imageView != null) { imageView.setPreserveRatio(true); imageView.setSmooth(true); } return imageView; }
Example 17
Source File: ArtistsController.java From MusicPlayer with MIT License | 4 votes |
private VBox createCell(Artist artist) { VBox cell = new VBox(); Label title = new Label(artist.getTitle()); ImageView image = new ImageView(artist.getArtistImage()); image.imageProperty().bind(artist.artistImageProperty()); VBox imageBox = new VBox(); title.setTextOverrun(OverrunStyle.CLIP); title.setWrapText(true); title.setPadding(new Insets(10, 0, 10, 0)); title.setAlignment(Pos.TOP_LEFT); title.setPrefHeight(66); title.prefWidthProperty().bind(grid.widthProperty().subtract(100).divide(5).subtract(1)); image.fitWidthProperty().bind(grid.widthProperty().subtract(100).divide(5).subtract(1)); image.fitHeightProperty().bind(grid.widthProperty().subtract(100).divide(5).subtract(1)); image.setPreserveRatio(true); image.setSmooth(true); imageBox.prefWidthProperty().bind(grid.widthProperty().subtract(100).divide(5).subtract(1)); imageBox.prefHeightProperty().bind(grid.widthProperty().subtract(100).divide(5).subtract(1)); imageBox.setAlignment(Pos.CENTER); imageBox.getChildren().add(image); cell.getChildren().addAll(imageBox, title); cell.setPadding(new Insets(10, 10, 0, 10)); cell.getStyleClass().add("artist-cell"); cell.setAlignment(Pos.CENTER); cell.setOnMouseClicked(event -> { MainController mainController = MusicPlayer.getMainController(); ArtistsMainController artistsMainController = (ArtistsMainController) mainController.loadView("ArtistsMain"); VBox artistCell = (VBox) event.getSource(); String artistTitle = ((Label) artistCell.getChildren().get(1)).getText(); Artist a = Library.getArtist(artistTitle); artistsMainController.selectArtist(a); }); cell.setOnDragDetected(event -> { PseudoClass pressed = PseudoClass.getPseudoClass("pressed"); cell.pseudoClassStateChanged(pressed, false); Dragboard db = cell.startDragAndDrop(TransferMode.ANY); ClipboardContent content = new ClipboardContent(); content.putString("Artist"); db.setContent(content); MusicPlayer.setDraggedItem(artist); db.setDragView(cell.snapshot(null, null), cell.widthProperty().divide(2).get(), cell.heightProperty().divide(2).get()); event.consume(); }); return cell; }
Example 18
Source File: CloudToTweetStep.java From TweetwallFX with MIT License | 4 votes |
private Pane createMediaBox( final WordleSkin wordleSkin, final MachineContext context, final Tweet displayTweet) { final Tweet originalTweet = displayTweet.getOriginTweet(); if (originalTweet.getMediaEntries().length > 0) { HBox mediaBox = new HBox(10); mediaBox.setOpacity(0); mediaBox.setPadding(new Insets(10)); mediaBox.setAlignment(Pos.CENTER_RIGHT); mediaBox.layoutXProperty().bind(Bindings.add( wordleSkin.getInfoBox().getPadding().getBottom() + wordleSkin.getInfoBox().getPadding().getTop(), wordleSkin.getLogo().getImage().widthProperty())); mediaBox.layoutYProperty().bind(Bindings.add( wordleSkin.getInfoBox().heightProperty(), wordleSkin.getInfoBox().layoutYProperty())); // ensure media box fills the complete area, so that layouting from right to left works mediaBox.minWidthProperty().bind(Bindings.add( wordleSkin.getPane().widthProperty(), Bindings.negate(Bindings.add( 80, wordleSkin.getLogo().getImage().widthProperty() )))); mediaBox.minHeightProperty().bind(Bindings.max( 50, Bindings.add( wordleSkin.getPane().heightProperty(), Bindings.negate(mediaBox.layoutYProperty())))); // MaxSize = MinSize mediaBox.maxWidthProperty().bind(mediaBox.minWidthProperty()); mediaBox.maxHeightProperty().bind(mediaBox.minHeightProperty()); final int imageCount = Math.min(3, originalTweet.getMediaEntries().length); //limit to maximum loading time of 3 images. final PhotoImageMediaEntryDataProvider pimedp = context.getDataProvider(PhotoImageMediaEntryDataProvider.class); for (int i = 0; i < imageCount; i++) { Image mediaImage = pimedp.getImage(originalTweet.getMediaEntries()[i]); ImageView mediaView = new ImageView(mediaImage); mediaView.setPreserveRatio(true); mediaView.setCache(true); mediaView.setSmooth(true); mediaView.fitWidthProperty().bind(Bindings.divide( Bindings.add( mediaBox.maxWidthProperty(), -10), imageCount )); mediaView.fitHeightProperty().bind(Bindings.add( mediaBox.maxHeightProperty(), -10)); mediaBox.getChildren().add(mediaView); } return mediaBox; } else { return null; } }
Example 19
Source File: CircuitSim.java From CircuitSim with BSD 3-Clause "New" or "Revised" License | 4 votes |
private ImageView setupImageView(Image image) { ImageView imageView = new ImageView(image); imageView.setSmooth(true); return imageView; }
Example 20
Source File: Skybox.java From FXyzLib with GNU General Public License v3.0 | 3 votes |
private void loadImageViews(){ for(ImageView iv : views){ iv.setSmooth(true); iv.setPreserveRatio(true); } validateImageType(); }