Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## sim.portrayal.grid
Class FastObjectGridPortrayal2D

    java.lang.Object
      sim.portrayal.FieldPortrayal
          sim.portrayal.FieldPortrayal2D
              sim.portrayal.grid.ObjectGridPortrayal2D
                  sim.portrayal.grid.FastObjectGridPortrayal2D

All Implemented Interfaces:
  java.io.Serializable, Portrayal, Portrayal2D

    public class FastObjectGridPortrayal2D

extends ObjectGridPortrayal2D

A "Fast" version of ObjectGridPortrayal2D, which draws objects as rectangles of specified colors, rather than using the provided SimplePortrayal2Ds. FastObjectGridPortrayal2D contains an underlying FastValueGridPortrayal2D. When the field needs to be drawn, it is first mapped into a DoubleGrid2D, using the mapping function `doubleValue(...)` (which you can override to provide specialized behavior). This DoubleGrid2D is then handed to the underlying FastValueGridPortrayal2D to draw with the provided ColorMap.

See Also:
  Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from class sim.portrayal.grid.ObjectGridPortrayal2D
`ObjectGridPortrayal2D.Message`

Nested classes/interfaces inherited from class sim.portrayal.FieldPortrayal
`FieldPortrayal.CustomInspector`

Field Summary

Fields inherited from class sim.portrayal.grid.ObjectGridPortrayal2D
`locationToPass`

Fields inherited from class sim.portrayal.FieldPortrayal2D
`DEFAULT, DONT_USE_BUFFER, USE_BUFFER`

Fields inherited from class sim.portrayal.FieldPortrayal
`classPortrayals, dirtyField, field, immutableField, portrayalForAll, portrayalForNonNull, portrayalForNull, portrayalForRemainder, portrayals`

Constructor Summary
`FastObjectGridPortrayal2D()` Equivalent to FastObjectGridPortrayal2D(false);
`FastObjectGridPortrayal2D(boolean immutableField)` If immutableField is true, we presume that the grid doesn't change.

Method Summary
`double` | `doubleValue(java.lang.Object obj)` Override this as necessary to map the provided object into a double value.
`void` | `draw(java.lang.Object object, java.awt.Graphics2D graphics, DrawInfo2D info)` Draws the field with its origin at [info.draw.x,info.draw.y], relative to the scaled coordinate system defined by [info.draw.width,info.draw.height].
`int` | `getBuffering()` Returns whether or not the FieldPortrayal2D will use a buffering "trick" to draw quickly.
`ColorMap` | `getMap()`
`void` | `reset()` Resets the underlying FastValueGridPortrayal2D.
`void` | `setBuffering(int val)` Sets whether or not the FieldPortrayal2D will use a buffering "trick" to draw quickly.
`void` | `setField(java.lang.Object field)` Sets the field.
`void` | `setImmutableField(boolean immutableField)` Specifies that the underlying field is (or is not) to be assumed unchanging -- thus there's no reason to update once we're created.
`void` | `setMap(ColorMap m)`

Methods inherited from class sim.portrayal.grid.ObjectGridPortrayal2D
`getClipLocation, getDefaultNullPortrayal, getDefaultPortrayal, getLocationPosition, getObjectLocation, getPositionLocation, getScale, getWrapper, hitOrDraw, setSelected`

Methods inherited from class sim.portrayal.FieldPortrayal2D
`getObjectPosition, getRelativeObjectPosition, hitObjects, setObjectPosition`

Methods inherited from class sim.portrayal.FieldPortrayal
`getField, getInspector, getName, getPortrayalForAll, getPortrayalForNonNull, getPortrayalForNull, getPortrayalForObject, getPortrayalForRemainder, getStatus, isImmutableField, setPortrayalForAll, setPortrayalForClass, setPortrayalForNonNull, 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, getStatus`

Constructor Detail

### FastObjectGridPortrayal2D

    public FastObjectGridPortrayal2D(boolean immutableField)

  If immutableField is true, we presume that the grid doesn't change. This allows us to just re-splat the buffer.

