com.bbn.openmap.omGraphics
Class OMWarpingImage

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

public class OMWarpingImage
extends OMGraphicAdapter
implements OMGraphic

An OMGraphic that wraps an ImageWarp object to display the resulting OMRaster, in any projection. For use as a background object, doesn't react to mouse events, distance queries, etc.

 try {
     String imageFile = "/data/geoimages/NBenguela.2004357.aqua.250m.jpg";
     WorldFile worldFile = WorldFile.get(PropUtils.getResourceOrFileOrURL(imageFile));
     OMWarpingImage omwi = new OMWarpingImage(imageFile, LatLonGCT.INSTANCE, worldFile);
     omList.add(omwi);
 } catch (MalformedURLException e) {
     e.printStackTrace();
 } catch (InterruptedException e) {
     e.printStackTrace();
 }
 
 try {
     String imageFile = "/data/images/earthmap4k.jpg";
     OMWarpingImage omwi = new OMWarpingImage(imageFile);
     omList.add(omwi);
 } catch (MalformedURLException e) {
     e.printStackTrace();
 } catch (InterruptedException e) {
     e.printStackTrace();
 }
 
 

Author:
dietrick
See Also:
Serialized Form

Field Summary
protected  Projection lastProjection
           
protected  OMRaster raster
           
protected  ImageWarp warp
           
 
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
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, 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
 
Constructor Summary
OMWarpingImage(java.awt.image.BufferedImage bi)
          Takes an image, assumed to be a world image in the LLXY projection (equal arc) covering -180, 180 longitude to -90, 90 latitude.
OMWarpingImage(java.awt.image.BufferedImage bi, GeoCoordTransformation transform, DataBounds imageBounds)
          Create an OMWarpingImage from a BufferedImage.
OMWarpingImage(java.awt.image.BufferedImage bi, GeoCoordTransformation transform, WorldFile worldfile)
          Create an OMWarpingImage from a BufferedImage.
OMWarpingImage(int[] pix, int width, int height)
          Takes an array of ARGB integer values representing an image, assumed to be a world image in the LLXY projection (equal arc) covering -180, 180 longitude to -90, 90 latitude.
OMWarpingImage(int[] pix, int width, int height, GeoCoordTransformation transform, DataBounds imageBounds)
          Create an OMWarpingImage from a BufferedImage.
OMWarpingImage(int[] pix, int width, int height, GeoCoordTransformation transform, WorldFile worldfile)
          Create an OMWarpingImage from a BufferedImage.
OMWarpingImage(OMScalingRaster omsr, GeoCoordTransformation transform)
          Create an OMWarpingImage from an OMScalingRaster - useful for when the projection being used on the map doesn't match the projection of the raster, and it needs to be transformed.
OMWarpingImage(java.lang.String imagePath)
          Create an OMWarpingImage from path to image (resource, file or URL).
OMWarpingImage(java.lang.String imagePath, GeoCoordTransformation transform, DataBounds imageBounds)
          Create an OMWarpingImage from path to image (resource, file or URL).
OMWarpingImage(java.lang.String imagePath, GeoCoordTransformation transform, WorldFile worldfile)
          Create an OMWarpingImage from path to image (resource, file or URL).
 
Method Summary
 boolean generate(Projection proj)
          Prepare the graphic for rendering.
 ImageWarp getWarp()
           
 void render(java.awt.Graphics g)
          Paint the graphic.
 void setWarp(java.awt.image.BufferedImage bi, GeoCoordTransformation transform, DataBounds imageBounds)
           
 void setWarp(java.awt.image.BufferedImage bi, GeoCoordTransformation transform, WorldFile worldfile)
           
 void setWarp(ImageWarp wrp)
           
 void setWarp(int[] pix, int width, int height, GeoCoordTransformation transform, DataBounds imageBounds)
          Set all the information needed.
 void setWarp(int[] pix, int width, int height, GeoCoordTransformation transform, WorldFile worldfile)
          Set all the information needed.
 void setWarp(java.lang.String imagePath, GeoCoordTransformation transform, DataBounds imageBounds)
          Set all the information needed.
 void setWarp(java.lang.String imagePath, GeoCoordTransformation transform, WorldFile worldfile)
           
protected  boolean updateImageForProjection(Projection proj)
          Called from within generate.
 
