Java Code Examples for javafx.scene.paint.RadialGradient

The following are top voted examples for showing how to use javafx.scene.paint.RadialGradient. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: marathonv5   File: RadialGradientSample.java   Source Code and License 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 2
Project: marathonv5   File: RadialGradientSample.java   Source Code and License 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 3
Project: charts   File: AreaHeatMap.java   Source Code and License 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 4
Project: enders_game   File: Bullet.java   Source Code and License 6 votes vote down vote up
/**
* The constructor for a bullet.
* 
* @param radius - the radius of the bullet
* @param fill - the color of the bullet highlight
*/
  public Bullet(double radius, Color fill) {
      sphere = CircleBuilder.create()
              .centerX(radius)
              .centerY(radius)
              .radius(radius)
              .cache(true)
              .build();
 
      RadialGradient rgrad = RadialGradientBuilder.create()
                  .centerX(sphere.getCenterX() - sphere.getRadius() / 3)
                  .centerY(sphere.getCenterY() - sphere.getRadius() / 3)
                  .radius(sphere.getRadius())
                  .proportional(false)
                  .stops(new Stop(0.0, fill), new Stop(1.0, Settings.BULLET_PRIMARY_COLOR))
                  .build();
 
      sphere.setFill(rgrad);
  }
 
Example 5
Project: CSS-Editor-FX   File: CSSPaintPaser.java   Source Code and License 6 votes vote down vote up
public List<Function<String, Paint>> getTasks() {
  return CacheUtil.cache(CSSPaintPaser.class, () -> Arrays.asList(
      text -> Color.web(text, 1),
      text -> LinearGradient.valueOf(text),
      text -> RadialGradient.valueOf(text),
      text -> context.lookup(text),
      text -> DeriveColorConverter.getInstance().convert(factory.apply(text), Font.getDefault()),
      text -> LadderConverter.getInstance().convert(factory.apply(text), Font.getDefault()),
      text -> LinearGradientConverter.getInstance().convert(factory.apply(text), Font.getDefault()),
      text -> RadialGradientConverter.getInstance().convert(factory.apply(text), Font.getDefault())
      ));
}
 
Example 6
Project: The-Projects   File: Player.java   Source Code and License 6 votes vote down vote up
/**
 * Constructor without cards
 * @param name the name of the player
 * @param role the role of the player
 */
public Player(String name, Role role) {
    this.name = name;
    this.role = role;
    color = role.roleToColor();
    hand = new LinkedList<>();
    handDeck = null;
    pane = new Pane();
    pane.setBackground(new Background(new BackgroundFill(new RadialGradient(0, 0, .5, .5, .8, true, CycleMethod.NO_CYCLE, new Stop(0, color.deriveColor(0,1,1,.25)), new Stop(1, color.deriveColor(0,1,.5,.25))), new CornerRadii(5), new Insets(0))));

    Label description = new Label(role.roleToDescription());
    description.setTextFill(role.roleToColor().brighter());
    pane.getChildren().add(description);
    nameLabel = new Label(name);
    nameLabel.setTextFill(role.roleToColor().brighter());
    nameLabel.setLayoutX(350);
    nameLabel.setLayoutY(20);
    pane.getChildren().add(nameLabel);


    pawn = new Pawn(this);
}
 
Example 7
Project: JavaOne2015JavaFXPitfalls   File: Utils.java   Source Code and License 6 votes vote down vote up
/**
 * Create an alpha masked ball with gradient colors from White to Black/Transparent. Used e. g. for particles.
 * May only be visible when you have a background other than white, ie use black
 *
 * @param radius
 * @return
 */
public static Node createAlphaMaskedBall( double radius) {

    Circle ball = new Circle(radius);

    RadialGradient gradient1 = new RadialGradient(0,
            .1,
            0,
            0,
            radius,
            false,
            CycleMethod.NO_CYCLE,
            new Stop(0, Color.WHITE.deriveColor(1,1,1,1)),
            new Stop(1, Color.BLACK.deriveColor(1,1,1,0)));

    ball.setFill(gradient1);

    return ball;
}
 
Example 8
Project: POL-POM-5   File: AbstractStepRepresentation.java   Source Code and License 6 votes vote down vote up
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 9
Project: kotlinfx-ensemble   File: RadialGradientSample.java   Source Code and License 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 10
Project: Fishification   File: FishWorld.java   Source Code and License 6 votes vote down vote up
/**
 * Draws the background of the aquarium.
 */
