Changeset 5818 in josm


Ignore:
Timestamp:
2013-03-31T21:38:01+02:00 (11 years ago)
Author:
stoecker
Message:

javadoc fixes

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/CloseChangesetAction.java

    r4982 r5818  
    7878        private UserInfo userInfo;
    7979
    80         /**
    81          *
    82          * @param model provides the user id of the current user and accepts the changesets
    83          * after download
    84          */
    8580        public DownloadOpenChangesetsTask() {
    8681            super(tr("Downloading open changesets ...", false /* don't ignore exceptions */));
  • trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java

    r5225 r5818  
    130130    }
    131131
    132     /** Enable this action only if something is selected */
     132    /**
     133      * Enable this action only if something is selected
     134      *
     135      * @param selection the current selection, gets tested for emptyness
     136      */
    133137    @Override protected void updateEnabledState(Collection < ? extends OsmPrimitive > selection) {
    134138        setEnabled(selection != null && !selection.isEmpty());
     
    137141    /**
    138142     * This method analyzes ways and creates multipolygon.
    139      * @param selectedWays
    140      * @return null, if there was a problem with the ways.
     143     * @param selectedWays list of selected ways
     144     * @return <code>null</code>, if there was a problem with the ways.
    141145     */
    142146    private MultipolygonCreate analyzeWays(Collection < Way > selectedWays) {
     
    155159    /**
    156160     * Builds a relation from polygon ways.
    157      * @param pol
    158      * @return
     161     * @param pol data storage class containing polygon information
     162     * @return multipolygon relation
    159163     */
    160164    private Relation createRelation(MultipolygonCreate pol) {
     
    182186     * This method removes tags/value pairs from inner and outer ways and put them on relation if necessary
    183187     * Function was extended in reltoolbox plugin by Zverikk and copied back to the core
    184      * @param relation
     188     * @param relation the multipolygon style relation to process
     189     * @return a list of commands to execute
    185190     */
    186191    private List<Command> removeTagsFromWaysIfNeeded( Relation relation ) {
    187         Map<String, String> values = new HashMap<String, String>();
    188 
    189         if( relation.hasKeys() ) {
    190             for( String key : relation.keySet() ) {
    191                 values.put(key, relation.get(key));
    192             }
    193         }
    194 
    195         List<Way> innerWays = new ArrayList<Way>();
    196         List<Way> outerWays = new ArrayList<Way>();
    197 
    198         Set<String> conflictingKeys = new TreeSet<String>();
    199 
    200         for( RelationMember m : relation.getMembers() ) {
    201 
    202             if( m.hasRole() && "inner".equals(m.getRole()) && m.isWay() && m.getWay().hasKeys() ) {
    203                 innerWays.add(m.getWay());
    204             }
    205 
    206             if( m.hasRole() && "outer".equals(m.getRole()) && m.isWay() && m.getWay().hasKeys() ) {
    207                 Way way = m.getWay();
    208                 outerWays.add(way);
     192        Map<String, String> values = new HashMap<String, String>();
     193
     194        if( relation.hasKeys() ) {
     195            for( String key : relation.keySet() ) {
     196                values.put(key, relation.get(key));
     197            }
     198        }
     199
     200        List<Way> innerWays = new ArrayList<Way>();
     201        List<Way> outerWays = new ArrayList<Way>();
     202
     203        Set<String> conflictingKeys = new TreeSet<String>();
     204
     205        for( RelationMember m : relation.getMembers() ) {
     206
     207            if( m.hasRole() && "inner".equals(m.getRole()) && m.isWay() && m.getWay().hasKeys() ) {
     208                innerWays.add(m.getWay());
     209            }
     210
     211            if( m.hasRole() && "outer".equals(m.getRole()) && m.isWay() && m.getWay().hasKeys() ) {
     212                Way way = m.getWay();
     213                outerWays.add(way);
    209214               
    210                 for( String key : way.keySet() ) {
    211                     if( !values.containsKey(key) ) { //relation values take precedence
    212                         values.put(key, way.get(key));
    213                     } else if( !relation.hasKey(key) && !values.get(key).equals(way.get(key)) ) {
    214                         conflictingKeys.add(key);
    215                     }
    216                 }
    217             }
    218         }
    219 
    220         // filter out empty key conflicts - we need second iteration
    221         if( !Main.pref.getBoolean("multipoly.alltags", false) )
    222             for( RelationMember m : relation.getMembers() )
    223                 if( m.hasRole() && m.getRole().equals("outer") && m.isWay() )
    224                     for( String key : values.keySet() )
    225                         if( !m.getWay().hasKey(key) && !relation.hasKey(key) )
    226                             conflictingKeys.add(key);
    227 
    228         for( String key : conflictingKeys )
    229             values.remove(key);
    230 
    231         for( String linearTag : Main.pref.getCollection("multipoly.lineartagstokeep", DEFAULT_LINEAR_TAGS) )
    232             values.remove(linearTag);
    233 
    234         if( values.containsKey("natural") && values.get("natural").equals("coastline") )
    235             values.remove("natural");
    236 
    237         values.put("area", "yes");
    238 
    239         List<Command> commands = new ArrayList<Command>();
    240         boolean moveTags = Main.pref.getBoolean("multipoly.movetags", true);
    241 
    242         for( String key : values.keySet() ) {
    243             List<OsmPrimitive> affectedWays = new ArrayList<OsmPrimitive>();
    244             String value = values.get(key);
    245 
    246             for( Way way : innerWays ) {
    247                 if( way.hasKey(key) && (value.equals(way.get(key))) ) {
    248                     affectedWays.add(way);
    249                 }
    250             }
    251 
    252             if( moveTags ) {
    253                 // remove duplicated tags from outer ways
    254                 for( Way way : outerWays ) {
    255                     if( way.hasKey(key) ) {
    256                         affectedWays.add(way);
    257                     }
    258                 }
    259             }
    260 
    261             if( affectedWays.size() > 0 ) {
     215                for( String key : way.keySet() ) {
     216                    if( !values.containsKey(key) ) { //relation values take precedence
     217                        values.put(key, way.get(key));
     218                    } else if( !relation.hasKey(key) && !values.get(key).equals(way.get(key)) ) {
     219                        conflictingKeys.add(key);
     220                    }
     221                }
     222            }
     223        }
     224
     225        // filter out empty key conflicts - we need second iteration
     226        if( !Main.pref.getBoolean("multipoly.alltags", false) )
     227            for( RelationMember m : relation.getMembers() )
     228                if( m.hasRole() && m.getRole().equals("outer") && m.isWay() )
     229                    for( String key : values.keySet() )
     230                        if( !m.getWay().hasKey(key) && !relation.hasKey(key) )
     231                            conflictingKeys.add(key);
     232
     233        for( String key : conflictingKeys )
     234            values.remove(key);
     235
     236        for( String linearTag : Main.pref.getCollection("multipoly.lineartagstokeep", DEFAULT_LINEAR_TAGS) )
     237            values.remove(linearTag);
     238
     239        if( values.containsKey("natural") && values.get("natural").equals("coastline") )
     240            values.remove("natural");
     241
     242        values.put("area", "yes");
     243
     244        List<Command> commands = new ArrayList<Command>();
     245        boolean moveTags = Main.pref.getBoolean("multipoly.movetags", true);
     246
     247        for( String key : values.keySet() ) {
     248            List<OsmPrimitive> affectedWays = new ArrayList<OsmPrimitive>();
     249            String value = values.get(key);
     250
     251            for( Way way : innerWays ) {
     252                if( way.hasKey(key) && (value.equals(way.get(key))) ) {
     253                    affectedWays.add(way);
     254                }
     255            }
     256
     257            if( moveTags ) {
     258                // remove duplicated tags from outer ways
     259                for( Way way : outerWays ) {
     260                    if( way.hasKey(key) ) {
     261                        affectedWays.add(way);
     262                    }
     263                }
     264            }
     265
     266            if( affectedWays.size() > 0 ) {
    262267                // reset key tag on affected ways
    263                 commands.add(new ChangePropertyCommand(affectedWays, key, null));
    264             }
    265         }
    266 
    267         if( moveTags ) {
    268             // add those tag values to the relation
    269 
    270             boolean fixed = false;
    271             Relation r2 = new Relation(relation);
    272             for( String key : values.keySet() ) {
    273                 if( !r2.hasKey(key) && !key.equals("area") ) {
    274                     if( relation.isNew() )
    275                         relation.put(key, values.get(key));
    276                     else
    277                         r2.put(key, values.get(key));
    278                     fixed = true;
    279                 }
    280             }
    281             if( fixed && !relation.isNew() )
    282                 commands.add(new ChangeCommand(relation, r2));
    283         }
    284 
    285         return commands;
     268                commands.add(new ChangePropertyCommand(affectedWays, key, null));
     269            }
     270        }
     271
     272        if( moveTags ) {
     273            // add those tag values to the relation
     274
     275            boolean fixed = false;
     276            Relation r2 = new Relation(relation);
     277            for( String key : values.keySet() ) {
     278                if( !r2.hasKey(key) && !key.equals("area") ) {
     279                    if( relation.isNew() )
     280                        relation.put(key, values.get(key));
     281                    else
     282                        r2.put(key, values.get(key));
     283                    fixed = true;
     284                }
     285            }
     286            if( fixed && !relation.isNew() )
     287                commands.add(new ChangeCommand(relation, r2));
     288        }
     289
     290        return commands;
    286291    }
    287292}
  • trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java

    r5360 r5818  
    272272     * @param targetNode the target node the collection of nodes is merged to. Must not be null.
    273273     * @param targetLocationNode this node's location will be used for the targetNode.
    274      * @throw IllegalArgumentException thrown if layer is null
     274     * @throws IllegalArgumentException thrown if layer is null
    275275     */
    276276    public static Command mergeNodes(OsmDataLayer layer, Collection<Node> nodes, Node targetNode, Node targetLocationNode) {
  • trunk/src/org/openstreetmap/josm/data/osm/User.java

    r5495 r5818  
    119119     * Replies the user name
    120120     *
    121      * @return the user name. Never null, but may be the empty string
     121     * @return the user name. Never <code>null</code>, but may be the empty string
    122122     */
    123123    public String getName() {
     
    128128     * Returns the list of user names
    129129     *
    130      * @returns list of names
     130     * @return list of names
    131131     */
    132132    public ArrayList<String> getNames() {
     
    147147     *
    148148     * @param name
     149     * @return <code>true</code> if the name is in the names list
    149150     */
    150151    public boolean hasName(String name) {
     
    160161     * always bound to a user with the same name.
    161162     *
     163     * @return the user id
    162164     */
    163165    public long getId() {
Note: See TracChangeset for help on using the changeset viewer.