Changeset 3486 in josm for trunk


Ignore:
Timestamp:
2010-08-29T16:20:19+02:00 (14 years ago)
Author:
bastiK
Message:

minor fixes

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/PurgeCommand.java

    r3479 r3486  
    191191            }
    192192
    193             /**
    194              * Rest are relations. Do topological sorting on a DAG where each
    195              * arrow points from child to parent. (Because it is faster to
    196              * loop over getReferrers() than getMembers().)
    197              */
    198             Set<Relation> inR = (Set) in;
    199             Set<Relation> childlessR = new HashSet<Relation>();
    200             List<Relation> outR = new ArrayList<Relation>(inR.size());
    201 
    202             HashMap<Relation, Integer> numChilds = new HashMap<Relation, Integer>();
    203 
    204             // calculate initial number of childs
    205             for (Relation r : inR) {
    206                 numChilds.put(r, 0);
    207             }
    208             for (Relation r : inR) {
    209                 for (OsmPrimitive parent : r.getReferrers()) {
    210                     if (!(parent instanceof Relation))
    211                         throw new AssertionError();
    212                     Integer i = numChilds.get(parent);
    213                     if (i != null) {
    214                         numChilds.put((Relation)parent, i+1);
    215                     }
    216                 }
    217             }
    218             for (Relation r : inR) {
    219                 if (numChilds.get(r).equals(0)) {
    220                     childlessR.add(r);
    221                 }
    222             }
    223 
    224             while (!childlessR.isEmpty()) {
    225                 // Identify one childless Relation and
    226                 // let it virtually die. This makes other
    227                 // relations childless.
    228                 Iterator<Relation> it  = childlessR.iterator();
    229                 Relation next = it.next();
    230                 it.remove();
    231                 outR.add(next);
    232 
    233                 for (OsmPrimitive parentPrim : next.getReferrers()) {
    234                     Relation parent = (Relation) parentPrim;
    235                     Integer i = numChilds.get(parent);
    236                     if (i != null) {
    237                         numChilds.put(parent, i-1);
    238                         if (i-1 == 0) {
    239                             childlessR.add(parent);
    240                         }
    241                     }
    242                 }
    243             }
    244 
    245             if (outR.size() != inR.size())
    246                 throw new AssertionError("topo sort algorithm failed");
    247 
    248             out.addAll(outR);
    249 
    250             return out;
     193        /**
     194         * Rest are relations. Do topological sorting on a DAG where each
     195         * arrow points from child to parent. (Because it is faster to
     196         * loop over getReferrers() than getMembers().)
     197         */
     198        Set<Relation> inR = (Set) in;
     199        Set<Relation> childlessR = new HashSet<Relation>();
     200        List<Relation> outR = new ArrayList<Relation>(inR.size());
     201
     202        HashMap<Relation, Integer> numChilds = new HashMap<Relation, Integer>();
     203
     204        // calculate initial number of childs
     205        for (Relation r : inR) {
     206            numChilds.put(r, 0);
     207        }
     208        for (Relation r : inR) {
     209            for (OsmPrimitive parent : r.getReferrers()) {
     210                if (!(parent instanceof Relation))
     211                    throw new AssertionError();
     212                Integer i = numChilds.get(parent);
     213                if (i != null) {
     214                    numChilds.put((Relation)parent, i+1);
     215                }
     216            }
     217        }
     218        for (Relation r : inR) {
     219            if (numChilds.get(r).equals(0)) {
     220                childlessR.add(r);
     221            }
     222        }
     223
     224        while (!childlessR.isEmpty()) {
     225            // Identify one childless Relation and
     226            // let it virtually die. This makes other
     227            // relations childless.
     228            Iterator<Relation> it  = childlessR.iterator();
     229            Relation next = it.next();
     230            it.remove();
     231            outR.add(next);
     232
     233            for (OsmPrimitive parentPrim : next.getReferrers()) {
     234                Relation parent = (Relation) parentPrim;
     235                Integer i = numChilds.get(parent);
     236                if (i != null) {
     237                    numChilds.put(parent, i-1);
     238                    if (i-1 == 0) {
     239                        childlessR.add(parent);
     240                    }
     241                }
     242            }
     243        }
     244
     245        if (outR.size() != inR.size())
     246            throw new AssertionError("topo sort algorithm failed");
     247
     248        out.addAll(outR);
     249
     250        return out;
    251251    }
    252252
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java

    r3481 r3486  
    949949                    setButtonIcons(new String[] {"ok.png", "cancel.png" });
    950950                    setContent(content);
     951                    setDefaultButton(1);
    951952                    setupDialog();
    952953                    buttons.get(0).setEnabled(!disableApply);
    953954                    buttons.get(0).setToolTipText(title);
    954                     getRootPane().setDefaultButton(buttons.get(0));
    955                     setVisible(true);
     955                    showDialog();
    956956                }
    957957            }
Note: See TracChangeset for help on using the changeset viewer.