Not sure if this can be done a different way, but I'm including source
for a very trivial layer that really just supports programmatic
addition/deletion of simple bitmaps to a layer. (Very similar to the
com.bbn.openmap.plugin.CSVTiledImagePlugin except that you can add files
in dynamically).
CVSTiledImagePlugin would have been fine for my requirements, except I
couldn't dynamically add images, and was restricted to using files to
load images. Perhaps, a refactor of CSVTiledImagePlugin would be better?
Perhaps something like, "GenericImagePlugin" and subclass
"CVSTiledImagePlugin"? (Where GenericImagePlugin allows programmatic
dynamic addition/deletion of images to the layer and CSVTiledImagePlugin
simply uses a constructor file property based initialisation?)
If it's worth doing, reply to this and I'll submit a proper patch.
Moreover, I'm looking into the OMScalingRaster to see if a pre-generated
mip mapped approach would be faster for 2d blits. (ie. for example, in
our instance, the 64MB OMScalingRaster takes a good 2 seconds to render
when zoomed out. I'm guessing this is due to having to blit the entire
thing down to a small area. A pre-generated mipmap would reduce the
data size to a small single digit percentage of the entire bitmap). If
it speeds things up, I'll submit a patch for this too.
Apologies if this is in the wrong area.
Cheers
Tom.
/**
* This class is a very naive implementation of a bitmap rendering
layer. It simply invokes
* the generate methods of the OMScalingRaster instances contained. The
OMScalingRaster instances
* do not (seem) to do any smarts with mip mapping, or hierarchical
tiled rendering.
* _at_author txs
*/
public class BitmapLayer extends OMGraphicHandlerLayer {
ArrayList<OMScalingRaster> m_aryImgs=new
ArrayList<OMScalingRaster>();
/**
* This adds an image to the layer and returns a handle to the image
raster
* _at_throws IOException
*/
public OMScalingRaster addImage(String strFilePath, LatLonPoint
latlonTopLeft, LatLonPoint latlonBotRight)throws IOException{
File fileImg=new java.io.File(strFilePath);
FileInputStream fisImg=new FileInputStream(fileImg);
FileCacheImageInputStream fciis = new
FileCacheImageInputStream(fisImg, null);
BufferedImage bufImg = ImageIO.read(fciis);
OMScalingRaster rasterImg=new
OMScalingRaster(latlonTopLeft.getLatitude(), latlonTopLeft.getLongitude(),
latlonBotRight.getLatitude(), latlonBotRight.getLongitude(),
bufImg);
m_aryImgs.add(rasterImg);
return(rasterImg);
}
/**
* Removes the specified OMScalingRaster image from the layer if it
has been added
* _at_param rasterImg
*/
public void removeImage(OMScalingRaster rasterImg){
m_aryImgs.remove(rasterImg);
}
/* (non-Javadoc)
* _at_see com.bbn.openmap.layer.OMGraphicHandlerLayer#prepare()
*/
public synchronized OMGraphicList prepare(){
OMGraphicList list=super.prepare();
Projection proj=getProjection();
// iterate through the entire array
if(list==null)
list=new OMGraphicList();
for(int iImg=0; iImg<m_aryImgs.size(); ++iImg){
OMScalingRaster rasterImg=m_aryImgs.get(iImg);
if(rasterImg.isOnMap(proj)){
rasterImg.generate(proj);
list.add(rasterImg);
}
}
return(list);
}
}
--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Fri Jun 16 2006 - 01:56:33 EDT