## com.bbn.openmap.omGraphics
Class OMGraphicHash

    java.lang.Object
      com.bbn.openmap.omGraphics.geom.BasicGeometry
          com.bbn.openmap.omGraphics.OMGraphic
              com.bbn.openmap.omGraphics.OMGraphicList
                  com.bbn.openmap.omGraphics.OMGraphicHash

All Implemented Interfaces:
  java.lang.Cloneable, GraphicList, java.util.Map, OMGeometry, OMGraphicConstants, java.io.Serializable

public class OMGraphicHash
extends OMGraphicList
implements java.util.Map

This is an OMGraphicsList cub-class with a Map interface. Access is backed by a HashMap. Insertion and removal of OMGraphics is through the Map interface.

The add(OMGraphic), addOMGraphic(OMGraphic), remove(OMGraphic), and removeOMGraphicAt(int) method are disabled and will throw a RuntimeException if called.

This class is suited for use as the top OMGraphicList in an OMHandlerLayer that has a large number of OMGraphic objects and needs to access those objects using a unique key.

Author:
  David J. Ward
See Also:
  `OMGraphicList`, Serialized Form

Nested Class Summary

Nested classes inherited from class com.bbn.openmap.omGraphics.OMGraphicList
`OMGraphicList.OMDist`

Nested classes inherited from class java.util.Map
`java.util.Map.Entry`

Field Summary

Fields inherited from class com.bbn.openmap.omGraphics.OMGraphicList
`allowDuplicates, FIRST_ADDED_ON_TOP, graphics, LAST_ADDED_ON_TOP, NONE, processAllGeometries, traverseMode, vague`

Fields inherited from class com.bbn.openmap.omGraphics.OMGraphic
`declutterType, displayPaint, edgeMatchesFill, fillPaint, hasLabel, linePaint, matted, mattingPaint, renderType, selected, selectPaint, showEditablePalette, stroke, textureMask`

Fields inherited from class com.bbn.openmap.omGraphics.geom.BasicGeometry
`APP_OBJECT_KEY, appObject, ATT_MAP_KEY, lineType, needToRegenerate, shape, visible`

Fields inherited from interface com.bbn.openmap.omGraphics.OMGraphicConstants

`ADD_GRAPHIC_MASK, BASIC_STROKE, CHANGE_APPEARANCE, clear, DECIMAL_DEGREES, DECLUTTERTYPE_LINE, DECLUTTERTYPE_MOVE, DECLUTTERTYPE_NONE, DECLUTTERTYPE_SPACE, DEFAULT_ROTATIONANGLE, DELETE_GRAPHIC_MASK, DESELECT_GRAPHIC_MASK, DESELECTALL_GRAPHIC_MASK, GRAPHICTYPE_ARC, GRAPHICTYPE_BITMAP, GRAPHICTYPE_CIRCLE, GRAPHICTYPE_ELLIPSE, GRAPHICTYPE_GRAPHIC, GRAPHICTYPE_GRID, GRAPHICTYPE_LINE, GRAPHICTYPE_POINT, GRAPHICTYPE_POLY, GRAPHICTYPE_RASTER, GRAPHICTYPE_RECTANGLE, GRAPHICTYPE_TEXT, INFOLINE, LABEL, LINETYPE_GREATCIRCLE, LINETYPE_RHUMB, LINETYPE_STRAIGHT, LINETYPE_UNKNOWN, LOWER_GRAPHIC_MASK, LOWER_TO_BOTTOM_GRAPHIC_MASK, RADIANS, RAISE_GRAPHIC_MASK, RAISE_TO_TOP_GRAPHIC_MASK, REMOVABLE, RENDERTYPE_LATLON, RENDERTYPE_OFFSET, RENDERTYPE_UNKNOWN, RENDERTYPE_XY, SELECT_GRAPHIC_MASK, SORT_GRAPHICS_MASK, TOOLTIP, UPDATE_GRAPHIC_MASK`

Constructor Summary
`OMGraphicHash()` Creates a new instance of OMGraphicHash
`OMGraphicHash(int initialCapacity)` Construct an OMGraphicList with an initial capacity.

