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

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

@ALDParametrizedClass
public class MTBPolygon2DSet
extends de.unihalle.informatik.Alida.operator.ALDData
implements java.lang.Cloneable

Data type to represent a set of MTBPolygon2D.

A set of 2D polygons lives in a common domain which is a rectangular subset of R x R. Each polygon is of type Polygon2D or a subclass. For reading and writing the derived class MTBSnake is handled in addition to MTBPolygon2D.

Author:
Stefan Posch

Field Summary
private  boolean debug
          Debug flag for internal use only.
(package private)  java.util.Vector<MTBPolygon2D> polygonSet
          The set of polygons represented as a Vector.
private  double xMax
          Maximal x coordinate of the domain of this polygon set.
private  double xMin
          Minimal x coordinate of the domain of this polygon set.
private  double yMax
          Maximal y coordinate of the domain of this polygon set.
private  double yMin
          Minimal y coordinate of the domain of this polygon set.
 
Constructor Summary
MTBPolygon2DSet()
          Standard constructor
MTBPolygon2DSet(double _xMin, double _yMin, double _xMax, double _yMax)
          Construct an empty set of polygons with given extent of domain.
MTBPolygon2DSet(java.util.Vector<MTBPolygon2D> _polys, double _xMin, double _yMin, double _xMax, double _yMax)
          Construct polygon set from given vector.
 
Method Summary
 boolean add(MTBPolygon2D polygon)
          Append a polygon (at the end) to the set of polygons.
 MTBPolygon2DSet clone()
           
 MTBPolygon2D elementAt(int i)
          Get a polygon by index.
private  java.util.Vector<java.awt.geom.Point2D.Double> extractPointVectorPolygon(de.unihalle.informatik.MiToBo_xml.MTBXMLPolygon2DType xmlPolygon)
          Extract the list of polygon points for a polygon.
private  java.util.Vector<MTBSnakePoint2D> extractPointVectorSnake(de.unihalle.informatik.MiToBo_xml.MTBXMLPolygon2DType xmlPolygon)
          Extract the list of polygon points for a snake.
 de.unihalle.informatik.MiToBo_xml.MTBXMLPolygon2DType getPolygon2DAsXml(MTBPolygon2D polygon, de.unihalle.informatik.MiToBo_xml.MTBXMLPolygon2DType xmlPolygon)
          Copy the information of polygon into the corresponding xml element xmlPolygon.
 MTBPolygon2D getPolygon2DFromXml(de.unihalle.informatik.MiToBo_xml.MTBXMLPolygon2DType xmlPolygon)
          * Get a new Polygon2D from the information of the xmlPolygon .
 de.unihalle.informatik.MiToBo_xml.MTBXMLSnakeType getSnakeAsXml(MTBSnake snake, de.unihalle.informatik.MiToBo_xml.MTBXMLSnakeType xmlSnake)
          Copy the information of snake into the corresponding xml element xmlSnake.
 double getXmax()
          Returns maximal x coordinate of the domain.
 double getXmin()
          Returns minimal x coordinate of the domain.
 double getYmax()
          Returns maximal x coordinate of the domain.
 double getYmin()
          Returns minimal y coordinate of the domain.
 void read(java.lang.String filename)
          Read a polygon set from an xml file filename and set the MTB polygon set accordingly.
 void setElementAt(int i, MTBPolygon2D poly)
          Set a polygon at i-th position of the set.
 int size()
          Get the number of polygons of this polygon set.
 java.lang.String toString()
           
 void write(java.lang.String filename)
          Write this polygon set as xml into file filename.xml Additionally the processing history is written.
 void write(java.lang.String filename, boolean writeHistory)
          Write this polygon set as xml into file filename If flag is set to true, the processing history is written, too.
 
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, wait, wait, wait
 

Field Detail

debug

private boolean debug
Debug flag for internal use only.


polygonSet

@ALDClassParameter(label="Set of polygons")
java.util.Vector<MTBPolygon2D> polygonSet
The set of polygons represented as a Vector.


xMax

@ALDClassParameter(label="Maximal x in domain")
private double xMax
Maximal x coordinate of the domain of this polygon set.


xMin

@ALDClassParameter(label="Minimal x in domain")
private double xMin
Minimal x coordinate of the domain of this polygon set.


yMax

@ALDClassParameter(label="Maximal y in domain")
private double yMax
Maximal y coordinate of the domain of this polygon set.


yMin

@ALDClassParameter(label="Minimal y in domain")
private double yMin
Minimal y coordinate of the domain of this polygon set.

Constructor Detail

MTBPolygon2DSet

public MTBPolygon2DSet()
Standard constructor


MTBPolygon2DSet

public MTBPolygon2DSet(double _xMin,
                       double _yMin,
                       double _xMax,
                       double _yMax)
Construct an empty set of polygons with given extent of domain.

