sim.portrayal3d
Class SparseFieldPortrayal3D

java.lang.Object
  extended bysim.portrayal.FieldPortrayal
      extended bysim.portrayal3d.FieldPortrayal3D
          extended bysim.portrayal3d.SparseFieldPortrayal3D
All Implemented Interfaces:
Portrayal, Portrayal3D, java.io.Serializable
Direct Known Subclasses:
ContinuousPortrayal3D, SparseGridPortrayal3D

public abstract class SparseFieldPortrayal3D
extends FieldPortrayal3D

An abstract superclass for all FieldPortrayal3Ds which display SparseFields. This class handles the createModel() and updateModel() methods for you; all you need to implement are the setField(), completedWrapper(), and getLocationOfObjectAsVector3d() methods.

SparseFieldPortrayal3D presently takes the TransformGroups of the models of its children and wraps them into BranchGroups so that they can be removed and added dynamically.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class sim.portrayal.FieldPortrayal
FieldPortrayal.CustomInspector
 
Field Summary
 
Fields inherited from class sim.portrayal3d.FieldPortrayal3D
field, immutableField
 
Fields inherited from class sim.portrayal.FieldPortrayal
classPortrayals, portrayalForAll, portrayalForNull, portrayalForRemainder, portrayals
 
Constructor Summary
SparseFieldPortrayal3D()
           
 
Method Summary
 javax.media.j3d.TransformGroup createModel()
          Returns a tree structure of the form InternalTransform[model info].
abstract  javax.vecmath.Vector3d getLocationOfObjectAsVector3d(java.lang.Object location, javax.vecmath.Vector3d putInHere)
          Converts a given location (perhaps a Double3D, Double2D, Int3D, or Int2D) into a Vector3d, placing it in the given Vector3d, and returning that Vector3d.
protected  javax.media.j3d.BranchGroup insertModelForNewObject(java.lang.Object o, javax.media.j3d.Transform3D localT)
          This function is called from createModel for each object in the field and from the updateModel part of getModel for the new objects.
 void updateModel(javax.media.j3d.TransformGroup globalTG)
          Returns a tree structure of the form InternalTransform[model info].
 
Methods inherited from class sim.portrayal3d.FieldPortrayal3D
completedWrapper, getDefaultPortrayal, getDefaultTransform, getField, getModel, getTransform, isImmutableField, polygonAttributes, resetTransform, rotateX, rotateY, rotateZ, scale, scale, setField, setImmutableField, setTransform, transform, translate
 
Methods inherited from class sim.portrayal.FieldPortrayal
getDefaultNullPortrayal, getInspector, getName, getPortrayalForAll, getPortrayalForNull, getPortrayalForObject, getPortrayalForRemainder, setPortrayalForAll, setPortrayalForClass, setPortrayalForNull, setPortrayalForObject, setPortrayalForRemainder, setSelected
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface sim.portrayal.Portrayal
getInspector, getName, setSelected
 

Constructor Detail

SparseFieldPortrayal3D

public SparseFieldPortrayal3D()
Method Detail

getLocationOfObjectAsVector3d

public abstract javax.vecmath.Vector3d getLocationOfObjectAsVector3d(java.lang.Object location,
                                                                     javax.vecmath.Vector3d putInHere)
Converts a given location (perhaps a Double3D, Double2D, Int3D, or Int2D) into a Vector3d, placing it in the given Vector3d, and returning that Vector3d. Double2D and Int2D should convert to a Vector3d with a zero Z value.


createModel

public javax.media.j3d.TransformGroup createModel()
Description copied from class: FieldPortrayal3D
Returns a tree structure of the form InternalTransform[model info].

...where InternalTransform is an identity transformgroup whose transform will be modified elsewhere (create it but don't play with it).

Specified by:
createModel in class FieldPortrayal3D

insertModelForNewObject

protected javax.media.j3d.BranchGroup insertModelForNewObject(java.lang.Object o,
                                                              javax.media.j3d.Transform3D localT)
This function is called from createModel for each object in the field and from the updateModel part of getModel for the new objects.

In order to dynamically add/remove the subtrees associated with children, this function wraps their TransformGroups into BranchGroups.


updateModel

public void updateModel(javax.media.j3d.TransformGroup globalTG)
Description copied from class: FieldPortrayal3D
Returns a tree structure of the form InternalTransform[model info].

...where InternalTransform is an identity transformgroup whose transform will be modified elsewhere (don't play with it). By default, this function does nothing. Override it to update the model when it's called.

Overrides:
updateModel in class FieldPortrayal3D