Class GeomVectorFieldPortrayal

  extended by sim.portrayal.FieldPortrayal
      extended by sim.portrayal.FieldPortrayal2D
          extended by sim.portrayal.geo.GeomVectorFieldPortrayal
All Implemented Interfaces:, 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
Fields inherited from class sim.portrayal.FieldPortrayal
classPortrayals, field, immutableField, portrayalForAll, portrayalForNonNull, portrayalForNull, portrayalForRemainder, portrayals
Constructor Summary
          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


public GeomVectorFieldPortrayal()
Default constructor


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

Method Detail


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

setPortrayalForNull in class sim.portrayal.FieldPortrayal


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.

getPortrayalForObject in class sim.portrayal.FieldPortrayal


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

getDefaultPortrayal in class sim.portrayal.FieldPortrayal2D


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.

hitOrDraw in class sim.portrayal.FieldPortrayal2D


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

setField in class sim.portrayal.FieldPortrayal


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