Search in sources :

Example 1 with Polyline

use of javafx.scene.shape.Polyline in project OTP2_R6_svaap by JNuutinen.

the class LaserBeam method buildLaser.

/**
 * Rakentaa projectilen Shapen
 * @param color Projectilen väri
 * @return Rakennettu PolyLine
 */
private Polyline buildLaser(Color color) {
    // Ammuksen muoto
    shape = new Polyline();
    shape.getPoints().addAll(-0.0, 0.0, WINDOW_WIDTH, 0.0);
    Bloom bloom = new Bloom(0.0);
    GaussianBlur blur = new GaussianBlur(3.0);
    blur.setInput(bloom);
    shape.setEffect(blur);
    shape.setFill(Color.TRANSPARENT);
    shape.setStroke(color);
    shape.setStrokeWidth(7.0);
    return shape;
}
Also used : GaussianBlur(javafx.scene.effect.GaussianBlur) Bloom(javafx.scene.effect.Bloom) Polyline(javafx.scene.shape.Polyline)

Example 2 with Polyline

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

the class PolylineRepresentation method updateChanges.

@Override
public void updateChanges() {
    // Not using default handling of X/Y super.updateChanges();
    if (dirty_display.checkAndClear()) {
        if (model_widget.propVisible().getValue()) {
            jfx_node.setVisible(true);
            // Change points x/y relative to widget location into
            // on-screen location
            final int x = model_widget.propX().getValue();
            final int y = model_widget.propY().getValue();
            final Double[] points = model_widget.propPoints().getValue().asDoubleArray();
            for (int i = 0; i < points.length; i += 2) {
                points[i] += x;
                points[i + 1] += y;
            }
            final List<Node> children = jfx_node.getChildrenUnmodifiable();
            final Color color = JFXUtil.convert(model_widget.propLineColor().getValue());
            final int line_width = model_widget.propLineWidth().getValue();
            final int arrows_val = model_widget.propArrows().getValue().ordinal();
            final int length = model_widget.propArrowLength().getValue();
            int i = 0;
            for (Node child : children) {
                if (child instanceof Polyline) {
                    final Polyline line = (Polyline) child;
                    line.getPoints().setAll(points);
                    final ObservableList<Double> dashes = line.getStrokeDashArray();
                    // matches legacy opibuilder resp. Draw2D
                    switch(model_widget.propLineStyle().getValue()) {
                        case DASH:
                            dashes.setAll(3.0 * line_width, 1.0 * line_width);
                            break;
                        case DOT:
                            dashes.setAll(1.0 * line_width, 1.0 * line_width);
                            break;
                        case DASHDOT:
                            dashes.setAll(3.0 * line_width, 1.0 * line_width, 1.0 * line_width, 1.0 * line_width);
                            break;
                        case DASHDOTDOT:
                            dashes.setAll(3.0 * line_width, 1.0 * line_width, 1.0 * line_width, 1.0 * line_width, 1.0 * line_width, 1.0 * line_width);
                            break;
                        case SOLID:
                        default:
                            dashes.setAll();
                            break;
                    }
                } else // child instanceof Arrow
                {
                    final Arrow arrow = (Arrow) child;
                    arrow.setFill(color);
                    if ((i & arrows_val) != 0 && points.length > 3) {
                        arrow.setVisible(true);
                        if (// to-arrow (pointing towards end point)
                        i == 1)
                            arrow.adjustPoints(points[0], points[1], points[2], points[3], length);
                        else // i == 2 //from-arrow (point towards first point)
                        {
                            final int len = points.length;
                            arrow.adjustPoints(points[len - 2], points[len - 1], points[len - 4], points[len - 3], length);
                        }
                    } else
                        arrow.setVisible(false);
                }
                ((Shape) child).setStroke(color);
                ((Shape) child).setStrokeWidth(line_width);
                i++;
            }
        } else
            jfx_node.setVisible(false);
    }
}
Also used : Shape(javafx.scene.shape.Shape) Node(javafx.scene.Node) Color(javafx.scene.paint.Color) Polyline(javafx.scene.shape.Polyline)

