Changeset 2659 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2009-12-19T18:12:03+01:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm/visitor
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
r2603 r2659 11 11 import java.awt.Font; 12 12 import java.awt.FontMetrics; 13 import java.awt.Graphics2D;14 13 import java.awt.Image; 15 14 import java.awt.Point; … … 92 91 public ElemStyle getPrimitiveStyle(OsmPrimitive osm) { 93 92 if(!useStyleCache) 94 return ( styles != null) ? styles.get(osm) : null;95 96 97 98 99 100 101 102 93 return ((styles != null) ? styles.get(osm) : null); 94 95 if(osm.mappaintStyle == null && styles != null) { 96 osm.mappaintStyle = styles.get(osm); 97 if(osm instanceof Way) { 98 ((Way)osm).isMappaintArea = styles.isArea(osm); 99 } 100 } 101 return osm.mappaintStyle; 103 102 } 104 103 … … 255 254 width = l.width; 256 255 realWidth = l.realWidth; 257 dashed = l. dashed;256 dashed = l.getDashed(); 258 257 dashedColor = l.dashedColor; 259 258 } … … 292 291 293 292 /* draw overlays under the way */ 294 if(l != null && l.overlays != null) 295 { 296 for(LineElemStyle s : l.overlays) 297 { 298 if(!s.over) 299 { 293 if(l != null && l.overlays != null) { 294 for(LineElemStyle s : l.overlays) { 295 if(!s.over) { 300 296 lastN = null; 301 for(Node n : w.getNodes()) 302 { 303 if(lastN != null) 304 { 297 for(Node n : w.getNodes()) { 298 if(lastN != null) { 305 299 drawSeg(lastN, n, s.color != null && !data.isSelected(w) ? s.color : color, 306 false, s.getWidth(width), s. dashed, s.dashedColor);300 false, s.getWidth(width), s.getDashed(), s.dashedColor); 307 301 } 308 302 lastN = n; … … 338 332 { 339 333 drawSeg(lastN, n, s.color != null && !data.isSelected(w) ? s.color : color, 340 false, s.getWidth(width), s. dashed, s.dashedColor);334 false, s.getWidth(width), s.getDashed(), s.dashedColor); 341 335 } 342 336 lastN = n; … … 1156 1150 int w = icon.getIconWidth(), h=icon.getIconHeight(); 1157 1151 icon.paintIcon ( Main.map.mapView, g, p.x-w/2, p.y-h/2 ); 1158 if(showNames > dist) 1159 { 1152 if(showNames > dist && annotate) { 1160 1153 String name = getNodeName(n); 1161 if (name!=null && annotate) 1162 { 1154 if (name!=null) { 1163 1155 if (inactive || n.isDisabled()) { 1164 1156 g.setColor(inactiveColor); … … 1219 1211 protected void displaySegments(Color newColor, int newWidth, float newDash[], Color newDashedColor) { 1220 1212 if (currentPath != null) { 1221 Graphics2D g2d = (Graphics2D)g; 1222 g2d.setColor(inactive ? inactiveColor : currentColor); 1213 g.setColor(inactive ? inactiveColor : currentColor); 1223 1214 if (currentStroke == null && useStrokes > dist) { 1224 1215 if (currentDashed.length > 0) { 1225 try { 1226 g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0,currentDashed,0)); 1227 } catch (IllegalArgumentException e) { 1228 g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); 1229 } 1216 g.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0,currentDashed,0)); 1230 1217 } else { 1231 g 2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));1232 } 1233 } 1234 g 2d.draw(currentPath);1218 g.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); 1219 } 1220 } 1221 g.draw(currentPath); 1235 1222 1236 1223 if(currentDashedColor != null) { 1237 g 2d.setColor(currentDashedColor);1224 g.setColor(currentDashedColor); 1238 1225 if (currentStroke == null && useStrokes > dist) { 1239 1226 if (currentDashed.length > 0) { … … 1242 1229 currentDashedOffset[currentDashed.length-1] = currentDashed[0]; 1243 1230 float offset = currentDashedOffset[0]; 1244 try { 1245 g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0,currentDashedOffset,offset)); 1246 } catch (IllegalArgumentException e) { 1247 g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); 1248 } 1231 g.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0,currentDashedOffset,offset)); 1249 1232 } else { 1250 g 2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));1251 } 1252 } 1253 g 2d.draw(currentPath);1233 g.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); 1234 } 1235 } 1236 g.draw(currentPath); 1254 1237 } 1255 1238 1256 1239 if(useStrokes > dist) { 1257 g 2d.setStroke(new BasicStroke(1));1240 g.setStroke(new BasicStroke(1)); 1258 1241 } 1259 1242 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
r2578 r2659 8 8 import java.awt.BasicStroke; 9 9 import java.awt.Color; 10 import java.awt.Graphics;11 10 import java.awt.Graphics2D; 12 11 import java.awt.Point; … … 45 44 * The environment to paint to. 46 45 */ 47 protected Graphics g;46 protected Graphics2D g; 48 47 /** 49 48 * MapView to get screen coordinates. … … 90 89 protected GeneralPath currentPath = new GeneralPath(); 91 90 92 Rectangle bbox = new Rectangle();93 94 91 public void getColors() 95 92 { … … 124 121 getColors(); 125 122 126 ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING,123 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 127 124 Main.pref.getBoolean("mappaint.use-antialiasing", false) ? 128 125 RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF); … … 386 383 } 387 384 388 ((Graphics2D) g).draw(relatedWayStroke.createStrokedShape(path));385 g.draw(relatedWayStroke.createStrokedShape(path)); 389 386 } 390 387 } … … 477 474 } 478 475 479 public void setGraphics(Graphics g) {476 public void setGraphics(Graphics2D g) { 480 477 this.g = g; 481 478 } … … 491 488 if (currentPath != null) { 492 489 g.setColor(currentColor); 493 ((Graphics2D) g).draw(currentPath);490 g.draw(currentPath); 494 491 currentPath = new GeneralPath(); 495 492 currentColor = newColor;
Note:
See TracChangeset
for help on using the changeset viewer.