Re: [OpenMap Users] how to add OMGraphics to a layer ?

From: Don Dietrick <dietrick_at_bbn.com>
Date: Wed, 23 May 2007 09:54:06 -0400

Hi John,

On May 23, 2007, at 9:39 AM, John Chamberlain wrote:

> I have been trying to draw some OMGraphics on a layer and can not
> figure
> out how to do it. I do not want to use a properties file, I want to
> add
> the objects directly to the layer.

Property file settings don't really let you add OMGraphics to a
layer, unless you are providing a specific layer type with enough
information it needs to fetch data from a particular source. But
anyway, I get what you are asking.


> My code (with extraneous lines
> removed) looks like this:
>
> mLayer = new
> com.bbn.openmap.layer.OMGraphicHandlerLayer();
> mMapBean.add( mLayer );
> OMGraphicList omgraphiclistToBePlotted = new
> OMGraphicList();
> // ... code makes OMGraphics objects and adds them to
> list
> omgraphiclistToBePlotted.regenerate(
> mMapBean.getProjection() );

Don't bother with the regenerate here, the layer will take care of it
later.

> mLayer.add( omgraphiclistToBePlotted ); /// DOES NOT
> COMPILE

Try:

mLayer.setList(omgraphiclistToBePlotted);
mLayer.doPrepare();




> mMapBean.repaint();

Don't bother with this, it's not needed. The doPrepare() takes care
of that on the layer, along with calling generate on the
OMGraphicList with the projection it has received from the MapBean.



Alternatively, you can extend OMGraphicHandlerLayer to create your
own layer, and do the work of creating the OMGraphicList in the
overrided prepare() method, where you would return the OMGraphicList
you create. If you want to reuse one list, just call getList() at
the beginning of the prepare() method, and if it's null, that's your
signal to create the list. If it's not null, just generate the list
you get and return it. Call getProjection() to get the current
projection for the generate() method.

See the DemoLayer.prepare() method for an example of this.

Hope this helps,

Don

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Don Dietrick, dietrick_at_bbn.com
BBN Technologies, Cambridge, MA
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


--
[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 Wed May 23 2007 - 09:54:30 EDT

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