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);
}
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();
}
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()));
}
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());
}
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);
}
Aggregations