Java Code Examples for javafx.scene.image.ImageView#setClip()
The following examples show how to use
javafx.scene.image.ImageView#setClip() .
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: RectangularImageViewSkin.java From WorkbenchFX with Apache License 2.0 | 6 votes |
RectangularImageViewSkin(RectangularImageView control) { super(control); clip = new Rectangle(getWidthToFit(), getHeightToFit()); imageView = new ImageView(); imageView.setSmooth(true); imageView.setClip(clip); imageView.imageProperty().bind( Bindings.createObjectBinding(() -> getImage(getSkinnable().getImageURL()), getSkinnable().imageURLProperty())); getSkinnable().imageSizeProperty().addListener((observable, oldValue, newValue) -> { clip.setWidth(getWidthToFit()); clip.setHeight(getHeightToFit()); getSkinnable().requestLayout(); }); getChildren().add(imageView); }
Example 2
Source File: UserDetail.java From DashboardFx with GNU General Public License v3.0 | 6 votes |
@Override public Node icon() { Image image = new Image(getClass().getResource("/com/gn/media/img/avatar.png").toExternalForm()); ImageView imageView = new ImageView(image); imageView.setFitHeight(30); imageView.setFitWidth(30); Circle circle = new Circle(12); circle.setStroke(Color.WHITE); circle.setStrokeWidth(5); circle.setCenterX(imageView.getFitWidth() / 2); circle.setCenterY(imageView.getFitHeight() / 2); imageView.setClip(circle); return imageView; }
Example 3
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 4
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 5
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 6
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 7
Source File: TweetsToTori.java From TweetwallFX with MIT License | 5 votes |
private static Parent createTweetInfoBox(Tweet info) { HBox hbox = new HBox(20); hbox.setStyle("-fx-padding: 20px;"); HBox hImage = new HBox(); hImage.setPadding(new Insets(10)); Image image = new Image(info.getUser().getProfileImageUrl(), 48, 48, true, false); ImageView imageView = new ImageView(image); Rectangle clip = new Rectangle(48, 48); clip.setArcWidth(10); clip.setArcHeight(10); imageView.setClip(clip); hImage.getChildren().add(imageView); HBox hName = new HBox(20); Label name = new Label(info.getUser().getName()); name.setStyle("-fx-font: 32px \"Andalus\"; -fx-text-fill: #292F33; -fx-font-weight: bold;"); DateFormat df = new SimpleDateFormat("HH:mm:ss"); Label handle = new Label("@" + info.getUser().getScreenName() + " ยท " + df.format(info.getCreatedAt())); handle.setStyle("-fx-font: 28px \"Andalus\"; -fx-text-fill: #8899A6;"); hName.getChildren().addAll(name, handle); Text text = new Text(info.getText()); text.setWrappingWidth(550); text.setStyle("-fx-font: 24px \"Andalus\"; -fx-fill: #292F33;"); VBox vbox = new VBox(20); vbox.getChildren().addAll(hName, text); hbox.getChildren().addAll(hImage, vbox); return hbox; }
Example 8
Source File: LcdSkin.java From Medusa with Apache License 2.0 | 4 votes |
private void initGraphics() { // Set initial size if (Double.compare(gauge.getPrefWidth(), 0.0) <= 0 || Double.compare(gauge.getPrefHeight(), 0.0) <= 0 || Double.compare(gauge.getWidth(), 0.0) <= 0 || Double.compare(gauge.getHeight(), 0.0) <= 0) { if (gauge.getPrefWidth() > 0 && gauge.getPrefHeight() > 0) { gauge.setPrefSize(gauge.getPrefWidth(), gauge.getPrefHeight()); } else { gauge.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT); } } mainInnerShadow0 = new InnerShadow(); mainInnerShadow0.setOffsetX(0.0); mainInnerShadow0.setOffsetY(0.0); mainInnerShadow0.setRadius(0.0625 * PREFERRED_HEIGHT); mainInnerShadow0.setColor(Color.rgb(255, 255, 255, 0.5)); mainInnerShadow0.setBlurType(BlurType.TWO_PASS_BOX); mainInnerShadow1 = new InnerShadow(); mainInnerShadow1.setOffsetX(0.0); mainInnerShadow1.setOffsetY(1.0); mainInnerShadow1.setRadius(0.04166667 * PREFERRED_HEIGHT); mainInnerShadow1.setColor(Color.rgb(0, 0, 0, 0.65)); mainInnerShadow1.setBlurType(BlurType.TWO_PASS_BOX); mainInnerShadow1.setInput(mainInnerShadow0); crystalClip = new Rectangle(0, 0, width, height); crystalClip.setArcWidth(5); crystalClip.setArcHeight(5); crystalImage = Helper.createNoiseImage(PREFERRED_WIDTH, PREFERRED_HEIGHT, DARK_NOISE_COLOR, BRIGHT_NOISE_COLOR, 8); crystalOverlay = new ImageView(crystalImage); crystalOverlay.setClip(crystalClip); boolean crystalEnabled = gauge.isLcdCrystalEnabled(); Helper.enableNode(crystalOverlay, crystalEnabled); threshold = new Path(); threshold.setStroke(null); Helper.enableNode(threshold, gauge.isThresholdVisible()); average = new Path(); average.setStroke(null); Helper.enableNode(average, gauge.isAverageVisible()); backgroundText = new Text(String.format(locale, valueFormatString, gauge.getCurrentValue())); backgroundText.setFill(gauge.getLcdDesign().lcdBackgroundColor); backgroundText.setOpacity((LcdFont.LCD == gauge.getLcdFont() || LcdFont.ELEKTRA == gauge.getLcdFont()) ? 1 : 0); valueText = new Text(String.format(locale, valueFormatString, gauge.getCurrentValue())); valueText.setFill(gauge.getLcdDesign().lcdForegroundColor); unitText = new Text(gauge.getUnit()); unitText.setFill(gauge.getLcdDesign().lcdForegroundColor); Helper.enableNode(unitText, !gauge.getUnit().isEmpty()); title = new Text(gauge.getTitle()); title.setFill(gauge.getLcdDesign().lcdForegroundColor); Helper.enableNode(title, !gauge.getTitle().isEmpty()); lowerRightText = new Text(gauge.getSubTitle()); lowerRightText.setFill(gauge.getLcdDesign().lcdForegroundColor); Helper.enableNode(lowerRightText, !gauge.getSubTitle().isEmpty()); upperLeftText = new Text(String.format(locale, otherFormatString, gauge.getMinMeasuredValue())); upperLeftText.setFill(gauge.getLcdDesign().lcdForegroundColor); Helper.enableNode(upperLeftText, gauge.isMinMeasuredValueVisible()); upperRightText = new Text(String.format(locale, otherFormatString, gauge.getMaxMeasuredValue())); upperRightText.setFill(gauge.getLcdDesign().lcdForegroundColor); Helper.enableNode(upperRightText, gauge.isMaxMeasuredValueVisible()); lowerCenterText = new Text(String.format(locale, otherFormatString, gauge.getOldValue())); lowerCenterText.setFill(gauge.getLcdDesign().lcdForegroundColor); Helper.enableNode(lowerCenterText, gauge.isOldValueVisible()); shadowGroup = new Group(); shadowGroup.setEffect(gauge.isShadowsEnabled() ? FOREGROUND_SHADOW : null); shadowGroup.getChildren().setAll(threshold, average, valueText, unitText, title, lowerRightText, upperLeftText, upperRightText, lowerCenterText); pane = new Pane(crystalOverlay, backgroundText, shadowGroup); pane.setEffect(gauge.isShadowsEnabled() ? mainInnerShadow1 : null); getChildren().setAll(pane); }
Example 9
Source File: LcdClockSkin.java From Medusa with Apache License 2.0 | 4 votes |
@Override protected void initGraphics() { // Set initial size if (Double.compare(clock.getPrefWidth(), 0.0) <= 0 || Double.compare(clock.getPrefHeight(), 0.0) <= 0 || Double.compare(clock.getWidth(), 0.0) <= 0 || Double.compare(clock.getHeight(), 0.0) <= 0) { if (clock.getPrefWidth() > 0 && clock.getPrefHeight() > 0) { clock.setPrefSize(clock.getPrefWidth(), clock.getPrefHeight()); } else { clock.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT); } } mainInnerShadow0 = new InnerShadow(); mainInnerShadow0.setOffsetX(0.0); mainInnerShadow0.setOffsetY(0.0); mainInnerShadow0.setRadius(3.0 / 132.0 * PREFERRED_WIDTH); mainInnerShadow0.setColor(Color.rgb(255, 255, 255, 0.5)); mainInnerShadow0.setBlurType(BlurType.TWO_PASS_BOX); mainInnerShadow1 = new InnerShadow(); mainInnerShadow1.setOffsetX(0.0); mainInnerShadow1.setOffsetY(1.0); mainInnerShadow1.setRadius(2.0 / 132.0 * PREFERRED_WIDTH); mainInnerShadow1.setColor(Color.rgb(0, 0, 0, 0.65)); mainInnerShadow1.setBlurType(BlurType.TWO_PASS_BOX); mainInnerShadow1.setInput(mainInnerShadow0); crystalClip = new Rectangle(0, 0, PREFERRED_WIDTH, PREFERRED_HEIGHT); crystalClip.setArcWidth(5); crystalClip.setArcHeight(5); crystalImage = Helper.createNoiseImage(PREFERRED_WIDTH, PREFERRED_HEIGHT, DARK_NOISE_COLOR, BRIGHT_NOISE_COLOR, 8); crystalOverlay = new ImageView(crystalImage); crystalOverlay.setClip(crystalClip); boolean crystalEnabled = clock.isLcdCrystalEnabled(); crystalOverlay.setManaged(crystalEnabled); crystalOverlay.setVisible(crystalEnabled); boolean secondsVisible = clock.isSecondsVisible(); backgroundTimeText = new Text(""); backgroundTimeText.setFill(clock.getLcdDesign().lcdBackgroundColor); backgroundTimeText.setOpacity((LcdFont.LCD == clock.getLcdFont() || LcdFont.ELEKTRA == clock.getLcdFont()) ? 1 : 0); backgroundSecondText = new Text(""); backgroundSecondText.setFill(clock.getLcdDesign().lcdBackgroundColor); backgroundSecondText.setOpacity((LcdFont.LCD == clock.getLcdFont() || LcdFont.ELEKTRA == clock.getLcdFont()) ? 1 : 0); backgroundSecondText.setManaged(secondsVisible); backgroundSecondText.setVisible(secondsVisible); timeText = new Text(""); timeText.setFill(clock.getLcdDesign().lcdForegroundColor); secondText = new Text(""); secondText.setFill(clock.getLcdDesign().lcdForegroundColor); secondText.setManaged(secondsVisible); secondText.setVisible(secondsVisible); title = new Text(clock.getTitle()); title.setFill(clock.getLcdDesign().lcdForegroundColor); boolean titleVisible = clock.isTitleVisible(); title.setManaged(titleVisible); title.setVisible(titleVisible); dateText = new Text(dateFormat.format(clock.getTime())); dateText.setFill(clock.getLcdDesign().lcdForegroundColor); boolean dateVisible = clock.isDateVisible(); dateText.setManaged(dateVisible); dateText.setVisible(dateVisible); dayOfWeekText = new Text(""); dayOfWeekText.setFill(clock.getLcdDesign().lcdForegroundColor); dayOfWeekText.setManaged(dateVisible); dayOfWeekText.setVisible(dateVisible); alarm = new Path(); alarm.setFillRule(FillRule.EVEN_ODD); alarm.setStroke(null); boolean alarmVisible = clock.getAlarms().size() > 0; alarm.setManaged(alarmVisible); alarm.setVisible(alarmVisible); shadowGroup = new Group(); shadowGroup.setEffect(clock.getShadowsEnabled() ? FOREGROUND_SHADOW : null); shadowGroup.getChildren().setAll(timeText, secondText, title, dateText, dayOfWeekText, alarm); pane = new Pane(); pane.setEffect(clock.getShadowsEnabled() ? mainInnerShadow1 : null); pane.getChildren().setAll(crystalOverlay, backgroundTimeText, backgroundSecondText, shadowGroup); getChildren().setAll(pane); }
Example 10
Source File: CloudToTweetStep.java From TweetwallFX with MIT License | 4 votes |
private Pane createInfoBox( final WordleSkin wordleSkin, final MachineContext context, final Tweet displayTweet, final Point2D lowerLeft) { final Tweet originalTweet = displayTweet.getOriginTweet(); Image profileImage = context.getDataProvider(TweetUserProfileImageDataProvider.class).getImage(originalTweet.getUser()); ImageView imageView = new ImageView(profileImage); Rectangle clip = new Rectangle(64, 64); clip.setArcWidth(10); clip.setArcHeight(10); imageView.setClip(clip); HBox imageBox = new HBox(imageView); imageBox.setPadding(new Insets(10)); Label name = new Label(originalTweet.getUser().getName()); name.getStyleClass().setAll("name"); Label handle = new Label("@" + originalTweet.getUser().getScreenName() + " - " + wordleSkin.getDf().format(originalTweet.getCreatedAt())); handle.getStyleClass().setAll("handle"); HBox firstLineBox = new HBox(); HBox secondLineBox = new HBox(name); HBox thirdLineBox = new HBox(handle); if (originalTweet.getUser().isVerified()) { FontAwesomeIconView verifiedIcon = new FontAwesomeIconView(); verifiedIcon.getStyleClass().addAll("verifiedAccount"); secondLineBox.getChildren().add(verifiedIcon); HBox.setMargin(verifiedIcon, new Insets(9, 10, 0, 5)); } if (displayTweet.isRetweet()) { FontAwesomeIconView retweetIconBack = new FontAwesomeIconView(); retweetIconBack.getStyleClass().addAll("retweetBack"); FontAwesomeIconView retweetIconFront = new FontAwesomeIconView(); retweetIconFront.getStyleClass().addAll("retweetFront"); Label retweetName = new Label(displayTweet.getUser().getName()); retweetName.getStyleClass().setAll("retweetName"); GlyphsStack stackedIcon = GlyphsStack.create() .add(retweetIconBack) .add(retweetIconFront); firstLineBox.getChildren().addAll(stackedIcon, retweetName); HBox.setMargin(stackedIcon, new Insets(0, 10, 0, 0)); } if (wordleSkin.getFavIconsVisible()) { if (0 < originalTweet.getRetweetCount()) { FontAwesomeIconView faiReTwCount = new FontAwesomeIconView(); faiReTwCount.getStyleClass().setAll("retweetCount"); Label reTwCount = new Label(String.valueOf(originalTweet.getRetweetCount())); reTwCount.getStyleClass().setAll("handle"); thirdLineBox.getChildren().addAll(faiReTwCount, reTwCount); HBox.setMargin(faiReTwCount, new Insets(5, 10, 0, 5)); } if (0 < originalTweet.getFavoriteCount()) { FontAwesomeIconView faiFavCount = new FontAwesomeIconView(); faiFavCount.getStyleClass().setAll("favoriteCount"); Label favCount = new Label(String.valueOf(originalTweet.getFavoriteCount())); favCount.getStyleClass().setAll("handle"); thirdLineBox.getChildren().addAll(faiFavCount, favCount); HBox.setMargin(faiFavCount, new Insets(5, 10, 0, 5)); } } final GridPane infoBox = new GridPane(); infoBox.setStyle("-fx-padding: 20px;"); infoBox.setPrefHeight(100); infoBox.setMaxHeight(100); infoBox.setLayoutX(lowerLeft.getX()); infoBox.setLayoutY(lowerLeft.getY()); infoBox.setAlignment(Pos.CENTER); infoBox.getChildren().addAll(imageBox, firstLineBox, secondLineBox, thirdLineBox); GridPane.setConstraints(imageBox, 0, 1, 1, 2); GridPane.setConstraints(firstLineBox, 1, 0); GridPane.setConstraints(secondLineBox, 1, 1); GridPane.setConstraints(thirdLineBox, 1, 2); return infoBox; }
Example 11
Source File: BrushedMetalPaint.java From Enzo with Apache License 2.0 | 4 votes |
public ImageView getImageView(final double W, final double H, final Shape CLIP) { final Image IMAGE = getImage(W, H); final ImageView IMAGE_VIEW = new ImageView(IMAGE); IMAGE_VIEW.setClip(CLIP); return IMAGE_VIEW; }
Example 12
Source File: LcdClockSkin.java From Enzo with Apache License 2.0 | 4 votes |
private void initGraphics() { // load the fonts Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/digital.ttf"), (0.5833333333 * PREFERRED_HEIGHT)); // "Digital-7" Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/digitalreadout.ttf"), (0.5833333333 * PREFERRED_HEIGHT)); // "Digital Readout Upright" Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/digitalreadoutb.ttf"), (0.5833333333 * PREFERRED_HEIGHT)); // "Digital Readout Thick Upright" Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/elektra.ttf"), (0.58333333 * PREFERRED_HEIGHT)); // "Elektra" Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/opensans-semibold.ttf"), (0.58333333 * PREFERRED_HEIGHT)); // "OpenSans" main = new Region(); main.getStyleClass().setAll("main"); main.setOpacity(getSkinnable().isBackgroundVisible() ? 1 : 0); mainInnerShadow0 = new InnerShadow(); mainInnerShadow0.setOffsetX(0.0); mainInnerShadow0.setOffsetY(0.0); mainInnerShadow0.setRadius(3.0 / 132.0 * PREFERRED_WIDTH); mainInnerShadow0.setColor(Color.web("0xffffff80")); mainInnerShadow0.setBlurType(BlurType.TWO_PASS_BOX); mainInnerShadow1 = new InnerShadow(); mainInnerShadow1.setOffsetX(0.0); mainInnerShadow1.setOffsetY(1.0); mainInnerShadow1.setRadius(2.0 / 132.0 * PREFERRED_WIDTH); mainInnerShadow1.setColor(Color.web("0x000000a6")); mainInnerShadow1.setBlurType(BlurType.TWO_PASS_BOX); mainInnerShadow1.setInput(mainInnerShadow0); main.setEffect(getSkinnable().isMainInnerShadowVisible() ? mainInnerShadow1 : null); crystalClip = new Rectangle(0, 0, PREFERRED_WIDTH, PREFERRED_HEIGHT); crystalClip.setArcWidth(5); crystalClip.setArcHeight(5); crystalImage = createNoiseImage(PREFERRED_WIDTH, PREFERRED_HEIGHT, DARK_NOISE_COLOR, BRIGHT_NOISE_COLOR, 8); crystalOverlay = new ImageView(crystalImage); crystalOverlay.setClip(this.crystalClip); crystalOverlay.setOpacity(getSkinnable().isCrystalOverlayVisible() ? 1 : 0); alarm = new Region(); alarm.getStyleClass().setAll("alarm"); alarm.setOpacity(getSkinnable().getAlarms().isEmpty() || allAlarmsInactive() ? 0 : 1); backgroundTimeText = new Text(""); backgroundTimeText.getStyleClass().setAll("fg-trsp"); backgroundTimeText.setOpacity((LcdClock.LcdFont.LCD == getSkinnable().getTimeFont() || LcdClock.LcdFont.ELEKTRA == getSkinnable().getTimeFont()) ? 1 : 0); timeText = new Text(""); timeText.getStyleClass().setAll("fg"); backgroundSecondText = new Text(""); backgroundSecondText.getStyleClass().setAll("fg-trsp"); backgroundSecondText.setOpacity((LcdClock.LcdFont.LCD == getSkinnable().getTimeFont() || LcdClock.LcdFont.ELEKTRA == getSkinnable().getTimeFont()) ? 1 : 0); secondText = new Text(""); secondText.getStyleClass().setAll("fg"); title = new Text(getSkinnable().getTitle()); title.getStyleClass().setAll("fg"); dateText = new Text(getSkinnable().getTime().getMonthValue() + "/" + getSkinnable().getTime().getDayOfMonth() + "/" + getSkinnable().getTime().getYear()); dateText.getStyleClass().setAll("fg"); dayOfWeekText = new Text(""); dayOfWeekText.getStyleClass().setAll("fg"); shadowGroup = new Group(); shadowGroup.setEffect(getSkinnable().isForegroundShadowVisible() ? FOREGROUND_SHADOW : null); shadowGroup.getChildren().setAll(alarm, timeText, secondText, title, dateText, dayOfWeekText); pane = new Pane(); pane.getChildren().setAll(main, crystalOverlay, backgroundTimeText, backgroundSecondText, shadowGroup); getChildren().setAll(pane); resize(); updateLcd(); }