Java Code Examples for javafx.scene.layout.Pane#setBackground()

The following examples show how to use javafx.scene.layout.Pane#setBackground() . 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: MorphingClockSkin.java    From Medusa with Apache License 2.0 7 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);
        }
    }

    canvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    ctx    = canvas.getGraphicsContext2D();
    ctx.setLineWidth(1);
    ctx.setStroke(null);

    pane = new Pane(canvas);
    pane.setBorder(new Border(new BorderStroke(clock.getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(clock.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
Example 2
Source File: TemplateClockSkin.java    From medusademo with Apache License 2.0 6 votes vote down vote up
private void initGraphics() {
    // Set initial size
    if (Double.compare(getSkinnable().getPrefWidth(), 0.0) <= 0 || Double.compare(getSkinnable().getPrefHeight(), 0.0) <= 0 ||
        Double.compare(getSkinnable().getWidth(), 0.0) <= 0 || Double.compare(getSkinnable().getHeight(), 0.0) <= 0) {
        if (getSkinnable().getPrefWidth() > 0 && getSkinnable().getPrefHeight() > 0) {
            getSkinnable().setPrefSize(getSkinnable().getPrefWidth(), getSkinnable().getPrefHeight());
        } else {
            getSkinnable().setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    pane = new Pane();
    pane.setBorder(new Border(new BorderStroke(getSkinnable().getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(getSkinnable().getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(getSkinnable().getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
Example 3
Source File: TextClockSkin.java    From Medusa with Apache License 2.0 6 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);
        }
    }

    timeText = new Text();
    timeText.setTextOrigin(VPos.CENTER);
    timeText.setFill(textColor);

    dateText = new Text();
    dateText.setTextOrigin(VPos.CENTER);
    dateText.setFill(dateColor);

    pane = new Pane(timeText, dateText);
    pane.setBorder(new Border(new BorderStroke(clock.getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(clock.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
Example 4
Source File: DigitalClockSkin.java    From Medusa with Apache License 2.0 6 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);
        }
    }

    canvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    ctx = canvas.getGraphicsContext2D();

    pane = new Pane(canvas);
    pane.setBorder(new Border(new BorderStroke(clock.getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(clock.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
Example 5
Source File: BT2111Generator.java    From testing-video with GNU General Public License v3.0 5 votes vote down vote up
protected Parent overlay(EncoderParameters params) {
    int b24 = b12 / 2, x = width - wc;
    Color fill = Color.BLACK;

    Pane grid = new Pane(
            text(0, 0, wc, b12, fill, font(height / 15), transferLabel()),
            text(0, b12, wc, b24, fill, font(height / 40), rangeLabel()),
            text(x, 0, wc, b12, fill, font(height / 18), "BT.2111"),
            text(x, b12, wc, b24, fill, font(height / 40),
                    "test.full.band"));

    grid.setBackground(EMPTY);
    return grid;
}
 
Example 6
Source File: TabsRepresentation.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void updateChanges()
{
    super.updateChanges();

    if (dirty_layout.checkAndClear())
    {
        final String style = JFXUtil.shadedStyle(model_widget.propBackgroundColor().getValue());

        final Background background = new Background(new BackgroundFill(JFXUtil.convert(model_widget.propBackgroundColor().getValue()), null, null));

        for (Tab tab : jfx_node.getTabs())
        {   // Set the font of the 'graphic' that's used to represent the tab
            final Label label = (Label) tab.getGraphic();
            label.setFont(tab_font);

            // Set colors
            tab.setStyle(style);

            final Pane content  = (Pane) tab.getContent();
            content.setBackground(background);
        }

        final Integer width = model_widget.propWidth().getValue();
        final Integer height = model_widget.propHeight().getValue();
        jfx_node.setPrefSize(width, height);
        jfx_node.setTabMinHeight(model_widget.propTabHeight().getValue());

        refreshHack();
    }
}
 
Example 7
Source File: LeaderBoardItem.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
private void initGraphics() {
    if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 ||
        Double.compare(getWidth(), 0.0) <= 0 || Double.compare(getHeight(), 0.0) <= 0) {
        if (getPrefWidth() > 0 && getPrefHeight() > 0) {
            setPrefSize(getPrefWidth(), getPrefHeight());
        } else {
            setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT); // 11x7
        }
    }

    state = State.CONSTANT;

    triangle = new Path();
    triangle.setStroke(null);
    triangle.setFill(state.color);
    triangle.setRotate(state.angle);

    nameText = new Text(getName());
    nameText.setTextOrigin(VPos.TOP);

    valueText = new Text();
    valueText.setTextOrigin(VPos.TOP);
    updateValueText();

    separator = new Line();

    pane = new Pane(triangle, nameText, valueText, separator);
    pane.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
Example 8
Source File: TileSkin.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
protected void initGraphics() {
    // Set initial size
    if (Double.compare(tile.getPrefWidth(), 0.0) <= 0 || Double.compare(tile.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(tile.getWidth(), 0.0) <= 0 || Double.compare(tile.getHeight(), 0.0) <= 0) {
        if (tile.getPrefWidth() > 0 && tile.getPrefHeight() > 0) {
            tile.setPrefSize(tile.getPrefWidth(), tile.getPrefHeight());
        } else {
            tile.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    shadow = new DropShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), 3, 0, 0, 0);

    backgroundImageView = new ImageView();
    backgroundImageView.setPreserveRatio(true);
    backgroundImageView.setMouseTransparent(true);
    if (null == tile.getBackgroundImage()) {
        enableNode(backgroundImageView, false);
    } else {
        backgroundImageView.setImage(tile.getBackgroundImage());
        enableNode(backgroundImageView, true);
    }

    notifyRegion = new NotifyRegion();
    enableNode(notifyRegion, false);

    infoRegion = new InfoRegion();
    infoRegion.setPickOnBounds(false);
    enableNode(infoRegion, false);

    lowerRightRegion = new LowerRightRegion();
    enableNode(lowerRightRegion, false);

    pane = new Pane(backgroundImageView, notifyRegion, infoRegion, lowerRightRegion);
    pane.getStyleClass().add("tile");
    pane.setBorder(new Border(new BorderStroke(tile.getBorderColor(), BorderStrokeStyle.SOLID, new CornerRadii(PREFERRED_WIDTH * 0.025), new BorderWidths(tile.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(tile.getBackgroundColor(), new CornerRadii(PREFERRED_WIDTH * 0.025), Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
Example 9
Source File: TileTextKpiSkin.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);
        }
    }

    barBackground = new Region();
    barBackground.setBackground(new Background(new BackgroundFill(gauge.getBarBackgroundColor(), new CornerRadii(0.0, 0.0, 0.025, 0.025, true), Insets.EMPTY)));

    barClip = new Rectangle();

    bar = new Rectangle();
    bar.setFill(gauge.getBarColor());
    bar.setStroke(null);
    bar.setClip(barClip);

    titleText = new Text();
    titleText.setFill(gauge.getTitleColor());
    Helper.enableNode(titleText, !gauge.getTitle().isEmpty());

    valueText = new Text();
    valueText.setFill(gauge.getValueColor());
    Helper.enableNode(valueText, gauge.isValueVisible());

    unitText = new Text(gauge.getUnit());
    unitText.setFill(gauge.getUnitColor());
    Helper.enableNode(unitText, !gauge.getUnit().isEmpty());

    percentageText = new Text();
    percentageText.setFill(gauge.getBarColor());

    percentageUnitText = new Text("%");
    percentageUnitText.setFill(gauge.getBarColor());

    maxValueRect = new Rectangle();
    maxValueRect.setFill(gauge.getThresholdColor());

    maxValueText = new Text(String.format(locale, "%." + gauge.getTickLabelDecimals() + "f", gauge.getMaxValue()));
    maxValueText.setFill(gauge.getBackgroundPaint());

    maxValueUnitText = new Text(gauge.getUnit());
    maxValueUnitText.setFill(gauge.getBackgroundPaint());

    pane = new Pane(barBackground, bar, titleText, valueText, unitText, percentageText, percentageUnitText, maxValueRect, maxValueText, maxValueUnitText);
    pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(PREFERRED_WIDTH * 0.025), new BorderWidths(gauge.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), new CornerRadii(PREFERRED_WIDTH * 0.025), Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
Example 10
Source File: PearClockSkin.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);
        }
    }

    sectionsAndAreasCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    sectionsAndAreasCtx    = sectionsAndAreasCanvas.getGraphicsContext2D();

    tickCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    tickCtx    = tickCanvas.getGraphicsContext2D();

    alarmPane = new Pane();

    hour  = new Path();
    hour.setFillRule(FillRule.EVEN_ODD);
    hour.setStroke(null);
    hour.getTransforms().setAll(hourRotate);

    minute = new Path();
    minute.setFillRule(FillRule.EVEN_ODD);
    minute.setStroke(null);
    minute.getTransforms().setAll(minuteRotate);

    second = new Path();
    second.setFillRule(FillRule.EVEN_ODD);
    second.setStroke(null);
    second.getTransforms().setAll(secondRotate);
    second.setVisible(clock.isSecondsVisible());
    second.setManaged(clock.isSecondsVisible());

    dropShadow = new DropShadow();
    dropShadow.setColor(Color.rgb(0, 0, 0, 0.25));
    dropShadow.setBlurType(BlurType.TWO_PASS_BOX);
    dropShadow.setRadius(0.015 * PREFERRED_WIDTH);
    dropShadow.setOffsetY(0.015 * PREFERRED_WIDTH);

    shadowGroupHour   = new Group(hour);
    shadowGroupMinute = new Group(minute);
    shadowGroupSecond = new Group(second);

    shadowGroupHour.setEffect(clock.getShadowsEnabled() ? dropShadow : null);
    shadowGroupMinute.setEffect(clock.getShadowsEnabled() ? dropShadow : null);
    shadowGroupSecond.setEffect(clock.getShadowsEnabled() ? dropShadow : null);

    title = new Text("");
    title.setVisible(clock.isTitleVisible());
    title.setManaged(clock.isTitleVisible());

    dateText = new Text("");
    dateText.setVisible(clock.isDateVisible());
    dateText.setManaged(clock.isDateVisible());

    dateNumber = new Text("");
    dateNumber.setVisible(clock.isDateVisible());
    dateNumber.setManaged(clock.isDateVisible());

    text = new Text("");
    text.setVisible(clock.isTextVisible());
    text.setManaged(clock.isTextVisible());

    pane = new Pane(sectionsAndAreasCanvas, tickCanvas, alarmPane, title, dateText, dateNumber, text, shadowGroupHour, shadowGroupMinute, shadowGroupSecond);
    pane.setBorder(new Border(new BorderStroke(clock.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(clock.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), new CornerRadii(1024), Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
Example 11
Source File: WhiteSkin.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);
        }
    }

    shadow     = new DropShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), 12, 0, 3, 3);
    textShadow = new DropShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), 4, 0, 2, 2);

    valueText = new Text(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), gauge.getCurrentValue()));
    valueText.setFill(Color.WHITE);
    valueText.setFont(Fonts.robotoBold(PREFERRED_WIDTH * 0.20625));
    valueText.setTextOrigin(VPos.CENTER);
    valueText.relocate(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.46875);
    valueText.setEffect(textShadow);
    Helper.enableNode(valueText, gauge.isValueVisible());

    unitText  = new Text(gauge.getUnit());
    unitText.setFill(Color.WHITE);
    unitText.setFont(Fonts.robotoBold(PREFERRED_WIDTH * 0.0875));
    unitText.setTextOrigin(VPos.CENTER);
    unitText.relocate(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.65625);
    unitText.setEffect(textShadow);
    Helper.enableNode(unitText, !gauge.getUnit().isEmpty());

    backgroundRing = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5,
                             PREFERRED_WIDTH * 0.43125, PREFERRED_HEIGHT * 0.43125,
                             0, 360);
    backgroundRing.setFill(null);
    backgroundRing.setStroke(Color.rgb(255, 255, 255, 0.9));
    backgroundRing.setStrokeLineCap(StrokeLineCap.BUTT);
    backgroundRing.setStrokeWidth(PREFERRED_WIDTH * 0.1375);
    backgroundRing.setEffect(shadow);

    barBackground = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5,
                            PREFERRED_WIDTH * 0.43125, PREFERRED_HEIGHT * 0.43125,
                            0, 360);
    barBackground.setFill(null);
    barBackground.setStroke(Color.rgb(255, 255, 255, 0.4));
    barBackground.setStrokeLineCap(StrokeLineCap.BUTT);
    barBackground.setStrokeWidth(PREFERRED_WIDTH * 0.1375);

    bar = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5,
                  PREFERRED_WIDTH * 0.43125, PREFERRED_HEIGHT * 0.43125,
                  90, -gauge.getAngleStep() * gauge.getValue());
    bar.setFill(null);
    bar.setStroke(Color.WHITE);
    bar.setStrokeWidth(PREFERRED_WIDTH * 0.1375);
    bar.setStrokeLineCap(StrokeLineCap.BUTT);

    pane = new Pane(valueText, unitText, backgroundRing, barBackground, bar);
    pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), new CornerRadii(1024), Insets.EMPTY)));
    pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(gauge.getBorderWidth()))));

    getChildren().setAll(pane);
}
 
