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

## com.bbn.openmap.omGraphics
Class OMRasterObject

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

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

Direct Known Subclasses:
  OMBitmap, OMRaster

public abstract class OMRasterObject
extends OMGraphic
implements java.io.Serializable, java.awt.image.ImageObserver

The OMRasterObject is the parent class for OMRaster and OMBitmap objects. It manages some of the same functions that both classes require in order to create image pixel data from bytes or integers.

An ImageFilter may be applied to OMRasterObjects. These can be scale filters, color filters, or maybe (?hopefully?) projection filters. These filters won't change the original image data, and the original can be reconstructed by resetting the filter to null, and generating the object.

For all classes in the OMRasterObject family, a java.awt.Shape object is created for the border of the image. This Shape object is used for distance calculations. If the OMRasterObject is selected(), however, this Shape will be rendered with the OMGraphic parameters that are set in the OMGraphic.

See Also:
  Serialized Form

Nested Class Summary
`protected class` | `OMRasterObject.TrimScaleFilter` This is an effort to create an scaling ImageFilter that will trim off the unused pixels, lessoning the load on the display server.

Field Summary
`protected java.awt.Image` | `bitmap` The bitmap is drawn to the graphics.
`protected byte[]` | `bits` The byte info for the image.
`protected int` | `colorModel` colorModel helps figure out what kind of updates are necessary, by knowing what kind of image we're dealing with.
`static int` | `COLORMODEL_DIRECT` The direct colormodel, for OMRasters, means the integer values passed in as pixels, already reflect the RGB color values each pixel should display.
`static int` | `COLORMODEL_IMAGEICON` The ImageIcon colormodel means that the image is externally set, and we just want to to display the image at the given location.
`static int` | `COLORMODEL_INDEXED` The indexed colormodel, for OMRasters, means that the byte array passed in for the pixels has to be resolved with a colortable in order to create a integer array of RGB pixels.
`protected boolean` | `DEBUG`
`static int` | `FAST_SCALING` If scaling the image, use the faster, replicating/clipping algorithm.
`protected int` | `filteredHeight` The height of the image after scaling, if you want the image to be a different size than the source.
`protected int` | `filteredWidth` The width of the image after scaling, if you want the image to be a different size than the source.
`protected int` | `height` The height of the image, in pixels.
`protected java.awt.image.ImageFilter` | `imageFilter` The image filter to use on the constructed image.
`protected float` | `lat` The latitude of the upper left corner for the image, in decimal degrees.
`protected float` | `lon` The longitude of the upper left corner for the image, in decimal degrees.
`protected boolean` | `needToReposition` Set if the projection has had attributes change that require a repositioning of the image, not a regeneration.
`protected int[]` | `pixels` The pixels are used for the image that is drawn on the window.
`protected java.awt.Point` | `point1` Projected window pixel location of the upper left corner of the image.
`protected java.awt.Point` | `point2` Projected window pixel location of the lower right corner of the image.
`protected double` | `rotationAngle` the angle by which the image is to be rotated, in radians
`static int` | `SMOOTH_SCALING` If scaling the image, use the slower, smoothing algorithm.
`protected int` | `width` The width of the image, in pixels.
`protected int` | `x` Horizontal location of the upper left corner of the image, or the x offset from the lon for that corner, in pixels.
`protected int` | `y` Vertical location of the upper left corner of the image, or the y offset from the lat for that corner, in pixels.

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 java.awt.image.ImageObserver
`ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH`

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
`OMRasterObject()` A Contructor that sets the graphic type to raster, render type to unknown, line type to unknown, and the declutter type to none.
`OMRasterObject(int rType, int lType, int dcType)` A Contructor that sets the graphic type, render type, line type and the declutter type to the values you pass in.

