Changeset 1236 in josm for trunk/src/org


Ignore:
Timestamp:
2009-01-11T00:01:00+01:00 (15 years ago)
Author:
stoecker
Message:

removed some double code

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

    r1235 r1236  
    7979        Point p = nc.getPoint(n.eastNorth);
    8080        if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) || (p.y > nc.getHeight())) return;
    81        
     81
    8282        IconElemStyle nodeStyle = (IconElemStyle)styles.get(n);
    8383        if (nodeStyle != null && isZoomOk(nodeStyle))
     
    100100
    101101        // 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         }
     102        Polygon polygon = getPolygon(w);
    108103        if(!isPolygonVisible(polygon))
    109104            return;
    110        
     105
    111106        ElemStyle wayStyle = styles.get(w);
    112107
     
    125120                l = ((AreaElemStyle)wayStyle).line;
    126121                if (fillAreas)
    127                     drawWayAsArea(w, areacolor);
     122                    drawArea(polygon, w.selected ? selectedColor : areacolor);
    128123            }
    129124        }
     
    342337                drawWay((Way)osm, ((AreaElemStyle)style).line, selectedColor, true);
    343338                if(area)
    344                     drawWayAsArea((Way)osm, areaselected ? selectedColor
     339                    drawArea(getPolygon((Way)osm), areaselected ? selectedColor
    345340                    : ((AreaElemStyle)style).color);
    346341            }
     
    580575                for (PolyData pd : poly)
    581576                {
    582                     Color color = (pd.way.selected || r.selected) ? selectedColor
    583                     : ((AreaElemStyle)wayStyle).color;
    584                     g.setColor(new Color( color.getRed(), color.getGreen(),
    585                     color.getBlue(), fillAlpha));
    586 
    587                     g.fillPolygon(pd.get());
     577                    drawArea(pd.get(), (pd.way.selected || r.selected) ? selectedColor
     578                    : ((AreaElemStyle)wayStyle).color);
    588579                }
    589580            }
     
    653644    }
    654645
    655     protected void drawWayAsArea(Way w, Color color)
     646    protected Polygon getPolygon(Way w)
    656647    {
    657648        Polygon polygon = new Polygon();
     
    662653            polygon.addPoint(p.x,p.y);
    663654        }
    664 
    665         Color mycolor = w.selected ? selectedColor : color;
     655        return polygon;
     656    }
     657
     658    protected void drawArea(Polygon polygon, Color color)
     659    {
    666660        // set the opacity (alpha) level of the filled polygon
    667         g.setColor(new Color( mycolor.getRed(), mycolor.getGreen(), mycolor.getBlue(), fillAlpha));
    668 
     661        g.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), fillAlpha));
    669662        g.fillPolygon(polygon);
    670663    }
     
    814807        alreadyDrawnAreas = new LinkedList<Way>();
    815808        selectedCall = false;
    816        
     809
    817810        // update the style name, just in case the user changed it in the meantime
    818811        styles.updateStyleName();
    819        
    820         if(profiler) 
     812
     813        if(profiler)
    821814        {
    822815            System.out.format("Prepare  : %4dms\n", (java.lang.System.currentTimeMillis()-profilerLast));
     
    838831            }
    839832
    840             if(profiler) 
     833            if(profiler)
    841834            {
    842835                System.out.format("Relations: %4dms, n=%d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java

    r1235 r1236  
    360360    protected boolean isPolygonVisible(Polygon polygon) {
    361361        Rectangle bounds = polygon.getBounds();
    362                 if (bounds.x > nc.getWidth()) return false;
    363                 else if (bounds.y > nc.getHeight()) return false;
    364                 else if (bounds.x + polygon.getBounds().width < 0) return false;
    365                 else if (bounds.y + polygon.getBounds().height < 0) return false;
    366        
     362        if (bounds.x > nc.getWidth()) return false;
     363        else if (bounds.y > nc.getHeight()) return false;
     364        else if (bounds.x + bounds.width < 0) return false;
     365        else if (bounds.y + bounds.height < 0) return false;
     366
    367367        return true;
    368368    }
    369        
     369
    370370    public void setGraphics(Graphics g) {
    371371        this.g = g;
Note: See TracChangeset for help on using the changeset viewer.