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

The following examples show how to use javafx.scene.layout.Region#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: StaticProgressIndicatorSkin.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void rebuild() {
    // update indeterminate indicator
    final int segments = skin.indeterminateSegmentCount.get();
    opacities.clear();
    pathsG.getChildren().clear();
    final double step = 0.8 / (segments - 1);
    for (int i = 0; i < segments; i++) {
        Region region = new Region();
        region.setScaleShape(false);
        region.setCenterShape(false);
        region.getStyleClass().addAll("segment", "segment" + i);
        if (fillOverride instanceof Color) {
            Color c = (Color) fillOverride;
            region.setStyle("-fx-background-color: rgba(" + ((int) (255 * c.getRed())) + "," +
                    "" + ((int) (255 * c.getGreen())) + "," + ((int) (255 * c.getBlue())) + "," +
                    "" + c.getOpacity() + ");");
        } else {
            region.setStyle(null);
        }
        double opacity = Math.min(1, i * step);
        opacities.add(opacity);
        region.setOpacity(opacity);
        pathsG.getChildren().add(region);
    }
}
 
Example 2
Source File: LedSkin.java    From Enzo with Apache License 2.0 6 votes vote down vote up
private void initGraphics() {
    frame = new Region();
    frame.setOpacity(getSkinnable().isFrameVisible() ? 1 : 0);

    led = new Region();
    led.setStyle("-led-color: " + Util.colorToCss((Color) getSkinnable().getLedColor()) + ";");

    innerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), 8, 0d, 0d, 0d);

    glow = new DropShadow(BlurType.TWO_PASS_BOX, (Color) getSkinnable().getLedColor(), 20, 0d, 0d, 0d);
    glow.setInput(innerShadow);

    highlight = new Region();

    // Set the appropriate style classes
    changeStyle();

    // Add all nodes
    getChildren().setAll(frame, led, highlight);
}
 
Example 3
Source File: SquareMatrixSegmentSkin.java    From Enzo with Apache License 2.0 6 votes vote down vote up
protected void handleControlPropertyChanged(final String PROPERTY) {
    if ("RESIZE".equals(PROPERTY)) {
        resize();
    } else if ("PREF_SIZE".equals(PROPERTY)) {
        aspectRatio = 1.0;
    } else if ("COLOR".equals(PROPERTY)) {
        updateMatrixColor();
    } else if ("BACKGROUND".equals(PROPERTY)) {
        background.setOpacity(getSkinnable().isBackgroundVisible() ? 1 : 0);
    } else if ("HIGHLIGHTS".equals(PROPERTY)) {
        for (Region highlight : highlights) {
            highlight.setOpacity(getSkinnable().isHighlightsVisible() ? 1 : 0);
        }
    } else if ("CHARACTER".equals(PROPERTY)) {
        updateMatrix();
    } else if ("GLOW".equals(PROPERTY)) {
        updateMatrix();
    }
}
 
Example 4
Source File: MatrixSegmentSkin.java    From Enzo with Apache License 2.0 6 votes vote down vote up
protected void handleControlPropertyChanged(final String PROPERTY) {
    if ("RESIZE".equals(PROPERTY)) {
        resize();
    } else if ("PREF_SIZE".equals(PROPERTY)) {
        aspectRatio = getSkinnable().getPrefHeight() / getSkinnable().getPrefWidth();
    } else if ("COLOR".equals(PROPERTY)) {
        updateMatrixColor();
    } else if ("BACKGROUND".equals(PROPERTY)) {
        background.setOpacity(getSkinnable().isBackgroundVisible() ? 1 : 0);
    } else if ("HIGHLIGHTS".equals(PROPERTY)) {
        for (Region highlight : highlights) {
            highlight.setOpacity(getSkinnable().isHighlightsVisible() ? 1 : 0);
        }
    } else if ("CHARACTER".equals(PROPERTY)) {
        updateMatrix();
    } else if ("GLOW".equals(PROPERTY)) {
        updateMatrix();
    }
}
 
