Changeset 3095 in josm


Ignore:
Timestamp:
08.03.2010 09:24:03 (2 years ago)
Author:
jttt
Message:

Changes in multipolygon handling (see #4661), cosmetics

Location:
trunk
Files:
8 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} 
  • trunk/src/org/openstreetmap/josm/gui/MultiSplitLayout.java

    r3083 r3095  
    4242import java.util.ListIterator; 
    4343import java.util.Map; 
     44 
    4445import javax.swing.UIManager; 
    4546 
     
    141142     */ 
    142143    public void setModel(Node model) { 
    143         if ((model == null) || (model instanceof Divider)) { 
     144        if ((model == null) || (model instanceof Divider)) 
    144145            throw new IllegalArgumentException("invalid model"); 
    145         } 
    146146        Node oldModel = model; 
    147147        this.model = model; 
     
    168168     */ 
    169169    public void setDividerSize(int dividerSize) { 
    170         if (dividerSize < 0) { 
     170        if (dividerSize < 0) 
    171171            throw new IllegalArgumentException("invalid dividerSize"); 
    172         } 
    173172        int oldDividerSize = this.dividerSize; 
    174173        this.dividerSize = dividerSize; 
     
    212211     */ 
    213212    public void addLayoutComponent(String name, Component child) { 
    214         if (name == null) { 
     213        if (name == null) 
    215214            throw new IllegalArgumentException("name not specified"); 
    216         } 
    217215        childMap.put(name, child); 
    218216    } 
     
    253251 
    254252    private Dimension preferredNodeSize(Node root) { 
    255         if (root instanceof Leaf) { 
     253        if (root instanceof Leaf) 
    256254            return preferredComponentSize(root); 
    257         } 
    258255        else if (root instanceof Divider) { 
    259256            int dividerSize = getDividerSize(); 
     
    363360        Rectangle splitBounds = split.getBounds(); 
    364361        ListIterator<Node> splitChildren = split.getChildren().listIterator(); 
    365         Node lastWeightedChild = split.lastWeightedChild(); 
    366362 
    367363        if (split.isRowLayout()) { 
     
    385381                (totalWeightedWidth - minWeightedWidth) > extraWidth; 
    386382 
    387             while(splitChildren.hasNext()) { 
    388                 Node splitChild = splitChildren.next(); 
    389                 Rectangle splitChildBounds = splitChild.getBounds(); 
    390                 double minSplitChildWidth = minimumNodeSize(splitChild).getWidth(); 
    391                 double splitChildWeight = (onlyShrinkWeightedComponents) 
     383                while(splitChildren.hasNext()) { 
     384                    Node splitChild = splitChildren.next(); 
     385                    Rectangle splitChildBounds = splitChild.getBounds(); 
     386                    double minSplitChildWidth = minimumNodeSize(splitChild).getWidth(); 
     387                    double splitChildWeight = (onlyShrinkWeightedComponents) 
    392388                    ? splitChild.getWeight() 
    393                     : (splitChildBounds.getWidth() / (double)totalWidth); 
    394  
    395                 if (!splitChildren.hasNext()) { 
    396                     double newWidth =  Math.max(minSplitChildWidth, bounds.getMaxX() - x); 
    397                     Rectangle newSplitChildBounds = boundsWithXandWidth(bounds, x, newWidth); 
    398                     layout2(splitChild, newSplitChildBounds); 
    399                 } 
    400                 else if ((availableWidth > 0.0) && (splitChildWeight > 0.0)) { 
    401                     double allocatedWidth = Math.rint(splitChildWeight * extraWidth); 
    402                     double oldWidth = splitChildBounds.getWidth(); 
    403                     double newWidth = Math.max(minSplitChildWidth, oldWidth - allocatedWidth); 
    404                     Rectangle newSplitChildBounds = boundsWithXandWidth(bounds, x, newWidth); 
    405                     layout2(splitChild, newSplitChildBounds); 
    406                     availableWidth -= (oldWidth - splitChild.getBounds().getWidth()); 
    407                 } 
    408                 else { 
    409                     double existingWidth = splitChildBounds.getWidth(); 
    410                     Rectangle newSplitChildBounds = boundsWithXandWidth(bounds, x, existingWidth); 
    411                     layout2(splitChild, newSplitChildBounds); 
    412                 } 
    413                 x = splitChild.getBounds().getMaxX(); 
    414             } 
     389                            : (splitChildBounds.getWidth() / totalWidth); 
     390 
     391                    if (!splitChildren.hasNext()) { 
     392                        double newWidth =  Math.max(minSplitChildWidth, bounds.getMaxX() - x); 
     393                        Rectangle newSplitChildBounds = boundsWithXandWidth(bounds, x, newWidth); 
     394                        layout2(splitChild, newSplitChildBounds); 
     395                    } 
     396                    else if ((availableWidth > 0.0) && (splitChildWeight > 0.0)) { 
     397                        double allocatedWidth = Math.rint(splitChildWeight * extraWidth); 
     398                        double oldWidth = splitChildBounds.getWidth(); 
     399                        double newWidth = Math.max(minSplitChildWidth, oldWidth - allocatedWidth); 
     400                        Rectangle newSplitChildBounds = boundsWithXandWidth(bounds, x, newWidth); 
     401                        layout2(splitChild, newSplitChildBounds); 
     402                        availableWidth -= (oldWidth - splitChild.getBounds().getWidth()); 
     403                    } 
     404                    else { 
     405                        double existingWidth = splitChildBounds.getWidth(); 
     406                        Rectangle newSplitChildBounds = boundsWithXandWidth(bounds, x, existingWidth); 
     407                        layout2(splitChild, newSplitChildBounds); 
     408                    } 
     409                    x = splitChild.getBounds().getMaxX(); 
     410                } 
    415411        } 
    416412 
     
    435431                (totalWeightedHeight - minWeightedHeight) > extraHeight; 
    436432 
    437             while(splitChildren.hasNext()) { 
    438                 Node splitChild = splitChildren.next(); 
    439                 Rectangle splitChildBounds = splitChild.getBounds(); 
    440                 double minSplitChildHeight = minimumNodeSize(splitChild).getHeight(); 
    441                 double splitChildWeight = (onlyShrinkWeightedComponents) 
     433                while(splitChildren.hasNext()) { 
     434                    Node splitChild = splitChildren.next(); 
     435                    Rectangle splitChildBounds = splitChild.getBounds(); 
     436                    double minSplitChildHeight = minimumNodeSize(splitChild).getHeight(); 
     437                    double splitChildWeight = (onlyShrinkWeightedComponents) 
    442438                    ? splitChild.getWeight() 
    443                     : (splitChildBounds.getHeight() / (double)totalHeight); 
    444  
    445                 if (!splitChildren.hasNext()) { 
    446                     double oldHeight = splitChildBounds.getHeight(); 
    447                     double newHeight =  Math.max(minSplitChildHeight, bounds.getMaxY() - y); 
    448                     Rectangle newSplitChildBounds = boundsWithYandHeight(bounds, y, newHeight); 
    449                     layout2(splitChild, newSplitChildBounds); 
    450                     availableHeight -= (oldHeight - splitChild.getBounds().getHeight()); 
    451                 } 
    452                 else if ((availableHeight > 0.0) && (splitChildWeight > 0.0)) { 
    453                     double allocatedHeight = Math.rint(splitChildWeight * extraHeight); 
    454                     double oldHeight = splitChildBounds.getHeight(); 
    455                     double newHeight = Math.max(minSplitChildHeight, oldHeight - allocatedHeight); 
    456                     Rectangle newSplitChildBounds = boundsWithYandHeight(bounds, y, newHeight); 
    457                     layout2(splitChild, newSplitChildBounds); 
    458                     availableHeight -= (oldHeight - splitChild.getBounds().getHeight()); 
    459                 } 
    460                 else { 
    461                     double existingHeight = splitChildBounds.getHeight(); 
    462                     Rectangle newSplitChildBounds = boundsWithYandHeight(bounds, y, existingHeight); 
    463                     layout2(splitChild, newSplitChildBounds); 
    464                 } 
    465                 y = splitChild.getBounds().getMaxY(); 
    466             } 
     439                            : (splitChildBounds.getHeight() / totalHeight); 
     440 
     441                    if (!splitChildren.hasNext()) { 
     442                        double oldHeight = splitChildBounds.getHeight(); 
     443                        double newHeight =  Math.max(minSplitChildHeight, bounds.getMaxY() - y); 
     444                        Rectangle newSplitChildBounds = boundsWithYandHeight(bounds, y, newHeight); 
     445                        layout2(splitChild, newSplitChildBounds); 
     446                        availableHeight -= (oldHeight - splitChild.getBounds().getHeight()); 
     447                    } 
     448                    else if ((availableHeight > 0.0) && (splitChildWeight > 0.0)) { 
     449                        double allocatedHeight = Math.rint(splitChildWeight * extraHeight); 
     450                        double oldHeight = splitChildBounds.getHeight(); 
     451                        double newHeight = Math.max(minSplitChildHeight, oldHeight - allocatedHeight); 
     452                        Rectangle newSplitChildBounds = boundsWithYandHeight(bounds, y, newHeight); 
     453                        layout2(splitChild, newSplitChildBounds); 
     454                        availableHeight -= (oldHeight - splitChild.getBounds().getHeight()); 
     455                    } 
     456                    else { 
     457                        double existingHeight = splitChildBounds.getHeight(); 
     458                        Rectangle newSplitChildBounds = boundsWithYandHeight(bounds, y, existingHeight); 
     459                        layout2(splitChild, newSplitChildBounds); 
     460                    } 
     461                    y = splitChild.getBounds().getMaxY(); 
     462                } 
    467463        } 
    468464 
     
    508504                else if ((availableWidth > 0.0) && (splitChildWeight > 0.0)) { 
    509505                    double allocatedWidth = (splitChild.equals(lastWeightedChild)) 
    510                         ? availableWidth 
    511                         : Math.rint(splitChildWeight * extraWidth); 
     506                    ? availableWidth 
     507                            : Math.rint(splitChildWeight * extraWidth); 
    512508                    double newWidth = splitChildBounds.getWidth() + allocatedWidth; 
    513509                    Rectangle newSplitChildBounds = boundsWithXandWidth(bounds, x, newWidth); 
     
    550546                else if ((availableHeight > 0.0) && (splitChildWeight > 0.0)) { 
    551547                    double allocatedHeight = (splitChild.equals(lastWeightedChild)) 
    552                         ? availableHeight 
    553                         : Math.rint(splitChildWeight * extraHeight); 
     548                    ? availableHeight 
     549                            : Math.rint(splitChildWeight * extraHeight); 
    554550                    double newHeight = splitChildBounds.getHeight() + allocatedHeight; 
    555551                    Rectangle newSplitChildBounds = boundsWithYandHeight(bounds, y, newHeight); 
     
    570566     * as needed. 
    571567     */ 
    572    private void layout2(Node root, Rectangle bounds) { 
     568    private void layout2(Node root, Rectangle bounds) { 
    573569        if (root instanceof Leaf) { 
    574570            Component child = childForNode(root); 
     
    584580            Split split = (Split)root; 
    585581            boolean grow = split.isRowLayout() 
    586                 ? (split.getBounds().width <= bounds.width) 
    587                 : (split.getBounds().height <= bounds.height); 
     582            ? (split.getBounds().width <= bounds.width) 
     583                    : (split.getBounds().height <= bounds.height); 
    588584            if (grow) { 
    589585                layoutGrow(split, bounds); 
     
    635631                        (splitChildren.hasNext()) ? (Divider)(splitChildren.next()) : null; 
    636632 
    637                     double childWidth = 0.0; 
    638                     if (getFloatingDividers()) { 
    639                         childWidth = preferredNodeSize(splitChild).getWidth(); 
    640                     } 
    641                     else { 
    642                         if (dividerChild != null) { 
    643                             childWidth = dividerChild.getBounds().getX() - x; 
     633                        double childWidth = 0.0; 
     634                        if (getFloatingDividers()) { 
     635                            childWidth = preferredNodeSize(splitChild).getWidth(); 
    644636                        } 
    645637                        else { 
    646                             childWidth = split.getBounds().getMaxX() - x; 
     638                            if (dividerChild != null) { 
     639                                childWidth = dividerChild.getBounds().getX() - x; 
     640                            } 
     641                            else { 
     642                                childWidth = split.getBounds().getMaxX() - x; 
     643                            } 
    647644                        } 
    648                     } 
    649                     childBounds = boundsWithXandWidth(bounds, x, childWidth); 
    650                     layout1(splitChild, childBounds); 
    651  
    652                     if (getFloatingDividers() && (dividerChild != null)) { 
    653                         double dividerX = childBounds.getMaxX(); 
    654                         Rectangle dividerBounds = boundsWithXandWidth(bounds, dividerX, dividerSize); 
    655                         dividerChild.setBounds(dividerBounds); 
    656                     } 
    657                     if (dividerChild != null) { 
    658                         x = dividerChild.getBounds().getMaxX(); 
    659                     } 
     645                        childBounds = boundsWithXandWidth(bounds, x, childWidth); 
     646                        layout1(splitChild, childBounds); 
     647 
     648                        if (getFloatingDividers() && (dividerChild != null)) { 
     649                            double dividerX = childBounds.getMaxX(); 
     650                            Rectangle dividerBounds = boundsWithXandWidth(bounds, dividerX, dividerSize); 
     651                            dividerChild.setBounds(dividerBounds); 
     652                        } 
     653                        if (dividerChild != null) { 
     654                            x = dividerChild.getBounds().getMaxX(); 
     655                        } 
    660656                } 
    661657            } 
     
    673669                        (splitChildren.hasNext()) ? (Divider)(splitChildren.next()) : null; 
    674670 
    675                     double childHeight = 0.0; 
    676                     if (getFloatingDividers()) { 
    677                         childHeight = preferredNodeSize(splitChild).getHeight(); 
    678                     } 
    679                     else { 
    680                         if (dividerChild != null) { 
    681                             childHeight = dividerChild.getBounds().getY() - y; 
     671                        double childHeight = 0.0; 
     672                        if (getFloatingDividers()) { 
     673                            childHeight = preferredNodeSize(splitChild).getHeight(); 
    682674                        } 
    683675                        else { 
    684                             childHeight = split.getBounds().getMaxY() - y; 
     676                            if (dividerChild != null) { 
     677                                childHeight = dividerChild.getBounds().getY() - y; 
     678                            } 
     679                            else { 
     680                                childHeight = split.getBounds().getMaxY() - y; 
     681                            } 
    685682                        } 
    686                     } 
    687                     childBounds = boundsWithYandHeight(bounds, y, childHeight); 
    688                     layout1(splitChild, childBounds); 
    689  
    690                     if (getFloatingDividers() && (dividerChild != null)) { 
    691                         double dividerY = childBounds.getMaxY(); 
    692                         Rectangle dividerBounds = boundsWithYandHeight(bounds, dividerY, dividerSize); 
    693                         dividerChild.setBounds(dividerBounds); 
    694                     } 
    695                     if (dividerChild != null) { 
    696                         y = dividerChild.getBounds().getMaxY(); 
    697                     } 
     683                        childBounds = boundsWithYandHeight(bounds, y, childHeight); 
     684                        layout1(splitChild, childBounds); 
     685 
     686                        if (getFloatingDividers() && (dividerChild != null)) { 
     687                            double dividerY = childBounds.getMaxY(); 
     688                            Rectangle dividerBounds = boundsWithYandHeight(bounds, dividerY, dividerSize); 
     689                            dividerChild.setBounds(dividerBounds); 
     690                        } 
     691                        if (dividerChild != null) { 
     692                            y = dividerChild.getBounds().getMaxY(); 
     693                        } 
    698694                } 
    699695            } 
     
    781777            Split split = (Split)root; 
    782778            for(Node child : split.getChildren()) { 
    783                 if (child.getBounds().contains(x, y)) { 
     779                if (child.getBounds().contains(x, y)) 
    784780                    return dividerAt(child, x, y); 
    785                 } 
    786781            } 
    787782        } 
     
    804799        Rectangle r1 = node.getBounds(); 
    805800        return 
    806             (r1.x <= (r2.x + r2.width)) && ((r1.x + r1.width) >= r2.x) && 
    807             (r1.y <= (r2.y + r2.height)) && ((r1.y + r1.height) >= r2.y); 
     801        (r1.x <= (r2.x + r2.width)) && ((r1.x + r1.width) >= r2.x) && 
     802        (r1.y <= (r2.y + r2.height)) && ((r1.y + r1.height) >= r2.y); 
    808803    } 
    809804 
     
    822817            } 
    823818            return dividers; 
    824         } 
    825         else { 
     819        } else 
    826820            return Collections.emptyList(); 
    827         } 
    828821    } 
    829822 
     
    837830     */ 
    838831    public List<Divider> dividersThatOverlap(Rectangle r) { 
    839         if (r == null) { 
     832        if (r == null) 
    840833            throw new IllegalArgumentException("null Rectangle"); 
    841         } 
    842834        return dividersThatOverlap(getModel(), r); 
    843835    } 
     
    890882         */ 
    891883        public void setBounds(Rectangle bounds) { 
    892             if (bounds == null) { 
     884            if (bounds == null) 
    893885                throw new IllegalArgumentException("null bounds"); 
    894             } 
    895886            this.bounds = new Rectangle(bounds); 
    896887        } 
     
    921912         */ 
    922913        public void setWeight(double weight) { 
    923             if ((weight < 0.0)|| (weight > 1.0)) { 
     914            if ((weight < 0.0)|| (weight > 1.0)) 
    924915                throw new IllegalArgumentException("invalid weight"); 
    925             } 
    926916            this.weight = weight; 
    927917        } 
     
    929919        private Node siblingAtOffset(int offset) { 
    930920            Split parent = getParent(); 
    931             if (parent == null) { return null; } 
     921            if (parent == null) 
     922                return null; 
    932923            List<Node> siblings = parent.getChildren(); 
    933924            int index = siblings.indexOf(this); 
    934             if (index == -1) { return null; } 
     925            if (index == -1) 
     926                return null; 
    935927            index += offset; 
    936928            return ((index > -1) && (index < siblings.size())) ? siblings.get(index) : null; 
     
    10201012         */ 
    10211013        public void setChildren(List<Node> children) { 
    1022             if (children == null) { 
     1014            if (children == null) 
    10231015                throw new IllegalArgumentException("children must be a non-null List"); 
    1024             } 
    10251016            for(Node child : this.children) { 
    10261017                child.setParent(null); 
     
    10511042        } 
    10521043 
     1044        @Override 
    10531045        public String toString() { 
    10541046            int nChildren = getChildren().size(); 
     
    10811073         */ 
    10821074        public Leaf(String name) { 
    1083             if (name == null) { 
     1075            if (name == null) 
    10841076                throw new IllegalArgumentException("name is null"); 
    1085             } 
    10861077            this.name = name; 
    10871078        } 
     
    11021093         */ 
    11031094        public void setName(String name) { 
    1104             if (name == null) { 
     1095            if (name == null) 
    11051096                throw new IllegalArgumentException("name is null"); 
    1106             } 
    11071097            this.name = name; 
    11081098        } 
    11091099 
     1100        @Override 
    11101101        public String toString() { 
    11111102            StringBuffer sb = new StringBuffer("MultiSplitLayout.Leaf"); 
     
    11421133         * @throws UnsupportedOperationException 
    11431134         */ 
     1135        @Override 
    11441136        public void setWeight(double weight) { 
    11451137            throw new UnsupportedOperationException(); 
    11461138        } 
    11471139 
     1140        @Override 
    11481141        public String toString() { 
    11491142            return "MultiSplitLayout.Divider " + getBounds().toString(); 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java

    r3072 r3095  
    118118        // 
    119119        memberTableModel = new MemberTableModel(getLayer()); 
    120         DataSet.selListeners.add(memberTableModel); 
    121         getLayer().data.addDataSetListener(memberTableModel); 
     120        memberTableModel.register(); 
    122121        selectionTableModel = new SelectionTableModel(getLayer()); 
    123         DataSet.selListeners.add(selectionTableModel); 
     122        selectionTableModel.register(); 
    124123        referrerModel = new ReferringRelationsBrowserModel(relation); 
    125124 
     
    553552            // 
    554553            selectionTableModel.unregister(); 
    555             DataSet.selListeners.remove(memberTableModel); 
    556             DataSet.selListeners.remove(selectionTableModel); 
    557             getLayer().data.removeDataSetListener(memberTableModel); 
     554            memberTableModel.unregister(); 
    558555            memberTable.unlinkAsListener(); 
    559556            dispose(); 
     
    10541051 
    10551052        /** 
    1056          * Apply the updates for an existing relation which has not been changed 
     1053         * Apply the updates for an existing relation which has been changed 
    10571054         * outside of the relation editor. 
    10581055         * 
     
    10671064 
    10681065        /** 
    1069          * Apply the updates for an existing relation which has been changed 
     1066         * Apply the updates for an existing relation which has not been changed 
    10701067         * outside of the relation editor. 
    10711068         * 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java

    r2985 r3095  
    2828import org.openstreetmap.josm.data.SelectionChangedListener; 
    2929import org.openstreetmap.josm.data.coor.EastNorth; 
     30import org.openstreetmap.josm.data.osm.DataSet; 
    3031import org.openstreetmap.josm.data.osm.Node; 
    3132import org.openstreetmap.josm.data.osm.OsmPrimitive; 
     
    5051     * data of the table model: The list of members and the cached WayConnectionType of each member. 
    5152     **/ 
    52     private ArrayList<RelationMember> members; 
    53     private ArrayList<WayConnectionType> connectionType = null; 
     53    private List<RelationMember> members; 
     54    private List<WayConnectionType> connectionType = null; 
    5455 
    5556    private DefaultListSelectionModel listSelectionModel; 
     
    6970    public OsmDataLayer getLayer() { 
    7071        return layer; 
     72    } 
     73 
     74    public void register() { 
     75        DataSet.selListeners.add(this); 
     76        getLayer().data.addDataSetListener(this); 
     77    } 
     78 
     79    public void unregister() { 
     80        DataSet.selListeners.remove(this); 
     81        getLayer().data.removeDataSetListener(this); 
    7182    } 
    7283 
     
    695706     * @return sorted collection of relation members 
    696707     */ 
    697     private ArrayList<RelationMember> sortMembers(ArrayList<RelationMember> relationMembers) { 
     708    private List<RelationMember> sortMembers(List<RelationMember> relationMembers) { 
    698709        RelationNodeMap map = new RelationNodeMap(relationMembers); 
    699710        // List of groups of linked members 
     
    744755     */ 
    745756    void sort() { 
    746         ArrayList<RelationMember> selectedMembers = new ArrayList<RelationMember>(getSelectedMembers()); 
    747         ArrayList<RelationMember> sortedMembers = null; 
    748         ArrayList<RelationMember> newMembers; 
     757        List<RelationMember> selectedMembers = new ArrayList<RelationMember>(getSelectedMembers()); 
     758        List<RelationMember> sortedMembers = null; 
     759        List<RelationMember> newMembers; 
    749760        if (selectedMembers.size() <= 1) { 
    750761            newMembers = sortMembers(members); 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationNodeMap.java

    r2886 r3095  
    11// License: GPL. For details, see LICENSE file. 
    22package org.openstreetmap.josm.gui.dialogs.relation; 
     3 
     4import static org.openstreetmap.josm.gui.dialogs.relation.WayConnectionType.Direction.NONE; 
    35 
    46import java.util.ArrayList; 
     
    1214import org.openstreetmap.josm.data.osm.RelationMember; 
    1315import org.openstreetmap.josm.data.osm.Way; 
    14  
    15 import static org.openstreetmap.josm.gui.dialogs.relation.WayConnectionType.Direction.*; 
    1616 
    1717/** 
     
    3131public class RelationNodeMap { 
    3232    /* 
    33      * read only list of all relation members 
    34      */ 
    35     private final List<RelationMember> members; 
    36     /* 
    3733     * the maps. (Need TreeMap for efficiency.) 
    3834     */ 
     
    4945    private List<Integer> notSortable = new ArrayList<Integer>(); 
    5046 
    51     RelationNodeMap(ArrayList<RelationMember> members) { 
    52         this.members = members; 
    53  
     47    RelationNodeMap(List<RelationMember> members) { 
    5448        nodesMap = new TreeMap<Node, TreeSet<Integer>>(); 
    5549        waysMap = new TreeMap<Integer, TreeSet<Node>>(); 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/SelectionTableModel.java

    r3083 r3095  
    3232        this.layer = layer; 
    3333        cache = new ArrayList<OsmPrimitive>(); 
     34        populateSelectedPrimitives(layer); 
     35    } 
     36 
     37    public void register() { 
     38        DataSet.selListeners.add(this); 
    3439        MapView.addLayerChangeListener(this); 
    35         populateSelectedPrimitives(layer); 
    3640    } 
    3741 
  • trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java

    r3083 r3095  
    4747    /** 
    4848     * Creates a new authorisation client with default OAuth parameters 
    49      *  
     49     * 
    5050     */ 
    5151    public OsmOAuthAuthorizationClient() { 
     
    5757    /** 
    5858     * Creates a new authorisation client with the parameters <code>parameters</code>. 
    59      *  
     59     * 
    6060     * @param parameters the OAuth parameters. Must not be null. 
    6161     * @throws IllegalArgumentException thrown if parameters is null 
     
    7171     * Creates a new authorisation client with the parameters <code>parameters</code> 
    7272     * and an already known Request Token. 
    73      *  
     73     * 
    7474     * @param parameters the OAuth parameters. Must not be null. 
    7575     * @param requestToken the request token. Must not be null. 
     
    117117     * Submits a request for a Request Token to the Request Token Endpoint Url of the OAuth Service 
    118118     * Provider and replies the request token. 
    119      *  
     119     * 
    120120     * @param monitor a progress monitor. Defaults to {@see NullProgressMonitor#INSTANCE} if null 
    121121     * @return the OAuth Request Token 
     
    147147     * Submits a request for an Access Token to the Access Token Endpoint Url of the OAuth Service 
    148148     * Provider and replies the request token. 
    149      *  
     149     * 
    150150     * You must have requested a Request Token using {@see #getRequestToken(ProgressMonitor)} first. 
    151      *  
     151     * 
    152152     * @param monitor a progress monitor. Defaults to {@see NullProgressMonitor#INSTANCE} if null 
    153153     * @return the OAuth Access Token 
     
    180180     * Builds the authorise URL for a given Request Token. Users can be redirected to this URL. 
    181181     * There they can login to OSM and authorise the request. 
    182      *  
     182     * 
    183183     * @param requestToken  the request token 
    184184     * @return  the authorise URL for this request 
     
    241241    /** 
    242242     * Derives the OSM login URL from the OAuth Authorization Website URL 
    243      *  
     243     * 
    244244     * @return the OSM login URL 
    245245     * @throws OsmOAuthAuthorizationException thrown if something went wrong, in particular if the 
     
    261261    /** 
    262262     * Derives the OSM logout URL from the OAuth Authorization Website URL 
    263      *  
     263     * 
    264264     * @return the OSM logout URL 
    265265     * @throws OsmOAuthAuthorizationException thrown if something went wrong, in particular if the 
     
    279279     * Submits a request to the OSM website for a login form. The OSM website replies a session ID in 
    280280     * a cookie. 
    281      *  
     281     * 
    282282     * @return the session ID 
    283283     * @throws OsmOAuthAuthorizationException thrown if something went wrong 
     
    460460    /** 
    461461     * Automatically authorises a request token for a set of privileges. 
    462      *  
     462     * 
    463463     * @param requestToken the request token. Must not be null. 
    464464     * @param osmUserName the OSM user name. Must not be null. 
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/tags/TagMergeModelTest.java

    r3025 r3095  
    201201    public void decideMultiple() { 
    202202 
    203         TagMergeItem item = new TagMergeItem("key", "myvalue", "theirvalue"); 
    204203        TagMergeModel model = new TagMergeModel(); 
    205204        for (int i=0; i < 10; i++) { 
     
    216215        model.decide(new int[] {0, 3, 5}, MergeDecisionType.KEEP_MINE); 
    217216        for (int i = 0; i< 10; i++) { 
    218             item = list.get(i); 
     217            TagMergeItem item = list.get(i); 
    219218            if (i == 0 || i == 3 || i == 5) { 
    220219                assertEquals(MergeDecisionType.KEEP_MINE, item.getMergeDecision()); 
Note: See TracChangeset for help on using the changeset viewer.