RE: [OpenMap Users] MapBean setCenter and OMGraphic select

From: Graham, John <j.graham_at_ngc.com>
Date: Sat, 12 Jan 2008 09:27:52 -0600

Thanks...problem solved. I also took the suggestion of using lat/lon values with setCenter instead of x,y points.
 
- John

________________________________

From: Don Dietrick [mailto:dietrick_at_bbn.com]
Sent: Fri 1/11/2008 10:46 AM
To: Graham, John
Cc: OpenMap MList; "Carsten Ø. Madsen"
Subject: Re: [OpenMap Users] MapBean setCenter and OMGraphic select



Hi John,

Carsten's right. You also have to make sure that in the prepare()
method, you're not resetting the OMGraphic you've selected, too. One
other note - MapBean.setCenter() is a little more than just a proxy
for setting the center on the projection. It also kicks off the
notification of the projectin change to the layers, which causes all
of the projectionChanged() stuff to happen on all the layers. It's
easy to get into some kind of OMGraphic 'reset' state if you are
creating OMGraphics every time the projection changes, which can cause
problems when the user interacts with the map.

Cheers,

Don



On Jan 11, 2008, at 10:08 AM, Carsten Ø. Madsen wrote:

> Hello
>
> Try moving the setCenter to after the selection and skip the
> repaint. The setCenter will trigger a projectionChange event which
> should cause a repaint.
>
> BR
> Carsten
>
> Graham, John wrote:
>> Calling select() on an OMGraphic doesn't seem to work after calling
>> mapBean.setCenter. Let me elaborate. I wrote a find utility to
>> hilight a specific shape in an esri shapefile (the user picks which
>> shape by name from a tree). This works fine, but to improve
>> things, I want to center the map on the item that is found. Here
>> is a simplified version of my find method:
>> public void findObject(String shapeName, Point2D shapeCenter)
>> {
>> // this is the line that causes difficulty //
>> getMapBean().setCenter((float)shapeCenter.getX(),
>> (float)shapeCenter.getY());
>> OMGraphicList omgraphics = (OMGraphicList) getList();
>>
>> Color c = new Color(255, 255, 0); BasicStroke
>> thickStroke = new BasicStroke(5.0f);
>> BasicStroke normalStroke = new BasicStroke();
>> if (omgraphics != null)
>> {
>> // turn off any previous border highlighting
>> omgraphics.deselectAll();
>> omgraphics.setTextureMask(null);
>> omgraphics.setStroke(normalStroke); Iterator
>> iter = omgraphics.iterator();
>> while (iter.hasNext())
>> {
>> OMGraphic graphic = (OMGraphic)iter.next();
>> Object obj = graphic.getAppObject();
>> if (obj.toString().equals(shapeName))
>> {
>> graphic.setSelectPaint(c);
>> graphic.setStroke(thickStroke);
>> graphic.select();
>> break;
>> }
>> }
>> }
>> repaint();
>> }
>> In this example, the found shape borders are hilighted by a thick
>> yellow-gold line. But if I uncomment the call to setCenter, the
>> map gets centered properly, but the shape does not get hilighted.
>> MapBean::setCenter is just a convienence for Proj::setCenter, so I
>> don't know why this would affect the abiloty to hilight the
>> OMGraphic.
>> Any ideas?
>> Thanks,
>> John Graham
>> j.graham_at_ngc.com
>>
>> --
>> [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"]

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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 Sat Jan 12 2008 - 10:31:57 EST

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