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:
Cloneable

@ALDParametrizedClass
public class MTBPolygon2DSet
extends de.unihalle.informatik.Alida.operator.ALDData
implements 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

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(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.
 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(de.unihalle.informatik.MiToBo_xml.MTBXMLPolygon2DSetType xmlPolygon2DSet)
          Read a polygon set from an xml object xmlPolygon2DSet and set the MTB polygon set accordingly.
 void read(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.
 String toString()
           
 de.unihalle.informatik.MiToBo_xml.MTBXMLPolygon2DSetType toXMLType()
          Create a xml representation of this polygon set using MiToBo's xml-scheme MTBXMLPolygon2DSet.xsd
 void write(String filename)
          Write this polygon set as xml into file filename.xml Additionally the processing history is written.
 void write(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
 

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(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

clone

public MTBPolygon2DSet clone()
Overrides:
clone in class Object

getXmin

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


getXmax

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


getYmin

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


getYmax

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


size

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

Returns:
Number of polygons in the set.

elementAt

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

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

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

add

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

Parameters:
polygon - Polygon to add.

read

public void read(String filename)
          throws IOException,
                 org.apache.xmlbeans.XmlException,
                 ClassNotFoundException
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:
IOException
org.apache.xmlbeans.XmlException
ClassNotFoundException

read

public void read(de.unihalle.informatik.MiToBo_xml.MTBXMLPolygon2DSetType xmlPolygon2DSet)
          throws ClassNotFoundException
Read a polygon set from an xml object xmlPolygon2DSet and set the MTB polygon set accordingly.

WARNING: currently assume filename WITHOUT extension.

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

getPolygon2DFromXml

public MTBPolygon2D getPolygon2DFromXml(de.unihalle.informatik.MiToBo_xml.MTBXMLPolygon2DType xmlPolygon)
                                 throws 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:
ClassNotFoundException

write

public void write(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(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

toXMLType

public de.unihalle.informatik.MiToBo_xml.MTBXMLPolygon2DSetType toXMLType()
                                                                   throws ClassNotFoundException
Create a xml representation of this polygon set using MiToBo's xml-scheme MTBXMLPolygon2DSet.xsd

Returns:
the xml representation of this polygon set
Throws:
ClassNotFoundException - if the class of the polygons in the set are not known to the implementation (rather an unknown extending class)

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 object is created, otherwise the passed object filled.


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.


toString

public String toString()
Overrides:
toString in class Object


Copyright © 2010–2015 Martin Luther University Halle-Wittenberg. All rights reserved.