Java Code Examples for javafx.scene.layout.Region#setEffect()

The following examples show how to use javafx.scene.layout.Region#setEffect() . 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: IconsListElementSkin.java    From phoenicis with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Updates grayscale of the miniature when the enabled state has been updated
 *
 * @param miniature The miniature
 */
private void updateEnabled(final Region miniature) {
    if (!getControl().isEnabled()) {
        final ColorAdjust grayScale = new ColorAdjust();
        grayScale.setSaturation(-1);

        miniature.setEffect(grayScale);
    } else {
        miniature.setEffect(null);
    }
}
 
Example 2
Source File: SignalTowerSkin.java    From Enzo with Apache License 2.0 5 votes vote down vote up
private void initGraphics() {
    green = new Region();
    green.getStyleClass().setAll("green");

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

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

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

    bodyDropShadow = new DropShadow(BlurType.TWO_PASS_BOX, Color.web("0x000000a6"), 0.0133333333 * PREFERRED_WIDTH, 1.0, 0d, 2d);

    bodyInnerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.web("0x000000a6"), 0.0133333333 * PREFERRED_WIDTH, 1.0, 1.4142135623730951, 1.4142135623730951);
    bodyInnerShadow.setInput(bodyDropShadow);

    body = new Region();
    body.getStyleClass().setAll("body");
    body.setEffect(bodyInnerShadow);

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

    pane = new Pane();
    pane.getChildren().setAll(green,
                              yellow,
                              red,
                              rack,
                              body,
                              roof);

    getChildren().setAll(pane);
    resize();
}
 
Example 3
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 4
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();
}