## com.bbn.openmap.omGraphics
Interface OMGeometry

All Known Implementing Classes:
  BasicGeometry, OMGraphic, PolygonGeometry, PolylineGeometry

public interface OMGeometry

Base class of OpenMap OMGraphics geometry.

The geometry classes are intended to pull the object location data out of the OMGraphics. If you have a bunch of OMGraphics that are all rendered with common attributes, you can create a bunch of OMGeometry objects to plavce in a OMGeometryList that will render them all alike.

See Also:
  `OMGeometryList`, `Projection`

Method Summary
`void` `clearAttributes()` Clear attributes from the OMGeometry.
`boolean` `contains(int x, int y)` Answsers the question whether or not the OMGeometry contains the given pixel point.
`void` `deselect()` Let the geometry object know that it is not selected.
`float` `distance(int x, int y)` Return the shortest distance from the graphic to an XY-point.
`void` `draw(java.awt.Graphics g)` Paint the graphic, as an outlined shape.
`void` `fill(java.awt.Graphics g)` Paint the graphic, as a filled shape.
`boolean` `generate(Projection proj)` Prepare the geometry for rendering.
`java.lang.Object` `getAppObject()` Gets the application's object pointer.
`java.lang.Object` `getAttribute(java.lang.Object key)` Get an attribute from an OMGeometry.
`java.util.Map` `getAttributes()` Get all attributes from the OMGeometry.
`int` `getLineType()` Return the line type.
`boolean` `getNeedToRegenerate()` Return the regeneration status.
`int` `getRenderType()` Return the render type.
`java.awt.geom.GeneralPath` `getShape()` Get the java.awt.Shape object that represents the projected graphic.
`boolean` `isRenderable()`
`boolean` `isVisible()` Get the visibility variable.
`void` `putAttribute(java.lang.Object key, java.lang.Object value)` Set an attribute in an OMGeometry.
`boolean` `regenerate(Projection proj)` Invoke this to regenerate a "dirty" graphic.
`java.lang.Object` `removeAttribute(java.lang.Object key)` Remove an attribute from the OMGeometry.
`void` `select()` Let the geometry object know that it is selected.
`void` `setAppObject(java.lang.Object obj)` Holds an application specific object for later access.
`void` `setAttributes(java.util.Map attributes)` Set all attributes on the OMGeometry.
`void` `setLineType(int value)` Set the line type for the graphic, which will affect how the lines will be drawn.
`void` `setNeedToRegenerate(boolean value)` Sets the regenerate flag for the graphic.
`void` `setShape(java.awt.geom.GeneralPath gp)` Set the java.awt.Shape object that represents the projected graphic.
`void` `setVisible(boolean visible)` Set the visibility variable.

Method Detail

### setLineType

    public void setLineType(int value)

  Set the line type for the graphic, which will affect how the lines will be drawn. See the definition of the lineType parameter. Accepts LINETYPE_RHUMB, LINETYPE_STRAIGHT and LINETYPE_GREATCIRCLE. Any weird values get set to LINETYPE_STRAIGHT.

  Parameters:
    `value` - the line type of the graphic.

### getLineType

    public int getLineType()

  Return the line type.

  Returns:
    the linetype - LINETYPE_RHUMB, LINETYPE_STRAIGHT, LINETYPE_GREATCIRCLE or LINETYPE_UNKNOWN.

### getRenderType

    public int getRenderType()

  Return the render type.

  Returns:
    the rendertype of the object - RENDERTYPE_LATLON, RENDERTYPE_XY, RENDERTYPE_OFFSET and RENDERTYPE_UNKNOWN.

### setNeedToRegenerate

    public void setNeedToRegenerate(boolean value)

  Sets the regenerate flag for the graphic. This flag is used to determine if extra work needs to be done to prepare the object for rendering.

  Parameters:
    `value` - boolean

### getNeedToRegenerate

    public boolean getNeedToRegenerate()

  Return the regeneration status.

  Returns:
    boolean

### setVisible

    public void setVisible(boolean visible)

  Set the visibility variable. NOTE:
  This is checked by the OMGeometryList when it iterates through its list for render and gesturing. It is not checked by the internal OMGeometry methods, although maybe it should be...

  Parameters:
    `visible` - boolean

### isVisible

    public boolean isVisible()

  Get the visibility variable.

  Returns:
    boolean

### select

    public void select()

  Let the geometry object know that it is selected. No action mandated.

### deselect

    public void deselect()

  Let the geometry object know that it is not selected. No action mandated.

### setAppObject

    public void setAppObject(java.lang.Object obj)

  Holds an application specific object for later access. This can be used to associate an application object with an OMGeometry for later retrieval. For instance, when the graphic is clicked on, the application gets the OMGeometry object back from the OMGeometryList, and can then get back to the application level object through this pointer.

  Parameters:
    `obj` - Object

### getAppObject

    public java.lang.Object getAppObject()

  Gets the application's object pointer.

  Returns:
    Object

