Changeset 5374 in josm
- Timestamp:
- 2012-07-28T15:19:01+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPainter.java
r5348 r5374 403 403 404 404 public void drawTextOnPath(Way way, TextElement text) { 405 if ( text == null)405 if (way == null || text == null) 406 406 return; 407 407 String name = text.getString(way); 408 if (name == null || name. equals(""))408 if (name == null || name.isEmpty()) 409 409 return; 410 410 … … 438 438 double[] p1 = pointAt(t1, poly, pathLength); 439 439 double[] p2 = pointAt(t2, poly, pathLength); 440 441 if (p1 == null || p2 == null) 442 return; 440 443 441 444 double angleOffset; … … 462 465 double t = tStart + offsetSign * (rect.getX() + rect.getWidth()/2) / pathLength; 463 466 double[] p = pointAt(t, poly, pathLength); 464 AffineTransform trfm = AffineTransform.getTranslateInstance(p[0] - rect.getX(), p[1]); 465 trfm.rotate(p[2]+angleOffset); 466 double off = -rect.getY() - rect.getHeight()/2 + text.yOffset; 467 trfm.translate(-rect.getWidth()/2, off); 468 gv.setGlyphTransform(i, trfm); 467 if (p != null) { 468 AffineTransform trfm = AffineTransform.getTranslateInstance(p[0] - rect.getX(), p[1]); 469 trfm.rotate(p[2]+angleOffset); 470 double off = -rect.getY() - rect.getHeight()/2 + text.yOffset; 471 trfm.translate(-rect.getWidth()/2, off); 472 gv.setGlyphTransform(i, trfm); 473 } 469 474 } 470 475 if (text.haloRadius != null) { … … 488 493 double segLen; 489 494 490 // Yes, it is ineff ecient to iterate from the beginning for each glyph.495 // Yes, it is inefficient to iterate from the beginning for each glyph. 491 496 // Can be optimized if it turns out to be slow. 492 497 for (int i = 1; i < poly.npoints; ++i) { … … 498 503 continue; 499 504 } 500 return new double[] {poly.xpoints[i-1]+(totalLen - curLen)/segLen*dx, 505 return new double[] { 506 poly.xpoints[i-1]+(totalLen - curLen)/segLen*dx, 501 507 poly.ypoints[i-1]+(totalLen - curLen)/segLen*dy, 502 508 Math.atan2(dy, dx)};
Note:
See TracChangeset
for help on using the changeset viewer.