NOTICE! This is a static HTML version of a legacy ImageJ Trac ticket.

The ImageJ project now uses GitHub Issues for issue tracking.

Please file all new issues there.

Ticket #1433 (new defect)

Opened 2012-08-24T11:36:28-05:00

Last modified 2013-09-25T14:49:01-05:00

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 2012-12-06T10:17:56-06:00 by bdezonia

  • Blocking 285 added

comment:2 Changed 2012-12-06T10:20:23-06:00 by bdezonia

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

comment:3 Changed 2013-09-25T14:49:01-05:00 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 2013-09-25T14:57:38-05:00 by bdezonia