de.unihalle.informatik.MiToBo.core.datatypes
Class MTBRegion2DSet

java.lang.Object
  extended by de.unihalle.informatik.Alida.operator.ALDData
      extended by de.unihalle.informatik.MiToBo.core.datatypes.MTBRegion2DSet
All Implemented Interfaces:
java.lang.Cloneable

public class MTBRegion2DSet
extends de.unihalle.informatik.Alida.operator.ALDData
implements java.lang.Cloneable

A set of 2D regions living in a common domain which is a rectangular subset of R x R. Each regions is of type Region2D

Author:
Stefan Posch

Nested Class Summary
private  class MTBRegion2DSet.RegionSelector
           
 
Field Summary
private  boolean debug
           
private  java.lang.String info
          Information about this region set
protected  java.util.Vector<MTBRegion2D> regionSet
          The set of regions represented as a Vector.
private  double xMax
          Maximal x coordinate of the domain of this region set.
private  double xMin
          Minimal x coordinate of the domain of this region set.
private  double yMax
          Maximal y coordinate of the domain of this region set.
private  double yMin
          Minimal y coordinate of the domain of this region set.
 
Constructor Summary
MTBRegion2DSet()
          Standard constructor.
MTBRegion2DSet(double _xMin, double _yMin, double _xMax, double _yMax)
          Construct an empty set of regions with given extent of domain
MTBRegion2DSet(de.unihalle.informatik.MiToBo_xml.MTBXMLRegion2DSetType xmlregion2Dset)
          Construct a new MTBRegion2DSet from a region set object that was constructed from a xml-representation.
MTBRegion2DSet(java.lang.String filename)
          Construct a set of regions from a xml-file that was written by the write method of this class.
MTBRegion2DSet(java.util.Vector<MTBRegion2D> regions, double _xMin, double _yMin, double _xMax, double _yMax)
          Construct an empty set of regions with given extent of domain
 
Method Summary
 boolean add(MTBRegion2D region)
          Append a region (at the end) to the set of regions.
 double calcAverageSize()
          Calculates the average size of the set.
 int calcMaxSize()
          Calculates the maximum size of the set.
 int calcMinSize()
          Calculates the minimum size of the set.
 void clear()
          Remove all regions from this set
 MTBRegion2DSet clone()
           
 MTBRegion2D elementAt(int i)
          Get a region by index
 MTBRegion2D get(int i)
          Get a region by index
 java.lang.String getInfo()
           
 double getXmax()
           
 double getXmin()
           
 double getYmax()
           
 double getYmin()
           
 void removeElementAt(int i)
          Delete the i-th region from the set
 MTBRegion2DSet selectLargeRegions(int minSize)
           
 void setElementAt(MTBRegion2D region, int i)
          Set the i-th region from the set
 void setInfo(java.lang.String info)
           
 int size()
          Get the number of regions of this region set
(package private)  de.unihalle.informatik.MiToBo_xml.MTBXMLRegion2DSetType toXMLType()
          Construct an object that represents this region by xml.
 void write(java.lang.String filename)
          Write this region set to disk in XML format using MiToBo's xml-scheme MTBRegion2DSet.xsd
 
Methods inherited from class de.unihalle.informatik.Alida.operator.ALDData
cloneProperties, getLocation, getProperty, getPropertyKeys, print, setLocation, setProperty
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

private boolean debug

info

private java.lang.String info
Information about this region set


regionSet

protected java.util.Vector<MTBRegion2D> regionSet
The set of regions represented as a Vector.


xMax

private double xMax
Maximal x coordinate of the domain of this region set.


xMin

private double xMin
Minimal x coordinate of the domain of this region set.


yMax

private double yMax
Maximal y coordinate of the domain of this region set.


yMin

private double yMin
Minimal y coordinate of the domain of this region set.

Constructor Detail

MTBRegion2DSet

public MTBRegion2DSet()
Standard constructor.


MTBRegion2DSet

public MTBRegion2DSet(double _xMin,
                      double _yMin,
                      double _xMax,
                      double _yMax)
Construct an empty set of regions with given extent of domain


MTBRegion2DSet

MTBRegion2DSet(de.unihalle.informatik.MiToBo_xml.MTBXMLRegion2DSetType xmlregion2Dset)
Construct a new MTBRegion2DSet from a region set object that was constructed from a xml-representation. Only used for reading region set bags (MTBRegion2DSetBag) from file.

Parameters:
xmlregion2Dset - object that represents the region set read from xml

MTBRegion2DSet

public MTBRegion2DSet(java.lang.String filename)
               throws org.apache.xmlbeans.XmlException,
                      java.io.IOException
Construct a set of regions from a xml-file that was written by the write method of this class. (These xml-files conform to xml-scheme MTBXMLRegion2DSet.xsd defined for MiToBo)

Parameters:
filename - path to the xml-file
Throws:
java.io.IOException - thrown if parsing of xml-file failed
org.apache.xmlbeans.XmlException - thrown if parsing of xml-file failed

MTBRegion2DSet

public MTBRegion2DSet(java.util.Vector<MTBRegion2D> regions,
                      double _xMin,
                      double _yMin,
                      double _xMax,
                      double _yMax)
Construct an empty set of regions with given extent of domain

Method Detail

add

public boolean add(MTBRegion2D region)
Append a region (at the end) to the set of regions.

Parameters:
region - region to add

calcAverageSize

public double calcAverageSize()
Calculates the average size of the set.

Returns:
average size of all regions, -1 if vector is empty

calcMaxSize

public int calcMaxSize()
Calculates the maximum size of the set.

Returns:
maximum size of all regions, -1 if vector is empty

calcMinSize

public int calcMinSize()
Calculates the minimum size of the set.

Returns:
minimum size of all regions, -1 if vector is empty

clear

public void clear()
Remove all regions from this set


clone

public MTBRegion2DSet clone()
Overrides:
clone in class java.lang.Object

elementAt

public MTBRegion2D elementAt(int i)
Get a region by index

Returns:
i-th region

get

public MTBRegion2D get(int i)
Get a region by index

Returns:
i-th region

getInfo

public java.lang.String getInfo()

getXmax

public double getXmax()

getXmin

public double getXmin()

getYmax

public double getYmax()

getYmin

public double getYmin()

removeElementAt

public void removeElementAt(int i)
Delete the i-th region from the set

Parameters:
i - index of region to remove

selectLargeRegions

public MTBRegion2DSet selectLargeRegions(int minSize)
                                  throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                                         de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException

setElementAt

public void setElementAt(MTBRegion2D region,
                         int i)
Set the i-th region from the set

Parameters:
i - index of region to remove

setInfo

public void setInfo(java.lang.String info)

size

public int size()
Get the number of regions of this region set

Returns:
number of regions

toXMLType

de.unihalle.informatik.MiToBo_xml.MTBXMLRegion2DSetType toXMLType()
Construct an object that represents this region by xml. Only used for writing region set bags (MTBRegion2DSetBag) to file.


write

public void write(java.lang.String filename)
           throws java.io.IOException,
                  de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException,
                  de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Write this region set to disk in XML format using MiToBo's xml-scheme MTBRegion2DSet.xsd

Throws:
java.io.IOException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException