Changeset 811 in josm for trunk/src


Ignore:
Timestamp:
2008-08-20T19:22:55+02:00 (16 years ago)
Author:
david
Message:

paste/duplicate at mouse position: patch on behalf of Petr Dlouhý, petr.dlouhyat at email dot cz

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

Legend:

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

    r627 r811  
    1212import java.util.LinkedList;
    1313import java.util.List;
     14
     15import java.awt.event.MouseMotionListener;
     16import javax.swing.JOptionPane;
    1417
    1518import org.openstreetmap.josm.Main;
     
    3841
    3942                /* Find the middle of the pasteBuffer area */
    40                 EastNorth centre = Main.map.mapView.getCenter();
    4143                double maxEast = -1E100, minEast = 1E100, maxNorth = -1E100, minNorth = 1E100;
    4244                for (Node n : pasteBuffer.nodes) {
     
    4850                        if (north < minNorth) { minNorth = north; }
    4951                }
    50                 double offsetEast = centre.east() - (maxEast + minEast)/2.0;
    51                 double offsetNorth = centre.north() - (maxNorth + minNorth)/2.0;
     52
     53                EastNorth mPosition;
     54                if((e.getModifiers() & ActionEvent.CTRL_MASK) ==0){
     55                        mPosition = Main.map.mapView.getCenter();
     56                } else {
     57                        mPosition = Main.map.mapView.getEastNorth(Main.map.mapView.lastMEvent.getX(), Main.map.mapView.lastMEvent.getY());
     58                };
     59
     60                double offsetEast  = mPosition.east() - (maxEast + minEast)/2.0;
     61                double offsetNorth = mPosition.north() - (maxNorth + minNorth)/2.0;
    5262               
    5363                HashMap<OsmPrimitive,OsmPrimitive> map = new HashMap<OsmPrimitive,OsmPrimitive>();
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r805 r811  
    1010import java.awt.Point;
    1111import java.awt.Transparency;
     12import java.awt.event.MouseEvent;
     13import java.awt.event.MouseMotionListener;
    1214import java.awt.event.ComponentAdapter;
    1315import java.awt.event.ComponentEvent;
     
    8486        private Layer activeLayer;
    8587       
     88        /**
     89         * The last event performed by mouse.
     90         */
     91        public MouseEvent lastMEvent;
     92
    8693        private LinkedList<MapViewPaintable> temporaryLayers = new LinkedList<MapViewPaintable>();
    8794       
     
    127134                        public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
    128135                                repaint();
     136                        }
     137                });
     138
     139                //store the last mouse action
     140                this.addMouseMotionListener(new MouseMotionListener() {
     141                        public void mouseDragged(MouseEvent e) {
     142                                mouseMoved(e);
     143                        }
     144                        public void mouseMoved(MouseEvent e) {
     145                                lastMEvent = e;
    129146                        }
    130147                });
Note: See TracChangeset for help on using the changeset viewer.