Changeset 5812 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2013-03-29T14:44:47+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
r5801 r5812 598 598 @Deprecated 599 599 public void drawLinePattern(Way way, Image pattern) { 600 drawRepeatImage(way, pattern, 0f, 0f, LineImageAlignment.TOP);600 drawRepeatImage(way, pattern, 0f, 0f, 0f, LineImageAlignment.TOP); 601 601 } 602 602 … … 608 608 * @param offset offset from the way 609 609 * @param spacing spacing between two images 610 * @param phase initial spacing 610 611 * @param align alignment of the image. The top, center or bottom edge 611 612 * can be aligned with the way. 612 613 */ 613 public void drawRepeatImage(Way way, Image pattern, float offset, float spacing, LineImageAlignment align) {614 public void drawRepeatImage(Way way, Image pattern, float offset, float spacing, float phase, LineImageAlignment align) { 614 615 final int imgWidth = pattern.getWidth(null); 615 616 final double repeat = imgWidth + spacing; … … 617 618 618 619 Point lastP = null; 619 double currentWayLength = 0; 620 double currentWayLength = phase % repeat; 621 if (currentWayLength < 0) { 622 currentWayLength += repeat; 623 } 620 624 621 625 int dy1, dy2; … … 647 651 final double dy = thisP.y - lastP.y; 648 652 649 double pos = currentWayLength == 0 ? 0 : repeat - (currentWayLength % repeat); 653 // pos is the position from the beginning of the current segment 654 // where an image should be painted 655 double pos = repeat - (currentWayLength % repeat); 650 656 651 657 AffineTransform saveTransform = g.getTransform(); … … 656 662 // is cut off 657 663 if (pos > spacing) { 658 g.drawImage(pattern, 0, dy1, (int) (pos - spacing), dy2, 659 (int) (imgWidth + spacing - pos), 0, imgWidth, imgHeight, null); 664 // segment is too short for a complete image 665 if (pos > segmentLength + spacing) { 666 g.drawImage(pattern, 0, dy1, (int) segmentLength, dy2, 667 (int) (repeat - pos), 0, 668 (int) (repeat - pos + segmentLength), imgHeight, null); 669 // rest of the image fits fully on the current segment 670 } else { 671 g.drawImage(pattern, 0, dy1, (int) (pos - spacing), dy2, 672 (int) (repeat - pos), 0, imgWidth, imgHeight, null); 673 } 660 674 } 661 675 // draw remaining images for this segment
Note:
See TracChangeset
for help on using the changeset viewer.