### putAttribute

    public void putAttribute(java.lang.Object key,
                             java.lang.Object value)

  Set an attribute in an OMGeometry.

### getAttribute

    public java.lang.Object getAttribute(java.lang.Object key)

  Get an attribute from an OMGeometry.

### removeAttribute

    public java.lang.Object removeAttribute(java.lang.Object key)

  Remove an attribute from the OMGeometry.

### clearAttributes

    public void clearAttributes()

  Clear attributes from the OMGeometry.

### setAttributes

    public void setAttributes(java.util.Map attributes)

  Set all attributes on the OMGeometry.

### getAttributes

    public java.util.Map getAttributes()

  Get all attributes from the OMGeometry.

### generate

    public boolean generate(Projection proj)

  Prepare the geometry for rendering. This must be done before calling `render()`! If a vector graphic has lat-lon components, then we project these vertices into x-y space. For raster graphics we prepare in a different fashion.

  If the generate is unsuccessful, it's usually because of some oversight, (for instance if `proj` is null), and if debugging is enabled, a message may be output to the controlling terminal.

  Parameters:
    `proj` - Projection
  Returns:
    boolean true if successful, false if not.
  See Also:
    `regenerate(com.bbn.openmap.proj.Projection)`

### isRenderable

    public boolean isRenderable()

### fill

    public void fill(java.awt.Graphics g)

  Paint the graphic, as a filled shape.

  This paints the graphic into the Graphics context. This is similar to `paint()` function of java.awt.Components. Note that if the graphic has not been generated or if it isn't visible, it will not be rendered.

  This method used to be abstract, but with the conversion of OMGeometrys to internally represent themselves as java.awt.Shape objects, it's a more generic method. If the OMGeometry hasn't been updated to use Shape objects, it should have its own render method.

  Parameters:
    `g` - Graphics2D context to render into.

### draw

    public void draw(java.awt.Graphics g)

  Paint the graphic, as an outlined shape.

  This paints the graphic into the Graphics context. This is similar to `paint()` function of java.awt.Components. Note that if the graphic has not been generated or if it isn't visible, it will not be rendered.

  This method used to be abstract, but with the conversion of OMGeometrys to internally represent themselves as java.awt.Shape objects, it's a more generic method. If the OMGeometry hasn't been updated to use Shape objects, it should have its own render method.

  Parameters:
    `g` - Graphics2D context to render into.

### distance

    public float distance(int x,
                          int y)

  Return the shortest distance from the graphic to an XY-point.

  This method used to be abstract, but with the conversion of OMGeometrys to internally represent themselves as java.awt.Shape objects, it's a more generic method. If the OMGeometry hasn't been updated to use Shape objects, it should have its own distance method.

  Parameters:
    `x` - X coordinate of the point.
    `y` - Y coordinate of the point.
  Returns:
    float distance, in pixels, from graphic to the point. Returns Float.POSITIVE_INFINITY if the graphic isn't ready (ungenerated).

### contains

    public boolean contains(int x,
                            int y)

  Answsers the question whether or not the OMGeometry contains the given pixel point.

  This method used to be abstract, but with the conversion of OMGeometrys to internally represent themselves as java.awt.Shape objects, it's a more generic method. If the OMGeometry hasn't been updated to use Shape objects, it should have its own contains method.

  This method duplicates a java.awt.Shape method, with some protection wrapped around it. If you have other queries for the internal Shape object, just ask for it and then ask it directly. This method is provided because it is the most useful, used when determining if a mouse event is occuring over an object on the map.

  Parameters:
    `x` - X pixel coordinate of the point.
    `y` - Y pixel coordinate of the point.
  Returns:
    getShape().contains(x, y), false if the OMGraphic hasn't been generated yet.

### regenerate

    public boolean regenerate(Projection proj)

  Invoke this to regenerate a "dirty" graphic. This method is a wrapper around the `generate()` method. It invokes `generate()` only if needToRegenerate() on the graphic returns true. To force a graphic to be generated, call `generate()` directly.

  Parameters:
    `proj` - the Projection
  Returns:
    true if generated, false if didn't do it (maybe a problem).
  See Also:
    `generate(com.bbn.openmap.proj.Projection)`

### getShape

    public java.awt.geom.GeneralPath getShape()

  Get the java.awt.Shape object that represents the projected graphic.

  The java.awt.Shape object gives you the ability to do a little spatial analysis on the graphics.

  Returns:
    java.awt.geom.GeneralPath (Shape), or null if the graphic needs to be generated with the current map projection, or null if the OMGeometry hasn't been updated to use Shape objects for its internal representation.

### setShape

    public void setShape(java.awt.geom.GeneralPath gp)

  Set the java.awt.Shape object that represents the projected graphic. Ideally, the OMGeometry will set this internally. This method is provided to clear out the object to save memory, or to allow manipulations if the situation dictates.

  The java.awt.Shape object gives you the ability to do a little spatial analysis on the graphics.

  Parameters:
    `gp` - java.awt.geom.GeneralPath (Shape), or null if the graphic needs to be cleared or regenerated.

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