Search in sources :

Example 1 with Tracker

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

the class ImagePlot method mouseDown.

/**
 * onMousePressed
 */
private void mouseDown(final MouseEvent e) {
    // Don't start mouse actions when user invokes context menu
    if (!e.isPrimaryButtonDown() || (PlatformInfo.is_mac_os_x && e.isControlDown()))
        return;
    // -> User clicked outside of tracker. Remove it.
    if (roi_tracker != null) {
        removeROITracker();
        // User needs to click again for that.
        return;
    }
    // Select any tracker
    final Point2D current = new Point2D(e.getX(), e.getY());
    for (RegionOfInterest roi : rois) if (roi.isVisible() && roi.isInteractive()) {
        final Rectangle rect = roiToScreen(roi);
        if (rect.contains(current.getX(), current.getY())) {
            // Check if complete ROI is visible,
            // because otherwise tracker would extend beyond the
            // current image viewport
            final Rectangle2D image_rect = GraphicsUtils.convert(image_area);
            if (image_rect.contains(rect.x, rect.y, rect.width, rect.height)) {
                roi_tracker = new Tracker(image_rect);
                roi_tracker.setPosition(rect.x, rect.y, rect.width, rect.height);
                ChildCare.addChild(getParent(), roi_tracker);
                final int index = rois.indexOf(roi);
                roi_tracker.setListener((old_pos, new_pos) -> updateRoiFromScreen(index, new_pos));
                return;
            }
        }
    }
    mouse_start = mouse_current = Optional.of(current);
    final int clicks = e.getClickCount();
    if (mouse_mode == MouseMode.NONE) {
        if (crosshair) {
            updateLocationInfo(e.getX(), e.getY());
            requestRedraw();
        }
    } else if (mouse_mode == MouseMode.PAN) {
        // Determine start of 'pan'
        mouse_start_x_range = x_axis.getValueRange();
        mouse_start_y_range = y_axis.getValueRange();
        mouse_mode = MouseMode.PAN_PLOT;
    } else if (mouse_mode == MouseMode.ZOOM_IN && clicks == 1) {
        // Reset cursor from SIZE* to CROSS.
        if (y_axis.getBounds().contains(current.getX(), current.getY())) {
            mouse_mode = MouseMode.ZOOM_IN_Y;
            PlotCursors.setCursor(this, mouse_mode);
        } else if (image_area.contains(current.getX(), current.getY())) {
            mouse_mode = MouseMode.ZOOM_IN_PLOT;
            PlotCursors.setCursor(this, mouse_mode);
        } else if (x_axis.getBounds().contains(current.getX(), current.getY())) {
            mouse_mode = MouseMode.ZOOM_IN_X;
            PlotCursors.setCursor(this, mouse_mode);
        }
    } else if ((mouse_mode == MouseMode.ZOOM_IN && clicks == 2) || mouse_mode == MouseMode.ZOOM_OUT)
        zoomInOut(current.getX(), current.getY(), ZOOM_FACTOR);
}
Also used : Color(java.awt.Color) Rectangle(java.awt.Rectangle) Interpolation(org.csstudio.javafx.rtplot.Interpolation) ArrayByte(org.diirt.util.array.ArrayByte) ListNumber(org.diirt.util.array.ListNumber) MouseEvent(javafx.scene.input.MouseEvent) IteratorNumber(org.diirt.util.array.IteratorNumber) VImageType(org.diirt.vtype.VImageType) RenderingHints(java.awt.RenderingHints) ChangeImageZoom(org.csstudio.javafx.rtplot.internal.undo.ChangeImageZoom) Level(java.util.logging.Level) RTImagePlotListener(org.csstudio.javafx.rtplot.RTImagePlotListener) DataBufferInt(java.awt.image.DataBufferInt) ChildCare(org.csstudio.javafx.ChildCare) Graphics2D(java.awt.Graphics2D) ArrayInt(org.diirt.util.array.ArrayInt) Point2D(javafx.geometry.Point2D) PlatformInfo(org.csstudio.javafx.PlatformInfo) GraphicsUtils(org.csstudio.javafx.rtplot.internal.util.GraphicsUtils) Rectangle2D(javafx.geometry.Rectangle2D) Messages(org.csstudio.javafx.rtplot.Messages) BufferedImage(java.awt.image.BufferedImage) Activator.logger(org.csstudio.javafx.rtplot.Activator.logger) ToIntFunction(java.util.function.ToIntFunction) Font(javafx.scene.text.Font) RegionOfInterest(org.csstudio.javafx.rtplot.RegionOfInterest) DoubleBuffer(org.csstudio.javafx.DoubleBuffer) ValueRange(org.csstudio.javafx.rtplot.data.ValueRange) ArrayShort(org.diirt.util.array.ArrayShort) Objects(java.util.Objects) Cursor(javafx.scene.Cursor) List(java.util.List) Tracker(org.csstudio.javafx.Tracker) Log10(org.csstudio.javafx.rtplot.internal.util.Log10) ToDoubleFunction(java.util.function.ToDoubleFunction) BufferUtil(org.csstudio.javafx.BufferUtil) SwingFXUtils(javafx.embed.swing.SwingFXUtils) Optional(java.util.Optional) ColorMappingFunction(org.csstudio.javafx.rtplot.ColorMappingFunction) Axis(org.csstudio.javafx.rtplot.Axis) LinearScreenTransform(org.csstudio.javafx.rtplot.internal.util.LinearScreenTransform) AxisRange(org.csstudio.javafx.rtplot.AxisRange) Image(javafx.scene.image.Image) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Tracker(org.csstudio.javafx.Tracker) RegionOfInterest(org.csstudio.javafx.rtplot.RegionOfInterest) Point2D(javafx.geometry.Point2D) Rectangle(java.awt.Rectangle) Rectangle2D(javafx.geometry.Rectangle2D)

Aggregations

Color (java.awt.Color)1 Graphics2D (java.awt.Graphics2D)1 Rectangle (java.awt.Rectangle)1 RenderingHints (java.awt.RenderingHints)1 BufferedImage (java.awt.image.BufferedImage)1 DataBufferInt (java.awt.image.DataBufferInt)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 ToDoubleFunction (java.util.function.ToDoubleFunction)1 ToIntFunction (java.util.function.ToIntFunction)1 Level (java.util.logging.Level)1 SwingFXUtils (javafx.embed.swing.SwingFXUtils)1 Point2D (javafx.geometry.Point2D)1 Rectangle2D (javafx.geometry.Rectangle2D)1 Cursor (javafx.scene.Cursor)1 Image (javafx.scene.image.Image)1 MouseEvent (javafx.scene.input.MouseEvent)1 Font (javafx.scene.text.Font)1