sim.portrayal.geo
Class GeomVectorFieldPortrayal

java.lang.Object
  extended by sim.portrayal.FieldPortrayal
      extended by sim.portrayal.FieldPortrayal2D
          extended by sim.portrayal.geo.GeomVectorFieldPortrayal
All Implemented Interfaces:
java.io.Serializable, sim.portrayal.Portrayal, sim.portrayal.Portrayal2D

public class GeomVectorFieldPortrayal
extends sim.portrayal.FieldPortrayal2D

Portrayal for MasonGeometry objects. The portrayal handles drawing and hit-testing (for inspectors).

GeomVectorFieldPortrayal overrides getPortrayalForObject to do a different thing than normal FieldPortrayals. Specifically:

  1. The object passed in is expected to be a MasonGeometry. From this we extract USER, the MASON user data of the geometry, and GEOMETRY, the JTS Geometry object.
  2. If there is a portrayalForAll, return it.
  3. If user exists and is a Portrayal, return user as the Portrayal.
  4. If a portrayal is registered for user, return it.
  5. If a portrayal is registered for geometry, return it.
  6. If a portrayal is registered for user's class, return it.
  7. If a portrayal is registered for the geometry's class, return it.
  8. If there is a portrayalForRemainder, return it.
  9. Else return the getDefaultPortrayal

Note that nowhere do we return portrayals for null objects: there is no PortrayalForNull and no DefaultNullPortrayal. Indeed, the method setPortrayalForNull will throw an error -- you are not permitted to call it.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class sim.portrayal.FieldPortrayal2D
DEFAULT, DONT_USE_BUFFER, USE_BUFFER
 
Fields inherited from class sim.portrayal.FieldPortrayal
classPortrayals, field, immutableField, portrayalForAll, portrayalForNonNull, portrayalForNull, portrayalForRemainder, portrayals
 
Constructor Summary
GeomVectorFieldPortrayal()
          Default constructor
GeomVectorFieldPortrayal(boolean immutableField)
          Constructor which sets the field's immutable flag
 
Method Summary
 sim.portrayal.Portrayal getDefaultPortrayal()
          Return the underlying portrayal
 sim.portrayal.Portrayal getPortrayalForObject(java.lang.Object obj)
          Returns the appropriate Portrayal.
protected  void hitOrDraw(java.awt.Graphics2D graphics, sim.portrayal.DrawInfo2D info, sim.util.Bag putInHere)
          Handles hit-testing and drawing of the underlying geometry objects.
 void setField(java.lang.Object field)
          Sets the underlying field, after ensuring its a GeomVectorField.
 void setPortrayalForNull(sim.portrayal.Portrayal portrayal)
          Throws an exception.
 boolean setSelected(sim.portrayal.LocationWrapper wrapper, boolean selected)
           
 
Methods inherited from class sim.portrayal.FieldPortrayal2D
draw, getBuffering, getClipLocation, getLocationPosition, getObjectLocation, getObjectPosition, getPositionLocation, getRelativeObjectPosition, getScale, hitObjects, setBuffering, setObjectPosition
 
Methods inherited from class sim.portrayal.FieldPortrayal
getDefaultNullPortrayal, getField, getInspector, getName, getPortrayalForAll, getPortrayalForNonNull, getPortrayalForNull, getPortrayalForRemainder, getStatus, isDirtyField, isImmutableField, reset, setDirtyField, setImmutableField, setPortrayalForAll, setPortrayalForClass, setPortrayalForNonNull, 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, getStatus
 

Constructor Detail

GeomVectorFieldPortrayal

public GeomVectorFieldPortrayal()
Default constructor


GeomVectorFieldPortrayal

public GeomVectorFieldPortrayal(boolean immutableField)
Constructor which sets the field's immutable flag

Method Detail

setPortrayalForNull

public void setPortrayalForNull(sim.portrayal.Portrayal portrayal)
Throws an exception. Do not call this method.

Overrides:
setPortrayalForNull in class sim.portrayal.FieldPortrayal

getPortrayalForObject

public sim.portrayal.Portrayal getPortrayalForObject(java.lang.Object obj)
Returns the appropriate Portrayal. See the class header for more information on the implementation of this method.

Overrides:
getPortrayalForObject in class sim.portrayal.FieldPortrayal

getDefaultPortrayal

public sim.portrayal.Portrayal getDefaultPortrayal()
Return the underlying portrayal

Overrides:
getDefaultPortrayal in class sim.portrayal.FieldPortrayal2D

hitOrDraw

protected void hitOrDraw(java.awt.Graphics2D graphics,
                         sim.portrayal.DrawInfo2D info,
                         sim.util.Bag putInHere)
Handles hit-testing and drawing of the underlying geometry objects.

Overrides:
hitOrDraw in class sim.portrayal.FieldPortrayal2D

setField

public void setField(java.lang.Object field)
Sets the underlying field, after ensuring its a GeomVectorField.

Overrides:
setField in class sim.portrayal.FieldPortrayal

setSelected

public boolean setSelected(sim.portrayal.LocationWrapper wrapper,
                           boolean selected)
Specified by:
setSelected in interface sim.portrayal.Portrayal
Overrides:
setSelected in class sim.portrayal.FieldPortrayal