Java Code Examples for javafx.scene.shape.Circle#setFill()
The following examples show how to use
javafx.scene.shape.Circle#setFill() .
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: ClientSession.java From Open-Lowcode with Eclipse Public License 2.0 | 6 votes |
/** * sets the title on the active tab (corresponding to the active client display) * * @param newtitle the text title to show * @param otpstatus status of OTP connection */ public void setTitle(String newtitle, String otpstatus) { logger.warning(" --- ---- Starting setting title "); Tab tab = this.tabpane.getTabs().get(activedisplayindex); if (otpstatus.equals("NONE")) { tab.setText((newtitle.length() > 20 ? newtitle.substring(0, 20) + "..." : newtitle)); tab.setTooltip(new Tooltip(newtitle)); return; } // ---------------------- Process otp status that is not null --------------- BorderPane borderpane = new BorderPane(); borderpane.setCenter(new Label(newtitle)); Color dotcolor = Color.LIGHTGREEN; if (otpstatus.equals("INVALID")) dotcolor = Color.INDIANRED; Circle dot = new Circle(0, 0, 4); dot.setFill(dotcolor); dot.setStroke(Color.LIGHTGRAY); borderpane.setRight(dot); BorderPane.setAlignment(dot, Pos.CENTER); tab.setText(""); tab.setGraphic(borderpane); }
Example 2
Source File: StopWatchSample.java From marathonv5 with Apache License 2.0 | 5 votes |
private void configureBackground() { ImageView imageView = new ImageView(); Image image = loadImage(); imageView.setImage(image); Circle circle1 = new Circle(); circle1.setCenterX(140); circle1.setCenterY(140); circle1.setRadius(120); circle1.setFill(Color.TRANSPARENT); circle1.setStroke(Color.web("#0A0A0A")); circle1.setStrokeWidth(0.3); Circle circle2 = new Circle(); circle2.setCenterX(140); circle2.setCenterY(140); circle2.setRadius(118); circle2.setFill(Color.TRANSPARENT); circle2.setStroke(Color.web("#0A0A0A")); circle2.setStrokeWidth(0.3); Circle circle3 = new Circle(); circle3.setCenterX(140); circle3.setCenterY(140); circle3.setRadius(140); circle3.setFill(Color.TRANSPARENT); circle3.setStroke(Color.web("#818a89")); circle3.setStrokeWidth(1); Ellipse ellipse = new Ellipse(140, 95, 180, 95); Circle ellipseClip = new Circle(140, 140, 140); ellipse.setFill(Color.web("#535450")); ellipse.setStrokeWidth(0); GaussianBlur ellipseEffect = new GaussianBlur(); ellipseEffect.setRadius(10); ellipse.setEffect(ellipseEffect); ellipse.setOpacity(0.1); ellipse.setClip(ellipseClip); background.getChildren().addAll(imageView, circle1, circle2, circle3, ellipse); }
Example 3
Source File: ClearIcon.java From FxDock with Apache License 2.0 | 5 votes |
public ClearIcon(double size) { super(size); double r = 0.4 * size; double w = 0.075 * size; double d = 0.14 * size; Circle c = new Circle(0, 0, r); c.setFill(null); c.setStrokeWidth(0); c.setStroke(null); c.setFill(Color.LIGHTGRAY); FxPath p = new FxPath(); p.setStrokeLineCap(StrokeLineCap.SQUARE); p.setStroke(Color.WHITE); p.setStrokeWidth(w); p.moveto(-d, -d); p.lineto(d, d); p.moveto(d, -d); p.lineto(-d, d); Group g = new Group(c, p); g.setTranslateX(size * 0.5); g.setTranslateY(size * 0.5); add(g); }
Example 4
Source File: StopWatch.java From netbeans with Apache License 2.0 | 5 votes |
private void configureHand() { Circle circle = new Circle(0, 0, radius / 18); circle.setFill(color); Rectangle rectangle1 = new Rectangle(-0.5 - radius / 140, +radius / 7 - radius / 1.08, radius / 70 + 1, radius / 1.08); Rectangle rectangle2 = new Rectangle(-0.5 - radius / 140, +radius / 3.5 - radius / 7, radius / 70 + 1, radius / 7); rectangle1.setFill(color); rectangle2.setFill(Color.BLACK); hand.getChildren().addAll(circle, rectangle1, rectangle2); }
Example 5
Source File: JFXColorPickerSkin.java From JFoenix with Apache License 2.0 | 5 votes |
private void updateColor() { final ColorPicker colorPicker = (ColorPicker) getSkinnable(); Color color = colorPicker.getValue(); Color circleColor = color == null ? Color.WHITE : color; // update picker box color if (((JFXColorPicker) getSkinnable()).isDisableAnimation()) { JFXNodeUtils.updateBackground(colorBox.getBackground(), colorBox, circleColor); } else { Circle colorCircle = new Circle(); colorCircle.setFill(circleColor); colorCircle.setManaged(false); colorCircle.setLayoutX(colorBox.getWidth() / 4); colorCircle.setLayoutY(colorBox.getHeight() / 2); colorBox.getChildren().add(colorCircle); Timeline animateColor = new Timeline(new KeyFrame(Duration.millis(240), new KeyValue(colorCircle.radiusProperty(), 200, Interpolator.EASE_BOTH))); animateColor.setOnFinished((finish) -> { JFXNodeUtils.updateBackground(colorBox.getBackground(), colorBox, colorCircle.getFill()); colorBox.getChildren().remove(colorCircle); }); animateColor.play(); } // update label color displayNode.setTextFill(circleColor.grayscale().getRed() < 0.5 ? Color.valueOf( "rgba(255, 255, 255, 0.87)") : Color.valueOf("rgba(0, 0, 0, 0.87)")); if (colorLabelVisible.get()) { displayNode.setText(JFXNodeUtils.colorToHex(circleColor)); } else { displayNode.setText(""); } }
Example 6
Source File: FanPane.java From Intro-to-Java-Programming with MIT License | 5 votes |
/** Return a Circle */ private Circle getCircle() { Circle c = new Circle(); c.setRadius(100); c.setStroke(Color.BLACK); c.setFill(Color.WHITE); return c; }
Example 7
Source File: CircleSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public static Node createIconContent() { Circle circle = new Circle(57,57,40); circle.setStroke(Color.web("#b9c0c5")); circle.setStrokeWidth(5); circle.getStrokeDashArray().addAll(15d,15d); circle.setFill(null); javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow(); effect.setOffsetX(1); effect.setOffsetY(1); effect.setRadius(3); effect.setColor(Color.rgb(0,0,0,0.6)); circle.setEffect(effect); return circle; }
Example 8
Source File: CircleSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public static Node createIconContent() { Circle circle = new Circle(57,57,40); circle.setStroke(Color.web("#b9c0c5")); circle.setStrokeWidth(5); circle.getStrokeDashArray().addAll(15d,15d); circle.setFill(null); javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow(); effect.setOffsetX(1); effect.setOffsetY(1); effect.setRadius(3); effect.setColor(Color.rgb(0,0,0,0.6)); circle.setEffect(effect); return circle; }
Example 9
Source File: Switch.java From tilesfx with Apache License 2.0 | 5 votes |
private void initGraphics() { if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 || Double.compare(getHeight(), 0.0) <= 0) { if (getPrefWidth() > 0 && getPrefHeight() > 0) { setPrefSize(getPrefWidth(), getPrefHeight()); } else { setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT); } } getStyleClass().add("switch"); shadow = new DropShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), 3, 0, 0, 0); switchBorder = new Rectangle(); switchBorder.setFill(getForegroundColor()); switchBackground = new Rectangle(); switchBackground.setMouseTransparent(true); switchBackground.setFill(isActive() ? getActiveColor() : getBackgroundColor()); thumb = new Circle(); thumb.setMouseTransparent(true); thumb.setFill(getForegroundColor()); thumb.setEffect(shadow); pane = new Pane(switchBorder, switchBackground, thumb); getChildren().setAll(pane); }
Example 10
Source File: DataViewerSample.java From chart-fx with Apache License 2.0 | 5 votes |
private static Pane getDemoPane() { final Rectangle rect = new Rectangle(-130, -40, 80, 80); rect.setFill(Color.BLUE); final Circle circle = new Circle(0, 0, 40); circle.setFill(Color.GREEN); final Polygon triangle = new Polygon(60, -40, 120, 0, 50, 40); triangle.setFill(Color.RED); final Group group = new Group(rect, circle, triangle); group.setTranslateX(300); group.setTranslateY(200); final RotateTransition rotateTransition = new RotateTransition(Duration.millis(4000), group); rotateTransition.setByAngle(3.0 * 360); rotateTransition.setCycleCount(Animation.INDEFINITE); rotateTransition.setAutoReverse(true); rotateTransition.play(); final RotateTransition rotateTransition1 = new RotateTransition(Duration.millis(1000), rect); rotateTransition1.setByAngle(360); rotateTransition1.setCycleCount(Animation.INDEFINITE); rotateTransition1.setAutoReverse(false); rotateTransition1.play(); final RotateTransition rotateTransition2 = new RotateTransition(Duration.millis(1000), triangle); rotateTransition2.setByAngle(360); rotateTransition2.setCycleCount(Animation.INDEFINITE); rotateTransition2.setAutoReverse(false); rotateTransition2.play(); group.setManaged(true); HBox.setHgrow(group, Priority.ALWAYS); final HBox box = new HBox(group); VBox.setVgrow(box, Priority.ALWAYS); box.setId("demoPane"); return box; }
Example 11
Source File: DetectionType.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
@Override public Node getCellNode(TreeTableCell<ModularFeatureListRow, FeatureStatus> cell, TreeTableColumn<ModularFeatureListRow, FeatureStatus> coll, FeatureStatus cellData, RawDataFile raw) { if (cellData == null) return null; Circle circle = new Circle(); circle.setRadius(10); circle.setFill(cellData.getColorFX()); return circle; }
Example 12
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 13
Source File: Exercise_16_03.java From Intro-to-Java-Programming with MIT License | 4 votes |
@Override // Override the start method in the Application calss public void start(Stage primaryStage) { // Create a vbox VBox paneForCircles = new VBox(5); paneForCircles.setAlignment(Pos.CENTER); // Create three circles Circle c1 = getCircle(); Circle c2 = getCircle(); Circle c3 = getCircle(); c1.setFill(Color.RED); // Place circles in vbox paneForCircles.getChildren().addAll(c1, c2, c3); // Create a rectangle Rectangle rectangle = new Rectangle(); rectangle.setFill(Color.WHITE); rectangle.setWidth(30); rectangle.setHeight(100); rectangle.setStroke(Color.BLACK); rectangle.setStrokeWidth(2); StackPane stopSign = new StackPane(rectangle, paneForCircles); // Create a hbox HBox paneForRadioButtons = new HBox(5); paneForRadioButtons.setAlignment(Pos.CENTER); // Create radio buttons RadioButton rbRed = new RadioButton("Red"); RadioButton rbYellow = new RadioButton("Yellow"); RadioButton rbGreen = new RadioButton("Green"); // Create a toggle group ToggleGroup group = new ToggleGroup(); rbRed.setToggleGroup(group); rbYellow.setToggleGroup(group); rbGreen.setToggleGroup(group); rbRed.setSelected(true); paneForRadioButtons.getChildren().addAll(rbRed, rbYellow, rbGreen); // Create a border pane BorderPane pane = new BorderPane(); pane.setCenter(stopSign); pane.setBottom(paneForRadioButtons); // Create and register handlers rbRed.setOnAction(e -> { if (rbRed.isSelected()) { c1.setFill(Color.RED); c2.setFill(Color.WHITE); c3.setFill(Color.WHITE); } }); rbYellow.setOnAction(e -> { if (rbYellow.isSelected()) { c1.setFill(Color.WHITE); c2.setFill(Color.YELLOW); c3.setFill(Color.WHITE); } }); rbGreen.setOnAction(e -> { if (rbGreen.isSelected()) { c1.setFill(Color.WHITE); c2.setFill(Color.WHITE); c3.setFill(Color.GREEN); } }); // Create a scene and place it in the stage Scene scene = new Scene(pane, 200, 150); primaryStage.setTitle("Exercise_16_03"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }
Example 14
Source File: IndustrialClockSkin.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); } } sectionsAndAreasCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); sectionsAndAreasCtx = sectionsAndAreasCanvas.getGraphicsContext2D(); tickCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); tickCtx = tickCanvas.getGraphicsContext2D(); alarmPane = new Pane(); hour = new Path(); hour.setFillRule(FillRule.EVEN_ODD); hour.setStroke(null); hour.getTransforms().setAll(hourRotate); minute = new Path(); minute.setFillRule(FillRule.EVEN_ODD); minute.setStroke(null); minute.getTransforms().setAll(minuteRotate); second = new Path(); second.setFillRule(FillRule.EVEN_ODD); second.setStroke(null); second.getTransforms().setAll(secondRotate); second.setVisible(clock.isSecondsVisible()); second.setManaged(clock.isSecondsVisible()); centerDot = new Circle(); centerDot.setFill(Color.WHITE); dropShadow = new DropShadow(); dropShadow.setColor(Color.rgb(0, 0, 0, 0.25)); dropShadow.setBlurType(BlurType.TWO_PASS_BOX); dropShadow.setRadius(0.015 * PREFERRED_WIDTH); dropShadow.setOffsetY(0.015 * PREFERRED_WIDTH); shadowGroupHour = new Group(hour); shadowGroupMinute = new Group(minute); shadowGroupSecond = new Group(second); shadowGroupHour.setEffect(clock.getShadowsEnabled() ? dropShadow : null); shadowGroupMinute.setEffect(clock.getShadowsEnabled() ? dropShadow : null); shadowGroupSecond.setEffect(clock.getShadowsEnabled() ? dropShadow : null); title = new Text(""); title.setVisible(clock.isTitleVisible()); title.setManaged(clock.isTitleVisible()); dateText = new Text(""); dateText.setVisible(clock.isDateVisible()); dateText.setManaged(clock.isDateVisible()); dateNumber = new Text(""); dateNumber.setVisible(clock.isDateVisible()); dateNumber.setManaged(clock.isDateVisible()); text = new Text(""); text.setVisible(clock.isTextVisible()); text.setManaged(clock.isTextVisible()); pane = new Pane(sectionsAndAreasCanvas, tickCanvas, alarmPane, title, dateText, dateNumber, text, shadowGroupMinute, shadowGroupHour, shadowGroupSecond, centerDot); 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 15
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 16
Source File: HeatControlSkin.java From Enzo with Apache License 2.0 | 4 votes |
private void initGraphics() { innerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), PREFERRED_HEIGHT * 0.1, 0, 0, 0); Color color = gradientLookup.getColorAt(getSkinnable().getValue() / (getSkinnable().getMaxValue() - getSkinnable().getMinValue())); background = new Circle(0.5 * PREFERRED_WIDTH, 0.5 * PREFERRED_HEIGHT, 0.5 * PREFERRED_WIDTH); background.setFill(new LinearGradient(0, 0, 0, PREFERRED_HEIGHT, false, CycleMethod.NO_CYCLE, new Stop(0, color.deriveColor(0, 1, 0.8, 1)), new Stop(1, color.deriveColor(0, 1, 0.6, 1)))); background.setEffect(innerShadow); ticksCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); ticksCanvas.setMouseTransparent(true); ticks = ticksCanvas.getGraphicsContext2D(); targetIndicator = new Region(); targetIndicator.getStyleClass().setAll("target-indicator"); targetIndicatorRotate = new Rotate(180 - getSkinnable().getStartAngle() - getSkinnable().getMinValue() * angleStep); targetIndicator.getTransforms().setAll(targetIndicatorRotate); targetExceeded = false; targetIndicator.setVisible(getSkinnable().isTargetEnabled()); valueIndicator = new Region(); valueIndicator.getStyleClass().setAll("value-indicator"); valueIndicatorRotate = new Rotate(180 - getSkinnable().getStartAngle()); valueIndicatorRotate.setAngle(valueIndicatorRotate.getAngle() + (getSkinnable().getValue() - getSkinnable().getOldValue() - getSkinnable().getMinValue()) * angleStep); valueIndicator.getTransforms().setAll(valueIndicatorRotate); infoText = new Text(getSkinnable().getInfoText().toUpperCase()); infoText.setTextOrigin(VPos.CENTER); infoText.setFont(Fonts.opensansSemiBold(0.06 * PREFERRED_HEIGHT)); infoText.setMouseTransparent(true); infoText.getStyleClass().setAll("info-text"); value = new Text(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getValue())); value.setMouseTransparent(true); value.setTextOrigin(VPos.CENTER); value.setFont(Fonts.opensansBold(0.32 * PREFERRED_HEIGHT)); value.setMouseTransparent(true); value.getStyleClass().setAll("value"); // Add all nodes pane = new Pane(); pane.getChildren().setAll(background, ticksCanvas, valueIndicator, targetIndicator, infoText, value); getChildren().setAll(pane); }
Example 17
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 18
Source File: ClockPane.java From Intro-to-Java-Programming with MIT License | 4 votes |
/** Paint the clock */ protected void paintClock() { // Initialize clock parameters double clockRadius = Math.min(w, h) * 0.8 * 0.5; double centerX = w / 2; double centerY = h / 2; // Draw circle Circle circle = new Circle(centerX, centerY, clockRadius); circle.setFill(Color.WHITE); circle.setStroke(Color.BLACK); Text t1 = new Text(centerX - 5, centerY - clockRadius + 12, "12"); Text t2 = new Text(centerX - clockRadius + 3, centerY + 5, "9"); Text t3 = new Text(centerX + clockRadius - 10, centerY + 3, "3"); Text t4 = new Text(centerX - 3, centerY + clockRadius - 3, "6"); // Draw second hand double sLength = clockRadius * 0.8; double secondX = centerX + sLength * Math.sin(second * (2 * Math.PI / 60)); double secondY = centerY - sLength * Math.cos(second * (2 * Math.PI / 60)); Line sLine = new Line(centerX, centerY, secondX, secondY); sLine.setStroke(Color.RED); // Draw minute hand double mLength = clockRadius * 0.65; double xMinute = centerX + mLength * Math.sin(minute * (2 * Math.PI / 60)); double minuteY = centerY - mLength * Math.cos(minute * (2 * Math.PI / 60)); Line mLine = new Line(centerX, centerY, xMinute, minuteY); mLine.setStroke(Color.BLUE); // Draw hour hand double hLength = clockRadius * 0.5; double hourX = centerX + hLength * Math.sin((hour % 12 + minute / 60.0) * (2 * Math.PI / 12)); double hourY = centerY - hLength * Math.cos((hour % 12 + minute / 60.0) * (2 * Math.PI / 12)); Line hLine = new Line(centerX, centerY, hourX, hourY); hLine.setStroke(Color.GREEN); getChildren().clear(); getChildren().addAll(circle, t1, t2, t3, t4, sLine, mLine, hLine); }
Example 19
Source File: SparkLineTileSkin.java From OEE-Designer with MIT License | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); averagingListener = o -> handleEvents("AVERAGING"); timeFormatter = DateTimeFormatter.ofPattern("HH:mm", tile.getLocale()); if (tile.isAutoScale()) tile.calcAutoScale(); niceScaleY = new NiceScale(tile.getMinValue(), tile.getMaxValue()); niceScaleY.setMaxTicks(5); tickLineColor = Color.color(tile.getChartGridColor().getRed(), tile.getChartGridColor().getGreen(), tile.getChartGridColor().getBlue(), 0.5); horizontalTickLines = new ArrayList<>(5); tickLabelsY = new ArrayList<>(5); for (int i = 0 ; i < 5 ; i++) { Line hLine = new Line(0, 0, 0, 0); hLine.getStrokeDashArray().addAll(1.0, 2.0); hLine.setStroke(Color.TRANSPARENT); horizontalTickLines.add(hLine); Text tickLabelY = new Text(""); tickLabelY.setFill(Color.TRANSPARENT); tickLabelsY.add(tickLabelY); } gradientLookup = new GradientLookup(tile.getGradientStops()); low = tile.getMaxValue(); high = tile.getMinValue(); stdDeviation = 0; movingAverage = tile.getMovingAverage(); noOfDatapoints = tile.getAveragingPeriod(); dataList = new LinkedList<>(); // To get smooth lines in the chart we need at least 4 values if (noOfDatapoints < 4) throw new IllegalArgumentException("Please increase the averaging period to a value larger than 3."); graphBounds = new Rectangle(PREFERRED_WIDTH * 0.05, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.45); 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()); unitText = new Text(tile.getUnit()); unitText.setFill(tile.getUnitColor()); Helper.enableNode(unitText, !tile.getUnit().isEmpty()); valueUnitFlow = new TextFlow(valueText, unitText); valueUnitFlow.setTextAlignment(TextAlignment.RIGHT); averageText = new Text(String.format(locale, formatString, tile.getAverage())); averageText.setFill(Tile.FOREGROUND); Helper.enableNode(averageText, tile.isAverageVisible()); highText = new Text(); highText.setTextOrigin(VPos.BOTTOM); highText.setFill(tile.getValueColor()); lowText = new Text(); lowText.setTextOrigin(VPos.TOP); lowText.setFill(tile.getValueColor()); text = new Text(tile.getText()); text.setTextOrigin(VPos.TOP); text.setFill(tile.getTextColor()); timeSpanText = new Text(""); timeSpanText.setTextOrigin(VPos.TOP); timeSpanText.setFill(tile.getTextColor()); Helper.enableNode(timeSpanText, !tile.isTextVisible()); stdDeviationArea = new Rectangle(); Helper.enableNode(stdDeviationArea, tile.isAverageVisible()); averageLine = new Line(); averageLine.setStroke(Tile.FOREGROUND); averageLine.getStrokeDashArray().addAll(PREFERRED_WIDTH * 0.005, PREFERRED_WIDTH * 0.005); Helper.enableNode(averageLine, tile.isAverageVisible()); pathElements = new ArrayList<>(noOfDatapoints); pathElements.add(0, new MoveTo()); for (int i = 1 ; i < noOfDatapoints ; i++) { pathElements.add(i, new LineTo()); } sparkLine = new Path(); sparkLine.getElements().addAll(pathElements); sparkLine.setFill(null); sparkLine.setStroke(tile.getBarColor()); sparkLine.setStrokeWidth(PREFERRED_WIDTH * 0.0075); sparkLine.setStrokeLineCap(StrokeLineCap.ROUND); sparkLine.setStrokeLineJoin(StrokeLineJoin.ROUND); dot = new Circle(); dot.setFill(tile.getBarColor()); getPane().getChildren().addAll(titleText, valueUnitFlow, stdDeviationArea, averageLine, sparkLine, dot, averageText, highText, lowText, timeSpanText, text); getPane().getChildren().addAll(horizontalTickLines); getPane().getChildren().addAll(tickLabelsY); }
Example 20
Source File: RadarNodeChart.java From tilesfx with Apache License 2.0 | 4 votes |
private void initGraphics() { stops = new ArrayList<>(16); for (Stop stop : getGradientStops()) { if (Double.compare(stop.getOffset(), 0.0) == 0) stops.add(new Stop(0, stop.getColor())); stops.add(new Stop(stop.getOffset() * 0.69924 + 0.285, stop.getColor())); } chartPath = new Path(); overlayPath = new Path(); overlayPath.setFill(Color.TRANSPARENT); centerCircle = new Circle(); thresholdCircle = new Circle(); thresholdCircle.setFill(Color.TRANSPARENT); unitText = new Text(getUnit()); unitText.setTextAlignment(TextAlignment.CENTER); unitText.setTextOrigin(VPos.CENTER); unitText.setFont(Fonts.latoLight(0.045 * PREFERRED_WIDTH)); legendStep = (getMaxValue() - getMinValue()) / 5d; dropShadow = new DropShadow(BlurType.TWO_PASS_BOX, Color.BLACK, 5, 0, 0, 0); minValueText = new Text(String.format(Locale.US, formatString, getMinValue())); minValueText.setTextAlignment(TextAlignment.CENTER); minValueText.setTextOrigin(VPos.CENTER); minValueText.setVisible(isLegendVisible()); minValueText.setEffect(dropShadow); legend1Text = new Text(String.format(Locale.US, formatString, getMinValue() + legendStep)); legend1Text.setTextAlignment(TextAlignment.CENTER); legend1Text.setTextOrigin(VPos.CENTER); legend1Text.setVisible(isLegendVisible()); legend1Text.setEffect(dropShadow); legend2Text = new Text(String.format(Locale.US, formatString, getMinValue() + legendStep * 2)); legend2Text.setTextAlignment(TextAlignment.CENTER); legend2Text.setTextOrigin(VPos.CENTER); legend2Text.setVisible(isLegendVisible()); legend2Text.setEffect(dropShadow); legend3Text = new Text(String.format(Locale.US, formatString, getMinValue() + legendStep * 3)); legend3Text.setTextAlignment(TextAlignment.CENTER); legend3Text.setTextOrigin(VPos.CENTER); legend3Text.setVisible(isLegendVisible()); legend3Text.setEffect(dropShadow); legend4Text = new Text(String.format(Locale.US, formatString, getMinValue() + legendStep * 3)); legend4Text.setTextAlignment(TextAlignment.CENTER); legend4Text.setTextOrigin(VPos.CENTER); legend4Text.setVisible(isLegendVisible()); legend4Text.setEffect(dropShadow); maxValueText = new Text(String.format(Locale.US, formatString, getMaxValue())); maxValueText.setTextAlignment(TextAlignment.CENTER); maxValueText.setTextOrigin(VPos.CENTER); maxValueText.setVisible(isLegendVisible()); maxValueText.setEffect(dropShadow); textGroup = new Group(); // Add all nodes pane = new Pane(chartPath, overlayPath, centerCircle, thresholdCircle, textGroup, unitText, minValueText, legend1Text, legend2Text, legend3Text, legend4Text, maxValueText); getChildren().setAll(pane); }