javafx.scene.paint.CycleMethod Java Examples

The following examples show how to use javafx.scene.paint.CycleMethod. 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 vote down vote up
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: ThermoDemo.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
Thermo(Color color)
{
    setFill(color);

    fill.setArcHeight(3);
    fill.setArcWidth(3);
    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);

    getChildren().add(border);
    getChildren().add(fill);
    getChildren().add(ellipse);
    setBorder(new Border(
            new BorderStroke(Color.BLACK, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderWidths.DEFAULT)));
}
 
Example #3
Source File: RadialGradientSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
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 #4
Source File: AreaHeatMap.java    From charts with Apache License 2.0 6 votes vote down vote up
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: SparkLineTileSkin.java    From tilesfx with Apache License 2.0 6 votes vote down vote up
private void setupGradient() {
    double loFactor = (low - minValue) / tile.getRange();
    double hiFactor = (high - minValue) / tile.getRange();
    Stop   loStop   = new Stop(loFactor, gradientLookup.getColorAt(loFactor));
    Stop   hiStop   = new Stop(hiFactor, gradientLookup.getColorAt(hiFactor));

    List<Stop> stopsInBetween = gradientLookup.getStopsBetween(loFactor, hiFactor);

    double     range  = hiFactor - loFactor;
    double     factor = 1.0 / range;
    List<Stop> stops  = new ArrayList<>();
    stops.add(new Stop(0, loStop.getColor()));
    for (Stop stop : stopsInBetween) {
        stops.add(new Stop((stop.getOffset() - loFactor) * factor, stop.getColor()));
    }
    stops.add(new Stop(1, hiStop.getColor()));

    gradient = new LinearGradient(0, graphBounds.getY() + graphBounds.getHeight(), 0, graphBounds.getY(), false, CycleMethod.NO_CYCLE, stops);
}
 
Example #6
Source File: GaugeSparkLineTileSkin.java    From tilesfx with Apache License 2.0 6 votes vote down vote up
private void setupGradient() {
    double loFactor = (low - minValue) / tile.getRange();
    double hiFactor = (high - minValue) / tile.getRange();
    Stop   loStop   = new Stop(loFactor, gradientLookup.getColorAt(loFactor));
    Stop   hiStop   = new Stop(hiFactor, gradientLookup.getColorAt(hiFactor));

    List<Stop> stopsInBetween = gradientLookup.getStopsBetween(loFactor, hiFactor);

    double     range  = hiFactor - loFactor;
    double     factor = 1.0 / range;
    List<Stop> stops  = new ArrayList<>();
    stops.add(new Stop(0, loStop.getColor()));
    for (Stop stop : stopsInBetween) {
        stops.add(new Stop((stop.getOffset() - loFactor) * factor, stop.getColor()));
    }
    stops.add(new Stop(1, hiStop.getColor()));

    gradient = new LinearGradient(0, graphBounds.getY() + graphBounds.getHeight(), 0, graphBounds.getY(), false, CycleMethod.NO_CYCLE, stops);
}
 
Example #7
Source File: RadialGradientSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
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 #8
Source File: SectionSkin.java    From Medusa with Apache License 2.0 6 votes vote down vote up
private void createNeedle() {
    double needleWidth  = size * 0.04;
    double needleHeight = size * 0.4675;
    needle.getElements().clear();
    needle.getElements().add(new MoveTo(0.3125 * needleWidth, 0.015957446808510637 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.3125 * needleWidth, 0.005319148936170213 * needleHeight,
                                              0.4375 * needleWidth, 0.0,
                                              0.5 * needleWidth, 0.0));
    needle.getElements().add(new CubicCurveTo(0.5625 * needleWidth, 0.0,
                                              0.6875 * needleWidth, 0.005319148936170213 * needleHeight,
                                              0.6875 * needleWidth, 0.015957446808510637 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.6875 * needleWidth, 0.015957446808510637 * needleHeight,
                                              needleWidth, 0.9946808510638298 * needleHeight,
                                              needleWidth, 0.9946808510638298 * needleHeight));
    needle.getElements().add(new LineTo(0.0, 0.9946808510638298 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.0, 0.9946808510638298 * needleHeight,
                                              0.3125 * needleWidth, 0.015957446808510637 * needleHeight,
                                              0.3125 * needleWidth, 0.015957446808510637 * needleHeight));
    needle.getElements().add(new ClosePath());
    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())));
}
 
