## com.bbn.openmap.omGraphics
Class OMRaster

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

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

Direct Known Subclasses:
  OMScalingRaster

public class OMRaster
extends OMRasterObject
implements java.io.Serializable

The OMRaster object lets you create multi-colored images. An image is a two dimensional array of pixel values that correspond to some color values. The pixels are used from the top left, across each row to the right, down to the bottom row.

There are two colormodels that are implemented in OMRaster - the direct colormodel and the indexed colormodel. The direct colormodel is implemented when the pixel values contain the actual java.awt.Color values for the image. The indexed colormodel is implemented when the pixel values are actually indexes into an array of java.awt.Colors. NOTE: The direct colormodel OMRaster is faster to display, because it doesn't need to take the time to resolve the colortable values into pixels.

For direct colormodel images: If you pass in a null pix or a pix with a zero length, the object will create the pixels for you but will not general a renderable version of the object. You will need to call render before generate after the pixels have been set. This feature is for cached rasters, where the content may be changed later. Use this (null pix) if you are building images in a cache, for tiled mapping data or something else where the data is not yet known. The memory for the pixels will be allocated, and then they can be set with image data later when a database is accessed.

For ImageIcon OMRasters: Using an ImageIcon to create an OMRaster gives you the ability to put an image on the screen based on an ImageIcon made from file or URL. The OMRaster uses this ImageIcon as is - there is no opportunity to change any parameters of this image. So set the colors, transparency, etc. before you create the OMRaster.

For indexed colormodel images: If you pass in an empty byte array, a byte array will be created based on the width and height. You will have to resolve empty colortables and set the pixels later. Use this method (null bytes) if you are building images in a cache, for tiled mapping data or something else where the data is not yet known. The memory for the pixels will be allocated, and then they can be set with image data later when a database is accessed. There is the ability to add a filter to the image, to change it's appearance for rendering. The most common filter, which is included as a kind of default, is the scale filter. Filtering the OMRasterObject replaces the bitmap variable, which is the internal java.awt.Image used for rendering. For OMRasters created with pixels, or with the colortable and the colortable index, the original data is left intact, and can be recreated later, or rescaled on the fly, because the internal bitmap will be recreated prior to rescaling. For OMRasters created by ImageIcons or Images, though, you'll need to hold on to the original Image. The internal version is replaced by the filtered version.

See Also:
  `OMRasterObject`, Serialized Form

Nested Class Summary

Nested classes inherited from class com.bbn.openmap.omGraphics.OMRasterObject
`OMRasterObject.TrimScaleFilter`

Field Summary
`protected int[]` `colors` The integer colors that are needed in a java colortable.
`protected int` `transparent` The transparency of the image.

Fields inherited from class com.bbn.openmap.omGraphics.OMRasterObject
`bitmap, bits, colorModel, COLORMODEL_DIRECT, COLORMODEL_IMAGEICON, COLORMODEL_INDEXED, DEBUG, FAST_SCALING, filteredHeight, filteredWidth, height, imageFilter, lat, lon, needToReposition, pixels, point1, point2, rotationAngle, SMOOTH_SCALING, width, x, y`

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
`OMRaster()` Constuct a blank OMRaster, to be filled in with setX calls.
`OMRaster(float lt, float ln, java.awt.Image ii)` Create an OMRaster, Lat/Lon placement with an Image.
`OMRaster(float lt, float ln, javax.swing.ImageIcon ii)` Create an OMRaster, Lat/Lon placement with an ImageIcon.
`OMRaster(float lt, float ln, int w, int h, byte[] bytes, java.awt.Color[] colorTable, int trans)` Lat/Lon placement with a indexed colormodel, which is using a colortable and a byte array to contruct the int[] pixels.
`OMRaster(float lt, float ln, int offset_x1, int offset_y1, java.awt.Image ii)` Create an OMRaster, Lat/Lon with X/Y placement with an Image.
`OMRaster(float lt, float ln, int offset_x1, int offset_y1, javax.swing.ImageIcon ii)` Create an OMRaster, Lat/Lon with X/Y placement with an ImageIcon.
`OMRaster(float lt, float ln, int w, int h, int[] pix)` Creates an OMRaster images, Lat/Lon placement with a direct colormodel.
`OMRaster(float lt, float ln, int offset_x1, int offset_y1, int w, int h, byte[] bytes, java.awt.Color[] colorTable, int trans)` Lat/lon placement with XY offset with a indexed colormodel, which is using a colortable and a byte array to construct the int[] pixels.
`OMRaster(float lt, float ln, int offset_x1, int offset_y1, int w, int h, int[] pix)` Create an OMRaster, Lat/lon placement with XY offset with a direct colormodel.
`OMRaster(int x1, int y1, java.awt.Image ii)` Create an OMRaster image, X/Y placement with an Image.
`OMRaster(int x1, int y1, javax.swing.ImageIcon ii)` Create an OMRaster image, X/Y placement with an ImageIcon.
`OMRaster(int x1, int y1, int w, int h, byte[] bytes, java.awt.Color[] colorTable, int trans)` XY placement with a indexed colormodel, which is using a colortable and a byte array to contruct the int[] pixels.
`OMRaster(int x1, int y1, int w, int h, int[] pix)` Create an OMRaster image, XY placement with a direct colormodel.

