com.quinncurtis.chart3djava
Class PolygonList

java.lang.Object
  extended by com.quinncurtis.chart3djava.PolygonList
All Implemented Interfaces:
java.lang.Comparable

public class PolygonList
extends java.lang.Object
implements java.lang.Comparable

A list class that organizes a list of 3D points into a collection of polygons.


Field Summary
static int MAX_VALUE_SORT
          Sort polygons using max value of vertices
static int MEAN_BASE_VALUE_SORT
          Sort polygons based on the value of element 0
static int MEAN_VALUE_SORT
          Sort polygons using mean value of vertices
static int MIN_VALUE_SORT
          Sort polygons using min value of vertices
static int REVERSE_MEAN_BASE_VALUE_SORT
          Sort polygon in reverse order based on the value of element 0
 
Constructor Summary
PolygonList()
          The default constructor.
PolygonList(PolygonList source)
          Constructor initializes the PolygonList object as a copy of a another PolygonList object.
 
Method Summary
 int addPolygon(PhysicalCoordinates transform, ChartPoint3D[] points, ChartAttribute attrib)
          Add a polygon to the PolygonList object.
 int addPolygon(PhysicalCoordinates transform, ChartPoint3D p1, ChartPoint3D p2, ChartAttribute attrib)
          Add a two point line to the PolygonList object.
 int addPolygon(Polygon3D newpolygon)
          Add the a polygon to the polygonArray.
 int addPolygonList(PolygonList newpolygons)
          Adds an array of polygons from the source Polygon3D object to the current PolygonList object.
 int addPolygons(Polygon3D[] newpolygons)
          Adds an array of polygons to the PolygonList object.
 int addSolidPointList(ChartPoint3D[] points)
          Add an array of points to the PolygonList point list.
 int addSolidPolygon(int[] pointindices, ChartAttribute outsideattrib)
          Add a polygon, specified using point indices of the already populated pointList.
 int addSolidPolygon(PhysicalCoordinates transform, int[] pointindices, ChartAttribute outsideattrib)
          Add a polygon, specified using point indices of the already populated pointList.
 void clampPolygonListToCoordinateLimits()
          Clamp the polygon vertex values to the coordinate systems limits.
 java.lang.Object clone()
          Returns an object that is a clone of this object.
 int compareTo(java.lang.Object obj)
          CompareTo method require by IComparable interface.
 void copy(PolygonList source)
          Copies the source object.
 int count()
          Returns the count of the polygonArray.
 void cullRearFacingPolygons()
          Cull the rear facing polygons.
 void draw(java.awt.Graphics2D g2)
          The draw function for the class.
 int getCoordinateType()
          Returns the coordinate type.
 Polygon3D getElement(int index)
          Get the value of an individual polygon in the Polygon3D list.
 PolygonList getLongFormPolygonList()
          This functions converts a PolygonList object that shares points in the pointList array across multipe polygons, into a PolygonList object where every polygon contains unique 3D points.
 double getMaxValue(int axis)
          Returns the maximum value of the polygons for a given axis.
 double getMeanValue(int axis)
          Returns the mean value of the polygons for a given axis.
 double getMinValue(int axis)
          Returns the minimum value of the polygons for a given axis.
 int getObjectSortElement()
          Get polygon sort element for the PolygonList object.
 Polygon3D getPolygon(int index)
          Returns a specific polygon in the array of Polygon3D objects.
 int getPolygonAtTestPoint(double x, double y)
          Get the index of the polygon in the PolygonList object at the test point (x,y).
 Polygon3D[] getPolygons()
          Returns an array of Polygon3D objects.
 int getSortingTestCase()
          Get the sortingTestCase for the object.
 boolean getSortPolygonsByZDepth()
          Returns true if the polygons are sorted by z-depth.
 void markPolygonIndices(int datapoint, int group)
          Mark all of the polygons in the polygon list object with data point and group indices.
