Hi Pat,
On Tuesday, February 4, 2003, at 12:44 PM, pat@n0hr.com wrote:
> Don
>
> Thanks for the reply!
>
> Based on your comments and my crude understanding of all this, my
> AnimationTester.java file now looks like the default one with the
> following changes:
>
> import com.bbn.openmap.event.CenterSupport; // in the import section
>
> protected transient CenterSupport centerDelegate;
>
> public AnimationTester() {
> }
>
> public void findAndInit(Iterator it) {
> Object someObj;
> while (it.hasNext()) {
> someObj = it.next();
> if (someObj instanceof MapBean) {
> Debug.message("AnimationTester", "AnimationTester: found the
> mapBean");
> centerDelegate = new CenterSupport(someObj);
> }
> }
> }
I think you can actually save yourself the trouble and have:
public void findAndInit(Object someObj) {
if (someObj instanceof MapBean) {
Debug.message("AnimationTester", "AnimationTester: found the
mapBean");
centerDelegate.addCenterListener((MapBean)someObj);
}
}
MapHandlerChild.findAndInit(Iterator) calls findAndInit(Object), which
makes it better for extended classes.
More importantly, note the change to the centerDelegate paradigm.
You should create the centerDelegate in your constructor, passing the
AnimatorTestor as the source. The MapBean is a listener.
> and the last line of the addNode method contains:
> centerDelegate.fireCenter(ranLat,ranLon);
>
> Additionally, I've backed out the MapHandler stuff as suggested.
>
> I'm presuming that I don't have to add a call to findAndInit in my
> constructor, right?
No, findAndInit gets called when an object gets added to the
MapHandler, or when your component is being told of other objects in
the MapHandler when you are added to it. It's called for you.
> I'm still missing a piece of this puzzle as it still
> doesn't recenter when I add a sprite.
FYI, everyone on openmap@bbn.com is also on openmap-users@bbn.com, so
you don't have to send messages to both. :)
- Don
>> On Tuesday, February 4, 2003, at 11:13 AM, pat@n0hr.com wrote:
>>
>>> In the hopes of trying to understand how I could add a 'recenter'
>>> feature
>>> to the animation tester, I added the following to
>>> AnimationTester.java:
>>>
>>> ....
>>> import com.bbn.openmap.event.CenterSupport;
>>> import com.bbn.openmap.MapBean;
>>> ....
>>> // a new class variable
>>> protected transient CenterSupport centerDelegate;
>>> MapBean myMapBean;
>>> ....
>>> // in the constructor
>>> myMapBean = new MapBean();
>>
>> Don't do that ^. You need to connect to the MapBean used in the
>> application.
>>
>>> centerDelegate = new CenterSupport(myMapBean);
>>
>> The AnimationTester extends the AbstractGraphicLoader, which extends
>> OMComponent. That means you get the MapHandler connection for free.
>> You just need to override the findAndInit(Object) method, and look for
>> an instance of MapBean. When you find it, create your CenterSupport
>> with it.
>>
>> Likewise, to be a good MapHandler citizen, you should override the
>> findAndUndo(Object), and if a MapBean is removed from the MapHandler,
>> you should detach your CenterSupport from it, and then continue on
>> gracefully.
>>
>>> ....
>>> // and, as the last line of the addNode method
>>> centerDelegate.fireCenter(ranLat,ranLon);
>>>
>>>
>>> To finish adding the anim tester, I added the following to my
>>> openmap.properties file:
>>> animMapHandler.class=com.bbn.openmap.MapHandler
>>
>> You don't have to define a MapHandler - its presence in the
>> application
>> is implicit.
>>
>>> animGLderConn.class=com.bbn.openmap.plugin.graphicLoader.GraphicLoade
>>> rC
>>> onnector
>>> animGLder.class=com.bbn.openmap.plugin.graphicLoader.GraphicLoader
>>> animAnim.class=com.bbn.openmap.plugin.graphicLoader.AnimationTester
>>> animAnim.prettyName=ANIM test
>>
>> All good.
>>
>>> animMapHandler.addToBeanContext=true
>>
>> So you don't need this, either.
>>
>> Hope this helps,
>>
>> Don
>>
>>
>>>
>>>
>>> Another failed attempt had me adding just the following to the
>>> AnimationTester.java file:
>>>
>>> private MapBean myMapBean; // class variable
>>>
>>> public AnimationTester() {
>>> myMapBean = new MapBean(); // constructor change
>>
>> Again, can't do this - you need the MapBean used in the application.
>>
>>> }
>>>
>>> // and, as the last line of the addnode method:
>>> myMapBean.setCenter(new LatLonPoint(ranLat, ranLon));
>>
>> Use the centerDelegate to fire recentering requests.
>>
>>
>>
>>
>>
>>> I'm thinking that it couldn't be that easy as I'd need to connect the
>>> mapbean to the maphandler somehow.
>>>
>>> Ok, the animation tester seems to add the 'sprites' as expected. The
>>> exception is that it does not recenter as I had hoped. A this point
>>> I'm starting to chase my tail.
>>>
>>> Maybe this is not such a simple task? Is there a better way to
>>> fireoff
>>> a
>>> recenter notification programmatically? Please be gentle:)
>>>
>>> Any advice?
>>> Pat
>>>
>>>
>>
>>
>> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>> Don Dietrick, BBN Technologies, dietrick@bbn.com
>> 10 Moulton Street, Cambridge, MA 02138
>> 617-873-3031 [fax]-2794
>> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
>
>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Don Dietrick, BBN Technologies, dietrick@bbn.com
10 Moulton Street, Cambridge, MA 02138
617-873-3031 [fax]-2794
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-- [To unsubscribe to this list send an email to "majdart@bbn.com" with the following text in the BODY of the message "unsubscribe openmap-users"]Received on Tue Feb 4 13:01:40 2003
This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:34 EDT