Changeset 33146 in osm for applications/editors


Ignore:
Timestamp:
2017-02-15T11:42:23+01:00 (8 years ago)
Author:
bastik
Message:

[piclayer] make rotation mouse handling more natural (stick to mouse pointer)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/transform/RotatePictureAction.java

    r32675 r33146  
    2323import static org.openstreetmap.josm.tools.I18n.tr;
    2424
    25 import java.awt.event.InputEvent;
     25import java.awt.Point;
    2626import java.awt.event.MouseEvent;
     27import java.awt.geom.Point2D;
    2728
    2829import org.openstreetmap.josm.Main;
     
    4748    @Override
    4849    protected void doAction(MouseEvent e) {
    49         double factor;
    50         if ((e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0) {
    51             factor = Main.pref.getDouble("piclayer.rotatefactors.high_precision", 100.0);
    52         } else {
    53             factor = Main.pref.getDouble("piclayer.rotatefactors.low_precision", 10.0);
    54         }
    55         currentLayer.rotatePictureBy((e.getY() - prevMousePoint.getY()) / factor);
     50        Point2D center = new Point(Main.map.mapView.getWidth()/2, Main.map.mapView.getHeight()/2);
     51        double alpha1 = Math.atan2(e.getY() - center.getY(), e.getX() - center.getX());
     52        double alpha0 = Math.atan2(prevMousePoint.getY() - center.getY(), prevMousePoint.getX() - center.getX());
     53        currentLayer.rotatePictureBy(alpha1 - alpha0);
    5654    }
    5755}
Note: See TracChangeset for help on using the changeset viewer.