Changeset 1333 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2009-01-25T00:20:25+01:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
r1313 r1333 54 54 protected Color untaggedColor; 55 55 protected Color textColor; 56 protected boolean currentDashed = false;56 protected int currentDashed = 0; 57 57 protected int currentWidth = 0; 58 58 protected Stroke currentStroke = null; … … 246 246 int width = defaultSegmentWidth; 247 247 int realWidth = 0; //the real width of the element in meters 248 boolean dashed = false;248 int dashed = 0; 249 249 Node lastN; 250 250 … … 1084 1084 } 1085 1085 1086 private void drawSeg(Node n1, Node n2, Color col, boolean showDirection, int width, booleandashed) {1086 private void drawSeg(Node n1, Node n2, Color col, boolean showDirection, int width, int dashed) { 1087 1087 profilerSegments++; 1088 1088 if (col != currentColor || width != currentWidth || dashed != currentDashed) { … … 1108 1108 1109 1109 protected void displaySegments() { 1110 displaySegments(null, 0, false);1111 } 1112 1113 protected void displaySegments(Color newColor, int newWidth, booleannewDash) {1110 displaySegments(null, 0, 0); 1111 } 1112 1113 protected void displaySegments(Color newColor, int newWidth, int newDash) { 1114 1114 if (currentPath != null) { 1115 1115 Graphics2D g2d = (Graphics2D)g; 1116 1116 g2d.setColor(inactive ? inactiveColor : currentColor); 1117 1117 if (currentStroke == null && useStrokes > dist) { 1118 if (currentDashed )1119 g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0,new float[] { 9},0));1118 if (currentDashed != 0) 1119 g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0,new float[] {currentDashed},0)); 1120 1120 else 1121 1121 g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyleHandler.java
r1241 r1333 68 68 } 69 69 70 private void error(String message) { 71 System.out.println(styleName + " (" + rule.key + "=" + rule.value + "): " + message); 72 } 73 74 private void startElementLine(String qName, Attributes atts, LineElemStyle line) { 75 for (int count=0; count<atts.getLength(); count++) 76 { 77 if(atts.getQName(count).equals("width")) 78 { 79 String val = atts.getValue(count); 80 if(val.startsWith("+")) 81 { 82 line.width = Integer.parseInt(val.substring(1)); 83 line.widthMode = LineElemStyle.WidthMode.OFFSET; 84 } 85 else if(val.startsWith("-")) 86 { 87 line.width = Integer.parseInt(val); 88 line.widthMode = LineElemStyle.WidthMode.OFFSET; 89 } 90 else if(val.endsWith("%")) 91 { 92 line.width = Integer.parseInt(val.substring(0, val.length()-1)); 93 line.widthMode = LineElemStyle.WidthMode.PERCENT; 94 } 95 else 96 line.width = Integer.parseInt(val); 97 } 98 else if (atts.getQName(count).equals("colour")) 99 line.color=convertColor(atts.getValue(count)); 100 else if (atts.getQName(count).equals("realwidth")) 101 line.realWidth=Integer.parseInt(atts.getValue(count)); 102 else if (atts.getQName(count).equals("dashed")) { 103 try 104 { 105 line.dashed=Integer.parseInt(atts.getValue(count)); 106 } catch (NumberFormatException nfe) { 107 boolean dashed=Boolean.parseBoolean(atts.getValue(count)); 108 if(dashed) { 109 line.dashed = 9; 110 } 111 } 112 } else if(atts.getQName(count).equals("priority")) 113 line.priority = Integer.parseInt(atts.getValue(count)); 114 else if(atts.getQName(count).equals("mode")) 115 line.over = !atts.getValue(count).equals("under"); 116 else 117 error("The element \"" + qName + "\" has unknown attribute \"" + atts.getQName(count) + "\"!"); 118 } 119 } 120 70 121 @Override public void startElement(String uri,String name, String qName, Attributes atts) { 71 122 if (inDoc==true) … … 97 148 else if(atts.getQName(count).equals("b")) 98 149 rule.boolValue = atts.getValue(count); 150 else 151 error("The element \"" + qName + "\" has unknown attribute \"" + atts.getQName(count) + "\"!"); 99 152 } 100 153 } … … 102 155 { 103 156 hadLine = inLine = true; 104 for (int count=0; count<atts.getLength(); count++) 105 { 106 if(atts.getQName(count).equals("width")) 107 rule.line.width = Integer.parseInt(atts.getValue(count)); 108 else if (atts.getQName(count).equals("colour")) 109 rule.line.color=convertColor(atts.getValue(count)); 110 else if (atts.getQName(count).equals("realwidth")) 111 rule.line.realWidth=Integer.parseInt(atts.getValue(count)); 112 else if (atts.getQName(count).equals("dashed")) 113 rule.line.dashed=Boolean.parseBoolean(atts.getValue(count)); 114 else if(atts.getQName(count).equals("priority")) 115 rule.line.priority = Integer.parseInt(atts.getValue(count)); 157 startElementLine(qName, atts, rule.line); 158 if(rule.line.widthMode != LineElemStyle.WidthMode.ABSOLUTE) { 159 error("Relative widths are not possible for normal lines"); 160 rule.line.widthMode = LineElemStyle.WidthMode.ABSOLUTE; 116 161 } 117 162 } … … 119 164 { 120 165 hadLineMod = inLineMod = true; 121 for (int count=0; count<atts.getLength(); count++) 122 { 123 if(atts.getQName(count).equals("width")) 124 { 125 String val = atts.getValue(count); 126 if(val.startsWith("+")) 127 { 128 rule.linemod.width = Integer.parseInt(val.substring(1)); 129 rule.linemod.widthMode = LineElemStyle.WidthMode.OFFSET; 130 } 131 else if(val.startsWith("-")) 132 { 133 rule.linemod.width = Integer.parseInt(val); 134 rule.linemod.widthMode = LineElemStyle.WidthMode.OFFSET; 135 } 136 else if(val.endsWith("%")) 137 { 138 rule.linemod.width = Integer.parseInt(val.substring(0, val.length()-1)); 139 rule.linemod.widthMode = LineElemStyle.WidthMode.PERCENT; 140 } 141 else 142 rule.linemod.width = Integer.parseInt(val); 143 } 144 else if (atts.getQName(count).equals("colour")) 145 rule.linemod.color=convertColor(atts.getValue(count)); 146 else if (atts.getQName(count).equals("realwidth")) 147 rule.linemod.realWidth=Integer.parseInt(atts.getValue(count)); 148 else if (atts.getQName(count).equals("dashed")) 149 rule.linemod.dashed=Boolean.parseBoolean(atts.getValue(count)); 150 else if(atts.getQName(count).equals("priority")) 151 rule.linemod.priority = Integer.parseInt(atts.getValue(count)); 152 else if(atts.getQName(count).equals("mode")) 153 rule.linemod.over = !atts.getValue(count).equals("under"); 154 } 166 startElementLine(qName, atts, rule.linemod); 155 167 } 156 168 else if (qName.equals("icon")) … … 165 177 else if(atts.getQName(count).equals("priority")) 166 178 rule.icon.priority = Integer.parseInt(atts.getValue(count)); 179 else 180 error("The element \"" + qName + "\" has unknown attribute \"" + atts.getQName(count) + "\"!"); 167 181 } 168 182 } … … 176 190 else if(atts.getQName(count).equals("priority")) 177 191 rule.area.priority = Integer.parseInt(atts.getValue(count)); 178 } 179 } 192 else 193 error("The element \"" + qName + "\" has unknown attribute \"" + atts.getQName(count) + "\"!"); 194 } 195 } 196 else 197 error("The element \"" + qName + "\" is unknown!"); 180 198 } 181 199 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/LineElemStyle.java
r1204 r1333 9 9 public int realWidth; //the real width of this line in meter 10 10 public Color color; 11 public booleandashed;11 public int dashed; 12 12 13 13 public boolean over; … … 54 54 width = 1; 55 55 realWidth = 0; 56 dashed = false;56 dashed = 0; 57 57 priority = 0; 58 58 color = null;
Note:
See TracChangeset
for help on using the changeset viewer.