use of org.csstudio.display.builder.editor.undo.SetWidgetPointsAction 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;
}
}
Aggregations