Example 5
Source File: LedSkin.java    From JFX8CustomControls with Apache License 2.0 6 votes vote down vote up
private void initGraphics() {
    frame = new Region();
    frame.getStyleClass().setAll("frame");
    frame.setOpacity(getSkinnable().isFrameVisible() ? 1 : 0);

    led = new Region();
    led.getStyleClass().setAll("main");
    led.setStyle("-led-color: " + (getSkinnable().getLedColor()).toString().replace("0x", "#") + ";");

    innerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), 8, 0d, 0d, 0d);

    glow = new DropShadow(BlurType.TWO_PASS_BOX, (Color) getSkinnable().getLedColor(), 20, 0d, 0d, 0d);
    glow.setInput(innerShadow);

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

    getChildren().addAll(frame, led, highlight);
}
 
Example 6
Source File: Led.java    From JFX8CustomControls with Apache License 2.0 6 votes vote down vote up
private void initGraphics() {
    frame = new Region();
    frame.getStyleClass().setAll("frame");
    frame.setOpacity(isFrameVisible() ? 1 : 0);

    led = new Region();
    led.getStyleClass().setAll("main");
    led.setStyle("-led-color: " + (getLedColor()).toString().replace("0x", "#") + ";");

    innerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), 8, 0d, 0d, 0d);

    glow = new DropShadow(BlurType.TWO_PASS_BOX, getLedColor(), 20, 0d, 0d, 0d);
    glow.setInput(innerShadow);

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

    // Add all nodes
    getChildren().addAll(frame, led, highlight);
}
 
Example 7
Source File: SlideCheckBoxSkin.java    From JFX8CustomControls with Apache License 2.0 5 votes vote down vote up
private void initGraphics() {
    markBox = new Region();
    markBox.getStyleClass().setAll("mark");
    markBox.setNodeOrientation(NodeOrientation.LEFT_TO_RIGHT);
    markBox.setTranslateX(-27);

    crossBox = new Region();
    crossBox.getStyleClass().setAll("cross");
    crossBox.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT);
    crossBox.setTranslateX(27);

    thumb = new Region();
    thumb.getStyleClass().setAll("thumb");
    thumb.setMinSize(48, 34);
    thumb.setPrefSize(48, 34);
    thumb.setMaxSize(48, 34);

    if (getSkinnable().isSelected()) {
        crossBox.setOpacity(0);
        thumb.setTranslateX(24);
    } else {
        markBox.setOpacity(0);
        thumb.setTranslateX(-24);
    }

    box.getStyleClass().setAll("box");
    box.getChildren().addAll(markBox, crossBox, thumb);
    updateChildren();
}
 
Example 8
Source File: SelectionStripSkin.java    From WorkbenchFX with Apache License 2.0 4 votes vote down vote up
/**
 * Constructor for all SkinBase instances.
 *
 * @param strip The strip for which this Skin should attach to.
 */
public SelectionStripSkin(SelectionStrip<T> strip) {
  super(strip);

  content = new HBox();
  content.setMinWidth(Region.USE_PREF_SIZE);
  content.setMaxWidth(Double.MAX_VALUE);
  content.setAlignment(Pos.CENTER_LEFT);

  leftBtn = new Region();
  leftBtn.getStyleClass().addAll("scroller", "left");
  leftBtn.setOpacity(0);
  leftBtn.setVisible(false);

  rightBtn = new Region();
  rightBtn.getStyleClass().addAll("scroller", "right");
  rightBtn.setOpacity(0);
  rightBtn.setVisible(false);

  leftFader = new Region();
  leftFader.setMouseTransparent(true);
  leftFader.getStyleClass().addAll("fader", "left");
  leftFader.setOpacity(0);

  rightFader = new Region();
  rightFader.setMouseTransparent(true);
  rightFader.getStyleClass().addAll("fader", "right");
  rightFader.setOpacity(0);

  getChildren().addAll(content, leftFader, rightFader, leftBtn, rightBtn);
  getChildren().forEach(child -> child.setManaged(false));

  Rectangle clip = new Rectangle();
  clip.widthProperty().bind(strip.widthProperty());
  clip.heightProperty().bind(strip.heightProperty());
  getSkinnable().setClip(clip);

  setupListeners();
  setupBindings();
  setupEventHandlers();

  strip.itemsProperty().addListener((Observable it) -> buildContent());
  buildContent();
}
 
Example 9
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();
}