use of javafx.geometry.Rectangle2D in project org.csstudio.display.builder by kasemir.
the class SetDisplaySize method run.
@Override
public void run() {
final DisplayModel model = editor.getModel();
final Rectangle2D bounds = GeometryTools.getBounds(model.getChildren());
final CompoundUndoableAction resize = new CompoundUndoableAction(getText());
resize.add(new SetWidgetPropertyAction<Integer>(model.propWidth(), (int) (2 * bounds.getMinX() + bounds.getWidth())));
resize.add(new SetWidgetPropertyAction<Integer>(model.propHeight(), (int) (2 * bounds.getMinY() + bounds.getHeight())));
editor.getUndoableActionManager().execute(resize);
}
use of javafx.geometry.Rectangle2D in project org.csstudio.display.builder by kasemir.
the class CreateGroupAction method run.
@Override
public void run() {
editor.getWidgetSelectionHandler().clear();
// Create group that surrounds the original widget boundaries
final GroupWidget group = new GroupWidget();
// Get bounds of widgets relative to their container,
// which might be a group within the display
// or the display itself
final Rectangle2D rect = GeometryTools.getBounds(widgets);
// Inset depends on representation and changes with group style and font.
// Can be obtained via group.runtimePropInsets() _after_ the group has
// been represented. For this reason Style.NONE is used, where the inset
// is always 0. An alternative could be Style.LINE, with an inset of 1.
final int inset = 0;
group.propStyle().setValue(Style.NONE);
group.propTransparent().setValue(true);
group.propX().setValue((int) rect.getMinX() - inset);
group.propY().setValue((int) rect.getMinY() - inset);
group.propWidth().setValue((int) rect.getWidth() + 2 * inset);
group.propHeight().setValue((int) rect.getHeight() + 2 * inset);
group.propName().setValue(org.csstudio.display.builder.model.Messages.GroupWidget_Name);
final ChildrenProperty parent_children = ChildrenProperty.getParentsChildren(widgets.get(0));
final UndoableActionManager undo = editor.getUndoableActionManager();
undo.execute(new GroupWidgetsAction(parent_children, group, widgets, (int) rect.getMinX(), (int) rect.getMinY()));
editor.getWidgetSelectionHandler().toggleSelection(group);
}
use of javafx.geometry.Rectangle2D in project org.csstudio.display.builder by kasemir.
the class ImagePlot method updateRoiFromScreen.
/**
* @param roi RegionOfInterest to move to new location
* @param screen_pos Screen position, will be converted into axes' values
*/
private void updateRoiFromScreen(final int index, final Rectangle2D screen_pos) {
final RegionOfInterest roi = rois.get(index);
// Convert screen position to axis values
final double x0 = x_axis.getValue((int) screen_pos.getMinX()), y0 = y_axis.getValue((int) screen_pos.getMinY()), x1 = x_axis.getValue((int) screen_pos.getMaxX()), y1 = y_axis.getValue((int) screen_pos.getMaxY());
final double x = Math.min(x0, x1);
final double y = Math.min(y0, y1);
final Rectangle2D region = new Rectangle2D(x, y, Math.abs(x1 - x0), Math.abs(y1 - y0));
roi.setRegion(region);
requestUpdate();
// Notify listener of ROI change
final RTImagePlotListener listener = plot_listener;
if (listener != null)
listener.changedROI(index, roi.getName(), roi.getRegion());
}
use of javafx.geometry.Rectangle2D in project org.csstudio.display.builder by kasemir.
the class ImagePlot method addROI.
/**
* Add region of interest
* @param name
* @param color
* @param visible
* @param interactive
* @return {@link RegionOfInterest}
*/
public RegionOfInterest addROI(final String name, final javafx.scene.paint.Color color, final boolean visible, final boolean interactive) {
// Return a ROI that triggers a redraw as it's changed
final RegionOfInterest roi = new RegionOfInterest(name, color, visible, interactive, 0, 0, 10, 10) {
@Override
public void setImage(final Image image) {
super.setImage(image);
requestUpdate();
}
@Override
public void setVisible(boolean visible) {
super.setVisible(visible);
requestUpdate();
}
@Override
public void setRegion(Rectangle2D region) {
super.setRegion(region);
requestUpdate();
}
};
rois.add(roi);
return roi;
}
use of javafx.geometry.Rectangle2D in project org.csstudio.display.builder by kasemir.
the class Tracker method endMouseDrag.
/**
* @param event {@link MouseEvent}
*/
protected void endMouseDrag(final MouseEvent event) {
if (start_x < 0)
return;
// Don't consume the event, otherwise the
// AutoScrollHandler will not work properly.
notifyListenerOfChange();
start_x = -1;
start_y = -1;
// Prepare for another move via keyboard
orig = new Rectangle2D(tracker.getX(), tracker.getY(), tracker.getWidth(), tracker.getHeight());
}
Aggregations