Methods inherited from class com.bbn.openmap.omGraphics.OMGraphicAdapter
clone, deselect, distance, getDeclutterType, getDisplayColor, getDisplayPaint, getEdgeMatchesFill, getFillColor, getFillPaint, getHasLabel, getLineColor, getLinePaint, getMattingPaint, getRenderType, getSelectColor, getSelectPaint, getShowEditablePalette, getStroke, getTextureMask, hasLineTypeChoice, initLabelingDuringGenerate, isClear, isMatted, isSelected, normalizeDistanceForLineWidth, readStroke, regenerate, renderLabel, restore, select, setDeclutterType, setEdgeMatchesFill, setFillColor, setFillPaint, setGraphicsColor, setGraphicsForEdge, setGraphicsForFill, setHasLabel, setLabelLocation, setLabelLocation, setLabelLocation, setLabelLocation, setLineColor, setLinePaint, setMatted, setMattingPaint, setRenderType, setSelectColor, setSelected, setSelectPaint, setShape, setShowEditablePalette, setStroke, setTextureMask, shouldRenderEdge, shouldRenderFill, writeStroke
 
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, getDescription, 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.OMGraphic
clone, deselect, getDeclutterType, getDisplayColor, getDisplayPaint, getFillColor, getFillPaint, getLineColor, getLinePaint, getMattingPaint, getRenderType, getSelectColor, getSelectPaint, getShowEditablePalette, getStroke, getTextureMask, hasLineTypeChoice, isMatted, isSelected, normalizeDistanceForLineWidth, regenerate, renderLabel, select, setDeclutterType, setFillPaint, setGraphicsColor, setGraphicsForEdge, setGraphicsForFill, setLabelLocation, setLabelLocation, setLabelLocation, setLinePaint, setMatted, setMattingPaint, setRenderType, setSelected, setSelectPaint, setShowEditablePalette, setStroke, setTextureMask, shouldRenderEdge, shouldRenderFill
 
Methods inherited from interface com.bbn.openmap.omGraphics.OMGeometry
clearAttributes, contains, distance, distanceToEdge, draw, fill, getAppObject, getAttribute, getAttributes, getDescription, getLineType, getNeedToRegenerate, getShape, isRenderable, isVisible, putAttribute, removeAttribute, restore, setAppObject, setAttributes, setLineType, setNeedToRegenerate, setShape, setVisible
 

Field Detail

warp

protected ImageWarp warp

raster

protected OMRaster raster

lastProjection

protected Projection lastProjection
Constructor Detail

OMWarpingImage

public OMWarpingImage(java.lang.String imagePath)
               throws java.net.MalformedURLException,
                      java.lang.InterruptedException
Create an OMWarpingImage from path to image (resource, file or URL).

Parameters:
imagePath -
Throws:
java.net.MalformedURLException
java.lang.InterruptedException

OMWarpingImage

public OMWarpingImage(java.lang.String imagePath,
                      GeoCoordTransformation transform,
                      DataBounds imageBounds)
               throws java.net.MalformedURLException,
                      java.lang.InterruptedException
Create an OMWarpingImage from path to image (resource, file or URL).

Parameters:
imagePath -
transform - the transform describing the image's projection.
imageBounds - the bounds of the image, in its coordinate system.
Throws:
java.net.MalformedURLException
java.lang.InterruptedException

OMWarpingImage

public OMWarpingImage(java.lang.String imagePath,
                      GeoCoordTransformation transform,
                      WorldFile worldfile)
               throws java.net.MalformedURLException,
                      java.lang.InterruptedException
Create an OMWarpingImage from path to image (resource, file or URL).

Parameters:
imagePath -
transform - transform the transform describing the image's projection.
worldfile - The WorldFile describing the image's location.
Throws:
java.net.MalformedURLException
java.lang.InterruptedException

OMWarpingImage

public OMWarpingImage(java.awt.image.BufferedImage bi)
Takes an image, assumed to be a world image in the LLXY projection (equal arc) covering -180, 180 longitude to -90, 90 latitude.

Parameters:
bi -

OMWarpingImage

public OMWarpingImage(java.awt.image.BufferedImage bi,
                      GeoCoordTransformation transform,
                      DataBounds imageBounds)
Create an OMWarpingImage from a BufferedImage.

Parameters:
bi - a BufferedImage
transform - the transform describing the image's projection.
imageBounds - the bounds of the image, in its coordinate system.
Throws:
java.net.MalformedURLException
java.lang.InterruptedException

OMWarpingImage

public OMWarpingImage(java.awt.image.BufferedImage bi,
                      GeoCoordTransformation transform,
                      WorldFile worldfile)
Create an OMWarpingImage from a BufferedImage.

Parameters:
bi - BufferedImage
transform - transform the transform describing the image's projection.
worldfile - The WorldFile describing the image's location.
Throws:
java.net.MalformedURLException
java.lang.InterruptedException

OMWarpingImage

public OMWarpingImage(int[] pix,
                      int width,
                      int height)
Takes an array of ARGB integer values representing an image, assumed to be a world image in the LLXY projection (equal arc) covering -180, 180 longitude to -90, 90 latitude.