static void polygonTransform3D(ChartPoint3D[] points, Transform3D transform)
          Static routine transforms the points using the specified Transform3D object.
static void polygonTransform3D(PolygonList polylist, Transform3D transform)
          Static routine transforms PolygonList object using the specified Transform3D object.
 void reset()
          Resets the PolygonList object back to it's default (empty) state.
 void reversePolygons()
          Reverses the drawing order of the polygons in the PolygonList object
 void scalePolyList(ChartPoint3D scalef, ChartPoint3D offset)
          Apply an mx + b scaling to each polygon of the PolygonList.
 void setCoordinateType(int value)
          Sets the coordinate type.
 void setElement(int index, Polygon3D value)
          Sets the value of an individual polygon in the Polygon3D list.
 void setEnableCullRearFacing(boolean value)
          Set to true to enable the culling of rear facing polygons
 void setObjectSortElement(int value)
          Set polygon sort element for the PolygonList object.
 void setPolygonItems(PhysicalCoordinates physscale, ChartAttribute attrib)
          Set the coordinate system and color attribute for the polygons in the PolygonList object.
 void setSortingTestCase(int value)
          Set the sortingTestCase for the object.
 void setSortPolygonsByZDepth(boolean value)
          Set to True and the polygons are sorted by z-depth.
 void solidTransformPolyList()
          A faster technique that transforms just the pointList array to screen coordinates.
 void sort()
          Sort the Polygon3D objects in the PolygonList.
 void transformPolyList()
          Transform all polygons in PolygonList object to Screen coordinates.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MEAN_VALUE_SORT

public static final int MEAN_VALUE_SORT
Sort polygons using mean value of vertices

See Also:
Constant Field Values

MAX_VALUE_SORT

public static final int MAX_VALUE_SORT
Sort polygons using max value of vertices

See Also:
Constant Field Values

MIN_VALUE_SORT

public static final int MIN_VALUE_SORT
Sort polygons using min value of vertices

See Also:
Constant Field Values

MEAN_BASE_VALUE_SORT

public static final int MEAN_BASE_VALUE_SORT
Sort polygons based on the value of element 0

See Also:
Constant Field Values

REVERSE_MEAN_BASE_VALUE_SORT

public static final int REVERSE_MEAN_BASE_VALUE_SORT
Sort polygon in reverse order based on the value of element 0

See Also:
Constant Field Values
Constructor Detail

PolygonList

public PolygonList()
The default constructor.


PolygonList

public PolygonList(PolygonList source)
Constructor initializes the PolygonList object as a copy of a another PolygonList object.

Parameters:
source - The source PolygonList object.
Method Detail

compareTo

public int compareTo(java.lang.Object obj)
CompareTo method require by IComparable interface.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
obj - sort object.
Returns:
Returns 1 if value of this.x greater o.x, 0 if equal, -1 if this.x less than o.x

reset

public void reset()
Resets the PolygonList object back to it's default (empty) state.


sort

public void sort()
Sort the Polygon3D objects in the PolygonList.


copy

public void copy(PolygonList source)
Copies the source object.

Parameters:
source - The source object.

cullRearFacingPolygons

public void cullRearFacingPolygons()
Cull the rear facing polygons.


clampPolygonListToCoordinateLimits

public void clampPolygonListToCoordinateLimits()
Clamp the polygon vertex values to the coordinate systems limits.


reversePolygons

public void reversePolygons()
Reverses the drawing order of the polygons in the PolygonList object


clone

public java.lang.Object clone()
Returns an object that is a clone of this object.

Overrides:
clone in class java.lang.Object
Returns:
Returns a clone of this object.

addSolidPointList

public int addSolidPointList(ChartPoint3D[] points)
Add an array of points to the PolygonList point list.

Parameters:
points - The source array of ChartPoint3D objects.
Returns:
Returns current length of the pointList.

addSolidPolygon

public int addSolidPolygon(PhysicalCoordinates transform,
                           int[] pointindices,
                           ChartAttribute outsideattrib)