Method Summary
`void` `add(OMGraphic g)` Add an OMGraphic to the list.
`void` `addOMGraphic(OMGraphic g)` Add an OMGraphic to the GraphicList.
`void` `clear()` Remove all elements from the graphic list.
`java.lang.Object` `clone()` Generic return of SinkGraphic for subclasses that don't implement clone properly for some reason.
`boolean` `containsKey(java.lang.Object obj)` Returns `true` if this map contains a mapping for the specified key.
`boolean` `containsValue(java.lang.Object obj)` Returns `true` if this map maps one or more keys to the specified value.
`java.util.Set` `entrySet()` Returns a set view of the mappings contained in this map.
`java.lang.Object` `get(java.lang.Object obj)` Returns the value to which this map maps the specified key.
`java.util.Set` `keySet()` Returns a set view of the keys contained in this map.
`java.lang.Object` `put(java.lang.Object key, java.lang.Object graphic)` Associates the specified value with the specified key in this map (optional operation).
`void` `putAll(java.util.Map map)` Copies all of the mappings from the specified map to this map (optional operation).
`java.lang.Object` `remove(java.lang.Object obj)` Removes the mapping for this key from this map if it is present (optional operation).
`boolean` `remove(OMGraphic graphic)` Remove the graphic.
`void` `removeOMGraphicAt(int location)` Remove the graphic at the location number.
`java.util.Collection` `values()` Returns a collection view of the values contained in this map.

Methods inherited from class com.bbn.openmap.omGraphics.OMGraphicList

`_add, _doAction, _findClosest, _findClosest, _getAt, _getContains, _getWithAppObject, _indexOf, _insert, _remove, _remove, _selectClosest, _setAt, checkForDuplicate, contains, deselect, deselectAll, distance, doAction, findAll, findAll, findAllTest, findClosest, findClosest, findClosestTest, findIndexOfClosest, findIndexOfClosest, generate, generate, getAllowDuplicates, getDescription, getDescription, getOMGraphicAt, getOMGraphicThatContains, getOMGraphicWithAppObject, getProcessAllGeometries, getTargets, getTraverseMode, indexOf, insertOMGraphicAt, isEmpty, isVague, isVisible, iterator, moveIndexedOneToBack, moveIndexedOneToBottom, moveIndexedOneToFront, moveIndexedOneToTop, moveIndexedToBottom, moveIndexedToFirst, moveIndexedToLast, moveIndexedToTop, objectToOMGraphic, project, project, readGraphics, readGraphics, render, renderAllAsSelected, select, selectAll, selectClosest, selectClosest, selectClosestTest, setAllowDuplicates, setFillPaint, setGridGenerator, setLinePaint, setMatted, setMattingPaint, setOMGraphicAt, setProcessAllGeometries, setSelectPaint, setStroke, setTargets, setTextureMask, setTraverseMode, setVague, setVisible, shouldProcess, size, sort, writeGraphics, writeGraphics`

Methods inherited from class com.bbn.openmap.omGraphics.OMGraphic

`getDeclutterType, getDisplayColor, getDisplayPaint, getEdgeMatchesFill, getFillColor, getFillPaint, getHasLabel, getLineColor, getLinePaint, getMattingPaint, getRenderType, getSelectColor, getSelectPaint, getShowEditablePalette, getStroke, getTextureMask, hasLineTypeChoice, initLabelingDuringGenerate, isClear, isMatted, isSelected, normalizeDistanceForLineWidth, regenerate, renderLabel, setDeclutterType, setEdgeMatchesFill, setFillColor, setGraphicsColor, setGraphicsForEdge, setGraphicsForFill, setHasLabel, setLabelLocation, setLabelLocation, setLabelLocation, setLineColor, setRenderType, setSelectColor, setSelected, setShape, setShowEditablePalette, shouldRenderEdge, shouldRenderFill`

Methods inherited from class com.bbn.openmap.omGraphics.geom.BasicGeometry

`_distance, appendShapeEdge, appendShapeEdge, appendShapeEdge, appendShapeEdge, checkAttributeMap, checkAttributeMap, clearAttributes, contains, createAttributeMap, createBoxShape, createShape, createShape, describeShapeDetail, describeShapeDetail, distanceToEdge, draw, fill, getAppObject, getAppObject, getAttribute, getAttributeMap, getAttributes, getLineType, getNeedToRegenerate, getShape, isRenderable, putAttribute, removeAttribute, replaceAppObjectWithAttributeMap, setAppObject, setAppObject, setAttributes, setLineType, setNeedToRegenerate`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface java.util.Map
`equals, hashCode, isEmpty, size`