private void fillAquariumBackground() {

    RadialGradientBuilder gradientBuilder = RadialGradientBuilder.create();
    gradientBuilder.centerX(getWorldCanvas().getWidth() / 2);
    gradientBuilder.centerY(50);
    gradientBuilder.radius(1000);
    gradientBuilder.proportional(false);
    gradientBuilder.stops(new Stop(0.0, Color.WHITE), new Stop(0.05, Color.rgb(245, 251, 251)),
                          new Stop(0.1, Color.rgb(220, 242, 239)), new Stop(0.2, Color.rgb(164, 214, 211)),
                          new Stop(0.3, Color.rgb(142, 195, 199)), new Stop(0.4, Color.rgb(111, 170, 184)),
                          new Stop(0.5, Color.rgb(84, 145, 166)), new Stop(0.6, Color.rgb(61, 125, 152)),
                          new Stop(0.7, Color.rgb(50, 111, 140)), new Stop(0.8, Color.rgb(33, 96, 129)),
                          new Stop(0.9, Color.rgb(25, 85, 121)), new Stop(1.0, Color.rgb(19, 77, 115)));
    RadialGradient gradient = gradientBuilder.build();

    getWorldCanvas().setFill(gradient);
}
 
Example 11
Project: Fishification   File: BubbleEntity.java   Source Code and License 6 votes vote down vote up
private Circle createBubbleCircle(double radius) {
    CircleBuilder<?> circleBuilder = CircleBuilder.create();
    circleBuilder.radius(radius);
    circleBuilder.cache(true);
    Circle sphere = circleBuilder.build();
    sphere.setOpacity(BUBBLE_OPACITY);

    RadialGradientBuilder gradientBuilder = RadialGradientBuilder.create();
    gradientBuilder.centerX(sphere.getCenterX() - sphere.getRadius() / 3);
    gradientBuilder.centerY(sphere.getCenterY() - sphere.getRadius() / 3);
    gradientBuilder.radius(sphere.getRadius());
    gradientBuilder.proportional(false);
    gradientBuilder.stops(new Stop(0.0, Color.BLUE), new Stop(1.0, Color.BLACK));
    RadialGradient gradient = gradientBuilder.build();

    sphere.setFill(gradient);
    return sphere;
}
 
Example 12
Project: RadialFx   File: RadialGlobalMenu.java   Source Code and License 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 13
Project: marathonv5   File: RadialGradientSample.java   Source Code and License 5 votes vote down vote up
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
Project: marathonv5   File: RadialGradientSample.java   Source Code and License 5 votes vote down vote up
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 15
Project: CSS-Editor-FX   File: CSSPaintPaser.java   Source Code and License 5 votes vote down vote up
public List<Function<String, Paint>> getTasks() {
  return CacheUtil.cache(CSSPaintPaser.class, () -> Arrays.asList(
      text -> Color.web(text, 1),
      text -> LinearGradient.valueOf(text),
      text -> RadialGradient.valueOf(text),
      text -> context.lookup(text),
      text -> DeriveColorConverter.getInstance().convert(factory.apply(text), Font.getDefault()),
      text -> LadderConverter.getInstance().convert(factory.apply(text), Font.getDefault()),
      text -> LinearGradientConverter.getInstance().convert(factory.apply(text), Font.getDefault()),
      text -> RadialGradientConverter.getInstance().convert(factory.apply(text), Font.getDefault())
      ));
}
 
Example 16
Project: charts   File: RadarChartTest.java   Source Code and License 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);

    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
Project: LuckPermsUI   File: Manager.java   Source Code and License 5 votes vote down vote up
public void setOverlay(Pane pane) {
	overlay.getChildren().clear();
	if (pane != null) {
		Rectangle fade = new Rectangle(mainView.getScene().getWidth(), mainView.getScene().getHeight());
		Stop[] stops = {new Stop(0, new Color(0.9, 0.9, 0.9, 0.9)), new Stop(1, new Color(0.1, 0.1, 0.1, 0.1))};
		fade.setFill(new RadialGradient(0, 0, 0.5, 0.5, 1.5, true, CycleMethod.NO_CYCLE, stops));
		VBox vCenter = new VBox(pane);
		HBox hCenter = new HBox(vCenter);
		vCenter.setAlignment(Pos.CENTER);
		hCenter.setAlignment(Pos.CENTER);
		overlay.getChildren().addAll(fade, hCenter);
	}
}
 
