Changeset 2663 in josm
- Timestamp:
- 2009-12-20T08:28:24+01:00 (15 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
r2659 r2663 15 15 import java.awt.Polygon; 16 16 import java.awt.Rectangle; 17 import java.awt.Stroke;18 17 import java.awt.geom.GeneralPath; 19 18 import java.awt.geom.Point2D; … … 65 64 protected Color textColor; 66 65 protected Color areaTextColor; 67 protected float[] currentDashed = new float[0];68 protected Color currentDashedColor;69 protected int currentWidth = 0;70 protected Stroke currentStroke = null;71 66 protected Font orderFont; 72 67 protected ElemStyles.StyleSet styles; … … 294 289 for(LineElemStyle s : l.overlays) { 295 290 if(!s.over) { 296 lastN = null; 297 for(Node n : w.getNodes()) { 298 if(lastN != null) { 299 drawSeg(lastN, n, s.color != null && !data.isSelected(w) ? s.color : color, 300 false, s.getWidth(width), s.getDashed(), s.dashedColor); 301 } 302 lastN = n; 303 } 291 drawWay(w, s.color != null && !data.isSelected(w) ? s.color : color, s.getWidth(width), 292 s.getDashed(), s.dashedColor, false, false); 304 293 } 305 294 } … … 307 296 308 297 /* draw the way */ 309 lastN = null; 310 Iterator<Node> it = w.getNodes().iterator(); 311 while (it.hasNext()) 312 { 313 Node n = it.next(); 314 if(lastN != null) { 315 drawSeg(lastN, n, color, 316 showOnlyHeadArrowOnly ? !it.hasNext() : showDirection, width, dashed, dashedColor); 317 } 318 lastN = n; 319 } 298 drawWay(w, color, width, dashed, dashedColor, showDirection, showOnlyHeadArrowOnly); 320 299 321 300 /* draw overlays above the way */ 322 if(l != null && l.overlays != null) 323 { 324 for(LineElemStyle s : l.overlays) 325 { 326 if(s.over) 327 { 328 lastN = null; 329 for(Node n : w.getNodes()) 330 { 331 if(lastN != null) 332 { 333 drawSeg(lastN, n, s.color != null && !data.isSelected(w) ? s.color : color, 334 false, s.getWidth(width), s.getDashed(), s.dashedColor); 335 } 336 lastN = n; 337 } 301 if(l != null && l.overlays != null) { 302 for(LineElemStyle s : l.overlays) { 303 if(s.over) { 304 drawWay(w, s.color != null && !data.isSelected(w) ? s.color : color, s.getWidth(width), 305 s.getDashed(), s.dashedColor, false, false); 338 306 } 339 307 } … … 354 322 } 355 323 } 356 displaySegments(); 324 } 325 326 public void drawWay(Way way, Color color, int width, float dashed[], Color dashedColor, boolean showDirection, 327 boolean showHeadArrowOnly) { 328 329 GeneralPath path = new GeneralPath(); 330 331 Node lastN = null; 332 Iterator<Node> it = way.getNodes().iterator(); 333 while (it.hasNext()) { 334 Node n = it.next(); 335 if(lastN != null) { 336 drawSegment(path, nc.getPoint(lastN), nc.getPoint(n), (showHeadArrowOnly ? !it.hasNext() : showDirection)); 337 } 338 lastN = n; 339 } 340 displaySegments(path, color, width, dashed, dashedColor); 341 } 342 343 private void displaySegments(GeneralPath path, Color color, int width, float dashed[], Color dashedColor) { 344 if (path != null) { 345 g.setColor(color); 346 if (useStrokes > dist) { 347 if (dashed.length > 0) { 348 g.setStroke(new BasicStroke(width,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0, dashed,0)); 349 } else { 350 g.setStroke(new BasicStroke(width,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); 351 } 352 } 353 g.draw(path); 354 355 if(useStrokes > dist && dashedColor != null) { 356 g.setColor(dashedColor); 357 if (dashed.length > 0) { 358 float[] dashedOffset = new float[dashed.length]; 359 System.arraycopy(dashed, 1, dashedOffset, 0, dashed.length - 1); 360 dashedOffset[dashed.length-1] = dashed[0]; 361 float offset = dashedOffset[0]; 362 g.setStroke(new BasicStroke(width,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0,dashedOffset,offset)); 363 } else { 364 g.setStroke(new BasicStroke(width,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); 365 } 366 g.draw(path); 367 } 368 369 if(useStrokes > dist) { 370 g.setStroke(new BasicStroke()); 371 } 372 } 357 373 } 358 374 … … 1184 1200 } 1185 1201 1186 private void drawSeg(Node n1, Node n2, Color col, boolean showDirection, int width, float dashed[], Color dashedColor) {1187 if (col != currentColor || width != currentWidth || !Arrays.equals(dashed,currentDashed) || dashedColor != currentDashedColor) {1188 displaySegments(col, width, dashed, dashedColor);1189 }1190 Point p1 = nc.getPoint(n1);1191 Point p2 = nc.getPoint(n2);1192 1193 if (!isSegmentVisible(p1, p2))1194 return;1195 currentPath.moveTo(p1.x, p1.y);1196 currentPath.lineTo(p2.x, p2.y);1197 1198 if (showDirection) {1199 double t = Math.atan2(p2.y-p1.y, p2.x-p1.x) + Math.PI;1200 currentPath.lineTo((int)(p2.x + 10*Math.cos(t-PHI)), (int)(p2.y + 10*Math.sin(t-PHI)));1201 currentPath.moveTo((int)(p2.x + 10*Math.cos(t+PHI)), (int)(p2.y + 10*Math.sin(t+PHI)));1202 currentPath.lineTo(p2.x, p2.y);1203 }1204 }1205 1206 @Override1207 protected void displaySegments() {1208 displaySegments(null, 0, new float[0], null);1209 }1210 1211 protected void displaySegments(Color newColor, int newWidth, float newDash[], Color newDashedColor) {1212 if (currentPath != null) {1213 g.setColor(inactive ? inactiveColor : currentColor);1214 if (currentStroke == null && useStrokes > dist) {1215 if (currentDashed.length > 0) {1216 g.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0,currentDashed,0));1217 } else {1218 g.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));1219 }1220 }1221 g.draw(currentPath);1222 1223 if(currentDashedColor != null) {1224 g.setColor(currentDashedColor);1225 if (currentStroke == null && useStrokes > dist) {1226 if (currentDashed.length > 0) {1227 float[] currentDashedOffset = new float[currentDashed.length];1228 System.arraycopy(currentDashed, 1, currentDashedOffset, 0, currentDashed.length - 1);1229 currentDashedOffset[currentDashed.length-1] = currentDashed[0];1230 float offset = currentDashedOffset[0];1231 g.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0,currentDashedOffset,offset));1232 } else {1233 g.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));1234 }1235 }1236 g.draw(currentPath);1237 }1238 1239 if(useStrokes > dist) {1240 g.setStroke(new BasicStroke(1));1241 }1242 1243 currentPath = new GeneralPath();1244 currentColor = newColor;1245 currentWidth = newWidth;1246 currentDashed = newDash;1247 currentDashedColor = newDashedColor;1248 currentStroke = null;1249 }1250 }1251 1202 1252 1203 /** … … 1402 1353 /*** SELECTED ***/ 1403 1354 for (final OsmPrimitive osm : data.getSelected()) { 1404 if (osm.isUsable() && !(osm instanceof Node) && osm.mappaintDrawnCode != paintid 1405 ) { 1355 if (osm.isUsable() && !(osm instanceof Node) && osm.mappaintDrawnCode != paintid) { 1406 1356 osm.visit(new AbstractVisitor() { 1407 1357 public void visit(Way w) { … … 1410 1360 1411 1361 public void visit(Node n) { 1412 drawNode(n);1362 // Selected nodes are painted in following part 1413 1363 } 1414 1364 1415 1365 public void visit(Relation r) { 1416 1366 /* TODO: is it possible to do this like the nodes/ways code? */ 1367 // Only nodes are painted, ways was already painted before (this might cause that 1368 // way in selected relation is hidden by another way) 1417 1369 for (RelationMember m : r.getMembers()) { 1418 1370 if (m.isNode() && m.getMember().isDrawable()) { … … 1425 1377 } 1426 1378 1427 /*** DISPLAY CACHED SEGMENTS (WAYS) NOW ***/1428 displaySegments();1429 1430 1379 /*** NODES ***/ 1431 1380 for (final Node osm: data.searchNodes(bbox)) { 1432 1381 if (!osm.isIncomplete() && !osm.isDeleted() && (data.isSelected(osm) || !osm.isFiltered()) 1433 && osm.mappaintDrawnCode != paintid) 1434 { 1382 && osm.mappaintDrawnCode != paintid) { 1435 1383 drawNode(osm); 1436 1384 } 1437 1385 } 1438 1386 1439 /*** VIRTUAL ***/ 1440 if (virtualNodeSize != 0) { 1441 currentColor = nodeColor; 1442 for (final OsmPrimitive osm: data.searchWays(bbox)) { 1443 if (osm.isUsable() && !osm.isFiltered()) 1444 { 1445 /* TODO: move this into the SimplePaint code? */ 1446 visitVirtual((Way)osm); 1447 } 1448 } 1449 displaySegments(null); 1450 } 1387 drawVirtualNodes(data.searchWays(bbox)); 1451 1388 } 1452 1389 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
r2659 r2663 15 15 import java.awt.Stroke; 16 16 import java.awt.geom.GeneralPath; 17 import java.util.Collection; 17 18 import java.util.Iterator; 18 19 … … 215 216 //} 216 217 217 if (virtualNodeSize != 0) { 218 // profilerN = 0; 219 currentColor = nodeColor; 220 for (final OsmPrimitive osm:data.getWays()){ 221 if (!osm.isDeleted() && !osm.isDisabled() && !osm.isFiltered()) { 222 visitVirtual((Way) osm); 223 // profilerN++; 224 } 225 } 226 displaySegments(); 227 228 // if(profiler) 229 // { 230 // System.out.format("Virtual : %4dms, n=%5d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 231 // profilerLast = java.lang.System.currentTimeMillis(); 232 // } 233 } 218 drawVirtualNodes(data.getWays()); 234 219 235 220 //if(profiler) … … 272 257 } 273 258 274 public void visitVirtual(Way w) { 259 public void drawVirtualNodes(Collection<Way> ways) { 260 261 if (virtualNodeSize != 0) { 262 GeneralPath path = new GeneralPath(); 263 for (Way osm: ways){ 264 if (osm.isUsable() && !osm.isFiltered()) { 265 visitVirtual(path, osm); 266 } 267 } 268 g.setColor(nodeColor); 269 g.draw(path); 270 } 271 } 272 273 public void visitVirtual(GeneralPath path, Way w) { 275 274 Iterator<Node> it = w.getNodes().iterator(); 276 275 if (it.hasNext()) { … … 283 282 int x = (p.x+lastP.x)/2; 284 283 int y = (p.y+lastP.y)/2; 285 currentPath.moveTo(x-virtualNodeSize, y);286 currentPath.lineTo(x+virtualNodeSize, y);287 currentPath.moveTo(x, y-virtualNodeSize);288 currentPath.lineTo(x, y+virtualNodeSize);284 path.moveTo(x-virtualNodeSize, y); 285 path.lineTo(x+virtualNodeSize, y); 286 path.moveTo(x, y-virtualNodeSize); 287 path.lineTo(x, y+virtualNodeSize); 289 288 } 290 289 lastP = p; … … 435 434 } 436 435 436 protected void drawSegment(GeneralPath path, Point p1, Point p2, boolean showDirection) { 437 if (isSegmentVisible(p1, p2)) { 438 path.moveTo(p1.x, p1.y); 439 path.lineTo(p2.x, p2.y); 440 441 if (showDirection) { 442 double t = Math.atan2(p2.y-p1.y, p2.x-p1.x) + Math.PI; 443 path.lineTo((int)(p2.x + 10*Math.cos(t-PHI)), (int)(p2.y + 10*Math.sin(t-PHI))); 444 path.moveTo((int)(p2.x + 10*Math.cos(t+PHI)), (int)(p2.y + 10*Math.sin(t+PHI))); 445 path.lineTo(p2.x, p2.y); 446 } 447 } 448 } 449 437 450 /** 438 451 * Draw a line with the given color. … … 442 455 displaySegments(col); 443 456 } 444 445 if (isSegmentVisible(p1, p2)) { 446 currentPath.moveTo(p1.x, p1.y); 447 currentPath.lineTo(p2.x, p2.y); 448 449 if (showDirection) { 450 double t = Math.atan2(p2.y-p1.y, p2.x-p1.x) + Math.PI; 451 currentPath.lineTo((int)(p2.x + 10*Math.cos(t-PHI)), (int)(p2.y + 10*Math.sin(t-PHI))); 452 currentPath.moveTo((int)(p2.x + 10*Math.cos(t+PHI)), (int)(p2.y + 10*Math.sin(t+PHI))); 453 currentPath.lineTo(p2.x, p2.y); 454 } 455 } 457 drawSegment(currentPath, p1, p2, showDirection); 456 458 } 457 459 -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java
r2662 r2663 6 6 package org.openstreetmap.josm.gui.layer.geoimage; 7 7 8 import java.awt.Image; 8 9 import java.io.File; 9 10 import java.util.Date; 10 import java.awt.Image;11 11 12 12 import org.openstreetmap.josm.data.coor.CachedLatLon; … … 29 29 30 30 Image thumbnail; 31 31 32 32 ImageEntry tmp; 33 33 34 34 public CachedLatLon getPos() { 35 if (tmp != null) {35 if (tmp != null) 36 36 return tmp.pos; 37 }38 37 return pos; 39 38 } 40 39 public Double getSpeed() { 41 if (tmp != null) {40 if (tmp != null) 42 41 return tmp.speed; 43 }44 42 return speed; 45 43 } 46 44 public Double getElevation() { 47 if (tmp != null) {45 if (tmp != null) 48 46 return tmp.elevation; 49 }50 47 return elevation; 51 48 } … … 56 53 this.speed = speed; 57 54 } 58 public void setElevation(Double speed) {55 public void setElevation(Double elevation) { 59 56 this.elevation = elevation; 60 57 } … … 70 67 return (ImageEntry) c; 71 68 } 72 69 73 70 public void setCoor(LatLon latlon) 74 71 { … … 86 83 return 1; 87 84 } 88 85 89 86 public void applyTmp() { 90 87 if (tmp != null) { … … 100 97 tmp.tmp = null; 101 98 } 102 99 103 100 public boolean isTagged() { 104 101 return pos != null; 105 102 } 106 103 107 104 /** 108 105 * only partial info 109 106 */ 107 @Override 110 108 public String toString() { 111 109 String result = file.getName()+": "+ 112 113 114 115 110 "pos = "+pos+" | "+ 111 "exifCoor = "+exifCoor+" | "+ 112 (tmp == null ? " tmp==null" : 113 " [tmp] pos = "+tmp.pos+""); 116 114 return result; 117 115 }
Note:
See TracChangeset
for help on using the changeset viewer.