Changeset 30316 in osm for applications/editors
- Timestamp:
- 2014-03-02T22:07:07+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/src/render/Renderer.java
r30315 r30316 492 492 493 493 public static void lineText(Feature feature, String str, Font font, Color colour, double offset, double dy) { 494 // Rectangle prect = symbolSize(prisymb);495 494 if (!str.isEmpty()) { 496 495 g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 497 496 FontRenderContext frc = g2.getFontRenderContext(); 498 GlyphVector gv = font.deriveFont((float)(font.getSize()*sScale)).createGlyphVector(frc, str); 499 // double psize = Math.abs(prect.getX()); 497 GlyphVector gv = font.deriveFont((float)(font.getSize())).createGlyphVector(frc, (" " + str)); 500 498 Point2D prev = new Point2D.Double(); 501 499 Point2D next = new Point2D.Double(); … … 503 501 Point2D succ = new Point2D.Double(); 504 502 boolean piv = false; 505 double len = 0;506 503 double angle = 0; 504 int index = 0; 505 double gwidth = offset * (feature.geom.length * context.mile(feature) - (gv.getLogicalBounds().getWidth() * sScale)); 507 506 GeomIterator git = map.new GeomIterator(feature.geom); 508 507 while (git.hasComp()) { … … 518 517 if (first) { 519 518 curr = succ = next; 520 // len = psize;521 519 first = false; 522 520 } else { 523 while (curr.distance(next) >= len) {521 while (curr.distance(next) >= gwidth) { 524 522 if (piv) { 525 double rem = len;523 double rem = gwidth; 526 524 double s = prev.distance(next); 527 525 double p = curr.distance(prev); … … 529 527 double n = curr.distance(next); 530 528 double theta = Math.acos((s * s + p * p - n * n) / 2 / s / p); 531 double phi = Math.asin(p / len* Math.sin(theta));532 rem = len* Math.sin(Math.PI - theta - phi) / Math.sin(theta);529 double phi = Math.asin(p / gwidth * Math.sin(theta)); 530 rem = gwidth * Math.sin(Math.PI - theta - phi) / Math.sin(theta); 533 531 } 534 532 succ = new Point2D.Double(prev.getX() + (rem * Math.cos(angle)), prev.getY() + (rem * Math.sin(angle))); 535 533 piv = false; 536 534 } else { 537 succ = new Point2D.Double(curr.getX() + ( len * Math.cos(angle)), curr.getY() + (len* Math.sin(angle)));535 succ = new Point2D.Double(curr.getX() + (gwidth * Math.cos(angle)), curr.getY() + (gwidth * Math.sin(angle))); 538 536 } 539 // Symbols.drawSymbol(g2, symbol, sScale, curr.getX(), curr.getY(), new Delta(Handle.BC, AffineTransform.getRotateInstance(Math.atan2((succ.getY() - curr.getY()), (succ.getX() - curr.getX())) + Math.toRadians(90))), null); 537 Symbol symbol = new Symbol(); 538 Shape shape = gv.getGlyphOutline(index); 539 Rectangle2D bounds = shape.getBounds2D(); 540 symbol.add(new Instr(Form.BBOX, new Rectangle2D.Double(bounds.getX(), (bounds.getY() - dy), bounds.getWidth(), bounds.getHeight()))); 541 symbol.add(new Instr(Form.PGON, new Path2D.Double(shape))); 542 Symbols.drawSymbol(g2, symbol, sScale, curr.getX(), curr.getY(), new Scheme(colour), 543 new Delta((dy < 0) ? Handle.BL : Handle.TL, AffineTransform.getRotateInstance(Math.atan2((succ.getY() - curr.getY()), (succ.getX() - curr.getX()))))); 540 544 curr = succ; 541 // len = psize; 545 if (++index < gv.getNumGlyphs()) { 546 gwidth = gv.getGlyphMetrics(index).getAdvance() * sScale; 547 } else { 548 return; 549 } 542 550 } 543 551 }
Note:
See TracChangeset
for help on using the changeset viewer.