org.eclipse.birt.chart.internal.computations
Class PolySimple

java.lang.Object
  extended byorg.eclipse.birt.chart.internal.computations.PolySimple
All Implemented Interfaces:
IPolygon

public class PolySimple
extends java.lang.Object
implements IPolygon

PolySimple is a simple polygon - contains only one inner polygon.

WARNING: This type of Poly cannot be used for an inner polygon that is a hole.

Author:
Dan Bridenbecker, Solution Engineering, Inc.

Constructor Summary
PolySimple()
          Creates a new instance of PolySimple
 
Method Summary
 void add(double x, double y)
          Add a point to the first inner PolySimple.
 void add(IPolygon p)
          Throws IllegalStateexception if called
 void add(Point p)
          Add a point to the first inner PolySimple.
 void clear()
          Remove all of the points.
 boolean contains(Point loc)
           
 boolean equals(java.lang.Object obj)
          Return true if the given object is equal to this one.
 double getArea()
          Returns the area of the PolySimple.
 Rectangle getBounds()
          Returns the bounding rectangle of this PolySimple.
 IPolygon getInnerPoly(int polyIndex)
          Returns this if polyIndex = 0, else it throws IllegalStateException.
 int getNumInnerPoly()
          Always returns 1.
 int getNumPoints()
          Return the number points of the first inner PolySimple
 Point getPoint(int index)
          Return the point at the index
 java.util.List getPoints()
          Returns the points
 double getX(int index)
          Return the X value of the point at the index
 double getY(int index)
          Return the Y value of the point at the index
 int hashCode()
          Return the hashCode of the object.
 IPolygon intersection(IPolygon p)
          Return a Poly that is the intersection of this PolySimple with the given PolySimple.
 boolean isContributing(int polyIndex)
          Return true if the given inner PolySimple is contributing to the set operation.
 boolean isEmpty()
          Return true if the PolySimple is empty
 boolean isHole()
          Always returns false since PolySimples cannot be holes.
 boolean isRectangle()
           
 void setContributing(int polyIndex, boolean contributes)
          Set whether or not this inner PolySimple is constributing to the set operation.
 void setIsHole(boolean isHole)
          Throws IllegalStateException if called.
 java.lang.String toString()
          Return a string briefly describing the PolySimple.
 IPolygon union(IPolygon p)
          Return a Poly that is the union of this PolySimple with the given PolySimple.
 IPolygon xor(IPolygon p)
          Return a Poly that is the exclusive-or of this PolySimple with the given PolySimple.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PolySimple

public PolySimple()
Creates a new instance of PolySimple

Method Detail

equals

public boolean equals(java.lang.Object obj)
Return true if the given object is equal to this one.

WARNING: This method failse if the first point appears more than once in the list.


hashCode

public int hashCode()
Return the hashCode of the object.

WARNING:Hash and Equals break contract.

Returns:
an integer value that is the same for two objects whenever their internal representation is the same (equals() is true)

toString

public java.lang.String toString()
Return a string briefly describing the PolySimple.


clear

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

Specified by:
clear in interface IPolygon

add

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

Specified by:
add in interface IPolygon

add

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

Specified by:
add in interface IPolygon

add

public void add(IPolygon p)
Throws IllegalStateexception if called

Specified by:
add in interface IPolygon

isEmpty

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

Specified by:
isEmpty in interface IPolygon

getBounds

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

Specified by:
getBounds in interface IPolygon

getInnerPoly

public IPolygon getInnerPoly(int polyIndex)
Returns this if polyIndex = 0, else it throws IllegalStateException.

Specified by:
getInnerPoly in interface IPolygon

getNumInnerPoly

public int getNumInnerPoly()
Always returns 1.

Specified by:
getNumInnerPoly in interface IPolygon

getNumPoints

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

Specified by:
getNumPoints in interface IPolygon

getX

public double getX(int index)
Return the X value of the point at the index

Specified by:
getX in interface IPolygon

getY

public double getY(int index)
Return the Y value of the point at the index

Specified by:
getY in interface IPolygon

getPoint

public Point getPoint(int index)
Return the point at the index

Specified by:
getPoint in interface IPolygon

getPoints

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

Specified by:
getPoints in interface IPolygon

isHole

public boolean isHole()
Always returns false since PolySimples cannot be holes.

Specified by:
isHole in interface IPolygon

setIsHole

public void setIsHole(boolean isHole)
Throws IllegalStateException if called.

Specified by:
setIsHole in interface IPolygon

isContributing

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

Specified by:
isContributing in interface IPolygon
Throws:
java.lang.IllegalStateException - if polyIndex != 0

setContributing

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

Specified by:
setContributing in interface IPolygon
Throws:
java.lang.IllegalStateException - if polyIndex != 0

intersection

public IPolygon intersection(IPolygon p)
Return a Poly that is the intersection of this PolySimple with the given PolySimple. The returned PolySimple is simple.

Specified by:
intersection in interface IPolygon
Returns:
The returned Poly is of type PolySimple

union

public IPolygon union(IPolygon p)
Return a Poly that is the union of this PolySimple with the given PolySimple. The returned PolySimple is simple.

Specified by:
union in interface IPolygon
Returns:
The returned Poly is of type PolySimple

xor

public IPolygon xor(IPolygon p)
Return a Poly that is the exclusive-or of this PolySimple with the given PolySimple. The returned PolySimple is simple.

Specified by:
xor in interface IPolygon
Returns:
The returned Poly is of type PolySimple

getArea

public double getArea()
Returns the area of the PolySimple.

The algorithm for the area of a complex PolySimple was take from code by Joseph O'Rourke author of " Computational Geometry in C".

Specified by:
getArea in interface IPolygon

contains

public boolean contains(Point loc)
Specified by:
contains in interface IPolygon

isRectangle

public boolean isRectangle()


Copyright © 2005 Actuate Corp. All rights reserved.