Java Code Examples for javafx.scene.effect.InnerShadow#setOffsetX()

The following examples show how to use javafx.scene.effect.InnerShadow#setOffsetX() . 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: InnerShadowSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public InnerShadowSample() {
    Text sample = new Text(0,100,"Shadow");
    sample.setFont(Font.font("Arial Black",80));
    sample.setFill(Color.web("#BBBBBB"));
    final InnerShadow innerShadow = new InnerShadow();
    innerShadow.setRadius(5d);
    innerShadow.setOffsetX(2);
    innerShadow.setOffsetY(2);
    sample.setEffect(innerShadow);
    getChildren().add(sample);
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Text Fill", sample.fillProperty()),
            new SimplePropertySheet.PropDesc("Inner Shadow Radius", innerShadow.radiusProperty(), 0d,60d),
            new SimplePropertySheet.PropDesc("Inner Shadow Offset X", innerShadow.offsetXProperty(), -10d, 10d),
            new SimplePropertySheet.PropDesc("Inner Shadow Offset Y", innerShadow.offsetYProperty(), -10d, 10d),
            new SimplePropertySheet.PropDesc("Inner Shadow Color", innerShadow.colorProperty())
    );
    // END REMOVE ME
}
 
Example 2
Source File: InnerShadowSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public InnerShadowSample() {
    Text sample = new Text(0,100,"Shadow");
    sample.setFont(Font.font("Arial Black",80));
    sample.setFill(Color.web("#BBBBBB"));
    final InnerShadow innerShadow = new InnerShadow();
    innerShadow.setRadius(5d);
    innerShadow.setOffsetX(2);
    innerShadow.setOffsetY(2);
    sample.setEffect(innerShadow);
    getChildren().add(sample);
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Text Fill", sample.fillProperty()),
            new SimplePropertySheet.PropDesc("Inner Shadow Radius", innerShadow.radiusProperty(), 0d,60d),
            new SimplePropertySheet.PropDesc("Inner Shadow Offset X", innerShadow.offsetXProperty(), -10d, 10d),
            new SimplePropertySheet.PropDesc("Inner Shadow Offset Y", innerShadow.offsetYProperty(), -10d, 10d),
            new SimplePropertySheet.PropDesc("Inner Shadow Color", innerShadow.colorProperty())
    );
    // END REMOVE ME
}
 
Example 3
Source File: InnerShadowSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public static Node createIconContent() {
    Text sample = new Text("FX");
    sample.setFont(Font.font(Font.getDefault().getFamily(), FontWeight.BOLD,80));
    sample.setStyle("-fx-font-size: 80px;");
    sample.setFill(Color.web("#aaaaaa"));
    final InnerShadow innerShadow = new InnerShadow();
    innerShadow.setRadius(4);
    innerShadow.setOffsetX(1);
    innerShadow.setOffsetY(1);
    innerShadow.setColor(Color.web("#333333"));
    sample.setEffect(innerShadow);
    return sample;
}
 
Example 4
Source File: InnerShadowSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public static Node createIconContent() {
    Text sample = new Text("FX");
    sample.setFont(Font.font(Font.getDefault().getFamily(), FontWeight.BOLD,80));
    sample.setStyle("-fx-font-size: 80px;");
    sample.setFill(Color.web("#aaaaaa"));
    final InnerShadow innerShadow = new InnerShadow();
    innerShadow.setRadius(4);
    innerShadow.setOffsetX(1);
    innerShadow.setOffsetY(1);
    innerShadow.setColor(Color.web("#333333"));
    sample.setEffect(innerShadow);
    return sample;
}
 