Example #9
Source File: SectionSkin.java    From Medusa with Apache License 2.0 6 votes vote down vote up
@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: Overlay1Controller.java    From examples-javafx-repos1 with Apache License 2.0 6 votes vote down vote up
private void createTopHighlightBorder() {
    Stop[] stops = new Stop[] {
            new Stop(0, Color.WHITE),
            new Stop(.3, Color.LIGHTGRAY),
            new Stop(1, Color.TRANSPARENT)
    };
    LinearGradient lg1 = new LinearGradient(0, 0, 0, 1, true, CycleMethod.NO_CYCLE, stops);

    topHighlightBorder =
            new Border(new BorderStroke(
                    lg1, null, null, null,
                    BorderStrokeStyle.SOLID, BorderStrokeStyle.NONE, BorderStrokeStyle.NONE, BorderStrokeStyle.NONE,
                    CornerRadii.EMPTY,
                    new BorderWidths( 8.0d ),
                    null
            ));
}
 
Example #11
Source File: ScatterChartPane.java    From constellation with Apache License 2.0 6 votes vote down vote up
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 #12
Source File: ConversationBubble.java    From constellation with Apache License 2.0 6 votes vote down vote up
public final void setColor(final Color color) {
    Color bottomColor = color.darker();
    Color topColor = color.brighter();

    Stop[] stops = new Stop[]{
        new Stop(0, topColor),
        new Stop(1, bottomColor)
    };
    LinearGradient gradient = new LinearGradient(0, 0, 0, 1, true, CycleMethod.NO_CYCLE, stops);

    bubbleGraphic.setStroke(color);
    bubbleGraphic.setFill(gradient);

    tail.setFill(bottomColor);
    tail.setStroke(color);
    tailTop.setStroke(bottomColor); // Erase the border of the buble where the tail joins
}
 
Example #13
Source File: ModernSkin.java    From Medusa with Apache License 2.0 6 votes vote down vote up
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 #14
Source File: RadialGlobalMenu.java    From RadialFx with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 #15
Source File: StopWatch.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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 #16
Source File: RadarChartTest.java    From charts with Apache License 2.0 5 votes vote down vote up
@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 #17
Source File: ThermometerRepresentation.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
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 #18
Source File: BaseLEDRepresentation.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
private Paint computeEditColors()
{
    final Color[] save_colors = colors;
    final List<Stop> stops = new ArrayList<>(2 * save_colors.length);
    final double offset = 1.0 / save_colors.length;

    for (int i = 0; i < save_colors.length; ++i)
    {
        stops.add(new Stop(i * offset, save_colors[i]));
        stops.add(new Stop((i + 1) * offset, save_colors[i]));
    }

    return new LinearGradient(0, 0, 1, 1, true, CycleMethod.NO_CYCLE, stops);
}
 
Example #19
Source File: ByteMonitorRepresentation.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
private Paint computeEditColors()
{
    final Color[] save_colors = colors;
    return new LinearGradient(0, 0, 1, 1, true, CycleMethod.NO_CYCLE,
            List.of(new Stop(0.0, save_colors[0]),
                    new Stop(0.5, save_colors[0]),
                    new Stop(0.5, save_colors[1]),
                    new Stop(1.0, save_colors[1])));
}
 
Example #20
Source File: BoolButtonRepresentation.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
private Paint computeEditColors()
{
    final Color[] save_colors = state_colors;
    return new LinearGradient(0, 0, 1, 1, true, CycleMethod.NO_CYCLE,
        List.of(new Stop(0.0, save_colors[0]),
                new Stop(0.5, save_colors[0]),
                new Stop(0.5, save_colors[1]),
                new Stop(1.0, save_colors[1])));
}
 
Example #21
Source File: SimpleHSBColorPicker.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
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 #22
Source File: ThermoDemo.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
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 #23
Source File: Helper.java    From charts with Apache License 2.0 5 votes vote down vote up
public static final LinearGradient createColorVariationGradient(final Color COLOR, final int NO_OF_COLORS) {
    List<Color> colorVariations = createColorVariations(COLOR, NO_OF_COLORS);
    List<Stop>  stops = new ArrayList<>(NO_OF_COLORS);
    double step = 1.0 / NO_OF_COLORS;
    for (int i = 0 ; i < NO_OF_COLORS ; i++) {
        stops.add(new Stop(i * step, colorVariations.get(i)));
    }
    return new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, stops);
}
 
Example #24
Source File: NodePart.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates the shape used to display the node's border and background.
 *
 * @return The newly created {@link Shape}.
 */
private Node createDefaultShape() {
	GeometryNode<?> shape = new GeometryNode<>(new org.eclipse.gef.geometry.planar.Rectangle());
	shape.setUserData(DEFAULT_SHAPE_ROLE);
	shape.getStyleClass().add(CSS_CLASS_SHAPE);
	shape.setFill(new LinearGradient(0, 0, 1, 1, true, CycleMethod.REFLECT,
			Arrays.asList(new Stop(0, new Color(1, 1, 1, 1)))));
	shape.setStroke(new Color(0, 0, 0, 1));
	shape.setStrokeType(StrokeType.INSIDE);
	return shape;
}
 