Example 18
Project: particlesfx   File: NodeBubbles.java   Source Code and License 5 votes vote down vote up
private Node[] createBubble(final double SIZE) {
    final double CENTER = SIZE * 0.5;
    final Node[] NODES  = new Node[3];

    final Circle MAIN = new Circle(CENTER, CENTER, CENTER);
    final Paint MAIN_FILL = new LinearGradient(CENTER, 0.02 * SIZE,
                                               0.50 * SIZE, 0.98 * SIZE,
                                               false, CycleMethod.NO_CYCLE,
                                               new Stop(0.0, Color.TRANSPARENT),
                                               new Stop(0.85, Color.rgb(255, 255, 255, 0.2)),
                                               new Stop(1.0, Color.rgb(255, 255, 255, 0.90)));
    MAIN.setFill(MAIN_FILL);
    MAIN.setStroke(null);

    final Circle FRAME      = new Circle(CENTER, CENTER, CENTER);
    final Paint  FRAME_FILL = new RadialGradient(0, 0,
                                                 CENTER, CENTER,
                                                 0.48 * SIZE,
                                                 false, CycleMethod.NO_CYCLE,
                                                 new Stop(0.0, Color.TRANSPARENT),
                                                 new Stop(0.92, Color.TRANSPARENT),
                                                 new Stop(1.0, Color.rgb(255, 255, 255, 0.5)));
    FRAME.setFill(FRAME_FILL);
    FRAME.setStroke(null);

    final Ellipse HIGHLIGHT      = new Ellipse(CENTER, 0.27 * SIZE, 0.38 * SIZE, 0.25 * SIZE);
    final Paint   HIGHLIGHT_FILL = new LinearGradient(CENTER, 0.04 * SIZE,
                                                     CENTER, CENTER,
                                                     false, CycleMethod.NO_CYCLE,
                                                     new Stop(0.0, Color.rgb(255, 255, 255, 0.7)),
                                                     new Stop(1.0, Color.TRANSPARENT));
    HIGHLIGHT.setFill(HIGHLIGHT_FILL);
    HIGHLIGHT.setStroke(null);

    NODES[0] = FRAME;
    NODES[1] = MAIN;
    NODES[2] = HIGHLIGHT;
    
    return NODES;
}
 
Example 19
Project: benchmarkjfx   File: FXBallVector.java   Source Code and License 5 votes vote down vote up
public FXBallVector() {
    List<Stop> stops = new ArrayList<>();
    stops.add(new Stop(0.2, Color.RED));
    stops.add(new Stop(0.8, Color.RED.darker()));
    stops.add(new Stop(1.0, Color.RED.darker().darker()));
    RadialGradient gradient = new RadialGradient(0, 0, 20, 20, 20, false, CycleMethod.NO_CYCLE, stops);
    circle = new Circle(20, 20, 20, gradient);
    move();
}
 
Example 20
Project: ColorSelector   File: ColorSelector.java   Source Code and License 5 votes vote down vote up
public void redraw(final Color COLOR) {
    mainCircle.setFill(new RadialGradient(0, 0, (size * 0.5), (size * 0.5), (size * 0.15410959),
                                          false, CycleMethod.NO_CYCLE,
                                          new Stop(0.0, COLOR.brighter()),
                                          new Stop(1.0, COLOR)));
    mainCircle.setStroke(COLOR.darker());
}
 
Example 21
Project: FXGL   File: Vignette.java   Source Code and License 5 votes vote down vote up
/**
 * This must be called on any property change since
 * gradient is effectively immutable.
 */
private void applyChanges() {
    region.setFill(new RadialGradient(0, 0, region.getWidth() / 2, region.getHeight() / 2, radius,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.TRANSPARENT),
            new Stop(1, Color.color(color.getRed(), color.getGreen(), color.getBlue(), intensity))));
}
 
Example 22
Project: The-Projects   File: MyButton.java   Source Code and License 5 votes vote down vote up
/**
 * Constructor with text to display
 * @param text the text to display
 */
