ptolemy.domains.gr.lib
Class ViewScreen3D

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.InstantiableNamedObj
          extended by ptolemy.kernel.Entity
              extended by ptolemy.kernel.ComponentEntity
                  extended by ptolemy.actor.AtomicActor
                      extended by ptolemy.actor.TypedAtomicActor
                          extended by ptolemy.domains.gr.kernel.GRActor
                              extended by ptolemy.domains.gr.kernel.GRActor3D
                                  extended by ptolemy.domains.gr.lib.ViewScreen3D
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Placeable, Initializable, TypedActor, ViewScreenInterface, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
Direct Known Subclasses:
MovableViewScreen3D

public class ViewScreen3D
extends GRActor3D
implements Placeable, ViewScreenInterface

A sink actor that renders the 3D GR geometry into a display screen.

Since:
Ptolemy II 4.1
Version:
$Id: ViewScreen3D.java 57040 2010-01-27 20:52:32Z cxh $
Author:
C. Fong, Adam Cataldo, Steve Neuendorffer
See Also:
Serialized Form
Accepted Rating:
Green (acataldo)
Proposed Rating:
Green (eal)

Nested Class Summary
private static class ViewScreen3D.MouseRotateView
           
 
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
 
Field Summary
protected  javax.media.j3d.BoundingSphere _bounds
          The BoundingSphere.
protected  javax.media.j3d.BranchGroup _branchRoot
          The main connection branch that connects to the universe.
protected  javax.media.j3d.Canvas3D _canvas
          The Java3D canvas component.
protected  java.awt.Container _container
          The container set in the place() method, or the content pane of the created frame if place was not called.
protected  javax.swing.JFrame _frame
          The frame containing our canvas, if we created it.
protected  boolean _iterationSynchronized
          True for manual rendering, false for default rendering.
protected  javax.media.j3d.Transform3D _lastTransform
          The last transform.
protected  ViewScreen3D.MouseRotateView _mouseRotate
          The mouse rotate view.
protected  javax.media.j3d.BranchGroup _root
          The connection branch to which incoming nodes connect.
protected  com.sun.j3d.utils.universe.SimpleUniverse _simpleUniverse
          The Java3D universe, displayed inside the canvas.
protected  javax.media.j3d.TransformGroup _userTransformation
          The user tranformation.
 ColorAttribute backgroundColor
          The background color.
 Parameter horizontalResolution
          The width in pixels of the display screen.
 Parameter iterationSynchronized
          Boolean variable that determines whether screen update is done once per iteration.
 Parameter rotatable
          Boolean variable that determines whether the user can rotate the model with the mouse.
 Parameter scalable
          Boolean variable that determines whether the user can move the point of view along the z axis using the mouse.
 TypedIOPort sceneGraphIn
          The input scene graph.
 Parameter showAxes
          Boolean variable that determines whether or not axes are shown.
 Parameter translatable
          Boolean variable that determines whether the user can translate the model with the mouse.
 Parameter verticalResolution
          The height in pixels of the display screen.
 
Fields inherited from class ptolemy.domains.gr.kernel.GRActor3D
_viewScreen
 
Fields inherited from class ptolemy.domains.gr.kernel.GRActor
_allowAttributeChanges, _isSceneGraphInitialized
 
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
 
Constructor Summary
ViewScreen3D(CompositeEntity container, java.lang.String name)
          Construct a ViewScreen in the given container with the given name.
 
Method Summary
protected  void _addChild(javax.media.j3d.Node node)
          Add the node argument as a child to the encapsulated Java3D node in this actor.
protected  void _createViewScreen()
          Create the view screen component.
protected  int _getHorizontalPixels()
          Get the number of horizontal pixels in the rendered image.
protected  javax.media.j3d.Node _getNodeObject()
          The ViewScreen does not have an associated Java3D node.
protected  int _getVerticalPixels()
          Get the number of vertical pixels in the rendered image.
private  boolean _isIterationSynchronized()
           
private  boolean _isRotatable()
           
private  boolean _isScalable()
           
private  boolean _isTranslatable()
           
protected  javax.media.j3d.Background _makeBackground()
          Makes the background for the viewScreen.
protected  void _makeNodeConnection()
          Connect each of the channels of the sceneGraphIn port to the scene.
protected  void _makeSceneGraphConnection()
          Setup the scene graph connections of this actor.
private  boolean _shouldShowAxes()
           
protected  void _startRenderer()
          Start the internal Java3D renderer.
