Changeset 3119 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2010-03-12T08:18:44+01:00 (14 years ago)
Author:
jttt
Message:

Cache offscreen buffer for GpxLayer

Location:
trunk/src/org/openstreetmap/josm
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java

    r2907 r3119  
    3535    public boolean fromServer;
    3636
    37     public Collection<GpxTrack> tracks = new LinkedList<GpxTrack>();
    38     public Collection<GpxRoute> routes = new LinkedList<GpxRoute>();
    39     public Collection<WayPoint> waypoints = new LinkedList<WayPoint>();
     37    public final Collection<GpxTrack> tracks = new LinkedList<GpxTrack>();
     38    public final Collection<GpxRoute> routes = new LinkedList<GpxRoute>();
     39    public final Collection<WayPoint> waypoints = new LinkedList<WayPoint>();
    4040
    4141    @SuppressWarnings("unchecked")
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxTrack.java

    r2907 r3119  
    2121    Bounds getBounds();
    2222    double length();
     23    /**
     24     *
     25     * @return Number of times this track has been changed. Always 0 for read-only tracks
     26     */
     27    int getUpdateCount();
    2328
    2429}
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxTrackSegment.java

    r3083 r3119  
    1515    Collection<WayPoint> getWayPoints();
    1616    double length();
    17 
     17    /**
     18     *
     19     * @return Number of times this track has been changed. Always 0 for read-only segments
     20     */
     21    int getUpdateCount();
    1822}
  • trunk/src/org/openstreetmap/josm/data/gpx/ImmutableGpxTrack.java

    r3083 r3119  
    7373        return segments;
    7474    }
     75
     76    public int getUpdateCount() {
     77        return 0;
     78    }
    7579}
  • trunk/src/org/openstreetmap/josm/data/gpx/ImmutableGpxTrackSegment.java

    r3083 r3119  
    6262    }
    6363
     64    public int getUpdateCount() {
     65        return 0;
     66    }
     67
    6468}
  • trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    r3097 r3119  
    7777public class GpxLayer extends Layer {
    7878    public GpxData data;
    79     private final GpxLayer me;
    8079    protected static final double PHI = Math.toRadians(15);
    8180    private boolean computeCacheInSync;
     
    8685    private boolean isLocalFile;
    8786
     87    private final List<GpxTrack> lastTracks = new ArrayList<GpxTrack>(); // List of tracks at last paint
     88    private int lastUpdateCount;
     89
    8890    private static class Markers {
    8991        public boolean timedMarkersOmitted = false;
     
    9496        super((String) d.attr.get("name"));
    9597        data = d;
    96         me = this;
    9798        computeCacheInSync = false;
    9899    }
     
    207208
    208209                MarkerLayer ml = new MarkerLayer(namedTrackPoints, tr("Named Trackpoints from {0}", getName()),
    209                         getAssociatedFile(), me);
     210                        getAssociatedFile(), GpxLayer.this);
    210211                if (ml.data.size() > 0) {
    211212                    Main.main.addLayer(ml);
     
    282283                    }
    283284                    MarkerLayer ml = new MarkerLayer(new GpxData(), tr("Audio markers from {0}", getName()) + names,
    284                             getAssociatedFile(), me);
     285                            getAssociatedFile(), GpxLayer.this);
    285286                    double firstStartTime = sel[0].lastModified() / 1000.0 /* ms -> seconds */
    286287                    - AudioUtil.getCalibratedDuration(sel[0]);
     
    452453    }
    453454
     455    private int sumUpdateCount() {
     456        int updateCount = 0;
     457        for (GpxTrack track: data.tracks) {
     458            updateCount += track.getUpdateCount();
     459        }
     460        return updateCount;
     461    }
     462
     463    @Override
     464    public boolean isChanged() {
     465        if (data.tracks.equals(lastTracks))
     466            return sumUpdateCount() != lastUpdateCount;
     467        else
     468            return true;
     469    }
     470
    454471    @Override
    455472    public void mergeFrom(Layer from) {
     
    481498    @Override
    482499    public void paint(Graphics2D g, MapView mv, Bounds box) {
     500        lastUpdateCount = sumUpdateCount();
     501        lastTracks.clear();
     502        lastTracks.addAll(data.tracks);
    483503
    484504        /****************************************************************
Note: See TracChangeset for help on using the changeset viewer.