Re: [OpenMap Users] How to animate OMGraphic and/or make AnimationTester class running

From: Christophe Ganivet <ganivet_at_cena.fr>
Date: Fri, 01 Jun 2007 15:05:59 +0200

regenerate doesn't seems to be enough too.
Here is a part of my code :

/* My moving plot item */
public class PlotItem {

    /** Constructor */
    public PlotItem(LatLonPoint point) {
        m_point = point;
        m_grafxPos = new OMCircle (m_point.getLatitude(),
m_point.getLongitude(), 0.02f);
        m_grafxPos.setFillPaint(Color.black);
    }

    /** Current position in lat,lon */
    private LatLonPoint m_point = null;

    /** Displayed object on map */
    private OMCircle m_grafxPos = null;

    /** Move plot to west */
    public void moveWest() {
        float X = m_point.getLongitude();
        m_point.setLatitude(X + 0.05f);
        updateGrafx();
    }

    /** Change coordinates */
    private void updateGrafx() {
        m_grafxPos.setCenter(m_point);
        m_grafxPos.regenerate(MovingPlotLayer.getLayer().getProjection());
    }

    [...]
}

When I make a CTRL-W in my frame, I call plot.moveWest();
And the "plot" object need to be redraw onto a Layer.

public class MovingPlotLayer extends Layer {

    /** list of graphics to be painted on the map. */
    private OMGraphicList m_omgraphics = new OMGraphicList();

    /** Projection used */
    private Projection m_projection = null;

    /** Draw plots on layer. */
    public void drawElements(OMGraphicList pGraphicList) {
        m_omgraphics.clear();
        for (PlotItem plot : m_list) {
            for (OMGraphic shapeItem : plot.getShapes()) {
                m_omgraphics.addOMGraphic(shapeItem);
                shapeItem.generate(m_projection);
            }
        }
    }
   
    public void projectionChanged(ProjectionEvent e) {
        m_projection = e.getProjection();
        m_omgraphics.project(e.getProjection(), true);
        repaint();
    }

    [...]
}

Did i miss anything ?
Thanx for your help.

Christophe

Stéphane WASSERHARDT a écrit :
> Hi Christophe,
>
> I think your problem is simply that "repaint" is not enough to redraw de
> circle correctly.
> You'll have to regenerate your OMCircle before repainting, by calling
> circle.generate(projection).
>
> If your layer only handles an OMGraphicList, you may want to extend
> OMGraphicHandlerLayer instead of Layer.
> An OMGraphicHandlerLayer manages an OMGraphicList internally, so you'll only
> have to call the "prepare" method to have all your OMGraphics regenerated.
>
> I hope this will help!
> Stephane
>
> -----Message d'origine-----
> De : owner-openmap-users_at_bbn.com [mailto:owner-openmap-users_at_bbn.com] De la
> part de Christophe Ganivet
> Envoyé : vendredi 1 juin 2007 10:28
> À : openmap-users_at_bbn.com
> Objet : [OpenMap Users] How to animate OMGraphic and/or make AnimationTester
> class running
>
> Hi all,
>
> I'm learning OpenMap for a few weeks and for some "basics" I've no
> trouble (displaying static data for instance).
> But now I'm trying to move a simple OMCircle (north, south, east and
> west) using keyboard and i fail.
> My OMcircle doesn't be "refresh" into the layer.
> I'm extending the com.bbn.openmap.Layer class with an OMGraphicList
> member (i'm copying what i've seen in provided example (Simple2.java and
> RouteLayer.java).
> When my OMCircle need to be moved, i only update its coordinates and
> then call repaint() on the layer.
> But this doesn't make my circle to be updated. If i zoom or span the map
> it is refresh at the good new coordinates.
> I've also seen in mailing list archive that some people are using a
> GraphicLoader. I've try to see the AnimationTester class but i don't
> succeed make it run in a short sample program.
> Can anyone help me ?
> Thanx
>
> Christophe
>
> --
> [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"]
Received on Fri Jun 01 2007 - 09:06:24 EDT

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