org.eclipse.birt.chart.computation
Interface IPolygon

All Known Implementing Classes:
Polygon, PolySimple

public interface IPolygon

Poly is an interface to a complex polygon. Poly polygons can consist of multiple "inner" polygons that can be disjoint and can be considered holes.

Currently, this interface supports two concepts:

Refactoring. This would be a good place for some refactoring to create a ComplexPoly and an InnerPoly or something so that these two concepts are broken out. One might also consider changing from an interface to an abstract class, so the methods isContributing() and setContributing() could have an access of package only. Or, the Clip algorithm could not store this information in the Poly.

Assumptions. The methods that access the polygon as though it were a set of points assume it is accessing the first polygon in the list of inner polygons. It is also assumed that inner polygons do not have more inner polygons.

Author:
Dan Bridenbecker, Solution Engineering, Inc.

Method Summary
 void add(double x, double y)
          Add a point to the first inner polygon.
 void add(IPolygon p)
          Add an inner polygon to this polygon - assumes that adding polygon does not have any inner polygons.
 void add(Point p)
          Add a point to the first inner polygon.
 void clear()
          Remove all of the points.
 boolean contains(Point loc)
           
 double getArea()
          Return the area of the polygon in square units.
 Rectangle getBounds()
          Returns the bounding rectangle of this polygon.
 IPolygon getInnerPoly(int polyIndex)
          Returns the polygon at this index.
 int getNumInnerPoly()
          Returns the number of inner polygons - inner polygons are assumed to return one here.
 int getNumPoints()
          Return the number points of the first inner polygon
 Point getPoint(int i)
           
 java.util.List getPoints()
          Returns the points
 double getX(int index)
          Return the X value of the point at the index in the first inner polygon
 double getY(int index)
          Return the Y value of the point at the index in the first inner polygon
 IPolygon intersection(IPolygon p)
          Return a Poly that is the intersection of this polygon with the given polygon.
 boolean isContributing(int polyIndex)
          Return true if the given inner polygon is contributing to the set operation.
 boolean isEmpty()
          Return true if the polygon is empty
 boolean isHole()
          Return true if this polygon is a hole.
 void setContributing(int polyIndex, boolean contributes)
          Set whether or not this inner polygon is constributing to the set operation.
 void setIsHole(boolean isHole)
          Set whether or not this polygon is a hole.
 IPolygon union(IPolygon p)
          Return a Poly that is the union of this polygon with the given polygon.
 IPolygon xor(IPolygon p)
          Return a Poly that is the exclusive-or of this polygon with the given polygon.
 

Method Detail

clear

public void clear()
Remove all of the points. Creates an empty polygon.


add

public void add(double x,
                double y)
Add a point to the first inner polygon.


add

public void add(Point p)
Add a point to the first inner polygon.


add

public void add(IPolygon p)
Add an inner polygon to this polygon - assumes that adding polygon does not have any inner polygons.


isEmpty

public boolean isEmpty()
Return true if the polygon is empty


getBounds

public Rectangle getBounds()
Returns the bounding rectangle of this polygon.


getInnerPoly

public IPolygon getInnerPoly(int polyIndex)
Returns the polygon at this index.


getPoints

public java.util.List getPoints()
Returns the points


getNumInnerPoly

public int getNumInnerPoly()
Returns the number of inner polygons - inner polygons are assumed to return one here.


getNumPoints

public int getNumPoints()
Return the number points of the first inner polygon


getX

public double getX(int index)
Return the X value of the point at the index in the first inner polygon


getY

public double getY(int index)
Return the Y value of the point at the index in the first inner polygon


isHole

public boolean isHole()
Return true if this polygon is a hole. Holes are assumed to be inner polygons of a more complex polygon.

Throws:
java.lang.IllegalStateException - if called on a complex polygon.

setIsHole

public void setIsHole(boolean isHole)
Set whether or not this polygon is a hole. Cannot be called on a complex polygon.

Throws:
java.lang.IllegalStateException - if called on a complex polygon.

isContributing

public boolean isContributing(int polyIndex)
Return true if the given inner polygon is contributing to the set operation. This method should NOT be used outside the Clip algorithm.


setContributing

public void setContributing(int polyIndex,
                            boolean contributes)
Set whether or not this inner polygon is constributing to the set operation. This method should NOT be used outside the Clip algorithm.


intersection

public IPolygon intersection(IPolygon p)
Return a Poly that is the intersection of this polygon with the given polygon. The returned polygon could be complex.


union

public IPolygon union(IPolygon p)
Return a Poly that is the union of this polygon with the given polygon. The returned polygon could be complex.


xor

public IPolygon xor(IPolygon p)
Return a Poly that is the exclusive-or of this polygon with the given polygon. The returned polygon could be complex.


getArea

public double getArea()
Return the area of the polygon in square units.


contains

public boolean contains(Point loc)

getPoint

public Point getPoint(int i)


Copyright © 2005 Actuate Corp. All rights reserved.