## com.bbn.openmap.omGraphics
Class OMRect

    java.lang.Object
      com.bbn.openmap.omGraphics.geom.BasicGeometry
          com.bbn.openmap.omGraphics.OMGraphic
              com.bbn.openmap.omGraphics.OMRect

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

Direct Known Subclasses:
  Waypoint.Graphic

public class OMRect
extends OMGraphic
implements java.io.Serializable

Graphic type that lets you draw four-sided polygons that have corners that share coordinates or window points.

### NOTE:

See the RESTRICTIONS on Lat/Lon polygons/polylines which apply to rectangles as well. Not following the guidelines listed may result in ambiguous/undefined shapes! Similar assumptions apply to the other vector graphics that we define: circles, ellipses, polys, lines.

These assumptions are virtually the same as those on the more generic OMPoly graphic type.

See Also:
  `OMPoly`, Serialized Form

Field Summary
`protected float` `lat1` Latitude of first corner, decimal degrees.
`protected float` `lat2` Latitude of second corner, decimal degrees.
`protected float` `lon1` Longitude of first corner, decimal degrees.
`protected float` `lon2` Longitude of second corner, decimal degrees.
`protected int` `nsegs` Number of segments to draw (used only for LINETYPE_GREATCIRCLE or LINETYPE_RHUMB lines).
`protected int` `x1` Horizontal window position of first corner, in pixels from left side of window.
`protected int` `x2` Horizontal window position of second corner, in pixels from left side of window.
`protected int` `y1` Vertical window position of first corner, in pixels from the top of the window.
`protected int` `y2` Vertical window position of second corner, in pixels from the top of the window.

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
`OMRect()` Default constructor, waiting to be filled.
`OMRect(float lt1, float ln1, float lt2, float ln2, int lType)` Create a lat/lon rectangle.
`OMRect(float lt1, float ln1, float lt2, float ln2, int lType, int nsegs)` Create a lat/lon rectangle.
`OMRect(float lt1, float ln1, int px1, int py1, int px2, int py2)` Construct an XY rectangle relative to a lat/lon point (RENDERTYPE_OFFSET).
`OMRect(int px1, int py1, int px2, int py2)` Construct an XY rectangle.

Method Summary
`boolean` `generate(Projection proj)` Prepare the rectangle for rendering.
`int` `getBottom()` Get the bottom of XY rectangle.
`float` `getEastLon()` Get the longitude of the east edge in a LatLon rectangle.
`int` `getLeft()` Get the left of XY rectangle.
`float` `getNorthLat()` Get the latitude of the north edge in a LatLon rectangle.
`int` `getNumSegs()` Get the number of segments of the lat/lon lines.
`int` `getRight()` Get the right of XY rectangle.
`float` `getSouthLat()` Get the latitude of the south edge in a LatLon rectangle.
`int` `getTop()` Get the top of XY rectangle.
`float` `getWestLon()` Get the longitude of the west edge in a LatLon rectangle.
`void` `setLocation(float lt1, float ln1, float lt2, float ln2, int lType)` Set a lat/lon rectangle.
`void` `setLocation(float lt1, float ln1, int px1, int py1, int px2, int py2)` Set an XY rectangle relative to a lat/lon point (RENDERTYPE_OFFSET).
`void` `setLocation(int px1, int py1, int px2, int py2)` Set an XY rectangle.
`void` `setNumSegs(int nsegs)` Set the number of segments of the lat/lon lines.

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

`clone, deselect, distance, getDeclutterType, getDescription, getDescription, getDisplayColor, getDisplayPaint, getEdgeMatchesFill, getFillColor, getFillPaint, getHasLabel, getLineColor, getLinePaint, getMattingPaint, getRenderType, getSelectColor, getSelectPaint, getShowEditablePalette, getStroke, getTextureMask, hasLineTypeChoice, initLabelingDuringGenerate, isClear, isMatted, isSelected, normalizeDistanceForLineWidth, regenerate, render, renderLabel, select, setDeclutterType, setEdgeMatchesFill, setFillColor, setFillPaint, setGraphicsColor, setGraphicsForEdge, setGraphicsForFill, setHasLabel, setLabelLocation, setLabelLocation, setLabelLocation, setLineColor, setLinePaint, setMatted, setMattingPaint, setRenderType, setSelectColor, setSelected, setSelectPaint, setShape, setShowEditablePalette, setStroke, setTextureMask, 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, isVisible, putAttribute, removeAttribute, replaceAppObjectWithAttributeMap, setAppObject, setAppObject, setAttributes, setLineType, setNeedToRegenerate, setVisible`

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

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

Field Detail

### x1

    protected int x1

  Horizontal window position of first corner, in pixels from left side of window.

### y1

    protected int y1

  Vertical window position of first corner, in pixels from the top of the window.

### lat1

    protected float lat1

  Latitude of first corner, decimal degrees.

### lon1

    protected float lon1

  Longitude of first corner, decimal degrees.

### x2

    protected int x2

  Horizontal window position of second corner, in pixels from left side of window.

### y2

    protected int y2

  Vertical window position of second corner, in pixels from the top of the window.

### lat2

    protected float lat2

  Latitude of second corner, decimal degrees.

### lon2

    protected float lon2

  Longitude of second corner, decimal degrees.

### nsegs

    protected int nsegs

  Number of segments to draw (used only for LINETYPE_GREATCIRCLE or LINETYPE_RHUMB lines).

Constructor Detail

### OMRect

    public OMRect()

  Default constructor, waiting to be filled.

### OMRect

    public OMRect(float lt1,
                  float ln1,
                  float lt2,
                  float ln2,
                  int lType)

  Create a lat/lon rectangle.

