Search in sources :

Example 46 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 47 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 48 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 49 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)

Example 50 with Rectangle2D

use of javafx.geometry.Rectangle2D in project org.csstudio.display.builder by kasemir.

the class Tracker method startDrag.

/**
 * @param event {@link MouseEvent}
 */
protected void startDrag(final MouseEvent event) {
    // Take snapshot of current positions
    if (event == null) {
        start_x = -1;
        start_y = -1;
    } else {
        event.consume();
        start_x = event.getX();
        start_y = event.getY();
    }
    orig = new Rectangle2D(tracker.getX(), tracker.getY(), tracker.getWidth(), tracker.getHeight());
}
Also used : Rectangle2D(javafx.geometry.Rectangle2D)

Aggregations

Rectangle2D (javafx.geometry.Rectangle2D)96 Image (javafx.scene.image.Image)14 Point2D (javafx.geometry.Point2D)13 Scene (javafx.scene.Scene)11 Color (javafx.scene.paint.Color)11 Screen (javafx.stage.Screen)11 List (java.util.List)8 IOException (java.io.IOException)7 Rectangle (javafx.scene.shape.Rectangle)7 Stage (javafx.stage.Stage)7 GameApplication (com.almasb.fxgl.app.GameApplication)6 GameSettings (com.almasb.fxgl.app.GameSettings)6 FXGL (com.almasb.fxgl.dsl.FXGL)6 KeyCode (javafx.scene.input.KeyCode)6 Duration (javafx.util.Duration)6 Interpolators (com.almasb.fxgl.animation.Interpolators)4 FXGLMath (com.almasb.fxgl.core.math.FXGLMath)4 Entity (com.almasb.fxgl.entity.Entity)4 BufferedImage (java.awt.image.BufferedImage)4 Collectors (java.util.stream.Collectors)4