Ignore:
Timestamp:
2005-12-03T14:14:35+01:00 (20 years ago)
Author:
imi
Message:
  • Removed edit layer, combine action, save gpx (integrated in normal save)
  • Simplified and unified shortkeys
  • many small code simplifications
  • added undo
  • broken checkin!
File:
1 edited

Legend:

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

    r23 r30  
    22
    33import java.awt.Component;
     4import java.awt.geom.Point2D;
    45import java.util.Collection;
     6import java.util.Iterator;
     7import java.util.LinkedList;
     8import java.util.List;
    59
    610import javax.swing.JLabel;
     
    2125         * The objects that should be moved.
    2226         */
    23         private Collection<OsmPrimitive> objects;
     27        private List<OsmPrimitive> objects;
    2428        /**
    2529         * x difference movement. Coordinates are in northern/eastern
     
    3236
    3337        /**
     38         * x/y List of all old positions of the objects.
     39         */
     40        private List<Point2D.Double> oldPositions;
     41       
     42        /**
    3443         * Create a MoveCommand and assign the initial object set and movement vector.
    3544         */
    3645        public MoveCommand(Collection<OsmPrimitive> objects, double x, double y) {
    37                 this.objects = objects;
     46                this.objects = new LinkedList<OsmPrimitive>(objects);
    3847                this.x = x;
    3948                this.y = y;
    40         }
    41 
    42         /**
    43          * Move the objects additional to the current movement.
    44          */
    45         public void move(double x, double y) {
    46                 this.x += x;
    47                 this.y += y;
    4849        }
    4950
     
    5859        }
    5960
     61        public void undoCommand() {
     62                AllNodesVisitor visitor = new AllNodesVisitor();
     63                for (OsmPrimitive osm : objects)
     64                        osm.visit(visitor);
     65                Iterator<Point2D.Double> it = oldPositions.iterator();
     66                for (Node n : visitor.nodes) {
     67                        Point2D.Double p = it.next();
     68                        n.coor.x = p.x;
     69                        n.coor.y = p.y;
     70                }
     71        }
     72
    6073        public Component commandDescription() {
    6174                String xstr = Math.abs(x) + (x < 0 ? "W" : "E");
     
    6578
    6679        public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
    67                 if (modified != null)
    68                         for (OsmPrimitive osm : objects)
    69                                 if (!modified.contains(osm))
    70                                         modified.add(osm);
     80                for (OsmPrimitive osm : objects)
     81                        if (!modified.contains(osm))
     82                                modified.add(osm);
    7183        }
    7284}
Note: See TracChangeset for help on using the changeset viewer.