Add a polygon, specified using point indices of the already populated pointList.

Parameters:
transform - The coordinate system associated with the polygons.
pointindices - An array of the point indices of points in the pointList defining the polygon.
outsideattrib - The outside attribute of the polygon.
Returns:
Returns current length of the polygonArray.

addSolidPolygon

public int addSolidPolygon(int[] pointindices,
                           ChartAttribute outsideattrib)
Add a polygon, specified using point indices of the already populated pointList.

Parameters:
pointindices - An array of the point indices of points in the pointList defining the polygon.
outsideattrib - The outside attribute of the polygon.
Returns:
Returns current length of the polygonArray.

addPolygon

public int addPolygon(Polygon3D newpolygon)
Add the a polygon to the polygonArray.

Parameters:
newpolygon - Add this polygon to the polygonArray.
Returns:
Returns current length of the polygonArray.

addPolygon

public int addPolygon(PhysicalCoordinates transform,
                      ChartPoint3D[] points,
                      ChartAttribute attrib)
Add a polygon to the PolygonList object.

Parameters:
transform - The coordinate system associated with the polygons.
points - An array of the points defining the polygon.
attrib - The outside attribute of the polygon.
Returns:
Returns current length of the polygonArray.

addPolygon

public int addPolygon(PhysicalCoordinates transform,
                      ChartPoint3D p1,
                      ChartPoint3D p2,
                      ChartAttribute attrib)
Add a two point line to the PolygonList object.

Parameters:
transform - The coordinate system associated with the polygons.
p1 - The first of the two points to add.
p2 - The second of the two points to add.
attrib - The outside attribute of the polygon.
Returns:
Returns current length of the polygonArray.

getPolygons

public Polygon3D[] getPolygons()
Returns an array of Polygon3D objects.

Returns:
Returns an array of Polygon3D objects.

getPolygon

public Polygon3D getPolygon(int index)
Returns a specific polygon in the array of Polygon3D objects.

Parameters:
index - The index of the polygon in the polygonArray.
Returns:
Returns the polygon.

addPolygons

public int addPolygons(Polygon3D[] newpolygons)
Adds an array of polygons to the PolygonList object.

Parameters:
newpolygons - An array of the Polygon3D objects.
Returns:
Returns current length of the polygonArray.

addPolygonList

public int addPolygonList(PolygonList newpolygons)
Adds an array of polygons from the source Polygon3D object to the current PolygonList object.

Parameters:
newpolygons - The source Polygon3D object.
Returns:
Returns current length of the polygonArray.

markPolygonIndices

public void markPolygonIndices(int datapoint,
                               int group)
Mark all of the polygons in the polygon list object with data point and group indices.

Parameters:
datapoint - The data point index of the polygon.
group - The group index of the polygon.

transformPolyList

public void transformPolyList()
Transform all polygons in PolygonList object to Screen coordinates.


solidTransformPolyList

public void solidTransformPolyList()
A faster technique that transforms just the pointList array to screen coordinates.


polygonTransform3D

public static void polygonTransform3D(ChartPoint3D[] points,
                                      Transform3D transform)
Static routine transforms the points using the specified Transform3D object.

Parameters:
transform - The Transform3D object associated with the polygon.
points - The point list to transform.

polygonTransform3D

public static void polygonTransform3D(PolygonList polylist,
                                      Transform3D transform)
Static routine transforms PolygonList object using the specified Transform3D object.

Parameters:
transform - The Transform3D object associated with the polygon.
polylist - The PolygonList object to transform.

scalePolyList

public void scalePolyList(ChartPoint3D scalef,
                          ChartPoint3D offset)
Apply an mx + b scaling to each polygon of the PolygonList.

Parameters:
scalef - The scale factor to apply to each point.
offset - The offset to apply to each point.

setPolygonItems

public void setPolygonItems(PhysicalCoordinates physscale,
                            ChartAttribute attrib)