Example 12
Source File: TileKpiSkin.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);
        }
    }

    barBackground = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.696, PREFERRED_WIDTH * 0.275, PREFERRED_WIDTH * 0.275, angleRange * 0.5 + 90, -angleRange);
    barBackground.setType(ArcType.OPEN);
    barBackground.setStroke(gauge.getBarColor());
    barBackground.setStrokeWidth(PREFERRED_WIDTH * 0.02819549 * 2);
    barBackground.setStrokeLineCap(StrokeLineCap.BUTT);
    barBackground.setFill(null);

    thresholdBar = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.696, PREFERRED_WIDTH * 0.275, PREFERRED_WIDTH * 0.275, -angleRange * 0.5 + 90, 0);
    thresholdBar.setType(ArcType.OPEN);
    thresholdBar.setStroke(gauge.getThresholdColor());
    thresholdBar.setStrokeWidth(PREFERRED_WIDTH * 0.02819549 * 2);
    thresholdBar.setStrokeLineCap(StrokeLineCap.BUTT);
    thresholdBar.setFill(null);
    enableNode(thresholdBar, !gauge.getSectionsVisible());

    sectionPane = new Pane();
    enableNode(sectionPane, gauge.getSectionsVisible());

    if (sectionsVisible) { drawSections(); }

    alertIcon = new Path();
    alertIcon.setFillRule(FillRule.EVEN_ODD);
    alertIcon.setFill(Color.YELLOW);
    alertIcon.setStroke(null);
    enableNode(alertIcon, gauge.isAlert());
    alertTooltip = new Tooltip(gauge.getAlertMessage());
    Tooltip.install(alertIcon, alertTooltip);

    needleRotate     = new Rotate((gauge.getValue() - oldValue - minValue) * angleStep);
    needleRectRotate = new Rotate((gauge.getValue() - oldValue - minValue) * angleStep);

    needleRect = new Rectangle();
    needleRect.setFill(gauge.getBackgroundPaint());
    needleRect.getTransforms().setAll(needleRectRotate);

    needle = new Path();
    needle.setFillRule(FillRule.EVEN_ODD);
    needle.getTransforms().setAll(needleRotate);
    needle.setFill(gauge.getNeedleColor());
    needle.setStrokeWidth(0);
    needle.setStroke(Color.TRANSPARENT);

    titleText = new Text(gauge.getTitle());
    titleText.setFill(gauge.getTitleColor());
    enableNode(titleText, !gauge.getTitle().isEmpty());

    valueText = new Text(String.format(locale, formatString, gauge.getCurrentValue()));
    valueText.setFill(gauge.getValueColor());
    enableNode(valueText, gauge.isValueVisible() && !gauge.isAlert());

    unitText = new Text(gauge.getUnit());
    unitText.setFill(gauge.getUnitColor());
    enableNode(unitText, gauge.isValueVisible() && !gauge.isAlert());

    minValueText = new Text(String.format(locale, "%." + gauge.getTickLabelDecimals() + "f", gauge.getMinValue()));
    minValueText.setFill(gauge.getTitleColor());

    maxValueText = new Text(String.format(locale, "%." + gauge.getTickLabelDecimals() + "f", gauge.getMaxValue()));
    maxValueText.setFill(gauge.getTitleColor());

    thresholdRect = new Rectangle();
    thresholdRect.setFill(sectionsVisible ? GRAY : gauge.getThresholdColor());
    enableNode(thresholdRect, gauge.isThresholdVisible());

    thresholdText = new Text(String.format(locale, "%." + gauge.getTickLabelDecimals() + "f", gauge.getThreshold()));
    thresholdText.setFill(sectionsVisible ? Color.TRANSPARENT : gauge.getBackgroundPaint());
    enableNode(thresholdText, gauge.isThresholdVisible());

    pane = new Pane(barBackground, thresholdBar, sectionPane, alertIcon, needleRect, needle, titleText, valueText, unitText, minValueText, maxValueText, thresholdRect, thresholdText);
    pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(PREFERRED_WIDTH * 0.025), new BorderWidths(gauge.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), new CornerRadii(PREFERRED_WIDTH * 0.025), Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
