 Timestamp:
 20100514T22:53:44+02:00 (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/SimplePaintVisitor.java
r3201 r3243 46 46 47 47 public boolean inactive; 48 49 protected static final double PHI = Math.toRadians(20);50 48 51 49 /** … … 470 468 } 471 469 470 private static final double PHI = Math.toRadians(20); 471 private static final double cosPHI = Math.cos(PHI); 472 private static final double sinPHI = Math.sin(PHI); 473 472 474 protected void drawSegment(GeneralPath path, Point p1, Point p2, boolean showDirection) { 473 if (isSegmentVisible(p1, p2)) { 475 boolean drawIt = false; 476 if (Main.isOpenjdk) { 477 /** 478 * Work around openjdk bug. It leads to drawing artefacts when zooming in a lot. (#4289, #4424) 479 * (It looks like int overflow when clipping.) We do custom clipping. 480 */ 481 Rectangle bounds = g.getClipBounds(); 482 bounds.grow(100, 100); // avoid arrow heads at the border 483 LineClip clip = new LineClip(); 484 drawIt = clip.cohenSutherland(p1.x, p1.y, p2.x, p2.y, bounds.x, bounds.y, bounds.x+bounds.width, bounds.y+bounds.height); 485 p1 = clip.getP1(); 486 p2 = clip.getP2(); 487 } else { 488 drawIt = isSegmentVisible(p1, p2); 489 } 490 if (drawIt) { 474 491 path.moveTo(p1.x, p1.y); 475 492 path.lineTo(p2.x, p2.y); 476 493 477 494 if (showDirection) { 478 double t = Math.atan2(p2.yp1.y, p2.xp1.x) + Math.PI; 479 path.lineTo((int)(p2.x + 10*Math.cos(tPHI)), (int)(p2.y + 10*Math.sin(tPHI))); 480 path.moveTo((int)(p2.x + 10*Math.cos(t+PHI)), (int)(p2.y + 10*Math.sin(t+PHI))); 495 final double l = 10. / p1.distance(p2); 496 497 final double sx = l * (p1.x  p2.x); 498 final double sy = l * (p1.y  p2.y); 499 500 path.lineTo (p2.x + (int) Math.round(cosPHI * sx  sinPHI * sy), p2.y + (int) Math.round(sinPHI * sx + cosPHI * sy)); 501 path.moveTo (p2.x + (int) Math.round(cosPHI * sx + sinPHI * sy), p2.y + (int) Math.round( sinPHI * sx + cosPHI * sy)); 481 502 path.lineTo(p2.x, p2.y); 482 503 }
Note: See TracChangeset
for help on using the changeset viewer.