private void updateHSLCircleColor(int x, int y) { // transform color to HSL space Color color = huesCircleView.getImage().getPixelReader().getColor(x, y); double max = Math.max(color.getRed(), Math.max(color.getGreen(), color.getBlue())); double min = Math.min(color.getRed(), Math.min(color.getGreen(), color.getBlue())); double hue = 0; if (max != min) { double d = max - min; if (max == color.getRed()) { hue = (color.getGreen() - color.getBlue()) / d + (color.getGreen() < color.getBlue() ? 6 : 0); } else if (max == color.getGreen()) { hue = (color.getBlue() - color.getRed()) / d + 2; } else if (max == color.getBlue()) { hue = (color.getRed() - color.getGreen()) / d + 4; } hue /= 6; } currentHue = map(hue, 0, 1, 0, 255); // refresh the HSL circle refreshHSLCircle(); }
if (node instanceof ImageView) { ImageView imageView = (ImageView) node; String url = imageView.getImage().impl_getUrl(); if (url != null && imageNamePattern.matcher(url).matches()) { Node button = imageView.getParent().getParent();
ImageView image = ... ImageView src = ... image.setImage(src.getImage());
public Node getView() { return imageView.getImage() != null ? imageView : view; }
public Node getView() { return imageView.getImage() != null ? imageView : view; }
box.setButtonCell(new ListCell<ImageView>() { @Override protected void updateItem(ImageView item, boolean empty) { super.updateItem(item, empty); if (item == null || empty) { setGraphic(null); } else { setGraphic(new ImageView(item.getImage())); } } });
/** * {@inheritDoc} */ @Override public Image getImage() { if ( _content instanceof ImageView ) { return ((ImageView) _content).getImage(); } else if ( _content instanceof FxLabelDecorator ) { return ((FxLabelDecorator) _content).getImage(); } return null; }
EventHandler mouseHandler = new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent t) { ImageView imageView = (ImageView) t.getSource(); System.out.println("You clicked " + imageView.getImage()); } }; for (int i = 0; i < 8; i++) { ImageView imageView = new ImageView(im[i]); imageView.setOnMouseClicked(mouseHandler); flowpane.getChildren().add(imageView); }
private static Node copyNode( Node node ) { if ( node instanceof ImageView ) { return new ImageView( ((ImageView)node).getImage()); } else if ( node instanceof Duplicatable<?> ) { return (Node) ((Duplicatable<?>)node).duplicate(); } else { return null; } }
/** * Create an element that will layout the <code>childNode</code> * horizontally centered within a Dialog. * @param childNode that should be centered * @return wrapping Pane */ public Pane center(ImageView childNode) { final int width = IDialog.WRAPPING_WIDTH - 24; Pane g = new Pane(childNode); double in = (width - childNode.getImage().getWidth())/2; g.setLayoutX(in); childNode.getImage().widthProperty().addListener((observable, oldValue, newValue) -> { double inset = (width - childNode.getImage().getWidth())/2; g.setLayoutX(inset); }); return g; } /**
private boolean scrolledAllToTheRight() { return clip.getX() >= imgView.getImage().getWidth() - clip.getWidth(); }
/** * Override this to create your own splash pane parent node. * * @return A standard image */ public Parent getParent() { final ImageView imageView = new ImageView(getClass().getResource(getImagePath()).toExternalForm()); final ProgressBar splashProgressBar = new ProgressBar(); splashProgressBar.setPrefWidth(imageView.getImage().getWidth()); final VBox vbox = new VBox(); vbox.getChildren().addAll(imageView, splashProgressBar); return vbox; }
private void focusOnPoint(Point2D focus) { double totalwidth = imgView.getImage().getWidth(); double focusX = focus.getX(); double clipX = clip.getX(); double clipWidth = clip.getWidth(); double centerX = clipX + clipWidth/2; if (clipX == 0.0 && focusX < centerX) { // we are all to the left } else if (clipX + clipWidth >= totalwidth) { // we are all to the right } else { double x = Math.min(focusX - clipWidth/2, totalwidth - clipWidth); resetClipXPosition(x); } }
/** * set the color of the graphic of the given tab * * @param tab * - the tab to change * @param oldColor * - the old color * @param newColor * - the new color */ protected void setColor(Tab tab, Color oldColor, Color newColor) { if (debug) LOGGER.log(Level.INFO, "changing tab color for " + tab.getId() + " from " + oldColor + " to " + newColor); Node graphic = tab.getGraphic(); if (graphic instanceof Glyph) { Glyph glyph = (Glyph) graphic; glyph.setColor(newColor); } else if (graphic instanceof ImageView) { // https://docs.oracle.com/javafx/2/image_ops/jfxpub-image_ops.htm ImageView imageView = (ImageView) graphic; imageView.setImage(reColor(imageView.getImage(), oldColor, newColor)); } }
private static final Image ledOff = new Image("/images/led_white.gif"); private static final Image ledOn = new Image("/images/led_blue.gif"); @FXML private GridPane ledPanel ; private ImageView[] leds ; public void initialize() { final int numLeds = 64 ; final int numLedsPerRow = 8 ; leds = new ImageView[numLeds]; for (int i=0; i<numLeds; i++) { ImageView led = new ImageView(ledOff); leds[i] = led ; ledPanel.add(leds[i], i % numLedsPerRow, i / numLedsPerRow); led.setOnMousePressed(event -> { if (led.getImage()==ledOff) { led.setImage(ledOn); } else { led.setImage(ledOff); } }); } }
private void updateHSLCircleColor(int x, int y) { // transform color to HSL space Color color = huesCircleView.getImage().getPixelReader().getColor(x, y); double max = Math.max(color.getRed(), Math.max(color.getGreen(), color.getBlue())); double min = Math.min(color.getRed(), Math.min(color.getGreen(), color.getBlue())); double hue = 0; if (max != min) { double d = max - min; if (max == color.getRed()) { hue = (color.getGreen() - color.getBlue()) / d + (color.getGreen() < color.getBlue() ? 6 : 0); } else if (max == color.getGreen()) { hue = (color.getBlue() - color.getRed()) / d + 2; } else if (max == color.getBlue()) { hue = (color.getRed() - color.getGreen()) / d + 4; } hue /= 6; } currentHue = map(hue, 0, 1, 0, 255); // refresh the HSL circle refreshHSLCircle(); }