public abstract class AbstractDrawable extends Object implements IGLRenderer, ISortableDraw
AbstractDrawable
defines objects that may be rendered into an
OpenGL context provided by a ICanvas
. 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. 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
. 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.
Modifier and Type | Field and Description |
---|---|
protected BoundingBox3d |
bbox |
protected Color |
boundingBoxColor |
protected boolean |
boundingBoxDisplayed |
protected boolean |
displayed |
protected boolean |
hasListeners |
protected ILegend |
legend |
protected boolean |
legendDisplayed |
protected List<IDrawableListener> |
listeners |
protected SpaceTransformer |
spaceTransformer |
protected Transform |
transform |
protected Transform |
transformBefore |
Constructor and Description |
---|
AbstractDrawable() |
Modifier and Type | Method and Description |
---|---|
void |
addDrawableListener(IDrawableListener listener) |
abstract void |
applyGeometryTransform(Transform transform) |
protected void |
call(com.jogamp.opengl.GL gl,
Color c) |
protected void |
call(com.jogamp.opengl.GL gl,
Color c,
float alpha) |
protected void |
callWithAlphaFactor(com.jogamp.opengl.GL gl,
Color c,
float alpha) |
protected void |
colorGL2(com.jogamp.opengl.GL gl,
Color c)
A helper to call glColor4f on the input color.
|
protected void |
colorGLES2(Color c)
A helper to call glColor4f on the input color.
|
void |
dispose()
Performs all required operation to cleanup the Drawable.
|
protected void |
doDrawBounds(com.jogamp.opengl.GL gl,
com.jogamp.opengl.glu.GLU glu,
Camera cam) |
void |
doTransform(com.jogamp.opengl.GL gl,
com.jogamp.opengl.glu.GLU glu,
Camera cam) |
abstract void |
draw(com.jogamp.opengl.GL gl,
com.jogamp.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.
|
Color |
getBoundingBoxColor() |
BoundingBox3d |
getBounds()
Return the BoundingBox of this object.
|
double |
getDistance(Camera camera)
Return the distance of the object center to the
Camera 's eye. |
ILegend |
getLegend() |
double |
getLongestDistance(Camera camera) |
double |
getShortestDistance(Camera camera) |
SpaceTransformer |
getSpaceTransformer() |
Transform |
getTransform()
Get object's transformation that is applied at the beginning of a call to
draw(GL,GLU,Camera) . |
Transform |
getTransformBefore() |
boolean |
hasLegend() |
boolean |
isBoundingBoxDisplayed() |
boolean |
isDisplayed()
Return the display status of this object.
|
boolean |
isLegendDisplayed() |
protected void |
negative(Color c) |
void |
removeDrawableListener(IDrawableListener listener) |
void |
setBoundingBoxColor(Color boundingBoxColor) |
void |
setBoundingBoxDisplayed(boolean boundingBoxDisplayed) |
void |
setDisplayed(boolean status)
Set to true or false the displayed status of this object.
|
void |
setLegend(ILegend face) |
void |
setLegendDisplayed(boolean status) |
void |
setSpaceTransformer(SpaceTransformer spaceTransformer) |
void |
setTransform(Transform transform)
Set object's transformation that is applied at the beginning of a call to
draw(GL,GLU,Camera) . |
void |
setTransformBefore(Transform transformBefore) |
String |
toString() |
String |
toString(int depth) |
abstract void |
updateBounds() |
protected void |
vertexGL2(com.jogamp.opengl.GL gl,
Coord3d c)
A helper to call glVerted3f on the input coordinate.
|
protected void |
vertexGLES2(Coord3d c)
A helper to call glVerted3f on the input coordinate.
|
protected Transform transform
protected Transform transformBefore
protected BoundingBox3d bbox
protected ILegend legend
protected List<IDrawableListener> listeners
protected boolean hasListeners
protected boolean displayed
protected boolean legendDisplayed
protected boolean boundingBoxDisplayed
protected Color boundingBoxColor
protected SpaceTransformer spaceTransformer
public void dispose()
public abstract void draw(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, Camera cam)
draw
in interface IGLRenderer
gl
- GL2 contextglu
- GLU contextcam
- a reference to a shooting Camera.public abstract void applyGeometryTransform(Transform transform)
public abstract void updateBounds()
public void doTransform(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, Camera cam)
protected void doDrawBounds(com.jogamp.opengl.GL gl, com.jogamp.opengl.glu.GLU glu, Camera cam)
protected void vertexGL2(com.jogamp.opengl.GL gl, Coord3d c)
protected void vertexGLES2(Coord3d c)
protected void colorGL2(com.jogamp.opengl.GL gl, Color c)
protected void colorGLES2(Color c)
protected void call(com.jogamp.opengl.GL gl, Color c)
protected void call(com.jogamp.opengl.GL gl, Color c, float alpha)
protected void callWithAlphaFactor(com.jogamp.opengl.GL gl, Color c, float alpha)
protected void negative(Color c)
public void setTransform(Transform transform)
draw(GL,GLU,Camera)
.transform
- public Transform getTransform()
draw(GL,GLU,Camera)
.public Transform getTransformBefore()
public void setTransformBefore(Transform transformBefore)
public BoundingBox3d getBounds()
public Coord3d getBarycentre()
Coord3d.INVALID
Coord3d.INVALID
.public void setDisplayed(boolean status)
status
- public boolean isDisplayed()
public double getDistance(Camera camera)
Camera
's eye.getDistance
in interface ISortableDraw
public double getShortestDistance(Camera camera)
getShortestDistance
in interface ISortableDraw
public double getLongestDistance(Camera camera)
getLongestDistance
in interface ISortableDraw
public void setLegend(ILegend face)
public ILegend getLegend()
public boolean hasLegend()
public void setLegendDisplayed(boolean status)
public boolean isLegendDisplayed()
public boolean isBoundingBoxDisplayed()
public void setBoundingBoxDisplayed(boolean boundingBoxDisplayed)
public Color getBoundingBoxColor()
public void setBoundingBoxColor(Color boundingBoxColor)
public SpaceTransformer getSpaceTransformer()
public void setSpaceTransformer(SpaceTransformer spaceTransformer)
public void addDrawableListener(IDrawableListener listener)
public void removeDrawableListener(IDrawableListener listener)
protected void fireDrawableChanged(int eventType)
protected void fireDrawableChanged(DrawableChangedEvent e)
public String toString(int depth)
Copyright © 2016. All rights reserved.