visad.java2d
Class DisplayRendererJ2D

java.lang.Object
  extended by visad.DisplayRenderer
      extended by visad.java2d.DisplayRendererJ2D
All Implemented Interfaces:
EventListener, ControlListener, RendererSourceListener
Direct Known Subclasses:
DefaultDisplayRendererJ2D

public abstract class DisplayRendererJ2D
extends DisplayRenderer
implements RendererSourceListener

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

DisplayRendererJ2D also manages the overall relation of DataRenderer output to Java2D and manages the VisAD scene graph.

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

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


Constructor Summary
DisplayRendererJ2D()
           
 
Method Summary
 void addDirectManipulationSceneGraphComponent(VisADGroup group, DirectManipulationRendererJ2D renderer)
           
 void addKeyboardBehavior(KeyboardBehaviorJ2D behavior)
          Add a KeyboardBehavior for keyboard control of translation and zoom.
 void addSceneGraphComponent(VisADGroup group)
           
 boolean anyCursorStringVector()
           
 boolean anyDirects()
           
 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.
 VisADGroup createBasicSceneGraph(VisADCanvasJ2D c, MouseBehaviorJ2D m)
          Deprecated. use createBasicSceneGraph(VisADCanvasJ2D c, MouseBehaviorJ2D m, VisADAppearance bx, VisADAppearance cr) instead
 VisADGroup createBasicSceneGraph(VisADCanvasJ2D c, MouseBehaviorJ2D m, VisADAppearance bx, VisADAppearance cr)
          Create scene graph root, if none exists, with Transform and direct manipulation root.
abstract  VisADGroup createSceneGraph(VisADCanvasJ2D c)
          Create scene graph root, if none exists, with Transform, direct manipulation root, and non-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 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(Graphics graphics, AffineTransform tgeometry, int width, int height)
          Whenever cursorOn or directOn is true, display Strings in cursorStringVector.
 DataRenderer findDirect(VisADRay ray, int mouseModifiers)
          Returns a direct manipulation renderer if one is close to the specified ray (within pick threshold).
 VisADGroup getBoxOnBranch()
           
 VisADCanvasJ2D getCanvas()
           
 double[] getCursor()
          Returns the location of the last unmodified, middle mouse button press.
 VisADGroup getCursorOnBranch()
           
 VisADGroup getDirect()
           
 BufferedImage getImage()
          Get a snapshot of the displayed image.
 MouseBehavior getMouseBehavior()
           
 VisADGroup getNonDirect()
           
 VisADGroup getRoot()
           
 int getTextureHeightMax()
           
 int getTextureWidthMax()
           
 AffineTransform getTrans()
           
 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)
          determine whether a DataRenderer 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()
          Factory for constructing the default subclass of DataRenderer for this 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(float xlow, float xhi, float ylow, float yhi)
           
 void setCursorOn(boolean on)
          set flag indicating whether the cursor should be displayed.
 void setDirectOn(boolean on)
          set flag indicating whether direct manipulation is active
 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)
          Allow scales to be displayed if they are set on.
 void setTransform2D(AffineTransform t)
           
 void setWaitFlag(boolean b)
          Set the wait flag to the specified value.
 void unsetClip()
           
 
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

DisplayRendererJ2D

public DisplayRendererJ2D()
Method Detail

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.

getRoot

public VisADGroup getRoot()

setClip

public void setClip(float xlow,
                    float xhi,
                    float ylow,
                    float yhi)

unsetClip

public void unsetClip()

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)
                    throws VisADException,
                           RemoteException
Update internal values from those in the RendererControl.

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

getTrans

public AffineTransform getTrans()

getCanvas

public VisADCanvasJ2D getCanvas()

getImage

public BufferedImage getImage()
Description copied from class: DisplayRenderer
Get a snapshot of the displayed image.

Specified by:
getImage in class DisplayRenderer
Returns:
The current image being displayed.

getCursorOnBranch

public VisADGroup getCursorOnBranch()

getBoxOnBranch

public VisADGroup getBoxOnBranch()

setCursorOn

public void setCursorOn(boolean on)
Description copied from class: DisplayRenderer
set flag indicating whether the cursor should be displayed.

Specified by:
setCursorOn in class DisplayRenderer
Parameters:
on - value of flag to set

setDirectOn

public void setDirectOn(boolean on)
Description copied from class: DisplayRenderer
set flag indicating whether direct manipulation is active

Specified by:
setDirectOn in class DisplayRenderer
Parameters:
on - value of flag to set

