[OpenMap Users] Possible bug in Layer subclasses

From: Sperlongano Brian M NPRI <SperlonganoBM_at_Npt.NUWC.Navy.Mil>
Date: Fri, 24 Sep 2004 15:35:02 -0400

Hello all,
I believe I have found a bug in the way layer rendering is implemented. I was using the ImageServer class to generate off-screen images for printing, and what I discovered was that the way ImageServer works is to call the renderDataForProjection() method on each of a set of layers onto a Graphics object.
One of the things that these implementations do (at least for OMGraphicHandlerLayer and GraticuleLayer, probably all of them) is to set the passed in projection as the new projection.
As an example of this, here is a clip from OMGraphicHandlerLayer:
    public synchronized void renderDataForProjection(Projection proj, Graphics g) {
        if (proj == null) {
            Debug.error("Layer(" + getName() +
                        ").renderDataForProjection: null projection!");
        } else if (!proj.equals(getProjection())) {
Note the line that says "setProjection(proj.makeClone())".
Now, if were were only using the layers on a MapBean, this would be fine. The problem comes when we use existing layers to render to projections other than the ones on the current map. Thus, say I have a 200x200 MapBean, but I wish to (off-screen) render a 400x400 version of the same map. I would create a Projection object with those parameters, and then pass it through renderDataForProjection. The Layer would then render my 400x400 map no problem. However, it would also store my 400x400 projection as the current projection. This results in display artifacts being shown in the container containing the MapBean.
It seems to me that the offending setProjection() lines should be removed. I commented out those lines in the layers I use and the bug seems to go away AND the map seemed to function all the same.
The other option would be to make sure that any class that used Layer in this manner (such as ImageServer) be modified to save the current Projection, render, and the set the old projection back, but this is clearly a less-desireable solution.
Brian Sperlongano
Computer Engineer

[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 Sep 24 2004 - 15:41:45 EDT

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