Set the coordinate system and color attribute for the polygons in the PolygonList object.

Parameters:
physscale - The coordinate system of the PolygonList object.
attrib - The color attribute of the PolygonList object.

getPolygonAtTestPoint

public int getPolygonAtTestPoint(double x,
                                 double y)
Get the index of the polygon in the PolygonList object at the test point (x,y).

Parameters:
x - The x-value of the test point.
y - The y-value of the test point.
Returns:
Returns the index of the polygon at the test point, -1 if one not found.

getMeanValue

public double getMeanValue(int axis)
Returns the mean value of the polygons for a given axis.

Parameters:
axis - The axis id (X_AXIS, Y_AXIS, Z_AXIS).
Returns:
Returns the mean value of the polygons for a given axis.

getMinValue

public double getMinValue(int axis)
Returns the minimum value of the polygons for a given axis.

Parameters:
axis - The axis id (X_AXIS, Y_AXIS, Z_AXIS).
Returns:
Returns the minimum value of the polygons for a given axis.

getMaxValue

public double getMaxValue(int axis)
Returns the maximum value of the polygons for a given axis.

Parameters:
axis - The axis id (X_AXIS, Y_AXIS, Z_AXIS).
Returns:
Returns the maximum value of the polygons for a given axis.

draw

public void draw(java.awt.Graphics2D g2)
The draw function for the class.

Parameters:
g2 - A graphics context

getLongFormPolygonList

public PolygonList getLongFormPolygonList()
This functions converts a PolygonList object that shares points in the pointList array across multipe polygons, into a PolygonList object where every polygon contains unique 3D points. This prevents multiple transforms on the same point.

Returns:
Returns a new, converted PolygonList object.

getElement

public Polygon3D getElement(int index)
Get the value of an individual polygon in the Polygon3D list.

Parameters:
index - Get the point at the index element.
Returns:
Returns the Polygon3D object at index.

setElement

public void setElement(int index,
                       Polygon3D value)
Sets the value of an individual polygon in the Polygon3D list.

Parameters:
index - Set the point at the index element.
value - Set the point at the index element using this value.

count

public int count()
Returns the count of the polygonArray.

Returns:
Returns the count of the polygonArray.

getSortingTestCase

public int getSortingTestCase()
Get the sortingTestCase for the object.

Returns:
Returns the sortingTestCase for the object.

setSortingTestCase

public void setSortingTestCase(int value)
Set the sortingTestCase for the object. Use one of the sortingTestCase constants: MEAN_VALUE_SORT, MIN_VALUE_SORT, MAX_VALUE_SORT, MEAN_BASE_VALUE_SORT, REVERSE)MEAN_BASE_VALUE_SORT.

Parameters:
value - Set the sortingTestCase for the object.

getObjectSortElement

public int getObjectSortElement()
Get polygon sort element for the PolygonList object.

Returns:
Return the polygon sort element for the PolygonList object.

setObjectSortElement

public void setObjectSortElement(int value)
Set polygon sort element for the PolygonList object.

Parameters:
value - Set the polygon sort element for the PolygonList object.

getSortPolygonsByZDepth

public boolean getSortPolygonsByZDepth()
Returns true if the polygons are sorted by z-depth.

Returns:
Returns true if the polygons are sorted by z-depth.

setSortPolygonsByZDepth

public void setSortPolygonsByZDepth(boolean value)
Set to True and the polygons are sorted by z-depth.

Parameters:
value - Set to true if the polygons are sorted by z-depth.

setEnableCullRearFacing

public void setEnableCullRearFacing(boolean value)
Set to true to enable the culling of rear facing polygons

Parameters:
value - Set to true to enable the culling of rear facing polygons

getCoordinateType

public int getCoordinateType()
Returns the coordinate type.

Returns:
Returns the coordinate type.

setCoordinateType

public void setCoordinateType(int value)
Sets the coordinate type.

Parameters:
value - Set the coordinate type.