org.jcae.viewer3d
Class View

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Canvas
          extended by javax.media.j3d.Canvas3D
              extended by org.jcae.viewer3d.View
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, PositionListener
Direct Known Subclasses:
TextureFitter

public class View
extends javax.media.j3d.Canvas3D
implements PositionListener

An AWT component wich display Viewable in a Java3D canvas. This class is responsible for handling picking and refresh events. The expected navigation behavior is the one of the OrbitBehavior of Java3D. Multiple selection is available using ctrl+Left click.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static byte BACK
           
static float BackClipDistanceFactor
           
static byte BOTTOM
           
static byte FRONT
           
static float FrontClipDistanceFactor
           
static byte LEFT
           
protected  com.sun.j3d.utils.behaviors.vp.OrbitBehavior orbit
           
static byte RIGHT
           
static byte TOP
           
 
Fields inherited from class javax.media.j3d.Canvas3D
FIELD_ALL, FIELD_LEFT, FIELD_RIGHT
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
View()
          Deprecated. Will cause a "java.lang.IllegalArgumentException: adding a container to a container on a different GraphicsDevice" in dual screen mode.
View(boolean offscreen)
          Deprecated. Will cause a "java.lang.IllegalArgumentException: adding a container to a container on a different GraphicsDevice" in dual screen mode.
View(boolean offscreen, boolean isSharedUniverse)
          Deprecated. Will cause a "java.lang.IllegalArgumentException: adding a container to a container on a different GraphicsDevice" in dual screen mode.
View(java.awt.Window window)
           
View(java.awt.Window window, boolean offscreen)
           
View(java.awt.Window window, boolean offscreen, boolean isSharedUniverse)
           
 
Method Summary
 void add(Viewable viewable)
          Add a Viewable to the current view
 void addBranchGroup(javax.media.j3d.BranchGroup branchGroup)
          Allow to had a custom branchgroup to the view
 void addPositionListener(PositionListener listener)
           
protected  void addPostRenderer(java.lang.Runnable runnable)
          Runnable to be call in the postRender method
 void addUnClipWidgetBranchGroup(javax.media.j3d.BranchGroup branchGroup)
          add a widget BranchGroup not clip by the clipModel
 void addWidgetBranchGroup(javax.media.j3d.BranchGroup branchGroup)
          add a widget BranchGroup
 boolean contains(Viewable viewable)
          inform if the view contains the viewable
protected  void finalize()
           
protected  void firePositionChanged()
           
protected  void fireViewableChanged(Viewable viewable)
          refresh the clip planes value
 void fit(Viewable viewable)
          Fit the view to show the specified viewable
 void fitAll()
          Fit the view to show all the Viewable
 double getBackClipDistance()
           
protected  javax.media.j3d.BoundingSphere getBound()
           
protected  javax.media.j3d.BranchGroup getBranchGroup(Viewable viewable)
          Get the cloned branchgroup of a viewable for this view.
 Viewable getCurrentViewable()
           
 double getFrontClipDistance()
           
protected  java.awt.image.BufferedImage getImage()
          Return an Image representing the current Canvas3D This method is not synchronized with the Java3D rendering.
protected  int getMouseMode()
           
 javax.media.j3d.TransformGroup getOriginAxisTransformGroup()
           
 double[] getRotationCenter()
           
 Viewable[] getViewables()
          Return viewables shown in this view
 com.sun.j3d.utils.universe.ViewingPlatform getViewingPlatform()
           
 boolean isInModelClip(javax.vecmath.Point3d pt)
          returns true if the point is in the modelclip
 boolean isOriginAxisVisible()
           
 void move(javax.media.j3d.Transform3D position)
          Move the view to the specified position
 void positionChanged()
          Implement PositionListener.
 void postRender()
           
 void postSwap()
          Overloaded for to be able to take snapshots and draw overlays (selection rectangle)
 void println(java.lang.String line)
          print a line in the PrintWriter
 void remove(Viewable viewable)
          Remove a viewable from this view
 void removeModelClip()
          remove the ModelClip of the view
