Changeset 6881 in josm


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

javadoc/code style/minor refactorization

Location:
trunk
Files:
54 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.
  • trunk/test/functional/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergerTest.java

    r6264 r6881  
    6060    }
    6161
     62    /**
     63     * Constructs a new {@code NodeListMergerTest}.
     64     */
    6265    public NodeListMergerTest() {
    6366        build();
     
    7073        test.setVisible(true);
    7174    }
    72 
    73 
    7475}
  • trunk/test/functional/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergerTest.java

    r5556 r6881  
    3535    }
    3636
     37    /**
     38     * Constructs a new {@code PropertiesMergerTest}.
     39     */
    3740    public PropertiesMergerTest() {
    3841        build();
     
    4548        app.setVisible(true);
    4649    }
    47 
    4850}
  • trunk/test/functional/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberMergerTest.java

    r3034 r6881  
    3939    }
    4040
     41    /**
     42     * Constructs a new {@code RelationMemberMergerTest}.
     43     */
    4144    public RelationMemberMergerTest() {
    4245        build();
  • trunk/test/functional/org/openstreetmap/josm/gui/conflict/pair/tags/TagMergerTest.java

    r2041 r6881  
    66import javax.swing.JFrame;
    77
    8 import org.openstreetmap.josm.gui.conflict.pair.tags.TagMergeItem;
    9 import org.openstreetmap.josm.gui.conflict.pair.tags.TagMerger;
    10 
    118public class TagMergerTest extends JFrame {
    129
    1310    private TagMerger tagMerger;
    14    
     11
    1512    protected void build() {
    1613        tagMerger = new TagMerger();
    1714        getContentPane().setLayout(new BorderLayout());
    18         getContentPane().add(tagMerger, BorderLayout.CENTER);       
     15        getContentPane().add(tagMerger, BorderLayout.CENTER);
    1916    }
    20    
     17
     18    /**
     19     * Constructs a new {@code TagMergerTest}.
     20     */
    2121    public TagMergerTest() {
    2222        build();
     
    2929        }
    3030    }
    31    
     31
    3232    public static void main(String args[]) {
    3333        TagMergerTest test  = new TagMergerTest();
     
    3535        test.setVisible(true);
    3636    }
    37    
    3837}
  • trunk/test/functional/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialogTest.java

    r3034 r6881  
    1717        dialog = new ConflictResolutionDialog(this);
    1818        dialog.setSize(600,600);
     19    }
    1920
    20 
    21     }
    2221    protected void populate() {
    2322        Way w1 = new Way(1);
     
    3635    }
    3736
     37    /**
     38     * Constructs a new {@code ConflictResolutionDialogTest}.
     39     */
    3840    public ConflictResolutionDialogTest() {
    3941        build();
  • trunk/test/functional/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManagerTest.java

    r2690 r6881  
    77
    88    private ChangesetCacheManager manager;
    9 
    10     public ChangesetCacheManagerTest() {
    11     }
    129
    1310    public void start() {
  • trunk/test/functional/org/openstreetmap/josm/gui/dialogs/changeset/query/ChangesetQueryDialogTest.java

    r2986 r6881  
    88    private ChangesetQueryDialog dialog;
    99
    10     public ChangesetQueryDialogTest() {
    11     }
    12 
    1310    public void start() {
    1411        dialog = new ChangesetQueryDialog(this);
     
    1714    }
    1815
    19 
    2016    static public void main(String args[]) {
    2117        new ChangesetQueryDialogTest().start();
  • trunk/test/functional/org/openstreetmap/josm/io/MultiFetchServerObjectReaderTest.java

    r6289 r6881  
    229229    private DataSet ds;
    230230
    231 
     231    /**
     232     * Setup test.
     233     */
    232234    @Before
    233235    public void setUp() throws IOException, IllegalDataException {
  • trunk/test/functional/org/openstreetmap/josm/io/OsmServerBackreferenceReaderTest.java

    r6289 r6881  
    236236    private DataSet ds;
    237237
     238    /**
     239     * Setup test.
     240     */
    238241    @Before
    239242    public void setUp() throws IOException, IllegalDataException {
  • trunk/test/unit/org/openstreetmap/TestUtils.java

    r6601 r6881  
    22package org.openstreetmap;
    33
    4 import org.junit.Before;
     4import static org.hamcrest.CoreMatchers.is;
     5import static org.junit.Assert.assertThat;
     6import static org.junit.Assert.assertTrue;
     7
     8import java.util.Map;
     9
    510import org.junit.Test;
    611import org.openstreetmap.josm.Main;
     
    1015import org.openstreetmap.josm.data.osm.Way;
    1116import org.openstreetmap.josm.tools.TextTagParser;
    12 
    13 import java.util.Map;
    14 
    15 import static org.hamcrest.CoreMatchers.is;
    16 import static org.junit.Assert.assertThat;
    17 import static org.junit.Assert.assertTrue;
    1817
    1918public class TestUtils {
  • trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java

    r6471 r6881  
    55import org.junit.Test;
    66import org.openstreetmap.josm.Main;
    7 import org.openstreetmap.josm.data.Preferences;
    87import org.openstreetmap.josm.data.osm.Node;
    98import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    1110public class SearchCompilerTest {
    1211
     12    /**
     13     * Setup test.
     14     */
    1315    @Before
    14     public void setUp() throws Exception {
     16    public void setUp() {
    1517        Main.initApplicationPreferences();
    1618    }
  • trunk/test/unit/org/openstreetmap/josm/corrector/ReverseWayTagCorrectorTest.java

    r6471 r6881  
    66import org.junit.Test;
    77import org.openstreetmap.josm.Main;
    8 import org.openstreetmap.josm.data.Preferences;
    98import org.openstreetmap.josm.data.osm.Tag;
    109
     
    2120        Main.initApplicationPreferences();
    2221    }
    23    
     22
    2423    /**
    2524     * Test of {@link ReverseWayTagCorrector.TagSwitcher#apply} method.
     
    9392        assertSwitch(new Tag("type", "drawdown"), new Tag("type", "drawdown"));
    9493    }
    95    
     94
    9695    private void assertSwitch(Tag oldTag, Tag newTag) {
    9796        Assert.assertEquals(ReverseWayTagCorrector.TagSwitcher.apply(oldTag), newTag);
  • trunk/test/unit/org/openstreetmap/josm/data/osm/APIDataSetTest.java

    r6801 r6881  
    1212import org.openstreetmap.josm.actions.upload.CyclicUploadDependencyException;
    1313import org.openstreetmap.josm.data.APIDataSet;
    14 import org.openstreetmap.josm.data.Preferences;
    15 
    1614
    1715public class APIDataSetTest {
  • trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java

    r6471 r6881  
    1818import org.junit.Test;
    1919import org.openstreetmap.josm.Main;
    20 import org.openstreetmap.josm.data.Preferences;
    2120import org.openstreetmap.josm.data.coor.LatLon;
    2221import org.openstreetmap.josm.data.projection.Projections;
    2322
    2423public class DataSetMergerTest {
    25     /*private static Logger logger = Logger.getLogger(DataSetMergerTest.class.getName());
    26 
    27     static Properties testProperties;
    28 
    29     @BeforeClass
    30     static public void init() {
    31 
    32         if(System.getProperty("josm.home") == null){
    33             testProperties = new Properties();
    34 
    35             // load properties
    36             //
    37             try {
    38                 testProperties.load(DataSetMergerTest.class.getResourceAsStream("/test-unit-env.properties"));
    39             } catch(Exception e){
    40                 logger.log(Level.SEVERE, MessageFormat.format("failed to load property file ''{0}''", "/test-unit-env.properties"));
    41                 fail(MessageFormat.format("failed to load property file ''{0}''", "/test-unit-env.properties"));
    42             }
    43 
    44             // check josm.home
    45             //
    46             String josmHome = testProperties.getProperty("josm.home");
    47             if (josmHome == null) {
    48                 fail(MessageFormat.format("property ''{0}'' not set in test environment", "josm.home"));
    49             } else {
    50                 File f = new File(josmHome);
    51                 if (! f.exists() || ! f.canRead()) {
    52                     fail(MessageFormat.format("property ''{0}'' points to ''{1}'' which is either not existing or not readable", "josm.home", josmHome));
    53                 }
    54             }
    55             System.setProperty("josm.home", josmHome);
    56         }
    57         Main.pref.init(false);
    58 
    59         // init projection
    60         Main.proj = new Mercator();
    61     }*/
    6224
    6325    @BeforeClass
     
    6931    private DataSet their;
    7032
     33    /**
     34     * Setup test.
     35     */
    7136    @Before
    7237    public void setUp() {
  • trunk/test/unit/org/openstreetmap/josm/data/osm/FilterTest.java

    r6471 r6881  
    1717import org.openstreetmap.josm.actions.search.SearchAction.SearchMode;
    1818import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
    19 import org.openstreetmap.josm.data.Preferences;
    2019import org.openstreetmap.josm.data.coor.LatLon;
    2120import org.openstreetmap.josm.data.projection.Projections;
     
    2423import org.openstreetmap.josm.io.OsmReader;
    2524
    26 
    2725public class FilterTest {
    2826
     27    /**
     28     * Setup test.
     29     */
    2930    @BeforeClass
    3031    public static void setUp() {
  • trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveKeyHandling.java

    r6830 r6881  
    3636
    3737    /**
    38      * Add a tag to an empty node and test the query and get methods.
    39      *
     38     * Adds a tag to an empty node and test the query and get methods.
    4039     */
    4140    @Test
     
    5150
    5251    /**
    53      * Add two tags to an empty node and test the query and get methods.
     52     * Adds two tags to an empty node and test the query and get methods.
    5453     */
    5554    @Test
     
    6867
    6968    /**
    70      * Remove tags from a node with two tags and test the state of the node.
    71      *
     69     * Removes tags from a node with two tags and test the state of the node.
    7270     */
    7371    @Test
     
    9694
    9795    /**
    98      * Remove all tags from a node
    99      *
     96     * Removes all tags from a node.
    10097     */
    10198    @Test
     
    132129     * Test hasEqualSemanticAttributes on two nodes with different tags.
    133130     */
    134 
    135131    @Test
    136132    public void hasEqualSemanticAttributes_2() {
     
    147143        assertTrue(!n1.hasEqualSemanticAttributes(n2));
    148144    }
    149 
    150145}
  • trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveTest.java

    r6471 r6881  
    99import org.junit.Test;
    1010import org.openstreetmap.josm.Main;
    11 import org.openstreetmap.josm.data.Preferences;
    1211import org.openstreetmap.josm.data.coor.LatLon;
    1312import org.openstreetmap.josm.data.projection.Projections;
     
    2726    private DataSet dataSet = new DataSet();
    2827
     28    /**
     29     * Setup test.
     30     */
    2931    @BeforeClass
    3032    public static void setUp() {
  • trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java

    r6471 r6881  
    1414import org.junit.Test;
    1515import org.openstreetmap.josm.Main;
    16 import org.openstreetmap.josm.data.Preferences;
    1716import org.openstreetmap.josm.data.coor.LatLon;
    1817import org.openstreetmap.josm.data.projection.Projections;
     
    8281        removeAllTest(ds);
    8382    }
    84 
    8583}
  • trunk/test/unit/org/openstreetmap/josm/data/osm/RelationTest.java

    r6471 r6881  
    88import org.junit.Test;
    99import org.openstreetmap.josm.Main;
    10 import org.openstreetmap.josm.data.Preferences;
    1110import org.openstreetmap.josm.data.coor.LatLon;
    1211import org.openstreetmap.josm.data.projection.Projections;
     
    1413public class RelationTest {
    1514
     15    /**
     16     * Setup test.
     17     */
    1618    @BeforeClass
    1719    public static void setUp() {
     
    104106        Assert.assertEquals(new BBox(w1), r1.getBBox());
    105107    }
    106 
    107108}
  • trunk/test/unit/org/openstreetmap/josm/data/osm/history/HistoryNodeTest.java

    r4603 r6881  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.osm.history;
    3 
    43
    54import static org.junit.Assert.assertEquals;
  • trunk/test/unit/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitorTest.java

    r6471 r6881  
    1212import org.junit.Test;
    1313import org.openstreetmap.josm.Main;
    14 import org.openstreetmap.josm.data.Preferences;
    1514import org.openstreetmap.josm.data.coor.LatLon;
    1615import org.openstreetmap.josm.data.osm.DataSet;
     
    3534    }
    3635
     36    /**
     37     * Setup test.
     38     */
    3739    @BeforeClass
    3840    public static void setUp() {
  • trunk/test/unit/org/openstreetmap/josm/data/projection/EllipsoidTest.java

    r6334 r6881  
    4141            maxErrLon = Math.max(maxErrLon, Math.abs(lon - ll.lon()));
    4242        }
    43         //System.err.println(String.format("maxerror lat: %s maxerror lon: %s", maxErrLat, maxErrLon));
    4443    }
    4544}
  • trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java

    r6471 r6881  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.projection;
    3 
    43
    54import java.io.BufferedReader;
     
    2524import org.openstreetmap.josm.Main;
    2625import org.openstreetmap.josm.data.Bounds;
    27 import org.openstreetmap.josm.data.Preferences;
    2826import org.openstreetmap.josm.data.coor.EastNorth;
    2927import org.openstreetmap.josm.data.coor.LatLon;
     
    147145    }
    148146
     147    /**
     148     * Setup test.
     149     */
    149150    @BeforeClass
    150151    public static void setUp() {
     
    198199            throw new AssertionError(fail.toString());
    199200        }
    200 
    201201    }
    202202}
  • trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionTest.java

    r6334 r6881  
    1212public class ProjectionTest {
    1313
    14     private static final boolean debug = false;
    1514    private static Random rand = new Random(System.currentTimeMillis());
    1615
     
    6463            double maxErrLat = 0, maxErrLon = 0;
    6564            Bounds b = p.getWorldBoundsLatLon();
    66    
     65
    6766            text += String.format("*** %s %s%n", p.toString(), p.toCode());
    6867            for (int num=0; num < 1000; ++num) {
    69    
     68
    7069                double lat = rand.nextDouble() * (b.getMax().lat() - b.getMin().lat()) + b.getMin().lat();
    7170                double lon = rand.nextDouble() * (b.getMax().lon() - b.getMin().lon()) + b.getMin().lon();
    72    
     71
    7372                LatLon ll = new LatLon(lat, lon);
    74    
     73
    7574                for (int i=0; i<10; ++i) {
    7675                    EastNorth en = p.latlon2eastNorth(ll);
     
    8079                maxErrLon = Math.max(maxErrLon, Math.abs(lon - ll.lon()));
    8180            }
    82    
     81
    8382            String mark = "";
    8483            if (maxErrLat + maxErrLon > 1e-5) {
  • trunk/test/unit/org/openstreetmap/josm/data/projection/SwissGridTest.java

    r6334 r6881  
    1313    private boolean debug = false;
    1414
     15    /**
     16     * Setup test.
     17     */
    1518    @BeforeClass
    1619    public static void setUp() {
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/DuplicateNodeTest.java

    r6471 r6881  
    77import org.junit.Test;
    88import org.openstreetmap.josm.Main;
    9 import org.openstreetmap.josm.data.Preferences;
    109import org.openstreetmap.josm.data.coor.LatLon;
    1110import org.openstreetmap.josm.data.osm.DataSet;
     
    1514
    1615/**
    17  * JUnit Test of "Duplicate node" validation test. 
     16 * JUnit Test of "Duplicate node" validation test.
    1817 */
    1918public class DuplicateNodeTest {
    2019
    2120    /**
    22      * Setup test by initializing JOSM preferences and projection. 
     21     * Setup test by initializing JOSM preferences and projection.
    2322     */
    2423    @BeforeClass
     
    4443        test.visit(ds.allPrimitives());
    4544        test.endTest();
    46        
     45
    4746        assertEquals(1, test.getErrors().size());
    4847    }
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java

    r6677 r6881  
    2828public class MapCSSTagCheckerTest {
    2929
     30    /**
     31     * Setup test.
     32     */
    3033    @Before
    3134    public void setUp() throws Exception {
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/OpeningHourTestTest.java

    r6858 r6881  
    22package org.openstreetmap.josm.data.validation.tests;
    33
    4 import org.junit.Before;
    5 import org.junit.Test;
    6 import org.openstreetmap.josm.Main;
    7 import org.openstreetmap.josm.data.osm.Tag;
    8 import org.openstreetmap.josm.data.validation.Severity;
    9 import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference;
    10 import org.openstreetmap.josm.gui.tagging.TaggingPreset;
    11 import org.openstreetmap.josm.gui.tagging.TaggingPresetItem;
    12 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems;
    13 import org.openstreetmap.josm.gui.tagging.TaggingPresetReader;
    14 import org.openstreetmap.josm.gui.tagging.TaggingPresetSearchAction;
     4import static org.CustomMatchers.hasSize;
     5import static org.CustomMatchers.isEmpty;
     6import static org.hamcrest.CoreMatchers.is;
     7import static org.hamcrest.CoreMatchers.not;
     8import static org.junit.Assert.assertThat;
    159
    1610import java.util.Arrays;
     
    2014import java.util.Set;
    2115
    22 import static org.CustomMatchers.hasSize;
    23 import static org.CustomMatchers.isEmpty;
    24 import static org.hamcrest.CoreMatchers.is;
    25 import static org.hamcrest.CoreMatchers.not;
    26 import static org.junit.Assert.assertThat;
     16import org.junit.Before;
     17import org.junit.Test;
     18import org.openstreetmap.josm.Main;
     19import org.openstreetmap.josm.data.osm.Tag;
     20import org.openstreetmap.josm.data.validation.Severity;
     21import org.openstreetmap.josm.gui.tagging.TaggingPreset;
     22import org.openstreetmap.josm.gui.tagging.TaggingPresetItem;
     23import org.openstreetmap.josm.gui.tagging.TaggingPresetItems;
     24import org.openstreetmap.josm.gui.tagging.TaggingPresetReader;
    2725
    2826/**
    29  * JUnit Test of "Opening hours" validation test. 
     27 * JUnit Test of "Opening hours" validation test.
    3028 */
    3129public class OpeningHourTestTest {
     
    3331    private static final OpeningHourTest OPENING_HOUR_TEST = new OpeningHourTest();
    3432
     33    /**
     34     * Setup test.
     35     */
    3536    @Before
    3637    public void setUp() throws Exception {
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/UnconnectedWaysTest.java

    r6603 r6881  
    1919    UnconnectedWays bib;
    2020
     21    /**
     22     * Setup test.
     23     */
    2124    @Before
    2225    public void setUp() throws Exception {
  • trunk/test/unit/org/openstreetmap/josm/gui/SystemOfMeasurementTest.java

    r6471 r6881  
    11package org.openstreetmap.josm.gui;
    22
    3 import static org.junit.Assert.*;
     3import static org.junit.Assert.assertEquals;
     4
     5import java.text.DecimalFormat;
     6import java.text.DecimalFormatSymbols;
     7import java.util.Locale;
    48
    59import org.junit.BeforeClass;
    610import org.junit.Test;
    711import org.openstreetmap.josm.Main;
    8 import org.openstreetmap.josm.data.Preferences;
    912import org.openstreetmap.josm.gui.NavigatableComponent.SystemOfMeasurement;
    10 
    11 import java.text.DecimalFormat;
    12 import java.text.DecimalFormatSymbols;
    13 import java.util.Locale;
    1413
    1514/**
     
    2524        Main.initApplicationPreferences();
    2625    }
    27    
     26
    2827    /**
    2928     * Test of {@link SystemOfMeasurement#getDistText} method.
     
    3130    @Test
    3231    public void testGetDistText() {
    33        
     32
    3433        assertEquals("< 0.01 m", NavigatableComponent.METRIC_SOM.getDistText(-1));
    3534        assertEquals("< 0.01 m", NavigatableComponent.METRIC_SOM.getDistText(-0.99));
     
    3837
    3938        assertEquals("0.01 m", NavigatableComponent.METRIC_SOM.getDistText(0.01));
    40        
     39
    4140        assertEquals("0.99 m", NavigatableComponent.METRIC_SOM.getDistText(0.99));
    4241        assertEquals("1.00 m", NavigatableComponent.METRIC_SOM.getDistText(1.0));
     
    6766    }
    6867
     68    /**
     69     * Test of {@link SystemOfMeasurement#getDistText} method with a non-English locale.
     70     */
    6971    @Test
    7072    public void testGetDistTextLocalized() {
     
    8890
    8991        assertEquals("0.01 m²", NavigatableComponent.METRIC_SOM.getAreaText(0.01));
    90        
     92
    9193        assertEquals("0.99 m²", NavigatableComponent.METRIC_SOM.getAreaText(0.99));
    9294        assertEquals("1.00 m²", NavigatableComponent.METRIC_SOM.getAreaText(1.0));
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/properties/PropertiesMergeModelTest.java

    r6471 r6881  
    1313import org.junit.Test;
    1414import org.openstreetmap.josm.Main;
    15 import org.openstreetmap.josm.data.Preferences;
    1615import org.openstreetmap.josm.data.conflict.Conflict;
    1716import org.openstreetmap.josm.data.coor.LatLon;
     
    5150    }
    5251
     52    /**
     53     * Setup test.
     54     */
    5355    @Before
    5456    public void setUp() {
     
    141143        model.deleteObserver(observerTest);
    142144    }
    143 
    144 
    145145}
  • trunk/test/unit/org/openstreetmap/josm/gui/tagging/TaggingPresetReaderTest.java

    r6562 r6881  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.tagging;
     3
     4import static org.CustomMatchers.hasSize;
     5import static org.hamcrest.CoreMatchers.is;
     6import static org.junit.Assert.assertThat;
     7
     8import java.io.IOException;
     9import java.util.Collection;
     10import java.util.List;
    311
    412import org.junit.Assert;
     
    1018import org.xml.sax.SAXException;
    1119
    12 import java.io.IOException;
    13 import java.util.Collection;
    14 import java.util.List;
    15 
    16 import static org.CustomMatchers.hasSize;
    17 import static org.hamcrest.CoreMatchers.is;
    18 import static org.junit.Assert.assertThat;
    19 
    2020/**
    2121 * Unit tests of {@link TaggingPresetReader} class.
     
    2323public class TaggingPresetReaderTest {
    2424
     25    /**
     26     * Setup test.
     27     */
    2528    @BeforeClass
    26     public static void setUpClass() {
     29    public static void setUp() {
    2730        Main.initApplicationPreferences();
    2831    }
     
    3033    /**
    3134     * Gets path to test data directory for given ticketid.
    32      * @param ticketid 
    33      * @return 
     35     * @param ticketid
     36     * @return
    3437     */
    3538    protected static String getRegressionDataDir(int ticketid) {
     
    4144     * @param ticketid
    4245     * @param filename
    43      * @return 
     46     * @return
    4447     */
    4548    protected static String getRegressionDataFile(int ticketid, String filename) {
     
    8588        Assert.assertTrue("Default presets are empty", presets.size()>0);
    8689    }
    87    
    8890}
  • trunk/test/unit/org/openstreetmap/josm/tools/TextTagParserTest.java

    r6471 r6881  
    1010import org.junit.Test;
    1111import org.openstreetmap.josm.Main;
    12 import org.openstreetmap.josm.data.Preferences;
    1312
    1413public class TextTagParserTest {
     14
     15    /**
     16     * Setup test.
     17     */
    1518    @BeforeClass
    16     public static void before() {
     19    public static void setUp() {
    1720        Main.initApplicationPreferences();
    1821    }
     
    2629        s = "\"2 \\\"3\\\" 4\"";       s1 = "2 \"3\" 4";
    2730        Assert.assertEquals(s1, TextTagParser.unescape(s));
    28        
     31
    2932        s = "\"2 3 ===4===\"";       s1 = "2 3 ===4===";
    3033        Assert.assertEquals(s1, TextTagParser.unescape(s));
     
    3336        Assert.assertEquals(s1, TextTagParser.unescape(s));
    3437    }
    35    
     38
    3639    @Test
    3740    public void testTNformat() {
     
    6366        tags = TextTagParser.readTagsFromText(txt);
    6467        Assert.assertEquals(correctTags, tags);
    65        
     68
    6669        txt = "\"a\"  :     \"1 1 1\", \"b2\"  :\"2 \\\"3 qwe\\\" 4\"";
    6770        correctTags= new HashMap<String, String>() { { put("a", "1 1 1"); put("b2", "2 \"3 qwe\" 4");}};
    6871        tags = TextTagParser.readTagsFromText(txt);
    6972        Assert.assertEquals(correctTags, tags);
    70        
     73
    7174        txt = " \"aыыы\"   :    \"val\\\"\\\"\\\"ue1\"";
    7275        correctTags= new HashMap<String, String>() { { put("aыыы", "val\"\"\"ue1");} };
     
    7477        Assert.assertEquals(correctTags, tags);
    7578    }
    76    
     79
    7780    @Test
    7881    public void testFreeformat() {
     
    8487        Assert.assertEquals(correctTags, tags);
    8588    }
    86    
     89
    8790    @Test
    8891    public void errorDetect() {
     
    9093        Map<String, String> tags = TextTagParser.readTagsFromText(txt);
    9194        Assert.assertEquals(Collections.EMPTY_MAP, tags);
    92        
     95
    9396    }
    9497}
  • trunk/test/unit/org/openstreetmap/josm/tools/template_engine/TemplateEngineTest.java

    r6471 r6881  
    1919public class TemplateEngineTest {
    2020
     21    /**
     22     * Setup test.
     23     */
    2124    @BeforeClass
    22     public static void before() {
     25    public static void setUp() {
    2326        Main.initApplicationPreferences();
    2427    }
Note: See TracChangeset for help on using the changeset viewer.