- Timestamp:
- 2013-03-24T12:58:45+01:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
r5705 r5801 57 57 import org.openstreetmap.josm.gui.mappaint.NodeElemStyle; 58 58 import org.openstreetmap.josm.gui.mappaint.NodeElemStyle.Symbol; 59 import org.openstreetmap.josm.gui.mappaint.RepeatImageElemStyle.LineImageAlignment; 59 60 import org.openstreetmap.josm.gui.mappaint.StyleCache.StyleList; 60 61 import org.openstreetmap.josm.gui.mappaint.TextElement; … … 595 596 } 596 597 598 @Deprecated 597 599 public void drawLinePattern(Way way, Image pattern) { 598 final int width = pattern.getWidth(null); 599 final int height = pattern.getHeight(null); 600 drawRepeatImage(way, pattern, 0f, 0f, LineImageAlignment.TOP); 601 } 602 603 /** 604 * Draw an image along a way repeatedly. 605 * 606 * @param way the way 607 * @param pattern the image 608 * @param offset offset from the way 609 * @param spacing spacing between two images 610 * @param align alignment of the image. The top, center or bottom edge 611 * can be aligned with the way. 612 */ 613 public void drawRepeatImage(Way way, Image pattern, float offset, float spacing, LineImageAlignment align) { 614 final int imgWidth = pattern.getWidth(null); 615 final double repeat = imgWidth + spacing; 616 final int imgHeight = pattern.getHeight(null); 600 617 601 618 Point lastP = null; 602 double wayLength = 0; 603 604 Iterator<Node> it = way.getNodes().iterator(); 619 double currentWayLength = 0; 620 621 int dy1, dy2; 622 switch (align) { 623 case TOP: 624 dy1 = 0; 625 dy2 = imgHeight; 626 break; 627 case CENTER: 628 dy1 = - imgHeight / 2; 629 dy2 = imgHeight + dy1; 630 break; 631 case BOTTOM: 632 dy1 = -imgHeight; 633 dy2 = 0; 634 break; 635 default: 636 throw new AssertionError(); 637 } 638 639 OffsetIterator it = new OffsetIterator(way.getNodes(), offset); 605 640 while (it.hasNext()) { 606 Node n = it.next(); 607 Point thisP = nc.getPoint(n); 641 Point thisP = it.next(); 608 642 609 643 if (lastP != null) { … … 613 647 final double dy = thisP.y - lastP.y; 614 648 615 double dist = wayLength == 0 ? 0 :width - (wayLength %width);649 double pos = currentWayLength == 0 ? 0 : repeat - (currentWayLength % repeat); 616 650 617 651 AffineTransform saveTransform = g.getTransform(); … … 619 653 g.rotate(Math.atan2(dy, dx)); 620 654 621 if (dist > 0) { 622 g.drawImage(pattern, 0, 0, (int) dist, height, 623 width - (int) dist, 0, width, height, null); 624 } 625 while (dist < segmentLength) { 626 if (dist + width > segmentLength) { 627 g.drawImage(pattern, (int) dist, 0, (int) segmentLength, height, 628 0, 0, (int) segmentLength - (int) dist, height, null); 655 // draw the rest of the image from the last segment in case it 656 // is cut off 657 if (pos > spacing) { 658 g.drawImage(pattern, 0, dy1, (int) (pos - spacing), dy2, 659 (int) (imgWidth + spacing - pos), 0, imgWidth, imgHeight, null); 660 } 661 // draw remaining images for this segment 662 while (pos < segmentLength) { 663 // cut off at the end? 664 if (pos + imgWidth > segmentLength) { 665 g.drawImage(pattern, (int) pos, dy1, (int) segmentLength, dy2, 666 0, 0, (int) segmentLength - (int) pos, imgHeight, null); 629 667 } else { 630 g.drawImage(pattern, (int) dist, 0, nc);668 g.drawImage(pattern, (int) pos, dy1, nc); 631 669 } 632 dist += width;670 pos += repeat; 633 671 } 634 672 g.setTransform(saveTransform); 635 673 636 wayLength += segmentLength;674 currentWayLength += segmentLength; 637 675 } 638 676 lastP = thisP; 639 677 } 640 678 } 641 679 642 680 @Override 643 681 public void drawNode(Node n, Color color, int size, boolean fill) { -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
r5774 r5801 314 314 addIfNotNull(sl, AreaElemStyle.create(c)); 315 315 addIfNotNull(sl, LinePatternElemStyle.create(env)); 316 addIfNotNull(sl, RepeatImageElemStyle.create(env)); 316 317 addIfNotNull(sl, LineElemStyle.createLine(env)); 317 318 addIfNotNull(sl, LineElemStyle.createLeftCasing(env)); … … 331 332 addIfNotNull(sl, AreaElemStyle.create(c)); 332 333 addIfNotNull(sl, LinePatternElemStyle.create(env)); 334 addIfNotNull(sl, RepeatImageElemStyle.create(env)); 333 335 addIfNotNull(sl, LineElemStyle.createLine(env)); 334 336 addIfNotNull(sl, LineElemStyle.createCasing(env)); -
trunk/src/org/openstreetmap/josm/gui/mappaint/LineElemStyle.java
r5702 r5801 12 12 import org.openstreetmap.josm.data.osm.Way; 13 13 import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings; 14 import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors; 14 15 import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer; 15 import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;16 16 import org.openstreetmap.josm.gui.mappaint.mapcss.Instruction.RelativeFloat; 17 17 import org.openstreetmap.josm.tools.Utils; -
trunk/src/org/openstreetmap/josm/gui/mappaint/LinePatternElemStyle.java
r5571 r5801 9 9 10 10 /** 11 * similar to mapnik's LinePatternSymbolizer 11 * Similar to mapnik's LinePatternSymbolizer. 12 * 13 * @deprecated superseded by #{@link RepeatImageElemStyle} 12 14 */ 15 @Deprecated 13 16 public class LinePatternElemStyle extends ElemStyle { 14 17 -
trunk/src/org/openstreetmap/josm/gui/mappaint/StyleKeys.java
r5376 r5801 4 4 public interface StyleKeys { 5 5 6 public static final String COLOR = "color"; 7 public static final String DASHES = "dashes"; 8 public static final String DASHES_BACKGROUND_COLOR = "dashes-background-color"; 9 public static final String DASHES_BACKGROUND_OPACITY = "dashes-background-opacity"; 10 public static final String DASHES_OFFSET = "dashes-offset"; 11 public static final String FILL_COLOR = "fill-color"; 12 public static final String FILL_IMAGE = "fill-image"; 13 public static final String FILL_OPACITY = "fill-opacity"; 14 public static final String ICON_IMAGE = "icon-image"; 15 public static final String MODIFIER = "modifier"; 16 public static final String OBJECT_Z_INDEX = "object-z-index"; 17 public static final String OFFSET = "offset"; 18 public static final String OPACITY = "opacity"; 19 public static final String REAL_WIDTH = "real-width"; 20 public static final String TEXT_POSITION = "text-position"; 21 public static final String TEXT = "text"; 22 public static final String WIDTH = "width"; 23 public static final String Z_INDEX = "z-index"; 6 String COLOR = "color"; 7 String DASHES = "dashes"; 8 String DASHES_BACKGROUND_COLOR = "dashes-background-color"; 9 String DASHES_BACKGROUND_OPACITY = "dashes-background-opacity"; 10 String DASHES_OFFSET = "dashes-offset"; 11 String FILL_COLOR = "fill-color"; 12 String FILL_IMAGE = "fill-image"; 13 String FILL_OPACITY = "fill-opacity"; 14 String ICON_IMAGE = "icon-image"; 15 String MODIFIER = "modifier"; 16 String OBJECT_Z_INDEX = "object-z-index"; 17 String OFFSET = "offset"; 18 String OPACITY = "opacity"; 19 String REAL_WIDTH = "real-width"; 20 String TEXT_POSITION = "text-position"; 21 String TEXT = "text"; 22 String WIDTH = "width"; 23 String Z_INDEX = "z-index"; 24 String REPEAT_IMAGE = "repeat-image"; 25 String REPEAT_IMAGE_OFFSET = "repeat-image-offset"; 26 String REPEAT_IMAGE_SPACING = "repeat-image-spacing"; 27 String REPEAT_IMAGE_ALIGN = "repeat-image-align"; 24 28 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Instruction.java
r5705 r5801 73 73 value = val; 74 74 } 75 if (key.equals(ICON_IMAGE) || key.equals(FILL_IMAGE) || key.equals("pattern-image")) { 75 if (key.equals(ICON_IMAGE) || key.equals(FILL_IMAGE) || key.equals("pattern-image") || key.equals(REPEAT_IMAGE)) { 76 76 if (value instanceof String) { 77 77 value = new IconReference((String) value, env.source);
Note:
See TracChangeset
for help on using the changeset viewer.