protected  void removePostRenderer(java.lang.Runnable runnable)
           
 void removeUnClipWidgetBranchGroup(javax.media.j3d.BranchGroup branchGroup)
          remove the specified widget BranchGroup not clip by the clipModel
 void removeWidgetBranchGroup(javax.media.j3d.BranchGroup branchGroup)
          remove the specified widget BranchGroup
 void restoreFrontClipDistance()
          restore the Front clip distance to see all the Viewable
 void setBackClipDistance(double d)
           
 void setChangeRotationCenter(boolean status)
          Allow the user to specify the rotation center.
 void setClipBox(ClipBox box)
          create a clip Box and remove the previous modelclip Warning : all shared viewables will be clipped in other views !!
 void setClipPlanes(javax.vecmath.Vector4d[] planes)
          create the modelclip with the specified planes and remove the previous modelclip Warning : all shared viewables will be clipped in other views !!
 void setCurrentViewable(Viewable v)
           
 void setFixedAxisVisible(boolean show)
          Display 3D x-y-z cartesian, at the center of the view.
 void setFrontClipDistance(double d)
           
 void setMouseMode(int mode)
          set the current mouse mode : see ViewBehavior
 void setNavigationMaster(View view)
          Create a navigation link with the specified view.
 void setOrientation(byte orientation)
          Change the view angle to a predefined one.
 void setOriginAxisVisible(boolean show)
          Display 3D x-y-z cartesian at the 3D origin of the model.
 void setPickableViewables(java.util.Collection viewables)
          Set the list of Viewables to which picking events will be dispatched.
 void setPickingMode(short mode)
          Set the picking mode: 0, for single click picking 1, for rectangular selection picking 2, for polygonal selection picking
 void setPrintWriter(java.io.PrintWriter writer)
          set a PrintWriter for the viewer messages
 void setRotationCenter(double x, double y, double z)
           
static void startRenderer(Viewable viewable)
           
static void stopRenderer(Viewable viewable)
           
 void takeScreenshot(ScreenshotListener listener)
          Take a snapshot of the current view Do not use this for offscreen rendering.
 java.awt.image.BufferedImage takeSnapshot()
          Deprecated. Use takeScreenshot Not thread safe. In some configuration a deadlock could occure.
 java.awt.image.BufferedImage takeSnapshot(int w, int h)
          Take a snapshot of the current view in Off-screen mode Do not use this for on-screen rendering.
static void viewableChanged(Viewable viewable)
           
 javax.media.j3d.Transform3D where()
          Return the current position of the view
 void zoomTo(float x, float y, float z, float radius)
          Modify the view to best see what is include a given sphere
 
Methods inherited from class javax.media.j3d.Canvas3D
addNotify, getBounds, getBounds, getCenterEyeInImagePlate, getDoubleBufferAvailable, getDoubleBufferEnable, getGraphics2D, getGraphicsContext3D, getHeight, getImagePlateToVworld, getInverseVworldProjection, getLeftEyeInImagePlate, getLeftManualEyeInImagePlate, getLocation, getLocation, getLocationOnScreen, getMonoscopicViewPolicy, getOffScreenBuffer, getOffScreenLocation, getOffScreenLocation, getPhysicalHeight, getPhysicalWidth, getPixelLocationFromImagePlate, getPixelLocationInImagePlate, getPixelLocationInImagePlate, getRightEyeInImagePlate, getRightManualEyeInImagePlate, getSceneAntialiasingAvailable, getScreen3D, getSize, getSize, getStereoAvailable, getStereoEnable, getView, getVworldProjection, getVworldToImagePlate, getWidth, getX, getY, isOffScreen, isRendererRunning, isShadingLanguageSupported, paint, preRender, queryProperties, removeNotify, renderField, renderOffScreenBuffer, setDoubleBufferEnable, setLeftManualEyeInImagePlate, setMonoscopicViewPolicy, setOffScreenBuffer, setOffScreenLocation, setOffScreenLocation, setRightManualEyeInImagePlate, setStereoEnable, startRenderer, stopRenderer, swap, waitForOffScreenRendering
 
Methods inherited from class java.awt.Canvas
createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, update
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FrontClipDistanceFactor

public static final float FrontClipDistanceFactor
See Also:
Constant Field Values

BackClipDistanceFactor

public static final float BackClipDistanceFactor
See Also:
Constant Field Values

orbit

protected com.sun.j3d.utils.behaviors.vp.OrbitBehavior orbit

TOP

public static final byte TOP
See Also:
Constant Field Values

BOTTOM

public static final byte BOTTOM
See Also:
Constant Field Values

LEFT

public static final byte LEFT
See Also:
Constant Field Values

RIGHT

public static final byte RIGHT
See Also:
Constant Field Values

FRONT

