Changeset 2580 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2009-12-06T11:52:51+01:00 (14 years ago)
Author:
stoecker
Message:

fixed regression - ways have been drawn below areas

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java

    r2578 r2580  
    5959    protected boolean drawRestriction;
    6060    protected boolean leftHandTraffic;
    61     //protected boolean restrictionDebug;
    6261    protected int showNames;
    6362    protected int showIcons;
     
    8180    private EastNorth maxEN;
    8281
    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 
    9082    protected boolean isZoomOk(ElemStyle e) {
    9183        if (!zoomLevelDisplay) /* show everything if the user wishes so */
     
    151143        IconElemStyle nodeStyle = (IconElemStyle)getPrimitiveStyle(n);
    152144
    153         //if(profilerOmitDraw)
    154         //    return;
    155 
    156145        if (nodeStyle != null && isZoomOk(nodeStyle) && showIcons > dist) {
    157146            if (inactive || n.isDisabled()) {
     
    219208        {
    220209            /* way without style */
    221             //profilerVisibleWays++;
    222             //if(!profilerOmitDraw)
    223210            drawWay(w, null, untaggedColor, data.isSelected(w));
    224211        }
     
    226213        {
    227214            /* way with line style */
    228             //profilerVisibleWays++;
    229             //if(!profilerOmitDraw)
    230215            drawWay(w, (LineElemStyle)wayStyle, untaggedColor, data.isSelected(w));
    231216        }
     
    234219            AreaElemStyle areaStyle = (AreaElemStyle) wayStyle;
    235220            /* way with area style */
    236             //if(!profilerOmitDraw)
    237             //{
    238221            if (fillAreas > dist)
    239222            {
    240                 //    profilerVisibleAreas++;
    241223                drawArea(w, data.isSelected(w) ? selectedColor : areaStyle.color);
    242224                if(!w.isClosed()) {
     
    245227            }
    246228            drawWay(w, areaStyle.line, areaStyle.color, data.isSelected(w));
    247             //}
    248229        }
    249230    }
     
    468449                w = new Way(w);
    469450                w.setNodes(n);
    470                 // Do not mess with the DataSet's contents here.
    471451            }
    472452            if(!w.isClosed())
     
    544524    }
    545525
    546     /* this current experimental implementation will only work for standard restrictions:
    547        from(Way) / via(Node) / to(Way) */
    548526    public void drawRestriction(Relation r) {
    549         //if(restrictionDebug)
    550         //    System.out.println("Restriction: " + r.keys.get("name") + " restriction " + r.keys.get("restriction"));
    551 
    552527        Way fromWay = null;
    553528        Way toWay = null;
     
    557532        for (RelationMember m : r.getMembers())
    558533        {
    559             //if(restrictionDebug)
    560             //    System.out.println("member " + m.member + " selected " + r.selected);
    561 
    562534            if (m.getMember().isDeleted()) {
    563535                putError(r, tr("Deleted member ''{0}'' in relation.",
     
    677649        Node fromNode = null;
    678650        if(fromWay.firstNode() == via) {
    679             //System.out.println("From way heading away from via");
    680651            fromNode = fromWay.getNode(1);
    681652        } else {
    682             //System.out.println("From way heading towards via");
    683653            fromNode = fromWay.getNode(fromWay.getNodesCount()-2);
    684654        }
     
    686656        Point pFrom = nc.getPoint(fromNode);
    687657        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         //}
    712658
    713659        /* starting from via, go back the "from" way a few pixels
     
    736682            vy = -vy;
    737683        }
    738 
    739         //if(restrictionDebug)
    740         //    System.out.println("vx " + vx + " vy " + vy);
    741684
    742685        /* go a few pixels away from the way (in a right angle)
     
    798741
    799742        /* rotate icon with direction last node in from to */
    800         //if(restrictionDebug)
    801         //    System.out.println("Deg1 " + fromAngleDeg + " Deg2 " + (fromAngleDeg + 180) + " Icon " + iconAngle);
    802743        ImageIcon rotatedIcon = ImageProvider.createRotatedImage(null /*icon2*/, inactive || r.isDisabled() ?
    803744                                                                                    nodeStyle.getDisabledIcon() :
     
    11711112                        (int)nb.getHeight());
    11721113
    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 
    11801114                if ((pb.width >= nb.getWidth() && pb.height >= nb.getHeight()) && // quick check
    11811115                        polygon.contains(centeredNBounds) // slow but nice
     
    12171151        if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) || (p.y > nc.getHeight())) return;
    12181152
    1219         //profilerVisibleNodes++;
    1220 
    12211153        int w = icon.getIconWidth(), h=icon.getIconHeight();
    12221154        icon.paintIcon ( Main.map.mapView, g, p.x-w/2, p.y-h/2 );
     
    12581190
    12591191    private void drawSeg(Node n1, Node n2, Color col, boolean showDirection, int width, float dashed[], Color dashedColor) {
    1260         //profilerSegments++;
    12611192        if (col != currentColor || width != currentWidth || !Arrays.equals(dashed,currentDashed) || dashedColor != currentDashedColor) {
    12621193            displaySegments(col, width, dashed, dashedColor);
     
    12671198        if (!isSegmentVisible(p1, p2))
    12681199            return;
    1269         //profilerVisibleSegments++;
    12701200        currentPath.moveTo(p1.x, p1.y);
    12711201        currentPath.lineTo(p2.x, p2.y);
     
    13481278                return;
    13491279
    1350             //profilerVisibleNodes++;
    1351 
    13521280            if (inactive || n.isDisabled()) {
    13531281                g.setColor(inactiveColor);
     
    14191347        BBox bbox = new BBox(bounds);
    14201348        this.data = data;
    1421         //boolean profiler = Main.pref.getBoolean("mappaint.profiler",false);
    1422         //profilerOmitDraw = Main.pref.getBoolean("mappaint.profiler.omitdraw",false);
    14231349
    14241350        useStyleCache = Main.pref.getBoolean("mappaint.cache", true);
     
    14321358        dist = ll1.greatCircleDistance(ll2);
    14331359
    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 
    14441360        getSettings(virtual);
    14451361        useRealWidth = Main.pref.getBoolean("mappaint.useRealWidth", false);
     
    14491365        drawMultipolygon = Main.pref.getBoolean("mappaint.multipolygon", true);
    14501366        drawRestriction = Main.pref.getBoolean("mappaint.restriction", true);
    1451         //restrictionDebug = Main.pref.getBoolean("mappaint.restriction.debug",false);
    14521367        leftHandTraffic = Main.pref.getBoolean("mappaint.lefthandtraffic", false);
    14531368        orderFont = new Font(Main.pref.get("mappaint.font", "Helvetica"), Font.PLAIN, Main.pref.getInteger("mappaint.fontsize", 8));
     
    14611376        ++paintid;
    14621377
    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 
    14751378        if (fillAreas > dist && styles != null && styles.hasAreas()) {
    14761379            Collection<Way> noAreaWays = new LinkedList<Way>();
    14771380
    14781381            /*** RELATIONS ***/
    1479             //    profilerN = 0;
    14801382            for (final Relation osm: data.getRelations()) {
    14811383                if (drawable(osm)) {
    14821384                    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            }
    14921387
    14931388            /*** AREAS ***/
    1494             //    profilerN = 0;
    14951389            for (final Way osm : selectedLast(data, data.searchWays(bbox))) {
    14961390                if (drawable(osm) && osm.mappaintDrawnCode != paintid) {
    1497                     if (isPrimitiveArea(osm) && osm.mappaintDrawnAreaCode != paintid) {
     1391                    if (isPrimitiveArea(osm) && osm.mappaintDrawnAreaCode != paintid)
    14981392                        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            }
    15121397
    15131398            /*** WAYS ***/
    1514             //    profilerN = 0;
    15151399            for (final Way osm : noAreaWays) {
    15161400                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            }
    15261402        } else {
    15271403            /*** WAYS (filling disabled)  ***/
    1528             //    profilerN = 0;
    15291404            for (final Way way: data.getWays()) {
    15301405                if (drawable(way) && !data.isSelected(way)) {
    15311406                    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            }
    15421409        }
    15431410
    15441411        /*** SELECTED  ***/
    1545         //profilerN = 0;
    15461412        for (final OsmPrimitive osm : data.getSelected()) {
    15471413            if (!osm.isIncomplete() && !osm.isDeleted() && !(osm instanceof Node)
     
    15591425                    public void visit(Relation r) {
    15601426                        /* TODO: is it possible to do this like the nodes/ways code? */
    1561                         //if(profilerOmitDraw)
    1562                         //    return;
    15631427                        for (RelationMember m : r.getMembers()) {
    15641428                            if (m.isNode() && drawable(m.getMember())) {
     
    15681432                    }
    15691433                });
    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        }
    15791436
    15801437        /*** DISPLAY CACHED SEGMENTS (WAYS) NOW ***/
     
    15821439
    15831440        /*** NODES ***/
    1584         //profilerN = 0;
    15851441        for (final Node osm: data.searchNodes(bbox)) {
    15861442            if (!osm.isIncomplete() && !osm.isDeleted() && (data.isSelected(osm) || !osm.isFiltered())
     
    15881444            {
    15891445                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        }
    16001448
    16011449        /*** VIRTUAL  ***/
    16021450        if (virtualNodeSize != 0) {
    1603             //    profilerN = 0;
    16041451            currentColor = nodeColor;
    16051452            for (final OsmPrimitive osm: data.searchWays(bbox)) {
     
    16071454                {
    16081455                    /* TODO: move this into the SimplePaint code? */
    1609                     //            if(!profilerOmitDraw)
    16101456                    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            }
    16211459            displaySegments(null);
    16221460        }
    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         //}
    16291461    }
    16301462
Note: See TracChangeset for help on using the changeset viewer.