org.jzy3d.plot3d.primitives
Class Polygon

java.lang.Object
  extended by org.jzy3d.plot3d.primitives.AbstractDrawable
      extended by org.jzy3d.plot3d.primitives.AbstractWireframeable
          extended by org.jzy3d.plot3d.primitives.Polygon
All Implemented Interfaces:
IMultiColorable, ISingleColorable, IGLRenderer, ISortableDraw, IWireframeable
Direct Known Subclasses:
Quad

public class Polygon
extends AbstractWireframeable
implements ISingleColorable, IMultiColorable

A Polygon holds a List of Points that store a coordinate and a color.
There is no setData function for a Polygon since it is built incrementaly by calls to add(Point).
The effective color of the Polygon will be an interpolation between all Polygon's point colors. The final rendering will thus depend on the selected shading model for Polygons (see Scene.init()).
A Polygon is not a AbstractComposite, because:

Author:
Martin Pernollet

Constructor Summary
Polygon()
          Initializes an empty Polygon with face status defaulting to true, and wireframe status defaulting to false.
 
Method Summary
 void add(Point point)
          Add a point to the polygon.
 void draw(javax.media.opengl.GL gl, javax.media.opengl.glu.GLU glu, Camera cam)
          Call OpenGL routines for rendering the object.
 Point get(int p)
          Retrieve a point from the Polygon.
 java.util.List<Point> getAll()
           
 Coord3d getBarycentre()
          Return the barycentre of this object, which is computed as the center of its bounding box.
 Color getColor()
          Get the color.
 ColorMapper getColorMapper()
          Get the colormapper.
 double getDistance(Camera camera)
          Return the distance of the object center to the Camera's eye.
 double getLongestDistance(Camera camera)
           
 double getShortestDistance(Camera camera)
           
 void setColor(Color color)
          Set the color.
 void setColorMapper(ColorMapper mapper)
          Set the colormapper that will be used by the Drawable, instead of using precomputed colors.
 int size()
          Indicates the number of points in this Polygon.
 java.lang.String toString(int depth)
           
 
Methods inherited from class org.jzy3d.plot3d.primitives.AbstractWireframeable
getFaceDisplayed, getWireframeColor, getWireframeDisplayed, getWireframeWidth, setFaceDisplayed, setWireframeColor, setWireframeDisplayed, setWireframeWidth
 
Methods inherited from class org.jzy3d.plot3d.primitives.AbstractDrawable
addDrawableListener, dispose, getBounds, getFace, getTransform, hasFace, isDisplayed, isFace2dDisplayed, removeDrawableListener, setDisplayed, setLegend, setLegendDisplayed, setTransform, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Polygon

public Polygon()
Initializes an empty Polygon with face status defaulting to true, and wireframe status defaulting to false.

Method Detail

draw

public void draw(javax.media.opengl.GL gl,
                 javax.media.opengl.glu.GLU glu,
                 Camera cam)
Description copied from class: AbstractDrawable
Call OpenGL routines for rendering the object.

Specified by:
draw in interface IGLRenderer
Specified by:
draw in class AbstractDrawable
Parameters:
gl - GL context
glu - GLU context
cam - a reference to a shooting Camera.

add

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


getBarycentre

public Coord3d getBarycentre()
Description copied from class: AbstractDrawable
Return the barycentre of this object, which is computed as the center of its bounding box. If the bounding box is not available, the returned value is Coord3d.INVALID

Overrides:
getBarycentre in class AbstractDrawable
Returns:
the center of the bounding box, or Coord3d.INVALID.

get

public Point get(int p)
Retrieve a point from the Polygon.

Returns:
a Point3d.

getAll

public java.util.List<Point> getAll()

size

public int size()
Indicates the number of points in this Polygon.

Returns:
the number of points

getDistance

public double getDistance(Camera camera)
Description copied from class: AbstractDrawable
Return the distance of the object center to the Camera's eye.

Specified by:
getDistance in interface ISortableDraw
Overrides:
getDistance in class AbstractDrawable

getShortestDistance

public double getShortestDistance(Camera camera)
Specified by:
getShortestDistance in interface ISortableDraw
Overrides:
getShortestDistance in class AbstractDrawable

getLongestDistance

public double getLongestDistance(Camera camera)
Specified by:
getLongestDistance in interface ISortableDraw
Overrides:
getLongestDistance in class AbstractDrawable

setColorMapper

public void setColorMapper(ColorMapper mapper)
Description copied from interface: IMultiColorable
Set the colormapper that will be used by the Drawable, instead of using precomputed colors.

Specified by:
setColorMapper in interface IMultiColorable

getColorMapper

public ColorMapper getColorMapper()
Description copied from interface: IMultiColorable
Get the colormapper.

Specified by:
getColorMapper in interface IMultiColorable

setColor

public void setColor(Color color)
Description copied from interface: ISingleColorable
Set the color.

Specified by:
setColor in interface ISingleColorable
Parameters:
color - the color

getColor

public Color getColor()
Description copied from interface: ISingleColorable
Get the color.

Specified by:
getColor in interface ISingleColorable
Returns:
color the color.

toString

public java.lang.String toString(int depth)
Overrides:
toString in class AbstractDrawable