public MyButton(String text) {
    super(text);
    setTextFill(Color.BLUEVIOLET);
    Color color = Color.ORANGE;
    setBackground(new Background(new BackgroundFill(new RadialGradient(0, 0, .5, .5, .8, true, CycleMethod.NO_CYCLE, new Stop(0, color), new Stop(1, color.deriveColor(0,1,.5,1))), new CornerRadii(20), new Insets(0))));
    setBorder(new Border(new BorderStroke(color.deriveColor(0,1,.5,1), BorderStrokeStyle.SOLID, new CornerRadii(20), new BorderWidths(2))));
    hoverProperty().addListener(e-> {
        if (!isFocused()) {
            if (isHover()) {
                setBorder(new Border(new BorderStroke(color.deriveColor(90, 1, .5, 1), BorderStrokeStyle.SOLID, new CornerRadii(20), new BorderWidths(2))));
            } else {
                setBorder(new Border(new BorderStroke(color.deriveColor(0, 1, .5, 1), BorderStrokeStyle.SOLID, new CornerRadii(20), new BorderWidths(2))));
            }
        }
    });
    focusedProperty().addListener(e-> {
        if (isFocused()) {
            setBorder(new Border(new BorderStroke(color.deriveColor(-90, 1, .5, 1), BorderStrokeStyle.SOLID, new CornerRadii(20), new BorderWidths(2))));
        } else {
            setBorder(new Border(new BorderStroke(color.deriveColor(0, 1, .5, 1), BorderStrokeStyle.SOLID, new CornerRadii(20), new BorderWidths(2))));
        }
    });
    pressedProperty().addListener(e -> {
        if (isPressed()) {
            setBackground(new Background(new BackgroundFill(new RadialGradient(0, 0, .5, .5, .8, true, CycleMethod.NO_CYCLE, new Stop(0, color.deriveColor(0,1,1,1)), new Stop(1, color.deriveColor(0,1,.1,1))), new CornerRadii(20), new Insets(0))));
        }else{
            setBackground(new Background(new BackgroundFill(new RadialGradient(0, 0, .5, .5, .8, true, CycleMethod.NO_CYCLE, new Stop(0, color), new Stop(1, color.deriveColor(0,1,.5,1))), new CornerRadii(20), new Insets(0))));
        }
    });

    setMaxWidth(Double.POSITIVE_INFINITY);
    setCursor(Cursor.HAND);
}
 
Example 23
Project: The-Projects   File: Building.java   Source Code and License 5 votes vote down vote up
/**
 * Constructor of a Building
 * @param color the color of the building
 * @param UV the name of the corresponding UV
 * @param shapes the different shapes composing the building
 */
public Building(Color color, String UV, Shape ... shapes) {
    this.UV = UV;
    if (shapes.length > 1) {
        shape = Arrays.asList(shapes).stream().reduce(Shape::union).get();
    }else{
        shape = shapes[0];
    }
    this.color = color;
    shape.setFill(new RadialGradient(0, 0, .5, .5, .8, true, CycleMethod.NO_CYCLE, new Stop(0, color), new Stop(1, color.deriveColor(0,1,.5,1))));
    shape.setStroke(color.deriveColor(0,1,.5,1));
    shape.setStrokeWidth(3);
}
 
Example 24
Project: org.csstudio.display.builder   File: ThermometerRepresentation.java   Source Code and License 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 25
Project: org.csstudio.display.builder   File: ThermoDemo.java   Source Code and License 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 26
Project: Consume   File: Vignette.java   Source Code and License 5 votes vote down vote up
/**
 * This must be called on any property change since
 * gradient is effectively immutable.
 */
private void applyChanges() {
    region.setFill(new RadialGradient(0, 0, region.getWidth() / 2, region.getHeight() / 2, radius,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.TRANSPARENT),
            new Stop(1, Color.color(color.getRed(), color.getGreen(), color.getBlue(), intensity))));
}
 
Example 27
Project: analogclock   File: AnalogClockDrawing.java   Source Code and License 5 votes vote down vote up
Node createCircle() {
    RadialGradient gradient = new RadialGradient(
            0, 0, 0.5, 0.5, 0.5, true, CycleMethod.NO_CYCLE,
            new Stop(0.8, Color.WHITE), new Stop(0.9, Color.BLACK), new Stop(0.95, Color.WHITE), new Stop(1.0, Color.BLACK)
    );
    Circle circle = new Circle(UNIT_SIZE, UNIT_SIZE, UNIT_SIZE, gradient);
    return circle;
}
 
