private void resetZoom(Point2D point) { if (!isZoomable()) { return; } Navigable navigable = InteractivePanel.getNavigableAt(getDrawable(), point); if (navigable == null) { return; } Navigator navigator = navigable.getNavigator(); navigator.reset(); repaint(); }
/** * Zooms a navigable object in (positive values) or out (negative values). * * @param point The location where the zoom was triggered. * @param times Number of times the navigable object will be zoomed. Positive values zoom in, * negative values zoom out. */ private void zoom(Point2D point, int times) { if (!isZoomable()) { return; } Navigable navigable = InteractivePanel.getNavigableAt(getDrawable(), point); if (navigable == null) { return; } Navigator navigator = navigable.getNavigator(); if (times >= 0) { for (int i = 0; i < times; i++) { navigator.zoomOut(); } } else { for (int i = 0; i < -times; i++) { navigator.zoomIn(); } } repaint(); }
@Override public void mouseDragged(MouseEvent e) { if (navigable == null) { return; } // Calculate distance that the current view was dragged // (screen units) Point pos = e.getPoint(); Navigator navigator = navigable.getNavigator(); int dx = pos.x - posPrev.x; int dy = pos.y - posPrev.y; posPrev = pos; if (Math.abs(dx) > MIN_DRAG || Math.abs(dy) > MIN_DRAG) { PointND<Integer> deltas = new PointND<Integer>(dx, dy); navigator.pan(deltas); panel.repaint(); } }