Parameters:
pix - int[] ARGB pixel array for image
width - pixel width of image
height - pixel height of image

OMWarpingImage

public OMWarpingImage(int[] pix,
                      int width,
                      int height,
                      GeoCoordTransformation transform,
                      DataBounds imageBounds)
Create an OMWarpingImage from a BufferedImage.

Parameters:
pix - int[] ARGB pixel array for image
width - pixel width of image
height - pixel height of image
transform - the transform describing the image's projection.
imageBounds - the bounds of the image, in its coordinate system.

OMWarpingImage

public OMWarpingImage(int[] pix,
                      int width,
                      int height,
                      GeoCoordTransformation transform,
                      WorldFile worldfile)
Create an OMWarpingImage from a BufferedImage.

Parameters:
pix - int[] ARGB pixel array for image
width - pixel width of image
height - pixel height of image
transform - transform the transform describing the image's projection.
worldfile - The WorldFile describing the image's location.

OMWarpingImage

public OMWarpingImage(OMScalingRaster omsr,
                      GeoCoordTransformation transform)
Create an OMWarpingImage from an OMScalingRaster - useful for when the projection being used on the map doesn't match the projection of the raster, and it needs to be transformed. The OMScalingRaster is in an equal-arc projection (CADRG or LLXY).

Parameters:
omsr - OMScalingRaster
transform - a GeoCoordTransform if the OMScalingRaster image isn't a WGS84 image.
Method Detail

setWarp

public void setWarp(java.lang.String imagePath,
                    GeoCoordTransformation transform,
                    DataBounds imageBounds)
             throws java.net.MalformedURLException,
                    java.lang.InterruptedException
Set all the information needed.

Parameters:
imagePath -
transform -
imageBounds -
Throws:
java.net.MalformedURLException
java.lang.InterruptedException

setWarp

public void setWarp(java.lang.String imagePath,
                    GeoCoordTransformation transform,
                    WorldFile worldfile)
             throws java.net.MalformedURLException,
                    java.lang.InterruptedException
Throws:
java.net.MalformedURLException
java.lang.InterruptedException

setWarp

public void setWarp(int[] pix,
                    int width,
                    int height,
                    GeoCoordTransformation transform,
                    DataBounds imageBounds)
Set all the information needed.

Parameters:
pix - int[] ARGB pixel array for image
width - pixel width of image
height - pixel height of image
transform -
imageBounds -

setWarp

public void setWarp(int[] pix,
                    int width,
                    int height,
                    GeoCoordTransformation transform,
                    WorldFile worldfile)
Set all the information needed.

Parameters:
pix - int[] ARGB pixel array for image
width - pixel width of image
height - pixel height of image
transform -
worldfile - describes projection of image

setWarp

public void setWarp(java.awt.image.BufferedImage bi,
                    GeoCoordTransformation transform,
                    DataBounds imageBounds)

setWarp

public void setWarp(java.awt.image.BufferedImage bi,
                    GeoCoordTransformation transform,
                    WorldFile worldfile)

setWarp

public void setWarp(ImageWarp wrp)

getWarp

public ImageWarp getWarp()

generate

public boolean generate(Projection proj)
Description copied from class: OMGraphicAdapter
Prepare the graphic for rendering. This must be done before calling render()! If a vector graphic has lat-lon components, then we project these vertices into x-y space. For raster graphics we prepare in a different fashion.

If the generate is unsuccessful, it's usually because of some oversight, (for instance if proj is null), and if debugging is enabled, a message may be output to the controlling terminal.

Specified by:
generate in interface OMGeometry
Specified by:
generate in class OMGraphicAdapter
Parameters:
proj - Projection
Returns:
boolean true if successful, false if not.
See Also:
OMGraphicAdapter.regenerate(com.bbn.openmap.proj.Projection)

updateImageForProjection

protected boolean updateImageForProjection(Projection proj)
Called from within generate. Some render buffering calls generate to make sure the latest projection is called on an OMGraphic before it's put into a buffer. We're keeping track of the last projection used to generate the warped image, and if it's the same, don't bother regenerating, use the raster we have.

Parameters:
proj - current projection.
Returns:
false if the rest of generate() should be skipped.

render

public void render(java.awt.Graphics g)
Description copied from class: OMGraphicAdapter
Paint the graphic. This paints the graphic into the Graphics context. This is similar to paint() function of java.awt.Components. Note that if the graphic has not been generated, it will not be rendered.

This method used to be abstract, but with the conversion of OMGraphics to internally represent themselves as java.awt.Shape objects, it's a more generic method. If the OMGraphic hasn't been updated to use Shape objects, it should have its own render method.

Specified by:
render in interface OMGeometry
Overrides:
render in class OMGraphicAdapter
Parameters:
g - Graphics2D context to render into.


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