Search in sources :

Example 6 with Ellipse

use of javafx.scene.shape.Ellipse in project blue by kunstmusik.

the class KnobSkin method initComponents.

private void initComponents(double w) {
    getChildren().clear();
    double width = snapSize(w);
    double radius = width / 2;
    double innerRadius = snapSize(radius * 0.5);
    final Color trackColor = getSkinnable().getTrackColor();
    Ellipse outer = new Ellipse(radius, radius, radius, radius);
    Ellipse inner = new Ellipse(radius, radius, innerRadius, innerRadius);
    Shape shape = Path.subtract(outer, inner);
    Rectangle rect = new Rectangle(radius, radius);
    Shape trackBG = Path.subtract(shape, rect);
    trackBG.setRotate(-135.0);
    trackBG.setStroke(getSkinnable().getTrackBackgroundColor());
    trackBG.setStrokeType(StrokeType.INSIDE);
    trackBG.setFill(getSkinnable().getTrackBackgroundColor().darker());
    Arc mask = new Arc(radius, radius, radius + 2, radius + 2, -270, -270);
    mask.setType(ArcType.ROUND);
    mask.lengthProperty().bind(percent.multiply(-ARC_LENGTH));
    track = Path.subtract(shape, rect);
    track.setRotate(-135.0);
    track.setStroke(trackColor);
    track.setStrokeType(StrokeType.INSIDE);
    track.setFill(trackColor.deriveColor(1.0, 1.0, 1.0, 0.5));
    track.setClip(mask);
    track.setEffect(new Glow(1.0));
    Canvas c = new Canvas(width, width);
    GraphicsContext gc = c.getGraphicsContext2D();
    gc.setStroke(trackColor.brighter().brighter().brighter());
    gc.setLineWidth(2.0);
    gc.strokeLine(radius, 0, radius, radius - innerRadius - 1);
    gc.setFill(Color.BLACK);
    gc.fillOval(width * 0.25, width * 0.25, width * 0.5, width * 0.5);
    gc.setFill(trackColor);
    double notchWidth = width / 10.0;
    double notchAdj = notchWidth / 2.0;
    gc.fillRoundRect(radius - notchAdj, (width * .25) - notchAdj, notchWidth, (width * .25) + notchWidth, notchWidth, notchWidth);
    gc.setStroke(Color.BLACK);
    gc.strokeRoundRect(radius - notchAdj, (width * .25) - notchAdj, notchWidth, (width * .25) + notchWidth, notchWidth, notchWidth);
    c.rotateProperty().bind(percent.multiply(ARC_LENGTH).subtract(135.0));
    getChildren().addAll(trackBG, track, c);
}
Also used : Ellipse(javafx.scene.shape.Ellipse) Shape(javafx.scene.shape.Shape) Arc(javafx.scene.shape.Arc) GraphicsContext(javafx.scene.canvas.GraphicsContext) Color(javafx.scene.paint.Color) Canvas(javafx.scene.canvas.Canvas) Rectangle(javafx.scene.shape.Rectangle) Glow(javafx.scene.effect.Glow)

Example 7 with Ellipse

use of javafx.scene.shape.Ellipse in project org.csstudio.display.builder by kasemir.

the class BaseLEDRepresentation method updateChanges.

@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(// 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);
    }
}
Also used : Ellipse(javafx.scene.shape.Ellipse) Stop(javafx.scene.paint.Stop) Color(javafx.scene.paint.Color) Rectangle(javafx.scene.shape.Rectangle) RadialGradient(javafx.scene.paint.RadialGradient)

Example 8 with Ellipse

use of javafx.scene.shape.Ellipse in project org.csstudio.display.builder by kasemir.

the class BoolButtonRepresentation method createJFXNode.

@Override
public ButtonBase createJFXNode() throws Exception {
    led = new Ellipse();
    button = new Button("BoolButton", led);
    button.getStyleClass().add("action_button");
    button.setOnAction(event -> handlePress());
    button.setMnemonicParsing(false);
    // Model has width/height, but JFX widget has min, pref, max size.
    // updateChanges() will set the 'pref' size, so make min use that as well.
    button.setMinSize(ButtonBase.USE_PREF_SIZE, ButtonBase.USE_PREF_SIZE);
    return button;
}
Also used : Ellipse(javafx.scene.shape.Ellipse) Button(javafx.scene.control.Button)

Example 9 with Ellipse

use of javafx.scene.shape.Ellipse in project org.csstudio.display.builder by kasemir.

the class EllipseRepresentation method createJFXNode.

@Override
public Ellipse createJFXNode() throws Exception {
    final Ellipse ellipse = new Ellipse();
    updateColors();
    return ellipse;
}
Also used : Ellipse(javafx.scene.shape.Ellipse)