Example 5
Source File: LcdSkin.java    From Medusa with Apache License 2.0 4 votes vote down vote up
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 6
Source File: LcdClockSkin.java    From Medusa with Apache License 2.0 4 votes vote down vote up
@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 7
Source File: PushButtonSkin.java    From Enzo with Apache License 2.0 4 votes vote down vote up
private void initGraphics() {
    frame = new Region();
    frame.getStyleClass().setAll("frame");

    frameInnerShadow0 = new InnerShadow();
    frameInnerShadow0.setOffsetX(0);
    frameInnerShadow0.setOffsetY(1);
    frameInnerShadow0.setRadius(0);
    frameInnerShadow0.setColor(Color.web("0x333333a6"));
    frameInnerShadow0.setBlurType(BlurType.TWO_PASS_BOX);
    frameInnerShadow1 = new InnerShadow();
    frameInnerShadow1.setOffsetX(0);
    frameInnerShadow1.setOffsetY(-1);
    frameInnerShadow1.setRadius(0);
    frameInnerShadow1.setColor(Color.web("0xeeeeeea6"));
    frameInnerShadow1.setBlurType(BlurType.TWO_PASS_BOX);
    frameInnerShadow1.setInput(frameInnerShadow0);
    frame.setEffect(frameInnerShadow1);

    deselected = new Region();
    deselected.getStyleClass().setAll("deselected");

    deselectedInnerShadow0 = new InnerShadow();
    deselectedInnerShadow0.setOffsetX(0);
    deselectedInnerShadow0.setOffsetY(-1);
    deselectedInnerShadow0.setRadius(0);
    deselectedInnerShadow0.setColor(Color.web("0x4b4e52a6"));
    deselectedInnerShadow0.setBlurType(BlurType.TWO_PASS_BOX);
    deselectedInnerShadow1 = new InnerShadow();
    deselectedInnerShadow1.setOffsetX(0);
    deselectedInnerShadow1.setOffsetY(1);
    deselectedInnerShadow1.setRadius(0);
    deselectedInnerShadow1.setColor(Color.web("0xeeeeeea6"));
    deselectedInnerShadow1.setBlurType(BlurType.TWO_PASS_BOX);
    deselectedInnerShadow1.setInput(deselectedInnerShadow0);
    deselectedDropShadow = new DropShadow();
    deselectedDropShadow.setOffsetX(0);
    deselectedDropShadow.setOffsetY(3);
    deselectedDropShadow.setRadius(3.0 / 128.0 * PREFERRED_WIDTH);
    deselectedDropShadow.setColor(Color.web("0x000000a6"));
    deselectedDropShadow.setBlurType(BlurType.TWO_PASS_BOX);
    deselectedDropShadow.setInput(deselectedInnerShadow1);
    deselected.setEffect(deselectedDropShadow);

    selected = new Region();
    selected.getStyleClass().setAll("selected");

    selectedInnerShadow0 = new InnerShadow();
    selectedInnerShadow0.setOffsetX(0);
    selectedInnerShadow0.setOffsetY(-1);
    selectedInnerShadow0.setRadius(0);
    selectedInnerShadow0.setColor(Color.web("0x4b4e52a6"));
    selectedInnerShadow0.setBlurType(BlurType.TWO_PASS_BOX);
    selectedInnerShadow1 = new InnerShadow();
    selectedInnerShadow1.setOffsetX(0);
    selectedInnerShadow1.setOffsetY(1);
    selectedInnerShadow1.setRadius(0);
    selectedInnerShadow1.setColor(Color.web("0xeeeeeea6"));
    selectedInnerShadow1.setBlurType(BlurType.TWO_PASS_BOX);
    selectedInnerShadow1.setInput(selectedInnerShadow0);
    selectedDropShadow = new DropShadow();
    selectedDropShadow.setOffsetX(0);
    selectedDropShadow.setOffsetY(0);
    selectedDropShadow.setRadius(2.0 / 128.0 * PREFERRED_WIDTH);
    selectedDropShadow.setColor(Color.web("0x000000a6"));
    selectedDropShadow.setBlurType(BlurType.TWO_PASS_BOX);
    selectedDropShadow.setInput(selectedInnerShadow1);
    selected.setEffect(selectedDropShadow);

    icon = new Region();
    icon.getStyleClass().setAll("icon");
    pane.getChildren().setAll(frame,
                              deselected,
                              selected,
                              icon);

    // Adjust visibility dependent on settings
    updateStatus();

    getChildren().setAll(pane);
    resize();
}
 
Example 8
Source File: LcdClockSkin.java    From Enzo with Apache License 2.0 4 votes vote down vote up
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();
}