Method Summary
`protected boolean` `computePixels()` Compute pixels is the function that resolves the color table into pixel integer values used in the Image.
`boolean` `generate(Projection proj)` Prepare the graphics for rendering.
`byte` `getByte(int x, int y)` Get image byte data, which the index to a colortable for indexed images.
`int[]` `getColors()` Get the array of colors used in the indexed color model.
`int` `getPixel(int x, int y)` Get the image pixel value at a locaiton.
`int` `getTransparent()` Get the transparent setting of the image.
`void` `setBits(byte[] values)` Set the bytes used to create the pixels used to create the image.
`boolean` `setByte(int x, int y, byte ctIndex)` Set image byte data, for index frame using colortable.
`void` `setColors(java.awt.Color[] values)` Set the color table according to the java.awt.Color array passed in.
`void` `setColors(int[] values)` Set the color table to the int RGB values passed in.
`void` `setImageIcon(javax.swing.ImageIcon img)` Set the ImageIcon.
`boolean` `setPixel(int x, int y, int colorValue)` Set the image pixel value at a location.
`void` `setTransparent(int value)` Set the transparency of the index type images.

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

`filterImage, getBits, getColorModel, getFilteredHeight, getFilteredWidth, getHeight, getImage, getImageFilter, getLat, getLon, getMapLocation, getNeedToReposition, getPixels, getRotationAngle, getWidth, getX, getY, hasLineTypeChoice, imageUpdate, position, render, rotate, scaleTo, setColorModel, setHeight, setImage, setImageFilter, setLat, setLon, setNeedToReposition, setPixels, setRotationAngle, setShape, setWidth, setX, setY, shouldRenderFill`

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, 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

### colors

    protected int[] colors

  The integer colors that are needed in a java colortable. The Color[] that gets passed into some of the constructors goes to build this, but this array is really used to build the image pixel array.

### transparent

    protected int transparent

  The transparency of the image. If this is set to anything less than 255, this value is used for all colors in the image. If it is set to 255, then the alpha value in each Color regulates the transparency of the image. The value of this variable should stay in the range: `0 <= transparent <= 255`

Constructor Detail

### OMRaster

    public OMRaster()

  Constuct a blank OMRaster, to be filled in with setX calls.

### OMRaster

    public OMRaster(float lt,
                    float ln,
                    int w,
                    int h,
                    int[] pix)

  Creates an OMRaster images, Lat/Lon placement with a direct colormodel.

Parameters:
  `lt` - latitude of the top of the image.
  `ln` - longitude of the left side of the image.
  `w` - width of the image, in pixels.
  `h` - height of the image, in pixels.
  `pix` - color values for the pixels.
See Also:
  `setPixel(int, int, int)`

### OMRaster

    public OMRaster(int x1,
                    int y1,
                    int w,
                    int h,
                    int[] pix)

  Create an OMRaster image, XY placement with a direct colormodel.

Parameters:
  `x1` - window location of the left side of the image.
  `y1` - window location of the top of the image.
  `w` - width of the image, in pixels.
  `h` - height of the image, in pixels.
  `pix` - color values for the pixels.
See Also:
  `setPixel(int, int, int)`

### OMRaster

    public OMRaster(float lt,
                    float ln,
                    int offset_x1,
                    int offset_y1,
                    int w,
                    int h,
                    int[] pix)

  Create an OMRaster, Lat/lon placement with XY offset with a direct colormodel.

Parameters:
  `lt` - latitude of the top of the image, before the offset.
  `ln` - longitude of the left side of the image, before the offset.
  `offset_x1` - number of pixels to move image to the right.
  `offset_y1` - number of pixels to move image down.
  `w` - width of the image, in pixels.
  `h` - height of the image, in pixels.
  `pix` - color values for the pixels.