Parameters:
_xMin - minimum value of x-coordinates for the set
_yMin - minimum value of y-coordinates for the set
_xMax - maximum value of x-coordinates for the set
_yMax - maximum value of y-coordinates for the set

MTBPolygon2DSet

public MTBPolygon2DSet(java.util.Vector<MTBPolygon2D> _polys,
                       double _xMin,
                       double _yMin,
                       double _xMax,
                       double _yMax)
Construct polygon set from given vector.

Parameters:
_polys - set of polygons
_xMin - minimum value of x-coordinates for the set
_yMin - minimum value of y-coordinates for the set
_xMax - maximum value of x-coordinates for the set
_yMax - maximum value of y-coordinates for the set
Method Detail

add

public boolean add(MTBPolygon2D polygon)
Append a polygon (at the end) to the set of polygons.

Parameters:
polygon - Polygon to add.

clone

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

elementAt

public MTBPolygon2D elementAt(int i)
Get a polygon by index.

Returns:
Polygon at i-th position of the set.

extractPointVectorPolygon

private java.util.Vector<java.awt.geom.Point2D.Double> extractPointVectorPolygon(de.unihalle.informatik.MiToBo_xml.MTBXMLPolygon2DType xmlPolygon)
Extract the list of polygon points for a polygon.

Parameters:
xmlPolygon - the xml polygon to copy the data from
Returns:
List of polygon points.

extractPointVectorSnake

private java.util.Vector<MTBSnakePoint2D> extractPointVectorSnake(de.unihalle.informatik.MiToBo_xml.MTBXMLPolygon2DType xmlPolygon)
Extract the list of polygon points for a snake.

Parameters:
xmlPolygon - the xml polygon to copy the data from
Returns:
List of snake points.

getPolygon2DAsXml

public de.unihalle.informatik.MiToBo_xml.MTBXMLPolygon2DType getPolygon2DAsXml(MTBPolygon2D polygon,
                                                                               de.unihalle.informatik.MiToBo_xml.MTBXMLPolygon2DType xmlPolygon)
Copy the information of polygon into the corresponding xml element xmlPolygon. If xmlPolygon is null, a new obejct is created, otherwise the passed object filled.


getPolygon2DFromXml

public MTBPolygon2D getPolygon2DFromXml(de.unihalle.informatik.MiToBo_xml.MTBXMLPolygon2DType xmlPolygon)
                                 throws java.lang.ClassNotFoundException
* Get a new Polygon2D from the information of the xmlPolygon . Returns Polygon2D and Snake type polygons as appropriate.

Parameters:
xmlPolygon - polygon object stored in the xmlPolygon
Returns:
Polygon2D and Snake type polygons.
Throws:
java.lang.ClassNotFoundException

getSnakeAsXml

public de.unihalle.informatik.MiToBo_xml.MTBXMLSnakeType getSnakeAsXml(MTBSnake snake,
                                                                       de.unihalle.informatik.MiToBo_xml.MTBXMLSnakeType xmlSnake)
Copy the information of snake into the corresponding xml element xmlSnake. If xmlSnake is null, a new obejct is created, otherwise the passed object filled.


getXmax

public double getXmax()
Returns maximal x coordinate of the domain.


getXmin

public double getXmin()
Returns minimal x coordinate of the domain.


getYmax

public double getYmax()
Returns maximal x coordinate of the domain.


getYmin

public double getYmin()
Returns minimal y coordinate of the domain.


read

public void read(java.lang.String filename)
          throws java.lang.ClassNotFoundException,
                 MTBException
Read a polygon set from an xml file filename and set the MTB polygon set accordingly. The processing history is read also if available.

WARNING: currently assume filename WITHOUT extension.

Parameters:
filename - Filename to read from, WITHOUT extension (for the moment).
Throws:
java.lang.ClassNotFoundException
MTBException

setElementAt

public void setElementAt(int i,
                         MTBPolygon2D poly)
Set a polygon at i-th position of the set.

Parameters:
i - position
poly - polygon object to set at position i

size

public int size()
Get the number of polygons of this polygon set.

Returns:
Number of polygons in the set.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

write

public void write(java.lang.String filename)
           throws de.unihalle.informatik.Alida.exceptions.ALDException
Write this polygon set as xml into file filename.xml Additionally the processing history is written.

WARNING: currently assume filename WITHOUT extension.

Parameters:
filename - Filename to write to, WITHOUT extension (for the moment)
Throws:
de.unihalle.informatik.Alida.exceptions.ALDException

write

public void write(java.lang.String filename,
                  boolean writeHistory)
           throws de.unihalle.informatik.Alida.exceptions.ALDException
Write this polygon set as xml into file filename If flag is set to true, the processing history is written, too.

Parameters:
filename - Filename to write to.
writeHistory - If true, the history is written as well.
Throws:
de.unihalle.informatik.Alida.exceptions.ALDException