[OpenMap Users] Writing map to an image

From: Jay D. Askren <jda_at_quantumleap.us>
Date: Fri, 24 Aug 2007 12:19:51 -0400

I need to write a map to an image. I do it as follows:

 

Projection proj = ProjectionFactory.makeProjection(LLXYView.class,

                  centerLat, centerLon, scale, width, height);

_mapBean.setProjection(proj);

BufferedImage currentImage = new BufferedImage(width, height,
BufferedImage.TYPE_4BYTE_ABGR);

try{

      Thread.sleep(200);

}catch (Exception e){

      e.printStackTrace();

}

Layer[] layers = _layerHandler.getMapLayers();

for (int i = 0; i < layers.length; i++) {

      layers[i].renderDataForProjection(proj,
currentImage.getGraphics());

}

 

 

I have the Thread.sleep(200) in there because it appears if I don't let
the thread sleep, open map sometimes does not have enough time to render
the layers, and the may image come out blank or with only some of the
layers drawn. The problem is that I don't know how long to sleep. It
varies depending on how hefty the layers are. Is there a way to tell
when the layers are done painting? I really would like to block until
the layer threads are done painting. Thanks.

 

 

Jay

 



--
[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 Aug 24 2007 - 12:17:14 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:08 EDT