Changeset 2580 in josm for trunk/src/org
- Timestamp:
- 2009-12-06T11:52:51+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
r2578 r2580 59 59 protected boolean drawRestriction; 60 60 protected boolean leftHandTraffic; 61 //protected boolean restrictionDebug;62 61 protected int showNames; 63 62 protected int showIcons; … … 81 80 private EastNorth maxEN; 82 81 83 //protected int profilerVisibleNodes;84 //protected int profilerVisibleWays;85 //protected int profilerVisibleAreas;86 //protected int profilerSegments;87 //protected int profilerVisibleSegments;88 //protected boolean profilerOmitDraw;89 90 82 protected boolean isZoomOk(ElemStyle e) { 91 83 if (!zoomLevelDisplay) /* show everything if the user wishes so */ … … 151 143 IconElemStyle nodeStyle = (IconElemStyle)getPrimitiveStyle(n); 152 144 153 //if(profilerOmitDraw)154 // return;155 156 145 if (nodeStyle != null && isZoomOk(nodeStyle) && showIcons > dist) { 157 146 if (inactive || n.isDisabled()) { … … 219 208 { 220 209 /* way without style */ 221 //profilerVisibleWays++;222 //if(!profilerOmitDraw)223 210 drawWay(w, null, untaggedColor, data.isSelected(w)); 224 211 } … … 226 213 { 227 214 /* way with line style */ 228 //profilerVisibleWays++;229 //if(!profilerOmitDraw)230 215 drawWay(w, (LineElemStyle)wayStyle, untaggedColor, data.isSelected(w)); 231 216 } … … 234 219 AreaElemStyle areaStyle = (AreaElemStyle) wayStyle; 235 220 /* way with area style */ 236 //if(!profilerOmitDraw)237 //{238 221 if (fillAreas > dist) 239 222 { 240 // profilerVisibleAreas++;241 223 drawArea(w, data.isSelected(w) ? selectedColor : areaStyle.color); 242 224 if(!w.isClosed()) { … … 245 227 } 246 228 drawWay(w, areaStyle.line, areaStyle.color, data.isSelected(w)); 247 //}248 229 } 249 230 } … … 468 449 w = new Way(w); 469 450 w.setNodes(n); 470 // Do not mess with the DataSet's contents here.471 451 } 472 452 if(!w.isClosed()) … … 544 524 } 545 525 546 /* this current experimental implementation will only work for standard restrictions:547 from(Way) / via(Node) / to(Way) */548 526 public void drawRestriction(Relation r) { 549 //if(restrictionDebug)550 // System.out.println("Restriction: " + r.keys.get("name") + " restriction " + r.keys.get("restriction"));551 552 527 Way fromWay = null; 553 528 Way toWay = null; … … 557 532 for (RelationMember m : r.getMembers()) 558 533 { 559 //if(restrictionDebug)560 // System.out.println("member " + m.member + " selected " + r.selected);561 562 534 if (m.getMember().isDeleted()) { 563 535 putError(r, tr("Deleted member ''{0}'' in relation.", … … 677 649 Node fromNode = null; 678 650 if(fromWay.firstNode() == via) { 679 //System.out.println("From way heading away from via");680 651 fromNode = fromWay.getNode(1); 681 652 } else { 682 //System.out.println("From way heading towards via");683 653 fromNode = fromWay.getNode(fromWay.getNodesCount()-2); 684 654 } … … 686 656 Point pFrom = nc.getPoint(fromNode); 687 657 Point pVia = nc.getPoint(viaNode); 688 689 //if(restrictionDebug) {690 /* find the "direct" node after the via node */691 // Node toNode = null;692 // if(toWay.firstNode() == via) {693 // System.out.println("To way heading away from via");694 // toNode = toWay.nodes.get(1);695 // } else {696 // System.out.println("To way heading towards via");697 // toNode = toWay.nodes.get(toWay.nodes.size()-2);698 // }699 // Point pTo = nc.getPoint(toNode);700 701 // /* debug output of interesting nodes */702 // System.out.println("From: " + fromNode);703 // drawNode(fromNode, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode);704 // System.out.println("Via: " + via);705 // drawNode(via, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode);706 // System.out.println("To: " + toNode);707 // drawNode(toNode, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode);708 // System.out.println("From X: " + pFrom.x + " Y " + pFrom.y);709 // System.out.println("Via X: " + pVia.x + " Y " + pVia.y);710 // System.out.println("To X: " + pTo.x + " Y " + pTo.y);711 //}712 658 713 659 /* starting from via, go back the "from" way a few pixels … … 736 682 vy = -vy; 737 683 } 738 739 //if(restrictionDebug)740 // System.out.println("vx " + vx + " vy " + vy);741 684 742 685 /* go a few pixels away from the way (in a right angle) … … 798 741 799 742 /* rotate icon with direction last node in from to */ 800 //if(restrictionDebug)801 // System.out.println("Deg1 " + fromAngleDeg + " Deg2 " + (fromAngleDeg + 180) + " Icon " + iconAngle);802 743 ImageIcon rotatedIcon = ImageProvider.createRotatedImage(null /*icon2*/, inactive || r.isDisabled() ? 803 744 nodeStyle.getDisabledIcon() : … … 1171 1112 (int)nb.getHeight()); 1172 1113 1173 //// Draw name bounding box for debugging:1174 // g.setColor(new Color(255,255,0,128));1175 // g.drawRect((int)centeredNBounds.getMinX(),1176 // (int)centeredNBounds.getMinY(),1177 // (int)centeredNBounds.getWidth(),1178 // (int)centeredNBounds.getHeight());1179 1180 1114 if ((pb.width >= nb.getWidth() && pb.height >= nb.getHeight()) && // quick check 1181 1115 polygon.contains(centeredNBounds) // slow but nice … … 1217 1151 if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) || (p.y > nc.getHeight())) return; 1218 1152 1219 //profilerVisibleNodes++;1220 1221 1153 int w = icon.getIconWidth(), h=icon.getIconHeight(); 1222 1154 icon.paintIcon ( Main.map.mapView, g, p.x-w/2, p.y-h/2 ); … … 1258 1190 1259 1191 private void drawSeg(Node n1, Node n2, Color col, boolean showDirection, int width, float dashed[], Color dashedColor) { 1260 //profilerSegments++;1261 1192 if (col != currentColor || width != currentWidth || !Arrays.equals(dashed,currentDashed) || dashedColor != currentDashedColor) { 1262 1193 displaySegments(col, width, dashed, dashedColor); … … 1267 1198 if (!isSegmentVisible(p1, p2)) 1268 1199 return; 1269 //profilerVisibleSegments++;1270 1200 currentPath.moveTo(p1.x, p1.y); 1271 1201 currentPath.lineTo(p2.x, p2.y); … … 1348 1278 return; 1349 1279 1350 //profilerVisibleNodes++;1351 1352 1280 if (inactive || n.isDisabled()) { 1353 1281 g.setColor(inactiveColor); … … 1419 1347 BBox bbox = new BBox(bounds); 1420 1348 this.data = data; 1421 //boolean profiler = Main.pref.getBoolean("mappaint.profiler",false);1422 //profilerOmitDraw = Main.pref.getBoolean("mappaint.profiler.omitdraw",false);1423 1349 1424 1350 useStyleCache = Main.pref.getBoolean("mappaint.cache", true); … … 1432 1358 dist = ll1.greatCircleDistance(ll2); 1433 1359 1434 //long profilerStart = java.lang.System.currentTimeMillis();1435 //long profilerLast = profilerStart;1436 //int profilerN;1437 //if(profiler)1438 // System.out.println("Mappaint Profiler (" +1439 // (useStyleCache ? "cache=true, " : "cache=false, ") +1440 // "fillareas " + fillAreas + ", " +1441 // "fillalpha=" + fillAlpha + "%, " +1442 // "dist=" + (int)dist + "m)");1443 1444 1360 getSettings(virtual); 1445 1361 useRealWidth = Main.pref.getBoolean("mappaint.useRealWidth", false); … … 1449 1365 drawMultipolygon = Main.pref.getBoolean("mappaint.multipolygon", true); 1450 1366 drawRestriction = Main.pref.getBoolean("mappaint.restriction", true); 1451 //restrictionDebug = Main.pref.getBoolean("mappaint.restriction.debug",false);1452 1367 leftHandTraffic = Main.pref.getBoolean("mappaint.lefthandtraffic", false); 1453 1368 orderFont = new Font(Main.pref.get("mappaint.font", "Helvetica"), Font.PLAIN, Main.pref.getInteger("mappaint.fontsize", 8)); … … 1461 1376 ++paintid; 1462 1377 1463 //profilerVisibleNodes = 0;1464 //profilerVisibleWays = 0;1465 //profilerVisibleAreas = 0;1466 //profilerSegments = 0;1467 //profilerVisibleSegments = 0;1468 1469 //if(profiler)1470 //{1471 // System.out.format("Prepare : %5dms\n", (java.lang.System.currentTimeMillis()-profilerLast));1472 // profilerLast = java.lang.System.currentTimeMillis();1473 //}1474 1475 1378 if (fillAreas > dist && styles != null && styles.hasAreas()) { 1476 1379 Collection<Way> noAreaWays = new LinkedList<Way>(); 1477 1380 1478 1381 /*** RELATIONS ***/ 1479 // profilerN = 0;1480 1382 for (final Relation osm: data.getRelations()) { 1481 1383 if (drawable(osm)) { 1482 1384 paintUnselectedRelation(osm); 1483 // profilerN++; 1484 } 1485 } 1486 1487 // if(profiler) 1488 // { 1489 // System.out.format("Relations: %5dms, calls=%7d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 1490 // profilerLast = java.lang.System.currentTimeMillis(); 1491 // } 1385 } 1386 } 1492 1387 1493 1388 /*** AREAS ***/ 1494 // profilerN = 0;1495 1389 for (final Way osm : selectedLast(data, data.searchWays(bbox))) { 1496 1390 if (drawable(osm) && osm.mappaintDrawnCode != paintid) { 1497 if (isPrimitiveArea(osm) && osm.mappaintDrawnAreaCode != paintid) {1391 if (isPrimitiveArea(osm) && osm.mappaintDrawnAreaCode != paintid) 1498 1392 drawWay(osm, fillAreas); 1499 // profilerN++; 1500 }// else { 1501 noAreaWays.add(osm); 1502 //} 1503 } 1504 } 1505 1506 // if(profiler) 1507 // { 1508 // System.out.format("Areas : %5dms, calls=%7d, visible=%d\n", 1509 // (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleAreas); 1510 // profilerLast = java.lang.System.currentTimeMillis(); 1511 // } 1393 else 1394 noAreaWays.add(osm); 1395 } 1396 } 1512 1397 1513 1398 /*** WAYS ***/ 1514 // profilerN = 0;1515 1399 for (final Way osm : noAreaWays) { 1516 1400 drawWay(osm, 0); 1517 // profilerN++; 1518 } 1519 1520 // if(profiler) 1521 // { 1522 // System.out.format("Ways : %5dms, calls=%7d, visible=%d\n", 1523 // (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleWays); 1524 // profilerLast = java.lang.System.currentTimeMillis(); 1525 // } 1401 } 1526 1402 } else { 1527 1403 /*** WAYS (filling disabled) ***/ 1528 // profilerN = 0;1529 1404 for (final Way way: data.getWays()) { 1530 1405 if (drawable(way) && !data.isSelected(way)) { 1531 1406 drawWay(way, 0); 1532 // profilerN++; 1533 } 1534 } 1535 1536 // if(profiler) 1537 // { 1538 // System.out.format("Ways : %5dms, calls=%7d, visible=%d\n", 1539 // (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleWays); 1540 // profilerLast = java.lang.System.currentTimeMillis(); 1541 // } 1407 } 1408 } 1542 1409 } 1543 1410 1544 1411 /*** SELECTED ***/ 1545 //profilerN = 0;1546 1412 for (final OsmPrimitive osm : data.getSelected()) { 1547 1413 if (!osm.isIncomplete() && !osm.isDeleted() && !(osm instanceof Node) … … 1559 1425 public void visit(Relation r) { 1560 1426 /* TODO: is it possible to do this like the nodes/ways code? */ 1561 //if(profilerOmitDraw)1562 // return;1563 1427 for (RelationMember m : r.getMembers()) { 1564 1428 if (m.isNode() && drawable(m.getMember())) { … … 1568 1432 } 1569 1433 }); 1570 // profilerN++; 1571 } 1572 } 1573 1574 //if(profiler) 1575 //{ 1576 // System.out.format("Selected : %5dms, calls=%7d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 1577 // profilerLast = java.lang.System.currentTimeMillis(); 1578 //} 1434 } 1435 } 1579 1436 1580 1437 /*** DISPLAY CACHED SEGMENTS (WAYS) NOW ***/ … … 1582 1439 1583 1440 /*** NODES ***/ 1584 //profilerN = 0;1585 1441 for (final Node osm: data.searchNodes(bbox)) { 1586 1442 if (!osm.isIncomplete() && !osm.isDeleted() && (data.isSelected(osm) || !osm.isFiltered()) … … 1588 1444 { 1589 1445 drawNode(osm); 1590 // profilerN++; 1591 } 1592 } 1593 1594 //if(profiler) 1595 //{ 1596 // System.out.format("Nodes : %5dms, calls=%7d, visible=%d\n", 1597 // (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleNodes); 1598 // profilerLast = java.lang.System.currentTimeMillis(); 1599 //} 1446 } 1447 } 1600 1448 1601 1449 /*** VIRTUAL ***/ 1602 1450 if (virtualNodeSize != 0) { 1603 // profilerN = 0;1604 1451 currentColor = nodeColor; 1605 1452 for (final OsmPrimitive osm: data.searchWays(bbox)) { … … 1607 1454 { 1608 1455 /* TODO: move this into the SimplePaint code? */ 1609 // if(!profilerOmitDraw)1610 1456 visitVirtual((Way)osm); 1611 // profilerN++; 1612 } 1613 } 1614 1615 // if(profiler) 1616 // { 1617 // System.out.format("Virtual : %5dms, calls=%7d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 1618 // profilerLast = java.lang.System.currentTimeMillis(); 1619 // } 1620 1457 } 1458 } 1621 1459 displaySegments(null); 1622 1460 } 1623 1624 //if(profiler)1625 //{1626 // System.out.format("Segments : calls=%7d, visible=%d\n", profilerSegments, profilerVisibleSegments);1627 // System.out.format("All : %5dms\n", (profilerLast-profilerStart));1628 //}1629 1461 } 1630 1462
Note:
See TracChangeset
for help on using the changeset viewer.