Java Code Examples for javafx.scene.text.Text#setOpacity()
The following examples show how to use
javafx.scene.text.Text#setOpacity() .
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: StringBindingSample.java From marathonv5 with Apache License 2.0 | 6 votes |
public static Node createIconContent() { Text text = new Text("abc"); text.setTextOrigin(VPos.TOP); text.setLayoutX(10); text.setLayoutY(11); text.setFill(Color.BLACK); text.setOpacity(0.5); text.setFont(Font.font(null, FontWeight.BOLD, 20)); text.setStyle("-fx-font-size: 20px;"); Text text2 = new Text("abc"); text2.setTextOrigin(VPos.TOP); text2.setLayoutX(28); text2.setLayoutY(51); text2.setFill(Color.BLACK); text2.setFont(javafx.scene.text.Font.font(null, FontWeight.BOLD, 20)); text2.setStyle("-fx-font-size: 20px;"); Line line = new Line(30, 32, 45, 57); line.setStroke(Color.DARKMAGENTA); return new javafx.scene.Group(text, line, text2); }
Example 2
Source File: StringBindingSample.java From marathonv5 with Apache License 2.0 | 6 votes |
public static Node createIconContent() { Text text = new Text("abc"); text.setTextOrigin(VPos.TOP); text.setLayoutX(10); text.setLayoutY(11); text.setFill(Color.BLACK); text.setOpacity(0.5); text.setFont(Font.font(null, FontWeight.BOLD, 20)); text.setStyle("-fx-font-size: 20px;"); Text text2 = new Text("abc"); text2.setTextOrigin(VPos.TOP); text2.setLayoutX(28); text2.setLayoutY(51); text2.setFill(Color.BLACK); text2.setFont(javafx.scene.text.Font.font(null, FontWeight.BOLD, 20)); text2.setStyle("-fx-font-size: 20px;"); Line line = new Line(30, 32, 45, 57); line.setStroke(Color.DARKMAGENTA); return new javafx.scene.Group(text, line, text2); }
Example 3
Source File: MKXMenuApp.java From FXTutorials with MIT License | 6 votes |
private Node createRightContent() { String title = "Please Subscribe :)"; HBox letters = new HBox(0); letters.setAlignment(Pos.CENTER); for (int i = 0; i < title.length(); i++) { Text letter = new Text(title.charAt(i) + ""); letter.setFont(FONT); letter.setFill(Color.WHITE); letter.setOpacity(0); letters.getChildren().add(letter); FadeTransition ft = new FadeTransition(Duration.seconds(2), letter); ft.setDelay(Duration.millis(i * 50)); ft.setToValue(1); ft.setAutoReverse(true); ft.setCycleCount(TranslateTransition.INDEFINITE); ft.play(); } return letters; }
Example 4
Source File: HyperlinkWithIcon.java From bisq with GNU Affero General Public License v3.0 | 6 votes |
public HyperlinkWithIcon(String text, GlyphIcons icon, String style) { super(text); Text textIcon = FormBuilder.getIcon(icon); textIcon.setOpacity(0.7); textIcon.getStyleClass().addAll("hyperlink", "no-underline"); if (style != null) { textIcon.getStyleClass().add(style); getStyleClass().add(style); } setPadding(new Insets(0)); setIcon(textIcon); }
Example 5
Source File: SpaceRunnerApp.java From FXGLGames with MIT License | 5 votes |
private void nextLevel() { uiTextLevel.setVisible(false); inc("level", +1); level = new Level(); level.spawnNewWave(); Text textLevel = getUIFactory().newText("Level " + geti("level"), Color.WHITE, 22); textLevel.setEffect(new DropShadow(7, Color.BLACK)); textLevel.setOpacity(0); centerText(textLevel); textLevel.setTranslateY(250); addUINode(textLevel); animationBuilder() .interpolator(Interpolators.SMOOTH.EASE_OUT()) .duration(Duration.seconds(1.66)) .onFinished(() -> { animationBuilder() .duration(Duration.seconds(1.66)) .interpolator(Interpolators.EXPONENTIAL.EASE_IN()) .onFinished(() -> { removeUINode(textLevel); uiTextLevel.setVisible(true); }) .translate(textLevel) .from(new Point2D(textLevel.getTranslateX(), textLevel.getTranslateY())) .to(new Point2D(330, 540)) .buildAndPlay(); }) .fadeIn(textLevel) .buildAndPlay(); }
Example 6
Source File: SpaceRunnerApp.java From FXGLGames with MIT License | 5 votes |
private void nextLevel() { uiTextLevel.setVisible(false); inc("level", +1); level = new Level(); level.spawnNewWave(); Text textLevel = getUIFactory().newText("Level " + geti("level"), Color.WHITE, 22); textLevel.setEffect(new DropShadow(7, Color.BLACK)); textLevel.setOpacity(0); centerText(textLevel); textLevel.setTranslateY(250); addUINode(textLevel); animationBuilder() .interpolator(Interpolators.SMOOTH.EASE_OUT()) .duration(Duration.seconds(1.66)) .onFinished(() -> { animationBuilder() .duration(Duration.seconds(1.66)) .interpolator(Interpolators.EXPONENTIAL.EASE_IN()) .onFinished(() -> { removeUINode(textLevel); uiTextLevel.setVisible(true); }) .translate(textLevel) .from(new Point2D(textLevel.getTranslateX(), textLevel.getTranslateY())) .to(new Point2D(330, 540)) .buildAndPlay(); }) .fadeIn(textLevel) .buildAndPlay(); }
Example 7
Source File: WhitespaceOverlayFactory.java From markdown-writer-fx with BSD 2-Clause "Simplified" License | 5 votes |
private Text createTextNode(String text, Collection<String> styleClasses, int start, int end) { Text t = new Text(text); t.setTextOrigin(VPos.TOP); t.getStyleClass().add("text"); t.setOpacity(0.3); t.getStyleClass().addAll(styleClasses); t.setUserData(new Range(start, end)); return t; }
Example 8
Source File: FroggerApp.java From FXTutorials with MIT License | 5 votes |
private void checkState() { for (Node car : cars) { if (car.getBoundsInParent().intersects(frog.getBoundsInParent())) { frog.setTranslateX(0); frog.setTranslateY(600 - 39); return; } } if (frog.getTranslateY() <= 0) { timer.stop(); String win = "YOU WIN"; HBox hBox = new HBox(); hBox.setTranslateX(300); hBox.setTranslateY(250); root.getChildren().add(hBox); for (int i = 0; i < win.toCharArray().length; i++) { char letter = win.charAt(i); Text text = new Text(String.valueOf(letter)); text.setFont(Font.font(48)); text.setOpacity(0); hBox.getChildren().add(text); FadeTransition ft = new FadeTransition(Duration.seconds(0.66), text); ft.setToValue(1); ft.setDelay(Duration.seconds(i * 0.15)); ft.play(); } } }
Example 9
Source File: FormBuilder.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
public static Text getIconForLabel(GlyphIcons icon, String iconSize, Label label, String style) { if (icon.fontFamily().equals(MATERIAL_DESIGN_ICONS)) { final Text textIcon = MaterialDesignIconFactory.get().createIcon(icon, iconSize); textIcon.setOpacity(0.7); if (style != null) { textIcon.getStyleClass().add(style); } label.setContentDisplay(ContentDisplay.LEFT); label.setGraphic(textIcon); return textIcon; } else { throw new IllegalArgumentException("Not supported icon type"); } }
Example 10
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 11
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 12
Source File: MKXMenuApp.java From FXTutorials with MIT License | 4 votes |
private Parent createContent() { Pane root = new Pane(); root.setPrefSize(900, 600); Rectangle bg = new Rectangle(900, 600); ContentFrame frame1 = new ContentFrame(createLeftContent()); ContentFrame frame2 = new ContentFrame(createMiddleContent()); ContentFrame frame3 = new ContentFrame(createRightContent()); HBox hbox = new HBox(15, frame1, frame2, frame3); hbox.setTranslateX(120); hbox.setTranslateY(50); MenuItem itemExit = new MenuItem("EXIT"); itemExit.setOnActivate(() -> System.exit(0)); menuBox = new VBox(10, new MenuItem("ONE PLAYER"), new MenuItem("TWO PLAYER"), new MenuItem("ONLINE"), new MenuItem("FACTION"), new MenuItem("KRYPT"), new MenuItem("OPTIONS"), new MenuItem("EXTRAS*"), itemExit); menuBox.setAlignment(Pos.TOP_CENTER); menuBox.setTranslateX(360); menuBox.setTranslateY(300); Text about = new Text("MKXMenuApp\n\tby\n AlmasB"); about.setTranslateX(50); about.setTranslateY(500); about.setFill(Color.WHITE); about.setFont(FONT); about.setOpacity(0.2); getMenuItem(0).setActive(true); root.getChildren().addAll(bg, hbox, menuBox, about); return root; }
Example 13
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(); }