Changeset 3382 in josm


Ignore:
Timestamp:
2010-07-23T21:27:18+02:00 (14 years ago)
Author:
jttt
Message:

Fix #4928 Moving of objects adds offset to down and right

Location:
trunk/src/org/openstreetmap/josm/data/osm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r3378 r3382  
    2121
    2222import org.openstreetmap.josm.data.SelectionChangedListener;
     23import org.openstreetmap.josm.data.coor.EastNorth;
    2324import org.openstreetmap.josm.data.coor.LatLon;
    2425import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent;
     
    804805    }
    805806
    806     private void reindexNode(Node node, LatLon newCoor) {
     807    private void reindexNode(Node node, LatLon newCoor, EastNorth eastNorth) {
    807808        nodes.remove(node);
    808         node.setCoorInternal(newCoor);
     809        node.setCoorInternal(newCoor, eastNorth);
    809810        nodes.add(node);
    810811        for (OsmPrimitive primitive: node.getReferrers()) {
     
    932933    }
    933934
    934     void fireNodeMoved(Node node, LatLon newCoor) {
    935         reindexNode(node, newCoor);
     935    void fireNodeMoved(Node node, LatLon newCoor, EastNorth eastNorth) {
     936        reindexNode(node, newCoor, eastNorth);
    936937        fireEvent(new NodeMovedEvent(this, node));
    937938    }
  • trunk/src/org/openstreetmap/josm/data/osm/Node.java

    r3348 r3382  
    22package org.openstreetmap.josm.data.osm;
    33
    4 import org.openstreetmap.josm.Main;
    54import org.openstreetmap.josm.data.coor.CachedLatLon;
    65import org.openstreetmap.josm.data.coor.EastNorth;
     
    1918    public final void setCoor(LatLon coor) {
    2019        if(coor != null){
    21             if (getDataSet() != null) {
    22                 boolean locked = writeLock();
    23                 try {
    24                     getDataSet().fireNodeMoved(this, coor);
    25                 } finally {
    26                     writeUnlock(locked);
    27                 }
    28             } else {
    29                 setCoorInternal(coor);
    30             }
     20            updateCoor(coor, null);
     21        }
     22    }
     23
     24    public final void setEastNorth(EastNorth eastNorth) {
     25        if(eastNorth != null) {
     26            updateCoor(null, eastNorth);
     27        }
     28    }
     29
     30    private void updateCoor(LatLon coor, EastNorth eastNorth) {
     31        if (getDataSet() != null) {
     32            boolean locked = writeLock();
     33            try {
     34                getDataSet().fireNodeMoved(this, coor, eastNorth);
     35            } finally {
     36                writeUnlock(locked);
     37            }
     38        } else {
     39            setCoorInternal(coor, eastNorth);
    3140        }
    3241    }
     
    3645    }
    3746
    38     public final void setEastNorth(EastNorth eastNorth) {
    39         if(eastNorth != null) {
    40             setCoor(Main.proj.eastNorth2latlon(eastNorth));
    41         }
    42     }
    43 
    4447    public final EastNorth getEastNorth() {
    4548        return coor != null ? coor.getEastNorth() : null;
     
    4952     * To be used only by Dataset.reindexNode
    5053     */
    51     protected void setCoorInternal(LatLon coor) {
     54    protected void setCoorInternal(LatLon coor, EastNorth eastNorth) {
    5255        if(this.coor == null) {
    53             this.coor = new CachedLatLon(coor);
     56            if (eastNorth == null) {
     57                this.coor = new CachedLatLon(coor);
     58            } else {
     59                this.coor = new CachedLatLon(eastNorth);
     60            }
    5461        } else {
    55             this.coor.setCoor(coor);
     62            if (eastNorth == null) {
     63                this.coor.setCoor(coor);
     64            } else {
     65                this.coor.setEastNorth(eastNorth);
     66            }
    5667        }
    5768    }
Note: See TracChangeset for help on using the changeset viewer.