if (cursorOverImage()) { Point cursorLoc = getCursorLoc(); cursorX = screenX(cursorLoc.x); cursorY = screenY(cursorLoc.y); imp.deleteRoi(); } else zoomIn(cursorX, cursorY); } else if (arg.equals("out")) { zoomOut(cursorX, cursorY); } else if (arg.equals("orig")) { unzoom(); } else if (arg.equals("100%")) { zoom100Percent(); } else if (arg.equals("to") && roiRect != null) { plot.zoomToRect(roiRect);
/** overrides ImageCanvas.mousePressed: no further processing of clicks on 'range' arrows */ public void mousePressed(MouseEvent e) { rangeArrowIndexWhenPressed = getRangeArrowIndex(e); if (rangeArrowIndexWhenPressed <0) super.mousePressed(e); }
/** Scrolling a PlotCanvas is updating the plot, not viewing part of the plot, unless the plot is frozen */ public void setSourceRect(Rectangle r) { if (plot.isFrozen()) super.setSourceRect(r); else resetMagnification(); }
/** Resizes the plot (unless frozen) to fit the window */ public void fitToWindow() { if (plot == null || plot.isFrozen()) { super.fitToWindow(); return; } ImageWindow win = imp.getWindow(); if (win==null) return; Rectangle bounds = win.getBounds(); Dimension extraSize = win.getExtraSize(); int width = bounds.width-extraSize.width;//(insets.left+insets.right+ImageWindow.HGAP*2); int height = bounds.height-extraSize.height;//(insets.top+insets.bottom+ImageWindow.VGAP*2); //IJ.log("fitToWindow "+bounds+"-> w*h="+width+"*"+height); resizeCanvas(width, height); getParent().doLayout(); }
/** Resizes the canvas when the user resizes the window. To avoid a race condition while creating * a new window, this is ignored if no window exists or the window has not been activated yet. */ void resizeCanvas(int width, int height) { if (plot == null || plot.isFrozen()) { super.resizeCanvas(width, height); return; } resetMagnification(); if (width == oldWidth && height == oldHeight) return; if (plot == null) return; ImageWindow win = imp.getWindow(); if (win==null || !(win instanceof PlotWindow)) return; if (!win.isVisible()) return; if (!((PlotWindow)win).wasActivated) return; // window layout not finished yet? Dimension minSize = plot.getMinimumSize(); int plotWidth = width < minSize.width ? minSize.width : width; int plotHeight = height < minSize.height ? minSize.height : height; plot.setSize(plotWidth, plotHeight); setSize(width, height); oldWidth = width; oldHeight = height; }
this.imp = imp; if (ic==null) { ic = (this instanceof PlotWindow) ? new PlotCanvas(imp) : new ImageCanvas(imp); newCanvas=true;
/** Resizes the plot (unless frozen) to fit the window */ public void fitToWindow() { if (plot == null || plot.isFrozen()) { super.fitToWindow(); return; } ImageWindow win = imp.getWindow(); if (win==null) return; Rectangle bounds = win.getBounds(); Dimension extraSize = win.getExtraSize(); int width = bounds.width-extraSize.width;//(insets.left+insets.right+ImageWindow.HGAP*2); int height = bounds.height-extraSize.height;//(insets.top+insets.bottom+ImageWindow.VGAP*2); //IJ.log("fitToWindow "+bounds+"-> w*h="+width+"*"+height); resizeCanvas(width, height); getParent().doLayout(); }
/** Resizes the canvas when the user resizes the window. To avoid a race condition while creating * a new window, this is ignored if no window exists or the window has not been activated yet. */ void resizeCanvas(int width, int height) { if (plot == null || plot.isFrozen()) { super.resizeCanvas(width, height); return; } resetMagnification(); if (width == oldWidth && height == oldHeight) return; if (plot == null) return; ImageWindow win = imp.getWindow(); if (win==null || !(win instanceof PlotWindow)) return; if (!win.isVisible()) return; if (!((PlotWindow)win).wasActivated) return; // window layout not finished yet? Dimension minSize = plot.getMinimumSize(); int plotWidth = width < minSize.width ? minSize.width : width; int plotHeight = height < minSize.height ? minSize.height : height; plot.setSize(plotWidth, plotHeight); setSize(width, height); oldWidth = width; oldHeight = height; }
this.imp = imp; if (ic==null) { ic = (this instanceof PlotWindow) ? new PlotCanvas(imp) : new ImageCanvas(imp); newCanvas=true;
if (cursorOverImage()) { Point cursorLoc = getCursorLoc(); cursorX = screenX(cursorLoc.x); cursorY = screenY(cursorLoc.y); imp.deleteRoi(); } else zoomIn(cursorX, cursorY); } else if (arg.equals("out")) { zoomOut(cursorX, cursorY); } else if (arg.equals("orig")) { unzoom(); } else if (arg.equals("100%")) { zoom100Percent(); } else if (arg.equals("to") && roiRect != null) { plot.zoomToRect(roiRect);
/** The image of a PlotCanvas is always shown at 100% magnification unless the plot is frozen */ public void setMagnification(double magnification) { if (plot == null || plot.isFrozen()) super.setMagnification(magnification); else resetMagnification(); }
/** overrides ImageCanvas.mousePressed: no further processing of clicks on 'range' arrows */ public void mousePressed(MouseEvent e) { rangeArrowIndexWhenPressed = getRangeArrowIndex(e); if (rangeArrowIndexWhenPressed <0) super.mousePressed(e); }
/** Scrolling a PlotCanvas is updating the plot, not viewing part of the plot, unless the plot is frozen */ public void setSourceRect(Rectangle r) { if (plot.isFrozen()) super.setSourceRect(r); else resetMagnification(); }
/** Overrides ImageCanvas.mouseReleased, handles clicks on 'range' arrows */ public void mouseReleased(MouseEvent e) { if (rangeArrowIndexWhenPressed>=0 && rangeArrowIndexWhenPressed==getRangeArrowIndex(e)) plot.zoomOnRangeArrow(rangeArrowIndexWhenPressed); else super.mouseReleased(e); }
/** The image of a PlotCanvas is always shown at 100% magnification unless the plot is frozen */ public void setMagnification(double magnification) { if (plot == null || plot.isFrozen()) super.setMagnification(magnification); else resetMagnification(); }
/** Overrides ImageCanvas.mouseReleased, handles clicks on 'range' arrows */ public void mouseReleased(MouseEvent e) { if (rangeArrowIndexWhenPressed>=0 && rangeArrowIndexWhenPressed==getRangeArrowIndex(e)) plot.zoomOnRangeArrow(rangeArrowIndexWhenPressed); else super.mouseReleased(e); }
/** Implements the Image/Zoom/Original Scale command. * Sets the original range of the x, y axes (unless the plot is frozen) */ public void unzoom() { if (plot == null || plot.isFrozen()) { super.unzoom(); return; } resetMagnification(); plot.setLimitsToDefaults(true); }
/** Implements the Image/Zoom/View 100% command: Sets the original frame size as specified * in Edit/Options/Plots (unless the plot is frozen) */ public void zoom100Percent() { if (plot == null || plot.isFrozen()) { super.zoom100Percent(); return; } resetMagnification(); plot.setFrameSize(PlotWindow.plotWidth, PlotWindow.plotHeight); }