Example 10 with Ellipse

use of javafx.scene.shape.Ellipse in project Malai by arnobl.

the class DnDHelpAnimation method createTransition.

@Override
public Transition createTransition() {
    ell = new Ellipse(x1, y1, size, size);
    text = new Text(textPress);
    text.xProperty().bind(ell.centerXProperty().add(ell.getRadiusX()));
    text.yProperty().bind(ell.centerYProperty().subtract(ell.getRadiusY()));
    ell.setFill(Color.LIGHTGRAY);
    ell.setEffect(new DropShadow(20d, Color.BLACK));
    helpPane.getChildren().add(ell);
    helpPane.getChildren().add(text);
    ell.setVisible(false);
    text.setVisible(false);
    ell.setFocusTraversable(false);
    ell.setMouseTransparent(true);
    text.setFocusTraversable(false);
    text.setMouseTransparent(true);
    final SequentialTransition mainTrans = new SequentialTransition();
    final ParallelTransition parallelTransition = new ParallelTransition(new Timeline(new KeyFrame(duration, new KeyValue(ell.centerXProperty(), x2))), new Timeline(new KeyFrame(duration, new KeyValue(ell.centerYProperty(), y2))));
    mainTrans.getChildren().add(new Timeline(new KeyFrame(Duration.millis(10), new KeyValue(text.visibleProperty(), Boolean.TRUE))));
    mainTrans.getChildren().add(new Timeline(new KeyFrame(Duration.millis(10), new KeyValue(ell.visibleProperty(), Boolean.TRUE))));
    mainTrans.getChildren().add(new PauseTransition(Duration.seconds(1.5)));
    mainTrans.getChildren().add(new ParallelTransition(new Timeline(new KeyFrame(Duration.millis(400d), new KeyValue(ell.radiusXProperty(), size / 2d))), new Timeline(new KeyFrame(Duration.millis(400d), new KeyValue(ell.radiusYProperty(), size / 2d)))));
    mainTrans.getChildren().add(new Timeline(new KeyFrame(Duration.millis(100d), new KeyValue(text.textProperty(), textDrag))));
    mainTrans.getChildren().add(parallelTransition);
    mainTrans.getChildren().add(new Timeline(new KeyFrame(Duration.millis(100d), new KeyValue(text.textProperty(), textRelease))));
    mainTrans.getChildren().add(new ParallelTransition(new Timeline(new KeyFrame(Duration.millis(400d), new KeyValue(ell.radiusXProperty(), size))), new Timeline(new KeyFrame(Duration.millis(400d), new KeyValue(ell.radiusYProperty(), size)))));
    mainTrans.getChildren().add(new PauseTransition(Duration.seconds(1.5)));
    mainTrans.getChildren().add(new Timeline(new KeyFrame(Duration.millis(10), new KeyValue(text.visibleProperty(), Boolean.FALSE))));
    mainTrans.getChildren().add(new Timeline(new KeyFrame(Duration.millis(10), new KeyValue(ell.visibleProperty(), Boolean.FALSE))));
    transition = mainTrans;
    return transition;
}
Also used : Ellipse(javafx.scene.shape.Ellipse) Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) SequentialTransition(javafx.animation.SequentialTransition) KeyFrame(javafx.animation.KeyFrame) Text(javafx.scene.text.Text) PauseTransition(javafx.animation.PauseTransition) DropShadow(javafx.scene.effect.DropShadow) ParallelTransition(javafx.animation.ParallelTransition)

Aggregations

Ellipse (javafx.scene.shape.Ellipse)10 Color (javafx.scene.paint.Color)4 Rectangle (javafx.scene.shape.Rectangle)4 Stop (javafx.scene.paint.Stop)2 Shape (javafx.scene.shape.Shape)2 Text (javafx.scene.text.Text)2 KeyFrame (javafx.animation.KeyFrame)1 KeyValue (javafx.animation.KeyValue)1 ParallelTransition (javafx.animation.ParallelTransition)1 PauseTransition (javafx.animation.PauseTransition)1 SequentialTransition (javafx.animation.SequentialTransition)1 Timeline (javafx.animation.Timeline)1 Scene (javafx.scene.Scene)1 Canvas (javafx.scene.canvas.Canvas)1 GraphicsContext (javafx.scene.canvas.GraphicsContext)1 Button (javafx.scene.control.Button)1 Label (javafx.scene.control.Label)1 DropShadow (javafx.scene.effect.DropShadow)1 Glow (javafx.scene.effect.Glow)1 Pane (javafx.scene.layout.Pane)1