public static final byte FRONT
See Also:
Constant Field Values

BACK

public static final byte BACK
See Also:
Constant Field Values
Constructor Detail

View

@Deprecated
public View()
Deprecated. Will cause a "java.lang.IllegalArgumentException: adding a container to a container on a different GraphicsDevice" in dual screen mode.

See https://java3d.dev.java.net/issues/show_bug.cgi?id=89


View

@Deprecated
public View(boolean offscreen)
Deprecated. Will cause a "java.lang.IllegalArgumentException: adding a container to a container on a different GraphicsDevice" in dual screen mode.

See https://java3d.dev.java.net/issues/show_bug.cgi?id=89


View

@Deprecated
public View(boolean offscreen,
                       boolean isSharedUniverse)
Deprecated. Will cause a "java.lang.IllegalArgumentException: adding a container to a container on a different GraphicsDevice" in dual screen mode.

See https://java3d.dev.java.net/issues/show_bug.cgi?id=89


View

public View(java.awt.Window window)

View

public View(java.awt.Window window,
            boolean offscreen)

View

public View(java.awt.Window window,
            boolean offscreen,
            boolean isSharedUniverse)
Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

setPrintWriter

public void setPrintWriter(java.io.PrintWriter writer)
set a PrintWriter for the viewer messages


println

public void println(java.lang.String line)
print a line in the PrintWriter


getOriginAxisTransformGroup

public javax.media.j3d.TransformGroup getOriginAxisTransformGroup()

add

public void add(Viewable viewable)
Add a Viewable to the current view


addBranchGroup

public void addBranchGroup(javax.media.j3d.BranchGroup branchGroup)
Allow to had a custom branchgroup to the view

Parameters:
branchGroup -

addWidgetBranchGroup

public void addWidgetBranchGroup(javax.media.j3d.BranchGroup branchGroup)
add a widget BranchGroup

Parameters:
branchGroup -

removeWidgetBranchGroup

public void removeWidgetBranchGroup(javax.media.j3d.BranchGroup branchGroup)
remove the specified widget BranchGroup

Parameters:
branchGroup -

addUnClipWidgetBranchGroup

public void addUnClipWidgetBranchGroup(javax.media.j3d.BranchGroup branchGroup)
add a widget BranchGroup not clip by the clipModel

Parameters:
branchGroup -

removeUnClipWidgetBranchGroup

public void removeUnClipWidgetBranchGroup(javax.media.j3d.BranchGroup branchGroup)
remove the specified widget BranchGroup not clip by the clipModel

Parameters:
branchGroup -

removeModelClip

public void removeModelClip()
remove the ModelClip of the view


setClipPlanes

public void setClipPlanes(javax.vecmath.Vector4d[] planes)
create the modelclip with the specified planes and remove the previous modelclip Warning : all shared viewables will be clipped in other views !!


setClipBox

public void setClipBox(ClipBox box)
create a clip Box and remove the previous modelclip Warning : all shared viewables will be clipped in other views !!


isInModelClip

public boolean isInModelClip(javax.vecmath.Point3d pt)
returns true if the point is in the modelclip


addPositionListener

public void addPositionListener(PositionListener listener)
Parameters:
view -

firePositionChanged

protected void firePositionChanged()

fit

public void fit(Viewable viewable)
Fit the view to show the specified viewable


fitAll

public void fitAll()
Fit the view to show all the Viewable


restoreFrontClipDistance

public void restoreFrontClipDistance()
restore the Front clip distance to see all the Viewable


setFrontClipDistance

public void setFrontClipDistance(double d)

getFrontClipDistance

public double getFrontClipDistance()

getBackClipDistance

public double getBackClipDistance()

setBackClipDistance

public void setBackClipDistance(double d)

getBound

protected javax.media.j3d.BoundingSphere getBound()

getBranchGroup

protected javax.media.j3d.BranchGroup getBranchGroup(Viewable viewable)
Get the cloned branchgroup of a viewable for this view. The viewables may used it to modify a branchgroup whithout rebuilding it entirely.

Parameters:
view -
Returns:

getViewables

public Viewable[] getViewables()
Return viewables shown in this view


getCurrentViewable

public Viewable getCurrentViewable()

getViewingPlatform

public com.sun.j3d.utils.universe.ViewingPlatform getViewingPlatform()

setCurrentViewable

public void setCurrentViewable(Viewable v)

move

public void move(javax.media.j3d.Transform3D position)
Move the view to the specified position


