Ticket #664 (closed task: fixed)

Opened 8 years ago

Last modified 8 years ago

Allow IJ1 to close IJ2 Displays

Reported by: bdezonia Owned by: bdezonia
Priority: major Milestone: biweekly-2011: Jul-05 to Jul-15
Component: Legacy Compatibility Version:
Severity: serious Keywords:
Cc: Blocked By:


If a plugin closes an open image window we need to reflect that by closing the associated IJ2 Display.

Experimental attempt #1:

Make Display have a close(0 method
Implement as needed in hierarchy.
SwingDisplayWindow has a close() that calls setVisible(false)
SwingImageDisplay implements close() by calling


Override ImageWindow method close() in LegacyManager to close the

correct Display


IJ1 sometimes calls win.close() when you may not expect it

For example imp.setStack() can close a window and open a new one
This actually crops up during prepluginHarmonization()

Though we've closed the window and might not care about Dataset

anymore it is registered as an output of the plugin and gets
redisplayed. The close handler in ImageWindowMethods needs to
unregister the Dataset from the plugin outputs.

Example to recreate problem

Open Organ Of Corti
Use Image::Stacks::Delete Data and delete 12 planes along Z axis
Now run Image::Stacks::Stack To Images

Window disappears (setStack() closes window before plugin called)
Window reappears (we've recorded dataset an output of the

plugin and thus a new window is hatched after plugin run)

Change History

comment:1 Changed 8 years ago by bdezonia

One of the keys here is that Delete Data is pure IJ2 and makes it the case that the IJ1 ImagePlus and the IJ2 Dataset have different dimensions. During prepluginHarmonization() imp.setStack() has to get called. This generates a win close deep in IJ1.

Just realized that if we still tracked insideIJ1Plugin() it would fix this problem.

comment:2 Changed 8 years ago by bdezonia

New approach will be taken. Like tracking output ImagePluses in LegacyPlugin we can track ImagePluses to close. ImageWindowMethods would update the imps to close list. We set imps to close to an empty set, then run plugin, and record results. After the plugin is run (and maybe after all harmonization has taken place) check imps to close. For any imp that does not have any ImageWindow currently associated with it close the associated Display.

Note we'll still have to make sure that any ImagePlus that was completely closed gets pulled from the output ImagePluses too.

comment:3 Changed 8 years ago by bdezonia

  • Status changed from new to closed
  • Resolution set to fixed

Fixed in 51d01814a1ea2407baaf6a19b2bc7491ea5bea4b

Note: See TracTickets for help on using tickets.