Package org.jzy3d.plot3d.primitives
Class Drawable
- java.lang.Object
-
- org.jzy3d.plot3d.primitives.Drawable
-
- All Implemented Interfaces:
IGLRenderer
,ISortableDraw
- Direct Known Subclasses:
AbstractDrawableGraph2d
,CoplanarityManager
,DrawableImage
,DrawableTextWrapper
,DrawableVBO
,MultiDrawable
,Point
,Scatter
,ScatterMultiColor
,ScatterMultiColorList
,ScatterPoint
,Texture3D
,Volume
,Wireframeable
public abstract class Drawable extends Object implements IGLRenderer, ISortableDraw
ADrawable
defines objects that may be rendered into an OpenGL context provided by aICanvas
. ADrawable
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. ADrawable
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 aDrawable
. A good practice is to define a setData function for initializing aDrawable
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, aDrawable
may have its data loaded by anadd(Drawable)
function. Note: ADrawable
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 theAxisBox
object but could be extended with some few more algorithm for referencing all GL2 polygons.- Author:
- Martin Pernollet
-
-
Field Summary
Fields Modifier and Type Field 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 Summary
Constructors Constructor Description Drawable()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addDrawableListener(IDrawableListener listener)
abstract void
applyGeometryTransform(Transform transform)
Wireframeable
asWireframeable()
void
dispose()
Performs all required operation to cleanup the Drawable.protected void
doDrawBoundsIfDisplayed(IPainter painter)
void
doTransform(IPainter painter)
abstract void
draw(IPainter painter)
Call OpenGL2 routines for rendering the object.protected void
fireDrawableChanged(int eventType)
protected void
fireDrawableChanged(DrawableChangedEvent e)
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 theCamera
'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 todraw(IPainter)
.Transform
getTransformBefore()
boolean
hasLegend()
boolean
isBoundingBoxDisplayed()
boolean
isDisplayed()
Return the display status of this object.boolean
isLegendDisplayed()
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 legend)
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 todraw(IPainter)
.void
setTransformBefore(Transform transformBefore)
String
toString()
String
toString(int depth)
abstract void
updateBounds()
-
-
-
Field Detail
-
transform
protected Transform transform
-
transformBefore
protected Transform transformBefore
-
bbox
protected BoundingBox3d bbox
-
legend
protected ILegend legend
-
listeners
protected List<IDrawableListener> listeners
-
hasListeners
protected boolean hasListeners
-
displayed
protected boolean displayed
-
legendDisplayed
protected boolean legendDisplayed
-
boundingBoxDisplayed
protected boolean boundingBoxDisplayed
-
boundingBoxColor
protected Color boundingBoxColor
-
spaceTransformer
protected SpaceTransformer spaceTransformer
-
-
Method Detail
-
dispose
public void dispose()
Performs all required operation to cleanup the Drawable.
-
draw
public abstract void draw(IPainter painter)
Call OpenGL2 routines for rendering the object.- Specified by:
draw
in interfaceIGLRenderer
-
applyGeometryTransform
public abstract void applyGeometryTransform(Transform transform)
-
updateBounds
public abstract void updateBounds()
-
doTransform
public void doTransform(IPainter painter)
-
doDrawBoundsIfDisplayed
protected void doDrawBoundsIfDisplayed(IPainter painter)
-
setTransform
public void setTransform(Transform transform)
Set object's transformation that is applied at the beginning of a call todraw(IPainter)
.- Parameters:
transform
-
-
getTransform
public Transform getTransform()
Get object's transformation that is applied at the beginning of a call todraw(IPainter)
.- Returns:
- transform
-
getTransformBefore
public Transform getTransformBefore()
-
setTransformBefore
public void setTransformBefore(Transform transformBefore)
-
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 isCoord3d.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 theCamera
's eye.- Specified by:
getDistance
in interfaceISortableDraw
-
getShortestDistance
public double getShortestDistance(Camera camera)
- Specified by:
getShortestDistance
in interfaceISortableDraw
-
getLongestDistance
public double getLongestDistance(Camera camera)
- Specified by:
getLongestDistance
in interfaceISortableDraw
-
setLegend
public void setLegend(ILegend legend)
-
getLegend
public ILegend getLegend()
-
hasLegend
public boolean hasLegend()
-
setLegendDisplayed
public void setLegendDisplayed(boolean status)
-
isLegendDisplayed
public boolean isLegendDisplayed()
-
isBoundingBoxDisplayed
public boolean isBoundingBoxDisplayed()
-
setBoundingBoxDisplayed
public void setBoundingBoxDisplayed(boolean boundingBoxDisplayed)
-
getBoundingBoxColor
public Color getBoundingBoxColor()
-
setBoundingBoxColor
public void setBoundingBoxColor(Color boundingBoxColor)
-
getSpaceTransformer
public SpaceTransformer getSpaceTransformer()
-
setSpaceTransformer
public void setSpaceTransformer(SpaceTransformer spaceTransformer)
-
addDrawableListener
public void addDrawableListener(IDrawableListener listener)
-
removeDrawableListener
public void removeDrawableListener(IDrawableListener listener)
-
fireDrawableChanged
protected void fireDrawableChanged(int eventType)
-
fireDrawableChanged
protected void fireDrawableChanged(DrawableChangedEvent e)
-
asWireframeable
public Wireframeable asWireframeable()
-
toString
public String toString(int depth)
-
-