com.bbn.openmap.omGraphics
Class OMBitmap

java.lang.Object
  extended bycom.bbn.openmap.omGraphics.geom.BasicGeometry
      extended bycom.bbn.openmap.omGraphics.OMGraphic
          extended bycom.bbn.openmap.omGraphics.OMRasterObject
              extended bycom.bbn.openmap.omGraphics.OMBitmap
All Implemented Interfaces:
java.lang.Cloneable, java.awt.image.ImageObserver, OMGeometry, OMGraphicConstants, java.io.Serializable

public class OMBitmap
extends OMRasterObject
implements java.io.Serializable

The OMBitmap lets you create a two color image. The display color is the foreground color, and the fill color is the background color. OMColors can be used, and their transparency values will be implemented.

The array of bytes is used to create the picture. Each bit, representing a pixel, is examined, and the color is set to the display or fill color, depending on the bit value. There isn't a height and width restriction on OMBitmaps, but you do have to be careful about the byte array that is used for one. The OMBitmap is based on an X bitmap, not a Windows bmp file. Again, each bit of the bytes corresponds to a pixel. If the height and/or width of the bitmap isn't a multiple of 8, you have to round up the number of bytes used so that the excess bits are covered in that extra byte for the row.

So, for a 4x4 bitmap, you need:

 
 
  ooooxxxx|ooooxxxx|ooooxxxx|ooooxxxx -> 1 by 4 bytes, 4 bytes total
 
  
 
where x's are the bits being used for the bitmap ( and whether they are 1 or 0 dictates either foreground or background color), and o's are the leftover bits (they are ignored). The '|' are byte boundaries.

The bits, per byte, look like they are used in reverse order because they are - least significant bit, per byte, is used in that order.

For a 6x6 bitmap:

 
 ooxxxxxx|ooxxxxxx|ooxxxxxx|ooxxxxxx|ooxxxxxx|ooxxxxxx -> 1 x 6
 bytes, 6 bytes total
 
 
for a 10x10 bitmap:
 
 xxxxxxxx|ooooooxx|xxxxxxxx|ooooooxx|xxxxxxxx|ooooooxx|xxxxxxxx|ooooooxx|xxxxxxxx|ooooooxx|xxxxxxxx|ooooooxx|xxxxxxxx|ooooooxx|xxxxxxxx|ooooooxx|xxxxxxxx|ooooooxx|xxxxxxxx|ooooooxx ->
 2 by 10 bytes, 20 bytes total
 
 
There is the ability to add a filter to the OMBitmap, 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.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class com.bbn.openmap.omGraphics.OMRasterObject
OMRasterObject.TrimScaleFilter
 
Field Summary
 
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
OMBitmap()
          Create empty, and add parameters later.
OMBitmap(float lt, float ln, int w, int h, byte[] bytes)
          Created a OMBitmap with a Lat/lon placement.
OMBitmap(float lt, float ln, int offset_x1, int offset_y1, int w, int h, byte[] bytes)
          Create an OMBitmap, located at a Lat/lon with a X/Y offset placement.
OMBitmap(int x1, int y1, int w, int h, byte[] bytes)
          Create an OMBitmap with a X/Y window placement.
 
Method Summary
protected  boolean computePixels()
          Create the image pixels from the display color and the fill color values, and the bitmap bytes.
 void deselect()
          Set the selected attribute to false, sets the color to the line color.
 boolean generate(Projection proj)
          Create the rendered image from the pixel values.
 void select()
          Set the selected attribute to true, and sets the color to the select color.
 void setBits(byte[] values)
          Set the bytes used to create the pixels used to create the image.
 void setFillPaint(java.awt.Paint value)
          This sets the bitmap to recompute the pixels if the background color is changed.
 void setLinePaint(java.awt.Paint value)
          This sets the bitmap to recompute the pixels if the foreground paint is changed.
 void setSelectPaint(java.awt.Paint value)
          This sets the bitmap to recompute the pixels if the foreground paint is changed.
 
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, 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, setDeclutterType, setEdgeMatchesFill, setFillColor, setGraphicsColor, setGraphicsForEdge, setGraphicsForFill, setHasLabel, setLabelLocation, setLabelLocation, setLabelLocation, setLineColor, setMatted, setMattingPaint, setRenderType, setSelectColor, setSelected, 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
 

Constructor Detail

OMBitmap

public OMBitmap()
Create empty, and add parameters later.


OMBitmap

public OMBitmap(float lt,
                float ln,
                int w,
                int h,
                byte[] bytes)
Created a OMBitmap with a Lat/lon placement.

Parameters:
lt - latitude of upper left corner of bitmap.
ln - longitude of upper left corner of bitmap.
w - width of bitmap.
h - height of bitmap.
bytes - byte array of bitmap, each bit representing a pixel.

OMBitmap

public OMBitmap(int x1,
                int y1,
                int w,
                int h,
                byte[] bytes)
Create an OMBitmap with a X/Y window placement.

Parameters:
x1 - window pixel x location of upper left corner of bitmap.
y1 - window pixel y location of upper left corner of bitmap.
w - width of bitmap.
h - height of bitmap.
bytes - byte array of bitmap, each bit representing a pixel.

OMBitmap

public OMBitmap(float lt,
                float ln,
                int offset_x1,
                int offset_y1,
                int w,
                int h,
                byte[] bytes)
Create an OMBitmap, located at a Lat/lon with a X/Y offset placement.

Parameters:
lt - latitude of upper left corner of bitmap.
ln - longitude of upper left corner of bitmap.
offset_x1 - window pixel x location from ln of upper left corner of bitmap.
offset_y1 - window pixel y location from lt of upper left corner of bitmap.
w - width of bitmap.
h - height of bitmap.
bytes - byte array of bitmap, each bit representing a pixel.
Method Detail

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*8 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.

computePixels

protected boolean computePixels()
Create the image pixels from the display color and the fill color values, and the bitmap bytes. All of these attributes should have been filled in.

Specified by:
computePixels in class OMRasterObject
Returns:
true if the pixels were successfully created.

generate

public boolean generate(Projection proj)
Create the rendered image from the pixel values.

Specified by:
generate in interface OMGeometry
Specified by:
generate in class OMGraphic
Parameters:
proj - Projection
Returns:
true if the OMBitmap has enough information and generates the rendered image successfully.
See Also:
OMGraphic.regenerate(com.bbn.openmap.proj.Projection)

setLinePaint

public void setLinePaint(java.awt.Paint value)
This sets the bitmap to recompute the pixels if the foreground paint is changed.

Overrides:
setLinePaint in class OMGraphic
Parameters:
value - the new line color.

setSelectPaint

public void setSelectPaint(java.awt.Paint value)
This sets the bitmap to recompute the pixels if the foreground paint is changed.

Overrides:
setSelectPaint in class OMGraphic
Parameters:
value - the new select color.

setFillPaint

public void setFillPaint(java.awt.Paint value)
This sets the bitmap to recompute the pixels if the background color is changed.

Overrides:
setFillPaint in class OMGraphic
Parameters:
value - the new background color

select

public void select()
Set the selected attribute to true, and sets the color to the select color.

Specified by:
select in interface OMGeometry
Overrides:
select in class OMGraphic

deselect

public void deselect()
Set the selected attribute to false, sets the color to the line color.

Specified by:
deselect in interface OMGeometry
Overrides:
deselect in class OMGraphic


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