Search in sources :

Example 41 with Rectangle2D

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);
}
Also used : DisplayModel(org.csstudio.display.builder.model.DisplayModel) CompoundUndoableAction(org.csstudio.display.builder.util.undo.CompoundUndoableAction) Rectangle2D(javafx.geometry.Rectangle2D)

Example 42 with Rectangle2D

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);
}
Also used : ChildrenProperty(org.csstudio.display.builder.model.ChildrenProperty) UndoableActionManager(org.csstudio.display.builder.util.undo.UndoableActionManager) Rectangle2D(javafx.geometry.Rectangle2D) GroupWidget(org.csstudio.display.builder.model.widgets.GroupWidget) GroupWidgetsAction(org.csstudio.display.builder.editor.undo.GroupWidgetsAction)

Example 43 with Rectangle2D

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());
}
Also used : RTImagePlotListener(org.csstudio.javafx.rtplot.RTImagePlotListener) RegionOfInterest(org.csstudio.javafx.rtplot.RegionOfInterest) Rectangle2D(javafx.geometry.Rectangle2D)

Example 44 with Rectangle2D

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;
}
Also used : RegionOfInterest(org.csstudio.javafx.rtplot.RegionOfInterest) Rectangle2D(javafx.geometry.Rectangle2D) BufferedImage(java.awt.image.BufferedImage) Image(javafx.scene.image.Image)

Example 45 with Rectangle2D

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());
}
Also used : Rectangle2D(javafx.geometry.Rectangle2D)

Aggregations

Rectangle2D (javafx.geometry.Rectangle2D)76 Image (javafx.scene.image.Image)14 Scene (javafx.scene.Scene)10 Screen (javafx.stage.Screen)10 Stage (javafx.stage.Stage)7 Point2D (javafx.geometry.Point2D)6 IOException (java.io.IOException)5 ImageView (javafx.scene.image.ImageView)5 BufferedImage (java.awt.image.BufferedImage)4 File (java.io.File)4 List (java.util.List)4 Color (javafx.scene.paint.Color)4 Optional (java.util.Optional)3 Level (java.util.logging.Level)3 Application (javafx.application.Application)3 Platform (javafx.application.Platform)3 Menu (javafx.scene.control.Menu)3 MenuBar (javafx.scene.control.MenuBar)3 MenuItem (javafx.scene.control.MenuItem)3 Pane (javafx.scene.layout.Pane)3