/** Sets the cursor based on the current tool and cursor location. */ public void setCursor(int sx, int sy, int ox, int oy) { xMouse = ox; yMouse = oy; mouseExited = false; Roi roi = imp.getRoi(); ImageWindow win = imp.getWindow(); if (win == null) return; if (IJ.spaceBarDown()) { setCursor(handCursor); return; } int id = Toolbar.getToolId(); switch (Toolbar.getToolId()) { case Toolbar.MAGNIFIER: setCursor(moveCursor); break; case Toolbar.HAND: setCursor(handCursor); break; default: // selection tool if (id == Toolbar.SPARE1 || id >= Toolbar.SPARE2) { if (Prefs.usePointerCursor) setCursor(defaultCursor); else setCursor(crosshairCursor); } else if (roi != null && roi.getState() != roi.CONSTRUCTING && roi.isHandle(sx, sy) >= 0) setCursor(handCursor); else if (Prefs.usePointerCursor || (roi != null && roi.getState() != roi.CONSTRUCTING && roi.contains(ox, oy))) setCursor(defaultCursor); else setCursor(crosshairCursor); } }
public void mouseMoved(MouseEvent e) { // if (ij==null) return; int sx = e.getX(); int sy = e.getY(); int ox = offScreenX(sx); int oy = offScreenY(sy); flags = e.getModifiers(); setCursor(sx, sy, ox, oy); IJ.setInputEvent(e); Roi roi = imp.getRoi(); if (roi != null && (roi.getType() == Roi.POLYGON || roi.getType() == Roi.POLYLINE || roi.getType() == Roi.ANGLE) && roi.getState() == roi.CONSTRUCTING) { PolygonRoi pRoi = (PolygonRoi) roi; pRoi.handleMouseMove(ox, oy); } else { if (ox < imageWidth && oy < imageHeight) { ImageWindow win = imp.getWindow(); // Cursor must move at least 12 pixels before text // displayed using IJ.showStatus() is overwritten. if ((sx - sx2) * (sx - sx2) + (sy - sy2) * (sy - sy2) > 144) showCursorStatus = true; if (win != null && showCursorStatus) win.mouseMoved(ox, oy); } else IJ.showStatus(""); } }
/*------------------------------------------------------------------*/ void setupProgressBar() { int height = imp.getHeight(); int width = imp.getWidth(); completed = 0; lastTime = System.currentTimeMillis(); switch (operation) { case GRADIENT_MAGNITUDE: processDuration = stackSize * (width + 2 * height); break; case GRADIENT_DIRECTION: processDuration = stackSize * (width + 2 * height); break; case LAPLACIAN: processDuration = stackSize * (width + 2 * height); break; case LARGEST_HESSIAN: processDuration = stackSize * (2 * width + 3 * height); break; case SMALLEST_HESSIAN: processDuration = stackSize * (2 * width + 3 * height); break; case HESSIAN_ORIENTATION: processDuration = stackSize * (2 * width + 3 * height); break; default: throw new IllegalArgumentException("Invalid operation"); } } /* end setupProgressBar */
boolean validDialogValues() { Calibration cal = imp.getCalibration(); double pw = cal.pixelWidth, ph = cal.pixelHeight; if (width / pw < 1 || height / ph < 1) return false; if (xRoi / pw > imp.getWidth() || yRoi / ph > imp.getHeight()) return false; return true; }
/** * Creates a dialog box, allowing the user to enter the requested width, height, x & y * coordinates, slice number for a Region Of Interest, option for oval, and option for whether x & * y coordinates to be centered. */ void showDialog() { Calibration cal = imp.getCalibration(); int digits = 0; if (scaledUnits && cal.scaled()) digits = 2; Roi roi = imp.getRoi(); if (roi == null) drawRoi(); GenericDialog gd = new GenericDialog("Specify"); gd.addNumericField("Width:", width, digits); gd.addNumericField("Height:", height, digits); gd.addNumericField("X coordinate:", xRoi, digits); gd.addNumericField("Y coordinate:", yRoi, digits); if (stackSize > 1) gd.addNumericField("Slice:", iSlice, 0); gd.addCheckbox("Oval", oval); gd.addCheckbox("Constrain square/circle", square); gd.addCheckbox("Centered", centered); if (cal.scaled()) { boolean unitsMatch = cal.getXUnit().equals(cal.getYUnit()); String units = unitsMatch ? cal.getUnits() : cal.getXUnit() + " x " + cal.getYUnit(); gd.addCheckbox("Scaled units (" + units + ")", scaledUnits); } fields = gd.getNumericFields(); gd.addDialogListener(this); gd.showDialog(); if (gd.wasCanceled()) { if (roi == null) imp.deleteRoi(); else // *ALWAYS* restore initial ROI when cancelled imp.setRoi(roi); } }
/** Generate output image whose type is same as input image. */ private ImagePlus makeOutputImage(ImagePlus imp, FloatProcessor fp, int ptype) { int width = imp.getWidth(); int height = imp.getHeight(); float[] pixels = (float[]) fp.getPixels(); ImageProcessor oip = null; // Create output image consistent w/ type of input image. int size = pixels.length; switch (ptype) { case BYTE_TYPE: oip = imp.getProcessor().createProcessor(width, height); byte[] pixels8 = (byte[]) oip.getPixels(); for (int i = 0; i < size; i++) pixels8[i] = (byte) pixels[i]; break; case SHORT_TYPE: oip = imp.getProcessor().createProcessor(width, height); short[] pixels16 = (short[]) oip.getPixels(); for (int i = 0; i < size; i++) pixels16[i] = (short) pixels[i]; break; case FLOAT_TYPE: oip = new FloatProcessor(width, height, pixels, null); break; } // Adjust for display. // Calling this on non-ByteProcessors ensures image // processor is set up to correctly display image. oip.resetMinAndMax(); // Create new image plus object. Don't use // ImagePlus.createImagePlus here because there may be // attributes of input image that are not appropriate for // projection. return new ImagePlus(makeTitle(), oip); }
// Added by Marcel Boeglin 2013.09.22 private Overlay projectHyperStackRois(Overlay overlay) { if (overlay == null) return null; int t1 = imp.getFrame(); int channels = projImage.getNChannels(); int slices = 1; int frames = projImage.getNFrames(); Overlay overlay2 = new Overlay(); Roi roi; int c, z, t; int size = channels * slices * frames; for (Roi r : overlay.toArray()) { c = r.getCPosition(); z = r.getZPosition(); t = r.getTPosition(); roi = (Roi) r.clone(); if (size == channels) { // current time frame if (z >= startSlice && z <= stopSlice && t == t1 || c == 0) { roi.setPosition(c); overlay2.add(roi); } } else if (size == frames * channels) { // all time frames if (z >= startSlice && z <= stopSlice) roi.setPosition(c, 1, t); else if (z == 0) roi.setPosition(c, 0, t); else continue; overlay2.add(roi); } } return overlay2; }
/** * Adds a checkbox labelled "Preview" for "automatic" preview. The reference to this checkbox can * be retrieved by getPreviewCheckbox() and it provides the additional method previewRunning for * optical feedback while preview is prepared. PlugInFilters can have their "run" method * automatically called for preview under the following conditions: - the PlugInFilter must pass a * reference to itself (i.e., "this") as an argument to the AddPreviewCheckbox - it must implement * the DialogListener interface and set the filter parameters in the dialogItemChanged method. - * it must have DIALOG and PREVIEW set in its flags. A previewCheckbox is always off when the * filter is started and does not get recorded by the Macro Recorder. * * @param pfr A reference to the PlugInFilterRunner calling the PlugInFilter if automatic preview * is desired, null otherwise. */ public void addPreviewCheckbox(PlugInFilterRunner pfr) { if (previewCheckbox != null) return; ImagePlus imp = WindowManager.getCurrentImage(); if (imp != null && imp.isComposite() && ((CompositeImage) imp).getMode() == IJ.COMPOSITE) return; this.pfr = pfr; addCheckbox(previewLabel, false, true); }
/** * Zooms out by making the source rectangle (srcRect) larger and centering it on (x,y). If we * can't make it larger, then make the window smaller. */ public void zoomOut(int x, int y) { if (magnification <= 0.03125) return; double oldMag = magnification; double newMag = getLowerZoomLevel(magnification); double srcRatio = (double) srcRect.width / srcRect.height; double imageRatio = (double) imageWidth / imageHeight; double initialMag = imp.getWindow().getInitialMagnification(); if (Math.abs(srcRatio - imageRatio) > 0.05) { double scale = oldMag / newMag; int newSrcWidth = (int) Math.round(srcRect.width * scale); int newSrcHeight = (int) Math.round(srcRect.height * scale); if (newSrcWidth > imageWidth) newSrcWidth = imageWidth; if (newSrcHeight > imageHeight) newSrcHeight = imageHeight; int newSrcX = srcRect.x - (newSrcWidth - srcRect.width) / 2; int newSrcY = srcRect.y - (newSrcHeight - srcRect.height) / 2; if (newSrcX < 0) newSrcX = 0; if (newSrcY < 0) newSrcY = 0; srcRect = new Rectangle(newSrcX, newSrcY, newSrcWidth, newSrcHeight); // IJ.log(newMag+" "+srcRect+" "+dstWidth+" "+dstHeight); int newDstWidth = (int) (srcRect.width * newMag); int newDstHeight = (int) (srcRect.height * newMag); setMagnification(newMag); setMaxBounds(); // IJ.log(newDstWidth+" "+dstWidth+" "+newDstHeight+" "+dstHeight); if (newDstWidth < dstWidth || newDstHeight < dstHeight) { // IJ.log("pack"); setDrawingSize(newDstWidth, newDstHeight); imp.getWindow().pack(); } else repaint(); return; } if (imageWidth * newMag > dstWidth) { int w = (int) Math.round(dstWidth / newMag); if (w * newMag < dstWidth) w++; int h = (int) Math.round(dstHeight / newMag); if (h * newMag < dstHeight) h++; x = offScreenX(x); y = offScreenY(y); Rectangle r = new Rectangle(x - w / 2, y - h / 2, w, h); if (r.x < 0) r.x = 0; if (r.y < 0) r.y = 0; if (r.x + w > imageWidth) r.x = imageWidth - w; if (r.y + h > imageHeight) r.y = imageHeight - h; srcRect = r; } else { srcRect = new Rectangle(0, 0, imageWidth, imageHeight); setDrawingSize((int) (imageWidth * newMag), (int) (imageHeight * newMag)); // setDrawingSize(dstWidth/2, dstHeight/2); imp.getWindow().pack(); } // IJ.write(newMag + " " + srcRect.x+" "+srcRect.y+" "+srcRect.width+" "+srcRect.height+" // "+dstWidth + " " + dstHeight); setMagnification(newMag); // IJ.write(srcRect.x + " " + srcRect.width + " " + dstWidth); setMaxBounds(); repaint(); }
/** * Builds dialog to query users for projection parameters. * * @param start starting slice to display * @param stop last slice */ protected GenericDialog buildControlDialog(int start, int stop) { GenericDialog gd = new GenericDialog("ZProjection", IJ.getInstance()); gd.addNumericField("Start slice:", startSlice, 0 /*digits*/); gd.addNumericField("Stop slice:", stopSlice, 0 /*digits*/); gd.addChoice("Projection type", METHODS, METHODS[method]); if (isHyperstack && imp.getNFrames() > 1 && imp.getNSlices() > 1) gd.addCheckbox("All time frames", allTimeFrames); return gd; }
/** Sets the color used used for the ROI Manager "Show All" mode. */ public static void setShowAllColor(Color c) { if (c == null) return; showAllColor = c; labelColor = null; ImagePlus img = WindowManager.getCurrentImage(); if (img != null) { ImageCanvas ic = img.getCanvas(); if (ic != null && ic.getShowAllROIs()) img.draw(); } }
void updateImage(ImagePlus imp) { this.imp = imp; int width = imp.getWidth(); int height = imp.getHeight(); imageWidth = width; imageHeight = height; srcRect = new Rectangle(0, 0, imageWidth, imageHeight); setDrawingSize(imageWidth, (int) imageHeight); magnification = 1.0; }
void addScrollbars(ImagePlus imp) { ImageStack s = imp.getStack(); int stackSize = s.getSize(); nSlices = stackSize; hyperStack = imp.getOpenAsHyperStack(); // imp.setOpenAsHyperStack(false); int[] dim = imp.getDimensions(); int nDimensions = 2 + (dim[2] > 1 ? 1 : 0) + (dim[3] > 1 ? 1 : 0) + (dim[4] > 1 ? 1 : 0); if (nDimensions <= 3 && dim[2] != nSlices) hyperStack = false; if (hyperStack) { nChannels = dim[2]; nSlices = dim[3]; nFrames = dim[4]; } // IJ.log("StackWindow: "+hyperStack+" "+nChannels+" "+nSlices+" "+nFrames); if (nSlices == stackSize) hyperStack = false; if (nChannels * nSlices * nFrames != stackSize) hyperStack = false; if (cSelector != null || zSelector != null || tSelector != null) removeScrollbars(); ImageJ ij = IJ.getInstance(); if (nChannels > 1) { cSelector = new ScrollbarWithLabel(this, 1, 1, 1, nChannels + 1, 'c'); add(cSelector); if (ij != null) cSelector.addKeyListener(ij); cSelector.addAdjustmentListener(this); cSelector.setFocusable(false); // prevents scroll bar from blinking on Windows cSelector.setUnitIncrement(1); cSelector.setBlockIncrement(1); } if (nSlices > 1) { char label = nChannels > 1 || nFrames > 1 ? 'z' : 't'; if (stackSize == dim[2] && imp.isComposite()) label = 'c'; zSelector = new ScrollbarWithLabel(this, 1, 1, 1, nSlices + 1, label); if (label == 't') animationSelector = zSelector; add(zSelector); if (ij != null) zSelector.addKeyListener(ij); zSelector.addAdjustmentListener(this); zSelector.setFocusable(false); int blockIncrement = nSlices / 10; if (blockIncrement < 1) blockIncrement = 1; zSelector.setUnitIncrement(1); zSelector.setBlockIncrement(blockIncrement); sliceSelector = zSelector.bar; } if (nFrames > 1) { animationSelector = tSelector = new ScrollbarWithLabel(this, 1, 1, 1, nFrames + 1, 't'); add(tSelector); if (ij != null) tSelector.addKeyListener(ij); tSelector.addAdjustmentListener(this); tSelector.setFocusable(false); int blockIncrement = nFrames / 10; if (blockIncrement < 1) blockIncrement = 1; tSelector.setUnitIncrement(1); tSelector.setBlockIncrement(blockIncrement); } }
/** Performs actual projection using specified method. */ public void doProjection() { if (imp == null) return; sliceCount = 0; if (method < AVG_METHOD || method > MEDIAN_METHOD) method = AVG_METHOD; for (int slice = startSlice; slice <= stopSlice; slice += increment) sliceCount++; if (method == MEDIAN_METHOD) { projImage = doMedianProjection(); return; } // Create new float processor for projected pixels. FloatProcessor fp = new FloatProcessor(imp.getWidth(), imp.getHeight()); ImageStack stack = imp.getStack(); RayFunction rayFunc = getRayFunction(method, fp); if (IJ.debugMode == true) { IJ.log("\nProjecting stack from: " + startSlice + " to: " + stopSlice); } // Determine type of input image. Explicit determination of // processor type is required for subsequent pixel // manipulation. This approach is more efficient than the // more general use of ImageProcessor's getPixelValue and // putPixel methods. int ptype; if (stack.getProcessor(1) instanceof ByteProcessor) ptype = BYTE_TYPE; else if (stack.getProcessor(1) instanceof ShortProcessor) ptype = SHORT_TYPE; else if (stack.getProcessor(1) instanceof FloatProcessor) ptype = FLOAT_TYPE; else { IJ.error("Z Project", "Non-RGB stack required"); return; } // Do the projection. for (int n = startSlice; n <= stopSlice; n += increment) { IJ.showStatus("ZProjection " + color + ": " + n + "/" + stopSlice); IJ.showProgress(n - startSlice, stopSlice - startSlice); projectSlice(stack.getPixels(n), rayFunc, ptype); } // Finish up projection. if (method == SUM_METHOD) { fp.resetMinAndMax(); projImage = new ImagePlus(makeTitle(), fp); } else if (method == SD_METHOD) { rayFunc.postProcess(); fp.resetMinAndMax(); projImage = new ImagePlus(makeTitle(), fp); } else { rayFunc.postProcess(); projImage = makeOutputImage(imp, fp, ptype); } if (projImage == null) IJ.error("Z Project", "Error computing projection."); }
private boolean ignoreArrowKeys(ImagePlus imp) { Frame frame = WindowManager.getFrontWindow(); String title = frame.getTitle(); if (title != null && title.equals("ROI Manager")) return true; // Control Panel? if (frame != null && frame instanceof javax.swing.JFrame) return true; ImageWindow win = imp.getWindow(); // LOCI Data Browser window? if (imp.getStackSize() > 1 && win != null && win.getClass().getName().startsWith("loci")) return true; return false; }
/** Implements the Image/Zoom/Original Scale command. */ public void unzoom() { double imag = imp.getWindow().getInitialMagnification(); if (magnification == imag) return; srcRect = new Rectangle(0, 0, imageWidth, imageHeight); ImageWindow win = imp.getWindow(); setDrawingSize((int) (imageWidth * imag), (int) (imageHeight * imag)); setMagnification(imag); setMaxBounds(); win.pack(); setMaxBounds(); repaint(); }
public ImageCanvas(ImagePlus imp) { this.imp = imp; ij = IJ.getInstance(); int width = imp.getWidth(); int height = imp.getHeight(); imageWidth = width; imageHeight = height; srcRect = new Rectangle(0, 0, imageWidth, imageHeight); setDrawingSize(imageWidth, (int) (imageHeight)); magnification = 1.0; addMouseListener(this); addMouseMotionListener(this); addKeyListener(ij); // ImageJ handles keyboard shortcuts setFocusTraversalKeysEnabled(false); }
public void mouseExited(MouseEvent e) { // autoScroll(e); ImageWindow win = imp.getWindow(); if (win != null) setCursor(defaultCursor); IJ.showStatus(""); mouseExited = true; }
void resetMaxBounds() { ImageWindow win = imp.getWindow(); if (win != null && (System.currentTimeMillis() - win.setMaxBoundsTime) > 500L) { win.setMaximizedBounds(win.maxWindowBounds); maxBoundsReset = true; } }
/** Enlarge the canvas if the user enlarges the window. */ void resizeCanvas(int width, int height) { ImageWindow win = imp.getWindow(); // IJ.log("resizeCanvas: "+srcRect+" "+imageWidth+" "+imageHeight+" "+width+" "+height+" // "+dstWidth+" "+dstHeight+" "+win.maxBounds); if (!maxBoundsReset && (width > dstWidth || height > dstHeight) && win != null && win.maxBounds != null && width != win.maxBounds.width - 10) { if (resetMaxBoundsCount != 0) resetMaxBounds(); // Works around problem that prevented window from being larger than // maximized size resetMaxBoundsCount++; } if (IJ.altKeyDown()) { fitToWindow(); return; } if (srcRect.width < imageWidth || srcRect.height < imageHeight) { if (width > imageWidth * magnification) width = (int) (imageWidth * magnification); if (height > imageHeight * magnification) height = (int) (imageHeight * magnification); setDrawingSize(width, height); srcRect.width = (int) (dstWidth / magnification); srcRect.height = (int) (dstHeight / magnification); if ((srcRect.x + srcRect.width) > imageWidth) srcRect.x = imageWidth - srcRect.width; if ((srcRect.y + srcRect.height) > imageHeight) srcRect.y = imageHeight - srcRect.height; repaint(); } // IJ.log("resizeCanvas2: "+srcRect+" "+dstWidth+" "+dstHeight+" "+width+" "+height); }
protected void handleRoiMouseDown(MouseEvent e) { int sx = e.getX(); int sy = e.getY(); int ox = offScreenX(sx); int oy = offScreenY(sy); Roi roi = imp.getRoi(); int handle = roi != null ? roi.isHandle(sx, sy) : -1; boolean multiPointMode = roi != null && (roi instanceof PointRoi) && handle == -1 && Toolbar.getToolId() == Toolbar.POINT && Toolbar.getMultiPointMode(); if (multiPointMode) { imp.setRoi(((PointRoi) roi).addPoint(ox, oy)); return; } setRoiModState(e, roi, handle); if (roi != null) { if (handle >= 0) { roi.mouseDownInHandle(handle, sx, sy); return; } Rectangle r = roi.getBounds(); int type = roi.getType(); if (type == Roi.RECTANGLE && r.width == imp.getWidth() && r.height == imp.getHeight() && roi.getPasteMode() == Roi.NOT_PASTING && !(roi instanceof ImageRoi)) { imp.killRoi(); return; } if (roi.contains(ox, oy)) { if (roi.modState == Roi.NO_MODS) roi.handleMouseDown(sx, sy); else { imp.killRoi(); imp.createNewRoi(sx, sy); } return; } if ((type == Roi.POLYGON || type == Roi.POLYLINE || type == Roi.ANGLE) && roi.getState() == roi.CONSTRUCTING) return; int tool = Toolbar.getToolId(); if ((tool == Toolbar.POLYGON || tool == Toolbar.POLYLINE || tool == Toolbar.ANGLE) && !(IJ.shiftKeyDown() || IJ.altKeyDown())) { imp.killRoi(); return; } } imp.createNewRoi(sx, sy); }
private void doHSRGBProjection(ImagePlus rgbImp) { ImageStack stack = rgbImp.getStack(); ImageStack stack2 = new ImageStack(stack.getWidth(), stack.getHeight()); for (int i = startSlice; i <= stopSlice; i++) stack2.addSlice(null, stack.getProcessor(i)); startSlice = 1; stopSlice = stack2.getSize(); doRGBProjection(stack2); }
public StackWindow(ImagePlus imp, ImageCanvas ic) { super(imp, ic); addScrollbars(imp); addMouseWheelListener(this); if (sliceSelector == null && this.getClass().getName().indexOf("Image5D") != -1) sliceSelector = new Scrollbar(); // prevents Image5D from crashing // IJ.log(nChannels+" "+nSlices+" "+nFrames); pack(); ic = imp.getCanvas(); if (ic != null) ic.setMaxBounds(); show(); int previousSlice = imp.getCurrentSlice(); if (previousSlice > 1 && previousSlice <= imp.getStackSize()) imp.setSlice(previousSlice); else imp.setSlice(1); thread = new Thread(this, "zSelector"); thread.start(); }
public void run(String arg) { imp = IJ.getImage(); Roi roi = imp.getRoi(); if (roi != null && !roi.isArea()) imp.killRoi(); // ignore any line selection ImageProcessor ip = imp.getProcessor(); if (!showDialog(ip)) return; if (ip.getWidth() > 1 && ip.getHeight() > 1) ip.setInterpolate(interpolate); else ip.setInterpolate(false); ip.setBackgroundValue(bgValue); imp.startTiming(); try { if (newWindow && imp.getStackSize() > 1 && processStack) createNewStack(imp, ip); else scale(ip); } catch (OutOfMemoryError o) { IJ.outOfMemory("Scale"); } IJ.showProgress(1.0); }
void setMaxBounds() { if (maxBoundsReset) { maxBoundsReset = false; ImageWindow win = imp.getWindow(); if (win != null && !IJ.isLinux() && win.maxBounds != null) { win.setMaximizedBounds(win.maxBounds); win.setMaxBoundsTime = System.currentTimeMillis(); } } }
public void run(String arg) { ImagePlus imp = WindowManager.getImage(id); if (imp != null && imp.getWindow() != null) { imp.getWindow().toFront(); return; } int colorWidth = 22; int colorHeight = 16; int columns = 5; int rows = 20; int width = columns * colorWidth; int height = rows * colorHeight; ColorGenerator cg = new ColorGenerator(width, height, new int[width * height], this); cg.drawColors(colorWidth, colorHeight, columns, rows); setProcessor("CP", cg); id = getID(); show(); IJ.register(ColorPicker.class); }
// Use double buffer to reduce flicker when drawing complex ROIs. // Author: Erik Meijering void paintDoubleBuffered(Graphics g) { final int srcRectWidthMag = (int) (srcRect.width * magnification); final int srcRectHeightMag = (int) (srcRect.height * magnification); if (offScreenImage == null || offScreenWidth != srcRectWidthMag || offScreenHeight != srcRectHeightMag) { offScreenImage = createImage(srcRectWidthMag, srcRectHeightMag); offScreenWidth = srcRectWidthMag; offScreenHeight = srcRectHeightMag; } Roi roi = imp.getRoi(); try { if (imageUpdated) { imageUpdated = false; imp.updateImage(); } Graphics offScreenGraphics = offScreenImage.getGraphics(); Java2.setBilinearInterpolation(offScreenGraphics, Prefs.interpolateScaledImages); Image img = imp.getImage(); if (img != null) offScreenGraphics.drawImage( img, 0, 0, srcRectWidthMag, srcRectHeightMag, srcRect.x, srcRect.y, srcRect.x + srcRect.width, srcRect.y + srcRect.height, null); if (overlay != null) drawOverlay(offScreenGraphics); if (showAllROIs) drawAllROIs(offScreenGraphics); if (roi != null) drawRoi(roi, offScreenGraphics); if (srcRect.width < imageWidth || srcRect.height < imageHeight) drawZoomIndicator(offScreenGraphics); if (IJ.debugMode) showFrameRate(offScreenGraphics); g.drawImage(offScreenImage, 0, 0, null); } catch (OutOfMemoryError e) { IJ.outOfMemory("Paint"); } }
private boolean deleteOverlayRoi(ImagePlus imp) { if (imp == null) return false; Overlay overlay = null; ImageCanvas ic = imp.getCanvas(); if (ic != null) overlay = ic.getShowAllList(); if (overlay == null) overlay = imp.getOverlay(); if (overlay == null) return false; Roi roi = imp.getRoi(); for (int i = 0; i < overlay.size(); i++) { Roi roi2 = overlay.get(i); if (roi2 == roi) { overlay.remove(i); imp.deleteRoi(); ic = imp.getCanvas(); if (ic != null) ic.roiManagerSelect(roi, true); return true; } } return false; }
public void refreshForeground() { // Boundary for Foreground Selection setColor(0x444444); drawRect(8, 266, (w * 2) + 4, (h * 2) + 4); setColor(0x999999); drawRect(9, 267, (w * 2) + 2, (h * 2) + 2); setRoi(10, 268, w * 2, h * 2); // Paints the Foreground Color setColor(Toolbar.getForegroundColor()); fill(); imp.updateAndDraw(); }
public void refreshBackground() { // Boundary for Background Selection setColor(0x444444); drawRect((w * 2) - 12, 276, (w * 2) + 4, (h * 2) + 4); setColor(0x999999); drawRect((w * 2) - 11, 277, (w * 2) + 2, (h * 2) + 2); setRoi((w * 2) - 10, 278, w * 2, h * 2); // Paints the Background Color setColor(Toolbar.getBackgroundColor()); fill(); imp.updateAndDraw(); }