com.bbn.openmap.omGraphics
Class OMBitmap

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

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/interfaces 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, logger, lon, needToReposition, pixels, point1, point2, renderRotationAngle, rotationAngle, SMOOTH_SCALING, width, x, y
 
Fields inherited from class com.bbn.openmap.omGraphics.OMGraphicAdapter
declutterType, displayPaint, edgeMatchesFill, fillPaint, hasLabel, linePaint, matted, mattingPaint, renderType, selected, selectPaint, showEditablePalette, stroke, textureMask
 
Fields inherited from class com.bbn.openmap.omGraphics.geom.BasicGeometry
attributes, lineType, needToRegenerate, shape, visible
 
Fields inherited from interface com.bbn.openmap.omGraphics.OMGraphicConstants
ADD_GRAPHIC_MASK, APP_OBJECT, 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, INDEX, INFOLINE, LABEL, LINETYPE_GREATCIRCLE, LINETYPE_RHUMB, LINETYPE_STRAIGHT, LINETYPE_UNKNOWN, LOWER_GRAPHIC_MASK, LOWER_TO_BOTTOM_GRAPHIC_MASK, NO_ROTATE, OMGRAPHIC_ELT, OMGRAPHIC_TYPE_ATTR, 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, UPDATED
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
OMBitmap()
          Create empty, and add parameters later.
OMBitmap(double lt, double ln, int w, int h, byte[] bytes)
          Created a OMBitmap with a Lat/lon placement.
OMBitmap(double lt, double 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  int[] computePixels(byte[] bits)
          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
adjustShapeForRotation, filterImage, getBits, getColorModel, getFilteredHeight, getFilteredWidth, getHeight, getImage, getImageFilter, getLat, getLon, getMapLocation, getNeedToReposition, getPixels, getRotationAngle, getWidth, getX, getY, hasLineTypeChoice, imageUpdate, position, regenerate, render, renderImage, restore, rotate, scaleTo, setColorModel, setHeight, setImage, setImageFilter, setLat, setLon, setNeedToReposition, setPixels, setRotationAngle, setShape, setWidth, setX, setY, shouldRenderFill
 
Methods inherited from class com.bbn.openmap.omGraphics.OMGraphicAdapter
clone, distance, getDeclutterType, getDisplayColor, getDisplayPaint, getEdgeMatchesFill, getFillColor, getFillPaint, getHasLabel, getLineColor, getLinePaint, getMattingPaint, getRenderType, getSelectColor, getSelectPaint, getShowEditablePalette, getStroke, getTextureMask, initLabelingDuringGenerate, isClear, isMatted, isSelected, normalizeDistanceForLineWidth, readStroke, readTextureMask, renderLabel, renderShape, setDeclutterType, setEdgeMatchesFill, setFillColor, setGraphicsColor, setGraphicsForEdge, setGraphicsForFill, setHasLabel, setLabelLocation, setLabelLocation, setLabelLocation, setLabelLocation, setLabelLocation, setLabelLocation, setLabelLocation, setLabelLocation, setLineColor, setMatted, setMattingPaint, setRenderType, setSelectColor, setSelected, setShowEditablePalette, setStroke, setTextureMask, shouldRenderEdge, writeStroke, writeTextureMask
 
Methods inherited from class com.bbn.openmap.omGraphics.geom.BasicGeometry
_distance, appendShapeEdge, appendShapeEdge, appendShapeEdge, appendShapeEdge, clearAttributes, contains, createAttributeMap, createBoxShape, createShape, createShape, describeShapeDetail, describeShapeDetail, distanceToEdge, distanceToEdge, draw, draw, fill, fill, getAppObject, getAttribute, getAttributes, getDescription, getLineType, getNeedToRegenerate, getShape, isRenderable, isRenderable, isVisible, putAttribute, removeAttribute, setAppObject, setAttributes, setLineType, setNeedToRegenerate, setShape, 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.OMGraphic
clone, getDeclutterType, getDisplayColor, getDisplayPaint, getFillColor, getFillPaint, getLineColor, getLinePaint, getMattingPaint, getRenderType, getSelectColor, getSelectPaint, getShowEditablePalette, getStroke, getTextureMask, isMatted, isSelected, normalizeDistanceForLineWidth, renderLabel, setDeclutterType, setGraphicsColor, setGraphicsForEdge, setGraphicsForFill, setLabelLocation, setLabelLocation, setLabelLocation, setMatted, setMattingPaint, setRenderType, setSelected, setShowEditablePalette, setStroke, setTextureMask, shouldRenderEdge
 
Methods inherited from interface com.bbn.openmap.omGraphics.OMGeometry
clearAttributes, contains, distance, distanceToEdge, draw, draw, fill, fill, getAppObject, getAttribute, getAttributes, getDescription, getLineType, getNeedToRegenerate, getShape, isRenderable, isRenderable, isVisible, putAttribute, removeAttribute, setAppObject, setAttributes, setLineType, setNeedToRegenerate, setShape, setVisible
 

Constructor Detail

OMBitmap

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


OMBitmap

public OMBitmap(double lt,
                double 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(double lt,
                double 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 int[] computePixels(byte[] bits)
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 OMGraphicAdapter
Parameters:
proj - Projection
Returns:
true if the OMBitmap has enough information and generates the rendered image successfully.
See Also:
OMGraphicAdapter.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.

Specified by:
setLinePaint in interface OMGraphic
Overrides:
setLinePaint in class OMGraphicAdapter
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.

Specified by:
setSelectPaint in interface OMGraphic
Overrides:
setSelectPaint in class OMGraphicAdapter
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.

Specified by:
setFillPaint in interface OMGraphic
Overrides:
setFillPaint in class OMGraphicAdapter
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
Specified by:
select in interface OMGraphic
Overrides:
select in class OMGraphicAdapter

deselect

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

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


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