visad.java3d
Class DisplayRendererJ3D

java.lang.Object
  extended by visad.DisplayRenderer
      extended by visad.java3d.DisplayRendererJ3D
All Implemented Interfaces:
EventListener, ControlListener, RendererSourceListener
Direct Known Subclasses:
DefaultDisplayRendererJ3D, ImmersaDeskDisplayRendererJ3D, TransformOnlyDisplayRendererJ3D, TwoDDisplayRendererJ3D

public abstract class DisplayRendererJ3D
extends DisplayRenderer
implements RendererSourceListener

DisplayRendererJ3D is the VisAD abstract super-class for background and metadata rendering algorithms. These complement depictions of Data objects created by DataRenderer objects.

DisplayRendererJ3D also manages the overall relation of DataRenderer output to Java3D and manages the scene graph.

It creates the binding between Control objects and scene graph Behavior objects for direct manipulation of Control objects.

DisplayRendererJ3D is not Serializable and should not be copied between JVMs.


Constructor Summary
DisplayRendererJ3D()
           
 
Method Summary
 void addDirectManipulationSceneGraphComponent(Group group, DirectManipulationRendererJ3D renderer)
           
 void addKeyboardBehavior(KeyboardBehaviorJ3D behavior)
          Add a KeyboardBehavior for keyboard control of rotation, translation and zoom.
 void addLockedSceneGraphComponent(Group group)
           
 void addLockedSceneGraphComponent(Group group, boolean initWithProj)
           
 void addSceneGraphComponent(Group group)
           
 boolean anyDirects()
          Check to see if there are any DirectManipulationRenderers in this display.
 void clearScale(AxisScale axisScale)
          Remove a particular scale being rendered.
 void clearScales()
          Remove all the scales being rendered.
 void clearScene(DataRenderer renderer)
           
 void controlChanged(ControlEvent evt)
          Update internal values from those in the RendererControl.
 BranchGroup createBasicSceneGraph(View v, TransformGroup vpt, VisADCanvasJ3D c, MouseBehaviorJ3D m)
          Deprecated. use createBasicSceneGraph(View v, TransformGroup vpt, VisADCanvasJ3D c, MouseBehaviorJ3D m, ColoringAttributes bc, ColoringAttributes cc) instead
 BranchGroup createBasicSceneGraph(View v, TransformGroup vpt, VisADCanvasJ3D c, MouseBehaviorJ3D m, ColoringAttributes bc, ColoringAttributes cc)
          Create scene graph root, if none exists, with Transform and direct manipulation root.
