Index: /applications/editors/josm/plugins/piclayer/build.xml
===================================================================
--- /applications/editors/josm/plugins/piclayer/build.xml	(revision 25218)
+++ /applications/editors/josm/plugins/piclayer/build.xml	(revision 25219)
@@ -23,5 +23,5 @@
 <project name="PicLayer" default="dist" basedir=".">
 
-	<property name="commit.message" value="Changed the constructor signature of the plugin main class" />
+	<property name="commit.message" value="applied #J5852 (patch by Petschge) - new shear option" />
 	<property name="plugin.main.version" value="3835" />
 
@@ -86,4 +86,5 @@
 				<attribute name="Plugin-Description" value="This plugin allows to display any picture as a background in the editor and align it with the map."/>
 				<attribute name="Plugin-Icon" value="images/layericon.png"/>
+                <attribute name="Plugin-Link" value="http://wiki.openstreetmap.org/wiki/JOSM/Plugins/PicLayer"/>
 				<attribute name="Plugin-Mainversion" value="${plugin.main.version}"/>
 				<attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
Index: /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/MovePictureAction.java
===================================================================
--- /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/MovePictureAction.java	(revision 25218)
+++ /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/MovePictureAction.java	(revision 25219)
@@ -33,5 +33,5 @@
 import org.openstreetmap.josm.data.coor.EastNorth;
 
-//TODO: Move/Rotate/Scale action classes are similar. Do the redesign!
+//TODO: Move/Rotate/Scale/Shear action classes are similar. Do the redesign!
 
 /**
Index: /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerAbstract.java
===================================================================
--- /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerAbstract.java	(revision 25218)
+++ /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerAbstract.java	(revision 25219)
@@ -74,4 +74,7 @@
     private double m_scalex = 1.0;
     private double m_scaley = 1.0;
+    // Shear of the image
+    private double m_shearx = 0.0;
+    private double m_sheary = 0.0;
     // The scale that was set on the map during image creation
     private double m_initial_scale = 1.0;
@@ -88,4 +91,6 @@
     private final String SCALEX = "SCALEX";
     private final String SCALEY = "SCALEY";
+    private final String SHEARX = "SHEARX";
+    private final String SHEARY = "SHEARY";
 
     /**
@@ -215,4 +220,6 @@
             double scaley = m_scaley * m_initial_scale / Main.map.mapView.getDist100Pixel();
             g.scale( scalex, scaley );
+            // Shear
+            g.shear(m_shearx, m_sheary);
 
             // Draw picture
@@ -258,4 +265,13 @@
 
     /**
+     * Shear the picture. shearx and sheary will separately add to the
+     * corresponding current value
+     */
+    public void shearPictureBy( double shearx, double sheary ) {
+        m_shearx += shearx;
+        m_sheary += sheary;
+    }
+
+    /**
      * Sets the image position to the initial position
      */
@@ -279,4 +295,12 @@
     }
 