### FastObjectGridPortrayal2D

    public FastObjectGridPortrayal2D()

  Equivalent to FastObjectGridPortrayal2D(false);

Method Detail

### setImmutableField

    public void setImmutableField(boolean immutableField)

  Description copied from class: `FieldPortrayal`
  Specifies that the underlying field is (or is not) to be assumed unchanging -- thus there's no reason to update once we're created. Not all FieldPortrayals will care about whether or not a field is immutable. Sets dirtyField to true.

  Overrides:
    `setImmutableField` in class `FieldPortrayal`

### setField

    public void setField(java.lang.Object field)

  Description copied from class: `FieldPortrayal`
  Sets the field. Also sets dirtyField = true. May throw an exception if the field is inappropriate.

  Overrides:
    `setField` in class `ObjectGridPortrayal2D`

### doubleValue

    public double doubleValue(java.lang.Object obj)

  Override this as necessary to map the provided object into a double value. Objects selected from the field will be mapped through this function to double values, which in turn will be passed to an underlying FastValueGridPortrayal2D, which will map them to appropriate colors using the map provided in setMap.

  The default form of this function is:

  1. If the object is null, return 0.
  2. Else if the object is a Number or is sim.util.Valuable, return obj.doubleValue();
  3. Else return 1.

### reset

    public void reset()

  Resets the underlying FastValueGridPortrayal2D.

### getMap

    public ColorMap getMap()

### setMap

    public void setMap(ColorMap m)

### getBuffering

    public int getBuffering()

  Description copied from class: `FieldPortrayal2D`
  Returns whether or not the FieldPortrayal2D will use a buffering "trick" to draw quickly. This optional property is in FieldPortrayal2D but is only taken advantage of by one or two subclasses. Some FieldPortrayal2Ds primarily draw lots of rectangles in a grid. Certain ones can draw this in one of two ways: either by drawing each rectangle separately, or by filling a buffer (an image) with individual points, then stretching the buffer over the area, causing the points to enlarge into rectangles. The second is often faster, especially if given lots of memory (and always faster on Macs regardless). The FieldPortrayal2D's behavior in this regard will depend on the value of the buffering property. The property can take on one of three values: DEFAULT (let the machine decide on its own in a platform-dependent fashion -- the default), USE_BUFFER, or DONT_USE_BUFFER.

  Overrides:
    `getBuffering` in class `FieldPortrayal2D`

### setBuffering

    public void setBuffering(int val)

  Description copied from class: `FieldPortrayal2D`
  Sets whether or not the FieldPortrayal2D will use a buffering "trick" to draw quickly. This optional property is in FieldPortrayal2D but is only taken advantage of by one or two subclasses. Some FieldPortrayal2Ds primarily draw lots of rectangles in a grid. Certain ones can draw this in one of two ways: either by drawing each rectangle separately, or by filling a buffer (an image) with individual points, then stretching the buffer over the area, causing the points to enlarge into rectangles. The second is often faster, especially if given lots of memory (and always faster on Macs regardless). The FieldPortrayal2D's behavior in this regard will depend on the value of the buffering property. The property can take on one of three values: DEFAULT (let the machine decide on its own in a platform-dependent fashion -- the default), USE_BUFFER, or DONT_USE_BUFFER.

  Overrides:
    `setBuffering` in class `FieldPortrayal2D`

### draw

    public void draw(java.lang.Object object,
                     java.awt.Graphics2D graphics,
                     DrawInfo2D info)

  Description copied from class: `FieldPortrayal2D`
  Draws the field with its origin at [info.draw.x,info.draw.y], relative to the scaled coordinate system defined by [info.draw.width,info.draw.height]. The only parts that need be drawn are those which fall within the [info.clip] rectangle. Since your draw and hitObjects methods are likely to be nearly identical, you can choose instead to override the hitOrDraw method to handle both of them. By default this method simply calls hitOrDraw. FieldPortrayals will receive null for the object; they should just draw their own fields.

  Specified by:
    `draw` in interface `Portrayal2D`
  Overrides:
    `draw` in class `FieldPortrayal2D`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD