javafx.scene.effect.ColorInput Java Examples
The following examples show how to use
javafx.scene.effect.ColorInput.
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: GameToken.java From metastone with GNU General Public License v2.0 | 6 votes |
private void createTargetButton() { target = (StackPane) lookup("#targetAnchor"); Image image = IconFactory.getTargetIcon(); ImageView targetIcon = new ImageView(image); targetIcon.setClip(new ImageView(image)); ColorAdjust monochrome = new ColorAdjust(); monochrome.setSaturation(-1.0); Blend red = new Blend(BlendMode.MULTIPLY, monochrome, new ColorInput(0, 0, targetIcon.getImage().getWidth(), targetIcon.getImage().getHeight(), Color.RED)); Blend green = new Blend(BlendMode.MULTIPLY, monochrome, new ColorInput(0, 0, targetIcon.getImage().getWidth(), targetIcon.getImage().getHeight(), new Color(0, 1, 0, 0.5))); targetButton = targetIcon; targetIcon.effectProperty().bind(Bindings.when(targetButton.hoverProperty()).then((Effect) green).otherwise((Effect) red)); targetButton.setId("target_button"); hideTargetMarker(); target.getChildren().add(targetButton); }
Example #2
Source File: FxmlImageManufacture.java From MyBox with Apache License 2.0 | 5 votes |
public static Image addArcFx(Image image, int arc, Color bgColor) { try { if (image == null || arc <= 0) { return null; } Group group = new Group(); double imageWidth = image.getWidth(), imageHeight = image.getHeight(); Scene scene = new Scene(group); ImageView view = new ImageView(image); view.setPreserveRatio(true); view.setFitWidth(imageWidth); view.setFitHeight(imageHeight); Rectangle clip = new Rectangle(imageWidth, imageHeight); clip.setArcWidth(arc); clip.setArcHeight(arc); view.setClip(clip); group.getChildren().add(view); Blend blend = new Blend(BlendMode.SRC_OVER); blend.setBottomInput(new ColorInput(0, 0, imageWidth, imageHeight, bgColor)); group.setEffect(blend); SnapshotParameters parameters = new SnapshotParameters(); parameters.setFill(Color.TRANSPARENT); WritableImage newImage = group.snapshot(parameters, null); return newImage; } catch (Exception e) { // logger.error(e.toString()); return null; } }
Example #3
Source File: DotGraphView.java From gef with Eclipse Public License 2.0 | 5 votes |
private void addGraphBackground(Paint paint) { double margin = 5; GraphPart graphPart = (GraphPart) getContentViewer().getRootPart() .getContentPartChildren().get(0); Group group = graphPart.getVisual(); Bounds bounds = group.getLayoutBounds(); group.setEffect(new Blend(BlendMode.SRC_OVER, new ColorInput(bounds.getMinX() - margin, bounds.getMinY() - margin, bounds.getWidth() + 2 * margin, bounds.getHeight() + 2 * margin, paint), null)); }
Example #4
Source File: DigitFactory.java From metastone with GNU General Public License v2.0 | 5 votes |
private static void applyFontColor(ImageView image, Color color) { ColorAdjust monochrome = new ColorAdjust(); monochrome.setSaturation(-1.0); Effect colorInput = new ColorInput(0, 0, image.getImage().getWidth(), image.getImage().getHeight(), color); Blend blend = new Blend(BlendMode.MULTIPLY, new ImageInput(image.getImage()), colorInput); image.setClip(new ImageView(image.getImage())); image.setEffect(blend); image.setCache(true); }
Example #5
Source File: ImageUtil.java From Augendiagnose with GNU General Public License v2.0 | 5 votes |
/** * Retrieve an overlay image. * * @param overlayType * The overlay type. * @param side * The side of the eye. * @param color * The overlay color. * * @return The overlay image. */ private static Image getOverlayImage(final int overlayType, final RightLeft side, final Color color) { URL imageUrl = ClassLoader.getSystemResource("overlay/" + getOverlayFileName(overlayType, side)); Image image = new Image(imageUrl.toExternalForm()); Canvas canvas = new Canvas(OVERLAY_SIZE, OVERLAY_SIZE); Color colorNoAlpha = new Color(color.getRed(), color.getGreen(), color.getBlue(), 1); Blend effect = new Blend( BlendMode.SRC_ATOP, null, new ColorInput( 0, 0, OVERLAY_SIZE, OVERLAY_SIZE, colorNoAlpha)); // Type 2 is not changed in color. if (overlayType != 2) { canvas.getGraphicsContext2D().setEffect(effect); } canvas.getGraphicsContext2D().setGlobalAlpha(color.getOpacity()); canvas.getGraphicsContext2D().drawImage(image, 0, 0, OVERLAY_SIZE, OVERLAY_SIZE); SnapshotParameters parameters = new SnapshotParameters(); parameters.setFill(Color.TRANSPARENT); return canvas.snapshot(parameters, null); }
Example #6
Source File: VertexTypeNodeProvider.java From constellation with Apache License 2.0 | 4 votes |
public VertexTypeNodeProvider() { schemaLabel = new Label(SeparatorConstants.HYPHEN); schemaLabel.setPadding(new Insets(5)); treeView = new TreeView<>(); vertexTypes = new ArrayList<>(); detailsView = new HBox(); detailsView.setPadding(new Insets(5)); backgroundIcons = new HashMap<>(); foregroundIcons = new HashMap<>(); startsWithRb = new RadioButton("Starts with"); filterText = new TextField(); // A shiny cell factory so the tree nodes show the correct text and graphic. treeView.setCellFactory(p -> new TreeCell<SchemaVertexType>() { @Override protected void updateItem(final SchemaVertexType item, boolean empty) { super.updateItem(item, empty); if (!empty && item != null) { setText(item.getName()); if (item.getForegroundIcon() != null) { // Background icon, sized, clipped, colored. final Color color = item.getColor().getJavaFXColor(); if (!backgroundIcons.containsKey(item)) { backgroundIcons.put(item, item.getBackgroundIcon().buildImage()); } final ImageView bg = new ImageView(backgroundIcons.get(item)); bg.setFitWidth(SMALL_ICON_IMAGE_SIZE); bg.setPreserveRatio(true); bg.setSmooth(true); final ImageView clip = new ImageView(bg.getImage()); clip.setFitWidth(SMALL_ICON_IMAGE_SIZE); clip.setPreserveRatio(true); clip.setSmooth(true); bg.setClip(clip); final ColorAdjust adjust = new ColorAdjust(); adjust.setSaturation(-1); final ColorInput ci = new ColorInput(0, 0, SMALL_ICON_IMAGE_SIZE, SMALL_ICON_IMAGE_SIZE, color); final Blend blend = new Blend(BlendMode.MULTIPLY, adjust, ci); bg.setEffect(blend); // Foreground icon, sized. if (!foregroundIcons.containsKey(item)) { foregroundIcons.put(item, item.getForegroundIcon().buildImage()); } final ImageView fg = new ImageView(foregroundIcons.get(item)); fg.setFitWidth(SMALL_ICON_IMAGE_SIZE); fg.setPreserveRatio(true); fg.setSmooth(true); fg.setCache(true); // Combine foreground and background icons. final Group iconGroup = new Group(bg, fg); setGraphic(iconGroup); } } else { setGraphic(null); setText(null); } } }); }
Example #7
Source File: FxmlImageManufacture.java From MyBox with Apache License 2.0 | 4 votes |
public static Image combineImagesColumnFx(List<Image> images, Color bgColor, int interval, int Margin) { try { if (images == null || images.isEmpty()) { return null; } Group group = new Group(); int x = Margin, y = Margin, width = 0, height = 0; for (int i = 0; i < images.size(); ++i) { Image image = images.get(i); ImageView view = new ImageView(image); view.setPreserveRatio(true); view.setFitWidth(image.getWidth()); view.setFitHeight(image.getHeight()); view.setX(x); view.setY(y); group.getChildren().add(view); x = Margin; y += image.getHeight() + interval; if (image.getWidth() > width) { width = (int) image.getWidth(); } } width += 2 * Margin; height = y + Margin - interval; Blend blend = new Blend(BlendMode.SRC_OVER); blend.setBottomInput(new ColorInput(0, 0, width, height, bgColor)); group.setEffect(blend); SnapshotParameters parameters = new SnapshotParameters(); parameters.setFill(Color.TRANSPARENT); WritableImage newImage = group.snapshot(parameters, null); return newImage; } catch (Exception e) { logger.error(e.toString()); return null; } }
Example #8
Source File: FxmlImageManufacture.java From MyBox with Apache License 2.0 | 4 votes |
public static Image combineSingleColumnFx(List<Image> images) { if (images == null || images.isEmpty()) { return null; } try { Group group = new Group(); double x = 0, y = 0, imageWidth, imageHeight; double totalWidth = 0, totalHeight = 0; for (Image theImage : images) { ImageView view = new ImageView(theImage); imageWidth = theImage.getWidth(); imageHeight = theImage.getHeight(); view.setPreserveRatio(true); view.setX(x); view.setY(y); view.setFitWidth(imageWidth); view.setFitHeight(imageHeight); group.getChildren().add(view); y += imageHeight; if (imageWidth > totalWidth) { totalWidth = imageWidth; } } totalHeight = y; Blend blend = new Blend(BlendMode.SRC_OVER); blend.setBottomInput(new ColorInput(0, 0, totalWidth, totalHeight, Color.TRANSPARENT)); group.setEffect(blend); SnapshotParameters parameters = new SnapshotParameters(); parameters.setFill(Color.TRANSPARENT); WritableImage newImage = group.snapshot(parameters, null); return newImage; } catch (Exception e) { logger.error(e.toString()); return null; } }
Example #9
Source File: FxmlImageManufacture.java From MyBox with Apache License 2.0 | 4 votes |
public static Image addMarginsFx2(Image image, Color color, int MarginWidth, boolean addTop, boolean addBottom, boolean addLeft, boolean addRight) { try { if (image == null || MarginWidth <= 0) { return image; } Group group = new Group(); double imageWidth = image.getWidth(), imageHeight = image.getHeight(); double totalWidth = image.getWidth(), totalHeight = image.getHeight(); ImageView view = new ImageView(image); view.setPreserveRatio(true); view.setFitWidth(imageWidth); view.setFitHeight(imageHeight); if (addLeft) { view.setX(MarginWidth); totalWidth += MarginWidth; } else { view.setX(0); } if (addTop) { view.setY(MarginWidth); totalHeight += MarginWidth; } else { view.setY(0); } if (addBottom) { totalHeight += MarginWidth; } if (addRight) { totalWidth += MarginWidth; } group.getChildren().add(view); Blend blend = new Blend(BlendMode.SRC_OVER); blend.setBottomInput(new ColorInput(0, 0, totalWidth, totalHeight, color)); group.setEffect(blend); SnapshotParameters parameters = new SnapshotParameters(); parameters.setFill(Color.TRANSPARENT); WritableImage newImage = group.snapshot(parameters, null); return newImage; } catch (Exception e) { logger.error(e.toString()); return image; } }