Changeset 312 in josm


Ignore:
Timestamp:
2007-08-23T15:59:32+02:00 (17 years ago)
Author:
imi
Message:
  • fixed bug to allow move of one node
  • removed "new shiny beta" warning
  • fixed uploading data marks as modified when saved before
Location:
src/org/openstreetmap/josm
Files:
6 edited

Legend:

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

    r311 r312  
    1515import org.openstreetmap.josm.Main;
    1616import org.openstreetmap.josm.actions.GroupAction;
    17 import org.openstreetmap.josm.actions.mapmode.AddNodeAction.Mode;
    1817import org.openstreetmap.josm.command.Command;
    1918import org.openstreetmap.josm.command.MoveCommand;
     
    120119               
    121120                // when rotating, having only one node makes no sense - quit silently
    122                 if (affectedNodes.size() < 2 && mode == Mode.move)
     121                if (mode == Mode.rotate && affectedNodes.size() < 2)
    123122                        return;
    124123               
  • src/org/openstreetmap/josm/command/MoveCommand.java

    r307 r312  
    55import static org.openstreetmap.josm.tools.I18n.trn;
    66
    7 import java.util.Arrays;
    87import java.util.Collection;
    98import java.util.Collections;
     
    4746         * Small helper for holding the interesting part of the old data state of the
    4847         * objects.
    49          * @author imi
    5048         */
    51         class OldState
    52         {
    53                 double x,y,lat,lon;
     49        public static class OldState {
     50                LatLon latlon;
     51                EastNorth eastNorth;
    5452                boolean modified;
    5553        }
     54       
    5655        /**
    5756         * List of all old states of the objects.
     
    7271                for (Node n : this.objects) {
    7372                        OldState os = new OldState();
    74                         os.x = n.eastNorth.east();
    75                         os.y = n.eastNorth.north();
    76                         os.lat = n.coor.lat();
    77                         os.lon = n.coor.lon();
     73                        os.eastNorth = n.eastNorth;
     74                        os.latlon = n.coor;
    7875                        os.modified = n.modified;
    7976                        oldState.add(os);
     
    110107                for (Node n : objects) {
    111108                        OldState os = it.next();
    112                         n.eastNorth = new EastNorth(os.x, os.y);
    113                         n.coor = new LatLon(os.lat, os.lon);
     109                        n.eastNorth = os.eastNorth;
     110                        n.coor = os.latlon;
    114111                        n.modified = os.modified;
    115112                }
  • src/org/openstreetmap/josm/command/RotateCommand.java

    r311 r312  
    44import static org.openstreetmap.josm.tools.I18n.trn;
    55
    6 import java.util.Arrays;
    76import java.util.Collection;
    87import java.util.HashMap;
    9 import java.util.Iterator;
    108import java.util.LinkedList;
    11 import java.util.List;
    129import java.util.Map;
    1310
     
    1714
    1815import org.openstreetmap.josm.Main;
    19 import org.openstreetmap.josm.command.MoveCommand.OldState;
    2016import org.openstreetmap.josm.data.coor.EastNorth;
    2117import org.openstreetmap.josm.data.coor.LatLon;
     
    5349       
    5450        /**
    55          * Small helper for holding the interesting part of the old data state of the
    56          * objects.
    57          */
    58         class OldState
    59         {
    60                 double x,y,lat,lon;
    61                 boolean modified;
    62                 Node originalNode;
    63         }
    64        
    65         /**
    6651         * List of all old states of the objects.
    6752         */
    68         private Map<Node, OldState> oldState = new HashMap<Node, OldState>();
     53        private Map<Node, MoveCommand.OldState> oldState = new HashMap<Node, MoveCommand.OldState>();
    6954       
    7055        /**
     
    8065                       
    8166                for (Node n : this.objects) {
    82                         OldState os = new OldState();
    83                         os.x = n.eastNorth.east();
    84                         os.y = n.eastNorth.north();
    85                         os.lat = n.coor.lat();
    86                         os.lon = n.coor.lon();
     67                        MoveCommand.OldState os = new MoveCommand.OldState();
     68                        os.eastNorth = n.eastNorth;
     69                        os.latlon = n.coor;
    8770                        os.modified = n.modified;
    8871                        oldState.put(n, os);
    89                         pivot.eastNorth = new EastNorth(pivot.eastNorth.east()+os.x, pivot.eastNorth.north()+os.y);
     72                        pivot.eastNorth = new EastNorth(pivot.eastNorth.east()+os.eastNorth.east(), pivot.eastNorth.north()+os.eastNorth.north());
    9073                        pivot.coor = Main.proj.eastNorth2latlon(pivot.eastNorth);
    9174                }
     
    118101                        double cosPhi = Math.cos(rotationAngle);
    119102                        double sinPhi = Math.sin(rotationAngle);
    120                         double x = oldState.get(n).x - pivot.eastNorth.east();
    121                         double y = oldState.get(n).y - pivot.eastNorth.north();
     103                        EastNorth oldEastNorth = oldState.get(n).eastNorth;
     104                        double x = oldEastNorth.east() - pivot.eastNorth.east();
     105                        double y = oldEastNorth.north() - pivot.eastNorth.north();
    122106                        double nx =  sinPhi * x + cosPhi * y + pivot.eastNorth.east();
    123107                        double ny = -cosPhi * x + sinPhi * y + pivot.eastNorth.north();
    124108                        n.eastNorth = new EastNorth(nx, ny);
    125109                        n.coor = Main.proj.eastNorth2latlon(n.eastNorth);
    126                         if (setModified) n.modified = true;
     110                        if (setModified)
     111                                n.modified = true;     
    127112                }
    128113        }
     
    134119        @Override public void undoCommand() {
    135120                for (Node n : objects) {
    136                         OldState os = oldState.get(n);
    137                         n.eastNorth = new EastNorth(os.x, os.y);
    138                         n.coor = new LatLon(os.lat, os.lon);
     121                        MoveCommand.OldState os = oldState.get(n);
     122                        n.eastNorth = os.eastNorth;
     123                        n.coor = os.latlon;
    139124                        n.modified = os.modified;
    140125                }
  • src/org/openstreetmap/josm/gui/GettingStarted.java

    r298 r312  
    4848                panel = new JPanel(new GridBagLayout());
    4949               
    50                 panel.add(new JLabel("<html><h2>You are running a beta version with a brand new feature <i>multiple data layers</i>.</h2>" +
    51                                 "<h3>This is a major change, so expect some bugs, especally with undo/redo and the merging code.<br>" +
    52                                 "If you can't work, downgrade to josm-1.5.jar, available at http://josm.openstreetmap.org/download/josm-1.5.jar<br><br>" +
    53                 "Imi.</h3>"), GBC.eol());
    54 
    5550                addGettingStarted();
    5651                addGettingHelp();
  • src/org/openstreetmap/josm/gui/MapFrame.java

    r311 r312  
    1818import org.openstreetmap.josm.actions.mapmode.DeleteAction;
    1919import org.openstreetmap.josm.actions.mapmode.MapMode;
    20 import org.openstreetmap.josm.actions.mapmode.MoveAction;
    2120import org.openstreetmap.josm.actions.mapmode.SelectionAction;
    2221import org.openstreetmap.josm.actions.mapmode.ZoomAction;
  • src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r303 r312  
    108108         */
    109109        public boolean uploadedModified = false;
    110         /**
    111          * Whether the data (or pieces of the data) was loaded from disk rather than from
    112          * the server directly. This affects the modified state.
    113          */
    114         private boolean fromDisk = false;
    115110
    116111        public final LinkedList<ModifiedChangedListener> listenerModified = new LinkedList<ModifiedChangedListener>();
     
    124119                super(name);
    125120                this.data = data;
    126                 this.fromDisk = associatedFile != null;
    127121                this.associatedFile = associatedFile;
    128122        }
     
    235229
    236230                // update the modified flag
    237                 if (fromDisk && processed != null && !dataAdded)
     231                if (associatedFile != null && processed != null && !dataAdded)
    238232                        return; // do nothing when uploading non-harmful changes.
    239233
    240234                // modified if server changed the data (esp. the id).
    241                 uploadedModified = fromDisk && processed != null && dataAdded;
     235                uploadedModified = associatedFile != null && processed != null && dataAdded;
    242236                setModified(uploadedModified);
    243237        }
Note: See TracChangeset for help on using the changeset viewer.