Ignore:
Timestamp:
2009-01-10T20:51:48+01:00 (15 years ago)
Author:
ulfl
Message:

first set of performance optimizations:

  • don't call Main.pref.get() when getting a style name, cache the name and only update once for each visitAll
  • check first, if a Way/Node to display is visible at all
File:
1 edited

Legend:

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

    r1221 r1235  
    7676     */
    7777    public void visit(Node n) {
     78        // check, if the node is visible at all
     79        Point p = nc.getPoint(n.eastNorth);
     80        if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) || (p.y > nc.getHeight())) return;
     81       
    7882        IconElemStyle nodeStyle = (IconElemStyle)styles.get(n);
    7983        if (nodeStyle != null && isZoomOk(nodeStyle))
     
    9599            return;
    96100
     101        // check, if the way is visible at all
     102        Polygon polygon = new Polygon();
     103        for (Node n : w.nodes)
     104        {
     105            Point p = nc.getPoint(n.eastNorth);
     106            polygon.addPoint(p.x,p.y);
     107        }
     108        if(!isPolygonVisible(polygon))
     109            return;
     110       
    97111        ElemStyle wayStyle = styles.get(w);
    98112
     
    104118        if(wayStyle!=null)
    105119        {
    106             boolean area = false;
    107120            if(wayStyle instanceof LineElemStyle)
    108121                l = (LineElemStyle)wayStyle;
     
    111124                areacolor = ((AreaElemStyle)wayStyle).color;
    112125                l = ((AreaElemStyle)wayStyle).line;
    113                 area = true;
    114             }
    115             if (area && fillAreas)
    116                 drawWayAsArea(w, areacolor);
     126                if (fillAreas)
     127                    drawWayAsArea(w, areacolor);
     128            }
    117129        }
    118130
     
    129141        int realWidth = 0; //the real width of the element in meters
    130142        boolean dashed = false;
     143        Node lastN;
    131144
    132145        if(l != null)
     
    147160            color = selectedColor;
    148161
    149         Node lastN;
     162        // draw overlays under the way
    150163        if(l != null && l.overlays != null)
    151164        {
     
    168181        }
    169182
     183        // draw the way
    170184        lastN = null;
    171185        for(Node n : w.nodes)
     
    176190        }
    177191
     192        // draw overlays above the way
    178193        if(l != null && l.overlays != null)
    179194        {
     
    799814        alreadyDrawnAreas = new LinkedList<Way>();
    800815        selectedCall = false;
    801 
     816       
     817        // update the style name, just in case the user changed it in the meantime
     818        styles.updateStyleName();
     819       
    802820        if(profiler)
    803821        {
Note: See TracChangeset for help on using the changeset viewer.