@Override public String toString() { return super.toString() + "\n\tviewport = " + getCanvas().getViewportWidth() + " x " + getCanvas().getViewportHeight(); }
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; } }
public CanvasEvent(final ImageCanvas canvas) { super(canvas.getDisplay()); this.canvas = canvas; }
@Override public String toString() { return super.toString() + "\n\tscale = " + getCanvas().getZoomFactor() + "\n\tcenterX = " + getCanvas().getPanCenter().x + "\n\tcenterY = " + getCanvas().getPanCenter().y; }
final int canvasWidth = canvas.getViewportWidth(); final int canvasHeight = canvas.getViewportHeight(); final double canvasZoom = canvas.getZoomFactor(); final IntCoords canvasOffset = canvas.getPanOffset(); if (sizeChanged) canvas.setViewportSize(uiSize.width, uiSize.height); canvas.setZoomAndCenter(uiZoom, new RealCoords(panCenterX, panCenterY));
@Override public String toString() { return super.toString() + "\n\tcursor = " + getCanvas().getCursor(); }
@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() { display.getCanvas().setZoomAndCenter(zoomPercent / 100.0, new RealCoords(centerU, centerV)); } });
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(); }
@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); }
sb.append("; "); final double zoomFactor = getDisplay().getCanvas().getZoomFactor(); if (zoomFactor != 1) { sb.append("(");