/** * get the ImageJ log window (if present) * @return the log window component or null if the log is not open; */ public static Component getIJLogWindow() { // this is how ImageJ itself does it final Component log = WindowManager.getWindow("Log"); return log; }
private TextWindow getWindow(final String title) { return (TextWindow) WindowManager.getWindow(title); }
boolean isOpen(String title) { boolean open = WindowManager.getWindow(title)!=null; if (open) return true; else if (Interpreter.isBatchMode() && Interpreter.imageTable!=null) { for (Enumeration en=Interpreter.imageTable.elements(); en.hasMoreElements();) { ImagePlus imp = (ImagePlus)en.nextElement(); if (imp!=null && imp.getTitle().equals(title)) return true; } } return false; }
boolean isOpen(String title) { boolean open = WindowManager.getWindow(title)!=null; if (open) return true; else if (Interpreter.isBatchMode() && Interpreter.imageTable!=null) { for (Enumeration en=Interpreter.imageTable.elements(); en.hasMoreElements();) { ImagePlus imp = (ImagePlus)en.nextElement(); if (imp!=null && imp.getTitle().equals(title)) return true; } } return false; }
/** Obsolete; replaced by getWindow(). */ public static Frame getFrame(String title) { for (int i=0; i<nonImageList.size(); i++) { Object win = nonImageList.get(i); String winTitle = win instanceof Frame?((Frame)win).getTitle():null; if (title.equals(winTitle)) return (Frame)win; } Frame frame = getImageWindow(title); if (frame==null) { Window win = getWindow(title); if (win!=null) frame = new Frame("Proxy"); } return frame; }
/** Obsolete; replaced by getWindow(). */ public static Frame getFrame(String title) { for (int i=0; i<nonImageList.size(); i++) { Object win = nonImageList.get(i); String winTitle = win instanceof Frame?((Frame)win).getTitle():null; if (title.equals(winTitle)) return (Frame)win; } Frame frame = getImageWindow(title); if (frame==null) { Window win = getWindow(title); if (win!=null) frame = new Frame("Proxy"); } return frame; }
/** * Ensures <em>all</em> the non-image windows are closed. * <p> * This is a non-trivial problem, as * {@link WindowManager#getNonImageWindows()} <em>only</em> returns * {@link Frame}s. However there are non-image, non-{@link Frame} windows that * are critical to close: for example, the * {@link ij.plugin.frame.ContrastAdjuster} spawns a polling thread to do its * work, which will continue to run until the {@code ContrastAdjuster} is * explicitly closed. * </p> */ private void disposeOtherNonImageWindows() { // NB: As of v1.49b, getNonImageTitles is not restricted to Frames, // so we can use it to iterate through the available windows. for (final String title : WindowManager.getNonImageTitles()) { final Window window = WindowManager.getWindow(title); // NB: We can NOT set these windows as active and run the Commands // plugin with argument "close", because the default behavior is to // try closing the window as an Image. As we know these are not Images, // that is never the right thing to do. WindowManager.removeWindow(window); window.dispose(); } }
void saveWindowLocations() { Window win = WindowManager.getWindow("B&C"); if (win!=null) Prefs.saveLocation(ContrastAdjuster.LOC_KEY, win.getLocation()); win = WindowManager.getWindow("Threshold"); if (win!=null) Prefs.saveLocation(ThresholdAdjuster.LOC_KEY, win.getLocation()); win = WindowManager.getWindow("Results"); if (win!=null) { Prefs.saveLocation(TextWindow.LOC_KEY, win.getLocation()); Dimension d = win.getSize(); Prefs.set(TextWindow.WIDTH_KEY, d.width); Prefs.set(TextWindow.HEIGHT_KEY, d.height); } win = WindowManager.getWindow("Log"); if (win!=null) { Prefs.saveLocation(TextWindow.LOG_LOC_KEY, win.getLocation()); Dimension d = win.getSize(); Prefs.set(TextWindow.LOG_WIDTH_KEY, d.width); Prefs.set(TextWindow.LOG_HEIGHT_KEY, d.height); } win = WindowManager.getWindow("ROI Manager"); if (win!=null) Prefs.saveLocation(RoiManager.LOC_KEY, win.getLocation()); }
void saveWindowLocations() { Window win = WindowManager.getWindow("B&C"); if (win!=null) Prefs.saveLocation(ContrastAdjuster.LOC_KEY, win.getLocation()); win = WindowManager.getWindow("Threshold"); if (win!=null) Prefs.saveLocation(ThresholdAdjuster.LOC_KEY, win.getLocation()); win = WindowManager.getWindow("Results"); if (win!=null) { Prefs.saveLocation(TextWindow.LOC_KEY, win.getLocation()); Dimension d = win.getSize(); Prefs.set(TextWindow.WIDTH_KEY, d.width); Prefs.set(TextWindow.HEIGHT_KEY, d.height); } win = WindowManager.getWindow("Log"); if (win!=null) { Prefs.saveLocation(TextWindow.LOG_LOC_KEY, win.getLocation()); Dimension d = win.getSize(); Prefs.set(TextWindow.LOG_WIDTH_KEY, d.width); Prefs.set(TextWindow.LOG_HEIGHT_KEY, d.height); } win = WindowManager.getWindow("ROI Manager"); if (win!=null) Prefs.saveLocation(RoiManager.LOC_KEY, win.getLocation()); }
/** Activates the window with the specified title. */ public static void selectWindow(String title) { if (title.equals("ImageJ")&&ij!=null) {ij.toFront(); return;} long start = System.currentTimeMillis(); while (System.currentTimeMillis()-start<3000) { // 3 sec timeout Window win = WindowManager.getWindow(title); if (win!=null && !(win instanceof ImageWindow)) { selectWindow(win); return; } int[] wList = WindowManager.getIDList(); int len = wList!=null?wList.length:0; for (int i=0; i<len; i++) { ImagePlus imp = WindowManager.getImage(wList[i]); if (imp!=null) { if (imp.getTitle().equals(title)) { selectWindow(imp.getID()); return; } } } wait(10); } error("Macro Error", "No window with the title \""+title+"\" found."); }
/** Activates the window with the specified title. */ public static void selectWindow(String title) { if (title.equals("ImageJ")&&ij!=null) {ij.toFront(); return;} long start = System.currentTimeMillis(); while (System.currentTimeMillis()-start<3000) { // 3 sec timeout Window win = WindowManager.getWindow(title); if (win!=null && !(win instanceof ImageWindow)) { selectWindow(win); return; } int[] wList = WindowManager.getIDList(); int len = wList!=null?wList.length:0; for (int i=0; i<len; i++) { ImagePlus imp = WindowManager.getImage(wList[i]); if (imp!=null) { if (imp.getTitle().equals(title)) { selectWindow(imp.getID()); return; } } } wait(10); } error("Macro Error", "No window with the title \""+title+"\" found."); }
private ResultsTable getTable(final String title) { ResultsTable rt = null; final Window window = WindowManager.getWindow(title); if (window != null) rt = ((TextWindow) window).getTextPanel().getResultsTable(); if (rt == null) rt = new ResultsTable(); rt.setPrecision(5); rt.setNaNEmptyCells(true); rt.showRowNumbers(false); return rt; }
public TextRoi(int x, int y, ImagePlus imp) { super(x, y, imp); ImageCanvas ic = imp.getCanvas(); double mag = getMagnification(); if (mag>1.0) mag = 1.0; if (size<(12/mag)) size = (int)(12/mag); if (firstTime) { theText[0] = line1; theText[1] = line2; theText[2] = line3; firstTime = false; } else theText[0] = line1a; if (previousRoi!=null && (previousRoi instanceof TextRoi)) { firstMouseUp = false; previousRoi = null; } instanceFont = new Font(name, style, size); justification = globalJustification; setStrokeColor(Toolbar.getForegroundColor()); if (WindowManager.getWindow("Fonts")!=null) { setFillColor(defaultFillColor); setAngle(defaultAngle); } }
public TextRoi(int x, int y, ImagePlus imp) { super(x, y, imp); ImageCanvas ic = imp.getCanvas(); double mag = getMagnification(); if (mag>1.0) mag = 1.0; if (size<(12/mag)) size = (int)(12/mag); if (firstTime) { theText[0] = line1; theText[1] = line2; theText[2] = line3; firstTime = false; } else theText[0] = line1a; if (previousRoi!=null && (previousRoi instanceof TextRoi)) { firstMouseUp = false; previousRoi = null; } instanceFont = new Font(name, style, size); justification = globalJustification; setStrokeColor(Toolbar.getForegroundColor()); if (WindowManager.getWindow("Fonts")!=null) { setFillColor(defaultFillColor); setAngle(defaultAngle); } }
final TextWindow window = ( TextWindow ) WindowManager.getWindow( TABLE_NAME ); final TextPanel textPanel = window.getTextPanel(); textPanel.addMouseListener( new MouseAdapter()
final TextWindow window = ( TextWindow ) WindowManager.getWindow( TABLE_NAME ); final TextPanel textPanel = window.getTextPanel(); textPanel.addMouseListener( new MouseAdapter()