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