Example 3 with Polyline

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

the class PolylineRepresentation method createJFXNode.

@Override
public Group createJFXNode() throws Exception {
    final Polyline polyline = new Polyline();
    polyline.setStrokeLineJoin(StrokeLineJoin.MITER);
    polyline.setStrokeLineCap(StrokeLineCap.BUTT);
    return new Group(polyline, new Arrow(), new Arrow());
}
Also used : Group(javafx.scene.Group) Polyline(javafx.scene.shape.Polyline)

Example 4 with Polyline

use of javafx.scene.shape.Polyline in project jphp by jphp-compiler.

the class TabOutlineMarker method updateBounds.

/**
 * Update the tab outline
 *
 * @param containerBounds
 *            the bounds of the container
 * @param referenceBounds
 *            the bounds of the reference tab
 * @param before
 *            <code>true</code> to mark the insert point before reference
 *            bounds
 */
public void updateBounds(Bounds containerBounds, Bounds referenceBounds, boolean before) {
    if (containerBounds.equals(this.containerBounds) && referenceBounds.equals(this.referenceBounds) && before == this.before) {
        return;
    }
    this.containerBounds = containerBounds;
    this.referenceBounds = referenceBounds;
    this.before = before;
    Polyline pl = new Polyline();
    Bounds _referenceBounds = referenceBounds;
    if (before) {
        _referenceBounds = new BoundingBox(Math.max(0, _referenceBounds.getMinX() - _referenceBounds.getWidth() / 2), _referenceBounds.getMinY(), _referenceBounds.getWidth(), _referenceBounds.getHeight());
    } else {
        _referenceBounds = new BoundingBox(Math.max(0, _referenceBounds.getMaxX() - _referenceBounds.getWidth() / 2), _referenceBounds.getMinY(), _referenceBounds.getWidth(), _referenceBounds.getHeight());
    }
    pl.getPoints().addAll(// start
    Double.valueOf(0.0), Double.valueOf(_referenceBounds.getMaxY()), // tab start
    Double.valueOf(_referenceBounds.getMinX()), Double.valueOf(_referenceBounds.getMaxY()), // // tab start top
    Double.valueOf(_referenceBounds.getMinX()), Double.valueOf(_referenceBounds.getMinY()), // tab end right
    Double.valueOf(_referenceBounds.getMaxX()), Double.valueOf(_referenceBounds.getMinY()), // tab end bottom
    Double.valueOf(_referenceBounds.getMaxX()), Double.valueOf(_referenceBounds.getMaxY()), // end
    Double.valueOf(containerBounds.getMaxX()), Double.valueOf(_referenceBounds.getMaxY()), // -----------------
    Double.valueOf(containerBounds.getMaxX()), Double.valueOf(containerBounds.getMaxY()), // -----------------
    Double.valueOf(containerBounds.getMinX()), Double.valueOf(containerBounds.getMaxY()), // -----------------
    Double.valueOf(containerBounds.getMinX()), Double.valueOf(_referenceBounds.getMaxY()));
    pl.strokeProperty().bind(fillProperty());
    pl.setStrokeWidth(3);
    pl.setStrokeType(StrokeType.INSIDE);
    getChildren().setAll(pl);
}
Also used : Bounds(javafx.geometry.Bounds) BoundingBox(javafx.geometry.BoundingBox) Polyline(javafx.scene.shape.Polyline)

Aggregations

Polyline (javafx.scene.shape.Polyline)4 BoundingBox (javafx.geometry.BoundingBox)1 Bounds (javafx.geometry.Bounds)1 Group (javafx.scene.Group)1 Node (javafx.scene.Node)1 Bloom (javafx.scene.effect.Bloom)1 GaussianBlur (javafx.scene.effect.GaussianBlur)1 Color (javafx.scene.paint.Color)1 Shape (javafx.scene.shape.Shape)1