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


Ignore:
Timestamp:
2009-05-30T17:24:29+02:00 (15 years ago)
Author:
stoecker
Message:

close #2426 - now mappaint handles area types which require closed ways (e.g. cliff) correctly

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

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

    r1553 r1629  
    223223        else if (wayStyle instanceof AreaElemStyle)
    224224        {
     225            AreaElemStyle areaStyle = (AreaElemStyle) wayStyle;
    225226            /* way with area style */
    226227            //if(!profilerOmitDraw)
    227228            //{
    228             if (fillAreas > dist)
     229            if (fillAreas > dist && (!areaStyle.closed || w.isClosed()))
    229230            {
    230231            //    profilerVisibleAreas++;
    231                 drawArea(w, w.selected ? selectedColor : ((AreaElemStyle)wayStyle).color);
     232                drawArea(w, w.selected ? selectedColor : areaStyle.color);
    232233                if(!w.isClosed())
    233234                    w.putError(tr("Area style way is not closed."), true);
    234235            }
    235             drawWay(w, ((AreaElemStyle)wayStyle).line, ((AreaElemStyle)wayStyle).color, w.selected);
     236            drawWay(w, areaStyle.line, areaStyle.color, w.selected);
    236237            //}
    237238        }
     
    456457            if(style instanceof AreaElemStyle)
    457458            {
    458                 drawWay((Way)osm, ((AreaElemStyle)style).line, selectedColor, true);
    459                 if(area)
    460                     drawArea((Way)osm, areaselected ? selectedColor
    461                     : ((AreaElemStyle)style).color);
     459                Way way = (Way)osm;
     460                AreaElemStyle areaStyle = (AreaElemStyle)style;
     461                drawWay(way, areaStyle.line, selectedColor, true);
     462                if(area && (!areaStyle.closed || way.isClosed()))
     463                    drawArea(way, areaselected ? selectedColor : areaStyle.color);
    462464            }
    463465            else
     
    907909                        inner.add(p);
    908910                    }
     911                    public boolean isClosed()
     912                    {
     913                        return (poly.npoints >= 3
     914                        && poly.xpoints[0] == poly.xpoints[poly.npoints-1]
     915                        && poly.ypoints[0] == poly.ypoints[poly.npoints-1]);
     916                    }
    909917                    public Polygon get()
    910918                    {
     
    967975                    o.addInner(polygon);
    968976                }
     977                AreaElemStyle areaStyle = (AreaElemStyle)wayStyle;
    969978                for (PolyData pd : poly)
    970979                {
    971                     if(isPolygonVisible(pd.get()))
    972                     {
    973                         drawAreaPolygon(pd.get(), (pd.way.selected || r.selected) ? selectedColor
    974                         : ((AreaElemStyle)wayStyle).color);
     980                    Polygon p = pd.get();
     981                    if(isPolygonVisible(p) && (!areaStyle.closed || pd.isClosed()))
     982                    {
     983                        drawAreaPolygon(p, (pd.way.selected || r.selected) ? selectedColor
     984                        : areaStyle.color);
    975985                        visible = true;
    976986                    }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/AreaElemStyle.java

    r1204 r1629  
    55{
    66    public Color color;
     7    public boolean closed;
    78    public LineElemStyle line = null;
    89
    910    public AreaElemStyle (AreaElemStyle a, long maxScale, long minScale) {
    1011        this.color = a.color;
     12        this.closed = a.closed;
    1113        this.priority = a.priority;
    1214        this.maxScale = maxScale;
     
    1719    {
    1820        this.color = a.color;
     21        this.closed = a.closed;
    1922        this.priority = a.priority;
    2023        this.maxScale = a.maxScale;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyleHandler.java

    r1583 r1629  
    7373        System.out.println(styleName + " (" + rule.key + "=" + rule.value + "): " + message);
    7474    }
    75    
     75
    7676    private void startElementLine(String qName, Attributes atts, LineElemStyle line) {
    7777        for (int count=0; count<atts.getLength(); count++)
     
    110110                    if(dashed) {
    111111                        line.dashed = 9;
    112                     }               
     112                    }
    113113                }
    114114            } else if (atts.getQName(count).equals("dashedcolour"))
     
    194194                    if (atts.getQName(count).equals("colour"))
    195195                        rule.area.color=convertColor(atts.getValue(count));
     196                    else if (atts.getQName(count).equals("closed"))
     197                        rule.area.closed=Boolean.parseBoolean(atts.getValue(count));
    196198                    else if(atts.getQName(count).equals("priority"))
    197199                        rule.area.priority = Integer.parseInt(atts.getValue(count));
Note: See TracChangeset for help on using the changeset viewer.