RE: [OpenMap Users] repainting issues in openmap 4.6.2

From: Butler, Jason <>
Date: Mon, 23 Jan 2006 11:09:56 +1030

Hi Don,

Yes, The layers that are not repainting are layers that I have written.
The custom layer extends the Layer classs.

The projectionChanged method code is as follows:

  public void projectionChanged(com.bbn.openmap.event.ProjectionEvent
    if(setProjection(theEvent) == null)
      //Nothing to do, already have it and have acted on it
    Projection proj = this.getProjection();
    //set the image to be painted to be null until the SwingWorker
returns the completed new image

Instead of storing my graphics in a OMGraphicList, I store it in a
BufferedImage that gets copied to the screen each time a paint occurs.
The BufferedImage is then recalculated when a projection change occurs.

The missing layer does reappear when a zoom or pan occurs. The redraw
problem seems to be random in its frequency. Sometimes the redraw works
correctly for several times, then the layer fails to redraw on and off
(opposite to the graticle being drawn) then the problem goes away again
for a while.

The layers are being manged by the mapbean that has a LayerHandler
component. I think I am initialising it correctly, but to be on the safe
side, here is the code.

   * This creates a map for OpenMap 4.6.
  public OpenMap(PropertyHandler propertyHandler)
    //create a map panel and initialise it from the properties
    BasicMapPanel mapPanel = new BasicMapPanel(propertyHandler,true);
    //Create the application window that holds the MapPanel, and
    //the MapBean
    omf = new OpenMapFrame();
    mapBean = mapPanel.getMapBean();
    mapBean.setBorder(new BevelBorder(BevelBorder.LOWERED));
    JSplitPane mainDisplay = null;
    beanHandler = mapPanel.getMapHandler();

    //create a frame since dialogs don't generate a button in windows
task bar
    Frame startFrame = new Frame();
    startFrame.setTitle("Starting Tobmap");
      //create singleton MapResources object.
      mapResources = MapResourcesSingleton.getInstance();
      //create dialog box to setup database connection pool for data
      setOpenApplicationDialog(propertyHandler, startFrame);
      //show the TOBMap splash screen
      //Read the previous scenario properties from the database.
      //Set a flag that will trigger the PropertyHandler to fire
      //progress events when it is going through the creation process.
      //Creates the layout manager for this container and create the
      //Add the mapPanel to the OpenMap Frame
      // Initialize the map projection, scale, center with user prefs or
      Projection proj = recallPreviousProjectionSize();

      //Set the OpenMapFrame bounds - x,y position, width, height - that
were stored in the preferences
TOBPrefs.getInt(PREF_FRAME_Y, 0),
              TOBPrefs.getInt(PREF_FRAME_WIDTH, 10),
TOBPrefs.getInt(PREF_FRAME_HEIGHT, 10));
      //Set the MapHandler in MapResources. Initiate mouse delegators
and modes.
      //Make the display of split into the layer control panel and the
      mainDisplay = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
mapResources.getLayersCtrlPanel(), mapBean);
      //Add mainDisplay component to mapPanel
      mapPanel.add("Center", mainDisplay);
      //Override the File Menu to add database handling
      setFileMenu(mapPanel.getMapBean().getRootPane(), propertyHandler);
    catch (MultipleSoloMapComponentException msmce)
      Debug.error("OpenMapNG: tried to add multiple components of the
same type when only one is allowed! - " + msmce);
    //Go through layers and for all that have their autopalette variable
    //turned on, show their palettes.
    //Hide the start splash screen
    //JB: added this to get frame to properly redraw.
    //invoke after regaining swing thread to stop swing repaint errors
due to multithreading issues
    SwingUtilities.invokeLater(new Runnable()
      public void run()

Best regards,

Jason Butler

-----Original Message-----
From: Don Dietrick []
Sent: Friday, January 20, 2006 10:51 PM
To: Butler, Jason
Subject: Re: [OpenMap Users] repainting issues in openmap 4.6.2

Hi Jason,

So the layers that are not repainting are layers that you've
written? What's going on in those layers' projectionChanged method?
Do they show up if you pan or zoom after removing the Graticule layer?
Is this in the OpenMap application (with a LayerHandler) or are you
managing the layers with your own code?

- Don

On Jan 20, 2006, at 1:32 AM, Butler, Jason wrote:

> Hi all,
> I am experiencing some odd behaviour in openmap 4.6.2. It seems to be
> failing to repaint some of my layers when other layers are being
> switched off.
> For example, I am showing a custom layer "under" a graticle layer, and

> switch off the graticlue layer, and some of the time the layer
> "disappears" from the map window, even though it is still on in the
> layer window.
> I have tried to track down the cause of this, but have failed to do
> so. It seems to be occuring during the mapbeans repaint. The mapbean's

> method repaintChildrenWithBorders is called, and it then goes into the

> super class JComponent to do the paintChildren method, but the
> JComponent.paintChildren method fails to call the paint method of the
> custom layer.
> Is there some sort of flag I need to be setting to indicate that the
> layers paint has finished each time?
> The behaviour of the layers paint method is simply to copy an image
> buffer into the Graphic Context, and is doing no extra processing, so
> it should be very quick to complete its repaint.
> Has anyone else encountered this when developing their own layers?
> How did you solve this issue?
> The version of java I am using is jse 1.4.2_04, but the behaviour is
> also ocurring when running under jse 1.5.0_06.
> Thanks in advance for any suggestions you might have,
> Best regards,
> Jason Butler.

[To unsubscribe to this list send an email to ""
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Sun Jan 22 2006 - 20:03:14 EST

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