Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] Problems with MapGraphic Example code

Actually.  I've decided this is a bug and fixed in in the source code.  But for now the work around is to use the layer or map blackboard.

Jesse

On 20-Nov-07, at 10:54 AM, Jesse Eichar wrote:

That example should not be taken verbatim.  It is just an example.  What you should do is store the state on the Map or Layer Blackboard not in the mapGraphic itself.  I will update the example and javadocs

Jesse

On 20-Nov-07, at 12:17 AM, Leigh Fitzgibbon wrote:

I’ve been using the example AnimationMapGraphic class and have been running into problems when the graphic is added to more than one map.  As I understand it (through debugging) there is only one instance of the AnimationMapGraphic class created to handle drawing on all maps.  The MapGraphicContext is used to provide context to the draw operation.  The AnimationMapGraphic example code only ever creates one animation - for the very first MapGraphicContext object that is passed to draw(). 
 
I tried the obvious – creating a new CircleAnimation object per MapGraphicContext:
 
    private Map<MapGraphicContext,CircleAnimation> animations = newHashMap<MapGraphicContext, CircleAnimation>();
 
    public void draw(MapGraphicContext context) {
        if (this.animations.get(context) == null) {
            ILayer layer = context.getLayer();
            IBlackboard blackboard = layer.getBlackboard();
            blackboard.putInteger("x", 0);
            blackboard.putInteger("y", 50);
            CircleAnimation animation = new CircleAnimation(layer, context);
            AnimationUpdater.runTimer(context.getMapDisplay(), animation);
            animations.put(context, animation);
        }
 
    }
 
But this gave very strange results and didn’t work as expected (lots of exceptions related to invalid SWT handles) and when it does work the animation gets faster and faster until the machine locks up.  There seems to be some other issue that I don’t understand in the AnimationUpdater logic.
 
So what is the best way to generalise the AnimationMapGraphic example to resolve this problem?  Is there any other example animation code available?
 
 
PS: In the nextFrame() method the display can sometimes be null so it should be checked for, e.g.:
 
            if (display == null || x > display.getWidth()) {
                x = 0;
            }
 
 
Cheers,
Leigh Fitzgibbon
Eurobios Australia

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.16.0/1137 - Release Date: 18/11/2007 5:15 PM

_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel

_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel


Back to the top