abstract  BranchGroup createSceneGraph(View v, TransformGroup vpt, VisADCanvasJ3D c)
          Create scene graph root, if none exists, with Transform and direct manipulation root; create special graphics (e.g., 3-D box, SkewT background), any lights, any user interface embedded in scene.
 void depth_cursor(VisADRay ray)
          set a VisADRay along which to drag cursor in depth (in and out of screen)
 void destroy()
           
 void drag_cursor(VisADRay ray, boolean first)
          drag cursor parallel to plane of screen
 void drag_depth(float diff)
          drag cursor in depth (in and out of screen)
 void drawCursorStringVector(VisADCanvasJ3D canvas)
          Whenever cursorOn or directOn is true, display Strings in cursorStringVector.
 DataRenderer findDirect(VisADRay ray, int mouseModifiers)
          Find the DataRenderer that is closest to the ray and uses the specified mouse modifiers for direct manipulation.
 BranchGroup getBoxOnBranch()
           
 VisADCanvasJ3D getCanvas()
          Get the canvas for this renderer
 double[] getCursor()
          Get the cusor location.
 BranchGroup getCursorOnBranch()
           
 BufferedImage getImage()
          Capture the display rendition as an image.
 KeyboardBehavior getKeyboardBehavior()
          Get the KeyboardBehavior associated with this renderer.
 MouseBehavior getMouseBehavior()
          Get the MouseBehavior associated with this renderer.
 BranchGroup getRoot()
           
 int getTextureHeightMax()
           
 int getTextureWidthMax()
           
 TransformGroup getTrans()
           
 View getView()
           
 TransformGroup getViewTrans()
           
 void initControl(RendererControl ctl)
          Internal method used to initialize newly created RendererControl with current renderer settings before it is actually connected to the renderer.
 boolean legalDataRenderer(DataRenderer renderer)
          Check if the DataRenderer in question is legal for this DisplayRenderer
 Control makeControl(ScalarMap map)
          Factory for constructing a subclass of Control appropriate for the graphics API and for this DisplayRenderer; invoked by ScalarMap when it is addMap()ed to a Display.
 DataRenderer makeDefaultRenderer()
          Create the default DataRenderer for this type of DisplayRenderer
 void render_trigger()
          trigger the graphics API to render the scene graph to the screen; intended to be over-ridden by graphics-API-specific extensions of DisplayRenderer
 void rendererDeleted(DataRenderer renderer)
           
 void setClip(int plane, boolean enable, float a, float b, float c, float d)
          Define a clipping plane in (XAxis, YAxis, ZAxis) space.
 void setCursorLoc(float x, float y, float z)
          Set the cursor location
 void setCursorOn(boolean on)
          Toggle the cursor in the display
 void setDirectOn(boolean on)
          Set the flag for direct manipulation
 void setDisplay(DisplayImpl dpy)
          Specify DisplayImpl to be rendered.
 void setLineWidth(float width)
           
 void setScale(AxisScale axisScale)
          Set the scale for the appropriate axis.
 void setScale(int axis, int axis_ordinal, VisADLineArray array, float[] scale_color)
          Set the scale for the appropriate axis.
 void setScale(int axis, int axis_ordinal, VisADLineArray array, VisADTriangleArray labels, float[] scale_color)
          Set the scale for the appropriate axis.
 void setScaleOn(boolean on)
          Set the scales on.
static void setSceneGraphObjectName(SceneGraphObject obj, String name)
          Set the name of a SceneGraphObject.
 void setTransform3D(Transform3D t)
           
 void setWaitFlag(boolean b)
          Set the wait flag to the specified value.
 void updateLockedTrans(double[] matrix)
           
 
Methods inherited from class visad.DisplayRenderer
getAnimationString, getAnimationStringVisible, getBoxOn, getCursorColor, getCursorStringVector, getCursorStringVectorUnconditional, getDirectAxisValue, getDirectAxisValue, getDisplay, getMode2D, getPickThreshhold, getRendererControl, getRotateAboutCenter, getScaleRotation, getWaitFlag, getWaitMessageVisible, legalDisplayScalar, prepareAction, setAnimationString, setAnimationStringVisible, setBackgroundColor, setBackgroundColor, setBoxAspect, setBoxColor, setBoxColor, setBoxOn, setCursorColor, setCursorColor, setCursorStringOn, setCursorStringVector, setCursorStringVector, setForegroundColor, setForegroundColor, setPickThreshhold, setRotateAboutCenter, setScaleRotation, setWaitMessageVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DisplayRendererJ3D

public DisplayRendererJ3D()
Method Detail

setSceneGraphObjectName

public static void setSceneGraphObjectName(SceneGraphObject obj,
                                           String name)
Set the name of a SceneGraphObject. If SceneGraphObject does not have a setName (J3D pre v1.4) this is a no-op.

Parameters:
name -

destroy

public void destroy()

setDisplay

public void setDisplay(DisplayImpl dpy)
                throws VisADException
Specify DisplayImpl to be rendered.

Overrides:
setDisplay in class DisplayRenderer
Parameters:
dpy - Display to render.
Throws:
VisADException - If a DisplayImpl has already been specified.

getView

public View getView()

getViewTrans

public TransformGroup getViewTrans()

getCanvas

