Changeset 2886 in josm


Ignore:
Timestamp:
2010-01-23T21:15:17+01:00 (11 years ago)
Author:
bastiK
Message:

relation dialog:

  • reverse order for selected members only;
  • if just one member is selected, don't sort this list of length 1, but sort all members instead
Location:
trunk/src/org/openstreetmap/josm/gui/dialogs/relation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java

    r2801 r2886  
    546546            }
    547547        }
    548 
     548        setSelectedMembersIdx(selectedIndices);
     549    }
     550
     551    /**
     552     * Selects the members in the collection selectedIndices
     553     *
     554     * @param selectedIndices the collection of selected member indices
     555     */
     556    public void setSelectedMembersIdx(Collection<Integer> selectedIndices) {
     557        if (selectedIndices == null || selectedIndices.isEmpty()) {
     558            getSelectionModel().clearSelection();
     559            return;
     560        }
    549561        // select the members
    550562        //
     
    740752
    741753    /**
    742      * Sort the relation members by the way they are linked.
     754     * Sort the selected relation members by the way they are linked.
    743755     */
    744756    void sort() {
     
    746758        ArrayList<RelationMember> sortedMembers = null;
    747759        ArrayList<RelationMember> newMembers;
    748         if (selectedMembers.isEmpty()) {
     760        if (selectedMembers.size() <= 1) {
    749761            newMembers = sortMembers(members);
     762            sortedMembers = newMembers;
    750763        } else {
    751764            sortedMembers = sortMembers(selectedMembers);
     
    774787
    775788    /**
    776      * Reverse the relation members.
    777      */
    778     void reverse() {
    779         Collections.reverse(members);
    780         fireTableDataChanged();
    781     }
    782 
    783     /**
    784789     * Determines the direction of way k with respect to the way ref_i.
    785790     * The way ref_i is assumed to have the direction ref_direction and
     
    790795     * Else the direction is given as follows:
    791796     * Let the relation be a route of oneway streets, and someone travels them in the given order.
    792      * Direction is FORWARD for if it is legel and BACKWARD if it is illegal to do so for the given way.
     797     * Direction is FORWARD if it is legel and BACKWARD if it is illegal to do so for the given way.
    793798     *
    794799     **/
     
    855860     * determine, if the way i is a roundabout and if yes, what type of roundabout
    856861     */
    857     private Direction roundaboutType(int i) { //FIXME
     862    private Direction roundaboutType(int i) {
    858863        RelationMember m = members.get(i);
    859864        if (m == null || !m.isWay()) return NONE;
     
    894899
    895900    /**
     901     * Reverse the relation members.
     902     */
     903    void reverse() {
     904        List<Integer> selectedIndices = getSelectedIndices();
     905        List<Integer> selectedIndicesReversed = getSelectedIndices();
     906
     907        if (selectedIndices.size() <= 1) {
     908            Collections.reverse(members);
     909            fireTableDataChanged();
     910            setSelectedMembers(members);
     911        } else {
     912            Collections.reverse(selectedIndicesReversed);
     913
     914            ArrayList<RelationMember> newMembers = new ArrayList<RelationMember>(members);
     915
     916            for (int i=0; i < selectedIndices.size(); i++) {
     917                newMembers.set(selectedIndices.get(i), members.get(selectedIndicesReversed.get(i)));
     918            }
     919
     920            if (members.size() != newMembers.size()) throw new AssertionError();
     921            members.clear();
     922            members.addAll(newMembers);
     923            fireTableDataChanged();
     924            setSelectedMembersIdx(selectedIndices);
     925        }
     926    }
     927
     928    /**
    896929     * refresh the cache of member WayConnectionTypes
    897930     */
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationNodeMap.java

    r2578 r2886  
    8888
    8989            if (nodeLinks.getValue().size() < 2) {
    90 //                System.err.println("DELETE: "+nodeLinks.getKey()+" "+nodeLinks.getValue());
    9190                if (nodeLinks.getValue().size() != 1) throw new AssertionError();
    9291
     
    9897                continue;
    9998            }
    100 //            System.err.println(nodeLinks.getKey()+" "+nodeLinks.getValue());
    101 
    10299        }
    103 //        System.err.println("");
    104 //        System.err.println(remaining);
    105 //        System.err.println("");
    106 //        System.err.println(nodesMap);
    107 //        System.err.println("");
    108 //        System.err.println(waysMap);
    109 
    110100    }
    111101
     
    132122     */
    133123    public Integer popAdjacent(Integer i) {
    134 //        System.err.print("Adjacent["+i+"]:");
    135124        TreeSet<Node> nodes = waysMap.get(i);
    136 //        System.err.print(nodes);
    137125        for (Node n : nodes) {
    138 //            System.err.print(" {"+n.getId()+"} ");
    139126            TreeSet<Integer> adj = nodesMap.get(n);
    140127            if (!adj.isEmpty()) {
     
    142129                done(j);
    143130                waysMap.get(j).remove(n);
    144 //                System.err.println(j);
    145131                return j;
    146132            }
Note: See TracChangeset for help on using the changeset viewer.