protected  void _stopRenderer()
          Stop the internal Java3D renderer.
 void addChild(javax.media.j3d.Node node)
          Add the node argument as a child to the encapsulated Java3D node in this actor.
 void fire()
          Fire this actor.
 javax.media.j3d.BranchGroup getBranchGroup()
          Return the root Java 3D rendering group used by this view screen.
 javax.media.j3d.Canvas3D getCanvas()
          Return the Java 3D canvas used by this view screen.
 void initialize()
          Initialize the execution.
 void place(java.awt.Container container)
          Set the container that this actor should display data in.
 boolean postfire()
          Return true, unless stop() has been called, in which case, return false.
 void wrapup()
          Wrapup an execution.
 
Methods inherited from class ptolemy.domains.gr.kernel.GRActor3D
_setViewScreen
 
Methods inherited from class ptolemy.actor.TypedAtomicActor
_addPort, _fireAt, _fireAt, attributeTypeChanged, clone, newPort, typeConstraintList, typeConstraints
 
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, addActorFiringListener, addInitializable, clone, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
 
Methods inherited from class ptolemy.kernel.Entity
_description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
 
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
 
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, prefire, stop, stopFire, terminate
 
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, preinitialize, removeInitializable
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
 
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 

Field Detail

sceneGraphIn

public TypedIOPort sceneGraphIn
The input scene graph. Actors that produce 3D objects can be connected to this port for rendering. The type of this port is sceneGraph.


backgroundColor

public ColorAttribute backgroundColor
The background color. Note that the alpha value (the fourth element of the array), which would normally specify transparency, is ignored.


horizontalResolution

public Parameter horizontalResolution
The width in pixels of the display screen. The larger of the vertical or horizontal size will correspond by default to one unit of distance, so this parameter determines the horizontal resolution as well as the size of the display. This is an int with default 400.


iterationSynchronized

public Parameter iterationSynchronized
Boolean variable that determines whether screen update is done once per iteration. This is a boolean with default false.


rotatable

public Parameter rotatable
Boolean variable that determines whether the user can rotate the model with the mouse. This is a boolean with default true.


scalable

public Parameter scalable
Boolean variable that determines whether the user can move the point of view along the z axis using the mouse. This is a boolean with default false.


showAxes

public Parameter showAxes
Boolean variable that determines whether or not axes are shown. This parameter is a boolean with default false.


translatable

public Parameter translatable
Boolean variable that determines whether the user can translate the model with the mouse. This is a boolean with default false.


verticalResolution

public Parameter verticalResolution
The height in pixels of the display screen. The larger of the vertical or horizontal size will correspond by default to one unit of distance, so this parameter determines the horizontal resolution as well as the size of the display. This is an integer with default 400.


_bounds

protected javax.media.j3d.BoundingSphere _bounds
The BoundingSphere.


_branchRoot

protected javax.media.j3d.BranchGroup _branchRoot
The main connection branch that connects to the universe.


_root

protected javax.media.j3d.BranchGroup _root
The connection branch to which incoming nodes connect.


_canvas

protected javax.media.j3d.Canvas3D _canvas
The Java3D canvas component.


_container

protected java.awt.Container _container
The container set in the place() method, or the content pane of the created frame if place was not called.


_frame

protected javax.swing.JFrame _frame
The frame containing our canvas, if we created it.


_iterationSynchronized

protected boolean _iterationSynchronized
True for manual rendering, false for default rendering.


_lastTransform

protected javax.media.j3d.Transform3D _lastTransform
The last transform.


_mouseRotate

protected ViewScreen3D.MouseRotateView _mouseRotate
The mouse rotate view.


_simpleUniverse

protected com.sun.j3d.utils.universe.SimpleUniverse _simpleUniverse
The Java3D universe, displayed inside the canvas.


_userTransformation

protected javax.media.j3d.TransformGroup _userTransformation
The user tranformation.

Constructor Detail

ViewScreen3D

public ViewScreen3D(CompositeEntity container,
                    java.lang.String name)
             throws IllegalActionException,
                    NameDuplicationException
Construct a ViewScreen in the given container with the given name. If the container argument is null, a NullPointerException will be thrown. If the name argument is null, then the name is set to the empty string. Increment the version number of the workspace.

Parameters:
container - Container of the director.
name - Name of this ViewScreen.
Throws:
IllegalActionException - If this actor is not compatible with the specified container.
NameDuplicationException - If the container not a CompositeActor and the name collides with an entity in the container.
Method Detail

addChild

public void addChild(javax.media.j3d.Node node)
Add the node argument as a child to the encapsulated Java3D node in this actor.

Parameters:
node - The node to be added.

fire

