@Override public void run() { display.getCanvas().setZoom(1); } });
@Override public void run() { display.getCanvas().setZoomAndCenter(zoomPercent / 100.0, new RealCoords(centerU, centerV)); } });
@Override public void run() { final RealRect selection = overlayService.getSelectionBounds(display); display.getCanvas().zoomToFit(selection); } });
/** * Gets the coordinates in <em>data</em> space for the given (x, y) pixel * coordinates. */ private RealCoords getDataCoords(final Display<?> d, final int x, final int y) { if (!(d instanceof ImageDisplay)) return null; final ImageDisplay imageDisplay = (ImageDisplay) d; final ImageCanvas canvas = imageDisplay.getCanvas(); return canvas.panelToDataCoords(new IntCoords(x, y)); }
@Override public Dimension getPreferredSize() { final Dimension drawViewSize = super.getPreferredSize(); if (drawViewSize.width > 0 && drawViewSize.height > 0) { // NB: Current preferred size is OK. return drawViewSize; } // NB: One or more figures in the drawing view are not initialized yet. // So we calculate the projected size manually. final RealRect imageBounds = getDisplay().getPlaneExtents(); final double zoomFactor = getDisplay().getCanvas().getZoomFactor(); final int x = (int) (imageBounds.width * zoomFactor); final int y = (int) (imageBounds.height * zoomFactor); // HACK: Add extra space to avoid unnecessary scroll bars. final int extra = 2; return new Dimension(x + extra, y + extra); } };
@Override public void run() { if (inputService.getDisplay() == display) { // zoom in centered around the mouse cursor final int x = inputService.getX(); final int y = inputService.getY(); display.getCanvas().zoomIn(new IntCoords(x, y)); } else { // no mouse coordinates available; use default behavior display.getCanvas().zoomIn(); } } });
private void doInitialSizing() { final double scale = findFullyVisibleScale(); final double zoomLevel = display.getCanvas().getBestZoomLevel(scale); final ImageCanvas canvas = displayViewer.getDisplay().getCanvas(); canvas.setZoomAndCenter(zoomLevel); if (!initialScaleCalculated) { canvas.setInitialScale(canvas.getZoomFactor()); initialScaleCalculated = true; } }
@Override public void run() { if (inputService.getDisplay() == display) { // zoom in centered around the mouse cursor final int x = inputService.getX(); final int y = inputService.getY(); display.getCanvas().zoomOut(new IntCoords(x, y)); } else { // no mouse coordinates available; use default behavior display.getCanvas().zoomOut(); } } });
@EventHandler protected void onEvent(final PanZoomEvent event) { final ImageCanvas canvas = event.getCanvas(); if (canvas != getDisplay().getCanvas()) return; // not this canvas syncUI(); }
sb.append("; "); final double zoomFactor = getDisplay().getCanvas().getZoomFactor(); if (zoomFactor != 1) { sb.append("(");
@EventHandler protected void onEvent(final MouseCursorEvent event) { final ImageCanvas canvas = event.getCanvas(); if (canvas != getDisplay().getCanvas()) return; // not this canvas final MouseCursor cursor = canvas.getCursor(); final Cursor awtCursor = AWTCursors.getCursor(cursor); drawingView.setCursor(awtCursor); }
private void sync(final boolean updateCanvas) { final ImageCanvas canvas = getDisplay().getCanvas();
@EventHandler protected void onEvent(final WinActivatedEvent event) { if (event.getDisplay() != getDisplay()) return; final ImageDisplay d = getDisplay(); if (d == null) return; d.getCanvas().setCursor(toolService.getActiveTool().getCursor()); }
private void maybeResizeWindow() { final Rectangle bounds = StaticSwingUtils.getWorkSpaceBounds(); final RealRect imageBounds = getDisplay().getPlaneExtents(); final ImageCanvas canvas = getDisplay().getCanvas(); final IntCoords topLeft = canvas.dataToPanelCoords(new RealCoords(imageBounds.x, imageBounds.y)); final IntCoords bottomRight = canvas.dataToPanelCoords(new RealCoords( imageBounds.x + imageBounds.width, imageBounds.y + imageBounds.height)); if (bottomRight.x - topLeft.x > bounds.width) return; if (bottomRight.y - topLeft.y > bounds.height) return; displayViewer.getWindow().pack(); }