Ticket #1607: GpxLayer.diff
File GpxLayer.diff, 3.2 KB (added by , 16 years ago) |
---|
-
src/org/openstreetmap/josm/gui/layer/GpxLayer.java
377 377 boolean large = Main.pref.getBoolean("draw.rawgps.large"); // paint large dots for points 378 378 boolean colored = Main.pref.getBoolean("draw.rawgps.colors"); // color the lines 379 379 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 } 380 386 381 387 /**************************************************************** 382 388 ********** STEP 2a - CHECK CACHE VALIDITY ********************** … … 463 469 ****************************************************************/ 464 470 if (lines && direction && !alternatedirection) { 465 471 Point old = null; 472 Point oldA = null; // last arrow painted 466 473 for (GpxTrack trk : data.tracks) { 467 474 for (Collection<WayPoint> segment : trk.trackSegs) { 468 475 for (WayPoint trkPnt : segment) { … … 471 478 if (trkPnt.drawLine) { 472 479 Point screen = mv.getPoint(trkPnt.eastNorth); 473 480 // 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)) { 475 482 g.setColor(trkPnt.speedLineColor); 476 483 double t = Math.atan2(screen.y-old.y, screen.x-old.x) + Math.PI; 477 484 g.drawLine(screen.x,screen.y, (int)(screen.x + 10*Math.cos(t-PHI)), (int)(screen.y 478 485 + 10*Math.sin(t-PHI))); 479 486 g.drawLine(screen.x,screen.y, (int)(screen.x + 10*Math.cos(t+PHI)), (int)(screen.y 480 487 + 10*Math.sin(t+PHI))); 488 oldA = screen; 481 489 } 482 490 old = screen; 483 491 } … … 491 499 ****************************************************************/ 492 500 if (lines && direction && alternatedirection) { 493 501 Point old = null; 502 Point oldA = null; // last arrow painted 494 503 for (GpxTrack trk : data.tracks) { 495 504 for (Collection<WayPoint> segment : trk.trackSegs) { 496 505 for (WayPoint trkPnt : segment) { … … 499 508 if (trkPnt.drawLine) { 500 509 Point screen = mv.getPoint(trkPnt.eastNorth); 501 510 // 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)) { 503 512 g.setColor(trkPnt.speedLineColor); 504 513 g.drawLine(screen.x, screen.y, screen.x + dir[trkPnt.dir][0], screen.y + dir[trkPnt.dir][1]); 505 514 g.drawLine(screen.x, screen.y, screen.x + dir[trkPnt.dir][2], screen.y + dir[trkPnt.dir][3]); 515 oldA = screen; 506 516 } 507 517 old = screen; 508 518 }