Example 13
Source File: RadarChart.java    From tilesfx with Apache License 2.0 4 votes vote down vote up
private void initGraphics() {
    stops = new ArrayList<>(16);
    for (Stop stop : getGradientStops()) {
        if (Double.compare(stop.getOffset(), 0.0) == 0) stops.add(new Stop(0, stop.getColor()));
        stops.add(new Stop(stop.getOffset() * 0.69924 + 0.285, stop.getColor()));
    }

    chartCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    chartCtx    = chartCanvas.getGraphicsContext2D();

    overlayCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    overlayCtx    = overlayCanvas.getGraphicsContext2D();

    unitText = new Text(getUnit());
    unitText.setTextAlignment(TextAlignment.CENTER);
    unitText.setTextOrigin(VPos.CENTER);
    unitText.setFont(Fonts.latoLight(0.045 * PREFERRED_WIDTH));

    legendStep = (getMaxValue() - getMinValue()) / 5d;
    dropShadow = new DropShadow(BlurType.TWO_PASS_BOX, Color.BLACK, 5, 0, 0, 0);

    minValueText = new Text(String.format(Locale.US, formatString, getMinValue()));
    minValueText.setTextAlignment(TextAlignment.CENTER);
    minValueText.setTextOrigin(VPos.CENTER);
    minValueText.setVisible(isLegendVisible());
    minValueText.setEffect(dropShadow);

    legend1Text = new Text(String.format(Locale.US, formatString, getMinValue() + legendStep));
    legend1Text.setTextAlignment(TextAlignment.CENTER);
    legend1Text.setTextOrigin(VPos.CENTER);
    legend1Text.setVisible(isLegendVisible());
    legend1Text.setEffect(dropShadow);

    legend2Text = new Text(String.format(Locale.US, formatString, getMinValue() + legendStep * 2));
    legend2Text.setTextAlignment(TextAlignment.CENTER);
    legend2Text.setTextOrigin(VPos.CENTER);
    legend2Text.setVisible(isLegendVisible());
    legend2Text.setEffect(dropShadow);

    legend3Text = new Text(String.format(Locale.US, formatString, getMinValue() + legendStep * 3));
    legend3Text.setTextAlignment(TextAlignment.CENTER);
    legend3Text.setTextOrigin(VPos.CENTER);
    legend3Text.setVisible(isLegendVisible());
    legend3Text.setEffect(dropShadow);

    legend4Text = new Text(String.format(Locale.US, formatString, getMinValue() + legendStep * 3));
    legend4Text.setTextAlignment(TextAlignment.CENTER);
    legend4Text.setTextOrigin(VPos.CENTER);
    legend4Text.setVisible(isLegendVisible());
    legend4Text.setEffect(dropShadow);

    maxValueText = new Text(String.format(Locale.US, formatString, getMaxValue()));
    maxValueText.setTextAlignment(TextAlignment.CENTER);
    maxValueText.setTextOrigin(VPos.CENTER);
    maxValueText.setVisible(isLegendVisible());
    maxValueText.setEffect(dropShadow);

    // Add all nodes
    pane = new Pane(chartCanvas, overlayCanvas, unitText, minValueText, legend1Text, legend2Text, legend3Text, legend4Text, maxValueText);
    pane.setBackground(new Background(new BackgroundFill(getChartBackgroundColor(), new CornerRadii(1024), Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
Example 14
Source File: BulletChartSkin.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(preferredWidth, preferredHeight);
        }
    }

    orientation = gauge.getOrientation();

    aspectRatio = preferredHeight / preferredWidth;

    titleText = new Text(gauge.getTitle());
    titleText.setTextOrigin(VPos.CENTER);
    Helper.enableNode(titleText, !gauge.getTitle().isEmpty());

    unitText = new Text(gauge.getUnit());
    unitText.setTextOrigin(VPos.CENTER);
    Helper.enableNode(unitText, !gauge.getUnit().isEmpty());

    tickMarkCanvas    = new Canvas(0.79699248 * preferredWidth, 0.08333333 * preferredHeight);
    tickMarksCtx      = tickMarkCanvas.getGraphicsContext2D();

    sectionsCanvas    = new Canvas(0.79699248 * preferredWidth, 0.5 * preferredHeight);
    sectionsCtx       = sectionsCanvas.getGraphicsContext2D();

    barRect           = new Rectangle();
    Tooltip.install(barRect, barTooltip);

    thresholdRect     = new Rectangle();
    Tooltip.install(thresholdRect, thresholdTooltip);

    pane = new Pane(titleText,
                    unitText,
                    tickMarkCanvas,
                    sectionsCanvas,
                    barRect,
                    thresholdRect);
    pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(gauge.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
Example 15
Source File: DashboardSkin.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);
        }
    }

    unitText = new Text(gauge.getUnit());
    unitText.setTextOrigin(VPos.CENTER);
    unitText.setFill(gauge.getUnitColor());
    Helper.enableNode(unitText, !gauge.getUnit().isEmpty());

    titleText = new Text(gauge.getTitle());
    titleText.setTextOrigin(VPos.CENTER);
    titleText.setFill(gauge.getTitleColor());
    Helper.enableNode(titleText, !gauge.getTitle().isEmpty());

    valueText = new Text(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), gauge.getCurrentValue()));
    valueText.setTextOrigin(VPos.CENTER);
    valueText.setFill(gauge.getValueColor());
    Helper.enableNode(valueText, gauge.isValueVisible());

    minValue = gauge.getMinValue();
    minText  = new Text(String.format(locale, otherFormatString, minValue));
    minText.setTextOrigin(VPos.CENTER);
    minText.setFill(gauge.getValueColor());

    maxText = new Text(String.format(locale, otherFormatString, gauge.getMaxValue()));
    maxText.setTextOrigin(VPos.CENTER);
    maxText.setFill(gauge.getValueColor());

    boolean tickLabelsVisible = gauge.getTickLabelsVisible();
    Helper.enableNode(minText, tickLabelsVisible);
    Helper.enableNode(maxText, tickLabelsVisible);

    innerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.3), 30.0, 0.0, 0.0, 10.0);

    barBackgroundStart          = new MoveTo(0, 0.675 * PREFERRED_HEIGHT);
    barBackgroundOuterArc       = new ArcTo(0.675 * PREFERRED_HEIGHT, 0.675 * PREFERRED_HEIGHT, 0, PREFERRED_WIDTH, 0.675 * PREFERRED_HEIGHT, true, true);
    barBackgroundLineToInnerArc = new LineTo(0.72222 * PREFERRED_WIDTH, 0.675 * PREFERRED_HEIGHT);
    barBackgroundInnerArc       = new ArcTo(0.3 * PREFERRED_HEIGHT, 0.3 * PREFERRED_HEIGHT, 0, 0.27778 * PREFERRED_WIDTH, 0.675 * PREFERRED_HEIGHT, false, false);

    barBackground = new Path();
    barBackground.setFillRule(FillRule.EVEN_ODD);
    barBackground.getElements().add(barBackgroundStart);
    barBackground.getElements().add(barBackgroundOuterArc);
    barBackground.getElements().add(barBackgroundLineToInnerArc);
    barBackground.getElements().add(barBackgroundInnerArc);
    barBackground.getElements().add(new ClosePath());
    barBackground.setFill(gauge.getBarBackgroundColor());
    barBackground.setStroke(gauge.getBorderPaint());
    barBackground.setEffect(gauge.isShadowsEnabled() ? innerShadow : null);

    dataBarStart          = new MoveTo(0, 0.675 * PREFERRED_HEIGHT);
    dataBarOuterArc       = new ArcTo(0.675 * PREFERRED_HEIGHT, 0.675 * PREFERRED_HEIGHT, 0, 0, 0, false, true);
    dataBarLineToInnerArc = new LineTo(0.27778 * PREFERRED_WIDTH, 0.675 * PREFERRED_HEIGHT);
    dataBarInnerArc       = new ArcTo(0.3 * PREFERRED_HEIGHT, 0.3 * PREFERRED_HEIGHT, 0, 0, 0, false, false);

    dataBar = new Path();
    dataBar.setFillRule(FillRule.EVEN_ODD);
    dataBar.getElements().add(dataBarStart);
    dataBar.getElements().add(dataBarOuterArc);
    dataBar.getElements().add(dataBarLineToInnerArc);
    dataBar.getElements().add(dataBarInnerArc);
    dataBar.getElements().add(new ClosePath());
    dataBar.setFill(gauge.getBarColor());
    dataBar.setStroke(gauge.getBorderPaint());
    dataBar.setEffect(gauge.isShadowsEnabled() ? innerShadow : null);

    threshold = new Line();
    threshold.setStrokeLineCap(StrokeLineCap.BUTT);
    Helper.enableNode(threshold, gauge.isThresholdVisible());

    thresholdText = new Text(String.format(locale, formatString, gauge.getThreshold()));
    Helper.enableNode(thresholdText, gauge.isThresholdVisible());

    pane = new Pane(unitText, titleText, valueText, minText, maxText, barBackground, dataBar, threshold, thresholdText);
    pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(gauge.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
Example 16
Source File: SlimClockSkin.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);
        }
    }

    ZonedDateTime time = clock.getTime();

    secondBackgroundCircle = new Circle(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.48);
    secondBackgroundCircle.setStrokeWidth(PREFERRED_WIDTH * 0.008);
    secondBackgroundCircle.setStrokeType(StrokeType.CENTERED);
    secondBackgroundCircle.setStrokeLineCap(StrokeLineCap.ROUND);
    secondBackgroundCircle.setFill(null);
    secondBackgroundCircle.setStroke(Helper.getTranslucentColorFrom(clock.getSecondColor(), 0.2));
    secondBackgroundCircle.setVisible(clock.isSecondsVisible());
    secondBackgroundCircle.setManaged(clock.isSecondsVisible());

    dateText = new Text(dateTextFormatter.format(time));
    dateText.setVisible(clock.isDayVisible());
    dateText.setManaged(clock.isDayVisible());

    dateNumbers = new Text(dateNumberFormatter.format(time));
    dateNumbers.setVisible(clock.isDateVisible());
    dateNumbers.setManaged(clock.isDateVisible());

    hour = new Text(HOUR_FORMATTER.format(time));
    hour.setFill(clock.getHourColor());

    minute = new Text(MINUTE_FORMATTER.format(time));
    minute.setFill(clock.getMinuteColor());

    secondArc = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.96, PREFERRED_WIDTH * 0.48, 90, (-6 * clock.getTime().getSecond()));
    secondArc.setStrokeWidth(PREFERRED_WIDTH * 0.008);
    secondArc.setStrokeType(StrokeType.CENTERED);
    secondArc.setStrokeLineCap(StrokeLineCap.ROUND);
    secondArc.setFill(null);
    secondArc.setStroke(clock.getSecondColor());
    secondArc.setVisible(clock.isSecondsVisible());
    secondArc.setManaged(clock.isSecondsVisible());

    pane = new Pane(secondBackgroundCircle, dateText, dateNumbers, hour, minute, secondArc);
    pane.setBorder(new Border(new BorderStroke(clock.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(clock.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), new CornerRadii(1024), Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
Example 17
Source File: Regulator.java    From regulators with Apache License 2.0 4 votes vote down vote up
private void initGraphics() {
    dropShadow  = new DropShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), PREFERRED_WIDTH * 0.016, 0.0, 0, PREFERRED_WIDTH * 0.028);
    highlight   = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(255, 255, 255, 0.2), PREFERRED_WIDTH * 0.008, 0.0, 0, PREFERRED_WIDTH * 0.008);
    innerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.2), PREFERRED_WIDTH * 0.008, 0.0, 0, -PREFERRED_WIDTH * 0.008);
    highlight.setInput(innerShadow);
    dropShadow.setInput(highlight);

    barArc = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.46, PREFERRED_HEIGHT * 0.46, BAR_START_ANGLE, 0);
    barArc.setType(ArcType.OPEN);
    barArc.setStrokeLineCap(StrokeLineCap.ROUND);
    barArc.setFill(null);
    barArc.setStroke(barColor.get());

    double center = PREFERRED_WIDTH * 0.5;
    ring = Shape.subtract(new Circle(center, center, PREFERRED_WIDTH * 0.42),
                          new Circle(center, center, PREFERRED_WIDTH * 0.3));
    ring.setFill(color.get());
    ring.setEffect(dropShadow);

    mainCircle = new Circle();
    mainCircle.setFill(color.get().darker().darker());

    text = new Text(String.format(Locale.US, formatString, getTargetValue()));
    text.setFill(Color.WHITE);
    text.setTextOrigin(VPos.CENTER);

    indicatorRotate = new Rotate(-ANGLE_RANGE *  0.5, center, center);

    indicatorGlow        = new DropShadow(BlurType.TWO_PASS_BOX, getIndicatorColor(), PREFERRED_WIDTH * 0.02, 0.0, 0, 0);
    indicatorInnerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.5), PREFERRED_WIDTH * 0.008, 0.0, 0, PREFERRED_WIDTH * 0.008);
    indicatorHighlight   = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(255, 255, 255, 0.35), PREFERRED_WIDTH * 0.008, 0.0, 0, -PREFERRED_WIDTH * 0.008);
    indicatorHighlight.setInput(indicatorInnerShadow);

    indicator = new Circle();
    indicator.setFill(color.get().darker());
    indicator.setStroke(color.get().darker().darker());
    indicator.setMouseTransparent(true);
    indicator.getTransforms().add(indicatorRotate);

    Group indicatorGroup = new Group(indicator);
    indicatorGroup.setEffect(indicatorHighlight);

    symbol = new Region();
    symbol.getStyleClass().setAll("symbol");
    symbol.setCacheHint(CacheHint.SPEED);

    icon = new FontIcon();
    icon.setTextOrigin(VPos.CENTER);

    iconPane = new StackPane(symbol, icon);

    pane = new Pane(barArc, ring, mainCircle, text, indicatorGroup, iconPane);
    pane.setPrefSize(PREFERRED_HEIGHT, PREFERRED_HEIGHT);
    pane.setBackground(new Background(new BackgroundFill(color.get().darker(), new CornerRadii(1024), Insets.EMPTY)));
    pane.setEffect(highlight);

    getChildren().setAll(pane);
}
 
