public ImageWindow(ImagePlus imp, ImageCanvas ic) { super(imp.getTitle()); if (Prefs.blackCanvas && getClass().getName().equals("ij.gui.ImageWindow")) { setForeground(Color.white); setBackground(Color.black); } else { setForeground(Color.black); if (IJ.isLinux()) setBackground(ImageJ.backgroundColor); else setBackground(Color.white); ImageWindow previousWindow = imp.getWindow(); setLayout(new ImageLayout(ic)); add(ic); addFocusListener(this); addWindowListener(this); addWindowStateListener(this); addKeyListener(ij); setFocusTraversalKeysEnabled(false); if (!(this instanceof StackWindow)) addMouseWheelListener(this); setResizable(true); if (!(this instanceof HistogramWindow&&IJ.isMacro()&&Interpreter.isBatchMode())) { WindowManager.addWindow(this); setLocationAndSize(false); else ic.update(previousWindow.getCanvas()); Point loc = previousWindow.getLocation();
if (stackSize>1) win = new StackWindow(this); else win = new ImageWindow(this);
public static void showList() { for (int i=0; i<imageList.size(); i++) { ImageWindow win = (ImageWindow)imageList.get(i); ImagePlus imp = win.getImagePlus(); IJ.log(i + " " + imp.getTitle() + (win==currentWindow?"*":"")+" "+imp.getID()); } for (int i=0; i<activations.size(); i++) { ImageWindow win = (ImageWindow)activations.get(i); ImagePlus imp = win.getImagePlus(); IJ.log(i + " " + imp.getTitle() + " " + imp.getID()); } if (imageList.size()==0) IJ.log("imageList is empty"); if (activations.size()==0) IJ.log("activations list is empty"); IJ.log(" "); }
/** Moves and resizes this window. Changes the magnification so the image fills the window. */ public void setLocationAndSize(int x, int y, int width, int height) { setBounds(x, y, width, height); getCanvas().fitToWindow(); pack(); }
public void setImage(ImagePlus imp2) { ImageCanvas ic = getCanvas(); if (ic==null || imp2==null) return; imp = imp2; imp.setWindow(this); ic.updateImage(imp); ic.setImageUpdated(); ic.repaint(); repaint(); }
private void addListeners(ImageCanvas canvas) { canvas.addMouseListener(this); canvas.addMouseMotionListener(this); canvas.addKeyListener(this); win.addWindowListener (this); win.addMouseWheelListener(this); win.addFocusListener(this); ImagePlus.addImageListener(this); Executer.addCommandListener(this); }
@Override public void run(final String arg) { final ImagePlus currentImage = WindowManager.getCurrentImage(); if (currentImage == null) { IJ.noImage(); return; IJ.error("Image is not an Image5D."); return; final ImageStack currentImageStack = currentImage.getImageStack(); new ImagePlus(currentImage.getTitle(), currentImageStack.getProcessor(1)); final ImageStack newStack = newImage.getStack(); newStack.setSliceLabel(currentImageStack.getSliceLabel(1), 1); newImage.setCalibration(currentImage.getCalibration().copy()); newImage.getProcessor().resetMinAndMax(); newImage.show(); currentImage.getWindow().close(); if (newImage.getWindow() != null) WindowManager.setCurrentWindow(newImage .getWindow());
@Override public void run( final String arg ) { ij = IJ.getInstance(); imp = IJ.getImage(); window = imp.getWindow(); canvas = imp.getCanvas(); canvas.addKeyListener( this ); window.addKeyListener( this ); canvas.addMouseMotionListener( this ); canvas.addMouseListener( this ); ij.addKeyListener( this ); init(); imp.getProcessor().snapshot(); Toolbar.getInstance().setTool( Toolbar.LINE ); painter = new PaintThread(); painter.start(); }
float[][] values = new float[height][]; Straightener straightener = new Straightener(); ImageStack stack = image.getStack(); for (int i = 0; i < rois.length; i++) if (rois[i] == null) ImagePlus dummy = new ImagePlus("dummy", stack.getProcessor(i + 1)); dummy.setRoi(rois[i]); ImageProcessor ip = straightener.straightenLine(dummy, lineWidth); int w = ip.getWidth(); if (!useFullLineWidth && lineWidth > 1) float value = ip.getf(j, 0); for (int k = 1; k < lineWidth; k++) value += ip.getf(j, k); ip.setf(j, 0, value / lineWidth); IJ.error("No ROIs!"); return null; ImageCanvas canvas = result.getCanvas(); KymographMouseListener listener = new KymographMouseListener(canvas, image, rois); canvas.addMouseMotionListener(listener); result.getWindow().addWindowListener(listener); return result;
if (Prefs.useInvertingLut && getBitDepth()==8 && ip!=null && !ip.isInvertedLut()&& !ip.isColorLut()) invertLookupTable(); img = getImage(); win = new PlotWindow(this, (Plot)(getProperty(Plot.PROPERTY_KEY))); else win = new ImageWindow(this); if (roi!=null) roi.setImage(this); if (overlay!=null && getCanvas()!=null) getCanvas().setOverlay(overlay); draw(); IJ.showStatus(statusMessage); if (IJ.isMacro()) { // wait for window to be activated long start = System.currentTimeMillis(); while (!activated) { IJ.wait(5); if ((System.currentTimeMillis()-start)>2000) { WindowManager.setTempCurrentImage(this); break; // 2 second timeout
/** * Method to start the dynamic reslice process after all parameters * have been set. Will not initiate as long as there is no ROI. */ public void start() { if (hasStarted || imp.getRoi() == null) return; // Get type of source window rgb = imp.getType() == ImagePlus.COLOR_RGB; notFloat = !rgb && imp.getType() != ImagePlus.GRAY32; // Create the destination ImagePlus dest_imp by get a slice a first time. dest_imp = new ImagePlus("Dynamic Reslice of "+imp.getShortTitle(), getSlice(imp, imp.getRoi())); dealWithCalibration(); // Copy min & max to new result final ImageProcessor ip = imp.getProcessor(); final double min = ip.getMin(); final double max = ip.getMax(); if (!rgb) dest_imp.getProcessor().setMinAndMax(min, max); // Display window result dest_imp.show(); // Add listeners imp.getCanvas().addMouseMotionListener(this); imp.getWindow().addWindowListener(this); dest_imp.getWindow().addWindowListener(this); // Set the started flag to true hasStarted = true; }
log("Running on ImageJ version "+IJ.getVersion()); log("Running on ImageScience version "+ImageScience.version()); image = WindowManager.getCurrentImage(); logok(); } else { log("Getting image with ID = "+iid+" from WindowManager..."); image = WindowManager.getImage(iid); logok(); canvas = window.getCanvas(); window.removeKeyListener(IJ.getInstance()); window.removeMouseWheelListener(window); canvas.removeKeyListener(IJ.getInstance()); canvas.removeMouseMotionListener(canvas); canvas.removeMouseListener(canvas); logok(); window.addWindowListener(this); handler = new MTJHandler(this); window.addKeyListener(handler); window.addMouseWheelListener(handler);
@Override public void run( final String arg ) { /* cleanup */ m.clear(); imp = IJ.getImage(); target = imp.getProcessor(); source = target.duplicate(); source.setInterpolationMethod( ImageProcessor.BILINEAR ); init(); createMapping(); painter = new MappingThread( imp, source, target, pleaseRepaint, mapping, interpolate ); painter.start(); Toolbar.getInstance().setTool( Toolbar.getInstance().addTool( "Add_and_drag_handles." ) ); imp.getCanvas().addMouseListener( this ); imp.getCanvas().addMouseMotionListener( this ); imp.getCanvas().addKeyListener( this ); imp.getWindow().addKeyListener( this ); IJ.getInstance().addKeyListener( this ); }
if ( imp != null ) imp.getCanvas().removeMouseListener( this ); imp.getCanvas().removeMouseMotionListener( this ); imp.getCanvas().removeKeyListener( this ); imp.getWindow().removeKeyListener( this ); IJ.getInstance().removeKeyListener( this ); imp.setOverlay( null ); imp.setRoi( ( Roi )null ); target.reset(); mapping.mapInterpolated( source, target ); imp.updateAndDraw();
ImagePlus imp = IJ.getImage(); if (imp==null) { IJ.noImage(); return null; ImageWindow win = imp.getWindow(); if (win==null) return null; win.toFront(); IJ.wait(500); Point loc = win.getLocation(); ImageCanvas ic = win.getCanvas(); Rectangle bounds = ic.getBounds(); loc.x += bounds.x; loc.y += bounds.y; ImagePlus imp2 = null; Image img = null; boolean wasHidden = ic.hideZoomIndicator(true); IJ.wait(250); try { img = robot.createScreenCapture(r); } catch(Exception e) { } ic.hideZoomIndicator(wasHidden); if (img!=null) { String title = WindowManager.getUniqueName(imp.getTitle()); imp2 = new ImagePlus(title, img);
@Override final protected void init() { window.addMouseWheelListener( this ); final ImageProcessor ip = imp.getProcessor(); min = ip.getMin(); max = ip.getMax(); ip.snapshot(); if ( imp.getType() == ImagePlus.GRAY32 ) ip.setMinAndMax( ( min - max ) / 2.0, ( max - min ) / 2.0 ); else if ( imp.getType() == ImagePlus.GRAY16 ) ip.setMinAndMax( 32767 - ( max - min ) / 2.0, 32767 + ( max - min ) / 2.0 ); dom = DifferenceOfMean.create( ip ); dp = -1 * dpScale; }
@Override public void run(String arg) { ImagePlus imp = IJ.getImage(); IJ.error("The current image is a labelfield!"); return; for(int i=1; (labels=WindowManager.getImage(i))!=null; i++) { IJ.error("No labelfields loaded"); return; String[] list=new String[labelfields.size()]; for(int i=0;i<list.length;i++) list[i]=((ImagePlus)labelfields.get(i)).getTitle(); if (imp.getStackSize()>1) new StackWindow(imp, cc); else new ImageWindow(imp, cc);
id = WindowManager.getNthImageID(id); ImagePlus imp = WindowManager.getImage(id); if (imp==null) error("Macro Error", "Image "+id+" not found or no images are open."); if (Interpreter.isBatchMode()) { ImagePlus impT = WindowManager.getTempCurrentImage(); ImagePlus impC = WindowManager.getCurrentImage(); if (impC!=null && impC!=imp && impT!=null) impC.saveRoi(); WindowManager.setTempCurrentImage(imp); Interpreter.activateImage(imp); if (imp==null) return; ImageWindow win = imp.getWindow(); if (win!=null) { win.toFront(); WindowManager.setWindow(win); if (IJ.isMacOSX() && IJ.isJava18() && timeout>0) timeout = 250; //work around OS X/Java 8 window activation bug while (true) { wait(10); imp = WindowManager.getCurrentImage(); if (imp!=null && imp.getID()==id) return; // specified image is now active if ((System.currentTimeMillis()-start)>timeout && win!=null) {
public RotatedRectRoi(int sx, int sy, ImagePlus imp) { super(sx, sy, imp); type = FREEROI; xstart = ic.offScreenXD(sx); ystart = ic.offScreenYD(sy); ImageWindow win = imp.getWindow(); int pixels = win!=null?(int)(win.getSize().height/win.getCanvas().getMagnification()):imp.getHeight(); if (IJ.debugMode) IJ.log("RotatedRectRoi: "+(int)rectWidth+" "+pixels); if (rectWidth>pixels) rectWidth = pixels/3; setDrawOffset(false); bounds = null; }
private void doGraph() { if (flow instanceof FlowJFlow && trueFlow instanceof FlowJFlow) { ImagePlus imp = new ImagePlus("True-Estimate "+description, GUI.createBlankImage(300,300)); ImageWindow imw = new ImageWindow(imp); imp.show(); Image img = imp.getImage(); FlowJError.map(img.getGraphics(), 300, 300, flow, trueFlow); } else IJ.error("flow or true flow not known"); } /**