javafx.scene.paint.RadialGradient Java Examples
The following examples show how to use
javafx.scene.paint.RadialGradient.
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: RadialGradientSample.java From marathonv5 with Apache License 2.0 | 6 votes |
public RadialGradientSample() { //create simple radial gradient RadialGradient gradient1 = new RadialGradient(0, 0, 0.5, 0.5, 1, true, CycleMethod.NO_CYCLE, new Stop[] { new Stop(0, Color.DODGERBLUE), new Stop(1, Color.BLACK) }); Circle circle1 = new Circle(45, 45, 40, gradient1); //create complex radial gradient RadialGradient gradient2 = new RadialGradient(20, 1, 0.5, 0.5, 0.6, true, CycleMethod.NO_CYCLE, new Stop[] { new Stop(0, Color.TRANSPARENT), new Stop(0.5, Color.DARKGRAY), new Stop(0.64, Color.WHITESMOKE), new Stop(0.65, Color.YELLOW), new Stop(1, Color.GOLD) }); Circle circle2 = new Circle(145, 45, 40, gradient2); HBox hb = new HBox(10); hb.getChildren().addAll(circle1, circle2); // show the circles getChildren().addAll(hb); }
Example #2
Source File: RadialGradientSample.java From marathonv5 with Apache License 2.0 | 6 votes |
public RadialGradientSample() { //create simple radial gradient RadialGradient gradient1 = new RadialGradient(0, 0, 0.5, 0.5, 1, true, CycleMethod.NO_CYCLE, new Stop[] { new Stop(0, Color.DODGERBLUE), new Stop(1, Color.BLACK) }); Circle circle1 = new Circle(45, 45, 40, gradient1); //create complex radial gradient RadialGradient gradient2 = new RadialGradient(20, 1, 0.5, 0.5, 0.6, true, CycleMethod.NO_CYCLE, new Stop[] { new Stop(0, Color.TRANSPARENT), new Stop(0.5, Color.DARKGRAY), new Stop(0.64, Color.WHITESMOKE), new Stop(0.65, Color.YELLOW), new Stop(1, Color.GOLD) }); Circle circle2 = new Circle(145, 45, 40, gradient2); HBox hb = new HBox(10); hb.getChildren().addAll(circle1, circle2); // show the circles getChildren().addAll(hb); }
Example #3
Source File: RadialGlobalMenu.java From RadialFx with GNU Lesser General Public License v3.0 | 6 votes |
public void addMenuItem(final String iconPath, final EventHandler<MouseEvent> eventHandler) { final RadialGradient backGradient = new RadialGradient(0, 0, 0, 0, radius.get(), false, CycleMethod.NO_CYCLE, new Stop(0, BACK_GRADIENT_COLOR), new Stop(1, Color.TRANSPARENT)); final RadialGradient backSelectGradient = new RadialGradient(0, 0, 0, 0, radius.get(), false, CycleMethod.NO_CYCLE, new Stop(0, BACK_SELECT_GRADIENT_COLOR), new Stop(1, Color.TRANSPARENT)); final RadialMenuItem item = RadialMenuItemBuilder.create() .length(length).graphic(new Group(getImageView(iconPath))) .backgroundFill(backGradient) .backgroundMouseOnFill(backSelectGradient) .innerRadius(innerRadius).radius(radius).offset(offset) .clockwise(true).backgroundVisible(true).strokeVisible(false) .build(); item.setOnMouseClicked(eventHandler); items.add(item); itemsContainer.getChildren().addAll(item); }
Example #4
Source File: AreaHeatMap.java From charts with Apache License 2.0 | 6 votes |
private void draw(final int LIMIT, final double RESOLUTION) { int limit = LIMIT > points.size() ? points.size() : LIMIT + 1; double pixelSize = 2 * RESOLUTION; ctx.clearRect(0, 0, width, height); for (double y = 0 ; y < height ; y += RESOLUTION) { for (double x = 0 ; x < width ; x += RESOLUTION) { double value = getValueAt(limit, x, y); if (value != -255) { Color color = getUseColorMapping() ? getColorForValue(value) : getColorForValue(value, isDiscreteColors()); RadialGradient gradient = new RadialGradient(0, 0, x, y, RESOLUTION, false, CycleMethod.NO_CYCLE, new Stop(0, Color.color(color.getRed(), color.getGreen(), color.getBlue(), getHeatMapOpacity())), new Stop(1, Color.color(color.getRed(), color.getGreen(), color.getBlue(), 0.0))); ctx.setFill(gradient); ctx.fillOval(x - RESOLUTION, y - RESOLUTION, pixelSize, pixelSize); } } } }
Example #5
Source File: AbstractStepRepresentation.java From phoenicis with GNU Lesser General Public License v3.0 | 6 votes |
protected void drawLeftImage() { AnchorPane pane = new AnchorPane(); pane.setPrefWidth(187); Stop[] stops = new Stop[] { new Stop(0, Color.web("#3c79b2")), new Stop(1, Color.web("#2d5d8b")) }; RadialGradient gradient = new RadialGradient(0, 0, 0.5, 0.5, 1, true, CycleMethod.NO_CYCLE, stops); Background background = new Background(new BackgroundFill(gradient, null, null)); pane.setBackground(background); Text text = new Text(this.parent.getLeftImageText()); text.setFill(Color.WHITE); text.setFont(Font.font("Maven Pro", 50)); text.setRotate(-90); pane.setPadding(new Insets(-50)); pane.getChildren().add(text); AnchorPane.setBottomAnchor(text, 160.0); AnchorPane.setRightAnchor(text, -40.0); getParent().getRoot().setLeft(pane); }
Example #6
Source File: RadialGradientSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public static Node createIconContent() { Rectangle rect = new Rectangle(80,80,new RadialGradient(0, 0, 0.5, 0.5, 1, true, CycleMethod.NO_CYCLE, new Stop[] { new Stop(0, Color.rgb(156,216,255)), new Stop(0.5, Color.DODGERBLUE), new Stop(1, Color.rgb(0,70,140)) })); rect.setArcWidth(20); rect.setArcHeight(20); return rect; }
Example #7
Source File: RadialGlobalMenu.java From RadialFx with GNU Lesser General Public License v3.0 | 5 votes |
private void computeBack() { final Rectangle rect = new Rectangle(); rect.setWidth(widthProp.get()); rect.setHeight(heightProp.get()); rect.setTranslateX(widthProp.get() / -2.0); rect.setTranslateY(heightProp.get() / -2.0); final RadialGradient radialGradient = new RadialGradient(0, 0, widthProp.get() / 2.0, heightProp.get() / 2.0, widthProp.get() / 2.0, false, CycleMethod.NO_CYCLE, new Stop(0, Color.TRANSPARENT), new Stop(1, BACK_GRADIENT_COLOR)); rect.setFill(radialGradient); backContainer.getChildren().setAll(rect); }
Example #8
Source File: Led.java From JFX8CustomControls with Apache License 2.0 | 5 votes |
private void recalc() { double size = getWidth() < getHeight() ? getWidth() : getHeight(); ledOffShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), 0.07 * size, 0, 0, 0); ledOnShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), 0.07 * size, 0, 0, 0); ledOnShadow.setInput(new DropShadow(BlurType.TWO_PASS_BOX, ledColor.get(), 0.36 * size, 0, 0, 0)); frameGradient = new LinearGradient(0.14 * size, 0.14 * size, 0.84 * size, 0.84 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, Color.rgb(20, 20, 20, 0.65)), new Stop(0.15, Color.rgb(20, 20, 20, 0.65)), new Stop(0.26, Color.rgb(41, 41, 41, 0.65)), new Stop(0.26, Color.rgb(41, 41, 41, 0.64)), new Stop(0.85, Color.rgb(200, 200, 200, 0.41)), new Stop(1.0, Color.rgb(200, 200, 200, 0.35))); ledOnGradient = new LinearGradient(0.25 * size, 0.25 * size, 0.74 * size, 0.74 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, ledColor.get().deriveColor(0d, 1d, 0.77, 1d)), new Stop(0.49, ledColor.get().deriveColor(0d, 1d, 0.5, 1d)), new Stop(1.0, ledColor.get())); ledOffGradient = new LinearGradient(0.25 * size, 0.25 * size, 0.74 * size, 0.74 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, ledColor.get().deriveColor(0d, 1d, 0.20, 1d)), new Stop(0.49, ledColor.get().deriveColor(0d, 1d, 0.13, 1d)), new Stop(1.0, ledColor.get().deriveColor(0d, 1d, 0.2, 1d))); highlightGradient = new RadialGradient(0, 0, 0.3 * size, 0.3 * size, 0.29 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, Color.WHITE), new Stop(1.0, Color.TRANSPARENT)); draw(); }
Example #9
Source File: FontIcon.java From ikonli with Apache License 2.0 | 5 votes |
private static Paint resolvePaintValue(String iconCode, String value) { try { return Color.valueOf(value); } catch (IllegalArgumentException e1) { try { return LinearGradient.valueOf(value); } catch (IllegalArgumentException e2) { try { return RadialGradient.valueOf(value); } catch (IllegalArgumentException e3) { throw invalidDescription(iconCode, e3); } } } }
Example #10
Source File: SVGIcon.java From ikonli with Apache License 2.0 | 5 votes |
private static Paint resolvePaintValue(String iconCode, String value) { try { return Color.valueOf(value); } catch (IllegalArgumentException e1) { try { return LinearGradient.valueOf(value); } catch (IllegalArgumentException e2) { try { return RadialGradient.valueOf(value); } catch (IllegalArgumentException e3) { throw invalidDescription(iconCode, e3); } } } }
Example #11
Source File: RotationEffect.java From tilesfx with Apache License 2.0 | 5 votes |
private void updateGradient() { gradient = new RadialGradient(0, 0, offsetX + width * centerX, offsetY + height * centerY, 1024, false, CycleMethod.NO_CYCLE, new Stop(0.0, getColorWithOpacity(getAlpha())), new Stop(1.0, Color.TRANSPARENT)); }
Example #12
Source File: RadarChartTest.java From charts with Apache License 2.0 | 5 votes |
@Override public void init() { List<YChartItem> item1 = new ArrayList<>(ELEMENTS); List<YChartItem> item2 = new ArrayList<>(ELEMENTS); List<YChartItem> item3 = new ArrayList<>(ELEMENTS); for (int i = 0 ; i < ELEMENTS ; i++) { YChartItem dataPoint; dataPoint = new YChartItem(RND.nextDouble() * 100, "P" + i); item1.add(dataPoint); dataPoint = new YChartItem(RND.nextDouble() * 100, "P" + i); item2.add(dataPoint); dataPoint = new YChartItem(RND.nextDouble() * 100, "P" + i); item3.add(dataPoint); } series1 = new YSeries(item3, CHART_TYPE, new RadialGradient(0, 0, 0, 0, 1, true, CycleMethod.NO_CYCLE, new Stop(0.0, Color.rgb(0, 255, 255, 0.25)), new Stop(0.5, Color.rgb(255, 255, 0, 0.5)), new Stop(1.0, Color.rgb(255, 0, 255, 0.75))), Color.TRANSPARENT); series2 = new YSeries(item1, CHART_TYPE, new RadialGradient(0, 0, 0, 0, 1, true, CycleMethod.NO_CYCLE, new Stop(0.0, Color.rgb(255, 0, 0, 0.25)), new Stop(0.5, Color.rgb(255, 255, 0, 0.5)), new Stop(1.0, Color.rgb(0, 200, 0, 0.75))), Color.TRANSPARENT); series3 = new YSeries(item2, CHART_TYPE, new RadialGradient(0, 0, 0, 0, 1, true, CycleMethod.NO_CYCLE, new Stop(0.0, Color.rgb(0, 255, 255, 0.25)), new Stop(0.5, Color.rgb(0, 255, 255, 0.5)), new Stop(1.0, Color.rgb(0, 0, 255, 0.75))), Color.TRANSPARENT); series2.setWithWrapping(true); chart = new YChart(new YPane(series1, series2, series3)); chart.setPrefSize(600, 600); timeline = new Timeline(); lastTimerCall = System.nanoTime(); timer = new AnimationTimer() { @Override public void handle(final long now) { if (now > lastTimerCall + INTERVAL) { animateData(); long delta = System.nanoTime() - now; timeline.play(); lastTimerCall = now + delta; } } }; registerListener(); }
Example #13
Source File: ThermoDemo.java From phoebus with Eclipse Public License 1.0 | 5 votes |
public void setFill(Color color) { ellipse.setFill( new RadialGradient(0, 0, 0.3, 0.1, 0.4, true, CycleMethod.NO_CYCLE, new Stop(0, color.interpolate(Color.WHITESMOKE, 0.8)), new Stop(1, color))); fill.setFill(new LinearGradient(0, 0, .8, 0, true, CycleMethod.NO_CYCLE, new Stop(0, color), new Stop(.3, color.interpolate(Color.WHITESMOKE, 0.7)), new Stop(1, color))); }
Example #14
Source File: ThermometerRepresentation.java From phoebus with Eclipse Public License 1.0 | 5 votes |
public void setFill(Color color) { ellipse.setFill( new RadialGradient(0, 0, 0.3, 0.1, 0.4, true, CycleMethod.NO_CYCLE, new Stop(0, color.interpolate(Color.WHITESMOKE, 0.8)), new Stop(1, color))); fill.setFill(new LinearGradient(0, 0, .8, 0, true, CycleMethod.NO_CYCLE, new Stop(0, color), new Stop(.3, color.interpolate(Color.WHITESMOKE, 0.7)), new Stop(1, color))); }
Example #15
Source File: RadialGradientSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public static Node createIconContent() { Rectangle rect = new Rectangle(80,80,new RadialGradient(0, 0, 0.5, 0.5, 1, true, CycleMethod.NO_CYCLE, new Stop[] { new Stop(0, Color.rgb(156,216,255)), new Stop(0.5, Color.DODGERBLUE), new Stop(1, Color.rgb(0,70,140)) })); rect.setArcWidth(20); rect.setArcHeight(20); return rect; }
Example #16
Source File: SingleChartTest.java From charts with Apache License 2.0 | 4 votes |
@Override public void init() { List<XYChartItem> xyItem1 = new ArrayList<>(NO_OF_X_VALUES); List<XYChartItem> xyItem2 = new ArrayList<>(NO_OF_X_VALUES); List<XYChartItem> xyItem3 = new ArrayList<>(NO_OF_X_VALUES); List<XYChartItem> xyItem4 = new ArrayList<>(NO_OF_X_VALUES); for (int i = 0 ; i < NO_OF_X_VALUES ; i++) { xyItem1.add(new XYChartItem(i, RND.nextDouble() * 12 + RND.nextDouble() * 6, "P" + i, COLORS[RND.nextInt(3)])); xyItem2.add(new XYChartItem(i, RND.nextDouble() * 7 + RND.nextDouble() * 3, "P" + i, COLORS[RND.nextInt(3)])); xyItem3.add(new XYChartItem(i, RND.nextDouble() * 3 + RND.nextDouble() * 4, "P" + i, COLORS[RND.nextInt(3)])); xyItem4.add(new XYChartItem(i, RND.nextDouble() * 4, "P" + i, COLORS[RND.nextInt(3)])); } xySeries1 = new XYSeries(xyItem1, ChartType.LINE, Color.rgb(255, 0, 0, 0.5), Color.RED); xySeries2 = new XYSeries(xyItem2, ChartType.LINE, Color.rgb(0, 255, 0, 0.5), Color.LIME); xySeries3 = new XYSeries(xyItem3, ChartType.LINE, Color.rgb(0, 0, 255, 0.5), Color.BLUE); xySeries4 = new XYSeries(xyItem4, ChartType.LINE, Color.rgb(255, 0, 255, 0.5), Color.MAGENTA); xySeries1.setSymbolsVisible(false); xySeries2.setSymbolsVisible(false); xySeries3.setSymbolsVisible(false); xySeries4.setSymbolsVisible(false); // XYChart Converter tempConverter = new Converter(TEMPERATURE, CELSIUS); // Type Temperature with BaseUnit Celsius double tempFahrenheitMin = tempConverter.convert(0, FAHRENHEIT); double tempFahrenheitMax = tempConverter.convert(20, FAHRENHEIT); lineChartXAxisBottom = createBottomXAxis(0, NO_OF_X_VALUES, true); lineChartYAxisLeft = createLeftYAxis(0, 20, true); lineChartYAxisRight = createRightYAxis(tempFahrenheitMin, tempFahrenheitMax, false); xyChart = new XYChart<>(new XYPane(xySeries1, xySeries2, xySeries3, xySeries4), lineChartYAxisLeft, lineChartYAxisRight, lineChartXAxisBottom); // YChart List<YChartItem> yItem1 = new ArrayList<>(20); List<YChartItem> yItem2 = new ArrayList<>(20); List<YChartItem> yItem3 = new ArrayList<>(20); for (int i = 0 ; i < 20 ; i++) { yItem1.add(new YChartItem(RND.nextDouble() * 100, "P" + i, COLORS[RND.nextInt(3)])); yItem2.add(new YChartItem(RND.nextDouble() * 100, "P" + i, COLORS[RND.nextInt(3)])); yItem3.add(new YChartItem(RND.nextDouble() * 100, "P" + i, COLORS[RND.nextInt(3)])); } ySeries1 = new YSeries(yItem1, ChartType.RADAR_SECTOR, new RadialGradient(0, 0, 0, 0, 1, true, CycleMethod.NO_CYCLE, new Stop(0.0, Color.rgb(255, 0, 0, 0.5)), new Stop(0.5, Color.rgb(255, 255, 0, 0.5)), new Stop(1.0, Color.rgb(0, 200, 0, 0.8))), Color.TRANSPARENT); ySeries2 = new YSeries(yItem2, ChartType.SMOOTH_RADAR_POLYGON, new RadialGradient(0, 0, 0, 0, 1, true, CycleMethod.NO_CYCLE, new Stop(0.0, Color.rgb(0, 255, 255, 0.5)), new Stop(1.0, Color.rgb(0, 0, 255, 0.5))), Color.TRANSPARENT); ySeries3 = new YSeries(yItem3, ChartType.SMOOTH_RADAR_POLYGON, new RadialGradient(0, 0, 0, 0, 1, true, CycleMethod.NO_CYCLE, new Stop(0.0, Color.rgb(255, 255, 0, 0.5)), new Stop(1.0, Color.rgb(255, 0, 255, 0.5))), Color.TRANSPARENT); yChart = new YChart(new YPane(ySeries1, ySeries2, ySeries3)); lastTimerCall = System.nanoTime(); timer = new AnimationTimer() { @Override public void handle(final long now) { if (now > lastTimerCall + UPDATE_INTERVAL) { ObservableList<XYChartItem> xyItems = xySeries1.getItems(); xyItems.forEach(item -> item.setY(RND.nextDouble() * 8 + RND.nextDouble() * 10)); xyItems = xySeries2.getItems(); xyItems.forEach(item -> item.setY(RND.nextDouble() * 4 + RND.nextDouble() * 10)); xyItems = xySeries3.getItems(); xyItems.forEach(item -> item.setY(RND.nextDouble() * 3 + RND.nextDouble() * 4)); xyItems = xySeries4.getItems(); xyItems.forEach(item -> item.setY(RND.nextDouble() * 4)); ObservableList<YChartItem> yItems = ySeries1.getItems(); yItems.forEach(item -> item.setY(RND.nextDouble() * 100)); yItems = ySeries2.getItems(); yItems.forEach(item -> item.setY(RND.nextDouble() * 100)); yItems = ySeries3.getItems(); yItems.forEach(item -> item.setY(RND.nextDouble() * 100)); // Can be used to update charts but if more than one series is in one xyPane // it's easier to use the refresh() method of XYChart //xySeries1.refresh(); //xySeries2.refresh(); //xySeries3.refresh(); //xySeries4.refresh(); // Useful to refresh the chart if it contains more than one series to avoid // multiple redraws xyChart.refresh(); //ySeries1.refresh(); //ySeries2.refresh(); yChart.refresh(); lastTimerCall = now; } } }; }
Example #17
Source File: MorphingClockSkin.java From Medusa with Apache License 2.0 | 4 votes |
@Override protected void redraw() { pane.setBorder(new Border(new BorderStroke(clock.getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(clock.getBorderWidth() / PREFERRED_WIDTH * height)))); pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY))); hourColor = clock.getHourColor(); hourOffColor = Helper.getTranslucentColorFrom(hourColor, 0.15); minuteColor = clock.getMinuteColor(); minuteOffColor = Helper.getTranslucentColorFrom(minuteColor, 0.15); secondColor = clock.getSecondColor(); secondOffColor = Helper.getTranslucentColorFrom(secondColor, 0.15); hourGradient = new RadialGradient(0, 0, 0.5, 0.5, 1, true, CycleMethod.NO_CYCLE, new Stop(0.00, hourColor), new Stop(0.25, hourColor), new Stop(0.43, hourColor.darker()), new Stop(0.48, hourColor.darker().darker().darker()), new Stop(0.50, hourColor.darker().darker().darker().darker())); hourOffGradient = new RadialGradient(0, 0, 0.5, 0.5, 1, true, CycleMethod.NO_CYCLE, new Stop(0.00, hourOffColor), new Stop(0.25, hourOffColor), new Stop(0.43, hourOffColor.darker()), new Stop(0.48, hourOffColor.darker().darker().darker()), new Stop(0.50, hourOffColor.darker().darker().darker().darker())); minuteGradient = new RadialGradient(0, 0, 0.5, 0.5, 1, true, CycleMethod.NO_CYCLE, new Stop(0.00, minuteColor), new Stop(0.25, minuteColor), new Stop(0.43, minuteColor.darker()), new Stop(0.48, minuteColor.darker().darker().darker()), new Stop(0.50, minuteColor.darker().darker().darker().darker())); minuteOffGradient = new RadialGradient(0, 0, 0.5, 0.5, 1, true, CycleMethod.NO_CYCLE, new Stop(0.00, minuteOffColor), new Stop(0.25, minuteOffColor), new Stop(0.43, minuteOffColor.darker()), new Stop(0.48, minuteOffColor.darker().darker().darker()), new Stop(0.50, minuteOffColor.darker().darker().darker().darker())); secondGradient = new RadialGradient(0, 0, 0.5, 0.5, 1, true, CycleMethod.NO_CYCLE, new Stop(0.00, secondColor), new Stop(0.25, secondColor), new Stop(0.43, secondColor.darker()), new Stop(0.48, secondColor.darker().darker().darker()), new Stop(0.50, secondColor.darker().darker().darker().darker())); secondOffGradient = new RadialGradient(0, 0, 0.5, 0.5, 1, true, CycleMethod.NO_CYCLE, new Stop(0.00, secondOffColor), new Stop(0.25, secondOffColor), new Stop(0.43, secondOffColor.darker()), new Stop(0.48, secondOffColor.darker().darker().darker()), new Stop(0.50, secondOffColor.darker().darker().darker().darker())); drawTime(); }
Example #18
Source File: PlainClockSkin.java From Medusa with Apache License 2.0 | 4 votes |
@Override protected void redraw() { pane.setBorder(new Border(new BorderStroke(clock.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(clock.getBorderWidth() / PREFERRED_WIDTH * size)))); pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), new CornerRadii(1024), Insets.EMPTY))); hour.setFill(clock.getHourColor()); minute.setFill(clock.getMinuteColor()); second.setFill(clock.getSecondColor()); knob.setFill(clock.getKnobColor()); title.setFill(clock.getTitleColor()); text.setFill(clock.getTextColor()); shadowGroupHour.setEffect(clock.getShadowsEnabled() ? dropShadow : null); shadowGroupMinute.setEffect(clock.getShadowsEnabled() ? dropShadow : null); shadowGroupSecond.setEffect(clock.getShadowsEnabled() ? dropShadow : null); // Areas, Sections sectionsAndAreasCtx.clearRect(0, 0, size, size); if (areasVisible) Helper.drawTimeAreas(clock, sectionsAndAreasCtx, areas, size, 0.025, 0.025, 0.95, 0.95); if (sectionsVisible) Helper.drawTimeSections(clock, sectionsAndAreasCtx, sections, size, 0.06, 0.06, 0.88, 0.88, 0.07); // Tick Marks tickCanvas.setCache(false); drawTicks(); tickCanvas.setCache(true); tickCanvas.setCacheHint(CacheHint.QUALITY); ZonedDateTime time = clock.getTime(); updateTime(time); title.setText(clock.getTitle()); Helper.adjustTextSize(title, 0.6 * size, size * 0.12); title.relocate((size - title.getLayoutBounds().getWidth()) * 0.5, size * 0.25); text.setText(TIME_FORMATTER.format(time)); Helper.adjustTextSize(text, 0.6 * size, size * 0.12); text.relocate((size - text.getLayoutBounds().getWidth()) * 0.5, size * 0.6); dateNumber.setText(DATE_NUMBER_FORMATER.format(time).toUpperCase()); Helper.adjustTextSize(dateNumber, 0.3 * size, size * 0.05); dateNumber.relocate(((size * 0.5) - dateNumber.getLayoutBounds().getWidth()) * 0.5 + (size * 0.6), (size - dateNumber.getLayoutBounds().getHeight()) * 0.5); knob.setFill(new RadialGradient(0, 0, size * 0.5, size * 0.5, size * 0.0148448, false, CycleMethod.NO_CYCLE, new Stop(0.0, Color.rgb(1, 2, 1)), new Stop(0.4, Color.rgb(15, 15, 15)), new Stop(0.6, Color.rgb(153, 153, 153)), new Stop(0.8, Color.rgb(27, 10, 27)), new Stop(1.0, Color.rgb(27, 10, 27)))); alarmPane.getChildren().setAll(alarmMap.values()); Helper.drawAlarms(clock, size, 0.015, 0.46, alarmMap, DATE_TIME_FORMATTER, time); }
Example #19
Source File: FGauge.java From Medusa with Apache License 2.0 | 4 votes |
private void redraw() { double width = getWidth() - getInsets().getLeft() - getInsets().getRight(); double height = getHeight() - getInsets().getTop() - getInsets().getBottom(); size = width < height ? width : height; if (size > 0) { if (getWidth() > getHeight()) { setTranslateX(0.5 * (getWidth() - size)); } else if (getHeight() > getWidth()) { setTranslateY(0.5 * (getHeight() - size)); } frame.setPrefSize(size, size); frame.setBorder(gaugeDesign.getBorder(size)); background.setCenterX(size * 0.5); background.setCenterY(size * 0.5); background.setRadius(size * 0.4375); background.setFill(gaugeBackground.getPaint(background.getLayoutBounds().getMinX(), background.getLayoutBounds().getMinY(), background.getLayoutBounds().getMaxX(), background.getLayoutBounds().getMaxY())); switch(gaugeDesign) { case NONE: frame.setVisible(false); foreground.setVisible(false); background.setVisible(false); break; case ENZO: background.setFill(Color.rgb(240, 240, 240)); innerShadow.setRadius(0.07407407 * size); innerShadow.setOffsetX(0); innerShadow.setOffsetY(0.07407407 * size); innerShadow.setColor(Color.rgb(0, 0, 0, 0.35)); foreground.setFill(Color.TRANSPARENT); foreground.setStroke(null); break; default: frame.setVisible(true); foreground.setVisible(true); background.setVisible(true); innerShadow.setColor(Color.rgb(0, 0, 0, 0.65)); innerShadow.setRadius(0.08 * size); innerShadow.setOffsetX(0); innerShadow.setOffsetY(0.0 * size); foreground.setFill(new RadialGradient(0, 0, size * 0.5, size * gaugeDesign.FRAME_FACTOR * 0.5, size, false, CycleMethod.NO_CYCLE, new Stop(0, Color.rgb(255, 255, 255, 0.6)), new Stop(0.4, Color.TRANSPARENT))); foreground.setStroke(null); break; } gauge.setPrefSize(size * (1.0 - gaugeDesign.FRAME_FACTOR * 2.0), size * (1.0 - gaugeDesign.FRAME_FACTOR * 2.0)); gauge.relocate(gaugeDesign.FRAME_FACTOR * size, gaugeDesign.FRAME_FACTOR * size); foreground.setCenterX(size * 0.5); foreground.setCenterY(size * 0.5); foreground.setRadius(size * 0.42); } }
Example #20
Source File: DoodleTrace.java From gluon-samples with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Constructor taking the application's name. */ public DoodleTrace() { // Create the drawing surface Pane drawSurface = new Pane(); setCenter(drawSurface); // Initialize draw path drawPath = new Path(); drawPath.setStrokeWidth(3); drawPath.setStroke(Color.BLACK); drawSurface.getChildren().add(drawPath); // Initialize trace path tracePath = new Path(); tracePath.setStrokeWidth(3); tracePath.setStroke(Color.BLACK); drawSurface.getChildren().add(tracePath); // Ball tracer RadialGradient gradient1 = new RadialGradient( 0, 0, .5, .5, .55, true, CycleMethod.NO_CYCLE, new Stop(0, Color.RED), new Stop(1, Color.BLACK)); // Create a ball ball = new Circle(100, 100, 20, gradient1); // Add ball drawSurface.getChildren().add(ball); // Animation responsible for tracing the doodle tracerTimeline = new Timeline(); // Flag to prevent user from doodling during animation tracerTimeline.setOnFinished(ae3 -> animating = false); if (Platform.isDesktop()) { applyMouseInput(drawSurface); } else if (Platform.isAndroid() || Platform.isIOS()) { applyTouchInput(drawSurface); } }
Example #21
Source File: Led.java From Enzo with Apache License 2.0 | 4 votes |
private void draw() { double size = getWidth() < getHeight() ? getWidth() : getHeight(); canvas.setWidth(size); canvas.setHeight(size); ctx.clearRect(0, 0, size, size); if (isFrameVisible()) { //frame Paint frame = new LinearGradient(0.14 * size, 0.14 * size, 0.84 * size, 0.84 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, Color.rgb(20, 20, 20, 0.65)), new Stop(0.15, Color.rgb(20, 20, 20, 0.65)), new Stop(0.26, Color.rgb(41, 41, 41, 0.65)), new Stop(0.26, Color.rgb(41, 41, 41, 0.64)), new Stop(0.85, Color.rgb(200, 200, 200, 0.41)), new Stop(1.0, Color.rgb(200, 200, 200, 0.35))); ctx.setFill(frame); ctx.fillOval(0, 0, size, size); } InnerShadow innerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), 0.07 * size, 0, 0, 0); if (isOn()) { //on ctx.save(); Paint on = new LinearGradient(0.25 * size, 0.25 * size, 0.74 * size, 0.74 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, ((Color)ledColor.get()).deriveColor(0d, 1d, 0.77, 1d)), new Stop(0.49, ((Color)ledColor.get()).deriveColor(0d, 1d, 0.5, 1d)), new Stop(1.0, ((Color)ledColor.get()))); innerShadow.setInput(new DropShadow(BlurType.TWO_PASS_BOX, (Color)ledColor.get(), 0.36 * size, 0, 0, 0)); ctx.setEffect(innerShadow); ctx.setFill(on); ctx.fillOval(0.14 * size, 0.14 * size, 0.72 * size, 0.72 * size); ctx.restore(); } else { // off ctx.save(); Paint off = new LinearGradient(0.25 * size, 0.25 * size, 0.74 * size, 0.74 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, ((Color)ledColor.get()).deriveColor(0d, 1d, 0.20, 1d)), new Stop(0.49, ((Color)ledColor.get()).deriveColor(0d, 1d, 0.13, 1d)), new Stop(1.0, ((Color)ledColor.get()).deriveColor(0d, 1d, 0.2, 1d))); ctx.setEffect(innerShadow); ctx.setFill(off); ctx.fillOval(0.14 * size, 0.14 * size, 0.72 * size, 0.72 * size); ctx.restore(); } //highlight Paint highlight = new RadialGradient(0, 0, 0.3 * size, 0.3 * size, 0.29 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, Color.WHITE), new Stop(1.0, Color.TRANSPARENT)); ctx.setFill(highlight); ctx.fillOval(0.21 * size, 0.21 * size, 0.58 * size, 0.58 * size); }
Example #22
Source File: RadialBargraphSkin.java From Enzo with Apache License 2.0 | 4 votes |
private void resize() { size = getSkinnable().getWidth() < getSkinnable().getHeight() ? getSkinnable().getWidth() : getSkinnable().getHeight(); centerX = size * 0.5; centerY = size * 0.5; final double RADIUS = size * 0.5 - 2; valueBlendBottomShadow.setOffsetY(0.005 * size); valueBlendTopShadow.setOffsetY(0.005 * size); valueBlendTopShadow.setRadius(0.005 * size); dropShadow.setRadius(0.015 * size); dropShadow.setOffsetY(0.015 * size); background.setPrefSize(size, size); ticksAndSectionsCanvas.setWidth(size); ticksAndSectionsCanvas.setHeight(size); ticksAndSections.clearRect(0, 0, size, size); drawSections(ticksAndSections); drawTickMarks(ticksAndSections); ticksAndSectionsCanvas.setCache(true); ticksAndSectionsCanvas.setCacheHint(CacheHint.QUALITY); drawMarkers(); minMeasuredValue.setPrefSize(0.03 * size, 0.03 * size); minMeasuredValue.relocate((size - minMeasuredValue.getPrefWidth()) * 0.5, size * 0.11); minMeasuredValueRotate.setPivotX(minMeasuredValue.getPrefWidth() * 0.5); minMeasuredValueRotate.setPivotY(size * 0.39); minMeasuredValueRotate.setAngle(getSkinnable().getMinMeasuredValue() * angleStep - 180 - getSkinnable().getStartAngle()); maxMeasuredValue.setPrefSize(0.03 * size, 0.03 * size); maxMeasuredValue.relocate((size - maxMeasuredValue.getPrefWidth()) * 0.5, size * 0.11); maxMeasuredValueRotate.setPivotX(maxMeasuredValue.getPrefWidth() * 0.5); maxMeasuredValueRotate.setPivotY(size * 0.39); maxMeasuredValueRotate.setAngle(getSkinnable().getMaxMeasuredValue() * angleStep - 180 - getSkinnable().getStartAngle()); threshold.setPrefSize(0.06 * size, 0.055 * size); threshold.relocate((size - threshold.getPrefWidth()) * 0.5, size * 0.08); thresholdRotate.setPivotX(threshold.getPrefWidth() * 0.5); thresholdRotate.setPivotY(size * 0.42); thresholdRotate.setAngle(getSkinnable().getThreshold() * angleStep - 180 - getSkinnable().getStartAngle()); value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", (angle.get() / angleStep))); bar.setCenterX(centerX); bar.setCenterY(centerY); bar.setRadiusX(RADIUS); bar.setRadiusY(RADIUS); if (getSkinnable().isBarGradientEnabled()) { recalculateBarGradient(); Image image = barGradient.getImage(size, size); bar.setFill(new ImagePattern(image, 0, 0, size, size, false)); } else { bar.setFill(new RadialGradient(0, 0, centerX, centerY, RADIUS, false, CycleMethod.NO_CYCLE, new Stop(0.0, barColor), new Stop(0.76, barColor.deriveColor(-5, 1, 1, 1)), // -5 for on the barColorHue) new Stop(0.79, barColor), new Stop(0.97, barColor), new Stop(1.0, barColor.deriveColor(-5, 1, 1, 1)))); // -5 for on the barColorHue) } knob.setPrefSize(size * 0.75, size * 0.75); knob.setTranslateX((size - knob.getPrefWidth()) * 0.5); knob.setTranslateY((size - knob.getPrefHeight()) * 0.5); resizeText(); }
Example #23
Source File: Led.java From Enzo with Apache License 2.0 | 4 votes |
private void draw() { double size = getWidth() < getHeight() ? getWidth() : getHeight(); canvas.setWidth(size); canvas.setHeight(size); ctx.clearRect(0, 0, size, size); if (isFrameVisible()) { //frame Paint frame = new LinearGradient(0.14 * size, 0.14 * size, 0.84 * size, 0.84 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, Color.rgb(20, 20, 20, 0.65)), new Stop(0.15, Color.rgb(20, 20, 20, 0.65)), new Stop(0.26, Color.rgb(41, 41, 41, 0.65)), new Stop(0.26, Color.rgb(41, 41, 41, 0.64)), new Stop(0.85, Color.rgb(200, 200, 200, 0.41)), new Stop(1.0, Color.rgb(200, 200, 200, 0.35))); ctx.setFill(frame); ctx.fillOval(0, 0, size, size); } InnerShadow innerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), 0.07 * size, 0, 0, 0); if (isOn()) { //on ctx.save(); Paint on = new LinearGradient(0.25 * size, 0.25 * size, 0.74 * size, 0.74 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, ledColor.get().deriveColor(0d, 1d, 0.77, 1d)), new Stop(0.49, ledColor.get().deriveColor(0d, 1d, 0.5, 1d)), new Stop(1.0, ledColor.get())); innerShadow.setInput(new DropShadow(BlurType.TWO_PASS_BOX, ledColor.get(), 0.36 * size, 0, 0, 0)); ctx.setEffect(innerShadow); ctx.setFill(on); ctx.fillOval(0.14 * size, 0.14 * size, 0.72 * size, 0.72 * size); ctx.restore(); } else { // off ctx.save(); Paint off = new LinearGradient(0.25 * size, 0.25 * size, 0.74 * size, 0.74 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, ledColor.get().deriveColor(0d, 1d, 0.20, 1d)), new Stop(0.49, ledColor.get().deriveColor(0d, 1d, 0.13, 1d)), new Stop(1.0, ledColor.get().deriveColor(0d, 1d, 0.2, 1d))); ctx.setEffect(innerShadow); ctx.setFill(off); ctx.fillOval(0.14 * size, 0.14 * size, 0.72 * size, 0.72 * size); ctx.restore(); } //highlight Paint highlight = new RadialGradient(0, 0, 0.3 * size, 0.3 * size, 0.29 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, Color.WHITE), new Stop(1.0, Color.TRANSPARENT)); ctx.setFill(highlight); ctx.fillOval(0.21 * size, 0.21 * size, 0.58 * size, 0.58 * size); }
Example #24
Source File: LedSkin.java From JFX8CustomControls with Apache License 2.0 | 4 votes |
private void resize() { size = getSkinnable().getWidth() < getSkinnable().getHeight() ? getSkinnable().getWidth() : getSkinnable().getHeight(); frameFill = new LinearGradient(0.14 * size, 0.14 * size, 0.84 * size, 0.84 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, Color.color(0.0784313725, 0.0784313725, 0.0784313725, 0.6470588235)), new Stop(0.15, Color.color(0.0784313725, 0.0784313725, 0.0784313725, 0.6470588235)), new Stop(0.26, Color.color(0.1607843137, 0.1607843137, 0.1607843137, 0.6470588235)), new Stop(0.2600001, Color.color(0.1607843137, 0.1607843137, 0.1607843137, 0.6431372549)), new Stop(0.85, Color.color(0.7843137255, 0.7843137255, 0.7843137255, 0.4039215686)), new Stop(1.0, Color.color(0.7843137255, 0.7843137255, 0.7843137255, 0.3450980392))); frame.setRadius(0.5 * size); frame.setCenterX(0.5 * size); frame.setCenterY(0.5 * size); frame.setFill(frameFill); mainOnFill = new LinearGradient(0.25 * size, 0.25 * size, 0.74 * size, 0.74 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, Color.color(0.7098039216, 0, 0, 1)), new Stop(0.49, Color.color(0.4392156863, 0, 0, 1)), new Stop(1.0, Color.color(0.9843137255, 0, 0, 1))); mainOffFill = new LinearGradient(0.25 * size, 0.25 * size, 0.74 * size, 0.74 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, Color.color(0.2039215686, 0.0588235294, 0.0784313725, 1)), new Stop(0.49, Color.color(0.1450980392, 0, 0, 1)), new Stop(1.0, Color.color(0.2039215686, 0.0588235294, 0.0784313725, 1))); innerShadow.setRadius(0.07 * size); glow.setRadius(0.36 * size); glow.setColor((Color) getSkinnable().getLedColor()); main.setRadius(0.36 * size); main.setCenterX(0.5 * size); main.setCenterY(0.5 * size); if (getSkinnable().isOn()) { main.setFill(mainOnFill); main.setEffect(glow); } else { main.setFill(mainOffFill); main.setEffect(innerShadow); } highlightFill = new RadialGradient(0, 0, 0.3 * size, 0.3 * size, 0.29 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, Color.WHITE), new Stop(1.0, Color.TRANSPARENT)); highlight.setRadius(0.29 * size); highlight.setCenterX(0.5 * size); highlight.setCenterY(0.5 * size); highlight.setFill(highlightFill); }
Example #25
Source File: FXAdvancedLinearGradientPicker.java From gef with Eclipse Public License 2.0 | 3 votes |
/** * Returns <code>true</code> if the given {@link Paint} is considered to be * an "advanced" gradient. Otherwise returns <code>false</code>. An advanced * gradient can either be a linear gradient with at least 3 stops, or any * radial gradient. * * @param paint * The {@link Paint} in question. * @return <code>true</code> if the given {@link Paint} is considered to be * an "advanced" gradient, othwerise <code>false</code>. */ public static boolean isAdvancedLinearGradient(Paint paint) { if (paint instanceof LinearGradient) { return ((LinearGradient) paint).getStops().size() > 2; } else if (paint instanceof RadialGradient) { return true; } return false; }