Ignore:
Timestamp:
2010-03-08T09:24:03+01:00 (15 years ago)
Author:
jttt
Message:

Changes in multipolygon handling (see #4661), cosmetics

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java

    r3083 r3095  
    77import java.util.ArrayList;
    88import java.util.Collection;
    9 import java.util.LinkedList;
    109import java.util.List;
    1110
     
    1918public class Multipolygon {
    2019
     20    public static class JoinedWay {
     21        private final List<Node> nodes;
     22        private final boolean selected;
     23
     24        public JoinedWay(List<Node> nodes, boolean selected) {
     25            this.nodes = nodes;
     26            this.selected = selected;
     27        }
     28
     29        public List<Node> getNodes() {
     30            return nodes;
     31        }
     32
     33        public boolean isSelected() {
     34            return selected;
     35        }
     36
     37        public boolean isClosed() {
     38            return nodes.isEmpty() || nodes.get(nodes.size() - 1).equals(nodes.get(0));
     39        }
     40    }
     41
    2142    public static class PolyData {
    2243        public enum Intersection {INSIDE, OUTSIDE, CROSSING}
     
    2647        private Point lastP;
    2748        private Rectangle bounds;
     49
     50        public PolyData(NavigatableComponent nc, JoinedWay joinedWay) {
     51            this(nc, joinedWay.getNodes(), joinedWay.isSelected());
     52        }
    2853
    2954        public PolyData(NavigatableComponent nc, List<Node> nodes, boolean selected) {
     
    92117    private final List<PolyData> outerPolygons = new ArrayList<PolyData>();
    93118    private final List<PolyData> combinedPolygons = new ArrayList<PolyData>();
    94     private boolean hasNonClosedWays;
    95119
    96120    public Multipolygon(NavigatableComponent nc) {
     
    137161        }
    138162
    139         result.addAll(joinWays(waysToJoin));
    140     }
    141 
    142     public Collection<PolyData> joinWays(Collection<Way> join)
     163        for (JoinedWay jw: joinWays(waysToJoin)) {
     164            result.add(new PolyData(nc, jw));
     165        }
     166    }
     167
     168    public static Collection<JoinedWay> joinWays(Collection<Way> join)
    143169    {
    144         Collection<PolyData> res = new LinkedList<PolyData>();
     170        Collection<JoinedWay> res = new ArrayList<JoinedWay>();
    145171        Way[] joinArray = join.toArray(new Way[join.size()]);
    146172        int left = join.size();
     
    230256            }
    231257
    232             if(!n.isEmpty() && !n.get(n.size() - 1).equals(n.get(0))) {
    233                 hasNonClosedWays = true;
    234             }
    235             PolyData pd = new PolyData(nc, n, selected);
    236             res.add(pd);
     258            res.add(new JoinedWay(n, selected));
    237259        } /* while(left != 0) */
    238260
     
    323345    }
    324346
    325     public boolean hasNonClosedWays() {
    326         return hasNonClosedWays;
    327     }
    328 
    329347}
Note: See TracChangeset for help on using the changeset viewer.