positionChanged

public void positionChanged()
Implement PositionListener. This listener is fired when the navigation master move.

Specified by:
positionChanged in interface PositionListener

postSwap

public void postSwap()
Overloaded for to be able to take snapshots and draw overlays (selection rectangle)

Overrides:
postSwap in class javax.media.j3d.Canvas3D
See Also:
takeSnapshot

getImage

protected java.awt.image.BufferedImage getImage()
Return an Image representing the current Canvas3D This method is not synchronized with the Java3D rendering. It used by takeSnapShopt method (which add synchronization), and for the rendering of the rectangle selection.


remove

public void remove(Viewable viewable)
Remove a viewable from this view


contains

public boolean contains(Viewable viewable)
inform if the view contains the viewable


setNavigationMaster

public void setNavigationMaster(View view)
Create a navigation link with the specified view. This will ensure that the current view show the same Position as the specified view.

Parameters:
view - the master view, null mean no master.

setPickableViewables

public void setPickableViewables(java.util.Collection viewables)
Set the list of Viewables to which picking events will be dispatched. The Viewable objects not in this list will not be pickable.

Parameters:
viewables -

setPickingMode

public void setPickingMode(short mode)
Set the picking mode:

Parameters:
mode -

setFixedAxisVisible

public void setFixedAxisVisible(boolean show)
Display 3D x-y-z cartesian, at the center of the view. These axis are visible whenever the 3D origin cannot be seen. Axis are identified with strings "x","y" and "z". The size of the axis do not depends on the zoom level.

Parameters:
show -

setOriginAxisVisible

public void setOriginAxisVisible(boolean show)
Display 3D x-y-z cartesian at the 3D origin of the model. Axis are identified with strings "x","y" and "z". The size of the axis do not depends on the zoom level.

Parameters:
show -

isOriginAxisVisible

public boolean isOriginAxisVisible()

takeSnapshot

@Deprecated
public java.awt.image.BufferedImage takeSnapshot()
Deprecated. Use takeScreenshot Not thread safe. In some configuration a deadlock could occure.

Take a snapshot of the current view Do not use this for offscreen rendering. See "On-screen Rendering vs. Off-screen Rendering" in Canvas3D javadoc. This method should be wrapped in a SwingUtilities.invokeXXXX statements.


takeScreenshot

public void takeScreenshot(ScreenshotListener listener)
Take a snapshot of the current view Do not use this for offscreen rendering. See "On-screen Rendering vs. Off-screen Rendering" in Canvas3D javadoc.


takeSnapshot

public java.awt.image.BufferedImage takeSnapshot(int w,
                                                 int h)
Take a snapshot of the current view in Off-screen mode Do not use this for on-screen rendering. See "On-screen Rendering vs. Off-screen Rendering" in Canvas3D javadoc.


where

public javax.media.j3d.Transform3D where()
Return the current position of the view


zoomTo

public void zoomTo(float x,
                   float y,
                   float z,
                   float radius)
Modify the view to best see what is include a given sphere

Parameters:
x - x coordinate of the center of the sphere
y - y coordinate of the center of the sphere
z - z coordinate of the center of the sphere
radius - radius of the sphere

getRotationCenter

public double[] getRotationCenter()

setRotationCenter

public void setRotationCenter(double x,
                              double y,
                              double z)

setChangeRotationCenter

public void setChangeRotationCenter(boolean status)
Allow the user to specify the rotation center. The next click will be concidered as a rotation center redefinition.


setMouseMode

public void setMouseMode(int mode)
set the current mouse mode : see ViewBehavior


getMouseMode

protected int getMouseMode()

setOrientation

public void setOrientation(byte orientation)
Change the view angle to a predefined one. It could be TOP, BOTTOM, LEFT, RIGHT, FRONT, BACK.


fireViewableChanged

protected void fireViewableChanged(Viewable viewable)
refresh the clip planes value


viewableChanged

public static void viewableChanged(Viewable viewable)

stopRenderer

public static void stopRenderer(Viewable viewable)

startRenderer

public static void startRenderer(Viewable viewable)

addPostRenderer

protected void addPostRenderer(java.lang.Runnable runnable)
Runnable to be call in the postRender method

Parameters:
runnable -

removePostRenderer

protected void removePostRenderer(java.lang.Runnable runnable)

postRender

public final void postRender()
Overrides:
postRender in class javax.media.j3d.Canvas3D