org.jzy3d.plot3d.primitives
Class AbstractDrawable

java.lang.Object
  extended by org.jzy3d.plot3d.primitives.AbstractDrawable
All Implemented Interfaces:
IGLRenderer, ISortableDraw
Direct Known Subclasses:
AbstractDrawableGraph2d, AbstractWireframeable, DrawableTexture, DrawableTextWrapper, MultiColorScatter, MultiColorScatterList, Point, Scatter

public abstract class AbstractDrawable
extends Object
implements IGLRenderer, ISortableDraw

A AbstractDrawable defines objects that may be rendered into an OpenGL context provided by a ICanvas.
A AbstractDrawable must basically provide a rendering function called draw() that receives a reference to a GL2 and a GLU context. It may also use a reference to a Camera in order to implement specific behaviors according to the Camera position.
A AbstractDrawable provides services for setting the transformation factor that is used inside the draw function, as well as a getter of the object's BoundingBox3d. Note that the BoundingBox must be set by a concrete descendant of a AbstractDrawable.
A good practice is to define a setData function for initializing a AbstractDrawable and building its polygons. Since each class may have its own inputs, setData is not part of the interface but should be used as a convention. When not defining a setData function, a AbstractDrawable may have its data loaded by an add(Drawable) function.

Note: A AbstractDrawable may last provide the information whether it is displayed or not, according to a rendering into the FeedBack buffer. This is currently supported specifically for the AxeBox object but could be extended with some few more algorithm for referencing all GL2 polygons.

Author:
Martin Pernollet

Field Summary
protected  BoundingBox3d bbox
           
protected  boolean displayed
           
protected  boolean hasListeners
           
protected  Legend legend
           
protected  boolean legendDisplayed
           
protected  List<IDrawableListener> listeners
           
protected  Transform transform
           
 
Constructor Summary
AbstractDrawable()
           
 
Method Summary
 void addDrawableListener(IDrawableListener listener)
           
protected  void call(javax.media.opengl.GL2 gl, Color c)
           
protected  void call(javax.media.opengl.GL2 gl, Color c, float alpha)
           
protected  void callWithAlphaFactor(javax.media.opengl.GL2 gl, Color c, float alpha)
           
 void dispose()
          Performs all required operation to cleanup the Drawable.
abstract  void draw(javax.media.opengl.GL2 gl, javax.media.opengl.glu.GLU glu, Camera cam)
          Call OpenGL2 routines for rendering the object.
protected  void fireDrawableChanged(DrawableChangedEvent e)
           
protected  void fireDrawableChanged(int eventType)
           
 Coord3d getBarycentre()
          Return the barycentre of this object, which is computed as the center of its bounding box.
 BoundingBox3d getBounds()
          Return the BoundingBox of this object.
 double getDistance(Camera camera)
          Return the distance of the object center to the Camera's eye.
 Legend getLegend()
           
 double getLongestDistance(Camera camera)
           
 double getShortestDistance(Camera camera)
           
 Transform getTransform()
          Get object's transformation that is applied at the beginning of a call to #draw(GL,GLU,Camera).
 boolean hasLegend()
           
 boolean isDisplayed()
          Return the display status of this object.
 boolean isLegendDisplayed()
           
protected  void negative(Color c)
           
 void removeDrawableListener(IDrawableListener listener)
           
 void setDisplayed(boolean status)
          Set to true or false the displayed status of this object.
 void setLegend(Legend face)
           
 void setLegendDisplayed(boolean status)
           
 void setTransform(Transform transform)
          Set object's transformation that is applied at the beginning of a call to #draw(GL,GLU,Camera).
 String toString()
           
 String toString(int depth)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

transform

protected Transform transform

bbox

protected BoundingBox3d bbox

legend

protected Legend legend

listeners

protected List<IDrawableListener> listeners

hasListeners

protected boolean hasListeners

displayed

protected boolean displayed

legendDisplayed

protected boolean legendDisplayed
Constructor Detail

AbstractDrawable

public AbstractDrawable()
Method Detail

dispose

public void dispose()
Performs all required operation to cleanup the Drawable.


draw

public abstract void draw(javax.media.opengl.GL2 gl,
                          javax.media.opengl.glu.GLU glu,
                          Camera cam)
Call OpenGL2 routines for rendering the object.

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

call

protected void call(javax.media.opengl.GL2 gl,
                    Color c)

call

protected void call(javax.media.opengl.GL2 gl,
                    Color c,
                    float alpha)

callWithAlphaFactor

protected void callWithAlphaFactor(javax.media.opengl.GL2 gl,
                                   Color c,
                                   float alpha)

negative

protected void negative(Color c)

setTransform

public void setTransform(Transform transform)
Set object's transformation that is applied at the beginning of a call to #draw(GL,GLU,Camera).

Parameters:
transform -

getTransform

public Transform getTransform()
Get object's transformation that is applied at the beginning of a call to #draw(GL,GLU,Camera).

Returns:
transform

getBounds

public BoundingBox3d getBounds()
Return the BoundingBox of this object.

Returns:
a bounding box

getBarycentre

public Coord3d getBarycentre()
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

Returns:
the center of the bounding box, or Coord3d.INVALID.

setDisplayed

public void setDisplayed(boolean status)
Set to true or false the displayed status of this object.

Parameters:
status -

isDisplayed

public boolean isDisplayed()
Return the display status of this object.


getDistance

public double getDistance(Camera camera)
Return the distance of the object center to the Camera's eye.

Specified by:
getDistance in interface ISortableDraw

getShortestDistance

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

getLongestDistance

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

setLegend

public void setLegend(Legend face)

getLegend

public Legend getLegend()

hasLegend

public boolean hasLegend()

setLegendDisplayed

public void setLegendDisplayed(boolean status)

isLegendDisplayed

public boolean isLegendDisplayed()

addDrawableListener

public void addDrawableListener(IDrawableListener listener)

removeDrawableListener

public void removeDrawableListener(IDrawableListener listener)

fireDrawableChanged

protected void fireDrawableChanged(int eventType)

fireDrawableChanged

protected void fireDrawableChanged(DrawableChangedEvent e)

toString

public String toString()
Overrides:
toString in class Object

toString

public String toString(int depth)