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
Direct Known Subclasses:
PickablePolygon, Quad, SimplePolygon

public class Polygon
extends AbstractWireframeable
implements ISingleColorable, IMultiColorable

Supports additional settings

Author:
Martin Pernollet

Nested Class Summary
static class Polygon.PolygonMode
           
 
Field Summary
protected  Coord3d center
           
protected  Color color
           
protected  ColorMapper mapper
           
protected  List<Point> points
           
protected  Polygon.PolygonMode polygonMode
           
protected  boolean polygonOffsetFillEnable
           
 
Fields inherited from class org.jzy3d.plot3d.primitives.AbstractWireframeable
facestatus, wfcolor, wfstatus, wfwidth
 
Fields inherited from class org.jzy3d.plot3d.primitives.AbstractDrawable
bbox, displayed, hasListeners, legend, legendDisplayed, listeners, transform
 
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.
protected  void applyPolygonModeFill(javax.media.opengl.GL2 gl)
           
protected  void applyPolygonModeLine(javax.media.opengl.GL2 gl)
           
 void draw(javax.media.opengl.GL2 gl, javax.media.opengl.glu.GLU glu, Camera cam)
          Call OpenGL2 routines for rendering the object.
 Point get(int p)
           
 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)
           
 Polygon.PolygonMode getPolygonMode()
           
 double getShortestDistance(Camera camera)
           
 boolean isPolygonOffsetFillEnable()
           
protected  void polygonOffseFillEnable(javax.media.opengl.GL2 gl)
           
protected  void polygonOffsetFillDisable(javax.media.opengl.GL2 gl)
           
 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.
 void setPolygonMode(Polygon.PolygonMode polygonMode)
          A null polygonMode imply no any call to gl.glPolygonMode(...) at rendering
static void setPolygonOffsetFillEnable(AbstractComposite composite, boolean polygonOffsetFillEnable)
          A utility to change polygon offset fill status of a AbstractComposite containing Polygons.
 void setPolygonOffsetFillEnable(boolean polygonOffsetFillEnable)
          Enable offset fill, which let a polygon with a wireframe render cleanly without weird depth incertainty between face and border.
 int size()
           
 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, call, call, callWithAlphaFactor, dispose, fireDrawableChanged, fireDrawableChanged, getBounds, getLegend, getTransform, hasLegend, isDisplayed, isLegendDisplayed, negative, removeDrawableListener, setDisplayed, setLegend, setLegendDisplayed, setTransform, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

polygonMode

protected Polygon.PolygonMode polygonMode

polygonOffsetFillEnable

protected boolean polygonOffsetFillEnable

mapper

protected ColorMapper mapper

points

protected List<Point> points

color

protected Color color

center

protected Coord3d center
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.GL2 gl,
                 javax.media.opengl.glu.GLU glu,
                 Camera cam)
Description copied from class: AbstractDrawable
Call OpenGL2 routines for rendering the object.

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

applyPolygonModeLine

protected void applyPolygonModeLine(javax.media.opengl.GL2 gl)

applyPolygonModeFill

protected void applyPolygonModeFill(javax.media.opengl.GL2 gl)

polygonOffseFillEnable

protected void polygonOffseFillEnable(javax.media.opengl.GL2 gl)

polygonOffsetFillDisable

protected void polygonOffsetFillDisable(javax.media.opengl.GL2 gl)

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)

getAll

public List<Point> getAll()

size

public int size()

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

getPolygonMode

public Polygon.PolygonMode getPolygonMode()

setPolygonMode

public void setPolygonMode(Polygon.PolygonMode polygonMode)
A null polygonMode imply no any call to gl.glPolygonMode(...) at rendering


isPolygonOffsetFillEnable

public boolean isPolygonOffsetFillEnable()

setPolygonOffsetFillEnable

public void setPolygonOffsetFillEnable(boolean polygonOffsetFillEnable)
Enable offset fill, which let a polygon with a wireframe render cleanly without weird depth incertainty between face and border. Default value is true.


setPolygonOffsetFillEnable

public static void setPolygonOffsetFillEnable(AbstractComposite composite,
                                              boolean polygonOffsetFillEnable)
A utility to change polygon offset fill status of a AbstractComposite containing Polygons.

Parameters:
composite -
polygonOffsetFillEnable - status

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 String toString(int depth)
Overrides:
toString in class AbstractDrawable