Method Summary
`protected abstract boolean` | `computePixels()` Compute the raster objects pixels, based on the color model and the byte values.
`protected java.awt.Image` | `filterImage()` A method used to manipulate the image according to the parameters set by the imageFilter in the OMRasterObject.
`byte[]` | `getBits()` Get the byte values for indexed color model images and OMBitmaps.
`int` | `getColorModel()` Get the color model type of the image.
`int` | `getFilteredHeight()` Get the height of image after a filter was applied.
`int` | `getFilteredWidth()` Get width of image, after a filter is applied.
`int` | `getHeight()` Get the height of image.
`java.awt.Image` | `getImage()` Get the image that will be put on the window.
`java.awt.image.ImageFilter` | `getImageFilter()` Return the image filter used on the image.
`float` | `getLat()` Get the latitude.
`float` | `getLon()` Get the longitude.
`java.awt.Point` | `getMapLocation()` Return the map location of the image, after generation.
`boolean` | `getNeedToReposition()` Return the reposition status.
`int[]` | `getPixels()` Return the pixels used for the image.
`double` | `getRotationAngle()` Get the current rotation of the image.
`int` | `getWidth()` Get width of image.
`int` | `getX()` Returns the x attribute.
`int` | `getY()` Return the y attribute.
`protected boolean` | `hasLineTypeChoice()` Used by the GraphicAttributes object to provide a choice on whether the line type choice can be changed.
`boolean` | `imageUpdate(java.awt.Image img, int infoflags, int x, int y, int width, int height)` From the Image Observer Interface.
`protected boolean` | `position(Projection proj)` Since the image doesn't necessarily need to be regenerated when it is merely moved, raster objects have this function, called from generate() and when a placement attribute is changed.
`void` | `render(java.awt.Graphics graphics)` Render the raster on the java.awt.Graphics
`protected void` | `rotate(java.awt.Graphics2D g)` Called from within render().
`void` | `scaleTo(int w, int h, int algorithmType)` Convenience function to scale the Image to the xy size.
`void` | `setBits(byte[] values)` Set the bytes used to create the pixels used to create the image.
`protected void` | `setColorModel(int cm)` The color model is set based on the constructor.
`void` | `setHeight(int value)` Set the height of the image, in pixels.
`void` | `setImage(java.awt.Image ii)` Set the image to be drawn, if the color model is COLORMODEL_IMAGEICON.
`void` | `setImageFilter(java.awt.image.ImageFilter filter)` Set a filter to be used on the constructed image.
`void` | `setLat(float value)` Change the latitude attribute, which matters only if the render type is RENDERTYPE_LATLON or RENDERTYPE_OFFSET.
`void` | `setLon(float value)` Change the longitude attribute, which matters only if the render type is RENDERTYPE_LATLON or RENDERTYPE_OFFSET.
`void` | `setNeedToReposition(boolean value)` Set the flag for the object that lets the render method (which draws the object) know that the object needs to be repositioned first.
`void` | `setPixels(int[] values)` Set the pixels for the image for direct color model images.
`void` | `setRotationAngle(double angle)` Set the angle by which the image is to rotated.
`void` | `setShape()` Set the rectangle, based on the location and size of the image.
`void` | `setWidth(int value)` Set width of image.
`void` | `setX(int value)` Change the x attribute, which matters only if the render type is RENDERTYPE_XY or RENDERTYPE_OFFSET.
`void` | `setY(int value)` Change the y attribute, which matters only if the render type is RENDERTYPE_XY or RENDERTYPE_OFFSET.
`boolean` | `shouldRenderFill()` Always true for images, affects distance measurements.

Methods inherited from class com.bbn.openmap.omGraphics.OMGraphic
`clone, deselect, distance, generate, getDeclutterType, getDescription, getDescription, getDisplayColor, getDisplayPaint, getEdgeMatchesFill, getFillColor, getFillPaint, getHasLabel, getLineColor, getLinePaint, getMattingPaint, getRenderType, getSelectColor, getSelectPaint, getShowEditablePalette, getStroke, getTextureMask, initLabelingDuringGenerate, isClear, isMatted, isSelected, normalizeDistanceForLineWidth, regenerate, 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`

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

### COLORMODEL_DIRECT

    public static final int COLORMODEL_DIRECT

  The direct colormodel, for OMRasters, means the integer values passed in as pixels, already reflect the RGB color values each pixel should display.

  See Also:
    Constant Field Values

### COLORMODEL_INDEXED

    public static final int COLORMODEL_INDEXED

  The indexed colormodel, for OMRasters, means that the byte array passed in for the pixels has to be resolved with a colortable in order to create a integer array of RGB pixels.

  See Also:
    Constant Field Values

### COLORMODEL_IMAGEICON

    public static final int COLORMODEL_IMAGEICON

  The ImageIcon colormodel means that the image is externally set, and we just want to to display the image at the given location.

  See Also:
    Constant Field Values

### SMOOTH_SCALING

    public static final int SMOOTH_SCALING

  If scaling the image, use the slower, smoothing algorithm.

  See Also:
    Constant Field Values

### FAST_SCALING

    public static final int FAST_SCALING

  If scaling the image, use the faster, replicating/clipping algorithm.

  See Also:
    Constant Field Values

### colorModel

    protected int colorModel

  colorModel helps figure out what kind of updates are necessary, by knowing what kind of image we're dealing with. For the images created with a ImageIcon, the attribute updates that don't relate to position will not take affect.

### pixels

    protected int[] pixels

  The pixels are used for the image that is drawn on the window. The pixels are either passed in as an int[] in some constructors of the OMRaster, or it is constructed in the OMBitmap and in OMRasters that have a colortable.

### x

    protected int x

  Horizontal location of the upper left corner of the image, or the x offset from the lon for that corner, in pixels.

### y

    protected int y

  Vertical location of the upper left corner of the image, or the y offset from the lat for that corner, in pixels.

