Re: [OpenMap Users] Calling Layer.repaint()

From: Don Dietrick <dfdietrick_at_gmail.com>
Date: Tue, 30 Nov 2010 19:32:01 -0500

Actually, RouteLayer doesn't extend OMGraphicHandlerLayer, so
doPrepare() isn't a method on RouteLayer. But you're right, the
problem is that the OMGraphicList isn't being generated with the new
projection.

Stephen, if your layer has been added to the map, then getProjection()
will give you the current projection of the map. When the OMGraphics
are updated, you need to call generate(projection) on your OMGraphic
list before calling repaint().

You should take a look at the com.bbn.openmap.layer.learn.BasicLayer,
read the comments, and get an idea of how OMGraphicHandlerLayers work.
 After that, you can create your own layer that extends
OMGraphicHandlerLayer. When you extend that class, your layer will
generally be based on an overridden prepare() method that returns an
OMGraphic list for the current projection. The OMGraphicHandlerLayer
sets its OMGraphicList from what is returned from the prepare()
method, and you can access it using the setList() and getList()
methods.

Based on what it sounds like you are doing, you would be able to call
setList(omGraphicList) on your new layer, and then call doPrepare() on
your layer, which would call prepare() and repaint() on your layer for
you, in a separate thread(). If you don't override prepare(), the
layer will use whatever list is already set on it.

Hope this helps,

Don

On Tue, Nov 30, 2010 at 7:07 PM, David Ward <synriga_at_yahoo.com> wrote:
> Your new or modified graphics need to be generated.
>
> After modifying your layer's OMGraphicList call layer.doPrepare() instead of layer.repaint().
>
> doPrepare() will regenerate the graphics in the list (get them ready for rendering), and the layer will be repainted when generation is complete.
>
> Cheers,
> David
>
>
>
>
> On Nov 30, 2010, at 2:46 PM, Dause, Stephen Howard CIV NSWCDD, K71 wrote:
>
>> Hello everyone,
>>
>> I've been having difficulty getting my layer to properly refresh itself when I call repaint().  If my understanding is correcting, calling the repaint() method of a class which extends Layer will cause that layer to be repainted.  For some reason, this is not working for me.
>>
>> I have made a simple modification to the example RouteLayer.java to wait for a few seconds, modify its OMGraphicList instance, and then call repaint() on itself.  Unfortunately, this does not have the desired effect: my changes to the OMGraphicList are not realized until I resize the window or interact with the map in another way (zoom in or out, etc.).  This is the case even when it is the only layer being displayed.
>>
>> To be clear, what I am trying to do is have a layer that changes its properties and repaints itself every so often based on data external to OpenMap (i.e., at regular intervals).  For whatever reason, I can't seem to get it to repaint itself properly.  Does anyone have a suggestion for what I am doing wrong, or a simple example of a layer that redraws itself every so often (independent of any user interaction)?
>>
>> Thanks in advance,
>>
>> Stephen Dause
>> stephen.dause_at_navy.mil
>
> --
> [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 Tue Nov 30 2010 - 19:32:39 EST

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