getDirect

public VisADGroup getDirect()

getNonDirect

public VisADGroup getNonDirect()

createSceneGraph

public abstract VisADGroup createSceneGraph(VisADCanvasJ2D c)
                                     throws DisplayException
Create scene graph root, if none exists, with Transform, direct manipulation root, and non-direct-manipulation root; create special graphics (e.g., 3-D box, SkewT background), any lights, any user interface embedded in scene.

Parameters:
c -
Returns:
Scene graph root.
Throws:
DisplayException

createBasicSceneGraph

public VisADGroup createBasicSceneGraph(VisADCanvasJ2D c,
                                        MouseBehaviorJ2D m)
                                 throws DisplayException
Deprecated. use createBasicSceneGraph(VisADCanvasJ2D c, MouseBehaviorJ2D m, VisADAppearance bx, VisADAppearance cr) instead

Throws:
DisplayException

createBasicSceneGraph

public VisADGroup createBasicSceneGraph(VisADCanvasJ2D c,
                                        MouseBehaviorJ2D m,
                                        VisADAppearance bx,
                                        VisADAppearance cr)
                                 throws DisplayException
Create scene graph root, if none exists, with Transform and direct manipulation root.

Parameters:
c -
m -
Returns:
Scene graph root.
Throws:
DisplayException

getMouseBehavior

public MouseBehavior getMouseBehavior()
Specified by:
getMouseBehavior in class DisplayRenderer
Returns:
the MouseBehavior for this display

addSceneGraphComponent

public void addSceneGraphComponent(VisADGroup group)
                            throws DisplayException
Throws:
DisplayException

addDirectManipulationSceneGraphComponent

public void addDirectManipulationSceneGraphComponent(VisADGroup group,
                                                     DirectManipulationRendererJ2D renderer)
                                              throws DisplayException
Throws:
DisplayException

clearScene

public void clearScene(DataRenderer renderer)

getCursor

public double[] getCursor()
Returns the location of the last unmodified, middle mouse button press.

Specified by:
getCursor in class DisplayRenderer
Returns:
The location of the last unmodified, middle mouse button press as (Display.XAxis, Display.YAxis, 0.0).

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

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

anyCursorStringVector

public boolean anyCursorStringVector()

drawCursorStringVector

public void drawCursorStringVector(Graphics graphics,
                                   AffineTransform tgeometry,
                                   int width,
                                   int height)
Whenever cursorOn or directOn is true, display Strings in cursorStringVector.

Parameters:
graphics -
tgeometry -
width -
height -

findDirect

public DataRenderer findDirect(VisADRay ray,
                               int mouseModifiers)
Description copied from class: DisplayRenderer
Returns a direct manipulation renderer if one is close to the specified ray (within pick threshold).

Specified by:
findDirect in class DisplayRenderer
Parameters:
ray - The ray used to look for a nearby direct manipulation renderer.
mouseModifiers - Value of InputEvent.getModifiers().
Returns:
DataRenderer or null.

anyDirects

public boolean anyDirects()
Specified by:
anyDirects in class DisplayRenderer
Returns:
flag indicating whether there are any direct manipulation DataRenderers linked to Display

setScaleOn

public void setScaleOn(boolean on)
Allow scales to be displayed if they are set on.

Specified by:
setScaleOn in class DisplayRenderer
Parameters:
on - true to turn them on, false to set them invisible

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 - scale to be removed

setTransform2D

public void setTransform2D(AffineTransform 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()
Description copied from class: DisplayRenderer
Factory for constructing the default subclass of DataRenderer for this DisplayRenderer.

Specified by:
makeDefaultRenderer in class DisplayRenderer
Returns:
The default DataRenderer.

legalDataRenderer

public boolean legalDataRenderer(DataRenderer renderer)
Description copied from class: DisplayRenderer
determine whether a DataRenderer is legal for this DisplayRenderer

Specified by:
legalDataRenderer in class DisplayRenderer
Parameters:
renderer - DisplayRenderer to test for legality
Returns:
true if renderer is legal

rendererDeleted

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

setLineWidth

public void setLineWidth(float width)

addKeyboardBehavior

public void addKeyboardBehavior(KeyboardBehaviorJ2D behavior)
Add a KeyboardBehavior for keyboard control of translation and zoom. This adds a KeyListener to the VisADCanvasJ2D to handle the behaviors for the arrow keys. Do not use this in conjunction with other KeyListeners that handle events for the arrow keys.

Parameters:
behavior - keyboard behavior to add

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