public VisADCanvasJ3D getCanvas()
Get the canvas for this renderer

Returns:
VisADCanvasJ3D that this renderer uses.

getImage

public BufferedImage getImage()
Capture the display rendition as an image.

Specified by:
getImage in class DisplayRenderer
Returns:
image of the display.

getRoot

public BranchGroup getRoot()

initControl

public void initControl(RendererControl ctl)
Internal method used to initialize newly created RendererControl with current renderer settings before it is actually connected to the renderer. This means that changes will not generate MonitorEvents.

Specified by:
initControl in class DisplayRenderer
Parameters:
ctl - RendererControl to initialize

controlChanged

public void controlChanged(ControlEvent evt)
Update internal values from those in the RendererControl.

Specified by:
controlChanged in interface ControlListener
Parameters:
evt - ControlEvent generated by a change to the RendererControl

getTrans

public TransformGroup getTrans()

getCursorOnBranch

public BranchGroup getCursorOnBranch()

getBoxOnBranch

public BranchGroup getBoxOnBranch()

setCursorOn

public void setCursorOn(boolean on)
Toggle the cursor in the display

Specified by:
setCursorOn in class DisplayRenderer
Parameters:
on - true to display the cursor, false to hide it.

setDirectOn

public void setDirectOn(boolean on)
Set the flag for direct manipulation

Specified by:
setDirectOn in class DisplayRenderer
Parameters:
on - true for enabling direct manipulation, false to disable

createSceneGraph

public abstract BranchGroup createSceneGraph(View v,
                                             TransformGroup vpt,
                                             VisADCanvasJ3D c)
Create scene graph root, if none exists, with Transform and direct manipulation root; create special graphics (e.g., 3-D box, SkewT background), any lights, any user interface embedded in scene.

Parameters:
v -
vpt -
c -
Returns:
Scene graph root.

createBasicSceneGraph

public BranchGroup createBasicSceneGraph(View v,
                                         TransformGroup vpt,
                                         VisADCanvasJ3D c,
                                         MouseBehaviorJ3D m)
Deprecated. use createBasicSceneGraph(View v, TransformGroup vpt, VisADCanvasJ3D c, MouseBehaviorJ3D m, ColoringAttributes bc, ColoringAttributes cc) instead


createBasicSceneGraph

public BranchGroup createBasicSceneGraph(View v,
                                         TransformGroup vpt,
                                         VisADCanvasJ3D c,
                                         MouseBehaviorJ3D m,
                                         ColoringAttributes bc,
                                         ColoringAttributes cc)
Create scene graph root, if none exists, with Transform and direct manipulation root.

Parameters:
v -
vpt -
c -
m -
Returns:
Scene graph root.

setClip

public void setClip(int plane,
                    boolean enable,
                    float a,
                    float b,
                    float c,
                    float d)
             throws VisADException
Define a clipping plane in (XAxis, YAxis, ZAxis) space. Allows up to 6 arbitrary planes. Each clip plane is defined by the equation:
      aX + bY + cZ + d <= 0
 

Example useage:

To clip to the usual VisAD cube (i.e., x, y and z values in the range -1.0 to +1.0) (see Test35.java), call:
    DisplayRendererJ3D dr = 
             (DisplayRendererJ3D) display.getDisplayRenderer();
    dr.setClip(0, true,  1.0f,  0.0f,  0.0f, -1.01f);  // X_POS face
    dr.setClip(1, true, -1.0f,  0.0f,  0.0f, -1.01f);  // X_NEG face
    dr.setClip(2, true,  0.0f,  1.0f,  0.0f, -1.01f);  // Y_POS face
    dr.setClip(3, true,  0.0f, -1.0f,  0.0f, -1.01f);  // Y_NEG face
    dr.setClip(4, true,  0.0f,  0.0f,  1.0f, -1.01f);  // Z_POS face
    dr.setClip(5, true,  0.0f,  0.0f, -1.0f, -1.01f);  // Z_NEG face
 