Example #25
Source File: RadialPercentageTileSkin.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
@Override protected void redraw() {
    super.redraw();
    locale           = tile.getLocale();
    formatString     = new StringBuilder("%.").append(Integer.toString(tile.getDecimals())).append("f").toString();
    sectionsVisible  = tile.getSectionsVisible();

    barBackground.setStroke(tile.getBarBackgroundColor());

    LinearGradient gradient = new LinearGradient(0, 0, 1, 1, true, CycleMethod.NO_CYCLE, tile.getGradientStops());

    bar.setStroke(tile.isFillWithGradient() ? gradient : tile.getBarColor());
    proportionBar.setStroke(tile.isFillWithGradient() ? gradient : tile.getBarColor());
    percentageValueText.setFill(tile.getValueColor());
    percentageUnitText.setFill(tile.getUnitColor());
    descriptionText.setFill(tile.getDescriptionColor());
    unitText.setFill(tile.getUnitColor());
    titleText.setFill(tile.getTitleColor());
    text.setFill(tile.getTextColor());
    separator.setStroke(tile.getBackgroundColor());

    titleText.setText(tile.getTitle());
    descriptionText.setText(tile.getDescription());
    text.setText(tile.getText());
    unitText.setText(tile.getUnit());

    referenceValue = tile.getReferenceValue() < maxValue ? maxValue : tile.getReferenceValue();

    resizeStaticText();
    resizeDynamicText();
}
 
Example #26
Source File: ViewSingleShape.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
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 #27
Source File: RotationEffect.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
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 #28
Source File: FuelGauge.java    From medusademo with Apache License 2.0 5 votes vote down vote up
@Override public void init() {
    fuelIcon = new Region();
    fuelIcon.getStyleClass().setAll("fuel-icon");

    gauge = GaugeBuilder.create()
                        .skinType(SkinType.HORIZONTAL)
                        .prefSize(500, 250)
                        .knobColor(Color.rgb(0, 0, 0))
                        .foregroundBaseColor(Color.rgb(249, 249, 249))
                        .animated(true)
                        .shadowsEnabled(true)
                        .valueVisible(false)
                        //.title("FUEL")
                        .needleColor(Color.web("0xEF2F06"))
                        //.needleColor(Color.rgb(255, 10, 1))
                        .needleShape(NeedleShape.ROUND)
                        .needleSize(NeedleSize.THICK)
                        .minorTickMarksVisible(false)
                        .mediumTickMarksVisible(false)
                        //.majorTickMarkType(TickMarkType.TRIANGLE)
                        .sectionsVisible(true)
                        .sections(new Section(0, 0.2, Color.rgb(255, 10, 1)))
                        .minValue(0)
                        .maxValue(1)
                        .angleRange(90)
                        .customTickLabelsEnabled(true)
                        .customTickLabels("E", "", "", "", "", "1/2", "", "", "", "", "F")
                        .build();

    pane = new StackPane(fuelIcon, gauge);
    pane.setPadding(new Insets(10));
    LinearGradient gradient = new LinearGradient(0, 0, 0, pane.getLayoutBounds().getHeight(),
                                                 false, CycleMethod.NO_CYCLE,
                                                 new Stop(0.0, Color.rgb(38, 38, 38)),
                                                 new Stop(1.0, Color.rgb(15, 15, 15)));
    pane.setBackground(new Background(new BackgroundFill(gradient, CornerRadii.EMPTY, Insets.EMPTY)));
}
 
Example #29
Source File: MedusaTempGauge.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override public void start(Stage stage) {
    StackPane pane = new StackPane(gauge);
    pane.setPadding(new Insets(20));
    pane.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT);
    LinearGradient gradient = new LinearGradient(0, 0, 0, pane.getLayoutBounds().getHeight(),
                                                 false, CycleMethod.NO_CYCLE,
                                                 new Stop(0.0, Color.rgb(38, 38, 38)),
                                                 new Stop(1.0, Color.rgb(15, 15, 15)));
    //pane.setBackground(new Background(new BackgroundFill(gradient, CornerRadii.EMPTY, Insets.EMPTY)));
    //pane.setBackground(new Background(new BackgroundFill(Color.rgb(39,44,50), CornerRadii.EMPTY, Insets.EMPTY)));
    //pane.setBackground(new Background(new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY)));
    //pane.setBackground(new Background(new BackgroundFill(Gauge.DARK_COLOR, CornerRadii.EMPTY, Insets.EMPTY)));

    Scene scene = new Scene(pane);
    scene.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT);

    stage.setTitle("mars-sim");
    stage.setScene(scene);
    stage.show();

    //gauge.setValue(50);

    // Calculate number of nodes
    calcNoOfNodes(pane);
    System.out.println(noOfNodes + " Nodes in SceneGraph");

    timer.start();

    //gauge.getSections().get(0).setStart(10);
    //gauge.getSections().get(0).setStop(90);
}
 
Example #30
Source File: QualityGauge.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
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);
    }
}