Methods inherited from interface com.bbn.openmap.omGraphics.OMGeometry
`clearAttributes, contains, draw, fill, getAppObject, getAttribute, getAttributes, getLineType, getNeedToRegenerate, getShape, isRenderable, putAttribute, removeAttribute, setAppObject, setAttributes, setLineType, setNeedToRegenerate`

Constructor Detail

### OMGraphicHash

    public OMGraphicHash()

  Creates a new instance of OMGraphicHash

### OMGraphicHash

    public OMGraphicHash(int initialCapacity)

  Construct an OMGraphicList with an initial capacity.

Parameters:
  `initialCapacity` - the initial capacity of the list

Method Detail

### get

    public java.lang.Object get(java.lang.Object obj)

  Returns the value to which this map maps the specified key. Returns `null` if the map contains no mapping for this key. A return value of `null` does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to `null`. The `containsKey` operation may be used to distinguish these two cases.

  More formally, if this map contains a mapping from a key `k` to a value `v` such that `(key==null ? k==null : key.equals(k))`, then this method returns `v`; otherwise it returns `null`. (There can be at most one such mapping.)

  Specified by:
    `get` in interface `java.util.Map`
  Returns:
    the value to which this map maps the specified key, or `null` if the map contains no mapping for this key.
  Throws:
    `java.lang.ClassCastException` - if the key is of an inappropriate type for this map (optional).
    `java.lang.NullPointerException` - if the key is `null` and this map does not permit `null` keys (optional).
  See Also:
    `containsKey(Object)`

### containsKey

    public boolean containsKey(java.lang.Object obj)

  Returns `true` if this map contains a mapping for the specified key. More formally, returns `true` if and only if this map contains a mapping for a key `k` such that `(key==null ? k==null : key.equals(k))`. (There can be at most one such mapping.)

  Specified by:
    `containsKey` in interface `java.util.Map`
  Returns:
    `true` if this map contains a mapping for the specified key.
  Throws:
    `java.lang.ClassCastException` - if the key is of an inappropriate type for this map (optional).
    `java.lang.NullPointerException` - if the key is `null` and this map does not permit `null` keys (optional).

### containsValue

    public boolean containsValue(java.lang.Object obj)

  Returns `true` if this map maps one or more keys to the specified value. More formally, returns `true` if and only if this map contains at least one mapping to a value `v` such that `(value==null ? v==null : value.equals(v))`. This operation will probably require time linear in the map size for most implementations of the `Map` interface.

  Specified by:
    `containsValue` in interface `java.util.Map`
  Returns:
    `true` if this map maps one or more keys to the specified value.
  Throws:
    `java.lang.ClassCastException` - if the value is of an inappropriate type for this map (optional).
    `java.lang.NullPointerException` - if the value is `null` and this map does not permit `null` values (optional).

### entrySet

    public java.util.Set entrySet()

  Returns a set view of the mappings contained in this map. Each element in the returned set is a `Map.Entry`. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own `remove` operation, or through the `setValue` operation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the `Iterator.remove`, `Set.remove`, `removeAll`, `retainAll` and `clear` operations. It does not support the `add` or `addAll` operations.

  Specified by:
    `entrySet` in interface `java.util.Map`
  Returns:
    a set view of the mappings contained in this map.

### keySet

    public java.util.Set keySet()

  Returns a set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own `remove` operation), the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the `Iterator.remove`, `Set.remove`, `removeAll` `retainAll`, and `clear` operations. It does not support the add or `addAll` operations.

  Specified by:
    `keySet` in interface `java.util.Map`
  Returns:
    a set view of the keys contained in this map.

### put

    public java.lang.Object put(java.lang.Object key,
                                java.lang.Object graphic)

  Associates the specified value with the specified key in this map (optional operation). If the map previously contained a mapping for this key, the old value is replaced by the specified value. (A map `m` is said to contain a mapping for a key `k` if and only if `m.containsKey(k)` would return `true`.))

  Specified by:
    `put` in interface `java.util.Map`
  Parameters:
    `key` - key with which the specified value is to be associated.
  Returns:
    previous value associated with specified key, or `null` if there was no mapping for key. A `null` return can also indicate that the map previously associated `null` with the specified key, if the implementation supports `null` values.
  Throws:
    `java.lang.UnsupportedOperationException` - if the `put` operation is not supported by this map.
    `java.lang.ClassCastException` - if the class of the specified key or value prevents it from being stored in this map.
    `java.lang.IllegalArgumentException` - if some aspect of this key or value prevents it from being stored in this map.
    `java.lang.NullPointerException` - if this map does not permit `null` keys or values, and the specified key or value is `null`.

