Changeset 6881 in josm for trunk/src


Ignore:
Timestamp:
2014-02-24T17:49:12+01:00 (10 years ago)
Author:
Don-vip
Message:

javadoc/code style/minor refactorization

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

Legend:

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

    r6093 r6881  
    1111import org.openstreetmap.josm.tools.ImageProvider;
    1212
    13 
    1413/**
    1514 * Creates a new relation with a copy of the current editor state
     
    1716 */
    1817public class DuplicateRelationAction extends AbstractRelationAction {
    19    
     18
    2019    /**
    21      * Constructs a new {@code DuplicateRelationAction}. 
     20     * Constructs a new {@code DuplicateRelationAction}.
    2221     */
    2322    public DuplicateRelationAction() {
     
    2726    }
    2827
     28    /**
     29     * Duplicates the given relation and launches the relation editor for the created copy.
     30     * @param original The relation to duplicate
     31     */
    2932    public static void duplicateRelationAndLaunchEditor(Relation original) {
    3033        Relation copy = new Relation(original, true);
     
    5053        // only one selected relation can be edited
    5154        setEnabled( relations.size()==1 );
    52     }       
     55    }
    5356}
  • trunk/src/org/openstreetmap/josm/command/AddCommand.java

    r6380 r6881  
    1717
    1818/**
    19  * A command that adds an osm primitive to a dataset. Keys cannot be added this
    20  * way.
     19 * A command that adds an osm primitive to a dataset. Keys cannot be added this way.
    2120 *
    2221 * See {@link ChangeCommand} for comments on relation back references.
     
    3231
    3332    /**
    34      * Create the command and specify the element to add.
     33     * Creates the command and specify the element to add in the context of the current edit layer, if any.
     34     * @param osm The primitive to add
    3535     */
    3636    public AddCommand(OsmPrimitive osm) {
    37         super();
    3837        this.osm = osm;
    3938    }
    4039
    4140    /**
    42      * Create the command and specify the element to add.
     41     * Creates the command and specify the element to add in the context of the given data layer.
     42     * @param layer The data layer. Must not be {@code null}
     43     * @param osm The primitive to add
    4344     */
    4445    public AddCommand(OsmDataLayer layer, OsmPrimitive osm) {
     
    4748    }
    4849
    49     @Override public boolean executeCommand() {
     50    @Override
     51    public boolean executeCommand() {
    5052        getLayer().data.addPrimitive(osm);
    5153        osm.setModified(true);
     
    5355    }
    5456
    55     @Override public void undoCommand() {
     57    @Override
     58    public void undoCommand() {
    5659        getLayer().data.removePrimitive(osm);
    5760    }
    5861
    59     @Override public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
     62    @Override
     63    public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
    6064        added.add(osm);
    6165    }
  • trunk/src/org/openstreetmap/josm/command/ChangeCommand.java

    r6380 r6881  
    2727    private final OsmPrimitive newOsm;
    2828
     29    /**
     30     * Constructs a new {@code ChangeCommand} in the context of the current edit layer, if any.
     31     * @param osm The existing primitive to modify
     32     * @param newOsm The new primitive
     33     */
    2934    public ChangeCommand(OsmPrimitive osm, OsmPrimitive newOsm) {
    30         super();
    3135        this.osm = osm;
    3236        this.newOsm = newOsm;
     
    3438    }
    3539
     40    /**
     41     * Constructs a new {@code ChangeCommand} in the context of a given data layer.
     42     * @param layer The data layer
     43     * @param osm The existing primitive to modify
     44     * @param newOsm The new primitive
     45     */
    3646    public ChangeCommand(OsmDataLayer layer, OsmPrimitive osm, OsmPrimitive newOsm) {
    3747        super(layer);
     
    4050        sanityChecks();
    4151    }
    42    
     52
    4353    private void sanityChecks() {
    4454        CheckParameterUtil.ensureParameterNotNull(osm, "osm");
  • trunk/src/org/openstreetmap/josm/command/ChangeNodesCommand.java

    r4918 r6881  
    66import java.util.Collection;
    77import java.util.List;
     8
    89import javax.swing.Icon;
    910
    1011import org.openstreetmap.josm.data.osm.Node;
    11 import org.openstreetmap.josm.data.osm.Way;
    1212import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1313import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
     14import org.openstreetmap.josm.data.osm.Way;
    1415import org.openstreetmap.josm.gui.DefaultNameFormatter;
    1516import org.openstreetmap.josm.tools.ImageProvider;
     
    2829    private final List<Node> newNodes;
    2930
     31    /**
     32     * Constructs a new {@code ChangeNodesCommand}.
     33     * @param way The way to modify
     34     * @param newNodes The new list of nodes for the given way
     35     */
    3036    public ChangeNodesCommand(Way way, List<Node> newNodes) {
    31         super();
    3237        this.way = way;
    3338        this.newNodes = newNodes;
    3439    }
    3540
    36     @Override public boolean executeCommand() {
     41    @Override
     42    public boolean executeCommand() {
    3743        super.executeCommand();
    3844        way.setNodes(newNodes);
     
    4147    }
    4248
    43     @Override public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
     49    @Override
     50    public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
    4451        modified.add(way);
    4552    }
  • trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java

    r6679 r6881  
    4949     */
    5050    public ChangePropertyCommand(Collection<? extends OsmPrimitive> objects, AbstractMap<String, String> tags) {
    51         super();
    5251        this.objects = new LinkedList<OsmPrimitive>();
    5352        this.tags = tags;
     
    184183
    185184            if (allnull) {
    186                 /* I18n: plural form detected for objects only (but value < 2 not possible!), try to do your best for tags */ 
     185                /* I18n: plural form detected for objects only (but value < 2 not possible!), try to do your best for tags */
    187186                text = trn("Deleted {0} tags for {1} object", "Deleted {0} tags for {1} objects", objects.size(), tags.size(), objects.size());
    188187            } else {
     
    222221    }
    223222
     223    /**
     224     * Returns the tags to set (key/value pairs).
     225     * @return the tags to set (key/value pairs)
     226     */
    224227    public Map<String, String> getTags() {
    225228        return Collections.unmodifiableMap(tags);
  • trunk/src/org/openstreetmap/josm/command/ChangeRelationMemberRoleCommand.java

    r6830 r6881  
    3333    private Boolean oldModified;
    3434
     35    /**
     36     * Constructs a new {@code ChangeRelationMemberRoleCommand}.
     37     * @param relation The relation to be changed
     38     * @param position Member position
     39     * @param newRole New role
     40     */
    3541    public ChangeRelationMemberRoleCommand(Relation relation, int position, String newRole) {
    36         super();
    3742        this.relation = relation;
    3843        this.position = position;
     
    4045    }
    4146
    42     @Override public boolean executeCommand() {
     47    @Override
     48    public boolean executeCommand() {
    4349        if (position < 0 || position >= relation.getMembersCount())
    4450            return false;
     
    5359    }
    5460
    55     @Override public void undoCommand() {
     61    @Override
     62    public void undoCommand() {
    5663        relation.setMember(position, new RelationMember(oldRole, relation.getMember(position).getMember()));
    5764        relation.setModified(oldModified);
    5865    }
    5966
    60     @Override public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
     67    @Override
     68    public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
    6169        modified.add(relation);
    6270    }
  • trunk/src/org/openstreetmap/josm/command/Command.java

    r6639 r6881  
    33
    44import java.awt.GridBagLayout;
    5 import java.awt.geom.Area;
    65import java.util.ArrayList;
    76import java.util.Collection;
     
    160159     *
    161160     */
    162     protected  OsmDataLayer getLayer() {
     161    protected OsmDataLayer getLayer() {
    163162        return layer;
    164163    }
  • trunk/src/org/openstreetmap/josm/command/ConflictResolveCommand.java

    r6248 r6881  
    2121    private ConflictCollection resolvedConflicts;
    2222
     23    /**
     24     * Constructs a new {@code ConflictResolveCommand} in the context of the current edit layer, if any.
     25     */
    2326    public ConflictResolveCommand() {
    2427        super();
     
    2629    }
    2730
     31    /**
     32     * Constructs a new {@code ConflictResolveCommand} in the context of a given data layer.
     33     * @param layer the data layer. Must not be null.
     34     */
    2835    public ConflictResolveCommand(OsmDataLayer layer) {
    2936        super(layer);
  • trunk/src/org/openstreetmap/josm/command/CoordinateConflictResolveCommand.java

    r5816 r6881  
    55
    66import java.util.Collection;
     7
    78import javax.swing.Icon;
    89
     
    1415
    1516/**
    16  * Represents a the resolution of a conflict between the coordinates of two {@link Node}s
     17 * Represents the resolution of a conflict between the coordinates of two {@link Node}s.
    1718 *
    1819 */
  • trunk/src/org/openstreetmap/josm/command/DeleteCommand.java

    r6639 r6881  
    348348
    349349        if (alsoDeleteNodesInWay) {
    350             // delete untagged nodes only referenced by primitives in primitivesToDelete,
    351             // too
     350            // delete untagged nodes only referenced by primitives in primitivesToDelete, too
    352351            Collection<Node> nodesToDelete = computeNodesToDelete(layer, primitivesToDelete);
    353352            primitivesToDelete.addAll(nodesToDelete);
     
    371370        }
    372371
    373         // get a confirmation that the objects to delete can be removed from their parent
    374         // relations
     372        // get a confirmation that the objects to delete can be removed from their parent relations
    375373        //
    376374        if (!silent) {
  • trunk/src/org/openstreetmap/josm/command/DeletedStateConflictResolveCommand.java

    r5816 r6881  
    99
    1010import org.openstreetmap.josm.data.conflict.Conflict;
    11 import org.openstreetmap.josm.data.osm.Node;
    1211import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1312import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType;
     
    1615
    1716/**
    18  * Represents a the resolution of a conflict between the coordinates of two {@link Node}s
     17 * Represents the resolution of a conflict between the deleted flag of two {@link OsmPrimitive}s.
    1918 *
    2019 */
  • trunk/src/org/openstreetmap/josm/command/ModifiedConflictResolveCommand.java

    r5926 r6881  
    1515
    1616/**
    17  * Represents a command for to set the modified flag {@link OsmPrimitive}
     17 * Represents the resolution of a conflict between the modified flag of two {@link OsmPrimitive}s.
    1818 *
    1919 *
  • trunk/src/org/openstreetmap/josm/command/MoveCommand.java

    r6380 r6881  
    5353    private List<OldNodeState> oldState = new LinkedList<OldNodeState>();
    5454
     55    /**
     56     * Constructs a new {@code MoveCommand} to move a primitive.
     57     * @param osm The primitive to move
     58     * @param x X difference movement. Coordinates are in northern/eastern
     59     * @param y Y difference movement. Coordinates are in northern/eastern
     60     */
    5561    public MoveCommand(OsmPrimitive osm, double x, double y) {
    5662        this(Collections.singleton(osm), x, y);
    5763    }
    5864
     65    /**
     66     * Constructs a new {@code MoveCommand} to move a node.
     67     * @param node The node to move
     68     */
    5969    public MoveCommand(Node node, LatLon position) {
    6070        this(Collections.singleton((OsmPrimitive) node), node.getEastNorth().sub(Projections.project(position)));
    6171    }
    6272
     73    /**
     74     * Constructs a new {@code MoveCommand} to move a collection of primitives.
     75     * @param objects The primitives to move
     76     * @param offset The movement vector
     77     */
    6378    public MoveCommand(Collection<OsmPrimitive> objects, EastNorth offset) {
    6479        this(objects, offset.getX(), offset.getY());
     
    6681
    6782    /**
    68      * Create a MoveCommand and assign the initial object set and movement vector.
     83     * Constructs a new {@code MoveCommand} and assign the initial object set and movement vector.
     84     * @param objects The primitives to move
     85     * @param x X difference movement. Coordinates are in northern/eastern
     86     * @param y Y difference movement. Coordinates are in northern/eastern
    6987     */
    7088    public MoveCommand(Collection<OsmPrimitive> objects, double x, double y) {
    71         super();
    7289        startEN = null;
    7390        saveCheckpoint(); // (0,0) displacement will be saved
     
    97114     * The move is immediately executed and any undo will undo both vectors to
    98115     * the original position the objects had before first moving.
     116     *
     117     * @param x X difference movement. Coordinates are in northern/eastern
     118     * @param y Y difference movement. Coordinates are in northern/eastern
    99119     */
    100120    public void moveAgain(double x, double y) {
     
    157177    }
    158178
    159     @Override public boolean executeCommand() {
     179    @Override
     180    public boolean executeCommand() {
    160181        for (Node n : nodes) {
    161182            // in case #3892 happens again
     
    171192    }
    172193
    173     @Override public void undoCommand() {
     194    @Override
     195    public void undoCommand() {
    174196        Iterator<OldNodeState> it = oldState.iterator();
    175197        for (Node n : nodes) {
     
    180202    }
    181203
    182     @Override public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
     204    @Override
     205    public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
    183206        for (OsmPrimitive osm : nodes) {
    184207            modified.add(osm);
  • trunk/src/org/openstreetmap/josm/command/RelationMemberConflictResolverCommand.java

    r6336 r6881  
    1717
    1818/**
    19  * Represent a command for resolving conflicts in the member lists of two
    20  * {@link Relation}s.
     19 * Represents the resolution of conflicts in the member list of two {@link Relation}s.
    2120 *
    2221 */
    23 public class RelationMemberConflictResolverCommand extends Command {
     22public class RelationMemberConflictResolverCommand extends ConflictResolveCommand {
    2423    /** my relation */
    2524    private final Relation my;
     
    3029     */
    3130    private final List<RelationMember> mergedMembers;
    32 
    33     /** the layer this conflict is resolved in */
    34     private OsmDataLayer layer;
    3531
    3632    /**
     
    6258        super.executeCommand();
    6359
    64         // replace the list of members of 'my' relation by the list of merged
    65         // members
     60        // replace the list of members of 'my' relation by the list of merged members
    6661        //
    6762        my.setMembers(mergedMembers);
    6863
    69         // remember the layer
    70         layer = Main.main.getEditLayer();
    7164        return true;
    7265    }
     
    8073    @Override
    8174    public void undoCommand() {
     75        OsmDataLayer layer = getLayer();
    8276        if (! Main.map.mapView.hasLayer(layer)) {
    8377            Main.warn(tr("Cannot undo command ''{0}'' because layer ''{1}'' is not present any more",
  • trunk/src/org/openstreetmap/josm/command/RemoveNodesCommand.java

    r6316 r6881  
    1212
    1313import org.openstreetmap.josm.data.osm.Node;
    14 import org.openstreetmap.josm.data.osm.Way;
    1514import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1615import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
     16import org.openstreetmap.josm.data.osm.Way;
    1717import org.openstreetmap.josm.gui.DefaultNameFormatter;
    1818import org.openstreetmap.josm.tools.ImageProvider;
     
    3030    private final Set<Node> rmNodes;
    3131
     32    /**
     33     * Constructs a new {@code RemoveNodesCommand}.
     34     * @param way The way to modify
     35     * @param rmNodes The list of nodes to remove
     36     */
    3237    public RemoveNodesCommand(Way way, List<Node> rmNodes) {
    33         super();
    3438        this.way = way;
    3539        this.rmNodes = new HashSet<Node>(rmNodes);
    3640    }
    3741
    38     @Override public boolean executeCommand() {
     42    @Override
     43    public boolean executeCommand() {
    3944        super.executeCommand();
    4045        way.removeNodes(rmNodes);
     
    4348    }
    4449
    45     @Override public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
     50    @Override
     51    public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
    4652        modified.add(way);
    4753    }
  • trunk/src/org/openstreetmap/josm/command/TagConflictResolveCommand.java

    r6679 r6881  
    22package org.openstreetmap.josm.command;
    33
    4 import static org.openstreetmap.josm.tools.I18n.marktr;
    5 import static org.openstreetmap.josm.tools.I18n.tr;
    64import static org.openstreetmap.josm.tools.I18n.trn;
    75
    86import java.util.Collection;
    97import java.util.List;
     8
    109import javax.swing.Icon;
    11 
    1210
    1311import org.openstreetmap.josm.data.conflict.Conflict;
     
    1917
    2018/**
    21  * Represents a the resolution of a tag conflict in an {@link OsmPrimitive}
     19 * Represents the resolution of a tag conflict in an {@link OsmPrimitive}.
    2220 *
    2321 */
  • trunk/src/org/openstreetmap/josm/command/VersionConflictResolveCommand.java

    r5816 r6881  
    66
    77import java.util.Collection;
     8
    89import javax.swing.Icon;
    910
     
    1415
    1516/**
    16  * Represents a command for resolving a version conflict between two {@link OsmPrimitive}
     17 * Represents the resolution of a version conflict between two {@link OsmPrimitive}s.
    1718 *
    1819 *
  • trunk/src/org/openstreetmap/josm/command/WayNodesConflictResolverCommand.java

    r6248 r6881  
    1717
    1818/**
    19  * Represent a command for resolving conflicts in the node list of two
    20  * {@link Way}s.
     19 * Represents the resolution of conflicts in the node list of two {@link Way}s.
    2120 *
    2221 */
     
    3938        this.mergedNodeList = mergedNodeList;
    4039    }
     40
    4141    @Override
    4242    public String getDescriptionText() {
  • trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java

    r6316 r6881  
    393393     *
    394394     * See {@link #getConflicts()} for a map of conflicts after the merge operation.
     395     * @param progressMonitor The progress monitor
    395396     */
    396397    public void merge(ProgressMonitor progressMonitor) {
  • trunk/src/org/openstreetmap/josm/io/OsmChangeReader.java

    r5927 r6881  
    1414import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    1515
     16/**
     17 * Reader for <a href="http://wiki.openstreetmap.org/wiki/OsmChange">OsmChange</a> file format.
     18 */
    1619public class OsmChangeReader extends OsmReader {
    1720
     21    /**
     22     * List of possible actions.
     23     */
    1824    public static final String[] ACTIONS = {"create", "modify", "delete"};
    19    
     25
    2026    /**
    2127     * constructor (for private and subclasses use only)
     
    2531    protected OsmChangeReader() {
    2632    }
    27    
    28     /* (non-Javadoc)
    29      * @see org.openstreetmap.josm.io.OsmReader#parseRoot()
    30      */
     33
    3134    @Override
    3235    protected void parseRoot() throws XMLStreamException {
     
    4346            throwException(tr("Missing mandatory attribute ''{0}''.", "version"));
    4447        }
    45         if (!v.equals("0.6")) {
     48        if (!"0.6".equals(v)) {
    4649            throwException(tr("Unsupported version: {0}", v));
    4750        }
     
    8790        }
    8891    }
    89    
     92
    9093    /**
    9194     * Parse the given input source and return the dataset.
Note: See TracChangeset for help on using the changeset viewer.