Changeset 3859 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2011-02-05T19:47:07+01:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPainter.java
r3858 r3859 100 100 } 101 101 102 public void drawWay(Way way, Color color, float width, float dashed[], Color dashedColor, boolean showDirection,102 public void drawWay(Way way, Color color, float width, float dashed[], float dashesOffset, Color dashedColor, boolean showDirection, 103 103 boolean reversedDirection, boolean showHeadArrowOnly) { 104 104 … … 156 156 lastPoint = p; 157 157 } 158 displaySegments(path, arrows, color, width, dashed, dashe dColor);159 } 160 161 private void displaySegments(GeneralPath path, GeneralPath arrows, Color color, float width, float dashed[], Color dashedColor) {158 displaySegments(path, arrows, color, width, dashed, dashesOffset, dashedColor); 159 } 160 161 private void displaySegments(GeneralPath path, GeneralPath arrows, Color color, float width, float dashed[], float dashesOffset, Color dashedColor) { 162 162 g.setColor(inactive ? inactiveColor : color); 163 163 if (useStrokes) { 164 164 if (dashed != null && dashed.length > 0) { 165 g.setStroke(new BasicStroke(width,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0, dashed,0));165 g.setStroke(new BasicStroke(width,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0,dashed,dashesOffset)); 166 166 } else { 167 167 g.setStroke(new BasicStroke(width,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); … … 175 175 if (dashed != null && dashed.length > 0) { 176 176 float[] dashedOffset = new float[dashed.length]; 177 System.arraycopy(dashed, 1, dashedOffset, 0, dashed.length - 1);178 dashedOffset[ dashed.length-1] = dashed[0];179 float offset = dashedOffset[0] ;180 g.setStroke(new BasicStroke(width,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0,dashedOffset, offset));177 System.arraycopy(dashed, 0, dashedOffset, 1, dashed.length - 1); 178 dashedOffset[0] = dashed[dashed.length-1]; 179 float offset = dashedOffset[0] + dashesOffset; 180 g.setStroke(new BasicStroke(width,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0,dashedOffset, offset)); 181 181 } else { 182 182 g.setStroke(new BasicStroke(width,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); -
trunk/src/org/openstreetmap/josm/gui/mappaint/AreaElemStyle.java
r3858 r3859 65 65 @Override 66 66 public String toString() { 67 return "AreaElemStyle{" + super.toString() + "color=" + color+ '}';67 return "AreaElemStyle{" + super.toString() + "color=" + Utils.toString(color) + '}'; 68 68 } 69 69 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/LineElemStyle.java
r3858 r3859 16 16 17 17 public static LineElemStyle createSimpleLineStyle(Color color) { 18 return new LineElemStyle(Cascade.EMPTY_CASCADE, -1f, 0f, color != null ? color : PaintColors.UNTAGGED.get(), null, null);18 return new LineElemStyle(Cascade.EMPTY_CASCADE, -1f, 0f, color != null ? color : PaintColors.UNTAGGED.get(), null, 0f, null); 19 19 } 20 20 public static final LineElemStyle UNTAGGED_WAY = createSimpleLineStyle(null); … … 24 24 public Color color; 25 25 private float[] dashed; 26 private float dashesOffset; 26 27 public Color dashedColor; 27 28 28 protected LineElemStyle(Cascade c, float width, float realWidth, Color color, float[] dashed, Color dashedColor) {29 protected LineElemStyle(Cascade c, float width, float realWidth, Color color, float[] dashed, float dashesOffset, Color dashedColor) { 29 30 super(c); 30 31 setWidth(width); … … 32 33 this.color = color; 33 34 this.dashed = dashed; 35 this.dashesOffset = dashesOffset; 34 36 this.dashedColor = dashedColor; 35 37 } … … 84 86 } 85 87 } 88 float dashesOffset = c.get(prefix + "dashes-offset", 0f, Float.class); 86 89 Color dashesBackground = c.get(prefix + "dashes-background-color", null, Color.class); 87 88 return new LineElemStyle(c, width, realWidth, color, dashes, dashesBackground); 90 if (dashesBackground != null) { 91 pAlpha = color_float2int(c.get(prefix + "dashes-background-opacity", null, Float.class)); 92 if (pAlpha != null) { 93 alpha = pAlpha; 94 } 95 dashesBackground = new Color(dashesBackground.getRed(), dashesBackground.getGreen(), 96 dashesBackground.getBlue(), alpha); 97 } 98 99 return new LineElemStyle(c, width, realWidth, color, dashes, dashesOffset, dashesBackground); 89 100 } 90 101 … … 140 151 } 141 152 142 painter.drawWay(w, markColor != null ? markColor : color, myWidth, dashed, myDashedColor, showDirection, 143 selected ? false : reversedDirection, showOnlyHeadArrowOnly); 153 painter.drawWay(w, markColor != null ? markColor : color, myWidth, dashed, 154 dashesOffset, myDashedColor, showDirection, 155 selected ? false : reversedDirection, showOnlyHeadArrowOnly); 144 156 145 157 if(paintSettings.isShowOrderNumber()) { … … 177 189 Utils.equal(color, other.color) && 178 190 Arrays.equals(dashed, other.dashed) && 191 dashesOffset == other.dashesOffset && 179 192 Utils.equal(dashedColor, other.dashedColor); 180 193 } … … 187 200 hash = 29 * hash + color.hashCode(); 188 201 hash = 29 * hash + Arrays.hashCode(dashed); 202 hash = 29 * hash + Float.floatToIntBits(dashesOffset); 189 203 hash = 29 * hash + (dashedColor != null ? dashedColor.hashCode() : 0); 190 204 return hash; … … 193 207 @Override 194 208 public String toString() { 195 return "LineElemStyle{" + super.toString() + "width=" + width + " realWidth=" + realWidth + " color=" + color + " dashed=" + Arrays.toString(dashed) + " dashedColor=" + dashedColor + '}'; 209 return "LineElemStyle{" + super.toString() + "width=" + width + 210 " realWidth=" + realWidth + " color=" + Utils.toString(color) + 211 " dashed=" + Arrays.toString(dashed) + 212 (dashesOffset == 0f ? "" : " dashesOffses=" + dashesOffset) + 213 " dashedColor=" + Utils.toString(dashedColor) + '}'; 196 214 } 197 215 } -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r3848 r3859 2 2 package org.openstreetmap.josm.tools; 3 3 4 import java.awt.Color; 4 5 import java.util.Collection; 5 6 … … 110 111 return s.toString(); 111 112 } 113 114 /** 115 * convert Color to String 116 * (Color.toString() omits alpha value) 117 */ 118 public static String toString(Color c) { 119 if (c == null) 120 return "null"; 121 if (c.getAlpha() == 255) 122 return String.format("#%06x", c.getRGB() & 0x00ffffff); 123 else 124 return String.format("#%06x(alpha=%d)", c.getRGB() & 0x00ffffff, c.getAlpha()); 125 } 112 126 }
Note:
See TracChangeset
for help on using the changeset viewer.