Ticket #1433 (new defect)

Opened 7 years ago

Last modified 6 years ago

Plugins that return overlays can throw exceptions

Reported by: bdezonia Owned by: bdezonia
Priority: major Milestone: imagej2-b8-analysis
Component: Data Model Version:
Severity: serious Keywords:
Cc: Blocked By:
Blocking: #1457

Description

During a test implementation of the SelectView plugin I had the plugin create an output that was an (Rectangle) Overlay. I expected that IJ2 display mechanisms would detect it an create the view etc. However I got an exception error (UnsupportedOperationException in a dimensions() call) because the Overlay isDiscrete() is false. So you can't get its long[] dimensions. This seems like a limitation we should address.

Change History

comment:1 Changed 7 years ago by bdezonia

  • Blocking 285 added

comment:2 Changed 7 years ago by bdezonia

  • Blocking 1457 added; 285 removed
  • Milestone changed from imagej-2.0.0-beta9 to imagej-2.0.0-beta8

comment:3 Changed 6 years ago by bdezonia

The isDiscrete() flag code is now gone from IJ2. You can now launch plugins that return nothing but overlays. However many exceptions get thrown since there are assumptions that a display is necessary. A window is opened for the overlay however. This is a good test bed. Does it make sense to return only an overlay with no associated display? The code below is a reasonable test plugin for exercising this issue.

package imagej.core.commands.debug;

import imagej.command.Command;
import imagej.data.overlay.RectangleOverlay;

import org.scijava.Context;
import org.scijava.ItemIO;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;


@Plugin(type = Command.class, menuPath = "Plugins>Sandbox>Create Overlay")
public class OverlayPlugin implements Command {

	@Parameter(type = ItemIO.OUTPUT)
	private RectangleOverlay overlay;

	@Parameter
	private Context context;

	@Override
	public void run() {
		overlay = new RectangleOverlay(context);
		overlay.setOrigin(0, 0);
		overlay.setOrigin(0, 1);
		overlay.setExtent(200, 0);
		overlay.setExtent(100, 1);
	}

}
Last edited 6 years ago by bdezonia (previous) (diff)
Note: See TracTickets for help on using tickets.