See Also:
  `setPixel(int, int, int)`

### OMRaster

    public OMRaster(float lt,
                    float ln,
                    javax.swing.ImageIcon ii)

  Create an OMRaster, Lat/Lon placement with an ImageIcon.

Parameters:
  `lt` - latitude of the top of the image.
  `ln` - longitude of the left side of the image.
  `ii` - ImageIcon used for the image.

### OMRaster

    public OMRaster(float lt,
                    float ln,
                    java.awt.Image ii)

  Create an OMRaster, Lat/Lon placement with an Image.

Parameters:
  `lt` - latitude of the top of the image.
  `ln` - longitude of the left side of the image.
  `ii` - Image used for the image.

### OMRaster

    public OMRaster(int x1,
                    int y1,
                    javax.swing.ImageIcon ii)

  Create an OMRaster image, X/Y placement with an ImageIcon.

Parameters:
  `x1` - window location of the left side of the image.
  `y1` - window location of the top of the image.
  `ii` - ImageIcon used for the image.

### OMRaster

    public OMRaster(int x1,
                    int y1,
                    java.awt.Image ii)

  Create an OMRaster image, X/Y placement with an Image.

Parameters:
  `x1` - window location of the left side of the image.
  `y1` - window location of the top of the image.
  `ii` - Image used for the image.

### OMRaster

    public OMRaster(float lt,
                    float ln,
                    int offset_x1,
                    int offset_y1,
                    javax.swing.ImageIcon ii)

  Create an OMRaster, Lat/Lon with X/Y placement with an ImageIcon.

Parameters:
  `lt` - latitude of the top of the image, before the offset.
  `ln` - longitude of the left side of the image, before the offset.
  `offset_x1` - number of pixels to move image to the right.
  `offset_y1` - number of pixels to move image down.
  `ii` - ImageIcon used for the image.

### OMRaster

    public OMRaster(float lt,
                    float ln,
                    int offset_x1,
                    int offset_y1,
                    java.awt.Image ii)

  Create an OMRaster, Lat/Lon with X/Y placement with an Image. Make sure that the Image is complete( if being loaded over the internet) and ready to be drawn. Otherwise, you have to figure out when the Image is complete, so that you can get the layer to paint it! Use the ImageIcon constructor if you don't mind blocking to wait for the pixels to arrive.

Parameters:
  `lt` - latitude of the top of the image, before the offset.
  `ln` - longitude of the left side of the image, before the offset.
  `offset_x1` - number of pixels to move image to the right.
  `offset_y1` - number of pixels to move image down.
  `ii` - Image used for the image.

### OMRaster

    public OMRaster(float lt,
                    float ln,
                    int w,
                    int h,
                    byte[] bytes,
                    java.awt.Color[] colorTable,
                    int trans)

  Lat/Lon placement with a indexed colormodel, which is using a colortable and a byte array to contruct the int[] pixels.

Parameters:
  `lt` - latitude of the top of the image.
  `ln` - longitude of the left side of the image.
  `w` - width of the image, in pixels.
  `h` - height of the image, in pixels.
  `bytes` - colortable index values for the pixels.
  `colorTable` - color array corresponding to bytes
  `trans` - transparency of image.
See Also:
  `setPixel(int, int, int)`

### OMRaster

    public OMRaster(int x1,
                    int y1,
                    int w,
                    int h,
                    byte[] bytes,
                    java.awt.Color[] colorTable,
                    int trans)

  XY placement with a indexed colormodel, which is using a colortable and a byte array to contruct the int[] pixels.

Parameters:
  `x1` - window location of the left side of the image.
  `y1` - window location of the top of the image.
  `w` - width of the image, in pixels.
  `h` - height of the image, in pixels.
  `bytes` - colortable index values for the pixels.
  `colorTable` - color array corresponding to bytes
  `trans` - transparency of image.
See Also:
  `setPixel(int, int, int)`

### OMRaster

    public OMRaster(float lt,
                    float ln,
                    int offset_x1,
                    int offset_y1,
                    int w,
                    int h,
                    byte[] bytes,
                    java.awt.Color[] colorTable,
                    int trans)

  Lat/lon placement with XY offset with a indexed colormodel, which is using a colortable and a byte array to construct the int[] pixels.