### lat

    protected float lat

  The latitude of the upper left corner for the image, in decimal degrees.

### lon

    protected float lon

  The longitude of the upper left corner for the image, in decimal degrees.

### width

    protected int width

  The width of the image, in pixels. This always reflects the width of the original image, even if a filter is applied to the image.

### height

    protected int height

  The height of the image, in pixels. This always reflects the height of the original image, even if a filter is applied to the image.

### bits

    protected byte[] bits

  The byte info for the image. OMBitmaps use each bit as an indication to use the lineColor or the fillColor for each pixel (like a XBitmap). OMRasters only use the bits when the image being created follows the indexed colormodel. Then, the bits hold the colortable indexes that each pixel needs to have a color substituted in later.

### bitmap

    protected transient java.awt.Image bitmap

  The bitmap is drawn to the graphics.

### point1

    protected java.awt.Point point1

  Projected window pixel location of the upper left corner of the image.

### point2

    protected java.awt.Point point2

  Projected window pixel location of the lower right corner of the image.

### filteredWidth

    protected int filteredWidth

  The width of the image after scaling, if you want the image to be a different size than the source.

### filteredHeight

    protected int filteredHeight

  The height of the image after scaling, if you want the image to be a different size than the source.

### imageFilter

    protected java.awt.image.ImageFilter imageFilter

  The image filter to use on the constructed image.

### needToReposition

    protected boolean needToReposition

  Set if the projection has had attributes change that require a repositioning of the image, not a regeneration.

### rotationAngle

    protected double rotationAngle

  the angle by which the image is to be rotated, in radians

### DEBUG

    protected boolean DEBUG

Constructor Detail

### OMRasterObject

    public OMRasterObject()

  A Contructor that sets the graphic type to raster, render type to unknown, line type to unknown, and the declutter type to none.

### OMRasterObject

    public OMRasterObject(int rType,
                          int lType,
                          int dcType)

  A Contructor that sets the graphic type, render type, line type and the declutter type to the values you pass in. See OMGraphic for the definitions of these attributes.

Parameters:
  `rType` - render type
  `lType` - line type
  `dcType` - declutter type

Method Detail

### setColorModel

    protected void setColorModel(int cm)

  The color model is set based on the constructor. This setting controls what parameter changes are posiible for different models of images.

  Parameters:
    `cm` - the colormode that describes how the colors are being set - COLORMODEL_DIRECT, COLORMODEL_INDEXED, or COLORMODEL_IMAGEICON.

### getColorModel

    public int getColorModel()

  Get the color model type of the image.

  Returns:
    COLORMODEL_DIRECT, COLORMODEL_INDEXED, or COLORMODEL_IMAGEICON.

### setNeedToReposition

    public void setNeedToReposition(boolean value)

  Set the flag for the object that lets the render method (which draws the object) know that the object needs to be repositioned first.

### getNeedToReposition

    public boolean getNeedToReposition()

  Return the reposition status.

### setRotationAngle

    public void setRotationAngle(double angle)

  Set the angle by which the image is to rotated.

  Parameters:
    `angle` - the number of radians the image is to be rotated. Measured clockwise from horizontal.

### getRotationAngle

    public double getRotationAngle()

  Get the current rotation of the image.

  Returns:
    the image rotation.

### computePixels

    protected abstract boolean computePixels()

  Compute the raster objects pixels, based on the color model and the byte values.

  Returns:
    true if everything goes OK (height*width = pixel.length, etc.).

### rotate

    protected void rotate(java.awt.Graphics2D g)

  Called from within render(). This method should call rotate() on the provided Graphics2D object, setting the rotation angle and the rotation point. By default, the rotation angle is whatever is set in the OMRasterObject, and the rotation point is the offset point plus half the image width in the horizonal direction, and half the image in the vertical direction.

### render

    public void render(java.awt.Graphics graphics)

  Render the raster on the java.awt.Graphics

  Overrides:
    `render` in class `OMGraphic`
  Parameters:
    `graphics` - Graphics2D context to render into.

### setShape

    public void setShape()

  Set the rectangle, based on the location and size of the image.

### position

    protected boolean position(Projection proj)

  Since the image doesn't necessarily need to be regenerated when it is merely moved, raster objects have this function, called from generate() and when a placement attribute is changed.

  Parameters:
    `proj` - projection of window.
  Returns:
    true if enough information is in the object for proper placement.

### setImage

    public void setImage(java.awt.Image ii)

  Set the image to be drawn, if the color model is COLORMODEL_IMAGEICON.

  Parameters:
    `ii` - the image icon to use.

### getImage

    public java.awt.Image getImage()

  Get the image that will be put on the window.

  Returns:
    the Image created by computePixels and generate().