### putAll

    public void putAll(java.util.Map map)

  Copies all of the mappings from the specified map to this map (optional operation). The effect of this call is equivalent to that of calling `put(k, v)` on this map once for each mapping from key `k` to value `v` in the specified map. The behavior of this operation is unspecified if the specified map is modified while the operation is in progress.

  Specified by:
    `putAll` in interface `java.util.Map`
  Throws:
    `java.lang.UnsupportedOperationException` - if the `putAll` method is not supported by this map.
    `java.lang.ClassCastException` - if the class of a key or value in the specified map prevents it from being stored in this map.
    `java.lang.IllegalArgumentException` - some aspect of a key or value in the specified map prevents it from being stored in this map.
    `java.lang.NullPointerException` - if the specified map is `null`, or if this map does not permit `null` keys or values, and the specified map contains `null` keys or values.

### remove

    public java.lang.Object remove(java.lang.Object obj)

  Removes the mapping for this key from this map if it is present (optional operation). More formally, if this map contains a mapping from key `k` to value `v` such that `(key==null ? k==null : key.equals(k))`, that mapping is removed. (The map can contain at most one such mapping.)

  Returns the value to which the map previously associated the key, or `null` if the map contained no mapping for this key. (A `null` return can also indicate that the map previously associated `null` with the specified key if the implementation supports `null` values.) The map will not contain a mapping for the specified key once the call returns.

  Specified by:
    `remove` in interface `java.util.Map`
  Returns:
    previous value associated with specified key, or `null` if there was no mapping for key.
  Throws:
    `java.lang.ClassCastException` - if the key is of an inappropriate type for this map (optional).
    `java.lang.NullPointerException` - if the key is `null` and this map does not permit `null` keys (optional).
    `java.lang.UnsupportedOperationException` - if the `remove` method is not supported by this map.

### values

    public java.util.Collection values()

  Returns a collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. If the map is modified while an iteration over the collection is in progress (except through the iterator's own `remove` operation), the results of the iteration are undefined. The collection supports element removal, which removes the corresponding mapping from the map, via the `Iterator.remove`, `Collection.remove`, `removeAll`, `retainAll` and `clear` operations. It does not support the add or `addAll` operations.

  Specified by:
    `values` in interface `java.util.Map`
  Returns:
    a collection view of the values contained in this map.

### clone

    public java.lang.Object clone()

  Description copied from class: `OMGraphic`
  Generic return of SinkGraphic for subclasses that don't implement clone properly for some reason.

  Overrides:
    `clone` in class `OMGraphicList`
  Returns:
    a duplicate list full of shallow copies of each of the OMGraphics contained on the list.

### addOMGraphic

    public void addOMGraphic(OMGraphic g)

  Add an OMGraphic to the GraphicList. The OMGraphic must not be null.

  For OMGraphicHash this method will throw an `IllegalArgumentException` because adding a graphic must be done through `put(key,value)`.

  Overrides:
    `addOMGraphic` in class `OMGraphicList`
  Parameters:
    `g` - the non-null OMGraphic to add
  Throws:
    `java.lang.IllegalArgumentException` - if OMGraphic is null

### add

    public void add(OMGraphic g)

  Add an OMGraphic to the list.

  For OMGraphicHash this method will throw an `IllegalArgumentException` because adding a graphic must be done through `put(key,value)`.

  Overrides:
    `add` in class `OMGraphicList`

### removeOMGraphicAt

    public void removeOMGraphicAt(int location)

  Remove the graphic at the location number.

  For OMGraphicHash this method will throw an `IllegalArgumentException` because removing a graphic must be done through `remove(key)`.

  Overrides:
    `removeOMGraphicAt` in class `OMGraphicList`
  Parameters:
    `location` - the location of the OMGraphic to remove.

### remove

    public boolean remove(OMGraphic graphic)

  Remove the graphic.

  For OMGraphicHash this method will throw an `IllegalArgumentException` because removing a graphic must be done through `remove(key)`.

  Overrides:
    `remove` in class `OMGraphicList`
  Parameters:
    `graphic` - the OMGraphic object to remove.
  Returns:
    true if graphic was on the list, false if otherwise.

### clear

    public void clear()

  Remove all elements from the graphic list.

  Specified by:
    `clear` in interface `java.util.Map`
  Overrides:
    `clear` in class `OMGraphicList`

Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details