use of javafx.scene.paint.RadialGradient in project SIMVA-SoS by SESoS.
the class FXGraphics2D method setPaint.
/**
* Sets the paint used to draw or fill shapes (or text). If
* {@code paint} is an instance of {@code Color}, this method will
* also update the current color attribute (see {@link #getColor()}). If
* you pass {@code null} to this method, it does nothing (in
* accordance with the JDK specification).
* <br><br>
* Note that this implementation will map {@link Color},
* {@link GradientPaint}, {@link LinearGradientPaint} and
* {@link RadialGradientPaint}, other paint implementations are not
* handled.
*
* @param paint the paint ({@code null} is permitted but ignored).
*
* @see #getPaint()
*/
@Override
public void setPaint(Paint paint) {
if (paint == null) {
return;
}
this.paint = paint;
if (paint instanceof Color) {
setColor((Color) paint);
} else if (paint instanceof GradientPaint) {
GradientPaint gp = (GradientPaint) paint;
Stop[] stops = new Stop[] { new Stop(0, awtColorToJavaFX(gp.getColor1())), new Stop(1, awtColorToJavaFX(gp.getColor2())) };
Point2D p1 = gp.getPoint1();
Point2D p2 = gp.getPoint2();
LinearGradient lg = new LinearGradient(p1.getX(), p1.getY(), p2.getX(), p2.getY(), false, CycleMethod.NO_CYCLE, stops);
this.gc.setStroke(lg);
this.gc.setFill(lg);
} else if (paint instanceof MultipleGradientPaint) {
MultipleGradientPaint mgp = (MultipleGradientPaint) paint;
Color[] colors = mgp.getColors();
float[] fractions = mgp.getFractions();
Stop[] stops = new Stop[colors.length];
for (int i = 0; i < colors.length; i++) {
stops[i] = new Stop(fractions[i], awtColorToJavaFX(colors[i]));
}
if (paint instanceof RadialGradientPaint) {
RadialGradientPaint rgp = (RadialGradientPaint) paint;
Point2D center = rgp.getCenterPoint();
Point2D focus = rgp.getFocusPoint();
double focusDistance = focus.distance(center);
double focusAngle = 0.0;
if (!focus.equals(center)) {
focusAngle = Math.atan2(focus.getY() - center.getY(), focus.getX() - center.getX());
}
double radius = rgp.getRadius();
RadialGradient rg = new RadialGradient(focusAngle * Math.PI / 180, focusDistance, center.getX(), center.getY(), radius, false, CycleMethod.NO_CYCLE, stops);
this.gc.setStroke(rg);
this.gc.setFill(rg);
} else if (paint instanceof LinearGradientPaint) {
LinearGradientPaint lgp = (LinearGradientPaint) paint;
Point2D start = lgp.getStartPoint();
Point2D end = lgp.getEndPoint();
LinearGradient lg = new LinearGradient(start.getX(), start.getY(), end.getX(), end.getY(), false, CycleMethod.NO_CYCLE, stops);
this.gc.setStroke(lg);
this.gc.setFill(lg);
}
} else {
// this is a paint we don't recognise
}
}
use of javafx.scene.paint.RadialGradient in project Board-Instrumentation-Framework by intel.
the class Led method recalc.
// ******************** Resize/Redraw *************************************
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();
}
use of javafx.scene.paint.RadialGradient in project Board-Instrumentation-Framework by intel.
the class Led method draw.
// ******************** Resize/Redraw *************************************
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);
}
use of javafx.scene.paint.RadialGradient in project Board-Instrumentation-Framework by intel.
the class LedOne method recalc.
// ******************** Resize/Redraw *************************************
private void recalc() {
width = getWidth();
height = getHeight();
if (width <= 0 || height <= 0)
return;
size = width < height ? width : height;
offsetX = 0;
offsetY = 0;
if (width > height) {
offsetX = 0.5 * (width - size);
} else if (height > width) {
offsetY = 0.5 * (height - size);
}
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(offsetX + 0.14 * size, offsetY + 0.14 * size, offsetX + 0.84 * size, offsetY + 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(offsetX + 0.25 * size, offsetY + 0.25 * size, offsetX + 0.74 * size, offsetY + 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(offsetX + 0.25 * size, offsetY + 0.25 * size, offsetX + 0.74 * size, offsetY + 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, offsetX + 0.3 * size, offsetY + 0.3 * size, 0.29 * size, false, CycleMethod.NO_CYCLE, new Stop(0.0, Color.WHITE), new Stop(1.0, Color.TRANSPARENT));
draw();
}
use of javafx.scene.paint.RadialGradient in project POL-POM-5 by PhoenicisOrg.
the class AbstractStepRepresentation method drawLeftImage.
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);
}
Aggregations