+
+    /**
+     * Sets the image to no shear
+     */
+    public void resetShear() {
+        m_shearx = 0.0;
+        m_sheary = 0.0;
+    }
     @Override
     /**
@@ -330,4 +354,6 @@
         props.put(SCALEY, "" + m_scaley);
         props.put(ANGLE, "" + m_angle);
+        props.put(SHEARX, "" + m_shearx);
+        props.put(SHEARY, "" + m_sheary);
     }
 
@@ -358,4 +384,6 @@
             double scale_x = Double.valueOf( props.getProperty(SCALEX));
             double scale_y = Double.valueOf( props.getProperty(SCALEY));
+            double shear_x = Double.valueOf( props.getProperty(SHEARX));
+            double shear_y = Double.valueOf( props.getProperty(SHEARY));
             m_position.setLocation(pos_x, pos_y);
             m_initial_position.setLocation(pos_x, pos_y);
@@ -363,4 +391,6 @@
             m_scalex = scale_x;
             m_scaley = scale_y;
+            m_shearx = shear_x;
+            m_sheary = shear_y;
             m_initial_scale = in_scale;
             // Refresh
@@ -384,4 +414,5 @@
             reset_submenu.add( new ResetPictureAngleAction( PicLayerAbstract.this ) );
             reset_submenu.add( new ResetPictureScaleAction( PicLayerAbstract.this ) );
+            reset_submenu.add( new ResetPictureShearAction( PicLayerAbstract.this ) );
             return reset_submenu;
         }
Index: /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerPlugin.java
===================================================================
--- /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerPlugin.java	(revision 25218)
+++ /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerPlugin.java	(revision 25219)
@@ -50,4 +50,5 @@
     private IconToggleButton m_scaleyPictureButton = null;
     private IconToggleButton m_scalexyPictureButton = null;
+    private IconToggleButton m_shearPictureButton = null;
 
     // Menu actions
@@ -89,4 +90,5 @@
             ScaleXPictureAction scaleXPictureAction = new ScaleXPictureAction(newFrame);
             ScaleYPictureAction scaleYPictureAction = new ScaleYPictureAction(newFrame);
+            ShearPictureAction shearPictureAction = new ShearPictureAction(newFrame);
             // Create plugin buttons and add them to the toolbar
             m_movePictureButton = new IconToggleButton(movePictureAction);
@@ -95,4 +97,5 @@
             m_scalexPictureButton = new IconToggleButton(scaleXPictureAction);
             m_scaleyPictureButton = new IconToggleButton(scaleYPictureAction);
+            m_shearPictureButton = new IconToggleButton(shearPictureAction);
             newFrame.addMapMode(m_movePictureButton);
             newFrame.addMapMode(m_rotatePictureButton);
@@ -100,4 +103,5 @@
             newFrame.addMapMode(m_scalexPictureButton);
             newFrame.addMapMode(m_scaleyPictureButton);
+            newFrame.addMapMode(m_shearPictureButton);
 //            newFrame.toolGroup.add(m_movePictureButton);
 //            newFrame.toolGroup.add(m_rotatePictureButton);
@@ -109,4 +113,5 @@
             m_scalexPictureButton.setVisible(true);
             m_scaleyPictureButton.setVisible(true);
+            m_shearPictureButton.setVisible(true);
         }
     }
Index: /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ResetPictureAllAction.java
===================================================================
--- /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ResetPictureAllAction.java	(revision 25218)
+++ /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ResetPictureAllAction.java	(revision 25219)
@@ -55,4 +55,5 @@
         m_owner.resetPosition();
         m_owner.resetScale();
+        m_owner.resetShear();
         // Redraw
         Main.map.mapView.repaint();
Index: /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ResetPictureShearAction.java
===================================================================
--- /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ResetPictureShearAction.java	(revision 25219)
+++ /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ResetPictureShearAction.java	(revision 25219)
@@ -0,0 +1,59 @@
+/***************************************************************************
+ *   Copyright (C) 2011 by Patrick "Petschge" Kilian, based on code        *
+ *   Copyright (C) 2009 by Tomasz Stelmach                                 *
+ *   http://www.stelmach-online.net/                                       *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+package org.openstreetmap.josm.plugins.piclayer;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.event.ActionEvent;
+
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.JosmAction;
+
+/**
+ * Action for resetting properties of an image.
+ * 
+ * TODO Four almost identical classes. Refactoring needed.
+ */
+public class ResetPictureShearAction extends JosmAction {
+
+    // Owner layer of the action
+    PicLayerAbstract m_owner = null;
+    
+    /**
+     * Constructor
+     */
+    public ResetPictureShearAction( PicLayerAbstract owner ) {
+        super(tr("Shear"), null, tr("Resets picture shear"), null, false);
+        // Remember the owner...
+        m_owner = owner;
+    }
+    
+    /**
+     * Action handler
+     */
+    public void actionPerformed(ActionEvent arg0) {
+        // Reset
+        m_owner.resetShear();
+        // Redraw
+        Main.map.mapView.repaint();
+    }
+}
Index: /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/RotatePictureAction.java
===================================================================
--- /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/RotatePictureAction.java	(revision 25218)
+++ /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/RotatePictureAction.java	(revision 25219)
@@ -32,5 +32,5 @@
 import org.openstreetmap.josm.tools.ImageProvider;
 