Example 28
Project: kotlinfx-ensemble   File: RadialGradientSample.java   Source Code and License 5 votes vote down vote up
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 29
Project: JFX8CustomControls   File: Led.java   Source Code and License 5 votes vote down vote up
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 30
Project: Fishification   File: FoodItemEntity.java   Source Code and License 5 votes vote down vote up
private Circle createFoodCircle(double radius) {
    CircleBuilder<?> circleBuilder = CircleBuilder.create();
    circleBuilder.radius(radius);
    circleBuilder.cache(true);
    Circle sphere = circleBuilder.build();
    sphere.setOpacity(FOOD_OPACITY);

    RadialGradientBuilder gradientBuilder = RadialGradientBuilder.create();
    gradientBuilder.centerX(sphere.getCenterX() - sphere.getRadius() / 3);
    gradientBuilder.centerY(sphere.getCenterY() - sphere.getRadius() / 3);
    gradientBuilder.radius(sphere.getRadius());
    gradientBuilder.proportional(false);

    if (m_foodSource.equalsIgnoreCase("twitter")) {
        gradientBuilder.stops(new Stop(0.0, Color.LIGHTCYAN), new Stop(1.0, Color.DARKCYAN));
    } else if (m_foodSource.equalsIgnoreCase("sociotech")) {
        gradientBuilder.stops(new Stop(0.0, Color.GRAY), new Stop(1.0, Color.DARKGRAY));
    } else if (m_foodSource.equalsIgnoreCase("cscm")) {
        gradientBuilder.stops(new Stop(0.4, Color.ORANGE), new Stop(1.0, Color.BLACK));
    } else if (m_foodSource.equalsIgnoreCase("unibwm")) {
        gradientBuilder.stops(new Stop(0.0, Color.DARKORANGE), new Stop(1.0, Color.BLACK));
    } else if (m_foodSource.equalsIgnoreCase("mendeley")) {
        gradientBuilder.stops(new Stop(0.0, Color.RED), new Stop(1.0, Color.BLACK));
    } else if (m_foodSource.equalsIgnoreCase("studiendekan")) {
        gradientBuilder.stops(new Stop(0.0, Color.SANDYBROWN), new Stop(1.0, Color.BLACK));
    } else {
        gradientBuilder.stops(new Stop(0.0, Color.YELLOW), new Stop(1.0, Color.BLACK));
    }
    RadialGradient gradient = gradientBuilder.build();

    sphere.setFill(gradient);
    return sphere;
}
 
Example 31
Project: RadialFx   File: RadialGlobalMenu.java   Source Code and License 5 votes vote down vote up
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 32
Project: Medusa   File: PlainClockSkin.java   Source Code and License 4 votes vote down vote up
@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 33
Project: Medusa   File: FGauge.java   Source Code and License 4 votes vote down vote up
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 34
Project: gluon-samples   File: DoodleTrace.java   Source Code and License 4 votes vote down vote up
/**
 * Constructor taking the application's name.
 * @param name The title of the application.
 */
