Ticket #1607: GpxLayer.diff

File GpxLayer.diff, 3.2 KB (added by Henry Loenwind, 16 years ago)
  • src/org/openstreetmap/josm/gui/layer/GpxLayer.java

     
    377377                boolean large = Main.pref.getBoolean("draw.rawgps.large");                                // paint large dots for points
    378378                boolean colored = Main.pref.getBoolean("draw.rawgps.colors");                             // color the lines
    379379                boolean alternatedirection = Main.pref.getBoolean("draw.rawgps.alternatedirection");      // paint direction arrow with alternate math. may be faster
     380                int delta = 0;
     381                try {
     382                        delta = Integer.parseInt(Main.pref.get("draw.rawgps.min-arrow-distance", "0"));         // don't draw arrows nearer to each other than this
     383                } catch (java.lang.NumberFormatException e) {
     384                        Main.pref.put("draw.rawgps.min-arrow-distance", "0");
     385                }
    380386
    381387                /****************************************************************
    382388                 ********** STEP 2a - CHECK CACHE VALIDITY **********************
     
    463469                 ****************************************************************/
    464470                if (lines && direction && !alternatedirection) {
    465471                        Point old = null;
     472                        Point oldA = null; // last arrow painted
    466473                        for (GpxTrack trk : data.tracks) {
    467474                                for (Collection<WayPoint> segment : trk.trackSegs) {
    468475                                        for (WayPoint trkPnt : segment) {
     
    471478                                                if (trkPnt.drawLine) {
    472479                                                        Point screen = mv.getPoint(trkPnt.eastNorth);
    473480                                                        // skip points that are on the same screenposition
    474                                                         if (old != null && ((old.x != screen.x) || (old.y != screen.y))) {
     481                                                        if (old != null && (oldA == null || screen.x < oldA.x-delta || screen.x > oldA.x+delta || screen.y < oldA.y-delta || screen.y > oldA.y+delta)) {
    475482                                                                g.setColor(trkPnt.speedLineColor);
    476483                                                                double t = Math.atan2(screen.y-old.y, screen.x-old.x) + Math.PI;
    477484                                                                g.drawLine(screen.x,screen.y, (int)(screen.x + 10*Math.cos(t-PHI)), (int)(screen.y
    478485                                                                + 10*Math.sin(t-PHI)));
    479486                                                                g.drawLine(screen.x,screen.y, (int)(screen.x + 10*Math.cos(t+PHI)), (int)(screen.y
    480487                                                                + 10*Math.sin(t+PHI)));
     488                                                                oldA = screen;
    481489                                                        }
    482490                                                        old = screen;
    483491                                                }
     
    491499                 ****************************************************************/
    492500                if (lines && direction && alternatedirection) {
    493501                        Point old = null;
     502                        Point oldA = null; // last arrow painted
    494503                        for (GpxTrack trk : data.tracks) {
    495504                                for (Collection<WayPoint> segment : trk.trackSegs) {
    496505                                        for (WayPoint trkPnt : segment) {
     
    499508                                                if (trkPnt.drawLine) {
    500509                                                        Point screen = mv.getPoint(trkPnt.eastNorth);
    501510                                                        // skip points that are on the same screenposition
    502                                                         if (old != null && ((old.x != screen.x) || (old.y != screen.y))) {
     511                                                        if (old != null && (oldA == null || screen.x < oldA.x-delta || screen.x > oldA.x+delta || screen.y < oldA.y-delta || screen.y > oldA.y+delta)) {
    503512                                                                g.setColor(trkPnt.speedLineColor);
    504513                                                                g.drawLine(screen.x, screen.y, screen.x + dir[trkPnt.dir][0], screen.y + dir[trkPnt.dir][1]);
    505514                                                                g.drawLine(screen.x, screen.y, screen.x + dir[trkPnt.dir][2], screen.y + dir[trkPnt.dir][3]);
     515                                                                oldA = screen;
    506516                                                        }
    507517                                                        old = screen;
    508518                                                }