public void fire()
          throws IllegalActionException
Fire this actor.

Specified by:
fire in interface Executable
Overrides:
fire in class GRActor
Throws:
IllegalActionException - If an error occurs during the scene graph initialization.

getBranchGroup

public javax.media.j3d.BranchGroup getBranchGroup()
Return the root Java 3D rendering group used by this view screen.

Returns:
the root Java 3D rendering group used by this view screen.

getCanvas

public javax.media.j3d.Canvas3D getCanvas()
Return the Java 3D canvas used by this view screen.

Returns:
the Java 3D canvas used by this view screen.

initialize

public void initialize()
                throws IllegalActionException
Initialize the execution. Create the ViewScreen frame if it hasn't been set using the place() method.

Specified by:
initialize in interface Initializable
Overrides:
initialize in class GRActor
Throws:
IllegalActionException - If the base class throws it.

place

public void place(java.awt.Container container)
Set the container that this actor should display data in. If place is not called, then the actor will create its own frame for display.

Specified by:
place in interface Placeable
Parameters:
container - The container in which to place the object, or null to specify that there is no current container.

postfire

public boolean postfire()
                 throws IllegalActionException
Description copied from class: AtomicActor
Return true, unless stop() has been called, in which case, return false. Derived classes override this method to define operations to be performed at the end of every iteration of its execution, after one invocation of the prefire() method and any number of invocations of the fire() method. This method typically wraps up an iteration, which may involve updating local state. In derived classes, this method returns false to indicate that this actor should not be fired again.

Specified by:
postfire in interface Executable
Overrides:
postfire in class AtomicActor
Returns:
True if execution can continue into the next iteration.
Throws:
IllegalActionException - Not thrown in this base class.

wrapup

public void wrapup()
            throws IllegalActionException
Wrapup an execution.

Specified by:
wrapup in interface Initializable
Overrides:
wrapup in class GRActor
Throws:
IllegalActionException - If the base class throws it.

_addChild

protected void _addChild(javax.media.j3d.Node node)
Add the node argument as a child to the encapsulated Java3D node in this actor.

Overrides:
_addChild in class GRActor3D
Parameters:
node - The node to add.

_createViewScreen

protected void _createViewScreen()
Create the view screen component. If place() was called with a container, then use the container. Otherwise, create a new frame and use that.


_getHorizontalPixels

protected int _getHorizontalPixels()
                            throws IllegalActionException
Get the number of horizontal pixels in the rendered image.

Returns:
the number of horizontal pixels in the rendered image.
Throws:
IllegalActionException - If thrown while reading the horizontalPixels parameter.

_getNodeObject

protected javax.media.j3d.Node _getNodeObject()
The ViewScreen does not have an associated Java3D node.

Specified by:
_getNodeObject in class GRActor3D
Returns:
null

_getVerticalPixels

protected int _getVerticalPixels()
                          throws IllegalActionException
Get the number of vertical pixels in the rendered image.

Returns:
the number of vertical pixels in the rendered image.
Throws:
IllegalActionException - If thrown while reading the verticalPixels parameter.

_makeBackground

protected javax.media.j3d.Background _makeBackground()
                                              throws IllegalActionException
Makes the background for the viewScreen.

Returns:
javax.media.j3d.Background
Throws:
IllegalActionException - If unable to read the color parameter.

_makeNodeConnection

protected void _makeNodeConnection()
                            throws IllegalActionException
Connect each of the channels of the sceneGraphIn port to the scene.

Throws:
IllegalActionException - If thrown while reading from a channel.

_makeSceneGraphConnection

protected void _makeSceneGraphConnection()
                                  throws IllegalActionException
Setup the scene graph connections of this actor.

Specified by:
_makeSceneGraphConnection in class GRActor
Throws:
IllegalActionException - Always thrown for this base class.

_startRenderer

protected void _startRenderer()
Start the internal Java3D renderer.


_stopRenderer

protected void _stopRenderer()
Stop the internal Java3D renderer.


_isIterationSynchronized

private boolean _isIterationSynchronized()
                                  throws IllegalActionException
Throws:
IllegalActionException

_isRotatable

private boolean _isRotatable()
                      throws IllegalActionException
Throws:
IllegalActionException

_isScalable

private boolean _isScalable()
                     throws IllegalActionException
Throws:
IllegalActionException

_isTranslatable

private boolean _isTranslatable()
                         throws IllegalActionException
Throws:
IllegalActionException

_shouldShowAxes

private boolean _shouldShowAxes()
                         throws IllegalActionException
Throws:
IllegalActionException