Example 18
Source File: SimpleDigitalSkin.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);
        }
    }

    arcExtend = gauge.getArcExtend();

    backgroundCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    backgroundCtx    = backgroundCanvas.getGraphicsContext2D();

    barCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    barCtx    = barCanvas.getGraphicsContext2D();

    titleText = new Text(gauge.getTitle());
    titleText.setFill(gauge.getTitleColor());
    Helper.enableNode(titleText, !gauge.getTitle().isEmpty());

    valueBkgText = new Text();
    valueBkgText.setStroke(null);
    valueBkgText.setFill(Helper.getTranslucentColorFrom(valueColor, 0.1));
    Helper.enableNode(valueBkgText, gauge.isValueVisible());

    valueText = new Text();
    valueText.setStroke(null);
    valueText.setFill(valueColor);
    Helper.enableNode(valueText, gauge.isValueVisible());

    if (gauge.isGradientBarEnabled()) { setupGradient(); }

    pane = new Pane(backgroundCanvas, barCanvas, titleText, valueBkgText, valueText);
    pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(gauge.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), new CornerRadii(1024), Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
Example 19
Source File: FatClockSkin.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);
        }
    }

    sectionsAndAreasCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    sectionsAndAreasCtx    = sectionsAndAreasCanvas.getGraphicsContext2D();

    tickCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    tickCtx    = tickCanvas.getGraphicsContext2D();

    alarmPane = new Pane();

    hour  = new Path();
    hour.setFillRule(FillRule.EVEN_ODD);
    hour.setStroke(null);
    hour.setFill(clock.getHourColor());
    hour.getTransforms().setAll(hourRotate);

    minute = new Path();
    minute.setFillRule(FillRule.EVEN_ODD);
    minute.setStroke(null);
    minute.setFill(clock.getMinuteColor());
    minute.getTransforms().setAll(minuteRotate);

    dropShadow = new DropShadow();
    dropShadow.setColor(Color.rgb(0, 0, 0, 0.25));
    dropShadow.setBlurType(BlurType.TWO_PASS_BOX);
    dropShadow.setRadius(0.015 * PREFERRED_WIDTH);
    dropShadow.setOffsetY(0.015 * PREFERRED_WIDTH);

    shadowGroup = new Group(hour, minute);
    shadowGroup.setEffect(clock.getShadowsEnabled() ? dropShadow : null);

    title = new Text("");
    title.setVisible(clock.isTitleVisible());
    title.setManaged(clock.isTitleVisible());

    dateText = new Text("");
    dateText.setVisible(clock.isDateVisible());
    dateText.setManaged(clock.isDateVisible());

    text = new Text("");
    text.setVisible(clock.isTextVisible());
    text.setManaged(clock.isTextVisible());

    pane = new Pane(sectionsAndAreasCanvas, tickCanvas, alarmPane, title, dateText, text, shadowGroup);
    pane.setBorder(new Border(new BorderStroke(clock.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(clock.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), new CornerRadii(1024), Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
Example 20
Source File: TileClockSkin.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);
        }
    }

    minuteTickMarks = new Path();
    minuteTickMarks.setFillRule(FillRule.EVEN_ODD);
    minuteTickMarks.setFill(null);
    minuteTickMarks.setStroke(clock.getMinuteColor());
    minuteTickMarks.setStrokeLineCap(StrokeLineCap.ROUND);

    hourTickMarks = new Path();
    hourTickMarks.setFillRule(FillRule.EVEN_ODD);
    hourTickMarks.setFill(null);
    hourTickMarks.setStroke(clock.getHourColor());
    hourTickMarks.setStrokeLineCap(StrokeLineCap.ROUND);

    hour = new Rectangle(3, 60);
    hour.setArcHeight(3);
    hour.setArcWidth(3);
    hour.setStroke(clock.getHourColor());
    hour.getTransforms().setAll(hourRotate);

    minute = new Rectangle(3, 96);
    minute.setArcHeight(3);
    minute.setArcWidth(3);
    minute.setStroke(clock.getMinuteColor());
    minute.getTransforms().setAll(minuteRotate);

    second = new Rectangle(1, 96);
    second.setArcHeight(1);
    second.setArcWidth(1);
    second.setStroke(clock.getSecondColor());
    second.getTransforms().setAll(secondRotate);
    second.setVisible(clock.isSecondsVisible());
    second.setManaged(clock.isSecondsVisible());

    knob = new Circle(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, 4.5);
    knob.setStroke(Color.web("#282a3280"));

    dropShadow = new DropShadow();
    dropShadow.setColor(Color.rgb(0, 0, 0, 0.25));
    dropShadow.setBlurType(BlurType.TWO_PASS_BOX);
    dropShadow.setRadius(0.015 * PREFERRED_WIDTH);
    dropShadow.setOffsetY(0.015 * PREFERRED_WIDTH);

    shadowGroupHour   = new Group(hour);
    shadowGroupMinute = new Group(minute);
    shadowGroupSecond = new Group(second, knob);

    shadowGroupHour.setEffect(clock.getShadowsEnabled() ? dropShadow : null);
    shadowGroupMinute.setEffect(clock.getShadowsEnabled() ? dropShadow : null);
    shadowGroupSecond.setEffect(clock.getShadowsEnabled() ? dropShadow : null);

    title = new Text("");
    title.setTextOrigin(VPos.TOP);
    Helper.enableNode(title, clock.isTitleVisible());

    amPmText = new Text(clock.getTime().get(ChronoField.AMPM_OF_DAY) == 0 ? "AM" : "PM");

    dateText = new Text("");
    Helper.enableNode(dateText, clock.isDateVisible());

    text = new Text("");
    Helper.enableNode(text, clock.isTextVisible());

    pane = new Pane(hourTickMarks, minuteTickMarks, title, amPmText, dateText, text, shadowGroupHour, shadowGroupMinute, shadowGroupSecond);
    pane.setBorder(new Border(new BorderStroke(clock.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(PREFERRED_WIDTH * 0.025), new BorderWidths(clock.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), new CornerRadii(PREFERRED_WIDTH * 0.025), Insets.EMPTY)));

    getChildren().setAll(pane);
}