use of javafx.scene.shape.Arc in project blue by kunstmusik.
the class KnobSkin method initComponents.
private void initComponents(double w) {
getChildren().clear();
double width = snapSize(w);
double radius = width / 2;
double innerRadius = snapSize(radius * 0.5);
final Color trackColor = getSkinnable().getTrackColor();
Ellipse outer = new Ellipse(radius, radius, radius, radius);
Ellipse inner = new Ellipse(radius, radius, innerRadius, innerRadius);
Shape shape = Path.subtract(outer, inner);
Rectangle rect = new Rectangle(radius, radius);
Shape trackBG = Path.subtract(shape, rect);
trackBG.setRotate(-135.0);
trackBG.setStroke(getSkinnable().getTrackBackgroundColor());
trackBG.setStrokeType(StrokeType.INSIDE);
trackBG.setFill(getSkinnable().getTrackBackgroundColor().darker());
Arc mask = new Arc(radius, radius, radius + 2, radius + 2, -270, -270);
mask.setType(ArcType.ROUND);
mask.lengthProperty().bind(percent.multiply(-ARC_LENGTH));
track = Path.subtract(shape, rect);
track.setRotate(-135.0);
track.setStroke(trackColor);
track.setStrokeType(StrokeType.INSIDE);
track.setFill(trackColor.deriveColor(1.0, 1.0, 1.0, 0.5));
track.setClip(mask);
track.setEffect(new Glow(1.0));
Canvas c = new Canvas(width, width);
GraphicsContext gc = c.getGraphicsContext2D();
gc.setStroke(trackColor.brighter().brighter().brighter());
gc.setLineWidth(2.0);
gc.strokeLine(radius, 0, radius, radius - innerRadius - 1);
gc.setFill(Color.BLACK);
gc.fillOval(width * 0.25, width * 0.25, width * 0.5, width * 0.5);
gc.setFill(trackColor);
double notchWidth = width / 10.0;
double notchAdj = notchWidth / 2.0;
gc.fillRoundRect(radius - notchAdj, (width * .25) - notchAdj, notchWidth, (width * .25) + notchWidth, notchWidth, notchWidth);
gc.setStroke(Color.BLACK);
gc.strokeRoundRect(radius - notchAdj, (width * .25) - notchAdj, notchWidth, (width * .25) + notchWidth, notchWidth, notchWidth);
c.rotateProperty().bind(percent.multiply(ARC_LENGTH).subtract(135.0));
getChildren().addAll(trackBG, track, c);
}
use of javafx.scene.shape.Arc in project Board-Instrumentation-Framework by intel.
the class RadialBargraphSkin method initGraphics.
private void initGraphics() {
// "OpenSans"
Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/opensans-semibold.ttf"), (0.06 * PREFERRED_HEIGHT));
barColor = getSkinnable().getBarColor();
barGradient = new ConicalGradient(new Stop(0.0, Color.TRANSPARENT), new Stop(1.0, Color.TRANSPARENT));
valueBlendBottomShadow = new DropShadow();
valueBlendBottomShadow.setBlurType(BlurType.TWO_PASS_BOX);
valueBlendBottomShadow.setColor(Color.rgb(255, 255, 255, 0.5));
valueBlendBottomShadow.setOffsetX(0);
valueBlendBottomShadow.setOffsetY(0.005 * PREFERRED_WIDTH);
valueBlendBottomShadow.setRadius(0);
valueBlendTopShadow = new InnerShadow();
valueBlendTopShadow.setBlurType(BlurType.TWO_PASS_BOX);
valueBlendTopShadow.setColor(Color.rgb(0, 0, 0, 0.7));
valueBlendTopShadow.setOffsetX(0);
valueBlendTopShadow.setOffsetY(0.005 * PREFERRED_WIDTH);
valueBlendTopShadow.setRadius(0.005 * PREFERRED_WIDTH);
blend = new Blend();
blend.setMode(BlendMode.MULTIPLY);
blend.setBottomInput(valueBlendBottomShadow);
blend.setTopInput(valueBlendTopShadow);
background = new Region();
background.getStyleClass().setAll("background");
ticksAndSectionsCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
ticksAndSections = ticksAndSectionsCanvas.getGraphicsContext2D();
minMeasuredValue = new Region();
minMeasuredValue.getStyleClass().setAll("min-measured-value");
minMeasuredValueRotate = new Rotate(180 - getSkinnable().getStartAngle());
minMeasuredValue.getTransforms().setAll(minMeasuredValueRotate);
minMeasuredValue.setOpacity(getSkinnable().isMinMeasuredValueVisible() ? 1 : 0);
minMeasuredValue.setManaged(getSkinnable().isMinMeasuredValueVisible());
maxMeasuredValue = new Region();
maxMeasuredValue.getStyleClass().setAll("max-measured-value");
maxMeasuredValueRotate = new Rotate(180 - getSkinnable().getStartAngle());
maxMeasuredValue.getTransforms().setAll(maxMeasuredValueRotate);
maxMeasuredValue.setOpacity(getSkinnable().isMaxMeasuredValueVisible() ? 1 : 0);
maxMeasuredValue.setManaged(getSkinnable().isMaxMeasuredValueVisible());
threshold = new Region();
threshold.getStyleClass().setAll("threshold");
thresholdRotate = new Rotate(180 - getSkinnable().getStartAngle());
threshold.getTransforms().setAll(thresholdRotate);
threshold.setOpacity(getSkinnable().isThresholdVisible() ? 1 : 0);
threshold.setManaged(getSkinnable().isThresholdVisible());
thresholdExceeded = false;
bar = new Arc();
bar.setType(ArcType.ROUND);
bar.setCenterX(PREFERRED_WIDTH * 0.5);
bar.setCenterY(PREFERRED_HEIGHT * 0.5);
bar.setRadiusX(PREFERRED_WIDTH * 0.5 - 4);
bar.setRadiusY(PREFERRED_HEIGHT * 0.5 - 4);
bar.setStartAngle(getSkinnable().getStartAngle() - 90);
bar.setLength(0);
bar.setStrokeType(StrokeType.CENTERED);
bar.setStroke(null);
bar.setFill(new RadialGradient(0, 0, PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.45, false, CycleMethod.NO_CYCLE, new Stop(0.0, barColor), // -5 for on the barColorHue)
new Stop(0.76, barColor.deriveColor(-5, 1, 1, 1)), new Stop(0.79, barColor), new Stop(0.97, barColor), // -5 for on the barColorHue)
new Stop(1.0, barColor.deriveColor(-5, 1, 1, 1))));
knob = new Region();
knob.setPickOnBounds(false);
knob.getStyleClass().setAll("knob");
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);
title = new Text(getSkinnable().getTitle());
title.setMouseTransparent(true);
title.setTextOrigin(VPos.CENTER);
title.getStyleClass().setAll("title");
title.setEffect(getSkinnable().isPlainValue() ? null : blend);
unit = new Text(getSkinnable().getUnit());
unit.setMouseTransparent(true);
unit.setTextOrigin(VPos.CENTER);
unit.getStyleClass().setAll("unit");
unit.setEffect(getSkinnable().isPlainValue() ? null : blend);
value = new Text();
value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getValue()));
value.setMouseTransparent(true);
value.setTextOrigin(VPos.CENTER);
value.getStyleClass().setAll("value");
value.setEffect(getSkinnable().isPlainValue() ? null : blend);
// Set initial value
double range = (getSkinnable().getMaxValue() - getSkinnable().getMinValue());
double angleRange = getSkinnable().getAngleRange();
angleStep = angleRange / range;
double targetAngle = getSkinnable().getValue() * angleStep;
angle.set(targetAngle);
double currentValue = angle.get() / angleStep;
value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", currentValue));
value.setTranslateX((size - value.getLayoutBounds().getWidth()) * 0.5);
bar.setLength(-currentValue * angleStep);
// Add all nodes
pane = new Pane();
pane.getChildren().setAll(background, bar, ticksAndSectionsCanvas, minMeasuredValue, maxMeasuredValue, threshold, knob, title, unit, value);
pane.getChildren().addAll(getSkinnable().getMarkers().keySet());
getChildren().setAll(pane);
}
use of javafx.scene.shape.Arc in project KNOBS by ESSICS.
the class Knob method initComponents.
protected void initComponents() {
angleStepProperty().bind(Bindings.divide(ANGLE_RANGE, Bindings.subtract(maxValueProperty(), minValueProperty())));
backgroundProperty().bind(Bindings.createObjectBinding(() -> Color.TRANSPARENT.equals(getBackgroundColor()) ? Background.EMPTY : new Background(new BackgroundFill(getBackgroundColor(), CornerRadii.EMPTY, Insets.EMPTY)), backgroundColorProperty()));
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.20), PREFERRED_WIDTH * 0.008, 0.0, 0, PREFERRED_WIDTH * 0.008);
innerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.20), PREFERRED_WIDTH * 0.008, 0.0, 0, -PREFERRED_WIDTH * 0.008);
highlight.setInput(innerShadow);
dropShadow.setInput(highlight);
barGradient = new ConicalGradient(reorderStops(getGradientStops()));
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)));
currentValueBarArc = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.46, PREFERRED_HEIGHT * 0.46, BAR_START_ANGLE, 0);
currentValueBarArc.setType(ArcType.OPEN);
currentValueBarArc.setStrokeLineCap(StrokeLineCap.ROUND);
currentValueBarArc.setFill(null);
currentValueBarArc.strokeProperty().bind(currentValueColorProperty());
currentValueBarArc.lengthProperty().bind(Bindings.createDoubleBinding(() -> {
double localMin = (isZeroDetentEnabled() && getMinValue() < 0) ? Math.min(0, getMaxValue()) : getMinValue();
double length = getAngleStep() * (localMin - getCurrentValue());
if (length == 0) {
length = getAngleStep() * (getMinValue() - getMaxValue()) / 10000;
}
return length;
}, angleStepProperty(), currentValueProperty(), maxValueProperty(), minValueProperty(), zeroDetentEnabledProperty()));
currentValueBarArc.opacityProperty().bind(Bindings.createDoubleBinding(() -> {
double localMin = (isZeroDetentEnabled() && getMinValue() < 0) ? Math.min(0, getMaxValue()) : getMinValue();
double length = getAngleStep() * (localMin - getCurrentValue());
if (length == 0) {
return 0.6666;
} else {
return 1.0;
}
}, angleStepProperty(), currentValueProperty(), maxValueProperty(), minValueProperty(), zeroDetentEnabledProperty()));
currentValueBarArc.startAngleProperty().bind(Bindings.createDoubleBinding(() -> {
double angle = BAR_START_ANGLE;
if (isZeroDetentEnabled() && getMinValue() < 0) {
angle += Math.max(getAngleStep() * getMinValue(), -ANGLE_RANGE);
}
return angle;
}, angleStepProperty(), minValueProperty(), zeroDetentEnabledProperty()));
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.fillProperty().bind(colorProperty());
ring.setEffect(dropShadow);
ring.addEventHandler(MouseEvent.MOUSE_PRESSED, e -> {
if (!isDisabled() && !isDragDisabled()) {
touchRotate(e.getSceneX(), e.getSceneY());
}
});
ring.addEventHandler(MouseEvent.MOUSE_DRAGGED, e -> {
if (!isDisabled() && !isDragDisabled()) {
touchRotate(e.getSceneX(), e.getSceneY());
}
});
ring.addEventHandler(MouseEvent.MOUSE_RELEASED, e -> {
if (!isDisabled() && !isDragDisabled()) {
fireTargeValueSet();
}
});
mainCircle = new Circle();
mainCircle.fillProperty().bind(Bindings.createObjectBinding(() -> getColor().darker().darker(), colorProperty()));
mainCircle.setOnMouseClicked(doubleClickHandler);
text = new Text(String.format(format, getCurrentValue()));
text.fillProperty().bind(textColorProperty());
text.setOnMouseClicked(doubleClickHandler);
text.setTextOrigin(VPos.CENTER);
targetText = new Text(String.format(format, getTargetValue()));
targetText.fillProperty().bind(Bindings.createObjectBinding(() -> getTextColor().darker(), textColorProperty()));
targetText.setOnMouseClicked(doubleClickHandler);
targetText.setTextOrigin(VPos.CENTER);
targetText.visibleProperty().bind(Bindings.createBooleanBinding(() -> isTargetValueAlwaysVisible() || !close(getCurrentValue(), getTargetValue(), (getMaxValue() - getMinValue()) * PROXIMITY_ERROR), targetValueAlwaysVisibleProperty(), currentValueProperty(), targetValueProperty(), maxValueProperty(), minValueProperty()));
unitText = new Text(getUnit());
unitText.fillProperty().bind(Bindings.createObjectBinding(() -> getTextColor().darker(), textColorProperty()));
unitText.setOnMouseClicked(doubleClickHandler);
unitText.setTextOrigin(VPos.CENTER);
textMinTag = new Polygon(0.0, 0.7, 0.6, 0.7, 0.6, 0.9, 0.0, 0.9);
textMinTag.fillProperty().bind(Bindings.createObjectBinding(() -> getColor().darker().darker(), colorProperty()));
textMinTag.visibleProperty().bind(extremaVisibleProperty());
textMin = new Text(String.format(format, getMinValue()));
textMin.fillProperty().bind(Bindings.createObjectBinding(() -> getTextColor().darker(), textColorProperty()));
textMin.setTextOrigin(VPos.CENTER);
textMin.visibleProperty().bind(extremaVisibleProperty());
textMaxTag = new Polygon(0.0, 0.7, 0.6, 0.7, 0.6, 0.9, 0.0, 0.9);
textMaxTag.fillProperty().bind(Bindings.createObjectBinding(() -> getColor().darker().darker(), colorProperty()));
textMaxTag.visibleProperty().bind(extremaVisibleProperty());
textMax = new Text(String.format(format, getMaxValue()));
textMax.fillProperty().bind(Bindings.createObjectBinding(() -> getTextColor().darker(), textColorProperty()));
textMax.setTextOrigin(VPos.CENTER);
textMax.visibleProperty().bind(extremaVisibleProperty());
tagBarArc = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.46, PREFERRED_HEIGHT * 0.46, BAR_START_ANGLE + 15, 50);
tagBarArc.setType(ArcType.OPEN);
tagBarArc.setStrokeLineCap(StrokeLineCap.ROUND);
tagBarArc.setFill(null);
tagBarArc.strokeProperty().bind(tagColorProperty());
tagBarArc.visibleProperty().bind(tagVisibleProperty());
indicatorRotate = new Rotate(-ANGLE_RANGE * 0.5, center, center);
indicatorGlow = new DropShadow(BlurType.TWO_PASS_BOX, getIndicatorColor(), PREFERRED_WIDTH * 0.020, 0.0, 0, 0);
indicatorInnerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.50), 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);
indicatorRotate.angleProperty().bind(Bindings.subtract(Bindings.multiply(Bindings.subtract(targetValueProperty(), minValueProperty()), angleStepProperty()), ANGLE_RANGE * 0.5));
indicatorGlow.colorProperty().bind(selectionColorProperty());
indicatorHighlight.setInput(indicatorInnerShadow);
indicator = new Circle();
indicator.effectProperty().bind(Bindings.createObjectBinding(() -> isSelected() ? indicatorGlow : null, selectionColorProperty(), selectedProperty()));
indicator.disableProperty().bind(dragDisabledProperty());
indicator.fillProperty().bind(Bindings.createObjectBinding(() -> {
Color c = isSelected() ? getSelectionColor() : getIndicatorColor();
return isDragDisabled() ? c.deriveColor(0, 1, 0.92, 0.6) : c;
}, colorProperty(), dragDisabledProperty(), indicatorColorProperty(), selectionColorProperty(), selectedProperty()));
indicator.strokeProperty().bind(Bindings.createObjectBinding(() -> {
Color c = isSelected() ? getSelectionColor().darker().darker() : getIndicatorColor().darker().darker();
return isDragDisabled() ? c.deriveColor(0, 1, 0.92, 0.6) : c;
}, colorProperty(), dragDisabledProperty(), indicatorColorProperty(), selectionColorProperty(), selectedProperty()));
indicator.setMouseTransparent(true);
indicator.getTransforms().add(indicatorRotate);
Group indicatorGroup = new Group(indicator);
indicatorGroup.setEffect(indicatorHighlight);
pane = new Pane(barArc, currentValueBarArc, ring, mainCircle, text, targetText, unitText, textMinTag, textMin, textMaxTag, textMax, tagBarArc, indicatorGroup);
pane.setPrefSize(PREFERRED_HEIGHT, PREFERRED_HEIGHT);
pane.backgroundProperty().bind(Bindings.createObjectBinding(() -> new Background(new BackgroundFill(getColor().darker(), new CornerRadii(1024), Insets.EMPTY)), colorProperty()));
pane.setEffect(highlight);
Platform.runLater(() -> getChildren().setAll(pane));
}
use of javafx.scene.shape.Arc in project tilesfx by HanSolo.
the class RadialPercentageTileSkin method initGraphics.
// ******************** Initialization ************************************
@Override
protected void initGraphics() {
super.initGraphics();
if (tile.isAutoScale())
tile.calcAutoScale();
minValue = tile.getMinValue();
range = tile.getRange();
sectionsVisible = tile.getSectionsVisible();
sections = tile.getSections();
formatString = new StringBuilder("%.").append(Integer.toString(tile.getDecimals())).append("f").toString();
locale = tile.getLocale();
dataList = tile.getChartData();
sum = dataList.stream().mapToDouble(ChartData::getValue).sum();
angleStep = ANGLE_RANGE / sum;
referenceValue = tile.getReferenceValue() < maxValue ? maxValue : tile.getReferenceValue();
chartEventListener = e -> setProportionBar();
tile.getChartData().forEach(chartData -> chartData.addChartDataEventListener(chartEventListener));
chartDataListener = c -> {
dataList = tile.getChartData();
sum = dataList.stream().mapToDouble(ChartData::getValue).sum();
setProportionBar();
};
currentValueListener = o -> setBar(tile.getCurrentValue());
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);
proportionBar = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.468, PREFERRED_HEIGHT * 0.468, 90, 0);
proportionBar.setType(ArcType.OPEN);
proportionBar.setStroke(tile.getBarColor());
proportionBar.setStrokeWidth(PREFERRED_WIDTH * 0.015);
proportionBar.setStrokeLineCap(StrokeLineCap.BUTT);
proportionBar.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);
percentageValueText = new Text(String.format(locale, formatString, tile.getCurrentValue()));
percentageValueText.setFont(Fonts.latoRegular(PREFERRED_WIDTH * 0.27333));
percentageValueText.setFill(tile.getValueColor());
percentageValueText.setTextOrigin(VPos.CENTER);
percentageUnitText = new Text(tile.getUnit());
percentageUnitText = new Text("\u0025");
percentageUnitText.setFont(Fonts.latoLight(PREFERRED_WIDTH * 0.08));
percentageUnitText.setFill(tile.getUnitColor());
percentageFlow = new TextFlow(percentageValueText, percentageUnitText);
percentageFlow.setTextAlignment(TextAlignment.CENTER);
descriptionText = new Text(String.format(locale, formatString, tile.getCurrentValue()));
descriptionText.setFont(Fonts.latoRegular(PREFERRED_WIDTH * 0.27333));
descriptionText.setFill(tile.getValueColor());
descriptionText.setTextOrigin(VPos.CENTER);
enableNode(descriptionText, tile.isValueVisible());
unitText = new Text(tile.getUnit());
unitText = new Text("\u0025");
unitText.setFont(Fonts.latoLight(PREFERRED_WIDTH * 0.08));
unitText.setFill(tile.getUnitColor());
enableNode(unitText, !tile.getUnit().isEmpty());
valueUnitFlow = new TextFlow(descriptionText, unitText);
valueUnitFlow.setTextAlignment(TextAlignment.CENTER);
getPane().getChildren().addAll(barBackground, proportionBar, bar, separator, titleText, text, percentageFlow, valueUnitFlow);
}
use of javafx.scene.shape.Arc in project tilesfx by HanSolo.
the class TimerControlTileSkin method initGraphics.
// ******************** Initialization ************************************
@Override
protected void initGraphics() {
super.initGraphics();
currentValueListener = o -> {
// Update time only if clock is not already running
if (tile.isRunning()) {
return;
}
updateTime(ZonedDateTime.ofInstant(Instant.ofEpochSecond(tile.getCurrentTime()), ZoneId.of(ZoneId.systemDefault().getId())));
};
timeListener = o -> updateTime(tile.getTime());
dateFormatter = DateTimeFormatter.ofPattern("EE d", tile.getLocale());
sectionMap = new HashMap<>(tile.getTimeSections().size());
for (TimeSection section : tile.getTimeSections()) {
sectionMap.put(section, new Arc());
}
minuteRotate = new Rotate();
hourRotate = new Rotate();
secondRotate = new Rotate();
sectionsPane = new Pane();
sectionsPane.getChildren().addAll(sectionMap.values());
Helper.enableNode(sectionsPane, tile.getSectionsVisible());
minuteTickMarks = new Path();
minuteTickMarks.setFillRule(FillRule.EVEN_ODD);
minuteTickMarks.setFill(null);
minuteTickMarks.setStroke(tile.getMinuteColor());
minuteTickMarks.setStrokeLineCap(StrokeLineCap.ROUND);
hourTickMarks = new Path();
hourTickMarks.setFillRule(FillRule.EVEN_ODD);
hourTickMarks.setFill(null);
hourTickMarks.setStroke(tile.getHourColor());
hourTickMarks.setStrokeLineCap(StrokeLineCap.ROUND);
hour = new Rectangle(3, 60);
hour.setArcHeight(3);
hour.setArcWidth(3);
hour.setStroke(tile.getHourColor());
hour.getTransforms().setAll(hourRotate);
minute = new Rectangle(3, 96);
minute.setArcHeight(3);
minute.setArcWidth(3);
minute.setStroke(tile.getMinuteColor());
minute.getTransforms().setAll(minuteRotate);
second = new Rectangle(1, 96);
second.setArcHeight(1);
second.setArcWidth(1);
second.setStroke(tile.getSecondColor());
second.getTransforms().setAll(secondRotate);
second.setVisible(tile.isSecondsVisible());
second.setManaged(tile.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(tile.isShadowsEnabled() ? dropShadow : null);
shadowGroupMinute.setEffect(tile.isShadowsEnabled() ? dropShadow : null);
shadowGroupSecond.setEffect(tile.isShadowsEnabled() ? dropShadow : null);
titleText = new Text("");
titleText.setTextOrigin(VPos.TOP);
Helper.enableNode(titleText, !tile.getTitle().isEmpty());
amPmText = new Text(tile.getTime().get(ChronoField.AMPM_OF_DAY) == 0 ? "AM" : "PM");
dateText = new Text("");
Helper.enableNode(dateText, tile.isDateVisible());
text = new Text("");
Helper.enableNode(text, tile.isTextVisible());
getPane().getChildren().addAll(sectionsPane, hourTickMarks, minuteTickMarks, titleText, amPmText, dateText, text, shadowGroupHour, shadowGroupMinute, shadowGroupSecond);
}
Aggregations