de.unihalle.informatik.MiToBo.core.imageJ
Class RoiManagerAdapter

java.lang.Object
  extended by de.unihalle.informatik.MiToBo.core.imageJ.RoiManagerAdapter

public class RoiManagerAdapter
extends java.lang.Object

Convenience functions for interaction with ImageJ's ROI manager.

This class is implemented as singleton. To access its functionality, use the getAdapter() function to get the singleton instance and call its methods.

Author:
moeller

Nested Class Summary
private static class RoiManagerAdapter.RoiReader
          Class for parsing ImageJ roi files and zip archives.
 
Field Summary
private static java.lang.Object classLock
          Lock variable to make singleton thread-safe.
private static RoiManagerAdapter roiAdapt
          The object instance.
private  ij.plugin.frame.RoiManager roiManager
          Reference to the current ImageJ roi manager.
 
Constructor Summary
private RoiManagerAdapter()
          Hidden constructor, never called from outside.
 
Method Summary
 void addContoursToRoiManager(MTBContour2DSet conts)
          Adds a set of 2D contours to the ROI manager.
 void addPolygonsToRoiManager(MTBPolygon2DSet polys)
          Adds a set of polygons to the ROI manager.
 void addPolygonToRoiManager(MTBPolygon2D poly)
          Adds the given polygon to the ROI manager.
 void addRegionsToRoiManager(MTBRegion2DSet regs)
          Adds a set of 2D regions to the ROI manager.
 boolean areRegionsInManagerAvailable()
          Returns true if there are regions available in ROI manager.
private  boolean checkSelectionConsistency()
           
 MTBContour2DSet getContourSetFromRoiManager()
          Reads a ROI manager selection into a set of contours.
static RoiManagerAdapter getInstance()
          Single access point for singleton functionality.
 MTBPolygon2DSet getPolygonSetFromRoiFile(java.lang.String file, boolean asSnakes)
          Reads an ImageJ roi file into a set of polygons/snakes.
 MTBPolygon2DSet getPolygonSetFromRoiManager()
          Reads ROI manager selections into a set of polygons/snakes.
 MTBRegion2DSet getRegionSetFromRoiManager()
          Reads a ROI manager selection into a set of regions.
private  void openRoiManager()
          Gets an instance of the current ROI manager of ImageJ.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classLock

private static java.lang.Object classLock
Lock variable to make singleton thread-safe.


roiAdapt

private static RoiManagerAdapter roiAdapt
The object instance.


roiManager

private ij.plugin.frame.RoiManager roiManager
Reference to the current ImageJ roi manager.

Constructor Detail

RoiManagerAdapter

private RoiManagerAdapter()
Hidden constructor, never called from outside.

Method Detail

addContoursToRoiManager

public void addContoursToRoiManager(MTBContour2DSet conts)
Adds a set of 2D contours to the ROI manager.

Parameters:
conts - Set of contours to be added to ROI manager.

addPolygonsToRoiManager

public void addPolygonsToRoiManager(MTBPolygon2DSet polys)
Adds a set of polygons to the ROI manager.

Note that the set is destroyed by this operation, i.e. it cannot be recovered lateron from the ROI manager as it does not support to group several polygons into a logic entity.

Parameters:
polys - Set of polygons to be added to ROI manager.

addPolygonToRoiManager

public void addPolygonToRoiManager(MTBPolygon2D poly)
Adds the given polygon to the ROI manager.

Parameters:
poly - Polygon to be added to ROI manager.

addRegionsToRoiManager

public void addRegionsToRoiManager(MTBRegion2DSet regs)
Adds a set of 2D regions to the ROI manager.

Parameters:
regs - Set of regions to be added to ROI manager.

areRegionsInManagerAvailable

public boolean areRegionsInManagerAvailable()
Returns true if there are regions available in ROI manager.

Returns:
True, if region manager contains at least one region.

checkSelectionConsistency

private boolean checkSelectionConsistency()

getContourSetFromRoiManager

public MTBContour2DSet getContourSetFromRoiManager()
Reads a ROI manager selection into a set of contours.

Returns:
Set of contours; always non-null, but probably empty.

getInstance

public static RoiManagerAdapter getInstance()
Single access point for singleton functionality.

Returns:
Reference to the singleton instance.

getPolygonSetFromRoiFile

public MTBPolygon2DSet getPolygonSetFromRoiFile(java.lang.String file,
                                                boolean asSnakes)
                                         throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                                                de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Reads an ImageJ roi file into a set of polygons/snakes.

Parameters:
file - Input file.
asSnakes - If true, function returns snakes, otherwise polygons.
Returns:
Set of polygons/snakes; always non-null, but probably empty.
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException

getPolygonSetFromRoiManager

public MTBPolygon2DSet getPolygonSetFromRoiManager()
Reads ROI manager selections into a set of polygons/snakes.

Returns:
Set of polygons; always non-null, but probably empty.

getRegionSetFromRoiManager

public MTBRegion2DSet getRegionSetFromRoiManager()
Reads a ROI manager selection into a set of regions.

Returns:
Set of regions; always non-null, but probably empty.

openRoiManager

private void openRoiManager()
Gets an instance of the current ROI manager of ImageJ.

If there is already a roi manager open, get a reference to that one, otherwise open a new one.