public DoodleTrace(String name) {
    // Set title
    super(name);

    // 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 35
Project: The-Projects   File: Deck.java   Source Code and License 4 votes vote down vote up
/**
 * complete constructor
 * @param scene the scene in which the Deck appear
 * @param text the text on the Deck
 * @param color the color of the Deck
 * @param relativeX the relative x position of the Deck
 * @param relativeY the relative y position of the Deck
 * @param horizontal the horizontality of the Deck
 */
public Deck (Scene scene,String text, Color color, double relativeX, double relativeY, boolean horizontal) {

    Rectangle rectangle = new Rectangle();
    rectangle.setFill(new RadialGradient(0, 0, .5, .5, .8, true, CycleMethod.NO_CYCLE, new Stop(0, color), new Stop(1, color.deriveColor(0,1,.5,1))));

    rectangle.setWidth(scene.getWidth()*(horizontal ? 22*9/16 : 9)/100.);
    rectangle.setHeight(scene.getHeight()*(horizontal ? 9*16/9 : 22)/100.);

    setLayoutX(scene.getWidth()*relativeX);
    setLayoutY(scene.getHeight()*relativeY);
    getChildren().add(rectangle);

    Label label = new Label(text);
    label.setFont(new Font(15));
    label.setTextFill(color.deriveColor(0,1,8,1));
    label.setMouseTransparent(true);


    getChildren().add(label);

}
 
Example 36
Project: The-Projects   File: MasteredCoursesDisplay.java   Source Code and License 4 votes vote down vote up
/**
 * Complete constructor
 * @param scene the scene where the Pane appear
 * @param buildings the list of the different courses
 * @param posX the relative x position on the scene
 * @param posY the relative y position on the scene
 */
public MasteredCoursesDisplay(Scene scene, Building[] buildings, double posX, double posY) {
    Color color = Color.INDIGO;
    setLayoutX(scene.getWidth()*posX);
    setLayoutY(scene.getHeight()*posY);
    setPrefSize(scene.getWidth()*14.5/100., scene.getHeight()*13.5/100.);
    setMaxSize(scene.getWidth()*14.5/100., scene.getHeight()*13.5/100.);

    Text title = new Text("État des UVs :\n Maîtrisée(V),\nÉradiquée(X).");
    title.setFill(color.brighter().brighter());
    title.setLayoutX(getPrefWidth()/3.2);
    title.setLayoutY(15);
    getChildren().add(title);

    toMastered = new Timeline[4];
    toEradicated = new Timeline[4];

    setBackground(new Background(new BackgroundFill(new RadialGradient(0, 0, .5, .5, .8, true, CycleMethod.NO_CYCLE, new Stop(1, color.deriveColor(0,1,1,1)), new Stop(0, color.deriveColor(0,1,.5,1))), new CornerRadii(15), new Insets(0))));

    for (int i = 0; i < 4; ++i) {
        Color courseColor = buildings[i].getColor();
        Circle circle = new Circle(45 + i*50, 90, 17, new RadialGradient(0, 0, .5, .5, .8, true, CycleMethod.NO_CYCLE, new Stop(0, courseColor.deriveColor(0,1,1,1)), new Stop(1, courseColor.deriveColor(0,1,.5,1))));
        Text text = new Text(30 + i*50, 70, buildings[i].getUV());
        text.setFill(buildings[i].getColor());

        MoveTo moveTo1 = new MoveTo(45 + i*50, 82);
        LineTo lineTo1 = new LineTo(45 - 8 + i*50, 99);
        MoveTo moveTo2 = new MoveTo(45 + i*50, 82);
        LineTo lineTo2 = new LineTo(45 + 8 + i*50, 99);
        Path path = new Path(moveTo1, lineTo1, moveTo2, lineTo2);
        path.setStrokeWidth(2);

        getChildren().addAll(circle, text, path);
        toMastered[i] = new Timeline(new KeyFrame(Duration.millis(1000),
                new KeyValue(moveTo1.xProperty(), 45 - 8 + i*50),
                new KeyValue(moveTo2.xProperty(), 45 + 8 + i*50),
                new KeyValue(lineTo1.xProperty(), 45 + i*50),
                new KeyValue(lineTo2.xProperty(), 45 + i*50)
                ));
        toEradicated[i] = new Timeline(new KeyFrame(Duration.millis(1000),
                new KeyValue(moveTo1.xProperty(), 45 - 8 + i*50),
                new KeyValue(moveTo2.xProperty(), 45 + 8 + i*50),
                new KeyValue(lineTo1.xProperty(), 45 + 8 + i*50),
                new KeyValue(lineTo2.xProperty(), 45 - 8 + i*50)
        ));
    }
}
 
Example 37
Project: FXImgurUploader   File: Led.java   Source Code and License 4 votes vote down vote up
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 38
Project: FXImgurUploader   File: RadialBargraphSkin.java   Source Code and License 4 votes vote down vote up
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 39
Project: FXImgurUploader   File: Led.java   Source Code and License 4 votes vote down vote up
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 40
Project: org.csstudio.display.builder   File: BaseLEDRepresentation.java   Source Code and License 4 votes vote down vote up
@Override
public void updateChanges()
{
    if (typeChanged.checkAndClear())
    {
        createLED();
        styleChanged.mark();
        dirty_content.mark();
    }
    super.updateChanges();
    if (styleChanged.checkAndClear())
    {
        final Color color = JFXUtil.convert(model_widget.propForegroundColor().getValue());
        label.setTextFill(color);
        label.setFont(JFXUtil.convert(model_widget.propFont().getValue()));

        final int w = model_widget.propWidth().getValue();
        final int h = model_widget.propHeight().getValue();

        jfx_node.setPrefSize(w, h);
        if (led instanceof Ellipse)
        {
            final Ellipse ell = (Ellipse) led;
            ell.setCenterX(w/2);
            ell.setCenterY(h/2);
            ell.setRadiusX(w/2);
            ell.setRadiusY(h/2);
        }
        else if (led instanceof Rectangle)
        {
            final Rectangle rect = (Rectangle) led;
            rect.setWidth(w);
            rect.setHeight(h);
        }
        label.setPrefSize(w, h);
    }
    if (dirty_content.checkAndClear())
    {
        led.setFill(
            // Put highlight in top-left corner, about 0.2 wide,
            // relative to actual size of LED
            new RadialGradient(0, 0, 0.3, 0.3, 0.4, true, CycleMethod.NO_CYCLE,
                               new Stop(0, value_color.interpolate(Color.WHITESMOKE, 0.8)),
                               new Stop(1, value_color)));
        label.setText(value_label);
    }
}