Search in sources :

Example 6 with Points

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

the class PointsBinding method pointsChanged.

// PointsEditorListener
@Override
public void pointsChanged(final Points screen_points) {
    // Update widget with edited points
    final Points points = screen_points.clone();
    final int N = points.size();
    // Widget may be inside a container
    final Point2D offset = GeometryTools.getDisplayOffset(widget);
    // Determine coordinate range of points
    double x0 = Double.MAX_VALUE, y0 = Double.MAX_VALUE;
    double x1 = 0, y1 = 0;
    for (int i = 0; i < N; ++i) {
        final double x = points.getX(i) - offset.getX();
        final double y = points.getY(i) - offset.getY();
        x0 = Math.min(x, x0);
        y0 = Math.min(y, y0);
        x1 = Math.max(x, x1);
        y1 = Math.max(y, y1);
    }
    // Adjust points relative to x0, y0 and widget's container offset
    for (int i = 0; i < N; ++i) {
        final double x = points.getX(i) - offset.getX();
        final double y = points.getY(i) - offset.getY();
        points.setX(i, x - x0);
        points.setY(i, y - y0);
    }
    changing_widget = true;
    try {
        if (N > 0)
            undo.execute(new SetWidgetPointsAction(widget.getProperty(propPoints), points, (int) x0, (int) y0, (int) (x1 - x0), (int) (y1 - y0)));
        else
            undo.execute(new SetWidgetPointsAction(widget.getProperty(propPoints), points));
    } finally {
        changing_widget = false;
    }
}
Also used : CommonWidgetProperties.propPoints(org.csstudio.display.builder.model.properties.CommonWidgetProperties.propPoints) Points(org.csstudio.display.builder.model.properties.Points) Point2D(javafx.geometry.Point2D) SetWidgetPointsAction(org.csstudio.display.builder.editor.undo.SetWidgetPointsAction)

Example 7 with Points

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

the class PointsBinding method scaleHoriz.

private void scaleHoriz(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.setX(i, factor * points.getX(i));
    prop.setValue(points);
}
Also used : CommonWidgetProperties.propPoints(org.csstudio.display.builder.model.properties.CommonWidgetProperties.propPoints) Points(org.csstudio.display.builder.model.properties.Points)

Example 8 with Points

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

the class PolygonWidget 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(background_color = propBackgroundColor.createProperty(this, new WidgetColor(50, 50, 255)));
    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)

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