Note: d value is slightly less than -1.0 so items in the plane are not clipped.

Parameters:
plane - plane number must be in (0, ..., 5)).
enable - true to enable clipping on this plane, false to disable
a - x coefficent
b - y coefficent
c - z coefficent
d - constant
Throws:
VisADException - illegal plane argument or unsupported (< 1.2) version of Java 3D

getMouseBehavior

public MouseBehavior getMouseBehavior()
Get the MouseBehavior associated with this renderer.

Specified by:
getMouseBehavior in class DisplayRenderer
Returns:
the MouseBehavior used by this renderer to handle mouse events.

getKeyboardBehavior

public KeyboardBehavior getKeyboardBehavior()
Get the KeyboardBehavior associated with this renderer.

Returns:
the KeyboardBehavior used by this renderer to handle mouse events.

addSceneGraphComponent

public void addSceneGraphComponent(Group group)

addLockedSceneGraphComponent

public void addLockedSceneGraphComponent(Group group)

addLockedSceneGraphComponent

public void addLockedSceneGraphComponent(Group group,
                                         boolean initWithProj)

updateLockedTrans

public void updateLockedTrans(double[] matrix)

addDirectManipulationSceneGraphComponent

public void addDirectManipulationSceneGraphComponent(Group group,
                                                     DirectManipulationRendererJ3D renderer)

clearScene

public void clearScene(DataRenderer renderer)

getCursor

public double[] getCursor()
Get the cusor location.

Specified by:
getCursor in class DisplayRenderer
Returns:
cursor location as an array of x, y, and z values

depth_cursor

public void depth_cursor(VisADRay ray)
Description copied from class: DisplayRenderer
set a VisADRay along which to drag cursor in depth (in and out of screen)

Specified by:
depth_cursor in class DisplayRenderer
Parameters:
ray - VisADRay to set

drag_depth

public void drag_depth(float diff)
Description copied from class: DisplayRenderer
drag cursor in depth (in and out of screen)

Specified by:
drag_depth in class DisplayRenderer
Parameters:
diff - amount to move cursor in depth (0.0 corresponds to no movement)

drag_cursor

public void drag_cursor(VisADRay ray,
                        boolean first)
Description copied from class: DisplayRenderer
drag cursor parallel to plane of screen

Specified by:
drag_cursor in class DisplayRenderer
Parameters:
ray - VisADRay that goes through new cursor location
first - true to indicate this is first call to drag_cursor() for this drag

setCursorLoc

public void setCursorLoc(float x,
                         float y,
                         float z)
Set the cursor location

Parameters:
x - x location
y - y location
z - z location

drawCursorStringVector

public void drawCursorStringVector(VisADCanvasJ3D canvas)
Whenever cursorOn or directOn is true, display Strings in cursorStringVector.

Parameters:
canvas -

findDirect

public DataRenderer findDirect(VisADRay ray,
                               int mouseModifiers)
Find the DataRenderer that is closest to the ray and uses the specified mouse modifiers for direct manipulation.

Specified by:
findDirect in class DisplayRenderer
Parameters:
ray - position to check
mouseModifiers - modifiers for mouse clicks
Returns:
closest DataRenderer that uses the specified mouse click modifiers for direct manipulation or null if there is none.

anyDirects

public boolean anyDirects()
Check to see if there are any DirectManipulationRenderers in this display.

Specified by:
anyDirects in class DisplayRenderer
Returns:
true if there are any

setScaleOn

public void setScaleOn(boolean on)
Set the scales on.

Specified by:
setScaleOn in class DisplayRenderer
Parameters:
on - turn on if true, otherwise turn them off

setScale

public void setScale(AxisScale axisScale)
              throws VisADException
Set the scale for the appropriate axis.

Specified by:
setScale in class DisplayRenderer
Parameters:
axisScale - AxisScale for this scale
Throws:
VisADException - couldn't set the scale