Parameters:
  `lt1` - latitude of north edge, decimal degrees.
  `ln1` - longitude of west edge, decimal degrees.
  `lt2` - latitude of south edge, decimal degrees.
  `ln2` - longitude of east edge, decimal degrees.
  `lType` - line type - see OMGraphic.lineType.

### OMRect

    public OMRect(float lt1,
                  float ln1,
                  float lt2,
                  float ln2,
                  int lType,
                  int nsegs)

  Create a lat/lon rectangle.

Parameters:
  `lt1` - latitude of north edge, decimal degrees.
  `ln1` - longitude of west edge, decimal degrees.
  `lt2` - latitude of south edge, decimal degrees.
  `ln2` - longitude of east edge, decimal degrees.
  `lType` - line type - see OMGraphic.lineType.
  `nsegs` - number of segment points (only for LINETYPE_GREATCIRCLE or LINETYPE_RHUMB line types, and if < 1, this value is generated internally)

### OMRect

    public OMRect(int px1,
                  int py1,
                  int px2,
                  int py2)

  Construct an XY rectangle. It doesn't matter which corners of the rectangle are used, as long as they are opposite from each other.

Parameters:
  `px1` - x pixel position of the first corner relative to the window origin
  `py1` - y pixel position of the first corner relative to the window origin
  `px2` - x pixel position of the second corner relative to the window origin
  `py2` - y pixel position of the second corner relative to the window origin

### OMRect

    public OMRect(float lt1,
                  float ln1,
                  int px1,
                  int py1,
                  int px2,
                  int py2)

  Construct an XY rectangle relative to a lat/lon point (RENDERTYPE_OFFSET). It doesn't matter which corners of the rectangle are used, as long as they are opposite from each other.

Parameters:
  `lt1` - latitude of the reference point, decimal degrees.
  `ln1` - longitude of the reference point, decimal degrees.
  `px1` - x pixel position of the first corner relative to the reference point
  `py1` - y pixel position of the first corner relative to the reference point
  `px2` - x pixel position of the second corner relative to the reference point
  `py2` - y pixel position of the second corner relative to the reference point

Method Detail

### setLocation

    public void setLocation(float lt1,
                            float ln1,
                            float lt2,
                            float ln2,
                            int lType)

  Set a lat/lon rectangle.

  Parameters:
    `lt1` - latitude of north edge, decimal degrees.
    `ln1` - longitude of west edge, decimal degrees.
    `lt2` - latitude of south edge, decimal degrees.
    `ln2` - longitude of east edge, decimal degrees.
    `lType` - line type - see OMGraphic.lineType.

### setLocation

    public void setLocation(int px1,
                            int py1,
                            int px2,
                            int py2)

  Set an XY rectangle. It doesn't matter which corners of the rectangle are used, as long as they are opposite from each other.

  Parameters:
    `px1` - x pixel position of the first corner relative to the window origin
    `py1` - y pixel position of the first corner relative to the window origin
    `px2` - x pixel position of the second corner relative to the window origin
    `py2` - y pixel position of the second corner relative to the window origin

### setLocation

    public void setLocation(float lt1,
                            float ln1,
                            int px1,
                            int py1,
                            int px2,
                            int py2)

  Set an XY rectangle relative to a lat/lon point (RENDERTYPE_OFFSET). It doesn't matter which corners of the rectangle are used, as long as they are opposite from each other.

  Parameters:
    `lt1` - latitude of the reference point, decimal degrees.
    `ln1` - longitude of the reference point, decimal degrees.
    `px1` - x pixel position of the first corner relative to the reference point
    `py1` - y pixel position of the first corner relative to the reference point
    `px2` - x pixel position of the second corner relative to the reference point
    `py2` - y pixel position of the second corner relative to the reference point

### getNorthLat

    public float getNorthLat()

  Get the latitude of the north edge in a LatLon rectangle. It also happens to be the latitude of the offset point.

  Returns:
    float latitude

### getWestLon

    public float getWestLon()

  Get the longitude of the west edge in a LatLon rectangle. It also happens to be the longitude of the offset point.

  Returns:
    float longitude

### getSouthLat

    public float getSouthLat()

  Get the latitude of the south edge in a LatLon rectangle.

  Returns:
    float latitude

### getEastLon

    public float getEastLon()

  Get the longitude of the east edge in a LatLon rectangle.

  Returns:
    float longitude

### getTop

    public int getTop()

  Get the top of XY rectangle.

  Returns:
    int

### getLeft

    public int getLeft()

  Get the left of XY rectangle.

  Returns:
    int

### getBottom

    public int getBottom()

  Get the bottom of XY rectangle.

  Returns:
    int

### getRight

    public int getRight()

  Get the right of XY rectangle.

  Returns:
    int

### setNumSegs

    public void setNumSegs(int nsegs)

  Set the number of segments of the lat/lon lines. (This is only for LINETYPE_GREATCIRCLE or LINETYPE_RHUMB line types, and if < 1, this value is generated internally).

  Parameters:
    `nsegs` - number of segment points

### getNumSegs

    public int getNumSegs()

  Get the number of segments of the lat/lon lines. (This is only for LINETYPE_GREATCIRCLE or LINETYPE_RHUMB line types).

  Returns:
    int number of segment points

### generate

    public boolean generate(Projection proj)

  Prepare the rectangle for rendering.

  Specified by:
    `generate` in interface `OMGeometry`
  Specified by:
    `generate` in class `OMGraphic`
  Parameters:
    `proj` - Projection
  Returns:
    true if generate was successful
  See Also:
    `OMGraphic.regenerate(com.bbn.openmap.proj.Projection)`

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