use of org.csstudio.javafx.rtplot.internal.undo.ChangeImageZoom in project org.csstudio.display.builder by kasemir.
the class ImagePlot method mouseUp.
/**
* setOnMouseReleased
*/
private void mouseUp(final MouseEvent e) {
final Point2D start = mouse_start.orElse(null);
final Point2D current = mouse_current.orElse(null);
if (start == null || current == null)
return;
if (mouse_mode == MouseMode.PAN_PLOT) {
mouseMove(e);
undo.add(new ChangeImageZoom(Messages.Pan, x_axis, mouse_start_x_range, x_axis.getValueRange(), y_axis, mouse_start_y_range, y_axis.getValueRange()));
mouse_mode = MouseMode.PAN;
mouse_start_x_range = null;
mouse_start_y_range = null;
} else if (mouse_mode == MouseMode.ZOOM_IN_X) {
// X axis increases going _right_ just like mouse 'x' coordinate
if (Math.abs(start.getX() - current.getX()) > ZOOM_PIXEL_THRESHOLD) {
final int low = (int) Math.min(start.getX(), current.getX());
final int high = (int) Math.max(start.getX(), current.getX());
final AxisRange<Double> original_x_range = x_axis.getValueRange();
final AxisRange<Double> new_x_range = getRestrictedRange(x_axis.getValue(low), x_axis.getValue(high), min_x, max_x);
undo.execute(new ChangeImageZoom(x_axis, original_x_range, new_x_range, null, null, null));
}
mouse_mode = MouseMode.ZOOM_IN;
} else if (mouse_mode == MouseMode.ZOOM_IN_Y) {
// Mouse 'y' increases going _down_ the screen
if (Math.abs(start.getY() - current.getY()) > ZOOM_PIXEL_THRESHOLD) {
final int high = (int) Math.min(start.getY(), current.getY());
final int low = (int) Math.max(start.getY(), current.getY());
final AxisRange<Double> original_y_range = y_axis.getValueRange();
final AxisRange<Double> new_y_range = getRestrictedRange(y_axis.getValue(low), y_axis.getValue(high), min_y, max_y);
undo.execute(new ChangeImageZoom(null, null, null, y_axis, original_y_range, new_y_range));
}
mouse_mode = MouseMode.ZOOM_IN;
} else if (mouse_mode == MouseMode.ZOOM_IN_PLOT) {
if (Math.abs(start.getX() - current.getX()) > ZOOM_PIXEL_THRESHOLD || Math.abs(start.getY() - current.getY()) > ZOOM_PIXEL_THRESHOLD) {
// X axis increases going _right_ just like mouse 'x' coordinate
int low = (int) Math.min(start.getX(), current.getX());
int high = (int) Math.max(start.getX(), current.getX());
final AxisRange<Double> original_x_range = x_axis.getValueRange();
final AxisRange<Double> new_x_range = getRestrictedRange(x_axis.getValue(low), x_axis.getValue(high), min_x, max_x);
// Mouse 'y' increases going _down_ the screen
high = (int) Math.min(start.getY(), current.getY());
low = (int) Math.max(start.getY(), current.getY());
final AxisRange<Double> original_y_range = y_axis.getValueRange();
final AxisRange<Double> new_y_range = getRestrictedRange(y_axis.getValue(low), y_axis.getValue(high), min_y, max_y);
undo.execute(new ChangeImageZoom(x_axis, original_x_range, new_x_range, y_axis, original_y_range, new_y_range));
}
mouse_mode = MouseMode.ZOOM_IN;
}
}
use of org.csstudio.javafx.rtplot.internal.undo.ChangeImageZoom in project org.csstudio.display.builder by kasemir.
the class RTImagePlot method changeAxisLimit.
protected void changeAxisLimit(AxisPart<Double> axis, boolean isHigh, Double value) {
AxisRange<Double> old_range = axis.getValueRange();
AxisRange<Double> new_range = isHigh ? new AxisRange<>(old_range.getLow(), value) : new AxisRange<>(value, old_range.getHigh());
if (// Y axis?
axis instanceof YAxisImpl<?>) {
getUndoableActionManager().execute(new ChangeImageZoom(Messages.Set_Axis_Range, null, null, null, axis, old_range, new_range));
} else // X axis
{
getUndoableActionManager().execute(new ChangeImageZoom(Messages.Set_Axis_Range, axis, old_range, new_range, null, null, null));
}
}
use of org.csstudio.javafx.rtplot.internal.undo.ChangeImageZoom in project org.csstudio.display.builder by kasemir.
the class ImagePlot method zoomInOut.
/**
* Zoom 'in' or 'out' from where the mouse was clicked
* @param x Mouse coordinate
* @param y Mouse coordinate
* @param factor Zoom factor, positive to zoom 'out'
*/
@Override
protected void zoomInOut(final double x, final double y, final double factor) {
// In case ROI is visible, hide because zoom invalidates the tracker position on the screen
removeROITracker();
final boolean zoom_x = x_axis.getBounds().contains(x, y);
final boolean zoom_y = y_axis.getBounds().contains(x, y);
final boolean zoom_both = image_area.getBounds().contains(x, y);
AxisRange<Double> orig_x = null, orig_y = null;
if (zoom_x || zoom_both)
orig_x = zoomAxis(x_axis, (int) x, factor, min_x, max_x);
if (zoom_y || zoom_both)
orig_y = zoomAxis(y_axis, (int) y, factor, min_y, max_y);
if (zoom_both)
undo.add(new ChangeImageZoom(x_axis, orig_x, x_axis.getValueRange(), y_axis, orig_y, y_axis.getValueRange()));
else if (zoom_x)
undo.add(new ChangeImageZoom(x_axis, orig_x, x_axis.getValueRange(), null, null, null));
else if (zoom_y)
undo.add(new ChangeImageZoom(null, null, null, y_axis, orig_y, y_axis.getValueRange()));
}
Aggregations