Parameters:
  `lt` - latitude of the top of the image, before the offset.
  `ln` - longitude of the left side of the image, before the offset.
  `offset_x1` - number of pixels to move image to the right.
  `offset_y1` - number of pixels to move image down.
  `w` - width of the image, in pixels.
  `h` - height of the image, in pixels.
  `bytes` - colortable index values for the pixels.
  `colorTable` - color array corresponding to bytes
  `trans` - transparency of image.
See Also:
  `setPixel(int, int, int)`

Method Detail

### setImageIcon

    public void setImageIcon(javax.swing.ImageIcon img)

  Set the ImageIcon.

  Parameters:
    `img` - ImageIcon

### setPixel

    public boolean setPixel(int x,
                            int y,
                            int colorValue)

  Set the image pixel value at a location.

  Parameters:
    `x` - Horizontal location of pixel from left.
    `y` - Vertical location of pixel from top.
    `colorValue` - the color value of the pixel.
  Returns:
    true if x, y location valid.

### getPixel

    public int getPixel(int x,
                        int y)

  Get the image pixel value at a locaiton.

  Parameters:
    `x` - Horizontal location of pixel from left.
    `y` - Vertical location of pixel from top.
  Returns:
    the integer color value of the image at x, y

### setByte

    public boolean setByte(int x,
                           int y,
                           byte ctIndex)

  Set image byte data, for index frame using colortable.

  Parameters:
    `x` - Horizontal location of pixel from left.
    `y` - Vertical location of pixel from top.
    `ctIndex` - The array index of the applicable color in the color table.
  Returns:
    true if x, y location valid.

### getByte

    public byte getByte(int x,
                        int y)

  Get image byte data, which the index to a colortable for indexed images.

  Parameters:
    `x` - Horizontal location of pixel from left.
    `y` - Vertical location of pixel from top.
  Returns:
    byte value of bytes(x, y)

### setBits

    public void setBits(byte[] values)

  Set the bytes used to create the pixels used to create the image. Checks to see of the length matches the height * width, but doesn't do anything if they don't match, except print out a warning. Make sure it does.

  Overrides:
    `setBits` in class `OMRasterObject`
  Parameters:
    `values` - byte values containing bit pixel values.

### setTransparent

    public void setTransparent(int value)

  Set the transparency of the index type images. For the Direct Colormodel the pixel data needs to be reconstructed, so this is an O(pixels.length) operation. For an indexed colormodel, the data still needs to be reconstructed, but it will cost you the time in generate(). The transparency value should be a number between 0-255.

  Parameters:
    `value` - New value of the alpha value for the image.

### getTransparent

    public int getTransparent()

  Get the transparent setting of the image.

  Returns:
    the transparent value (0-255) of the image.

### setColors

    public void setColors(int[] values)

  Set the color table to the int RGB values passed in. Valid for the indexed colormodel only. The pixels will be colored according to these values.

  Parameters:
    `values` - array of color RGB values.

### setColors

    public void setColors(java.awt.Color[] values)

  Set the color table according to the java.awt.Color array passed in. Valid for the indexed colormodel only. The pixels will be colored according to these values. The transparency values of these colors will only take effect of they are less than the transparency value of the images' value.

  Parameters:
    `values` - array of java.awt.Color colors.

### getColors

    public int[] getColors()

  Get the array of colors used in the indexed color model. If the image is not a indexed colormodel, the int[] will be null.

  Returns:
    color int[] if index colormodel, null otherwise.

### computePixels

    protected boolean computePixels()

  Compute pixels is the function that resolves the color table into pixel integer values used in the Image. It uses the bits as indexes into the color table, and builds a big array of ints to use in the bitmap image. If the bits are null, then the object was created in the direct color model where the colors are already built into the pixels. SO, if you call this, the pixels have to be null and the bits good indexes into the colortable.

  Specified by:
    `computePixels` in class `OMRasterObject`
  Returns:
    true if the image is OK to draw after this function.

### generate

    public boolean generate(Projection proj)

  Prepare the graphics for rendering. For all image types, it positions the image relative to the projection. For direct and indexed colormodel images, it creates the ImageIcon used for drawing to the window (internal to object). For indexed colormodel images, it also calls computePixels, to resolve the colortable and the bytes to create the image pixels.

  Specified by:
    `generate` in interface `OMGeometry`
  Specified by:
    `generate` in class `OMGraphic`
  Parameters:
    `proj` - Projection used to position the image on the window.
  Returns:
    true if the image is ready to paint.
  See Also:
    `OMGraphic.regenerate(com.bbn.openmap.proj.Projection)`

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