### shouldRenderFill

    public boolean shouldRenderFill()

  Always true for images, affects distance measurements. Forces the omGraphics package to treat the OMRasterObject as a filled shape.

  Overrides:
    `shouldRenderFill` in class `OMGraphic`

### setPixels

    public void setPixels(int[] values)

  Set the pixels for the image for direct color model images. Checks to see of the length matches the height * width, but doesn't do anything if they don't match. Make sure it does.

  Parameters:
    `values` - the pixel values.

### getPixels

    public int[] getPixels()

  Return the pixels used for the image.

  Returns:
    the integer array of ints used as integer colors for each pixel of the image.

### setX

    public void setX(int value)

  Change the x attribute, which matters only if the render type is RENDERTYPE_XY or RENDERTYPE_OFFSET.

  Parameters:
    `value` - the x location in pixels.

### getX

    public int getX()

  Returns the x attribute.

  Returns:
    the x value, pixels from left of window or image origin.

### setY

    public void setY(int value)

  Change the y attribute, which matters only if the render type is RENDERTYPE_XY or RENDERTYPE_OFFSET.

  Parameters:
    `value` - the y location in pixels

### getY

    public int getY()

  Return the y attribute.

  Returns:
    the y value, pixels from top or image origin.

### getMapLocation

    public java.awt.Point getMapLocation()

  Return the map location of the image, after generation.

  Returns:
    Point, null if not projected yet.

### setLat

    public void setLat(float value)

  Change the latitude attribute, which matters only if the render type is RENDERTYPE_LATLON or RENDERTYPE_OFFSET.

  Parameters:
    `value` - latitude in decimal degrees.

### getLat

    public float getLat()

  Get the latitude.

  Returns:
    the latitude in decimal degrees.

### setLon

    public void setLon(float value)

  Change the longitude attribute, which matters only if the render type is RENDERTYPE_LATLON or RENDERTYPE_OFFSET.

  Parameters:
    `value` - the longitude in decimal degrees.

### getLon

    public float getLon()

  Get the longitude.

  Returns:
    longitude in decimal degrees.

### setHeight

    public void setHeight(int value)

  Set the height of the image, in pixels.

  Parameters:
    `value` - height in pixels.

### getHeight

    public int getHeight()

  Get the height of image.

  Returns:
    height in pixels.

### getFilteredHeight

    public int getFilteredHeight()

  Get the height of image after a filter was applied.

  Returns:
    filteredHeight in pixels.

### setWidth

    public void setWidth(int value)

  Set width of image.

  Parameters:
    `value` - width in pixels.

### getWidth

    public int getWidth()

  Get width of image.

  Returns:
    width of image in pixels.

### getFilteredWidth

    public int getFilteredWidth()

  Get width of image, after a filter is applied.

  Returns:
    filteredWidth of image in pixels.

### setBits

    public void setBits(byte[] values)

  Set the bytes used to create the pixels used to create the image. Used for indexed color model images in OMRaster, and OMBitmaps.

  Parameters:
    `values` - byte values

### getBits

    public byte[] getBits()

  Get the byte values for indexed color model images and OMBitmaps.

  Returns:
    the bytes used to create the pixels.

### setImageFilter

    public void setImageFilter(java.awt.image.ImageFilter filter)

  Set a filter to be used on the constructed image. Applied at generate().

  Parameters:
    `filter` - Image filter to apply to contructed raster.

### getImageFilter

    public java.awt.image.ImageFilter getImageFilter()

  Return the image filter used on the image.

  Returns:
    imagefilter, null if one wasn't set.

### scaleTo

    public void scaleTo(int w,
                        int h,
                        int algorithmType)

  Convenience function to scale the Image to the xy size. Sets the imageFilter to a ReplicateScaleFilter or AreaAveragingScaleFilter, depending on the algorithm type.

  Parameters:
    `w` - width to scale to, in pixels
    `h` - height to scale to, in pixels
    `algorithmType` - OMRasterObject parameter describing which scaling algorithm to use.

### filterImage

    protected java.awt.Image filterImage()

  A method used to manipulate the image according to the parameters set by the imageFilter in the OMRasterObject. Called from generate() if the filteredWidth and filteredHeight differ from width and height.

  Returns:
    the filtered image.

### imageUpdate

    public boolean imageUpdate(java.awt.Image img,
                               int infoflags,
                               int x,
                               int y,
                               int width,
                               int height)

  From the Image Observer Interface. Called when the image bits have arrived, and therefore calls setImage() to reset all the OMRasterObject parameters.
  Don't call this method!

  Specified by:
    `imageUpdate` in interface `java.awt.image.ImageObserver`

### hasLineTypeChoice

    protected boolean hasLineTypeChoice()

  Description copied from class: `OMGraphic`
  Used by the GraphicAttributes object to provide a choice on whether the line type choice can be changed.

  Overrides:
    `hasLineTypeChoice` in class `OMGraphic`

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

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