Changeset 12759 in josm


Ignore:
Timestamp:
2017-09-06T17:00:54+02:00 (3 months ago)
Author:
Don-vip
Message:

fix #15252 - see #13036 - MoveCommand created without data set

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

Legend:

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

    r12641 r12759  
    144144                ((MoveCommand) c).moveAgain(distx, disty);
    145145            } else {
    146                 c = new MoveCommand(selection, distx, disty);
     146                c = new MoveCommand(ds, selection, distx, disty);
    147147                MainApplication.undoRedo.add(c);
    148148            }
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r12726 r12759  
    12441244                virtualCmds.add(new ChangeCommand(ds, w, wnew));
    12451245            }
    1246             virtualCmds.add(new MoveCommand(virtualNode, startEN, currentEN));
     1246            virtualCmds.add(new MoveCommand(ds, virtualNode, startEN, currentEN));
    12471247            String text = trn("Add and move a virtual new node to way",
    12481248                    "Add and move a virtual new node to {0} ways", virtualWays.size(),
  • trunk/src/org/openstreetmap/josm/command/MoveCommand.java

    r12726 r12759  
    1616import org.openstreetmap.josm.data.coor.EastNorth;
    1717import org.openstreetmap.josm.data.coor.LatLon;
     18import org.openstreetmap.josm.data.osm.DataSet;
    1819import org.openstreetmap.josm.data.osm.Node;
    1920import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    9293     */
    9394    public MoveCommand(Collection<OsmPrimitive> objects, double x, double y) {
    94         super(objects.iterator().next().getDataSet());
     95        this(objects.iterator().next().getDataSet(), objects, x, y);
     96    }
     97
     98    /**
     99     * Constructs a new {@code MoveCommand} and assign the initial object set and movement vector.
     100     * @param ds the dataset context for moving these primitives. Must not be null.
     101     * @param objects The primitives to move. Must neither be null.
     102     * @param x X difference movement. Coordinates are in northern/eastern
     103     * @param y Y difference movement. Coordinates are in northern/eastern
     104     * @throws NullPointerException if objects is null or contain null item
     105     * @throws NoSuchElementException if objects is empty
     106     * @since 12759
     107     */
     108    public MoveCommand(DataSet ds, Collection<OsmPrimitive> objects, double x, double y) {
     109        super(ds);
    95110        startEN = null;
    96111        saveCheckpoint(); // (0,0) displacement will be saved
     
    106121    /**
    107122     * Constructs a new {@code MoveCommand} to move a collection of primitives.
     123     * @param ds the dataset context for moving these primitives. Must not be null.
    108124     * @param objects The primitives to move
    109125     * @param start The starting position (northern/eastern)
    110126     * @param end The ending position (northern/eastern)
     127     * @since 12759
     128     */
     129    public MoveCommand(DataSet ds, Collection<OsmPrimitive> objects, EastNorth start, EastNorth end) {
     130        this(Objects.requireNonNull(ds, "ds"),
     131             Objects.requireNonNull(objects, "objects"),
     132             Objects.requireNonNull(end, "end").getX() - Objects.requireNonNull(start, "start").getX(),
     133             Objects.requireNonNull(end, "end").getY() - Objects.requireNonNull(start, "start").getY());
     134        startEN = start;
     135    }
     136
     137    /**
     138     * Constructs a new {@code MoveCommand} to move a collection of primitives.
     139     * @param objects The primitives to move
     140     * @param start The starting position (northern/eastern)
     141     * @param end The ending position (northern/eastern)
    111142     */
    112143    public MoveCommand(Collection<OsmPrimitive> objects, EastNorth start, EastNorth end) {
    113         this(
    114                 Objects.requireNonNull(objects, "objects"),
    115                 Objects.requireNonNull(end, "end").getX() - Objects.requireNonNull(start, "start").getX(),
    116                 Objects.requireNonNull(end, "end").getY() - Objects.requireNonNull(start, "start").getY());
    117         startEN = start;
     144        this(Objects.requireNonNull(objects, "objects").iterator().next().getDataSet(), objects, start, end);
     145    }
     146
     147    /**
     148     * Constructs a new {@code MoveCommand} to move a primitive.
     149     * @param ds the dataset context for moving these primitives. Must not be null.
     150     * @param p The primitive to move
     151     * @param start The starting position (northern/eastern)
     152     * @param end The ending position (northern/eastern)
     153     * @since 12759
     154     */
     155    public MoveCommand(DataSet ds, OsmPrimitive p, EastNorth start, EastNorth end) {
     156        this(ds, Collections.singleton(Objects.requireNonNull(p, "p")), start, end);
    118157    }
    119158
     
    125164     */
    126165    public MoveCommand(OsmPrimitive p, EastNorth start, EastNorth end) {
    127         this(
    128                 Collections.singleton(Objects.requireNonNull(p, "p")),
    129                 Objects.requireNonNull(end, "end").getX() - Objects.requireNonNull(start, "start").getX(),
    130                 Objects.requireNonNull(end, "end").getY() - Objects.requireNonNull(start, "start").getY());
    131         startEN = start;
     166        this(Collections.singleton(Objects.requireNonNull(p, "p")), start, end);
    132167    }
    133168
Note: See TracChangeset for help on using the changeset viewer.