Hi Stefano,
You can call yourLayer.doPrepare() whenever you want to have the prepare() method called on your layer in a separate thread. You don’t have to call it for layers that create OMGraphics from a static data set. You only need to call it if your layer should display new OMGraphics because its data source has been updated. Calling the doPrepare() method will also call repaint() on your layer with the OMGraphicList returned from the prepare() method, so you don’t have to make that call.
The projection changes are received by the Layer.projectionChanged(ProjectionEvent) method. This method is abstract in Layer.java, but the OMGraphicHandlerLayer implements it and lets the ProjectionChange policy handle it. You can change what your layer does in the projectionChanged() method by using different ProjectionChangedPolicy in your layer. I usually set that object in the constructor, but you can also set it in the properties set on a layer. You can see this being done in the layers in the com.bbn.openmap.layer.learn package.
There are two main ProjectionChangedPolicy objects. The StandardPCPolicy assumes the OMGraphicList gets set once on the layer and doesn’t change. The ListResetPCPolicy will delete the rendered OMGraphicList before replacing it with the list returned from the prepare() method. They both will work if your layer returns a new OMGraphicList from the prepare() method, but the StandardPCPolicy is just a little more efficient if it doesn’t change.
The StandardPCPolicy will kick off a thread for the projectionChange if it starts detecting that there are a large number of OMGraphics on the layer. You can also call layer.setAlwaysSpawnThread(true) to force it to do that.
The ListResetPCPolicy always kicks off a separate thread.
Hope this helps,
Don
> --
> You received this message because you are subscribed to the Google Groups "openmap-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
openmap-user...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/openmap-users/e172b6aa-bbed-4d7f-b61c-d115ebe357a1%40googlegroups.com.