de.jreality.ui.viewerapp
Class ViewerSwitch

java.lang.Object
  extended by de.jreality.ui.viewerapp.ViewerSwitch
All Implemented Interfaces:
Viewer

public class ViewerSwitch
extends Object
implements Viewer

hides several viewer implementations and provides the same viewing component for all. Using this class an application doesn't need to care about component replacement when switching from one viewer to another...

Author:
Steffen Weissmann

Constructor Summary
ViewerSwitch(Viewer[] viewers)
           
ViewerSwitch(Viewer[] viewers, String[] names)
           
 
Method Summary
 boolean canRenderAsync()
          Tells wether this viewer supports asyncronous rendering.
 void dispose()
           
 SceneGraphComponent getAuxiliaryRoot()
          Some viewers (at least the jogl viewer) support an auxilary root - for things to display that are no part of the scene itself.
 SceneGraphPath getCameraPath()
          Get the camera path.
 Viewer getCurrentViewer()
           
 int getNumViewers()
           
 SceneGraphComponent getSceneRoot()
          Get the scene root.
 String[] getViewerNames()
           
 Viewer[] getViewers()
           
 Component getViewingComponent()
          Gives the viewing component.
 Dimension getViewingComponentSize()
          Gives the dimension of the viewing component in pixel.
 boolean hasViewingComponent()
          Has this viewer a viewing component?
 void render()
          This method triggers rendering of the viewer.
 void renderAsync()
          Some viewers support asyncronous rendering.
 void selectViewer(int i)
           
 void selectViewer(String viewerName)
           
 void setAuxiliaryRoot(SceneGraphComponent ar)
          Some viewers (at least the jogl viewer) support an auxilary root - for things to display that are no part of the scene itself.
 void setCameraPath(SceneGraphPath p)
          Set the camera path.
 void setSceneRoot(SceneGraphComponent r)
          Set the scene root.
 void setToolSystem(ToolSystem toolSystem)
          Set all the viewers and the ViewerSwitch to have the same ToolSystem Would it be better to look up the tool system via the scene root, rather than per viewer?
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViewerSwitch

public ViewerSwitch(Viewer[] viewers)

ViewerSwitch

public ViewerSwitch(Viewer[] viewers,
                    String[] names)
Method Detail

getCurrentViewer

public Viewer getCurrentViewer()

selectViewer

public void selectViewer(int i)

getNumViewers

public int getNumViewers()

getViewers

public Viewer[] getViewers()

getViewerNames

public String[] getViewerNames()

selectViewer

public void selectViewer(String viewerName)

getSceneRoot

public SceneGraphComponent getSceneRoot()
Description copied from interface: Viewer
Get the scene root.

Specified by:
getSceneRoot in interface Viewer
Returns:
the scene root

getAuxiliaryRoot

public SceneGraphComponent getAuxiliaryRoot()
Description copied from interface: Viewer
Some viewers (at least the jogl viewer) support an auxilary root - for things to display that are no part of the scene itself. I. e. bounding boxes should go here.

Specified by:
getAuxiliaryRoot in interface Viewer
Returns:
the auxiliary root

getCameraPath

public SceneGraphPath getCameraPath()
Description copied from interface: Viewer
Get the camera path.

Specified by:
getCameraPath in interface Viewer
Returns:
the camera path

getViewingComponent

public Component getViewingComponent()
Description copied from interface: Viewer
Gives the viewing component. This is a java.awt.Component for an AWT viewer, or an org.eclipse.swt.Widget for an SWT viewer. Maybe there will be other types of viewing components that we do not know yet.

Specified by:
getViewingComponent in interface Viewer
Returns:
for now: a java.awt.Component or a org.eclipse.swt.Widget

hasViewingComponent

public boolean hasViewingComponent()
Description copied from interface: Viewer
Has this viewer a viewing component?

Specified by:
hasViewingComponent in interface Viewer
Returns:
true if the viewer has a viewing component, false otherwise.

render

public void render()
Description copied from interface: Viewer
This method triggers rendering of the viewer. The method returns as soon as the rendering is finished.

Specified by:
render in interface Viewer

setAuxiliaryRoot

public void setAuxiliaryRoot(SceneGraphComponent ar)
Description copied from interface: Viewer
Some viewers (at least the jogl viewer) support an auxilary root - for things to display that are no part of the scene itself. I. e. bounding boxes should go here.

Specified by:
setAuxiliaryRoot in interface Viewer
Parameters:
ar - the auxiliary root

setCameraPath

public void setCameraPath(SceneGraphPath p)
Description copied from interface: Viewer
Set the camera path. Some backends assume that this is a valid (existing) path starting at the scene root. This implies that one first needs to set the scene root. A camera path must have a Camera as the last element.

Specified by:
setCameraPath in interface Viewer
Parameters:
p - the camera path.

setSceneRoot

public void setSceneRoot(SceneGraphComponent r)
Description copied from interface: Viewer
Set the scene root.

Specified by:
setSceneRoot in interface Viewer
Parameters:
r - the scene root

canRenderAsync

public boolean canRenderAsync()
Description copied from interface: Viewer
Tells wether this viewer supports asyncronous rendering.

Specified by:
canRenderAsync in interface Viewer
Returns:
true if the viewer supports renderAsync() false otherwise

getViewingComponentSize

public Dimension getViewingComponentSize()
Description copied from interface: Viewer
Gives the dimension of the viewing component in pixel.

Specified by:
getViewingComponentSize in interface Viewer
Returns:
the Dimension of the viewing component when hasViewingComponent() returns true - null otherwise.

renderAsync

public void renderAsync()
                 throws UnsupportedOperationException
Description copied from interface: Viewer
Some viewers support asyncronous rendering. This means: when this method is called, it returns immediately and the viewer renders again as soon as possible: either right now or when the current rendering has finished. Multiple calls of this method while the viewer is rendering trigger one single rendering after the current one (optional operation).

Specified by:
renderAsync in interface Viewer
Throws:
UnsupportedOperationException

dispose

public void dispose()

setToolSystem

public void setToolSystem(ToolSystem toolSystem)
Set all the viewers and the ViewerSwitch to have the same ToolSystem Would it be better to look up the tool system via the scene root, rather than per viewer?

Parameters:
toolSystem -