sim.portrayal3d.grid
Class ValueGrid2DPortrayal3D

java.lang.Object
  extended bysim.portrayal.FieldPortrayal
      extended bysim.portrayal3d.FieldPortrayal3D
          extended bysim.portrayal3d.grid.ValueGrid2DPortrayal3D
All Implemented Interfaces:
Portrayal, Portrayal3D, java.io.Serializable

public class ValueGrid2DPortrayal3D
extends FieldPortrayal3D

Displays ValueGrid2Ds values along the XY grid using a surface. The kind of surface is defined by the underlying Portrayal used for the objects, which must be a subclass of QuadPortrayal. Presently there are two kinds of surfaces: TilePortrayal and MeshPortrayal. TilePortrayal draws values as square regions on the surface. MeshPortrayal draws values as the intersections of square regions. This distinction is important because QuadPortrayals may additionally specify a scale which determines how "high" on the Z dimension the QuadPortrayal is drawn to reflect its underlying value. Thus MeshPortrayals look like landscapes, and TilePortrayals look like space-age stairs. QuadPortrayals can also change color to reflect their underlying values, and scale is often 0 by default.

ValueGrid2DPortrayal3Ds can also be wrapped with an opaque image which obscures any colors, and can be set to have some degree of overall transparency (but not the two in combination). Images will be squished to fit just within the field space.

ValueGrid2DPortrayal3Ds do not allow you to specify transparency on a per-gridpoint basis unfortunately. This is due to a lack of this feature in Java3D. Sorry abut that. You can change the colors from gridpoint to gridpoint, but you can't change the transparency from gridpoint to gridpoint.

