Re: [OpenMap Users] ImageServer/MapRequestHandler (Newbie Question)

From: Don Dietrick <dietrick_at_bbn.com>
Date: Wed, 12 Jul 2006 22:53:12 -0400

Hi Philip,

Setting the drawing attributes on the layer via the properties will
only set the DrawingAttributes object for when OMGraphics are
created. If you want to change the OMGraphics that have already been
created, you need to change the settings directly on them. If you
are extending an OMGraphicHandlerLayer, you can call getList() on the
layer to get its OMGraphicList, and then set the colors directly on
that list (or on specific OMGraphics). If the projection changes, it
sounds like the layer you are using will revert back to the
DrawingAttributes settings, so you'll want to change those, too.

I think what's happening is that you are telling the layer to render
data for a projection, and it thinks it's already got what it needs,
so it paints the OMGraphics it has, without adjusting the colors or
rebuilding them. When you pan/zoom, the layer is rebuilding them
from the data, and you see the changes.

- Don



On Jul 12, 2006, at 1:44 PM, Monte Philip V NPRI wrote:

> 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 - 22:53:31 EDT

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