Index: /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/HelpAction.java
===================================================================
--- /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/HelpAction.java	(revision 14779)
+++ /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/HelpAction.java	(revision 14779)
@@ -0,0 +1,99 @@
+/***************************************************************************
+ *   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 java.awt.event.ActionEvent;
+
+import javax.swing.JFrame;
+import javax.swing.JScrollPane;
+import javax.swing.JTextPane;
+
+import org.openstreetmap.josm.actions.JosmAction;
+
+/**
+ * Help class. Basically copied from WMSPlugin.
+ */
+public class HelpAction extends JosmAction {
+
+	/**
+	 * Constructor
+	 */
+	public HelpAction() {
+		super( "Help", null, null, null, false);
+
+	}
+
+	/**
+	 * Shows help window.
+	 */
+	public void actionPerformed(ActionEvent e) {
+          String helptext = 
+            "This plugin is meant for showing images as a background of the data being edited."
+            + "It offers two ways of loading the data - from a file and from the clipboard."
+            + "This is an early version and is not end-user-proof, so please follow the steps exactly in case you want to use it."
+            + "Actually... it's barely working at the moment but I already find it very useful :)."
+            + "\n\n"
+            + "NOTE: Make sure the image is suitable, copyright-wise, if in doubt, don't use."
+            + "\n"
+            + "Step 1) Load some data from the server so that map is visible."
+            + "\n"
+            + "Step 2) Go to PicLayer menu and either choose to add a layer from a file or from the clipboard."
+            + "\n"
+            + "Step 2a) If you chose a file, a file selector will pop-up. Choose the image you want. Of course the format you are using might not be supported yet :)"
+            + "\n"
+            + "Step 2b) If you chose a clipboard, please wait. For some reason it takes time. To be fixed later."
+            + "\n"
+            + "NOTE) If something failed, you should get a message box. If not - check the console for messages (Linux only?)"
+            + "\n"
+            + "Step 3) Once the image is visible you may start positioning it. For that - select the PicLayer in the layers list."
+            + "\n"
+            + "Step 4) Start aligning the image."
+            + "\n"
+            + "Step 4a) Move the image by choosing 'Move' from the toolbar and draggin the mouse around with left button pressed."
+            + "\n"
+            + "Step 4b) Rotate the image by choosing 'Rotate' from the toolbar and draggin the mouse up/down with left button pressed."
+            + "\n"
+            + "Step 4c) Scale the image by choosing 'Scale' from the toolbar and draggin the mouse up/down with left button pressed."
+            + "\n"
+            + "NOTE) If it does not work - make sure the right layer is selected."
+            + "\n"
+            + "Step 5) If you need to reset your changes - you can use the popup menu available under the PicLayer entry in the layer list."
+            + "\n\n"
+            + "This plugin is meant to help with mapping from photos (for me it's mostly buildings) for people who simply don't like MetaCarta Rectifier (like me)."
+            + "\n\n"
+            + "Although I wrote it only to help myself and currently have no intention of extending it beyond what I need, you may still contact me with any suggestions that you think are important: tomasz.stelmach@poczta.onet.pl"
+            + "\n\n"
+            + "I used wmsplugin and routing plugin code very much during coding. Thank you and I hope you don't mind :)"
+       	  ;
+        
+		JTextPane tp = new JTextPane();
+		JScrollPane js = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+		          JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
+		           
+		js.getViewport().add(tp);
+		JFrame jf = new JFrame("PicLayer Help");
+		jf.getContentPane().add(js);
+		jf.pack();
+		jf.setSize(600,600);
+		jf.setVisible(true); 
+		tp.setText(helptext);
+    }
+}
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 14779)
+++ /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/MovePictureAction.java	(revision 14779)
@@ -0,0 +1,104 @@
+/***************************************************************************
+ *   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 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 action classes are similar. Do the redesign!
+
+/**
+ * This class handles the input during moving the picture.
+ */
+public class MovePictureAction 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 MovePictureAction(MapFrame frame) {
+		super("PicLayer", "move", "Drag to move 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.movePictureBy(
+            	eastNorth.east()-m_prevEastNorth.east(), 
+                eastNorth.north()-m_prevEastNorth.north()
+            );
+            m_prevEastNorth = eastNorth;
+            Main.map.mapView.repaint();
+        }
+    }    
+    
+    @Override 
+    public void mouseReleased(MouseEvent e) {
+    	// Stop moving
+    	mb_dragging = false;
+    }    
+
+}
Index: /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/NewLayerFromClipboardAction.java
===================================================================
--- /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/NewLayerFromClipboardAction.java	(revision 14779)
+++ /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/NewLayerFromClipboardAction.java	(revision 14779)
@@ -0,0 +1,62 @@
+/***************************************************************************
+ *   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 java.awt.event.ActionEvent;
+import java.io.IOException;
+import javax.swing.JOptionPane;
+
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.JosmAction;
+
+/**
+ * Action responsible for creation of a new layer based on
+ * the content of the clipboard.
+ */
+public class NewLayerFromClipboardAction extends JosmAction {
+	
+	/**
+	 * Constructor...
+	 */
+	public NewLayerFromClipboardAction() {
+		super("New picture layer from clipboard", null, null, null, false);
+	}
+
+	/**
+	 * Action handler
+	 */
+	public void actionPerformed(ActionEvent arg0) {
+		// Create layer from clipboard
+		PicLayerFromClipboard layer = new PicLayerFromClipboard();
+		// Add layer only if successfully initialized
+		try {
+			layer.Initialize();
+		}
+		catch (IOException e) {
+			// Failed
+			System.out.println( "NewLayerFromClipboardAction::actionPerformed - " + e.getMessage() );
+			JOptionPane.showMessageDialog(null, e.getMessage() );  
+			return;
+		}
+		// Add layer
+		Main.main.addLayer( layer );
+	}
+}
Index: /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/NewLayerFromFileAction.java
===================================================================
--- /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/NewLayerFromFileAction.java	(revision 14779)
+++ /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/NewLayerFromFileAction.java	(revision 14779)
@@ -0,0 +1,104 @@
+/***************************************************************************
+ *   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 java.awt.event.ActionEvent;
+import java.io.File;
+import java.io.IOException;
+
+import javax.swing.JFileChooser;
+import javax.swing.JOptionPane;
+import javax.swing.filechooser.FileFilter;
+
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.JosmAction;
+
+/**
+ * Action responsible for creation of a new layer based on
+ * an image file.
+ */
+public class NewLayerFromFileAction extends JosmAction {
+	
+	/**
+	 * Provides filtering of only image files.
+	 */
+	private class ImageFileFilter extends FileFilter {
+
+		@Override
+		public boolean accept(File f) {
+		    
+		    String ext3 = ( f.getName().length() > 4 ) ?  f.getName().substring( f.getName().length() - 4 ).toLowerCase() : "";
+		    String ext4 = ( f.getName().length() > 5 ) ?  f.getName().substring( f.getName().length() - 5 ).toLowerCase() : "";
+
+		    // TODO: check what is supported by Java :)
+		    return ( f.isDirectory() 
+		    	||	ext3.equals( ".jpg" )
+		    	||	ext4.equals( ".jpeg" )
+		    	||	ext3.equals( ".png" )
+		    	);
+		}
+
+
+		@Override
+		public String getDescription() {
+			return "Image files";
+		}
+		
+	}
+	
+	/**
+	 * Constructor...
+	 */
+	public NewLayerFromFileAction() {
+		super("New picture layer from file...", null, null, null, false);
+	}
+
+	/**
+	 * Action handler
+	 */
+	public void actionPerformed(ActionEvent arg0) {
+		
+		// Choose a file
+		JFileChooser fc = new JFileChooser();
+		fc.setAcceptAllFileFilterUsed( false );
+		fc.setFileFilter( new ImageFileFilter() );
+		int result = fc.showOpenDialog( Main.parent );
+		
+		// Create a layer?
+		if ( result == JFileChooser.APPROVE_OPTION ) {
+			// Create layer from file
+			PicLayerFromFile layer = new PicLayerFromFile( fc.getSelectedFile() );
+			// Add layer only if successfully initialized
+			try {
+				layer.Initialize();
+			}
+			catch (IOException e) {
+				// Failed
+				System.out.println( "NewLayerFromFileAction::actionPerformed - " + e.getMessage() );
+				JOptionPane.showMessageDialog(null, e.getMessage() );  
+				return;
+			}
+			// Add layer
+			Main.main.addLayer( layer );
+		}
+		
+	}
+}
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 14779)
+++ /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerAbstract.java	(revision 14779)
@@ -0,0 +1,261 @@
+/***************************************************************************
+ *   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 java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.Toolkit;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JSeparator;
+
+import org.openstreetmap.josm.data.coor.EastNorth;
+import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.gui.MapView;
+import org.openstreetmap.josm.gui.layer.Layer;
+
+/**
+ * Base class for layers showing images. Actually it does all the showing. The
+ * subclasses are supposed only to create images in different ways (load from
+ * files, copy from clipboard, hack into a spy satellite and download them,
+ * anything...)
+ */
+public abstract class PicLayerAbstract extends Layer 
+{
+	// Counter - just for naming of layers
+	private static int m_counter = 0;
+	// This is the main image to be displayed
+	private BufferedImage m_image = null;
+	// Initial position of the image in the real world
+	private EastNorth m_initial_position;
+	// Position of the image in the real world
+	private EastNorth m_position;
+	// Angle of rotation of the image
+	private double m_angle = 0.0;
+	// Scale of the image
+	private double m_scale = 1.0;
+	// The scale that was set on the map during image creation
+	private double m_initial_scale = 0;
+	// Popup menu items
+	private Component m_popupmenu[] = null;
+	// Layer icon
+    private Icon m_layericon = null;
+	
+	/**
+	 * Constructor
+	 */
+    public PicLayerAbstract() {
+        super("PicLayer #" + m_counter);
+
+        //Increase number
+        m_counter++;
+        
+        // Create popup menu
+        // Reset submenu
+        JMenu reset_submenu = new JMenu( "Reset" );
+        reset_submenu.add( new ResetPictureAllAction( this ) );
+        reset_submenu.addSeparator();
+        reset_submenu.add( new ResetPicturePositionAction( this ) );
+        reset_submenu.add( new ResetPictureAngleAction( this ) );
+        reset_submenu.add( new ResetPictureScaleAction( this ) );
+        // Main menu
+        m_popupmenu = new Component[]{
+        		reset_submenu,
+        		new JSeparator(),
+        		new JMenuItem( new HelpAction() )
+        };
+        
+        // Load layer icon
+        m_layericon = new ImageIcon(Toolkit.getDefaultToolkit().createImage(PicLayerAbstract.class.getResource("/images/layericon.png")));
+    }		
+    
+    /**
+     * Initializes the image. Gets the image from a subclass and stores some
+     * initial parameters. Throws exception if something fails.
+     */
+    public void Initialize() throws IOException {
+    	
+    	// Create image
+    	Image image = createImage();
+    	if ( image == null ) {
+    		throw new IOException( "Image not created properly.");
+    	}
+    	// Convert to Buffered Image - not sure if this is the right way...
+    	m_image = new BufferedImage( image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB );
+    	Graphics g = m_image.getGraphics();
+    	g.drawImage( image, 0, 0, null );
+    	
+    	// If the map does not exist - we're screwed. We should not get into this situation in the first place!
+    	if ( Main.map != null && Main.map.mapView != null ) {
+    		// Geographical position of the image
+    		m_initial_position = m_position = Main.map.mapView.getCenter();
+    		// Initial scale at which the image was loaded
+    		m_initial_scale = Main.map.mapView.getScale(); 
+    	} else {
+    		throw new IOException( "Could not find the map object." );
+    	}
+    }
+    
+    /**
+     * To be overridden by subclasses. Provides an image from an external sources.
+     * Throws exception if something does not work.
+     * 
+     * TODO: Replace the IOException by our own exception.
+     */
+    protected abstract Image createImage() throws IOException;
+    
+    /**
+     * To be overridden by subclasses. Returns the user readable name of the layer.
+     */
+    protected abstract String getPicLayerName();
+	
+	@Override
+	public Icon getIcon() {
+		return m_layericon;
+	}
+
+	@Override
+	public Object getInfoComponent() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Component[] getMenuEntries() {
+		return m_popupmenu;
+	}
+
+	@Override
+	public String getToolTipText() {
+		return getPicLayerName();
+	}
+
+	@Override
+	public boolean isMergable(Layer arg0) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public void mergeFrom(Layer arg0) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void paint(Graphics arg0, MapView arg1) {
+		
+		if ( m_image != null && arg0 instanceof Graphics2D) {
+			
+			// Position image at the right graphical place
+			EastNorth center = Main.map.mapView.getCenter();
+			EastNorth leftop = Main.map.mapView.getEastNorth( 0, 0 );
+			double pixel_per_en = ( Main.map.mapView.getWidth() / 2.0 ) / ( center.east() - leftop.east() );
+
+			// 	This is now the offset in screen pixels
+			double pic_offset_x = (( m_position.east() - leftop.east() ) * pixel_per_en);
+			double pic_offset_y = (( leftop.north() - m_position.north() ) * pixel_per_en);
+		
+			// Let's use Graphics 2D
+			Graphics2D g = (Graphics2D)arg0.create();
+			// Move
+			g.translate( pic_offset_x, pic_offset_y );
+			// Rotate
+			g.rotate( m_angle * Math.PI / 180.0 );
+			// Scale
+		    double scale = m_scale * m_initial_scale / Main.map.mapView.getScale();
+		    g.scale( scale, scale );
+		    
+		    // Draw picture
+			g.drawImage( m_image, -m_image.getWidth() / 2, -m_image.getHeight() / 2, null );
+			
+			// Draw additional rectangle for the active pic layer
+			if ( Main.map.mapView.getActiveLayer() == this ) {
+				g.setColor( new Color( 0xFF0000 ) );
+				g.drawRect(
+					-m_image.getWidth() / 2,
+					-m_image.getHeight() / 2,
+					m_image.getWidth(),
+					m_image.getHeight()
+				);
+			}
+		} else {
+			// TODO: proper logging
+			System.out.println( "PicLayerAbstract::paint - general drawing error (m_image is null or Graphics not 2D" );
+		}
+	}
+	
+	/**
+	 * Moves the picture. Scaled in EastNorth...
+	 */
+	public void movePictureBy( double east, double north ) {
+		m_position = m_position.add( east, north );
+	}
+
+	/**
+	 * Scales the picture. Scaled in... don't know but works ok :)
+	 */
+	public void scalePictureBy( double scale ) {
+		m_scale += scale;
+	}	
+
+	/**
+	 * Rotates the picture. Scales in angles.
+	 */
+	public void rotatePictureBy( double angle ) {
+		m_angle += angle;
+	}	
+	
+	/**
+	 * Sets the image position to the initial position
+	 */
+	public void resetPosition() {
+		m_position = m_initial_position; 
+	}
+	
+	/**
+	 * Sets the image scale to 1.0
+	 */
+	public void resetScale() {
+		m_scale = 1.0; 
+	}
+
+	/**
+	 * Sets the image angle to 0.0
+	 */
+	public void resetAngle() {
+		m_angle = 0.0; 
+	}
+
+	@Override
+	public void visitBoundingBox(BoundingXYVisitor arg0) {
+		// TODO Auto-generated method stub
+
+	}
+}
Index: /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerFromClipboard.java
===================================================================
--- /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerFromClipboard.java	(revision 14779)
+++ /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerFromClipboard.java	(revision 14779)
@@ -0,0 +1,66 @@
+/***************************************************************************
+ *   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 java.awt.Image;
+import java.awt.Toolkit;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.io.IOException;
+
+/**
+ * Layer displaying a picture copied from the clipboard.
+ */
+public class PicLayerFromClipboard extends PicLayerAbstract {
+
+	@Override
+	protected Image createImage() throws IOException {
+		// Return item
+		Image image = null;
+		// Access the clipboard
+        Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
+        // Check result
+        if ( t == null ) {
+        	throw new IOException( "Nothing in clipboard" );
+        }
+        
+        // TODO: Why is it so slow?
+        // Try to make it an image data
+        try {
+            if (t.isDataFlavorSupported(DataFlavor.imageFlavor)) {
+                image = (Image)t.getTransferData(DataFlavor.imageFlavor);
+            } else {
+            	throw new IOException( "The clipboard data is not an image" );
+            }
+        } catch (UnsupportedFlavorException e) {
+        	throw new IOException( e.getMessage() );
+        } 
+        
+        return image;
+	}
+
+	@Override
+	protected String getPicLayerName() {
+		return super.name + " <Clipboard>";
+	}
+
+}
Index: /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerFromFile.java
===================================================================
--- /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerFromFile.java	(revision 14779)
+++ /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerFromFile.java	(revision 14779)
@@ -0,0 +1,57 @@
+/***************************************************************************
+ *   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 java.awt.Image;
+import java.io.File;
+import java.io.IOException;
+import javax.imageio.ImageIO;
+
+/**
+ * Layer displaying a picture loaded from a file.
+ */
+public class PicLayerFromFile extends PicLayerAbstract {
+	
+	// File to load from.
+	private File m_file;
+	// Tooltip text
+	private String m_tooltiptext;
+
+    public PicLayerFromFile( File file ) {
+    	// Remember the file
+    	m_file = file;
+    	// Generate tooltip text
+    	m_tooltiptext = super.name + " <" + m_file.getAbsolutePath() + ">";
+    }	
+    
+	@Override
+	protected Image createImage() throws IOException {
+        // Try to load file
+		Image image = null;
+		image = ImageIO.read( m_file );
+		return image;
+	}
+
+	@Override
+	protected String getPicLayerName() {
+		return m_tooltiptext;
+	}	
+}
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 14779)
+++ /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerPlugin.java	(revision 14779)
@@ -0,0 +1,129 @@
+/***************************************************************************
+ *   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 java.awt.event.KeyEvent;
+import javax.swing.JMenu;
+
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.plugins.Plugin;
+import org.openstreetmap.josm.gui.IconToggleButton;
+import org.openstreetmap.josm.gui.layer.Layer;
+import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;
+import org.openstreetmap.josm.gui.MapFrame;
+
+/**
+ * Main Plugin class.
+ */
+public class PicLayerPlugin extends Plugin implements LayerChangeListener {
+	
+	// Plugin menu
+	private JMenu m_menu = null;
+	
+	// Toolbar buttons
+	private IconToggleButton m_movePictureButton = null;
+	private IconToggleButton m_rotatePictureButton = null;
+	private IconToggleButton m_scalePictureButton = null;
+	
+	// Menu actions
+	private NewLayerFromFileAction 		m_newFromFileAction = null;  
+	private NewLayerFromClipboardAction m_newFromClipAction = null;
+
+	/**
+	 * Constructor...
+	 */
+	public PicLayerPlugin() {
+		
+		// Create menu entry
+		if ( Main.main.menu != null ) {
+			m_menu = Main.main.menu.addMenu( "PicLayer" , KeyEvent.VK_I, Main.main.menu.defaultMenuPos );
+		}
+		
+		// Add menu items
+		if ( m_menu != null ) {
+			m_menu.add( m_newFromFileAction = new NewLayerFromFileAction() );
+			m_menu.add( m_newFromClipAction = new NewLayerFromClipboardAction() );
+			m_menu.addSeparator();
+			m_menu.add( new HelpAction() );
+			m_newFromFileAction.setEnabled( false );
+			m_newFromClipAction.setEnabled( false );
+		}
+		
+		// Listen to layers
+		Layer.listeners.add( this );
+		
+	}
+	
+    /**
+     * Called when the map is created. Creates the toolbar buttons.
+     */
+    public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
+        if(newFrame != null) {
+        	// Create plugin map modes
+        	MovePictureAction movePictureAction = new MovePictureAction(newFrame);
+        	RotatePictureAction rotatePictureAction = new RotatePictureAction(newFrame);
+        	ScalePictureAction scalePictureAction = new ScalePictureAction(newFrame);
+        	// Create plugin buttons and add them to the toolbar
+        	m_movePictureButton = new IconToggleButton(movePictureAction);
+        	m_rotatePictureButton = new IconToggleButton(rotatePictureAction);
+        	m_scalePictureButton = new IconToggleButton(scalePictureAction);
+            newFrame.addMapMode(m_movePictureButton);
+            newFrame.addMapMode(m_rotatePictureButton);
+            newFrame.addMapMode(m_scalePictureButton);
+            newFrame.toolGroup.add(m_movePictureButton);
+            newFrame.toolGroup.add(m_rotatePictureButton);
+            newFrame.toolGroup.add(m_scalePictureButton);
+            // Hide them by default
+            m_movePictureButton.setVisible(true);
+            m_rotatePictureButton.setVisible(true);
+            m_scalePictureButton.setVisible(true);
+        }
+    }
+
+	/**
+	 * The toolbar buttons shall be active only when the PicLayer is active.
+	 */
+	public void activeLayerChange(Layer oldLayer, Layer newLayer) {
+		m_movePictureButton.setEnabled( newLayer instanceof PicLayerAbstract );		
+		m_rotatePictureButton.setEnabled( newLayer instanceof PicLayerAbstract );		
+		m_scalePictureButton.setEnabled( newLayer instanceof PicLayerAbstract );
+	}
+
+	/**
+	 * The menu is enabled once another layer is first created. This is needed
+	 * because the picture must be positioned based on the current mapview (so
+	 * one must exist first). User should not be able to load a picture too early.
+	 */
+	public void layerAdded(Layer arg0) {
+		m_newFromFileAction.setEnabled( true );
+		m_newFromClipAction.setEnabled( true );
+	}
+
+	/**
+	 * When all layers are gone - the menu is gone too.
+	 */
+	public void layerRemoved(Layer arg0) {
+		boolean enable = Main.map.mapView.getAllLayers().size() != 0;
+		m_newFromFileAction.setEnabled( enable );
+		m_newFromClipAction.setEnabled( enable );
+	}	
+	
+};
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 14779)
+++ /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ResetPictureAllAction.java	(revision 14779)
@@ -0,0 +1,57 @@
+/***************************************************************************
+ *   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 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 ResetPictureAllAction extends JosmAction {
+
+	// Owner layer of the action
+	PicLayerAbstract m_owner = null;
+	
+	/**
+	 * Constructor
+	 */
+	public ResetPictureAllAction( PicLayerAbstract owner ) {
+		super("All", null, null, null, false);
+		// Remember the owner...
+		m_owner = owner;
+	}
+	
+	/**
+	 * Action handler
+	 */
+	public void actionPerformed(ActionEvent arg0) {
+		// Reset
+		m_owner.resetAngle();
+		m_owner.resetPosition();
+		m_owner.resetScale();
+		// Redraw
+        Main.map.mapView.repaint();
+	}
+}
Index: /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ResetPictureAngleAction.java
===================================================================
--- /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ResetPictureAngleAction.java	(revision 14779)
+++ /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ResetPictureAngleAction.java	(revision 14779)
@@ -0,0 +1,55 @@
+/***************************************************************************
+ *   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 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 ResetPictureAngleAction extends JosmAction {
+
+	// Owner layer of the action
+	PicLayerAbstract m_owner = null;
+	
+	/**
+	 * Constructor
+	 */
+	public ResetPictureAngleAction( PicLayerAbstract owner ) {
+		super("Angle", null, null, null, false);
+		// Remember the owner...
+		m_owner = owner;
+	}
+	
+	/**
+	 * Action handler
+	 */
+	public void actionPerformed(ActionEvent arg0) {
+		// Reset
+		m_owner.resetAngle();
+		// Redraw
+        Main.map.mapView.repaint();
+	}
+}
Index: /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ResetPicturePositionAction.java
===================================================================
--- /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ResetPicturePositionAction.java	(revision 14779)
+++ /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ResetPicturePositionAction.java	(revision 14779)
@@ -0,0 +1,55 @@
+/***************************************************************************
+ *   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 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 ResetPicturePositionAction extends JosmAction {
+
+	// Owner layer of the action
+	PicLayerAbstract m_owner = null;
+	
+	/**
+	 * Constructor
+	 */
+	public ResetPicturePositionAction( PicLayerAbstract owner ) {
+		super("Position", null, null, null, false);
+		// Remember the owner...
+		m_owner = owner;
+	}
+	
+	/**
+	 * Action handler
+	 */
+	public void actionPerformed(ActionEvent arg0) {
+		// Reset
+		m_owner.resetPosition();
+		// Redraw
+        Main.map.mapView.repaint();
+	}
+}
Index: /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ResetPictureScaleAction.java
===================================================================
--- /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ResetPictureScaleAction.java	(revision 14779)
+++ /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ResetPictureScaleAction.java	(revision 14779)
@@ -0,0 +1,55 @@
+/***************************************************************************
+ *   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 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 ResetPictureScaleAction extends JosmAction {
+
+	// Owner layer of the action
+	PicLayerAbstract m_owner = null;
+	
+	/**
+	 * Constructor
+	 */
+	public ResetPictureScaleAction( PicLayerAbstract owner ) {
+		super("Scale", null, null, null, false);
+		// Remember the owner...
+		m_owner = owner;
+	}
+	
+	/**
+	 * Action handler
+	 */
+	public void actionPerformed(ActionEvent arg0) {
+		// Reset
+		m_owner.resetScale();
+		// 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 14779)
+++ /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/RotatePictureAction.java	(revision 14779)
@@ -0,0 +1,99 @@
+/***************************************************************************
+ *   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 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;
+
+//TODO: Move/Rotate/Scale action classes are similar. Do the redesign!
+
+/**
+ * This class handles the input during rotating the picture.
+ */
+public class RotatePictureAction extends MapMode implements MouseListener, MouseMotionListener 
+{
+	// Action ongoing?
+	private boolean mb_dragging = false;
+	
+	// Last mouse position
+	private int m_prevY;
+	
+	// Layer we're working on
+	private PicLayerAbstract m_currentLayer = null;
+	
+	/**
+	 * Constructor
+	 */
+	public RotatePictureAction(MapFrame frame) {
+		super("PicLayer", "rotate", "Drag to rotate the picture", frame, ImageProvider.getCursor("crosshair", null));
+		// TODO Auto-generated constructor stub
+	}
+
+    @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) {
+    	// Start rotating
+    	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_prevY=e.getY();
+	        }
+    	}
+    }   
+    
+    @Override 
+    public void mouseDragged(MouseEvent e) {
+    	// Rotate the picture
+        if(mb_dragging) {
+            // TODO: Magic number
+            m_currentLayer.rotatePictureBy( ( e.getY() - m_prevY ) / 10.0 );
+            m_prevY = e.getY();
+            Main.map.mapView.repaint();
+        }
+    }    
+    
+    @Override public void mouseReleased(MouseEvent e) {
+    	// End rotating
+    	mb_dragging = false;
+    }    
+
+}
Index: /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ScalePictureAction.java
===================================================================
--- /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ScalePictureAction.java	(revision 14779)
+++ /applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ScalePictureAction.java	(revision 14779)
@@ -0,0 +1,99 @@
+/***************************************************************************
+ *   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 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;
+
+// TODO: Move/Rotate/Scale action classes are similar. Do the redesign!
+
+/**
+ * This class handles the input during scaling the picture.
+ */
+public class ScalePictureAction extends MapMode implements MouseListener, MouseMotionListener 
+{
+	// Scaling ongoing?
+	private boolean mb_dragging = false;
+	
+	// Last mouse position
+	private int m_prevY;
+	
+	// Layer we're working on
+	private PicLayerAbstract m_currentLayer = null;
+	
+	/**
+	 * Constructor
+	 */
+	public ScalePictureAction(MapFrame frame) {
+		super("PicLayer", "scale", "Drag to scale the picture", frame, ImageProvider.getCursor("crosshair", null));
+		// TODO Auto-generated constructor stub
+	}
+
+    @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) {
+    	// Start scaling
+    	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_prevY = e.getY();
+	        }
+    	}
+    }   
+    
+    @Override 
+    public void mouseDragged(MouseEvent e) {
+    	// Scale the picture
+        if(mb_dragging) {
+            m_currentLayer.scalePictureBy( ( e.getY() - m_prevY ) / 500.0 );
+            m_prevY = e.getY();
+            Main.map.mapView.repaint();
+        }
+    }    
+    
+    @Override 
+    public void mouseReleased(MouseEvent e) {
+    	// Stop scaling
+    	mb_dragging = false;
+    }    
+
+}
