Re: [OpenMap Users] repainting issues in openmap 4.6.2

From: Don Dietrick <dietrick_at_bbn.com>
Date: Sun, 22 Jan 2006 21:50:56 -0500

Hi Jason,

On Jan 22, 2006, at 7:39 PM, Butler, Jason wrote:

> 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
> theEvent)
> {
> if(setProjection(theEvent) == null)
> {
> //Nothing to do, already have it and have acted on it
> return;


Actually, you need to call repaint() here. If your layer is the only
one on the map, you need to have something calling repaint on the
MapBean. You can check out the
com.bbn.openmap.layer.policy.StandardPCPolicy for notes. The policy
objects really only affect OMGraphicHandlerLayers, but you get the
idea...

- Don

> }
>
> Projection proj = this.getProjection();
>
> //set the image to be painted to be null until the SwingWorker
> returns the completed new image
> setImage(null);
> doPrepare();
> }
>
> 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
> eventually
> //the MapBean
> omf = new OpenMapFrame();
> setWindowListenerOnFrame(omf);
>
> mapPanel.getMapHandler().add(omf);
> mapPanel.getMapBean().showLayerPalettes();
>
> 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");
> startFrame.setLocationRelativeTo(null);
> startFrame.setVisible(true);
> try
> {
> //create singleton MapResources object.
> mapResources = MapResourcesSingleton.getInstance();
>
> //create dialog box to setup database connection pool for data
> handlers
> setOpenApplicationDialog(propertyHandler, startFrame);
>
> //show the TOBMap splash screen
> setSplashScreen(startFrame);
>
> //Read the previous scenario properties from the database.
> readScenarioProperties(propertyHandler);
>
> //Set a flag that will trigger the PropertyHandler to fire
> //progress events when it is going through the creation process.
> propertyHandler.setUpdateProgress(true);
>
> //Creates the layout manager for this container and create the
> components
> mapPanel.create();
>
> //Add the mapPanel to the OpenMap Frame
> omf.findAndInit(mapPanel);
>
> // Initialize the map projection, scale, center with user
> prefs or
> defaults.
> Projection proj = recallPreviousProjectionSize();
> mapBean.setProjection(proj);
>
> //Set the OpenMapFrame bounds - x,y position, width, height -
> that
> were stored in the preferences
> omf.setBounds(TOBPrefs.getInt(PREF_FRAME_X,0),
> TOBPrefs.getInt(PREF_FRAME_Y, 0),
> TOBPrefs.getInt(PREF_FRAME_WIDTH, 10),
> TOBPrefs.getInt(PREF_FRAME_HEIGHT, 10));
> omf.setExtendedState(TOBPrefs.getInt(PREF_FRAME_STATE,
> JFrame.NORMAL));
>
> //Set the MapHandler in MapResources. Initiate mouse delegators
> and modes.
> mapResources.setMapHandler(beanHandler);
>
> //Make the display of split into the layer control panel and the
> map.
> 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.
> mapBean.showLayerPalettes();
> //Hide the start splash screen
> startFrame.hide();
>
> if(mainDisplay!=null)
> mainDisplay.setDividerLocation(180);
>
> //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()
> {
> omf.show();
> }
> });
> }
>
> Best regards,
>
> Jason Butler
>
> -----Original Message-----
> From: Don Dietrick [mailto:dietrick_at_bbn.com]
> Sent: Friday, January 20, 2006 10:51 PM
> To: Butler, Jason
> Cc: openmap-users_at_bbn.com
> 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 "majdart_at_bbn.com"
> with the following text in the BODY of the message "unsubscribe
> openmap-users"]

--
[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 Sun Jan 22 2006 - 21:51:39 EST

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