MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / waitTillActivated

Method waitTillActivated

ij/src/main/java/ij/ImagePlus.java:652–667  ·  view source on GitHub ↗

Waits until the image window becomes activated. This is necessary in macros or other programs if an ImagePlus is shown on the screen, because displaying the window is asynchronous (happens later) and will make the image the active one. Without waiting, in the meanwhile another window could be al

()

Source from the content-addressed store, hash-verified

650 * executing an IJ.run(...) call.
651 */
652 public void waitTillActivated() {
653 if (win == null) return;
654 if (EventQueue.isDispatchThread()) { //'activated' is set in the EventQueue, we can't wait for it in the EventQueue
655 WindowManager.setTempCurrentImage(this);
656 return;
657 }
658 long start = System.currentTimeMillis();
659 while (!activated) {
660 IJ.wait(5);
661 if (ij != null && ij.quitting()) return;
662 if ((System.currentTimeMillis()-start)>2000) {
663 WindowManager.setTempCurrentImage(this);
664 break; // 2 second timeout
665 }
666 }
667 }
668
669 /** Called by ImageWindow.windowActivated(); to end waiting in waitTillActivated. */
670 public void setActivated() {

Callers 6

showMethod · 0.95
setStackMethod · 0.95
StackWindowMethod · 0.80
imageUpdatedMethod · 0.80
AstroStackWindowMethod · 0.80
hasOverlayCanvasMethod · 0.80

Calls 3

setTempCurrentImageMethod · 0.95
waitMethod · 0.95
quittingMethod · 0.80

Tested by

no test coverage detected