-//TODO: Move/Rotate/Scale action classes are similar. Do the redesign!
+//TODO: Move/Rotate/Scale/Shear action classes are similar. Do the redesign!
 
 /**
Index: /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ScaleXPictureAction.java
===================================================================
--- /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ScaleXPictureAction.java	(revision 25218)
+++ /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ScaleXPictureAction.java	(revision 25219)
@@ -28,5 +28,5 @@
 import org.openstreetmap.josm.tools.ImageProvider;
 
-// TODO: Move/Rotate/Scale action classes are similar. Do the redesign!
+// TODO: Move/Rotate/Scale/Shear action classes are similar. Do the redesign!
 
 /**
Index: /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ScaleXYPictureAction.java
===================================================================
--- /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ScaleXYPictureAction.java	(revision 25218)
+++ /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ScaleXYPictureAction.java	(revision 25219)
@@ -28,5 +28,5 @@
 import org.openstreetmap.josm.tools.ImageProvider;
 
-// TODO: Move/Rotate/Scale action classes are similar. Do the redesign!
+// TODO: Move/Rotate/Scale/Shear action classes are similar. Do the redesign!
 
 /**
Index: /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ScaleYPictureAction.java
===================================================================
--- /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ScaleYPictureAction.java	(revision 25218)
+++ /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ScaleYPictureAction.java	(revision 25219)
@@ -28,5 +28,5 @@
 import org.openstreetmap.josm.tools.ImageProvider;
 
-// TODO: Move/Rotate/Scale action classes are similar. Do the redesign!
+// TODO: Move/Rotate/Scale/Shear action classes are similar. Do the redesign!
 
 /**
Index: /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ShearPictureAction.java
===================================================================
--- /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ShearPictureAction.java	(revision 25219)
+++ /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ShearPictureAction.java	(revision 25219)
@@ -0,0 +1,108 @@
+/***************************************************************************
+ *                                                                         *
+ *   Copyright (C) 2011 Patrick "Petschge" Kilian, based on code           *
+ *   (c) 2009 by Tomasz Stelmach                                           *
+ *   http://www.stelmach-online.net/                                       *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+package org.openstreetmap.josm.plugins.piclayer;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.mapmode.MapMode;
+import org.openstreetmap.josm.gui.MapFrame;
+import org.openstreetmap.josm.tools.ImageProvider;
+import org.openstreetmap.josm.data.coor.EastNorth;
+
+//TODO: Move/Rotate/Scale/Shear action classes are similar. Do the redesign!
+
+/**
+ * This class handles the input during shearing of the picture.
+ */
+public class ShearPictureAction extends MapMode implements MouseListener, MouseMotionListener
+{
+    // Action ongoing?
+    private boolean mb_dragging = false;
+
+    // Last mouse position
+    private EastNorth m_prevEastNorth;
+
+    // The layer we're working on
+    private PicLayerAbstract m_currentLayer = null;
+
+    /**
+     * Constructor
+     */
+    public ShearPictureAction(MapFrame frame) {
+        super(tr("PicLayer shear"), "shear", tr("Drag to shear the picture"), frame, ImageProvider.getCursor("crosshair", null));
+    }
+
+    @Override
+    public void enterMode() {
+        super.enterMode();
+        Main.map.mapView.addMouseListener(this);
+        Main.map.mapView.addMouseMotionListener(this);
+    }
+
+    @Override
+    public void exitMode() {
+        super.exitMode();
+        Main.map.mapView.removeMouseListener(this);
+        Main.map.mapView.removeMouseMotionListener(this);
+    }
+
+    @Override
+    public void mousePressed(MouseEvent e) {
+
+        // If everything is OK, we start dragging/moving the picture
+        if ( Main.map.mapView.getActiveLayer() instanceof PicLayerAbstract ) {
+            m_currentLayer = (PicLayerAbstract)Main.map.mapView.getActiveLayer();
+
+            if ( m_currentLayer != null && e.getButton() == MouseEvent.BUTTON1 ) {
+                mb_dragging = true;
+                m_prevEastNorth=Main.map.mapView.getEastNorth(e.getX(),e.getY());
+            }
+        }
+    }
+
+    @Override
+    public void mouseDragged(MouseEvent e) {
+        // Picture moving is ongoing
+        if(mb_dragging) {
+            EastNorth eastNorth = Main.map.mapView.getEastNorth(e.getX(),e.getY());
+            m_currentLayer.shearPictureBy(
+                1000* (eastNorth.east()-m_prevEastNorth.east()),
+                1000* (eastNorth.north()-m_prevEastNorth.north())
+            );
+            m_prevEastNorth = eastNorth;
+            Main.map.mapView.repaint();
+        }
+    }
+
+    @Override
+    public void mouseReleased(MouseEvent e) {
+        // Stop moving
+        mb_dragging = false;
+    }
+
+}