setScale

public void setScale(int axis,
                     int axis_ordinal,
                     VisADLineArray array,
                     float[] scale_color)
              throws VisADException
Set the scale for the appropriate axis.

Specified by:
setScale in class DisplayRenderer
Parameters:
axis - axis for this scale (0 = XAxis, 1 = YAxis, 2 = ZAxis)
axis_ordinal - position along the axis
array - VisADLineArray representing the scale plot
scale_color - array (dim 3) representing the red, green and blue color values.
Throws:
VisADException - couldn't set the scale

setScale

public void setScale(int axis,
                     int axis_ordinal,
                     VisADLineArray array,
                     VisADTriangleArray labels,
                     float[] scale_color)
              throws VisADException
Set the scale for the appropriate axis.

Specified by:
setScale in class DisplayRenderer
Parameters:
axis - axis for this scale (0 = XAxis, 1 = YAxis, 2 = ZAxis)
axis_ordinal - position along the axis
array - VisADLineArray representing the scale plot
labels - VisADTriangleArray representing the labels created using a font (can be null)
scale_color - array (dim 3) representing the red, green and blue color values.
Throws:
VisADException - couldn't set the scale

clearScales

public void clearScales()
Remove all the scales being rendered.

Specified by:
clearScales in class DisplayRenderer

clearScale

public void clearScale(AxisScale axisScale)
Remove a particular scale being rendered.

Specified by:
clearScale in class DisplayRenderer
Parameters:
axisScale - AxisScale to remove

setTransform3D

public void setTransform3D(Transform3D t)

makeControl

public Control makeControl(ScalarMap map)
Factory for constructing a subclass of Control appropriate for the graphics API and for this DisplayRenderer; invoked by ScalarMap when it is addMap()ed to a Display.

Specified by:
makeControl in class DisplayRenderer
Parameters:
map - The ScalarMap for which a Control should be built.
Returns:
The appropriate Control.

makeDefaultRenderer

public DataRenderer makeDefaultRenderer()
Create the default DataRenderer for this type of DisplayRenderer

Specified by:
makeDefaultRenderer in class DisplayRenderer
Returns:
new default renderer

legalDataRenderer

public boolean legalDataRenderer(DataRenderer renderer)
Check if the DataRenderer in question is legal for this DisplayRenderer

Specified by:
legalDataRenderer in class DisplayRenderer
Parameters:
renderer - DataRenderer to check
Returns:
true if renderer is a subclass of RendererJ3D

rendererDeleted

public void rendererDeleted(DataRenderer renderer)
Specified by:
rendererDeleted in interface RendererSourceListener

setLineWidth

public void setLineWidth(float width)

addKeyboardBehavior

public void addKeyboardBehavior(KeyboardBehaviorJ3D behavior)
Add a KeyboardBehavior for keyboard control of rotation, translation and zoom.

Parameters:
behavior - keyboard behavior to add

render_trigger

public void render_trigger()
Description copied from class: DisplayRenderer
trigger the graphics API to render the scene graph to the screen; intended to be over-ridden by graphics-API-specific extensions of DisplayRenderer

Overrides:
render_trigger in class DisplayRenderer

setWaitFlag

public void setWaitFlag(boolean b)
Description copied from class: DisplayRenderer
Set the wait flag to the specified value. (When the wait flag is enabled, the user is informed that the application is busy, typically by displaying a Please wait . . . message at the bottom of the Display.) DisplayEvent.WAIT_ON and DisplayEvent.WAIT_OFF events are fired based on value of b.

Overrides:
setWaitFlag in class DisplayRenderer
Parameters:
b - Boolean value to which wait flag is set.

getTextureWidthMax

public int getTextureWidthMax()
Specified by:
getTextureWidthMax in class DisplayRenderer

getTextureHeightMax

public int getTextureHeightMax()
Specified by:
getTextureHeightMax in class DisplayRenderer