javafx.scene.paint.Stop Java Examples
The following examples show how to use
javafx.scene.paint.Stop.
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: ThermometerRepresentation.java From phoebus with Eclipse Public License 1.0 | 6 votes |
Thermo(Color color) { setFill(color); fill.setArcHeight(6); fill.setArcWidth(6); fill.setManaged(false); border.setFill(new LinearGradient(.3, 0, .7, 0, true, CycleMethod.NO_CYCLE, new Stop(0, Color.LIGHTGRAY), new Stop(.3, Color.WHITESMOKE), new Stop(1, Color.LIGHTGRAY))); border.setStroke(Color.BLACK); arc.setLargeArcFlag(true); rightcorner.setY(0); getChildren().add(border); getChildren().add(fill); getChildren().add(ellipse); setBorder(new Border( new BorderStroke(Color.BLACK, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderWidths.DEFAULT))); }
Example #2
Source File: InteractiveGaugeSkin.java From medusademo with Apache License 2.0 | 6 votes |
private void drawGradientBar() { double xy = TickLabelLocation.OUTSIDE == tickLabelLocation ? 0.115 * size : 0.0515 * size; double wh = TickLabelLocation.OUTSIDE == tickLabelLocation ? size * 0.77 : size * 0.897; double offset = 90 - startAngle; List<Stop> stops = getSkinnable().getGradientBarStops(); Map<Double, Color> stopAngleMap = new HashMap<>(stops.size()); for (Stop stop : stops) { stopAngleMap.put(stop.getOffset() * angleRange, stop.getColor()); } double offsetFactor = ScaleDirection.CLOCKWISE == scaleDirection ? (startAngle - 90) : (startAngle + 180); AngleConicalGradient gradient = new AngleConicalGradient(size * 0.5, size * 0.5, offsetFactor, stopAngleMap, getSkinnable().getScaleDirection()); double barStartAngle = ScaleDirection.CLOCKWISE == scaleDirection ? -minValue * angleStep : minValue * angleStep; double barAngleExtend = ScaleDirection.CLOCKWISE == scaleDirection ? getSkinnable().getRange() * angleStep : -getSkinnable().getRange() * angleStep; tickMarkCtx.save(); tickMarkCtx.setStroke(gradient.getImagePattern(new Rectangle(xy - 0.026 * size, xy - 0.026 * size, wh + 0.052 * size, wh + 0.052 * size))); tickMarkCtx.setLineWidth(size * 0.052); tickMarkCtx.setLineCap(StrokeLineCap.BUTT); tickMarkCtx.strokeArc(xy, xy, wh, wh, -(offset + barStartAngle), -barAngleExtend, ArcType.OPEN); tickMarkCtx.restore(); }
Example #3
Source File: HeatTabController.java From marathonv5 with Apache License 2.0 | 6 votes |
/** * Get the color at the give {@code position} in the ladder of color stops */ private static Color ladder(final double position, final Stop[] stops) { Stop prevStop = null; for (int i=0; i<stops.length; i++) { Stop stop = stops[i]; if(position <= stop.getOffset()){ if (prevStop == null) { return stop.getColor(); } else { return interpolateLinear((position-prevStop.getOffset())/(stop.getOffset()-prevStop.getOffset()), prevStop.getColor(), stop.getColor()); } } prevStop = stop; } // position is greater than biggest stop, so will we biggest stop's color return prevStop.getColor(); }
Example #4
Source File: ConicalGradient.java From Medusa with Apache License 2.0 | 6 votes |
private List<Stop> normalizeStops(final double OFFSET, final List<Stop> STOPS) { double offset = Helper.clamp(0.0, 1.0, OFFSET); List<Stop> stops; if (null == STOPS || STOPS.isEmpty()) { stops = new ArrayList<>(); stops.add(new Stop(0.0, Color.TRANSPARENT)); stops.add(new Stop(1.0, Color.TRANSPARENT)); } else { stops = STOPS; } List<Stop> sortedStops = calculate(stops, offset); // Reverse the Stops for CCW direction if (ScaleDirection.COUNTER_CLOCKWISE == scaleDirection) { List<Stop> sortedStops3 = new ArrayList<>(); Collections.reverse(sortedStops); for (Stop stop : sortedStops) { sortedStops3.add(new Stop(1.0 - stop.getOffset(), stop.getColor())); } sortedStops = sortedStops3; } return sortedStops; }
Example #5
Source File: GaugeSkin.java From Medusa with Apache License 2.0 | 6 votes |
private void drawGradientBar() { double xy = TickLabelLocation.OUTSIDE == tickLabelLocation ? 0.115 * size : 0.0515 * size; double wh = TickLabelLocation.OUTSIDE == tickLabelLocation ? size * 0.77 : size * 0.897; double offset = 90 - startAngle; List<Stop> stops = gauge.getGradientBarStops(); Map<Double, Color> stopAngleMap = new HashMap<>(stops.size()); for (Stop stop : stops) { stopAngleMap.put(stop.getOffset() * angleRange, stop.getColor()); } double offsetFactor = ScaleDirection.CLOCKWISE == scaleDirection ? (startAngle - 90) : (startAngle + 180); AngleConicalGradient gradient = new AngleConicalGradient(size * 0.5, size * 0.5, offsetFactor, stopAngleMap, gauge.getScaleDirection()); double barStartAngle = ScaleDirection.CLOCKWISE == scaleDirection ? -minValue * angleStep : minValue * angleStep; double barAngleExtend = ScaleDirection.CLOCKWISE == scaleDirection ? gauge.getRange() * angleStep : -gauge.getRange() * angleStep; tickMarkCtx.save(); tickMarkCtx.setStroke(gradient.getImagePattern(new Rectangle(xy - 0.026 * size, xy - 0.026 * size, wh + 0.052 * size, wh + 0.052 * size))); tickMarkCtx.setLineWidth(size * 0.052); tickMarkCtx.setLineCap(StrokeLineCap.BUTT); tickMarkCtx.strokeArc(xy, xy, wh, wh, -(offset + barStartAngle), -barAngleExtend, ArcType.OPEN); tickMarkCtx.restore(); }
Example #6
Source File: ModernSkin.java From Medusa with Apache License 2.0 | 6 votes |
public void handleMouseEvent(final MouseEvent EVENT) { if (gauge.isDisabled()) return; final EventType TYPE = EVENT.getEventType(); if (MouseEvent.MOUSE_PRESSED.equals(TYPE)) { gauge.fireEvent(gauge.BTN_PRESSED_EVENT); centerKnob.setFill(new LinearGradient(0.5 * size, 0.2708333333333333 * size, 0.5 * size, 0.7291666666666666 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, Color.rgb(31, 31, 31)), new Stop(1.0, Color.rgb(69, 70, 73)))); valueText.setTranslateY(size * 0.501); subTitleText.setTranslateY(size * 0.3525); unitText.setTranslateY(size * 0.6675); } else if (MouseEvent.MOUSE_RELEASED.equals(TYPE)) { gauge.fireEvent(gauge.BTN_RELEASED_EVENT); centerKnob.setFill(new LinearGradient(0.5 * size, 0.2708333333333333 * size, 0.5 * size, 0.7291666666666666 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, Color.rgb(69, 70, 73)), new Stop(1.0, Color.rgb(31, 31, 31)))); valueText.setTranslateY(size * 0.5); subTitleText.setTranslateY(size * 0.35); unitText.setTranslateY(size * 0.67); } }
Example #7
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 #8
Source File: ScatterChartPane.java From constellation with Apache License 2.0 | 6 votes |
public ScatterChartPane(final ScatterPlotPane parent) { this.scatterPlot = parent; final LinearGradient gradient = new LinearGradient(0.0, 0.0, 0.0, 0.75, true, CycleMethod.NO_CYCLE, new Stop[]{new Stop(0, Color.LIGHTGRAY), new Stop(1, Color.GRAY.darker())}); this.selection = new Rectangle(0, 0, 0, 0); selection.setFill(Color.WHITE); selection.setStroke(Color.BLACK); selection.setOpacity(0.4); selection.setMouseTransparent(true); selection.setStroke(Color.SILVER); selection.setStrokeWidth(2d); selection.setFill(gradient); selection.setSmooth(true); selection.setArcWidth(5.0); selection.setArcHeight(5.0); this.tooltip = new Tooltip(); this.currentData = Collections.synchronizedSet(new HashSet<>()); this.currentSelectedData = new HashSet<>(); this.getChildren().addAll(selection); this.setId("scatter-chart-pane"); this.setPadding(new Insets(5)); }
Example #9
Source File: SectionSkin.java From Medusa with Apache License 2.0 | 6 votes |
@Override protected void redraw() { sectionsVisible = gauge.getSectionsVisible(); drawSections(); needle.setFill(new LinearGradient(needle.getLayoutBounds().getMinX(), 0, needle.getLayoutBounds().getMaxX(), 0, false, CycleMethod.NO_CYCLE, new Stop(0.0, gauge.getNeedleColor().darker()), new Stop(0.5, gauge.getNeedleColor()), new Stop(1.0, gauge.getNeedleColor().darker()))); titleText.setFill(gauge.getTitleColor()); valueText.setFill(gauge.getValueColor()); mask.setFill(gauge.getBackgroundPaint()); knob.setFill(gauge.getKnobColor()); titleText.setText(gauge.getTitle()); resizeText(); }
Example #10
Source File: QuarterSkin.java From Medusa with Apache License 2.0 | 6 votes |
private void drawGradientBar() { Pos knobPosition = gauge.getKnobPosition(); TickLabelLocation tickLabelLocation = gauge.getTickLabelLocation(); double scaledSize = size * 1.9; double xy = TickLabelLocation.OUTSIDE == tickLabelLocation ? 0.105 * scaledSize : 0.03875 * scaledSize; double wh = TickLabelLocation.OUTSIDE == tickLabelLocation ? scaledSize * 0.79 : scaledSize * 0.925; double offsetX = Pos.TOP_LEFT == knobPosition || Pos.BOTTOM_LEFT == knobPosition ? -scaledSize * 0.475 : 0; double offsetY = Pos.TOP_LEFT == knobPosition || Pos.TOP_RIGHT == knobPosition ? -scaledSize * 0.475 : 0; double offset = 90 - startAngle; ScaleDirection scaleDirection = gauge.getScaleDirection(); List<Stop> stops = gauge.getGradientBarStops(); Map<Double, Color> stopAngleMap = new HashMap<>(stops.size()); for (Stop stop : stops) { stopAngleMap.put(stop.getOffset() * ANGLE_RANGE, stop.getColor()); } double offsetFactor = ScaleDirection.CLOCKWISE == scaleDirection ? (Pos.TOP_LEFT == knobPosition || Pos.BOTTOM_RIGHT == knobPosition ? startAngle : 180 - startAngle) : (startAngle + 180); AngleConicalGradient gradient = new AngleConicalGradient(scaledSize * 0.5, scaledSize * 0.5, offsetFactor, stopAngleMap, gauge.getScaleDirection()); double barStartAngle = ScaleDirection.CLOCKWISE == scaleDirection ? -minValue * angleStep : minValue * angleStep; double barAngleExtend = ScaleDirection.CLOCKWISE == scaleDirection ? gauge.getRange() * angleStep : -gauge.getRange() * angleStep; tickMarkCtx.save(); tickMarkCtx.setStroke(gradient.getImagePattern(new Rectangle(xy - 0.026 * scaledSize + offsetX, xy - 0.026 * scaledSize + offsetY, wh + 0.052 * scaledSize, wh + 0.052 * scaledSize))); tickMarkCtx.setLineWidth(scaledSize * 0.052); tickMarkCtx.setLineCap(StrokeLineCap.BUTT); tickMarkCtx.strokeArc(xy + offsetX, xy + offsetY, wh, wh, -(offset + barStartAngle), -barAngleExtend, ArcType.OPEN); tickMarkCtx.restore(); }
Example #11
Source File: VSkin.java From Medusa with Apache License 2.0 | 6 votes |
private void drawGradientBar() { TickLabelLocation tickLabelLocation = gauge.getTickLabelLocation(); double scaledHeight = height * 0.9; double xy = TickLabelLocation.OUTSIDE == tickLabelLocation ? 0.1705 * scaledHeight : 0.107 * scaledHeight; double wh = TickLabelLocation.OUTSIDE == tickLabelLocation ? scaledHeight * 0.77 : scaledHeight * 0.897; double offset = 90 - startAngle; double offsetX = -0.1 * width; double knobPositionOffsetCW = Pos.CENTER_LEFT == gauge.getKnobPosition() ? 90 : 270; double knobPositionOffsetCCW = Pos.CENTER_LEFT == gauge.getKnobPosition() ? 180 : 0; ScaleDirection scaleDirection = gauge.getScaleDirection(); List<Stop> stops = gauge.getGradientBarStops(); Map<Double, Color> stopAngleMap = new HashMap<>(stops.size()); for (Stop stop : stops) { stopAngleMap.put(stop.getOffset() * angleRange, stop.getColor()); } double offsetFactor = ScaleDirection.CLOCKWISE == scaleDirection ? knobPositionOffsetCW - angleRange * 0.5 : angleRange - (angleRange / 180 * angleRange) + knobPositionOffsetCCW; AngleConicalGradient gradient = new AngleConicalGradient(width * 0.5, width * 0.5, offsetFactor, stopAngleMap, gauge.getScaleDirection()); double barStartAngle = ScaleDirection.CLOCKWISE == scaleDirection ? -minValue * angleStep : minValue * angleStep; double barAngleExtend = ScaleDirection.CLOCKWISE == scaleDirection ? gauge.getRange() * angleStep : -gauge.getRange() * angleStep; tickMarkCtx.save(); tickMarkCtx.setStroke(gradient.getImagePattern(new Rectangle(xy - 0.026 * height + offsetX, xy - 0.026 * height, wh + 0.052 * height, wh + 0.052 * height))); tickMarkCtx.setLineWidth(scaledHeight * 0.052); tickMarkCtx.setLineCap(StrokeLineCap.BUTT); tickMarkCtx.strokeArc(xy + offsetX, xy, wh, wh, -(offset + barStartAngle), -barAngleExtend, ArcType.OPEN); tickMarkCtx.restore(); }
Example #12
Source File: QualityGauge.java From mars-sim with GNU General Public License v3.0 | 5 votes |
private void updateValue() { double value = model.getValue(); if (value == 0) { currentQuality.setFill(Color.TRANSPARENT); currentQuality.setStroke(Color.TRANSPARENT); currentQualityText.setFill(Color.TRANSPARENT); currentQualityText.setText(""); knob.setFill(Color.web("#cccccc")); } else { currentQualityRotate.setAngle(279 + ((int) value) * sectionAngle - sectionAngle); double radius = width * 0.45; double sinValue = Math.sin(Math.toRadians(currentQualityRotate.getAngle() + (-sectionAngle * ((int) value + 0.5) + model.getStartAngle() + 270 + sectionAngle))); double cosValue = Math.cos(Math.toRadians(currentQualityRotate.getAngle() + (-sectionAngle * ((int) value + 0.5) + model.getStartAngle() + 270 + sectionAngle))); Color sectionColor = model.getSections().get((int) value - 1).getColor().deriveColor(0, 2.5, 1, 1); LinearGradient currentQualityFill = new LinearGradient(centerX + radius * sinValue, centerY + radius * cosValue, centerX, centerY, false, CycleMethod.NO_CYCLE, new Stop(0.0, sectionColor), new Stop(0.22, sectionColor), new Stop(0.22, sectionColor.deriveColor(0, 0.7, 1.1, 1)), new Stop(1.0, sectionColor.deriveColor(0, 0.7, 1.1, 1))); currentQuality.setFill(currentQualityFill); currentQuality.setStroke(Color.WHITE); sinValue = Math.sin(Math.toRadians(-sectionAngle * ((int) value + 0.5) + model.getStartAngle() + 270 + sectionAngle)); cosValue = Math.cos(Math.toRadians(-sectionAngle * ((int) value + 0.5) + model.getStartAngle() + 270 + sectionAngle)); currentQualityText.setFont(Fonts.latoBold(height * 0.14860681)); currentQualityText.setText(model.getSections().get((int) value - 1).getText()); currentQualityText.setFill(Color.WHITE); currentQualityText.setX(centerX - (currentQualityText.getLayoutBounds().getWidth() * 0.55) + radius * sinValue); currentQualityText.setY(centerY + radius * cosValue); knob.setFill(sectionColor); } }
Example #13
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 #14
Source File: Cluster.java From constellation with Apache License 2.0 | 5 votes |
/** * Constructs a new <code>ClusterRectangle</code> instance. */ public ClusterRectangle() { super(0, 0, 0, 40); // Round the edges of the rectangle: setArcWidth(5.0); setArcHeight(5.0); // Make slightly transparent: setOpacity(0.65); // Set a gradient for the percentage selected: final float percentage = 1 - (float) selectedCount / (float) count; if (anyNodesSelected && percentage == 1) { setStrokeWidth(3); setStroke(Color.YELLOW.deriveColor(0, 1, 1, 0.5)); } else { setStrokeWidth(0); } // 'Blue' or unselected items represent 0% of the total: if (percentage == 0) { setFill(Color.RED.darker()); } else { final LinearGradient gradient = new LinearGradient(0.0, 0.0, 0.0, percentage, true, CycleMethod.NO_CYCLE, new Stop[]{ new Stop(percentage, Color.DODGERBLUE), new Stop(1, Color.RED.darker()) }); setFill(gradient); } }
Example #15
Source File: RadarNodeChart.java From tilesfx with Apache License 2.0 | 5 votes |
public RadarNodeChart(final List<ChartData> DATA) { _minValue = 0; _maxValue = 100; _range = 100; _threshold = 100; _noOfSectors = MIN_NO_OF_SECTORS; _unit = ""; _legendVisible = false; _thresholdVisible = false; _mode = RadarChartMode.POLYGON; gradientStops = FXCollections.observableArrayList(); decimals = 0; formatString = new StringBuilder("%.").append(decimals).append("f").toString(); data = FXCollections.observableArrayList(); legendScaleFactor = 1.0; _smoothing = false; _chartBackgroundColor = Color.TRANSPARENT; _chartForegroundColor = Tile.FOREGROUND; _chartTextColor = Tile.FOREGROUND; _gridColor = Tile.GRAY; _chartFill = Tile.BLUE; _thresholdColor = Tile.LIGHT_RED; resizeListener = o -> resize(); gradientListener = change -> { stops.clear(); 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())); } redraw(); }; init(); initGraphics(); initData(DATA); registerListeners(); }
Example #16
Source File: GradientLookup.java From regulators with Apache License 2.0 | 5 votes |
private Color interpolateColor(final Stop LOWER_BOUND, final Stop UPPER_BOUND, final double POSITION) { final double POS = (POSITION - LOWER_BOUND.getOffset()) / (UPPER_BOUND.getOffset() - LOWER_BOUND.getOffset()); final double DELTA_RED = (UPPER_BOUND.getColor().getRed() - LOWER_BOUND.getColor().getRed()) * POS; final double DELTA_GREEN = (UPPER_BOUND.getColor().getGreen() - LOWER_BOUND.getColor().getGreen()) * POS; final double DELTA_BLUE = (UPPER_BOUND.getColor().getBlue() - LOWER_BOUND.getColor().getBlue()) * POS; final double DELTA_OPACITY = (UPPER_BOUND.getColor().getOpacity() - LOWER_BOUND.getColor().getOpacity()) * POS; double red = clamp(0.0, 1.0, (LOWER_BOUND.getColor().getRed() + DELTA_RED)); double green = clamp(0.0, 1.0, (LOWER_BOUND.getColor().getGreen() + DELTA_GREEN)); double blue = clamp(0.0, 1.0, (LOWER_BOUND.getColor().getBlue() + DELTA_BLUE)); double opacity = clamp(0.0, 1.0, (LOWER_BOUND.getColor().getOpacity() + DELTA_OPACITY)); return Color.color(red, green, blue, opacity); }
Example #17
Source File: GradientLookup.java From tilesfx with Apache License 2.0 | 5 votes |
private void init() { if (stops.isEmpty()) return; double minFraction = Collections.min(stops.keySet()); double maxFraction = Collections.max(stops.keySet()); if (Double.compare(minFraction, 0) > 0) { stops.put(0.0, new Stop(0.0, stops.get(minFraction).getColor())); } if (Double.compare(maxFraction, 1) < 0) { stops.put(1.0, new Stop(1.0, stops.get(maxFraction).getColor())); } }
Example #18
Source File: SimpleHSBColorPicker.java From marathonv5 with Apache License 2.0 | 5 votes |
private LinearGradient buildHueBar() { double offset; Stop[] stops = new Stop[255]; for (int y = 0; y < 255; y++) { offset = (double) (1.0 / 255) * y; int h = (int)((y / 255.0) * 360); stops[y] = new Stop(offset, Color.hsb(h, 1.0, 1.0)); } return new LinearGradient(0f, 0f, 1f, 0f, true, CycleMethod.NO_CYCLE, stops); }
Example #19
Source File: ColorSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public static Node createIconContent() { double offset; Stop[] stops = new Stop[255]; for (int y = 0; y < 255; y++) { offset = (double) (1.0 / 255) * y; int h = (int)((y / 255.0) * 360); stops[y] = new Stop(offset, Color.hsb(h, 0.8, 0.9)); } Rectangle rect = new Rectangle(80,80, new LinearGradient(0f, 0f, 1f, 1f, true, CycleMethod.NO_CYCLE, stops)); rect.setArcWidth(20); rect.setArcHeight(20); return rect; }
Example #20
Source File: LinearGradientSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public static Node createIconContent() { Rectangle rect = new Rectangle(80,80,new LinearGradient(0, 0, 1, 0, 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 #21
Source File: HeatControlSkin.java From Enzo with Apache License 2.0 | 5 votes |
private void adjustBackgroundColor() { Color color = gradientLookup.getColorAt(getSkinnable().getValue() / (getSkinnable().getMaxValue() - getSkinnable().getMinValue())); background.setFill(new LinearGradient(0, 0, 0, size, false, CycleMethod.NO_CYCLE, new Stop(0, color.deriveColor(0, 1, 0.8, 1)), new Stop(1, color.deriveColor(0, 1, 0.6, 1)))); }
Example #22
Source File: StopWatch.java From netbeans with Apache License 2.0 | 5 votes |
private void configureDesign() { rectangleVisual.setLayoutY(0f); rectangleVisual.setLayoutX(-14); rectangleVisual.setFill(Color.TRANSPARENT); rectangleSmall.setLayoutX(-7); rectangleSmall.setLayoutY(5); rectangleSmall.setFill(new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, new Stop[]{ new Stop(0, colorWeak), new Stop(0.5, colorStrong), new Stop(1, colorWeak)})); rectangleBig.setLayoutX(-14); rectangleBig.setLayoutY(0); rectangleBig.setFill(new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, new Stop[]{ new Stop(0, colorStrong), new Stop(0.5, colorWeak), new Stop(1, colorStrong)})); rectangleWatch.setFill(new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, new Stop[]{ new Stop(0, Color.web("#4e605f")), new Stop(0.2, Color.web("#c3d6d5")), new Stop(0.5, Color.web("#f9ffff")), new Stop(0.8, Color.web("#c3d6d5")), new Stop(1, Color.web("#4e605f"))})); rectangleWatch.setLayoutX(-12); rectangleWatch.setLayoutY(12); }
Example #23
Source File: ViewSingleShape.java From latexdraw with GNU General Public License v3.0 | 5 votes |
private LinearGradient computeRotatedGradient(final double angle, final double gradMidPt, final Point tl, final Point br) { Point pt1; Point pt2; if(MathUtils.INST.equalsDouble(angle % (Math.PI / 2d), 0d)) { pt1 = ShapeFactory.INST.createPoint(tl.getX(), (tl.getY() + br.getY()) / 2d); pt2 = ShapeFactory.INST.createPoint(br.getX(), (tl.getY() + br.getY()) / 2d); if(gradMidPt < 0.5) { pt1.setX(pt2.getX() - Point2D.distance(pt2.getX(), pt2.getY(), br.getX(), (tl.getY() + br.getY()) / 2d)); } pt2.setX(tl.getX() + (br.getX() - tl.getX()) * gradMidPt); }else { final Line l2; final Point cg = model.getGravityCentre(); pt1 = ShapeFactory.INST.createPoint((tl.getX() + br.getX()) / 2d, tl.getY()).rotatePoint(cg, -angle); pt2 = ShapeFactory.INST.createPoint((tl.getX() + br.getX()) / 2d, br.getY()).rotatePoint(cg, -angle); final Line l = ShapeFactory.INST.createLine(pt1, pt2); if(angle >= 0d && angle < Math.PI / 2d) { l2 = l.getPerpendicularLine(tl); }else { l2 = l.getPerpendicularLine(ShapeFactory.INST.createPoint(tl.getX(), br.getY())); } pt1 = l.getIntersection(l2); l.setX1(pt1.getX()); l.setY1(pt1.getY()); pt2 = l.findPoints(pt1, 2d * Point2D.distance(cg.getX(), cg.getY(), pt1.getX(), pt1.getY()) * gradMidPt)[0]; if(gradMidPt < 0.5) { pt1 = pt1.rotatePoint(model.getGravityCentre(), Math.PI); } } return new LinearGradient(pt1.getX(), pt1.getY(), pt2.getX(), pt2.getY(), false, CycleMethod.NO_CYCLE, new Stop(0d, model.getGradColStart().toJFX()), new Stop(1d, model.getGradColEnd().toJFX())); }
Example #24
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 #25
Source File: Helper.java From OEE-Designer with MIT License | 5 votes |
public static final Color interpolateColor(final Stop LOWER_BOUND, final Stop UPPER_BOUND, final double POSITION) { final double POS = (POSITION - LOWER_BOUND.getOffset()) / (UPPER_BOUND.getOffset() - LOWER_BOUND.getOffset()); final double DELTA_RED = (UPPER_BOUND.getColor().getRed() - LOWER_BOUND.getColor().getRed()) * POS; final double DELTA_GREEN = (UPPER_BOUND.getColor().getGreen() - LOWER_BOUND.getColor().getGreen()) * POS; final double DELTA_BLUE = (UPPER_BOUND.getColor().getBlue() - LOWER_BOUND.getColor().getBlue()) * POS; final double DELTA_OPACITY = (UPPER_BOUND.getColor().getOpacity() - LOWER_BOUND.getColor().getOpacity()) * POS; double red = clamp(0, 1, (LOWER_BOUND.getColor().getRed() + DELTA_RED)); double green = clamp(0, 1, (LOWER_BOUND.getColor().getGreen() + DELTA_GREEN)); double blue = clamp(0, 1, (LOWER_BOUND.getColor().getBlue() + DELTA_BLUE)); double opacity = clamp(0, 1, (LOWER_BOUND.getColor().getOpacity() + DELTA_OPACITY)); return Color.color(red, green, blue, opacity); }
Example #26
Source File: FeedbackRegulator.java From regulators with Apache License 2.0 | 5 votes |
private List<Stop> reorderStops(final List<Stop> STOPS) { /* 0.0 -> 0.611 0.5 -> 0.0 & 1.0 1.0 -> 0.389 */ double range = 0.778; double halfRange = range * 0.5; Map<Double, Color> stopMap = new HashMap<>(); for (Stop stop : STOPS) { stopMap.put(stop.getOffset(), stop.getColor()); } List<Stop> sortedStops = new ArrayList<>(STOPS.size()); SortedSet<Double> sortedFractions = new TreeSet<>(stopMap.keySet()); if (sortedFractions.last() < 1) { stopMap.put(1.0, stopMap.get(sortedFractions.last())); sortedFractions.add(1.0); } if (sortedFractions.first() > 0) { stopMap.put(0.0, stopMap.get(sortedFractions.first())); sortedFractions.add(0.0); } for (double fraction : sortedFractions) { double offset = fraction * range - halfRange; offset = offset < 0 ? 1.0 + offset : offset; sortedStops.add(new Stop(offset, stopMap.get(fraction))); } return sortedStops; }
Example #27
Source File: InfluenceAnalysisUI.java From SONDY with GNU General Public License v3.0 | 5 votes |
public final void updateRankDistributionChart(){ Stop[] stops = new Stop[] { new Stop(0, Color.STEELBLUE), new Stop(0.5, Color.YELLOW), new Stop(1, Color.RED)}; rankDistributionChart.getData().clear(); int[] rankDistribution = selectedMethod.rankedUsers.extractRankDistribution(); XYChart.Series series = new XYChart.Series(); for(int i = 0; i < rankDistribution.length; i++){ series.getData().add(new XYChart.Data(i+"",rankDistribution[i])); } rankDistributionChart.getData().add(series); }
Example #28
Source File: Gauge2TileSkin.java From tilesfx with Apache License 2.0 | 5 votes |
private void createConicalGradient() { List<Stop> stops = tile.getGradientStops(); Map<Double, Color> stopAngleMap = new HashMap<>(stops.size()); for (Stop stop : stops) { stopAngleMap.put(stop.getOffset() * angleRange, stop.getColor()); } double offsetFactor = (tile.getStartAngle() - 90); conicalGradient = new AngleConicalGradient(barBounds.getX() * barBounds.getWidth() * 0.5, barBounds.getY() * barBounds.getHeight() * 0.5, offsetFactor, stopAngleMap); }
Example #29
Source File: LinearGradientSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public LinearGradientSample() { //First rectangle Rectangle rect1 = new Rectangle(0,0,80,80); //create simple linear gradient LinearGradient gradient1 = new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, new Stop[] { new Stop(0, Color.DODGERBLUE), new Stop(1, Color.BLACK) }); //set rectangle fill rect1.setFill(gradient1); // Second rectangle Rectangle rect2 = new Rectangle(0,0,80,80); //create complex linear gradient LinearGradient gradient2 = new LinearGradient(0, 0, 0, 0.5, true, CycleMethod.REFLECT, new Stop[] { new Stop(0, Color.DODGERBLUE), new Stop(0.1, Color.BLACK), new Stop(1, Color.DODGERBLUE) }); //set rectangle fill rect2.setFill(gradient2); // show the rectangles HBox hb = new HBox(10); hb.getChildren().addAll(rect1, rect2); getChildren().add(hb); }
Example #30
Source File: GradientLookup.java From charts with Apache License 2.0 | 5 votes |
public List<Stop> getStopsBetween(final double MIN_OFFSET, final double MAX_OFFSET) { List<Stop> selectedStops = new ArrayList<>(); for (Entry<Double, Stop> entry : stops.entrySet()) { if (entry.getValue().getOffset() >= MIN_OFFSET && entry.getValue().getOffset() <= MAX_OFFSET) { selectedStops.add(entry.getValue()); } } return selectedStops; }