Search in sources :

Example 1 with Points

use of org.csstudio.display.builder.model.properties.Points in project org.csstudio.display.builder by kasemir.

the class PointsBinding method createEditor.

/**
 * @param widget Widget for which to create editor
 */
private void createEditor(final Widget widget) {
    disposeEditor();
    this.widget = Objects.requireNonNull(widget);
    // Turn points from widget into absolute screen coords for editor
    final Points screen_points = widget.getProperty(propPoints).getValue().clone();
    final Point2D offset = GeometryTools.getDisplayOffset(widget);
    final double x0 = widget.getProperty(propX).getValue() + offset.getX();
    final double y0 = widget.getProperty(propY).getValue() + offset.getY();
    final int N = screen_points.size();
    for (int i = 0; i < N; ++i) {
        screen_points.setX(i, x0 + screen_points.getX(i));
        screen_points.setY(i, y0 + screen_points.getY(i));
    }
    editor = new PointsEditor(parent, screen_points, this);
    widget.getProperty(propX).addUntypedPropertyListener(this);
    widget.getProperty(propY).addUntypedPropertyListener(this);
    widget.getProperty(propWidth).addUntypedPropertyListener(this);
    widget.getProperty(propHeight).addUntypedPropertyListener(this);
    widget.getProperty(propPoints).addUntypedPropertyListener(this);
}
Also used : CommonWidgetProperties.propPoints(org.csstudio.display.builder.model.properties.CommonWidgetProperties.propPoints) Points(org.csstudio.display.builder.model.properties.Points) Point2D(javafx.geometry.Point2D)

Example 2 with Points

use of org.csstudio.display.builder.model.properties.Points in project org.csstudio.display.builder by kasemir.

the class PointsEditorDemo method start.

@Override
public void start(final Stage stage) throws Exception {
    poly.setStroke(Color.BLUE);
    poly.setStrokeWidth(4);
    poly.setStrokeLineCap(StrokeLineCap.ROUND);
    poly.setStrokeLineJoin(StrokeLineJoin.ROUND);
    poly.setFill(Color.CORNSILK);
    final Group root = new Group();
    root.getChildren().add(poly);
    final Scene scene = new Scene(root, 400, 400);
    stage.setScene(scene);
    stage.show();
    EditorUtil.setSceneStyle(scene);
    editor = new PointsEditor(root, points, new PointsEditorListener() {

        @Override
        public void pointsChanged(final Points points) {
            updatePoly();
        }

        @Override
        public void done() {
            editor.dispose();
        }
    });
    updatePoly();
}
Also used : Group(javafx.scene.Group) Points(org.csstudio.display.builder.model.properties.Points) Scene(javafx.scene.Scene)

Example 3 with Points

use of org.csstudio.display.builder.model.properties.Points in project org.csstudio.display.builder by kasemir.

the class PolylineWidget method defineProperties.

@Override
protected void defineProperties(final List<WidgetProperty<?>> properties) {
    super.defineProperties(properties);
    properties.add(line_width = propLineWidth.createProperty(this, 3));
    properties.add(line_color = propLineColor.createProperty(this, new WidgetColor(0, 0, 255)));
    properties.add(line_style = propLineStyle.createProperty(this, LineStyle.SOLID));
    properties.add(arrows = propArrows.createProperty(this, Arrows.NONE));
    properties.add(arrow_length = propArrowLength.createProperty(this, 20));
    properties.add(points = propPoints.createProperty(this, new Points()));
}
Also used : CommonWidgetProperties.propPoints(org.csstudio.display.builder.model.properties.CommonWidgetProperties.propPoints) Points(org.csstudio.display.builder.model.properties.Points) WidgetColor(org.csstudio.display.builder.model.properties.WidgetColor)

Example 4 with Points

use of org.csstudio.display.builder.model.properties.Points in project org.csstudio.display.builder by kasemir.

the class JFXPointsDialogDemo method start.

@Override
public void start(final Stage stage) {
    final Points points = new Points();
    points.add(1, 10);
    points.add(2, 20);
    points.add(3, 30);
    final PointsDialog dialog = new PointsDialog(points);
    System.out.println(dialog.showAndWait());
}
Also used : Points(org.csstudio.display.builder.model.properties.Points) PointsDialog(org.csstudio.display.builder.representation.javafx.PointsDialog)

Example 5 with Points

use of org.csstudio.display.builder.model.properties.Points in project org.csstudio.display.builder by kasemir.

the class PointsBinding method scaleVert.

private void scaleVert(final Widget widget, final Number new_size, final Number old_size) {
    final double factor = new_size.doubleValue() / old_size.doubleValue();
    final WidgetProperty<Points> prop = widget.getProperty(propPoints);
    final Points points = prop.getValue().clone();
    final int N = points.size();
    for (int i = 0; i < N; ++i) points.setY(i, factor * points.getY(i));
    prop.setValue(points);
}
Also used : CommonWidgetProperties.propPoints(org.csstudio.display.builder.model.properties.CommonWidgetProperties.propPoints) Points(org.csstudio.display.builder.model.properties.Points)

Aggregations

Points (org.csstudio.display.builder.model.properties.Points)8 CommonWidgetProperties.propPoints (org.csstudio.display.builder.model.properties.CommonWidgetProperties.propPoints)6 Point2D (javafx.geometry.Point2D)2 WidgetColor (org.csstudio.display.builder.model.properties.WidgetColor)2 Group (javafx.scene.Group)1 Scene (javafx.scene.Scene)1 SetWidgetPointsAction (org.csstudio.display.builder.editor.undo.SetWidgetPointsAction)1 PointsDialog (org.csstudio.display.builder.representation.javafx.PointsDialog)1