I am trying to take advantage of the existing SimpleHttpImageServer for generating map images on a server (that get sent to a client application). I am trying to add the customization of land and border color. So, I extended MapRequestHandler and overrode createImage (listed below) to change the layer properties doe fillColor and lineColor. I does not seem to work unless the projection is changed via a zoom/pan. So, if I make a request for a new map, it gets returned with the same colors, but once I zoom/pan I see the change. Is there something else I can do to the layer to force the projection to be regenerated inturn displaying the new color(s)? What am I missing here?
public byte[] createImage(Projection proj, int scaledWidth,
int scaledHeight, Vector showLayers, String landColor, String borderColor) {
Debug.message("imageserver",
"ImageServer: using the new ProjectionPainter interface! createImage with layer string array. ");
if (formatter == null) {
Debug.error("ImageServer.createImage: no formatter set! Can't create image.");
return new byte[0];
}
ImageFormatter imageFormatter = formatter.makeClone();
java.awt.Graphics graphics = createGraphics(imageFormatter,
proj.getWidth(),
proj.getHeight());
if (graphics == null) {
return new byte[0];
}
((Proj) proj).drawBackground((Graphics2D) graphics, background);
int size = showLayers.size();
if (showLayers != null) {
for (int j = size - 1; j >= 0; j--) {
for (int i = layers.length - 1; i >= 0; i--) {
String layerName = (String) showLayers.elementAt(j);
Layer layer = layers[i];
//Set the land and border color
Properties p = new Properties();
layer.getProperties(p);
p.setProperty("shapePolitical.fillColor", landColor);
p.setProperty("shapePolitical.lineColor", borderColor);
layer.setProperties(p);
if (layerName.equals(layer.getPropertyPrefix())) {
layer.renderDataForProjection(proj, graphics);
layer.repaint();
if (Debug.debugging("imageserver")) {
Debug.output("ImageServer: image request adding layer graphics from : "
+ layer.getName());
}
}
}
}
} else if (Debug.debugging("imageserver")) {
Debug.output("ImageServer: no layers available for image");
}
byte[] formattedImage = getFormattedImage(imageFormatter,
scaledWidth,
scaledHeight);
graphics.dispose();
return formattedImage;
}
Philip V. Monte
Software Engineer
Code 2514, Warfare Interoperability Branch
NAVSEA Warfare Centers Division Newport
(401) 832-5325
--
[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 Wed Jul 12 2006 - 14:32:09 EDT