Bug in MeshPortrayal. It appears that if values in MeshPortrayals cause "bends" in the angle of the underlying squares that are too severe (we've seen over 45 degrees), then when Java3D tries to pick the square you've double-clicked on, the "bent" squares will insist on being included in the pick collection. We believe this to be a bug in Sun's Java3D code. You'll see this happen when you double-click on a MeshPortrayal and the wrong-coordinate object pops up.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class sim.portrayal.FieldPortrayal
FieldPortrayal.CustomInspector
 
Field Summary
 Grid2D field
           
 java.awt.Image image
           
protected  javax.media.j3d.Transform3D tmpLocalT
          tmp Transform3D it is reused, since the TGs are copying it internally
protected  javax.vecmath.Vector3d tmpVect
          tmp Vector3d
 float transparency
          Non-image transparency: 1.0f is fully opaque, 0.0f is fully transparent.
 java.lang.String valueName
           
 
Fields inherited from class sim.portrayal3d.FieldPortrayal3D
immutableField
 
Fields inherited from class sim.portrayal.FieldPortrayal
classPortrayals, portrayalForAll, portrayalForNull, portrayalForRemainder, portrayals
 
Constructor Summary
ValueGrid2DPortrayal3D()
           
ValueGrid2DPortrayal3D(java.lang.String valueName)
          Be completely opaque
ValueGrid2DPortrayal3D(java.lang.String valueName, float transparency)
          Be somewhat transparent (1.0 is fully opaque, 0.0f is fully transparent).
ValueGrid2DPortrayal3D(java.lang.String valueName, java.awt.Image image)
          Use a fully opaque image as the appearance.
 
Method Summary
 LocationWrapper completedWrapper(LocationWrapper w, com.sun.j3d.utils.picking.PickIntersection pi)
          Given the provided PickIntersection, fill in w the location of the picked object, and return it.
 javax.media.j3d.TransformGroup createModel()
          Format is:
 Portrayal getDefaultPortrayal()
          Should return a portrayal which can portray any object regardless of whether it's valid or not
 java.lang.Object getField()
          Returns the current field.
 java.lang.String getValueName()
           
 double newValue(int x, int y, double value)
          This method is called by the default inspector to filter new values set by the user.
 javax.media.j3d.PolygonAttributes polygonAttributes()
          Provides a PolygonAttributes which can be modified to change the underlying model's attributes (culling, vertex versus point versus fill).
 void setField(java.lang.Object grid)
          Attaches the field portrayal to the given field.
 void setImage(java.awt.Image image)
          Set the appearance to a fully opaque image.
 void setTransparency(float transparency)
          Sets non-image transparency: 1.0f is fully opaque, 0.0f is fully transparent.
 void updateModel(javax.media.j3d.TransformGroup modelTG)
          Returns a tree structure of the form InternalTransform[model info].
 
Methods inherited from class sim.portrayal3d.FieldPortrayal3D
getDefaultTransform, getModel, getTransform, isImmutableField, resetTransform, rotateX, rotateY, rotateZ, scale, scale, 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
 

Field Detail

field

public Grid2D field

image

public java.awt.Image image

transparency

public float transparency
Non-image transparency: 1.0f is fully opaque, 0.0f is fully transparent.


valueName

public java.lang.String valueName

tmpVect

protected javax.vecmath.Vector3d tmpVect
tmp Vector3d


tmpLocalT

protected javax.media.j3d.Transform3D tmpLocalT
tmp Transform3D it is reused, since the TGs are copying it internally

Constructor Detail

ValueGrid2DPortrayal3D

public ValueGrid2DPortrayal3D(java.lang.String valueName,
                              java.awt.Image image)
Use a fully opaque image as the appearance.


ValueGrid2DPortrayal3D

public ValueGrid2DPortrayal3D(java.lang.String valueName,
                              float transparency)
Be somewhat transparent (1.0 is fully opaque, 0.0f is fully transparent).


ValueGrid2DPortrayal3D

public ValueGrid2DPortrayal3D(java.lang.String valueName)
Be completely opaque


ValueGrid2DPortrayal3D

public ValueGrid2DPortrayal3D()
Method Detail

getField

public java.lang.Object getField()
Description copied from class: FieldPortrayal
Returns the current field.

Overrides:
getField in class FieldPortrayal3D

getValueName

public java.lang.String getValueName()

setTransparency

public void setTransparency(float transparency)
Sets non-image transparency: 1.0f is fully opaque, 0.0f is fully transparent.


setImage

public void setImage(java.awt.Image image)
Set the appearance to a fully opaque image. If image is null, then removes any image.


polygonAttributes

public javax.media.j3d.PolygonAttributes polygonAttributes()
Description copied from interface: Portrayal3D
Provides a PolygonAttributes which can be modified to change the underlying model's attributes (culling, vertex versus point versus fill). This is an optional function: you are free to return null

Specified by:
polygonAttributes in interface Portrayal3D
Overrides:
polygonAttributes in class FieldPortrayal3D

getDefaultPortrayal

public Portrayal getDefaultPortrayal()
Description copied from class: FieldPortrayal
Should return a portrayal which can portray any object regardless of whether it's valid or not

Overrides:
getDefaultPortrayal in class FieldPortrayal3D

setField

public void setField(java.lang.Object grid)
Description copied from class: FieldPortrayal
Attaches the field portrayal to the given field. Should throw an exception if the object is invalid.

Specified by:
setField in class FieldPortrayal3D

createModel

public javax.media.j3d.TransformGroup createModel()
Format is:

Specified by:
createModel in class FieldPortrayal3D

updateModel

public void updateModel(javax.media.j3d.TransformGroup modelTG)
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

newValue

public double newValue(int x,
                       int y,
                       double value)
This method is called by the default inspector to filter new values set by the user. You should return the "corrected" value if the given value is invalid. The default version of this method bases values on the values passed into the setLevels() and setColorTable() methods.


completedWrapper

public LocationWrapper completedWrapper(LocationWrapper w,
                                        com.sun.j3d.utils.picking.PickIntersection pi)
Description copied from class: FieldPortrayal3D
Given the provided PickIntersection, fill in w the location of the picked object, and return it. Alternatively, return a new LocationWrapper with all information filled in.

Specified by:
completedWrapper in class FieldPortrayal3D