Java Code Examples for javafx.scene.shape.Arc#setStroke()
The following examples show how to use
javafx.scene.shape.Arc#setStroke() .
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: ArcSample.java From marathonv5 with Apache License 2.0 | 6 votes |
public ArcSample() { super(180,90); // Simple red filled arc Arc arc1 = new Arc(45,60,45,45,40,100); arc1.setFill(Color.RED); // Blue stroked arc Arc arc2 = new Arc(155,60,45,45,40,100); arc2.setStroke(Color.DODGERBLUE); arc2.setFill(null); // Create a group to show all the arcs); getChildren().add(new Group(arc1,arc2)); // REMOVE ME setControls( new SimplePropertySheet.PropDesc("Arc 1 Fill", arc1.fillProperty()), new SimplePropertySheet.PropDesc("Arc 1 Start Angle", arc1.startAngleProperty(), 0d, 360d), new SimplePropertySheet.PropDesc("Arc 1 Length", arc1.lengthProperty(), 0d, 360d), new SimplePropertySheet.PropDesc("Arc 2 Stroke", arc2.strokeProperty()), new SimplePropertySheet.PropDesc("Arc 2 Stroke Width", arc2.strokeWidthProperty(), 1d, 5d), new SimplePropertySheet.PropDesc("Arc 2 Radius X", arc2.radiusXProperty(), 0d, 50d), new SimplePropertySheet.PropDesc("Arc 2 Radius Y", arc2.radiusYProperty(), 0d, 50d) ); // END REMOVE ME }
Example 2
Source File: Exercise_14_11.java From Intro-to-Java-Programming with MIT License | 5 votes |
/** Return a Arc of specified properties */ private Arc getArc(Circle c) { Arc a = new Arc(c.getRadius(), c.getRadius() * 1.30, c.getRadius() / 2, c.getRadius() / 4, 0, -180); a.setType(ArcType.OPEN); a.setFill(Color.WHITE); a.setStroke(Color.BLACK); return a; }
Example 3
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 4
Source File: Exercise_15_26.java From Intro-to-Java-Programming with MIT License | 4 votes |
@Override // Override the start method in the Application class public void start(Stage primaryStage) { // Create a pane Pane pane = new Pane(); // Create a arc Arc arc = new Arc(100, 50, 75, 25, 0, -180); arc.setFill(Color.WHITE); arc.setStroke(Color.BLACK); // Create a circle Circle ball = new Circle(100, 75, 10); // Place nodes in pane pane.getChildren().addAll(arc, ball); // Create a path transition PathTransition pt = new PathTransition(); pt.setDuration(Duration.millis(4000)); pt.setPath(arc); pt.setNode(ball); pt.setOrientation( PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT); pt.setCycleCount(Timeline.INDEFINITE); pt.setAutoReverse(true); pt.play(); // Start animation // Create a fade transition to ball FadeTransition ft = new FadeTransition(Duration.millis(4000), ball); ft.setFromValue(1.0); ft.setToValue(0.1); ft.setCycleCount(Timeline.INDEFINITE); ft.setAutoReverse(true); ft.play(); // Start animation // Create and register the handle pane.setOnMousePressed(e -> { pt.pause(); ft.pause(); }); pane.setOnMouseReleased(e -> { pt.play(); ft.play(); }); // Create a scene and place it in the stage Scene scene = new Scene(pane, 200, 100); primaryStage.setTitle("Exercise_15_26"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }
Example 5
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 6
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 7
Source File: SlimClockSkin.java From Medusa with Apache License 2.0 | 4 votes |
@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 8
Source File: FlatSkin.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); } } colorRing = new Circle(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.5); colorRing.setFill(Color.TRANSPARENT); colorRing.setStrokeWidth(PREFERRED_WIDTH * 0.0075); colorRing.setStroke(gauge.getBarColor()); 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(gauge.getBarColor()); bar.setStrokeWidth(PREFERRED_WIDTH * 0.15); 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(gauge.getBorderPaint()); separator.setFill(Color.TRANSPARENT); titleText = new Text(gauge.getTitle()); titleText.setFont(Fonts.robotoLight(PREFERRED_WIDTH * 0.08)); 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(colorRing, bar, separator, titleText, valueText, unitText); 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 9
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 10
Source File: Exercise_15_24.java From Intro-to-Java-Programming with MIT License | 4 votes |
@Override // Override the start method in the Application class public void start(Stage primaryStage) { // Create a pane Pane pane = new Pane(); // Create a arc Arc arc = new Arc(100, 50, 75, 25, 0, -180); arc.setFill(Color.WHITE); arc.setStroke(Color.BLACK); // Create a circle Circle circle = new Circle(100, 75, 5); // Place nodes in pane pane.getChildren().addAll(arc, circle); // Create a path transition PathTransition pt = new PathTransition(); pt.setDuration(Duration.millis(4000)); pt.setPath(arc); pt.setNode(circle); pt.setOrientation( PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT); pt.setCycleCount(Timeline.INDEFINITE); pt.setAutoReverse(true); pt.play(); // Start animation // Create and register the handle pane.setOnMousePressed(e -> { pt.pause(); }); pane.setOnMouseReleased(e -> { pt.play(); }); // Create a scene and place it in the stage Scene scene = new Scene(pane, 200, 100); primaryStage.setTitle("Exercise_15_24"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }
Example 11
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 12
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 13
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 14
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 15
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 16
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 17
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 18
Source File: MinimalClockSkin.java From Medusa with Apache License 2.0 | 4 votes |
@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.isDateVisible()); dateText.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()); minuteCircle = new Circle(0.075 * PREFERRED_WIDTH); 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.BUTT); secondArc.setFill(null); secondArc.setStroke(clock.getSecondColor()); secondArc.setVisible(clock.isSecondsVisible()); secondArc.setManaged(clock.isSecondsVisible()); pane = new Pane(secondBackgroundCircle, dateText, hour, secondArc, minuteCircle, minute); pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), new CornerRadii(1024), new Insets(PREFERRED_WIDTH * 0.04)))); getChildren().setAll(pane); }
Example 19
Source File: Exercise_14_17.java From Intro-to-Java-Programming with MIT License | 4 votes |
@Override // Override the start method in the Application class public void start(Stage primaryStage) { // Create a pane Pane pane = new Pane(); // Create three polylines and set their properties Polyline polyline1 = new Polyline(); pane.getChildren().add(polyline1); polyline1.setStroke(Color.BLACK); ObservableList<Double> list = polyline1.getPoints(); double x1 = 40.0; double y1 = 190.0; double y2 = 20.0; double x3 = 125.0; list.addAll(x1, y1, x1, y2, x3, y2, x3, y1 * .60); Polyline polyline2 = new Polyline(); pane.getChildren().add(polyline2); polyline2.setStroke(Color.BLACK); ObservableList<Double> list2 = polyline2.getPoints(); list2.addAll((x1 + x3) * .5, y1 * .5, x3, y1 * .25, x3 + (x3 - x1) * .5, y1 * .5); Polyline polyline3 = new Polyline(); pane.getChildren().add(polyline3); polyline3.setStroke(Color.BLACK); ObservableList<Double> list3 = polyline3.getPoints(); list3.addAll((x1 + x3) * .6, y1 * .80, x3, y1 * .60, x3 + (x3 - x1) * .3, y1 * .80); // Create a circle and set its properties Circle circle = new Circle(x3, y1 * .25, 15); circle.setFill(Color.WHITE); circle.setStroke(Color.BLACK); pane.getChildren().add(circle); // Create an arc and set its properties Arc arc = new Arc(x1, y1 + 1, 25, 15, 0, 180); arc.setFill(Color.WHITE); arc.setStroke(Color.BLACK); pane.getChildren().add(arc); // Create a scene and place it in the stage Scene scene = new Scene(pane, 200, 200); primaryStage.setTitle("Exercise_14_17"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }
Example 20
Source File: FarCry4Loading.java From FXTutorials with MIT License | 2 votes |
public LoadingArc() { Arc arc = new Arc(); arc.setCenterX(25); arc.setCenterY(25); arc.setRadiusX(25.0f); arc.setRadiusY(25.0f); arc.setLength(30.0f); arc.setStrokeWidth(5); Stop[] stops = new Stop[] { new Stop(0, Color.WHITE), new Stop(1, Color.BLUE)}; LinearGradient lg1 = new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, stops); arc.setStroke(lg1); Rectangle rect = new Rectangle(50, 50); rect.setFill(null); rect.setStroke(Color.RED); getChildren().addAll(rect, arc); double time = 0.75; Rotate r = new Rotate(0, 25, 25); arc.getTransforms().add(r); //arc.getTransforms().add(new Scale(-1, 1, 25, 25)); Timeline timeline = new Timeline(); KeyFrame kf2 = new KeyFrame(Duration.seconds(time), new KeyValue(r.angleProperty(), 270)); timeline.getKeyFrames().addAll(kf2); Timeline timeline3 = new Timeline(new KeyFrame(Duration.seconds(time), new KeyValue(r.angleProperty(), 360))); SequentialTransition st = new SequentialTransition(timeline, timeline3); st.setCycleCount(Timeline.INDEFINITE); st.setInterpolator(Interpolator.EASE_BOTH); st.play(); ////////// Timeline timeline2 = new Timeline(); timeline2.setAutoReverse(true); timeline2.setCycleCount(Timeline.INDEFINITE); KeyFrame kf = new KeyFrame(Duration.seconds(time), new KeyValue(arc.lengthProperty(), 270, Interpolator.EASE_BOTH)); timeline2.getKeyFrames().add(kf); timeline2.play(); }