Java Code Examples for javafx.scene.shape.Arc#setStrokeLineCap()
The following examples show how to use
javafx.scene.shape.Arc#setStrokeLineCap() .
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: IndicatorSkin.java From Medusa with Apache License 2.0 | 6 votes |
private void drawSections() { if (sections.isEmpty()) return; sectionLayer.getChildren().clear(); double centerX = width * 0.5; double centerY = height * 0.85; double barRadius = height * 0.54210526; double barWidth = width * 0.28472222; List<Arc> sectionBars = new ArrayList<>(sections.size()); for (Section section : sections) { Arc sectionBar = new Arc(centerX, centerY, barRadius, barRadius, angleRange * 0.5 + 90 - (section.getStart() * angleStep), -((section.getStop() - section.getStart()) - minValue) * angleStep); sectionBar.setType(ArcType.OPEN); sectionBar.setStroke(section.getColor()); sectionBar.setStrokeWidth(barWidth); sectionBar.setStrokeLineCap(StrokeLineCap.BUTT); sectionBar.setFill(null); Tooltip sectionTooltip = new Tooltip(new StringBuilder(section.getText()).append("\n").append(String.format(Locale.US, "%.2f", section.getStart())).append(" - ").append(String.format(Locale.US, "%.2f", section.getStop())).toString()); sectionTooltip.setTextAlignment(TextAlignment.CENTER); Tooltip.install(sectionBar, sectionTooltip); sectionBars.add(sectionBar); } sectionLayer.getChildren().addAll(sectionBars); }
Example 2
Source File: CircularProgressIndicator.java From mars-sim with GNU General Public License v3.0 | 4 votes |
private void initGraphics() { double center = PREFERRED_WIDTH * 0.5; double radius = PREFERRED_WIDTH * 0.45; circle = new Circle(); circle.setCenterX(center); circle.setCenterY(center); circle.setRadius(radius); circle.getStyleClass().add("indicator"); circle.setStrokeLineCap(isRoundLineCap() ? StrokeLineCap.ROUND : StrokeLineCap.SQUARE); circle.setStrokeWidth(PREFERRED_WIDTH * 0.10526316); circle.setStrokeDashOffset(dashOffset.get()); circle.getStrokeDashArray().setAll(dashArray_0.getValue(), 200d); arc = new Arc(center, center, radius, radius, 90, -360.0 * getProgress()); arc.setStrokeLineCap(isRoundLineCap() ? StrokeLineCap.ROUND : StrokeLineCap.SQUARE); arc.setStrokeWidth(PREFERRED_WIDTH * 0.1); arc.getStyleClass().add("indicator"); indeterminatePane = new StackPane(circle); indeterminatePane.setVisible(false); progressPane = new Pane(arc); progressPane.setVisible(Double.compare(getProgress(), 0.0) != 0); getChildren().setAll(progressPane, indeterminatePane); // Setup timeline animation KeyValue kvDashOffset_0 = new KeyValue(dashOffset, 0, Interpolator.EASE_BOTH); KeyValue kvDashOffset_50 = new KeyValue(dashOffset, -32, Interpolator.EASE_BOTH); KeyValue kvDashOffset_100 = new KeyValue(dashOffset, -64, Interpolator.EASE_BOTH); KeyValue kvDashArray_0_0 = new KeyValue(dashArray_0, 5, Interpolator.EASE_BOTH); KeyValue kvDashArray_0_50 = new KeyValue(dashArray_0, 89, Interpolator.EASE_BOTH); KeyValue kvDashArray_0_100 = new KeyValue(dashArray_0, 89, Interpolator.EASE_BOTH); KeyValue kvRotate_0 = new KeyValue(circle.rotateProperty(), -10, Interpolator.LINEAR); KeyValue kvRotate_100 = new KeyValue(circle.rotateProperty(), 370, Interpolator.LINEAR); KeyFrame kf0 = new KeyFrame(Duration.ZERO, kvDashOffset_0, kvDashArray_0_0, kvRotate_0); KeyFrame kf1 = new KeyFrame(Duration.millis(1000), kvDashOffset_50, kvDashArray_0_50); KeyFrame kf2 = new KeyFrame(Duration.millis(1500), kvDashOffset_100, kvDashArray_0_100, kvRotate_100); timeline.setCycleCount(Animation.INDEFINITE); timeline.getKeyFrames().setAll(kf0, kf1, kf2); // Setup additional pane rotation indeterminatePaneRotation = new RotateTransition(); indeterminatePaneRotation.setNode(indeterminatePane); indeterminatePaneRotation.setFromAngle(0); indeterminatePaneRotation.setToAngle(-360); indeterminatePaneRotation.setInterpolator(Interpolator.LINEAR); indeterminatePaneRotation.setCycleCount(Timeline.INDEFINITE); indeterminatePaneRotation.setDuration(new Duration(4500)); }
Example 3
Source File: SlimSkin.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); } } barBackground = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.48590226, PREFERRED_HEIGHT * 0.48590226, 90, 360); barBackground.setType(ArcType.OPEN); barBackground.setStroke(gauge.getBarBackgroundColor()); barBackground.setStrokeWidth(PREFERRED_WIDTH * 0.02819549 * 2); barBackground.setStrokeLineCap(StrokeLineCap.ROUND); barBackground.setFill(null); bar = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.48590226, PREFERRED_HEIGHT * 0.48590226, 90, 0); bar.setType(ArcType.OPEN); bar.setStroke(gauge.getBarColor()); bar.setStrokeWidth(PREFERRED_WIDTH * 0.02819549 * 2); bar.setStrokeLineCap(StrokeLineCap.ROUND); bar.setFill(null); titleText = new Text(gauge.getTitle()); titleText.setFill(gauge.getTitleColor()); Helper.enableNode(titleText, !gauge.getTitle().isEmpty()); valueText = new Text(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), gauge.getCurrentValue())); valueText.setFill(gauge.getValueColor()); Helper.enableNode(valueText, gauge.isValueVisible()); unitText = new Text(gauge.getUnit()); unitText.setFill(gauge.getUnitColor()); Helper.enableNode(unitText, !gauge.getUnit().isEmpty()); pane = new Pane(barBackground, bar, titleText, valueText, unitText); 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 4
Source File: SimpleSectionSkin.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); } } sectionCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); sectionCtx = sectionCanvas.getGraphicsContext2D(); barBackground = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.4, PREFERRED_HEIGHT * 0.4, gauge.getStartAngle() + 90, -ANGLE_RANGE); barBackground.setType(ArcType.OPEN); barBackground.setStroke(gauge.getBarBackgroundColor()); barBackground.setStrokeWidth(PREFERRED_WIDTH * 0.125); barBackground.setStrokeLineCap(StrokeLineCap.BUTT); barBackground.setFill(null); bar = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.4, PREFERRED_HEIGHT * 0.4, gauge.getStartAngle() + 90, 0); bar.setType(ArcType.OPEN); bar.setStroke(gauge.getBarColor()); bar.setStrokeWidth(PREFERRED_WIDTH * 0.125); bar.setStrokeLineCap(StrokeLineCap.BUTT); bar.setFill(null); titleText = new Text(gauge.getTitle()); titleText.setFill(gauge.getTitleColor()); Helper.enableNode(titleText, !gauge.getTitle().isEmpty()); valueText = new Text(); valueText.setStroke(null); valueText.setFill(gauge.getValueColor()); Helper.enableNode(valueText, gauge.isValueVisible()); unitText = new Text(); unitText.setStroke(null); unitText.setFill(gauge.getUnitColor()); Helper.enableNode(unitText, gauge.isValueVisible() && !gauge.getUnit().isEmpty()); pane = new Pane(barBackground, sectionCanvas, titleText, valueText, unitText, bar); getChildren().setAll(pane); }
Example 5
Source File: ColorRegulator.java From regulators with Apache License 2.0 | 4 votes |
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); Stop[] stops = { new Stop(0.0, Color.rgb(255,255,0)), new Stop(0.125, Color.rgb(255,0,0)), new Stop(0.375, Color.rgb(255,0,255)), new Stop(0.5, Color.rgb(0,0,255)), new Stop(0.625, Color.rgb(0,255,255)), new Stop(0.875, Color.rgb(0,255,0)), new Stop(1.0, Color.rgb(255,255,0)) }; List<Stop> reorderedStops = reorderStops(stops); gradientLookup = new GradientLookup(stops); barGradient = new ConicalGradient(reorderedStops); 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(barGradient.getImagePattern(new Rectangle(0, 0, PREFERRED_WIDTH, PREFERRED_HEIGHT))); buttonOn = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.46, PREFERRED_HEIGHT * 0.46, -125, 34.75); buttonOn.setFill(null); buttonOn.setStroke(color.get()); buttonOn.setStrokeLineCap(StrokeLineCap.BUTT); buttonOn.setStrokeWidth(PREFERRED_WIDTH * 0.072); buttonOn.setEffect(dropShadow); buttonOff = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.46, PREFERRED_HEIGHT * 0.46, -89.75, 34.75); buttonOff.setFill(null); buttonOff.setStroke(color.get()); buttonOff.setStrokeLineCap(StrokeLineCap.BUTT); buttonOff.setStrokeWidth(PREFERRED_WIDTH * 0.072); buttonOff.setEffect(dropShadow); 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(highlight); mainCircle = new Circle(); mainCircle.setFill(color.get().darker().darker()); textOn = new Text("ON"); textOn.setFill(textColor.get()); textOn.setTextOrigin(VPos.CENTER); textOn.setMouseTransparent(true); textOn.setRotate(17); textOff = new Text("OFF"); textOff.setFill(textColor.get()); textOff.setTextOrigin(VPos.CENTER); textOff.setMouseTransparent(true); textOff.setRotate(-17); 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); innerRing = Shape.subtract(new Circle(center, center, PREFERRED_WIDTH * 0.24), new Circle(center, center, PREFERRED_WIDTH * 0.2)); innerRing.setFill(color.get()); currentColorCircle = new Circle(); currentColorCircle.setFill(targetColor.get()); currentColorCircle.setVisible(isOn()); pane = new Pane(barArc, ring, mainCircle, currentColorCircle, innerRing, indicatorGroup, buttonOn, textOn, buttonOff, textOff); 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 6
Source File: CircularProgressIndicator.java From mars-sim with GNU General Public License v3.0 | 4 votes |
private void initGraphics() { double center = PREFERRED_WIDTH * 0.5; double radius = PREFERRED_WIDTH * 0.45; circle = new Circle(); circle.setCenterX(center); circle.setCenterY(center); circle.setRadius(radius); circle.getStyleClass().add("indicator"); circle.setStrokeLineCap(isRoundLineCap() ? StrokeLineCap.ROUND : StrokeLineCap.SQUARE); circle.setStrokeWidth(PREFERRED_WIDTH * 0.10526316); circle.setStrokeDashOffset(dashOffset.get()); circle.getStrokeDashArray().setAll(dashArray_0.getValue(), 200d); arc = new Arc(center, center, radius, radius, 90, -360.0 * getProgress()); arc.setStrokeLineCap(isRoundLineCap() ? StrokeLineCap.ROUND : StrokeLineCap.SQUARE); arc.setStrokeWidth(PREFERRED_WIDTH * 0.1); arc.getStyleClass().add("indicator"); indeterminatePane = new StackPane(circle); indeterminatePane.setVisible(false); progressPane = new Pane(arc); progressPane.setVisible(Double.compare(getProgress(), 0.0) != 0); getChildren().setAll(progressPane, indeterminatePane); // Setup timeline animation KeyValue kvDashOffset_0 = new KeyValue(dashOffset, 0, Interpolator.EASE_BOTH); KeyValue kvDashOffset_50 = new KeyValue(dashOffset, -32, Interpolator.EASE_BOTH); KeyValue kvDashOffset_100 = new KeyValue(dashOffset, -64, Interpolator.EASE_BOTH); KeyValue kvDashArray_0_0 = new KeyValue(dashArray_0, 5, Interpolator.EASE_BOTH); KeyValue kvDashArray_0_50 = new KeyValue(dashArray_0, 89, Interpolator.EASE_BOTH); KeyValue kvDashArray_0_100 = new KeyValue(dashArray_0, 89, Interpolator.EASE_BOTH); KeyValue kvRotate_0 = new KeyValue(circle.rotateProperty(), -10, Interpolator.LINEAR); KeyValue kvRotate_100 = new KeyValue(circle.rotateProperty(), 370, Interpolator.LINEAR); KeyFrame kf0 = new KeyFrame(Duration.ZERO, kvDashOffset_0, kvDashArray_0_0, kvRotate_0); KeyFrame kf1 = new KeyFrame(Duration.millis(1000), kvDashOffset_50, kvDashArray_0_50); KeyFrame kf2 = new KeyFrame(Duration.millis(1500), kvDashOffset_100, kvDashArray_0_100, kvRotate_100); timeline.setCycleCount(Animation.INDEFINITE); timeline.getKeyFrames().setAll(kf0, kf1, kf2); // Setup additional pane rotation indeterminatePaneRotation = new RotateTransition(); indeterminatePaneRotation.setNode(indeterminatePane); indeterminatePaneRotation.setFromAngle(0); indeterminatePaneRotation.setToAngle(-360); indeterminatePaneRotation.setInterpolator(Interpolator.LINEAR); indeterminatePaneRotation.setCycleCount(Timeline.INDEFINITE); indeterminatePaneRotation.setDuration(new Duration(4500)); }
Example 7
Source File: IndicatorSkin.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); } } 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.getBarBackgroundColor()); barBackground.setStrokeWidth(PREFERRED_WIDTH * 0.02819549 * 2); barBackground.setStrokeLineCap(StrokeLineCap.BUTT); barBackground.setFill(null); sectionLayer = new Pane(); sectionLayer.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY))); bar = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.696, PREFERRED_WIDTH * 0.275, PREFERRED_WIDTH * 0.275, angleRange * 0.5 + 90, 0); bar.setType(ArcType.OPEN); bar.setStroke(gauge.getBarColor()); bar.setStrokeWidth(PREFERRED_WIDTH * 0.02819549 * 2); bar.setStrokeLineCap(StrokeLineCap.BUTT); bar.setFill(null); //bar.setMouseTransparent(sectionsAlwaysVisible ? true : false); bar.setVisible(!sectionsAlwaysVisible); needleRotate = new Rotate((gauge.getValue() - oldValue - minValue) * angleStep); needleMoveTo1 = new MoveTo(); needleCubicCurveTo2 = new CubicCurveTo(); needleCubicCurveTo3 = new CubicCurveTo(); needleCubicCurveTo4 = new CubicCurveTo(); needleCubicCurveTo5 = new CubicCurveTo(); needleCubicCurveTo6 = new CubicCurveTo(); needleCubicCurveTo7 = new CubicCurveTo(); needleClosePath8 = new ClosePath(); needle = new Path(needleMoveTo1, needleCubicCurveTo2, needleCubicCurveTo3, needleCubicCurveTo4, needleCubicCurveTo5, needleCubicCurveTo6, needleCubicCurveTo7, needleClosePath8); needle.setFillRule(FillRule.EVEN_ODD); needle.getTransforms().setAll(needleRotate); needle.setFill(gauge.getNeedleColor()); needle.setPickOnBounds(false); needle.setStrokeType(StrokeType.INSIDE); needle.setStrokeWidth(1); needle.setStroke(gauge.getBackgroundPaint()); needleTooltip = new Tooltip(String.format(locale, formatString, gauge.getValue())); needleTooltip.setTextAlignment(TextAlignment.CENTER); Tooltip.install(needle, needleTooltip); minValueText = new Text(String.format(locale, "%." + gauge.getTickLabelDecimals() + "f", gauge.getMinValue())); minValueText.setFill(gauge.getTitleColor()); Helper.enableNode(minValueText, gauge.getTickLabelsVisible()); maxValueText = new Text(String.format(locale, "%." + gauge.getTickLabelDecimals() + "f", gauge.getMaxValue())); maxValueText.setFill(gauge.getTitleColor()); Helper.enableNode(maxValueText, gauge.getTickLabelsVisible()); titleText = new Text(gauge.getTitle()); titleText.setFill(gauge.getTitleColor()); Helper.enableNode(titleText, !gauge.getTitle().isEmpty()); if (!sections.isEmpty() && sectionsVisible && !sectionsAlwaysVisible) { barTooltip = new Tooltip(); barTooltip.setTextAlignment(TextAlignment.CENTER); Tooltip.install(bar, barTooltip); } pane = new Pane(barBackground, sectionLayer, bar, needle, minValueText, maxValueText, titleText); 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 8
Source File: TinySkin.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); } } barBackground = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.696, PREFERRED_WIDTH * 0.275, PREFERRED_WIDTH * 0.275, ANGLE_RANGE * 0.5 + 90, -ANGLE_RANGE); barBackground.setType(ArcType.OPEN); barBackground.setStroke(gauge.getBarBackgroundColor()); barBackground.setStrokeWidth(PREFERRED_WIDTH * 0.02819549 * 2); barBackground.setStrokeLineCap(StrokeLineCap.BUTT); barBackground.setFill(null); sectionCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); sectionCtx = sectionCanvas.getGraphicsContext2D(); needleRotate = new Rotate((gauge.getValue() - oldValue - minValue) * angleStep); needleMoveTo1 = new MoveTo(); needleCubicCurveTo2 = new CubicCurveTo(); needleCubicCurveTo3 = new CubicCurveTo(); needleCubicCurveTo4 = new CubicCurveTo(); needleCubicCurveTo5 = new CubicCurveTo(); needleClosePath6 = new ClosePath(); needleMoveTo7 = new MoveTo(); needleCubicCurveTo8 = new CubicCurveTo(); needleCubicCurveTo9 = new CubicCurveTo(); needleCubicCurveTo10 = new CubicCurveTo(); needleCubicCurveTo11 = new CubicCurveTo(); needleClosePath12 = new ClosePath(); needle = new Path(needleMoveTo1, needleCubicCurveTo2, needleCubicCurveTo3, needleCubicCurveTo4, needleCubicCurveTo5, needleClosePath6, needleMoveTo7, needleCubicCurveTo8, needleCubicCurveTo9, needleCubicCurveTo10, needleCubicCurveTo11, needleClosePath12); needle.setFillRule(FillRule.EVEN_ODD); needle.getTransforms().setAll(needleRotate); needle.setFill(gauge.getNeedleColor()); needle.setStrokeType(StrokeType.INSIDE); needle.setStrokeWidth(1); needle.setStroke(gauge.getBackgroundPaint()); needleTooltip = new Tooltip(String.format(locale, formatString, gauge.getValue())); needleTooltip.setTextAlignment(TextAlignment.CENTER); Tooltip.install(needle, needleTooltip); pane = new Pane(barBackground, sectionCanvas, needle); 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 9
Source File: KpiSkin.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); } } 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); needleRotate = new Rotate((gauge.getValue() - oldValue - minValue) * angleStep); 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()); Helper.enableNode(titleText, !gauge.getTitle().isEmpty()); valueText = new Text(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), gauge.getCurrentValue())); valueText.setFill(gauge.getValueColor()); Helper.enableNode(valueText, gauge.isValueVisible()); 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()); thresholdText = new Text(String.format(locale, "%." + gauge.getTickLabelDecimals() + "f", gauge.getThreshold())); thresholdText.setFill(gauge.getTitleColor()); Helper.enableNode(thresholdText, Double.compare(gauge.getThreshold(), gauge.getMinValue()) != 0 && Double.compare(gauge.getThreshold(), gauge.getMaxValue()) != 0); pane = new Pane(barBackground, thresholdBar, needle, titleText, valueText, minValueText, maxValueText, 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 10
Source File: FeedbackRegulator.java From regulators with Apache License 2.0 | 4 votes |
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); Stop[] stops = { new Stop(0.0, Color.rgb(135, 255, 190)), new Stop(0.125, Color.rgb(254, 190, 106)), new Stop(0.389, Color.rgb(252, 84, 68)), new Stop(0.611, Color.rgb(99, 195, 255)), new Stop(1.0, Color.rgb(125, 255, 190)) }; barGradient = new ConicalGradient(stops); 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(barGradient.getImagePattern(new Rectangle(0, 0, PREFERRED_WIDTH, PREFERRED_HEIGHT))); overlayBarArc = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.46, PREFERRED_HEIGHT * 0.46, BAR_START_ANGLE, 0); overlayBarArc.setType(ArcType.OPEN); overlayBarArc.setStrokeLineCap(StrokeLineCap.ROUND); overlayBarArc.setFill(null); overlayBarArc.setStroke(Color.rgb(0, 0, 0, 0.3)); overlayBarArc.setVisible((int) targetValue.get() != (int) currentValue.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, currentValue.get())); text.setFill(textColor.get()); text.setTextOrigin(VPos.CENTER); targetText = new Text(String.format(Locale.US, formatString, targetValue.get())); targetText.setFill(textColor.get().darker()); targetText.setTextOrigin(VPos.CENTER); targetText.setVisible((int) targetValue.get() != (int) currentValue.get()); 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, overlayBarArc, ring, mainCircle, text, targetText, 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 11
Source File: GaugeTileSkin.java From OEE-Designer with MIT License | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); if (tile.isAutoScale()) tile.calcAutoScale(); oldValue = tile.getValue(); sectionMap = new HashMap<>(sections.size()); for(Section section : sections) { sectionMap.put(section, new Arc()); } barColor = tile.getBarColor(); thresholdColor = tile.getThresholdColor(); 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(barColor); 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(tile.getThresholdColor()); thresholdBar.setStrokeWidth(PREFERRED_WIDTH * 0.02819549 * 2); thresholdBar.setStrokeLineCap(StrokeLineCap.BUTT); thresholdBar.setFill(null); Helper.enableNode(thresholdBar, !tile.getSectionsVisible()); sectionPane = new Pane(); Helper.enableNode(sectionPane, tile.getSectionsVisible()); if (sectionsVisible) { drawSections(); } alertIcon = new Path(); alertIcon.setFillRule(FillRule.EVEN_ODD); alertIcon.setFill(Color.YELLOW); alertIcon.setStroke(null); Helper.enableNode(alertIcon, tile.isAlert()); alertTooltip = new Tooltip(tile.getAlertMessage()); Tooltip.install(alertIcon, alertTooltip); needleRotate = new Rotate((tile.getValue() - oldValue - minValue) * angleStep); needleRectRotate = new Rotate((tile.getValue() - oldValue - minValue) * angleStep); needleRect = new Rectangle(); needleRect.setFill(tile.getBackgroundColor()); needleRect.getTransforms().setAll(needleRectRotate); needle = new Path(); needle.setFillRule(FillRule.EVEN_ODD); needle.getTransforms().setAll(needleRotate); needle.setFill(tile.getNeedleColor()); needle.setStrokeWidth(0); needle.setStroke(Color.TRANSPARENT); titleText = new Text(tile.getTitle()); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); valueText = new Text(String.format(locale, formatString, tile.getCurrentValue())); valueText.setFill(tile.getValueColor()); valueText.setTextOrigin(VPos.BASELINE); Helper.enableNode(valueText, tile.isValueVisible() && !tile.isAlert()); unitText = new Text(tile.getUnit()); unitText.setFill(tile.getUnitColor()); unitText.setTextOrigin(VPos.BASELINE); Helper.enableNode(unitText, tile.isValueVisible() && !tile.isAlert()); valueUnitFlow = new TextFlow(valueText, unitText); valueUnitFlow.setTextAlignment(TextAlignment.CENTER); minValueText = new Text(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", tile.getMinValue())); minValueText.setFill(tile.getTitleColor()); maxValueText = new Text(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", tile.getMaxValue())); maxValueText.setFill(tile.getTitleColor()); thresholdRect = new Rectangle(); thresholdRect.setFill(sectionsVisible ? Color.TRANSPARENT : tile.getValue() > tile.getThreshold() ? tile.getThresholdColor() : Tile.GRAY); Helper.enableNode(thresholdRect, tile.isThresholdVisible()); thresholdText = new Text(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", tile.getThreshold())); thresholdText.setFill(sectionsVisible ? Color.TRANSPARENT : Tile.GRAY); Helper.enableNode(thresholdText, tile.isThresholdVisible()); getPane().getChildren().addAll(barBackground, thresholdBar, sectionPane, alertIcon, needleRect, needle, titleText, valueUnitFlow, minValueText, maxValueText, thresholdRect, thresholdText); }
Example 12
Source File: WhiteSkin.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); } } 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 13
Source File: TileKpiSkin.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); } } 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 14
Source File: Slim1Skin.java From medusademo 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); } } barBackground = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.48590226, PREFERRED_HEIGHT * 0.48590226, 90, 360); barBackground.setType(ArcType.OPEN); barBackground.setStroke(gauge.getBarBackgroundColor()); barBackground.setStrokeWidth(PREFERRED_WIDTH * 0.02819549 * 2); barBackground.setStrokeLineCap(StrokeLineCap.ROUND); barBackground.setFill(null); bar = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.48590226, PREFERRED_HEIGHT * 0.48590226, 90, 0); bar.setType(ArcType.OPEN); bar.setStroke(gauge.getBarColor()); bar.setStrokeWidth(PREFERRED_WIDTH * 0.02819549 * 2); bar.setStrokeLineCap(StrokeLineCap.ROUND); bar.setFill(null); titleText = new Text(gauge.getTitle()); titleText.setFill(gauge.getTitleColor()); Helper.enableNode(titleText, !gauge.getTitle().isEmpty()); valueText = new Text(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), gauge.getCurrentValue())); valueText.setFill(gauge.getValueColor()); Helper.enableNode(valueText, gauge.isValueVisible()); unitText = new Text(gauge.getUnit()); unitText.setFill(gauge.getUnitColor()); Helper.enableNode(unitText, !gauge.getUnit().isEmpty()); pane = new Pane(barBackground, bar, titleText, valueText, unitText); 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 15
Source File: CountdownTimerTileSkin.java From tilesfx with Apache License 2.0 | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); duration = tile.getTimePeriod(); minValue = 0; maxValue = duration.getSeconds(); range = duration.getSeconds(); angleStep = ANGLE_RANGE / range; locale = tile.getLocale(); titleText = new Text(); titleText.setFill(tile.getTitleColor()); enableNode(titleText, !tile.getTitle().isEmpty()); text = new Text(tile.getText()); text.setFill(tile.getTextColor()); enableNode(text, tile.isTextVisible()); barBackground = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.468, PREFERRED_HEIGHT * 0.468, 90, 360); barBackground.setType(ArcType.OPEN); barBackground.setStroke(tile.getBarBackgroundColor()); barBackground.setStrokeWidth(PREFERRED_WIDTH * 0.1); barBackground.setStrokeLineCap(StrokeLineCap.BUTT); barBackground.setFill(null); bar = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.468, PREFERRED_HEIGHT * 0.468, 90, 0); bar.setType(ArcType.OPEN); bar.setStroke(tile.getBarColor()); bar.setStrokeWidth(PREFERRED_WIDTH * 0.1); bar.setStrokeLineCap(StrokeLineCap.BUTT); bar.setFill(null); separator = new Line(PREFERRED_WIDTH * 0.5, 1, PREFERRED_WIDTH * 0.5, 0.16667 * PREFERRED_HEIGHT); separator.setStroke(tile.getBackgroundColor()); separator.setFill(Color.TRANSPARENT); durationText = new Text(); durationText.setFont(Fonts.latoRegular(PREFERRED_WIDTH * 0.27333)); durationText.setFill(tile.getValueColor()); durationText.setTextOrigin(VPos.CENTER); durationFlow = new TextFlow(durationText); durationFlow.setTextAlignment(TextAlignment.CENTER); timeText = new Text(DTF.format(LocalTime.now().plus(tile.getTimePeriod().getSeconds(), ChronoUnit.SECONDS))); timeText.setFont(Fonts.latoRegular(PREFERRED_WIDTH * 0.27333)); timeText.setFill(tile.getValueColor()); timeText.setTextOrigin(VPos.CENTER); enableNode(timeText, tile.isValueVisible()); timeFlow = new TextFlow(timeText); timeFlow.setTextAlignment(TextAlignment.CENTER); runningListener = (o, ov, nv) -> { if (nv) { timeText.setText(DTF.format(LocalTime.now().plus(duration.getSeconds(), ChronoUnit.SECONDS))); } }; timeListener = e -> { if (TimeEventType.SECOND == e.TYPE) { updateBar(); } }; getPane().getChildren().addAll(barBackground, bar, separator, titleText, text, durationFlow, timeFlow); }
Example 16
Source File: BarGaugeTileSkin.java From tilesfx with Apache License 2.0 | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); if (tile.isAutoScale()) tile.calcAutoScale(); gradientLookup = new GradientLookup(tile.getGradientStops()); noOfGradientStops = tile.getGradientStops().size(); sectionsVisible = tile.getSectionsVisible(); colorGradientEnabled = tile.isStrokeWithGradient(); titleText = new Text(tile.getTitle()); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); valueText = new Text(String.format(locale, formatString, tile.getValue())); valueText.setFill(tile.getValueColor()); Helper.enableNode(valueText, tile.isValueVisible()); upperUnitText = new Text(""); upperUnitText.setFill(tile.getUnitColor()); Helper.enableNode(upperUnitText, !tile.getUnit().isEmpty()); fractionLine = new Line(); unitText = new Text(tile.getUnit()); unitText.setFill(tile.getUnitColor()); Helper.enableNode(unitText, !tile.getUnit().isEmpty()); unitFlow = new VBox(upperUnitText, unitText); unitFlow.setAlignment(Pos.CENTER_RIGHT); valueUnitFlow = new HBox(valueText, unitFlow); valueUnitFlow.setAlignment(Pos.CENTER); valueUnitFlow.setMouseTransparent(true); text = new Text(tile.getText()); text.setTextOrigin(VPos.TOP); text.setFill(tile.getTextColor()); barBackground = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.4, PREFERRED_HEIGHT * 0.4, 0, ANGLE_RANGE); barBackground.setType(ArcType.OPEN); barBackground.setStroke(tile.getBarBackgroundColor()); barBackground.setStrokeWidth(PREFERRED_WIDTH * 0.125); barBackground.setStrokeLineCap(StrokeLineCap.BUTT); barBackground.setFill(null); bar = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.4, PREFERRED_HEIGHT * 0.4, 270, 0); bar.setType(ArcType.OPEN); bar.setStroke(tile.getBarColor()); bar.setStrokeWidth(PREFERRED_WIDTH * 0.125); bar.setStrokeLineCap(StrokeLineCap.BUTT); bar.setFill(null); lowerThreshold = new Line(); lowerThreshold.setStroke(tile.getLowerThresholdColor()); lowerThreshold.setStrokeLineCap(StrokeLineCap.BUTT); Helper.enableNode(lowerThreshold, tile.isLowerThresholdVisible()); lowerThresholdText = new Text(String.format(locale, formatString, tile.getLowerThreshold())); Helper.enableNode(lowerThresholdText, tile.isLowerThresholdVisible()); threshold = new Line(); threshold.setStroke(tile.getThresholdColor()); threshold.setStrokeLineCap(StrokeLineCap.BUTT); Helper.enableNode(threshold, tile.isThresholdVisible()); thresholdText = new Text(String.format(locale, formatString, tile.getThreshold())); Helper.enableNode(thresholdText, tile.isThresholdVisible()); minValueText = new Text(); maxValueText = new Text(); getPane().getChildren().addAll(barBackground, bar, lowerThreshold, lowerThresholdText, threshold, thresholdText, minValueText, maxValueText, titleText, valueUnitFlow, fractionLine, text); }
Example 17
Source File: TimerControlTileSkin.java From tilesfx with Apache License 2.0 | 4 votes |
private void drawTimeSections() { if (sectionMap.isEmpty()) return; ZonedDateTime time = tile.getTime(); DayOfWeek day = time.getDayOfWeek(); boolean isAM = time.get(ChronoField.AMPM_OF_DAY) == 0; double offset = 90; double angleStep = 360.0 / 60.0; boolean highlightSections = tile.isHighlightSections(); for (TimeSection section : sectionMap.keySet()) { LocalTime start = section.getStart(); LocalTime stop = section.getStop(); boolean isStartAM = start.get(ChronoField.AMPM_OF_DAY) == 0; boolean isStopAM = stop.get(ChronoField.AMPM_OF_DAY) == 0; boolean draw = isAM ? (isStartAM || isStopAM) : (!isStartAM || !isStopAM); if (!section.getDays().contains(day)) { draw = false; } if (!section.isActive()) { draw = false; } if (draw) { double sectionStartAngle = (start.getHour() % 12 * 5.0 + start.getMinute() / 12.0 + start.getSecond() / 300.0) * angleStep + 180; double sectionAngleExtend = ((stop.getHour() - start.getHour()) % 12 * 5.0 + (stop.getMinute() - start.getMinute()) / 12.0 + (stop.getSecond() - start.getSecond()) / 300.0) * angleStep; if (start.getHour() > stop.getHour()) { sectionAngleExtend = (360.0 - Math.abs(sectionAngleExtend)); } Arc arc = sectionMap.get(section); arc.setCenterX(clockSize * 0.5); arc.setCenterY(clockSize * 0.5); arc.setRadiusX(clockSize * 0.45); arc.setRadiusY(clockSize * 0.45); arc.setStartAngle(-(offset + sectionStartAngle)); arc.setLength(-sectionAngleExtend); arc.setType(ArcType.OPEN); arc.setStrokeWidth(clockSize * 0.04); arc.setStrokeLineCap(StrokeLineCap.BUTT); arc.setFill(null); if (highlightSections) { arc.setStroke(section.contains(time.toLocalTime()) ? section.getHighlightColor() : section.getColor()); } else { arc.setStroke(section.getColor()); } } } }
Example 18
Source File: BarSkin.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); } } Color barColor = gauge.getBarColor(); gauge.setGradientBarStops(new Stop(0.0, barColor), new Stop(0.01, barColor), new Stop(0.75, barColor.deriveColor(-10, 1, 1, 1)), new Stop(1.0, barColor.deriveColor(-20, 1, 1, 1))); shadow = new DropShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.45), 0.01 * PREFERRED_WIDTH, 0, 0.01 * PREFERRED_WIDTH, 0); circle = new Circle(); circle.setFill(null); arc = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.96, PREFERRED_WIDTH * 0.48, 90, 0); arc.setStrokeWidth(PREFERRED_WIDTH * 0.008); arc.setStrokeType(StrokeType.CENTERED); arc.setStrokeLineCap(StrokeLineCap.ROUND); arc.setFill(null); fakeDot = new Circle(); fakeDot.setStroke(null); dot = new Circle(); dot.setStroke(null); dot.setVisible(false); dot.setEffect(shadow); titleText = new Text(gauge.getTitle()); titleText.setFont(Fonts.robotoLight(PREFERRED_WIDTH * 0.5)); titleText.setFill(gauge.getTitleColor()); Helper.enableNode(titleText, !gauge.getTitle().isEmpty()); valueText = new Text(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), gauge.getCurrentValue())); valueText.setFont(Fonts.robotoRegular(PREFERRED_WIDTH * 0.27333)); valueText.setFill(gauge.getValueColor()); Helper.enableNode(valueText, gauge.isValueVisible()); unitText = new Text(gauge.getUnit()); unitText.setFont(Fonts.robotoLight(PREFERRED_WIDTH * 0.08)); unitText.setFill(gauge.getUnitColor()); Helper.enableNode(unitText, !gauge.getUnit().isEmpty()); pane = new Pane(circle, arc, fakeDot, dot, titleText, valueText, unitText); getChildren().setAll(pane); }
Example 19
Source File: GaugeTileSkin.java From tilesfx with Apache License 2.0 | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); if (tile.isAutoScale()) tile.calcAutoScale(); oldValue = tile.getValue(); sectionMap = new HashMap<>(sections.size()); for(Section section : sections) { sectionMap.put(section, new Arc()); } barColor = tile.getBarColor(); thresholdColor = tile.getThresholdColor(); 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(barColor); 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(tile.getThresholdColor()); thresholdBar.setStrokeWidth(PREFERRED_WIDTH * 0.02819549 * 2); thresholdBar.setStrokeLineCap(StrokeLineCap.BUTT); thresholdBar.setFill(null); Helper.enableNode(thresholdBar, !tile.getSectionsVisible()); sectionPane = new Pane(); Helper.enableNode(sectionPane, tile.getSectionsVisible()); if (sectionsVisible) { drawSections(); } alertIcon = new Path(); alertIcon.setFillRule(FillRule.EVEN_ODD); alertIcon.setFill(Color.YELLOW); alertIcon.setStroke(null); Helper.enableNode(alertIcon, tile.isAlert()); alertTooltip = new Tooltip(tile.getAlertMessage()); Tooltip.install(alertIcon, alertTooltip); needleRotate = new Rotate((tile.getValue() - oldValue - minValue) * angleStep); needleRectRotate = new Rotate((tile.getValue() - oldValue - minValue) * angleStep); needleRect = new Rectangle(); needleRect.setFill(tile.getBackgroundColor()); needleRect.getTransforms().setAll(needleRectRotate); needle = new Path(); needle.setFillRule(FillRule.EVEN_ODD); needle.getTransforms().setAll(needleRotate); needle.setFill(tile.getNeedleColor()); needle.setStrokeWidth(0); needle.setStroke(Color.TRANSPARENT); titleText = new Text(tile.getTitle()); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); valueText = new Text(String.format(locale, formatString, tile.getCurrentValue())); valueText.setFill(tile.getValueColor()); valueText.setTextOrigin(VPos.BASELINE); Helper.enableNode(valueText, tile.isValueVisible() && !tile.isAlert()); upperUnitText = new Text(""); upperUnitText.setFill(tile.getUnitColor()); Helper.enableNode(upperUnitText, !tile.getUnit().isEmpty()); fractionLine = new Line(); unitText = new Text(tile.getUnit()); unitText.setFill(tile.getUnitColor()); Helper.enableNode(unitText, !tile.getUnit().isEmpty()); unitFlow = new VBox(upperUnitText, unitText); unitFlow.setAlignment(Pos.CENTER_RIGHT); valueUnitFlow = new HBox(valueText, unitFlow); valueUnitFlow.setAlignment(Pos.CENTER); valueUnitFlow.setMouseTransparent(true); minValueText = new Text(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", tile.getMinValue())); minValueText.setFill(tile.getTitleColor()); maxValueText = new Text(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", tile.getMaxValue())); maxValueText.setFill(tile.getTitleColor()); thresholdRect = new Rectangle(); thresholdRect.setFill(sectionsVisible ? Color.TRANSPARENT : tile.getValue() > tile.getThreshold() ? tile.getThresholdColor() : Tile.GRAY); Helper.enableNode(thresholdRect, tile.isThresholdVisible()); thresholdText = new Text(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", tile.getThreshold())); thresholdText.setFill(sectionsVisible ? Color.TRANSPARENT : Tile.GRAY); Helper.enableNode(thresholdText, tile.isThresholdVisible()); getPane().getChildren().addAll(barBackground, thresholdBar, sectionPane, alertIcon, needleRect, needle, titleText, valueUnitFlow, fractionLine, minValueText, maxValueText, thresholdRect, thresholdText); }
Example 20
Source File: TimerControlTileSkin.java From OEE-Designer with MIT License | 4 votes |
private void drawTimeSections() { if (sectionMap.isEmpty()) return; ZonedDateTime time = tile.getTime(); DayOfWeek day = time.getDayOfWeek(); boolean isAM = time.get(ChronoField.AMPM_OF_DAY) == 0; double offset = 90; double angleStep = 360.0 / 60.0; boolean highlightSections = tile.isHighlightSections(); for (TimeSection section : sectionMap.keySet()) { LocalTime start = section.getStart(); LocalTime stop = section.getStop(); boolean isStartAM = start.get(ChronoField.AMPM_OF_DAY) == 0; boolean isStopAM = stop.get(ChronoField.AMPM_OF_DAY) == 0; boolean draw = isAM ? (isStartAM || isStopAM) : (!isStartAM || !isStopAM); if (!section.getDays().contains(day)) { draw = false; } if (!section.isActive()) { draw = false; } if (draw) { double sectionStartAngle = (start.getHour() % 12 * 5.0 + start.getMinute() / 12.0 + start.getSecond() / 300.0) * angleStep + 180; double sectionAngleExtend = ((stop.getHour() - start.getHour()) % 12 * 5.0 + (stop.getMinute() - start.getMinute()) / 12.0 + (stop.getSecond() - start.getSecond()) / 300.0) * angleStep; if (start.getHour() > stop.getHour()) { sectionAngleExtend = (360.0 - Math.abs(sectionAngleExtend)); } Arc arc = sectionMap.get(section); arc.setCenterX(clockSize * 0.5); arc.setCenterY(clockSize * 0.5); arc.setRadiusX(clockSize * 0.45); arc.setRadiusY(clockSize * 0.45); arc.setStartAngle(-(offset + sectionStartAngle)); arc.setLength(-sectionAngleExtend); arc.setType(ArcType.OPEN); arc.setStrokeWidth(clockSize * 0.04); arc.setStrokeLineCap(StrokeLineCap.BUTT); arc.setFill(null); if (highlightSections) { arc.setStroke(section.contains(time.toLocalTime()) ? section.getHighlightColor() : section.getColor()); } else { arc.setStroke(section.getColor()); } } } }