Search in sources :

Example 6 with Shape

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

the class Unit method setSecondaryWeaponWithCustomOffsets.

/**
 * Asetetaan sekundaarinen ase unittiin. Asetta ei laiteta koottavien komponenttien joukkoon, sen sijaan ase sijoitetaan sen komponentin poikkeaman perusteella.
 * @param secondaryWeapon Weapon-rajapinnan toteuttava olio.
 */
public void setSecondaryWeaponWithCustomOffsets(Weapon secondaryWeapon) {
    secondaryWeapon.setParentUnit(this);
    // asetetaan komponentin poikkeama
    Shape componentShape = secondaryWeapon.getShape();
    componentShape.setLayoutX(secondaryWeapon.getOffset().getX());
    componentShape.setLayoutY(secondaryWeapon.getOffset().getY());
    this.secondaryWeapon = secondaryWeapon;
    Platform.runLater(() -> this.getChildren().add((secondaryWeapon).getShape()));
// tästä metodista ei mene koottavien komponenttien joukkoon
}
Also used : Shape(javafx.scene.shape.Shape)

Example 7 with Shape

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

the class Unit method addPrimaryWeaponWithCustomOffsets.

/**
 * Lisätään pääase unittiin. Asetta ei laiteta koottavien komponenttien joukkoon, sen sijaan ase sijoitetaan sen komponentin poikkeaman perusteella.
 * @param primaryWeapon Weapon-rajapinnan toteuttava olio.
 */
public void addPrimaryWeaponWithCustomOffsets(Weapon primaryWeapon) {
    (primaryWeapon).setParentUnit(this);
    // asetetaan komponentin poikkeama
    Shape componentShape = primaryWeapon.getShape();
    componentShape.setLayoutX(primaryWeapon.getOffset().getX());
    componentShape.setLayoutY(primaryWeapon.getOffset().getY());
    this.primaryWeapons.add(primaryWeapon);
    Platform.runLater(() -> this.getChildren().add((primaryWeapon).getShape()));
// tästä metodista ei mene koottavien komponenttien joukkoon
}
Also used : Shape(javafx.scene.shape.Shape)

Example 8 with Shape

use of javafx.scene.shape.Shape 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 9 with Shape

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

the class ByteMonitorRepresentation method addLEDs.

private void addLEDs(final Pane pane, final int w, final int h, final boolean horizontal) {
    final int save_bits = numBits;
    final boolean save_sq = square_led;
    final Color[] save_colorVals = value_colors;
    final Shape[] leds = new Shape[save_bits];
    for (int i = 0; i < save_bits; i++) {
        final Shape led;
        if (save_sq) {
            final Rectangle rect = new Rectangle();
            rect.setX(horizontal ? i * w / save_bits : 0);
            rect.setY(horizontal ? 0 : i * h / save_bits);
            rect.setWidth(horizontal ? w / save_bits : w);
            rect.setHeight(horizontal ? h : h / save_bits);
            led = rect;
        } else {
            final Ellipse ell = new Ellipse();
            final int dh = horizontal ? w / save_bits : w;
            final int dv = horizontal ? h : h / save_bits;
            ell.setCenterX(horizontal ? dh / 2 + i * dh : dh / 2);
            ell.setCenterY(horizontal ? dv / 2 : dv / 2 + i * dv);
            ell.setRadiusX(dh / 2);
            ell.setRadiusY(dv / 2);
            led = ell;
        }
        led.getStyleClass().add("led");
        if (save_colorVals != null && i < save_colorVals.length)
            led.setFill(makeGradient(save_colorVals[i]));
        leds[i] = led;
    }
    this.leds = leds;
    pane.getChildren().clear();
    pane.getChildren().addAll(leds);
}
Also used : Ellipse(javafx.scene.shape.Ellipse) Shape(javafx.scene.shape.Shape) Color(javafx.scene.paint.Color) Rectangle(javafx.scene.shape.Rectangle)

Example 10 with Shape

use of javafx.scene.shape.Shape in project contentment by GeePawHill.

the class TypeFace method font.

public static Style font(Font font, Double width, Double opacity) {
    StyleApplier applier = new StyleApplier() {

        @Override
        public void apply(Shape shape) {
            if (shape instanceof Text) {
                Text text = (Text) shape;
                text.setFont(font);
                text.setStrokeWidth(width);
                text.setOpacity(opacity);
            }
        }
    };
    return new Style(FACE, applier, font.getFamily() + " " + font.getSize());
}
Also used : Shape(javafx.scene.shape.Shape) Style(org.geepawhill.contentment.format.Style) Text(javafx.scene.text.Text) StyleApplier(org.geepawhill.contentment.format.StyleApplier)

Aggregations

Shape (javafx.scene.shape.Shape)35 Rectangle (javafx.scene.shape.Rectangle)9 Node (javafx.scene.Node)8 Test (org.junit.Test)7 TimeGraphDrawnEventProvider (com.efficios.jabberwocky.views.timegraph.model.provider.drawnevents.TimeGraphDrawnEventProvider)6 Color (javafx.scene.paint.Color)6 Circle (javafx.scene.shape.Circle)6 StubDrawnEventProvider1 (org.lttng.scope.views.timeline.widgets.timegraph.StubDrawnEventProviders.StubDrawnEventProvider1)6 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 Platform (javafx.application.Platform)4 Text (javafx.scene.text.Text)4 Bounds (javafx.geometry.Bounds)3 Parent (javafx.scene.Parent)3 URL (java.net.URL)2 ResourceBundle (java.util.ResourceBundle)2 SimpleIntegerProperty (javafx.beans.property.SimpleIntegerProperty)2 FXML (javafx.fxml.FXML)2 Initializable (javafx.fxml.Initializable)2