Index: applications/editors/josm/plugins/ImportImagePlugin/build.xml
===================================================================
--- applications/editors/josm/plugins/ImportImagePlugin/build.xml	(revision 23184)
+++ applications/editors/josm/plugins/ImportImagePlugin/build.xml	(revision 23187)
@@ -121,6 +121,5 @@
                 <attribute name="Plugin-Date" value="${version.entry.commit.date}"/>
                 <attribute name="Plugin-Description" value="Plugin for importing spatial referenced images"/>
-                <attribute name="Plugin-Link" value=" -- will soon be added -- "/>
-                <attribute name="Plugin-Mainversion" value="1.0"/>
+                <attribute name="Plugin-Mainversion" value="3376"/>
                 <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
 				<attribute name="Class-Path" value="."/>
Index: applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/ImageImportPlugin.java
===================================================================
--- applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/ImageImportPlugin.java	(revision 23184)
+++ applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/ImageImportPlugin.java	(revision 23187)
@@ -31,261 +31,261 @@
  */
 public class ImageImportPlugin extends Plugin{
-	
-	private static Logger logger;
-	
-	JMenu mainmenu = null;
-	JosmAction loadFileAction = null;
-	
-	// custom Classloader
-	static ClassLoader pluginClassLoader;
-	
-	// plugin proerties
-	static Properties pluginProps;
-	
-	// path constants
-	static final String PLUGIN_DIR = Main.pref.getPluginsDirectory().getAbsolutePath() + "/ImageImportPlugin/";
-	static final String PLUGINPROPERTIES_PATH = Main.pref.getPluginsDirectory().getAbsolutePath() + "/ImageImportPlugin/pluginProperties.properties"; 
-	static final String PLUGINLIBRARIES_DIR = Main.pref.getPluginsDirectory().getAbsolutePath() + "/ImageImportPlugin/lib/"; 
-	static final String PLUGINPROPERTIES_FILENAME = "pluginProperties.properties";
-	static final String LOGGING_PROPERTIES_FILEPATH = Main.pref.getPluginsDirectory().getAbsolutePath() + "/ImageImportPlugin/log4j.properties/";
-	
-	
-	public Properties getPluginProps() {
-		return pluginProps;
-	}
-
-
-	/**
-	 * constructor
-	 * 
-	 * @param info
-	 */
-	public ImageImportPlugin(PluginInformation info){
-		super(info);
-		
-		try {
-			
-			// First create custom ClassLoader to load resources from the main JAR
-			pluginClassLoader = createPluginClassLoader();
-			
-			// Initialize logger
-			initializeLogger(pluginClassLoader);
-			
-			// Check whether plugin has already been installed. Otherwise install
-			checkInstallation();
-			
-			// If resources are available load properties from plugin directory
-			if(pluginProps == null || pluginProps.isEmpty())
-			{
-				pluginProps = new Properties();
-				pluginProps.load(new File(PLUGINPROPERTIES_PATH).toURI().toURL().openStream());
-				logger.debug("Plugin properties loaded");
-			}
-
-			/* Change class path:
-			 * Use java reflection methods to add URLs to the class-path.
-			 * Changes take effect when calling methods of other plugin classes
-			 * (new threads)
-			 * */
-			URLClassLoader sysLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
-			String[] libraryNames = pluginProps.getProperty("libraries").split(",");
-			Class<URLClassLoader> sysclass = URLClassLoader.class;
-			Method method = sysclass.getDeclaredMethod("addURL", new Class[]{URL.class});
-			method.setAccessible(true);
-			for (int i = 0; i < libraryNames.length; i++) {
-				File library = new File(PLUGINLIBRARIES_DIR + "/" + libraryNames[i]);
-				method.invoke(sysLoader, new Object[]{library.toURI().toURL()});
-			}
-	        
-	        
-			// load information about supported reference systems
-			PluginOperations.loadCRSData(pluginProps);
-			
-			// create new Action for menu entry
-			LoadImageAction loadFileAction = new LoadImageAction();
-			loadFileAction.setEnabled(true);
-			
-			// add menu entries
-			Main.main.menu.fileMenu.insert(loadFileAction, 8);
-			Main.main.menu.fileMenu.insertSeparator(9);
-			
-
-		} catch (Exception e) {
-			logger.fatal("Error while loading plugin", e);
-			try {
-				throw e;
-			} catch (Exception e1) {
-				e1.printStackTrace();
-			}
-		}
-
-		logger.info("Plugin successfully loaded.");
-		
-	}
-
-	
-	
-	/**
-	 * Checks whether plugin resources are available.
-	 * If not, start install procedure.
-	 * 
-	 * @throws IOException
-	 */
-	private void checkInstallation() throws IOException
-	{
-		
-		// check plugin resource state
-		boolean isInstalled = true;
-		if(!new File(PLUGINPROPERTIES_PATH).exists()
-				|| !new File(PLUGIN_DIR).exists()
-				|| !new File(PLUGINLIBRARIES_DIR).exists())
-			isInstalled = false;
-		
-		
-		// if properties file doesn't exist, install plugin
-		if(!isInstalled)
-		{
-			
-			/*----------- Begin installation ---------------*/
-			
-			// check if plugin directory exist
-			File pluginDir = new File(PLUGIN_DIR);
-			if(!pluginDir.exists()){
-				pluginDir.mkdir();
-			}
-			
-			// check if "lib" directory exist
-			File libDir = new File(PLUGINLIBRARIES_DIR);
-			if(!libDir.exists()){
-				libDir.mkdir();
-			}
-			
-			// create local properties file
-			if(pluginProps == null || pluginProps.isEmpty()){
-				
-				FileWriter fw = new FileWriter(new File(PLUGINPROPERTIES_PATH));
-				URL propertiesURL = pluginClassLoader.getResource("resources/" + PLUGINPROPERTIES_FILENAME);
-				pluginProps = new Properties();
-				pluginProps.load(propertiesURL.openStream());
-				pluginProps.store(fw, null);
-				fw.close();
-				logger.debug("Plugin properties loaded");
-			}
-			
-			if(!new File(LOGGING_PROPERTIES_FILEPATH).exists())
-			{
-				FileWriter fw = new FileWriter(new File(LOGGING_PROPERTIES_FILEPATH));
-				URL propertiesURL = pluginClassLoader.getResource("resources/log4j.properties");
-				Properties loggingProps = new Properties();
-				loggingProps.load(propertiesURL.openStream());
-				loggingProps.store(fw, null);
-				fw.close();
-				logger.debug("Logging properties created");
-			}
-
-			
-			// Copy all needed JAR files to $PLUGIN_DIR$/lib/  
-			String[] libStrings = pluginProps.getProperty("libraries").split(",");
-			
-			for (int i = 0; i < libStrings.length; i++) {
-				
-				URL url = pluginClassLoader.getResource("lib/" + libStrings[i]);
-				
-				FileOutputStream out = null;
-				
-				try{
-					out = new FileOutputStream(new File(libDir, libStrings[i]));
-				} catch (FileNotFoundException e) {
-					break;
-				}
-				
-				BufferedInputStream in = null;
-				try
-				{
-					in = new BufferedInputStream(url.openStream());
-
-					byte[] buffer = new byte[1024];
-					while (true)
-					{
-						int count = in.read(buffer);
-						if (count == -1)
-							break;
-						out.write(buffer, 0, count);
-					}
-				}
-				finally
-				{
-					if (in != null)
-						in.close();
-				}
-			}
-			logger.debug("Plugin successfully installed");
-		}
-	}
-
-
-	/**
-	 * Initialize logger using plugin classloader.
-	 * 
-	 * @param cl
-	 */
-	private void initializeLogger(ClassLoader cl) {
-
-		Properties props = new Properties();
-		try {
-			props.load(new File(LOGGING_PROPERTIES_FILEPATH).toURI().toURL().openStream());
-			
-			// Set file for logging here:
-			props.setProperty("log4j.appender.MyRoFiAppender.file",
-					(Main.pref.getPluginsDirectory().getAbsolutePath() + "/ImageImportPlugin/" + "log.log"));
-			
-			PropertyConfigurator.configure(props);
-
-			logger = Logger.getLogger(ImageImportPlugin.class);
-			
-			logger.info("Logger successfully initialized.");
-			
-			return;
-		
-		} catch (IOException e) {
-			System.out.println("Logging properties file not found. Using standard settings.");
-		}
-		
-		// if no log4j.properties file can be found, initialize manually:
-		
-		props.setProperty("log4j.rootLogger", "INFO, A");
-		props.setProperty("log4j.appender.A", "org.apache.log4j.FileAppender");
-
-		props.setProperty("log4j.appender.A.layout",
-				"org.apache.log4j.PatternLayout ");
-		props.setProperty("log4j.appender.A.layout.ConversionPattern",
-				"%d{ISO8601} %-5p [%t] %c: %m%n");
-
-		// Set file for logging here:
-		props.setProperty("log4j.appender.A.file",
-				(Main.pref.getPluginsDirectory().getAbsolutePath() + "/ImageImportPlugin/" + "log.log"));
-		
-		PropertyConfigurator.configure(props);
-		logger = Logger.getLogger(ImageImportPlugin.class);
-		logger.info("Logger successfully initialized with standard settings.");
-		
-	}
-	
-	/**
-	 * get a plugin-specific classloader.
-	 * 
-	 * @return
-	 * @throws MalformedURLException 
-	 */
-	private ClassLoader createPluginClassLoader() throws MalformedURLException 
-	{
-		ClassLoader loader = null;
-		loader = URLClassLoader.newInstance(
-			    new URL[] { new File(Main.pref.getPluginsDirectory().getAbsolutePath() + "/ImportImagePlugin.jar").toURI().toURL()},
-			    ImageImportPlugin.class.getClassLoader()
-				);
-		
-		return loader;
-	}
-	
+    
+    private static Logger logger;
+    
+    JMenu mainmenu = null;
+    JosmAction loadFileAction = null;
+    
+    // custom Classloader
+    static ClassLoader pluginClassLoader;
+    
+    // plugin proerties
+    static Properties pluginProps;
+    
+    // path constants
+    static final String PLUGIN_DIR = Main.pref.getPluginsDirectory().getAbsolutePath() + "/ImageImportPlugin/";
+    static final String PLUGINPROPERTIES_PATH = Main.pref.getPluginsDirectory().getAbsolutePath() + "/ImageImportPlugin/pluginProperties.properties"; 
+    static final String PLUGINLIBRARIES_DIR = Main.pref.getPluginsDirectory().getAbsolutePath() + "/ImageImportPlugin/lib/"; 
+    static final String PLUGINPROPERTIES_FILENAME = "pluginProperties.properties";
+    static final String LOGGING_PROPERTIES_FILEPATH = Main.pref.getPluginsDirectory().getAbsolutePath() + "/ImageImportPlugin/log4j.properties/";
+    
+    
+    public Properties getPluginProps() {
+        return pluginProps;
+    }
+
+
+    /**
+     * constructor
+     * 
+     * @param info
+     */
+    public ImageImportPlugin(PluginInformation info){
+        super(info);
+        
+        try {
+            
+            // First create custom ClassLoader to load resources from the main JAR
+            pluginClassLoader = createPluginClassLoader();
+            
+            // Initialize logger
+            initializeLogger(pluginClassLoader);
+            
+            // Check whether plugin has already been installed. Otherwise install
+            checkInstallation();
+            
+            // If resources are available load properties from plugin directory
+            if(pluginProps == null || pluginProps.isEmpty())
+            {
+                pluginProps = new Properties();
+                pluginProps.load(new File(PLUGINPROPERTIES_PATH).toURI().toURL().openStream());
+                logger.debug("Plugin properties loaded");
+            }
+
+            /* Change class path:
+             * Use java reflection methods to add URLs to the class-path.
+             * Changes take effect when calling methods of other plugin classes
+             * (new threads)
+             * */
+            URLClassLoader sysLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
+            String[] libraryNames = pluginProps.getProperty("libraries").split(",");
+            Class<URLClassLoader> sysclass = URLClassLoader.class;
+            Method method = sysclass.getDeclaredMethod("addURL", new Class[]{URL.class});
+            method.setAccessible(true);
+            for (int i = 0; i < libraryNames.length; i++) {
+                File library = new File(PLUGINLIBRARIES_DIR + "/" + libraryNames[i]);
+                method.invoke(sysLoader, new Object[]{library.toURI().toURL()});
+            }
+            
+            
+            // load information about supported reference systems
+            PluginOperations.loadCRSData(pluginProps);
+            
+            // create new Action for menu entry
+            LoadImageAction loadFileAction = new LoadImageAction();
+            loadFileAction.setEnabled(true);
+            
+            // add menu entries
+            Main.main.menu.fileMenu.insert(loadFileAction, 8);
+            Main.main.menu.fileMenu.insertSeparator(9);
+            
+
+        } catch (Exception e) {
+            logger.fatal("Error while loading plugin", e);
+            try {
+                throw e;
+            } catch (Exception e1) {
+                e1.printStackTrace();
+            }
+        }
+
+        logger.info("Plugin successfully loaded.");
+        
+    }
+
+    
+    
+    /**
+     * Checks whether plugin resources are available.
+     * If not, start install procedure.
+     * 
+     * @throws IOException
+     */
+    private void checkInstallation() throws IOException
+    {
+        
+        // check plugin resource state
+        boolean isInstalled = true;
+        if(!new File(PLUGINPROPERTIES_PATH).exists()
+                || !new File(PLUGIN_DIR).exists()
+                || !new File(PLUGINLIBRARIES_DIR).exists())
+            isInstalled = false;
+        
+        
+        // if properties file doesn't exist, install plugin
+        if(!isInstalled)
+        {
+            
+            /*----------- Begin installation ---------------*/
+            
+            // check if plugin directory exist
+            File pluginDir = new File(PLUGIN_DIR);
+            if(!pluginDir.exists()){
+                pluginDir.mkdir();
+            }
+            
+            // check if "lib" directory exist
+            File libDir = new File(PLUGINLIBRARIES_DIR);
+            if(!libDir.exists()){
+                libDir.mkdir();
+            }
+            
+            // create local properties file
+            if(pluginProps == null || pluginProps.isEmpty()){
+                
+                FileWriter fw = new FileWriter(new File(PLUGINPROPERTIES_PATH));
+                URL propertiesURL = pluginClassLoader.getResource("resources/" + PLUGINPROPERTIES_FILENAME);
+                pluginProps = new Properties();
+                pluginProps.load(propertiesURL.openStream());
+                pluginProps.store(fw, null);
+                fw.close();
+                logger.debug("Plugin properties loaded");
+            }
+            
+            if(!new File(LOGGING_PROPERTIES_FILEPATH).exists())
+            {
+                FileWriter fw = new FileWriter(new File(LOGGING_PROPERTIES_FILEPATH));
+                URL propertiesURL = pluginClassLoader.getResource("resources/log4j.properties");
+                Properties loggingProps = new Properties();
+                loggingProps.load(propertiesURL.openStream());
+                loggingProps.store(fw, null);
+                fw.close();
+                logger.debug("Logging properties created");
+            }
+
+            
+            // Copy all needed JAR files to $PLUGIN_DIR$/lib/  
+            String[] libStrings = pluginProps.getProperty("libraries").split(",");
+            
+            for (int i = 0; i < libStrings.length; i++) {
+                
+                URL url = pluginClassLoader.getResource("lib/" + libStrings[i]);
+                
+                FileOutputStream out = null;
+                
+                try{
+                    out = new FileOutputStream(new File(libDir, libStrings[i]));
+                } catch (FileNotFoundException e) {
+                    break;
+                }
+                
+                BufferedInputStream in = null;
+                try
+                {
+                    in = new BufferedInputStream(url.openStream());
+
+                    byte[] buffer = new byte[1024];
+                    while (true)
+                    {
+                        int count = in.read(buffer);
+                        if (count == -1)
+                            break;
+                        out.write(buffer, 0, count);
+                    }
+                }
+                finally
+                {
+                    if (in != null)
+                        in.close();
+                }
+            }
+            logger.debug("Plugin successfully installed");
+        }
+    }
+
+
+    /**
+     * Initialize logger using plugin classloader.
+     * 
+     * @param cl
+     */
+    private void initializeLogger(ClassLoader cl) {
+
+        Properties props = new Properties();
+        try {
+            props.load(new File(LOGGING_PROPERTIES_FILEPATH).toURI().toURL().openStream());
+            
+            // Set file for logging here:
+            props.setProperty("log4j.appender.MyRoFiAppender.file",
+                    (Main.pref.getPluginsDirectory().getAbsolutePath() + "/ImageImportPlugin/" + "log.log"));
+            
+            PropertyConfigurator.configure(props);
+
+            logger = Logger.getLogger(ImageImportPlugin.class);
+            
+            logger.info("Logger successfully initialized.");
+            
+            return;
+        
+        } catch (IOException e) {
+            System.out.println("Logging properties file not found. Using standard settings.");
+        }
+        
+        // if no log4j.properties file can be found, initialize manually:
+        
+        props.setProperty("log4j.rootLogger", "INFO, A");
+        props.setProperty("log4j.appender.A", "org.apache.log4j.FileAppender");
+
+        props.setProperty("log4j.appender.A.layout",
+                "org.apache.log4j.PatternLayout ");
+        props.setProperty("log4j.appender.A.layout.ConversionPattern",
+                "%d{ISO8601} %-5p [%t] %c: %m%n");
+
+        // Set file for logging here:
+        props.setProperty("log4j.appender.A.file",
+                (Main.pref.getPluginsDirectory().getAbsolutePath() + "/ImageImportPlugin/" + "log.log"));
+        
+        PropertyConfigurator.configure(props);
+        logger = Logger.getLogger(ImageImportPlugin.class);
+        logger.info("Logger successfully initialized with standard settings.");
+        
+    }
+    
+    /**
+     * get a plugin-specific classloader.
+     * 
+     * @return
+     * @throws MalformedURLException 
+     */
+    private ClassLoader createPluginClassLoader() throws MalformedURLException 
+    {
+        ClassLoader loader = null;
+        loader = URLClassLoader.newInstance(
+                new URL[] { new File(Main.pref.getPluginsDirectory().getAbsolutePath() + "/ImportImagePlugin.jar").toURI().toURL()},
+                ImageImportPlugin.class.getClassLoader()
+                );
+        
+        return loader;
+    }
+    
 }
Index: applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/ImageLayer.java
===================================================================
--- applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/ImageLayer.java	(revision 23184)
+++ applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/ImageLayer.java	(revision 23187)
@@ -12,4 +12,5 @@
 
 import javax.media.jai.PlanarImage;
+import javax.swing.Action;
 import javax.swing.AbstractAction;
 import javax.swing.Icon;
@@ -40,5 +41,5 @@
 
 /**
- * 	Layer which contains spatial referenced image data.
+ *  Layer which contains spatial referenced image data.
  * 
  * @author Christoph Beekmans, Fabian Kowitz, Anna Robaszkiewicz, Oliver Kuhn, Martin Ulitzny
@@ -47,297 +48,297 @@
 public class ImageLayer extends Layer {
 
-	private Logger logger = Logger.getLogger(ImageLayer.class);
-
-	private File imageFile;
-	
-	private BufferedImage image = null;
-
-	// coordinates of upper left corner
-	private EastNorth upperLeft;
-	// Angle of rotation of the image
-	private double angle = 0.0;
-
-	// current bbox
-	private Envelope2D bbox;
-	
-	// Layer icon
-	private Icon layericon = null;
-	
-	// reference system of the oringinal image
-	private CoordinateReferenceSystem sourceRefSys;
-
-
-
-	/**
-	 * Constructor
-	 * 
-	 * @param file
-	 * @throws IOException 
-	 */
-	public ImageLayer(File file) throws IOException {
-		super(file.getName());
-		
-		this.imageFile = file;
-		this.image = (BufferedImage) createImage();
-		layericon = new ImageIcon(ImageImportPlugin.pluginClassLoader.getResource("images/layericon.png"));
-		
-	}
-
-	/**
-	 * create spatial referenced image.
-	 * 
-	 * @return
-	 * @throws IOException
-	 */
-	private Image createImage() throws IOException {
-
-		// geotools type for images and value coverages
-		GridCoverage2D coverage = null;
-		try {
-			// create a grid coverage from the image
-			coverage = PluginOperations.createGridFromFile(imageFile, null);
-			this.sourceRefSys = coverage.getCoordinateReferenceSystem();
-			
-			// now reproject grid coverage
-			coverage = PluginOperations.reprojectCoverage(coverage, CRS.decode(Main.proj.toCode()));
-		
-		} catch (FactoryException e) {
-			logger.error("Error while creating GridCoverage:",e);
-			throw new IOException(e.getMessage());
-		} catch (Exception e) {
-			if(e.getMessage().contains("No projection file found"))
-			{
-				int useDefaultCRS = JOptionPane.showConfirmDialog(Main.parent, "<html>No projection file (.prj) found.<br>Use the default Coordinate Reference System instead?</html>", "Missing projection", JOptionPane.YES_NO_OPTION);
-				if (useDefaultCRS == 0)
-				{
-					try {
-						// create a grid coverage from the image
-						coverage = PluginOperations.createGridFromFile(imageFile, PluginOperations.defaultSourceCRS);
-						this.sourceRefSys = coverage.getCoordinateReferenceSystem();
-						
-						// now reproject grid coverage
-						coverage = PluginOperations.reprojectCoverage(coverage, CRS.decode(Main.proj.toCode()));
-					} catch (Exception e1) {
-						logger.error("Error while creating GridCoverage:",e1);
-						throw new IOException(e1);
-					}
-				}
-				else{
-					logger.debug("Layer creation cancled by user due to missing projection information.");
-					throw new LayerCreationCancledException();
-				}
-
-			}
-			else
-			{
-				logger.error("Error while creating GridCoverage:",e);
-				throw new IOException(e);
-			}
-
-		}
-		logger.debug("Coverage created: " + coverage);
-
-		// TODO
-		upperLeft = new EastNorth(coverage.getEnvelope2D().y, coverage
-				.getEnvelope2D().x
-				+ coverage.getEnvelope2D().width);
-		angle = 0;
-		bbox = coverage.getEnvelope2D();
-
-		// Refresh
-		// Main.map.mapView.repaint();
-//		PlanarImage image = (PlanarImage) coverage.getRenderedImage();
-//		logger.info("Color Model: " + coverage.getRenderedImage().getColorModel());
-		ImageWorker worker = new ImageWorker(coverage.getRenderedImage());
-
-		return worker.getBufferedImage();
-	}
-
-	@Override
-	public void paint(Graphics2D g2, MapView mv, Bounds bounds) {
-
-		if (image != null && g2 != null) {
-
-			// Position image at the right graphical place
-			EastNorth center = Main.map.mapView.getCenter();
-			EastNorth leftop = Main.map.mapView.getEastNorth(0, 0);
-			double pixel_per_lon_degree = (Main.map.mapView.getWidth() / 2.0)
-					/ (center.east() - leftop.east());
-			double pixel_per_lat_degree = (Main.map.mapView.getHeight() / 2.0)
-					/ (leftop.north() - center.north());
-
-			// This is now the offset in screen pixels
-			double pic_offset_x = ((upperLeft.east() - leftop.east()) * pixel_per_lon_degree);
-			double pic_offset_y = ((leftop.north() - upperLeft.north()) * pixel_per_lat_degree);
-
-			Graphics2D g = (Graphics2D) g2.create();
-
-			// Move picture by offset from upper left corner
-			g.translate(pic_offset_x, pic_offset_y);
-
-			// Rotate image by angle
-			g.rotate(angle * Math.PI / 180.0);
-			
-			// Determine scale to fit JOSM extents
-			ProjectionBounds projbounds = Main.map.mapView
-					.getProjectionBounds();
-
-			double width = projbounds.max.getX() - projbounds.min.getX();
-			double height = projbounds.max.getY() - projbounds.min.getY();
-
-			double ratio_x = (this.bbox.getMaxY() - this.bbox.getMinY())
-					/ width;
-			double ratio_y = (this.bbox.getMaxX() - this.bbox.getMinX())
-					/ height;
-
-			double pixels4bbox_width = ratio_x * Main.map.mapView.getWidth();
-			double pixels4bbox_height = ratio_y * Main.map.mapView.getHeight();
-
-			// Scale image to JOSM extents
-			double scalex = pixels4bbox_width / image.getWidth();
-			double scaley = pixels4bbox_height / image.getHeight();
-
-			g.scale(scalex, scaley);
-
-			// Draw picture
-			g.drawImage(image, 0, 0, null);
-			
-		} else {
-			logger.error("Error while dawing image: image == null or Graphics == null");
-		}
-	}
-	
-	public Envelope2D getBbox() {
-		return bbox;
-	}
-
-	@Override
-	public Icon getIcon() {
-		// TODO Auto-generated method stub
-		return this.layericon;
-	}
-
-	@Override
-	public Object getInfoComponent() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public Component[] getMenuEntries() {
-        return new Component[]{
-                new JMenuItem(LayerListDialog.getInstance().createActivateLayerAction(this)),
-                new JMenuItem(LayerListDialog.getInstance().createShowHideLayerAction(this)),
-                new JMenuItem(LayerListDialog.getInstance().createDeleteLayerAction(this)),
-                new JSeparator(),
-                new JMenuItem(new RenameLayerAction(getAssociatedFile(), this)),
-                new JMenuItem(new LayerPropertiesAction(this)),
-                new JSeparator(),
-                new JMenuItem(new LayerListPopup.InfoAction(this))};
-	}
-
-	@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 visitBoundingBox(BoundingXYVisitor arg0) {
-		// TODO Auto-generated method stub
-	}
-	
-
-	@Override
-	public String getToolTipText() {
-		// TODO Auto-generated method stub
-		return this.getName();
-	}
-	
-
-	public File getImageFile() {
-		return imageFile;
-	}
-
-	public BufferedImage getImage() {
-		return image;
-	}
-	
-	/**
-	 * loads the image and reprojects it using a transformation
-	 * calculated by the new reference system.
-	 * 
-	 * @param newRefSys
-	 * @throws IOException 
-	 * @throws FactoryException 
-	 * @throws NoSuchAuthorityCodeException 
-	 */
-	void resample(CoordinateReferenceSystem refSys) throws IOException, NoSuchAuthorityCodeException, FactoryException
-	{
-		
-		GridCoverage2D coverage =  PluginOperations.createGridFromFile(this.imageFile, refSys);
-		coverage = PluginOperations.reprojectCoverage(coverage, CRS.decode(Main.proj.toCode()));
-		this.bbox = coverage.getEnvelope2D();
-		this.image = ((PlanarImage)coverage.getRenderedImage()).getAsBufferedImage();
-		
-		// TODO
-		upperLeft = new EastNorth(coverage.getEnvelope2D().y, coverage
-				.getEnvelope2D().x
-				+ coverage.getEnvelope2D().width);
-		angle = 0;
-
-		// repaint and zoom to new bbox
-		Main.map.mapView.repaint();
-		LatLon min = new LatLon(bbox.getMinX(), bbox.getMinY());
-		LatLon max = new LatLon(bbox.getMaxX(), bbox.getMaxY());
-		Main.map.mapView.zoomTo(new Bounds(min, max));
-		
-		
-	}
-	
-	/**
-	 * Action that creates a dialog GUI element with properties of a layer.
-	 * 
-	 */
-	public class LayerPropertiesAction extends AbstractAction
-	{
-		public ImageLayer imageLayer;
-		
-		public LayerPropertiesAction(ImageLayer imageLayer){
-			super(tr("Layer Properties"));
-			this.imageLayer = imageLayer;
-		}
-
-		public void actionPerformed(ActionEvent arg0) {
-			
-			LayerPropertiesDialog layerProps = new LayerPropertiesDialog(imageLayer, PluginOperations.crsDescriptions);
-			layerProps.setLocation(Main.parent.getWidth() / 4 , Main.parent.getHeight() / 4);
-			layerProps.setVisible(true);
-		}
-		
-	}
-	
-	/**
-	 * Exception which represents that the layer creation has been cancled by the
-	 * user.
-	 *
-	 */
-	class LayerCreationCancledException extends IOException{
-	}
-	
-	
-	
-	public CoordinateReferenceSystem getSourceRefSys() {
-		return sourceRefSys;
-	}
-
-	public void setSourceRefSys(CoordinateReferenceSystem sourceRefSys) {
-		this.sourceRefSys = sourceRefSys;
-	}
+    private Logger logger = Logger.getLogger(ImageLayer.class);
+
+    private File imageFile;
+    
+    private BufferedImage image = null;
+
+    // coordinates of upper left corner
+    private EastNorth upperLeft;
+    // Angle of rotation of the image
+    private double angle = 0.0;
+
+    // current bbox
+    private Envelope2D bbox;
+    
+    // Layer icon
+    private Icon layericon = null;
+    
+    // reference system of the oringinal image
+    private CoordinateReferenceSystem sourceRefSys;
+
+
+
+    /**
+     * Constructor
+     * 
+     * @param file
+     * @throws IOException 
+     */
+    public ImageLayer(File file) throws IOException {
+        super(file.getName());
+        
+        this.imageFile = file;
+        this.image = (BufferedImage) createImage();
+        layericon = new ImageIcon(ImageImportPlugin.pluginClassLoader.getResource("images/layericon.png"));
+        
+    }
+
+    /**
+     * create spatial referenced image.
+     * 
+     * @return
+     * @throws IOException
+     */
+    private Image createImage() throws IOException {
+
+        // geotools type for images and value coverages
+        GridCoverage2D coverage = null;
+        try {
+            // create a grid coverage from the image
+            coverage = PluginOperations.createGridFromFile(imageFile, null);
+            this.sourceRefSys = coverage.getCoordinateReferenceSystem();
+            
+            // now reproject grid coverage
+            coverage = PluginOperations.reprojectCoverage(coverage, CRS.decode(Main.proj.toCode()));
+        
+        } catch (FactoryException e) {
+            logger.error("Error while creating GridCoverage:",e);
+            throw new IOException(e.getMessage());
+        } catch (Exception e) {
+            if(e.getMessage().contains("No projection file found"))
+            {
+                int useDefaultCRS = JOptionPane.showConfirmDialog(Main.parent, "<html>No projection file (.prj) found.<br>Use the default Coordinate Reference System instead?</html>", "Missing projection", JOptionPane.YES_NO_OPTION);
+                if (useDefaultCRS == 0)
+                {
+                    try {
+                        // create a grid coverage from the image
+                        coverage = PluginOperations.createGridFromFile(imageFile, PluginOperations.defaultSourceCRS);
+                        this.sourceRefSys = coverage.getCoordinateReferenceSystem();
+                        
+                        // now reproject grid coverage
+                        coverage = PluginOperations.reprojectCoverage(coverage, CRS.decode(Main.proj.toCode()));
+                    } catch (Exception e1) {
+                        logger.error("Error while creating GridCoverage:",e1);
+                        throw new IOException(e1);
+                    }
+                }
+                else{
+                    logger.debug("Layer creation cancled by user due to missing projection information.");
+                    throw new LayerCreationCancledException();
+                }
+
+            }
+            else
+            {
+                logger.error("Error while creating GridCoverage:",e);
+                throw new IOException(e);
+            }
+
+        }
+        logger.debug("Coverage created: " + coverage);
+
+        // TODO
+        upperLeft = new EastNorth(coverage.getEnvelope2D().y, coverage
+                .getEnvelope2D().x
+                + coverage.getEnvelope2D().width);
+        angle = 0;
+        bbox = coverage.getEnvelope2D();
+
+        // Refresh
+        // Main.map.mapView.repaint();
+//      PlanarImage image = (PlanarImage) coverage.getRenderedImage();
+//      logger.info("Color Model: " + coverage.getRenderedImage().getColorModel());
+        ImageWorker worker = new ImageWorker(coverage.getRenderedImage());
+
+        return worker.getBufferedImage();
+    }
+
+    @Override
+    public void paint(Graphics2D g2, MapView mv, Bounds bounds) {
+
+        if (image != null && g2 != null) {
+
+            // Position image at the right graphical place
+            EastNorth center = Main.map.mapView.getCenter();
+            EastNorth leftop = Main.map.mapView.getEastNorth(0, 0);
+            double pixel_per_lon_degree = (Main.map.mapView.getWidth() / 2.0)
+                    / (center.east() - leftop.east());
+            double pixel_per_lat_degree = (Main.map.mapView.getHeight() / 2.0)
+                    / (leftop.north() - center.north());
+
+            // This is now the offset in screen pixels
+            double pic_offset_x = ((upperLeft.east() - leftop.east()) * pixel_per_lon_degree);
+            double pic_offset_y = ((leftop.north() - upperLeft.north()) * pixel_per_lat_degree);
+
+            Graphics2D g = (Graphics2D) g2.create();
+
+            // Move picture by offset from upper left corner
+            g.translate(pic_offset_x, pic_offset_y);
+
+            // Rotate image by angle
+            g.rotate(angle * Math.PI / 180.0);
+            
+            // Determine scale to fit JOSM extents
+            ProjectionBounds projbounds = Main.map.mapView
+                    .getProjectionBounds();
+
+            double width = projbounds.max.getX() - projbounds.min.getX();
+            double height = projbounds.max.getY() - projbounds.min.getY();
+
+            double ratio_x = (this.bbox.getMaxY() - this.bbox.getMinY())
+                    / width;
+            double ratio_y = (this.bbox.getMaxX() - this.bbox.getMinX())
+                    / height;
+
+            double pixels4bbox_width = ratio_x * Main.map.mapView.getWidth();
+            double pixels4bbox_height = ratio_y * Main.map.mapView.getHeight();
+
+            // Scale image to JOSM extents
+            double scalex = pixels4bbox_width / image.getWidth();
+            double scaley = pixels4bbox_height / image.getHeight();
+
+            g.scale(scalex, scaley);
+
+            // Draw picture
+            g.drawImage(image, 0, 0, null);
+            
+        } else {
+            logger.error("Error while dawing image: image == null or Graphics == null");
+        }
+    }
+    
+    public Envelope2D getBbox() {
+        return bbox;
+    }
+
+    @Override
+    public Icon getIcon() {
+        // TODO Auto-generated method stub
+        return this.layericon;
+    }
+
+    @Override
+    public Object getInfoComponent() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Action[] getMenuEntries() {
+        return new Action[]{
+                LayerListDialog.getInstance().createActivateLayerAction(this),
+                LayerListDialog.getInstance().createShowHideLayerAction(),
+                LayerListDialog.getInstance().createDeleteLayerAction(),
+                SeparatorLayerAction.INSTANCE,
+                new RenameLayerAction(getAssociatedFile(), this),
+                new LayerPropertiesAction(this),
+                SeparatorLayerAction.INSTANCE,
+                new LayerListPopup.InfoAction(this)};
+    }
+
+    @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 visitBoundingBox(BoundingXYVisitor arg0) {
+        // TODO Auto-generated method stub
+    }
+    
+
+    @Override
+    public String getToolTipText() {
+        // TODO Auto-generated method stub
+        return this.getName();
+    }
+    
+
+    public File getImageFile() {
+        return imageFile;
+    }
+
+    public BufferedImage getImage() {
+        return image;
+    }
+    
+    /**
+     * loads the image and reprojects it using a transformation
+     * calculated by the new reference system.
+     * 
+     * @param newRefSys
+     * @throws IOException 
+     * @throws FactoryException 
+     * @throws NoSuchAuthorityCodeException 
+     */
+    void resample(CoordinateReferenceSystem refSys) throws IOException, NoSuchAuthorityCodeException, FactoryException
+    {
+        
+        GridCoverage2D coverage =  PluginOperations.createGridFromFile(this.imageFile, refSys);
+        coverage = PluginOperations.reprojectCoverage(coverage, CRS.decode(Main.proj.toCode()));
+        this.bbox = coverage.getEnvelope2D();
+        this.image = ((PlanarImage)coverage.getRenderedImage()).getAsBufferedImage();
+        
+        // TODO
+        upperLeft = new EastNorth(coverage.getEnvelope2D().y, coverage
+                .getEnvelope2D().x
+                + coverage.getEnvelope2D().width);
+        angle = 0;
+
+        // repaint and zoom to new bbox
+        Main.map.mapView.repaint();
+        LatLon min = new LatLon(bbox.getMinX(), bbox.getMinY());
+        LatLon max = new LatLon(bbox.getMaxX(), bbox.getMaxY());
+        Main.map.mapView.zoomTo(new Bounds(min, max));
+        
+        
+    }
+    
+    /**
+     * Action that creates a dialog GUI element with properties of a layer.
+     * 
+     */
+    public class LayerPropertiesAction extends AbstractAction
+    {
+        public ImageLayer imageLayer;
+        
+        public LayerPropertiesAction(ImageLayer imageLayer){
+            super(tr("Layer Properties"));
+            this.imageLayer = imageLayer;
+        }
+
+        public void actionPerformed(ActionEvent arg0) {
+            
+            LayerPropertiesDialog layerProps = new LayerPropertiesDialog(imageLayer, PluginOperations.crsDescriptions);
+            layerProps.setLocation(Main.parent.getWidth() / 4 , Main.parent.getHeight() / 4);
+            layerProps.setVisible(true);
+        }
+        
+    }
+    
+    /**
+     * Exception which represents that the layer creation has been cancled by the
+     * user.
+     *
+     */
+    class LayerCreationCancledException extends IOException{
+    }
+    
+    
+    
+    public CoordinateReferenceSystem getSourceRefSys() {
+        return sourceRefSys;
+    }
+
+    public void setSourceRefSys(CoordinateReferenceSystem sourceRefSys) {
+        this.sourceRefSys = sourceRefSys;
+    }
 }
Index: applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/LayerPropertiesDialog.java
===================================================================
--- applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/LayerPropertiesDialog.java	(revision 23184)
+++ applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/LayerPropertiesDialog.java	(revision 23187)
@@ -42,544 +42,544 @@
  */
 public class LayerPropertiesDialog extends JFrame{
-	
-	private Vector<String> supportedCRS;
-	private ImageLayer imageLayer;
-
-	private JPanel mainPanel = null;
-	private JPanel jPanel = null;
-	private JPanel buttonPanel = null;
-	private JTabbedPane jTabbedPane = null;
-	private JPanel infoPanel = null;
-	private JPanel crsPanel = null;
-	private JButton okButton = null;
-	private JLabel layerNameLabel = null;
-	private JLabel layerNameValueLabel = null;
-	private JLabel imageFileLabel = null;
-	private JLabel imageFileValueLabel = null;
-	private JLabel sizeLabel = null;
-	private JLabel sizeValueLabel = null;
-	private JLabel crsLabel = null;
-	private JLabel crsValueLabel = null;
-	private JLabel extentLabel = null;
-	private JLabel defaultCRSDescriptorLabel = null;
-	private JLabel defaultCRSLabel = null;
-	private JTextField searchField = null;
-	private JScrollPane crsListScrollPane = null;
-	private JList crsJList = null;
-	private JButton useDefaultCRSButton = null;
-	private JButton applySelectedCRSButton = null;
-	private JButton setSelectedCRSAsDefaultButton = null;
-	private JLabel searchFieldLabel = null;
-	private JCheckBox eastingFirstCheckBox = null;
-	private JLabel eastingFirstLabel = null;
-	private JLabel tabDescriptionLabel = null;
-	private JLabel upperLeftLabel = null;
-	private JLabel lowerLeftLabel = null;
-	private JLabel upperRightLabel = null;
-	private JLabel lowerRightLabel = null;
-	private JLabel upperLeftValueLabel = null;
-	private JLabel upperRightValueLabel = null;
-	private JLabel lowerLeftValueLabel = null;
-	private JLabel lowerRightValueLabel = null;
-	private JLabel currentCRSLabel = null;
-	private JLabel currentCRSValueLabel = null;
-
-	/**
-	 * This method initializes 
-	 * 
-	 */
-	public LayerPropertiesDialog(ImageLayer imageLayer, Vector<String> supportedCRS) {
-		super(imageLayer.getName());
-		this.supportedCRS = supportedCRS;
-		this.imageLayer = imageLayer;
-		initialize();
-	}
-	
-	/**
-	 * This method initializes 
-	 * 
-	 */
-	public LayerPropertiesDialog(Vector<String> supportedCRS) {
-		super();
-		this.supportedCRS = supportedCRS;
-		initialize();
-	}
-	
-
-	/**
-	 * This method initializes this
-	 * 
-	 */
-	private void initialize() {
+    
+    private Vector<String> supportedCRS;
+    private ImageLayer imageLayer;
+
+    private JPanel mainPanel = null;
+    private JPanel jPanel = null;
+    private JPanel buttonPanel = null;
+    private JTabbedPane jTabbedPane = null;
+    private JPanel infoPanel = null;
+    private JPanel crsPanel = null;
+    private JButton okButton = null;
+    private JLabel layerNameLabel = null;
+    private JLabel layerNameValueLabel = null;
+    private JLabel imageFileLabel = null;
+    private JLabel imageFileValueLabel = null;
+    private JLabel sizeLabel = null;
+    private JLabel sizeValueLabel = null;
+    private JLabel crsLabel = null;
+    private JLabel crsValueLabel = null;
+    private JLabel extentLabel = null;
+    private JLabel defaultCRSDescriptorLabel = null;
+    private JLabel defaultCRSLabel = null;
+    private JTextField searchField = null;
+    private JScrollPane crsListScrollPane = null;
+    private JList crsJList = null;
+    private JButton useDefaultCRSButton = null;
+    private JButton applySelectedCRSButton = null;
+    private JButton setSelectedCRSAsDefaultButton = null;
+    private JLabel searchFieldLabel = null;
+    private JCheckBox eastingFirstCheckBox = null;
+    private JLabel eastingFirstLabel = null;
+    private JLabel tabDescriptionLabel = null;
+    private JLabel upperLeftLabel = null;
+    private JLabel lowerLeftLabel = null;
+    private JLabel upperRightLabel = null;
+    private JLabel lowerRightLabel = null;
+    private JLabel upperLeftValueLabel = null;
+    private JLabel upperRightValueLabel = null;
+    private JLabel lowerLeftValueLabel = null;
+    private JLabel lowerRightValueLabel = null;
+    private JLabel currentCRSLabel = null;
+    private JLabel currentCRSValueLabel = null;
+
+    /**
+     * This method initializes 
+     * 
+     */
+    public LayerPropertiesDialog(ImageLayer imageLayer, Vector<String> supportedCRS) {
+        super(imageLayer.getName());
+        this.supportedCRS = supportedCRS;
+        this.imageLayer = imageLayer;
+        initialize();
+    }
+    
+    /**
+     * This method initializes 
+     * 
+     */
+    public LayerPropertiesDialog(Vector<String> supportedCRS) {
+        super();
+        this.supportedCRS = supportedCRS;
+        initialize();
+    }
+    
+
+    /**
+     * This method initializes this
+     * 
+     */
+    private void initialize() {
         this.setMinimumSize(new Dimension(404, 485));
         this.setContentPane(getMainPanel());
         this.setPreferredSize(new Dimension(404, 485));
-			
-	}
-
-	/**
-	 * This method initializes mainPanel	
-	 * 	
-	 * @return javax.swing.JPanel	
-	 */
-	private JPanel getMainPanel() {
-		if (mainPanel == null) {
-			mainPanel = new JPanel();
-			mainPanel.setLayout(null);
-			mainPanel.add(getJPanel(), null);
-			mainPanel.add(getButtonPanel(), null);
-		}
-		return mainPanel;
-	}
-
-	/**
-	 * This method initializes jPanel	
-	 * 	
-	 * @return javax.swing.JPanel	
-	 */
-	private JPanel getJPanel() {
-		if (jPanel == null) {
-			GridBagConstraints gridBagConstraints = new GridBagConstraints();
-			gridBagConstraints.fill = GridBagConstraints.BOTH;
-			gridBagConstraints.gridy = 0;
-			gridBagConstraints.weightx = 1.0;
-			gridBagConstraints.weighty = 1.0;
-			gridBagConstraints.gridx = 0;
-			jPanel = new JPanel();
-			jPanel.setLayout(new GridBagLayout());
-			jPanel.setBounds(new Rectangle(0, 0, 391, 406));
-			jPanel.add(getJTabbedPane(), gridBagConstraints);
-		}
-		return jPanel;
-	}
-
-	/**
-	 * This method initializes buttonPanel	
-	 * 	
-	 * @return javax.swing.JPanel	
-	 */
-	private JPanel getButtonPanel() {
-		if (buttonPanel == null) {
-			buttonPanel = new JPanel();
-			buttonPanel.setLayout(null);
-			buttonPanel.setBounds(new Rectangle(0, 405, 391, 46));
-			buttonPanel.add(getOkButton(), null);
-		}
-		return buttonPanel;
-	}
-
-	/**
-	 * This method initializes jTabbedPane	
-	 * 	
-	 * @return javax.swing.JTabbedPane	
-	 */
-	private JTabbedPane getJTabbedPane() {
-		if (jTabbedPane == null) {
-			jTabbedPane = new JTabbedPane();
-			jTabbedPane.addTab("General Information", null, getInfoPanel(), null);
-			jTabbedPane.addTab("Source Reference System", null, getCrsPanel(), null);
-		}
-		return jTabbedPane;
-	}
-
-	/**
-	 * This method initializes infoPanel	
-	 * 	
-	 * @return javax.swing.JPanel	
-	 */
-	private JPanel getInfoPanel() {
-		if (infoPanel == null) {
-			lowerRightValueLabel = new JLabel();
-			lowerRightValueLabel.setBounds(new Rectangle(210, 315, 134, 16));
-			lowerRightValueLabel.setHorizontalAlignment(SwingConstants.RIGHT);
-			lowerRightValueLabel.setText((float)imageLayer.getBbox().getMinX() + ", " + (float)imageLayer.getBbox().getMaxY());
-			lowerLeftValueLabel = new JLabel();
-			lowerLeftValueLabel.setBounds(new Rectangle(30, 315, 133, 16));
-			lowerLeftValueLabel.setHorizontalAlignment(SwingConstants.LEFT);
-			lowerLeftValueLabel.setText((float)imageLayer.getBbox().getMinX() + ", " + (float)imageLayer.getBbox().getMinY());
-			upperRightValueLabel = new JLabel();
-			upperRightValueLabel.setBounds(new Rectangle(210, 255, 138, 16));
-			upperRightValueLabel.setHorizontalAlignment(SwingConstants.RIGHT);
-			upperRightValueLabel.setText((float)imageLayer.getBbox().getMaxX() + ", " + (float)imageLayer.getBbox().getMaxY());
-			upperLeftValueLabel = new JLabel();
-			upperLeftValueLabel.setBounds(new Rectangle(30, 255, 133, 16));
-			upperLeftValueLabel.setHorizontalAlignment(SwingConstants.LEFT);
-			upperLeftValueLabel.setText((float)imageLayer.getBbox().getMaxX() + ", " + (float)imageLayer.getBbox().getMinY());
-			lowerRightLabel = new JLabel();
-			lowerRightLabel.setBounds(new Rectangle(287, 344, 74, 16));
-			lowerRightLabel.setText("Lower Right");
-			upperRightLabel = new JLabel();
-			upperRightLabel.setBounds(new Rectangle(285, 225, 91, 16));
-			upperRightLabel.setText("Upper Right");
-			lowerLeftLabel = new JLabel();
-			lowerLeftLabel.setBounds(new Rectangle(15, 345, 92, 16));
-			lowerLeftLabel.setText("Lower Left");
-			upperLeftLabel = new JLabel();
-			upperLeftLabel.setBounds(new Rectangle(15, 224, 91, 16));
-			upperLeftLabel.setText("Upper Left");
-			extentLabel = new JLabel();
-			extentLabel.setBounds(new Rectangle(120, 195, 136, 16));
-			extentLabel.setEnabled(false);
-			extentLabel.setHorizontalAlignment(SwingConstants.CENTER);
-			extentLabel.setDisplayedMnemonic(KeyEvent.VK_UNDEFINED);
-			extentLabel.setText("Extent");
-			crsValueLabel = new JLabel();
-			crsValueLabel.setBounds(new Rectangle(150, 150, 226, 16));
-			
-			String crsDescription = "";
-			try {
-				crsDescription = imageLayer.getBbox().getCoordinateReferenceSystem().getIdentifiers().iterator().next().toString();
-			} catch (Exception e) {
-			}
-			crsValueLabel.setText(crsDescription + "(" + imageLayer.getBbox().getCoordinateReferenceSystem().getName().toString() + ")");
-			
-			crsLabel = new JLabel();
-			crsLabel.setBounds(new Rectangle(15, 150, 118, 16));
-			crsLabel.setText("Reference System");
-			sizeValueLabel = new JLabel();
-			sizeValueLabel.setBounds(new Rectangle(150, 105, 226, 16));
-			sizeValueLabel.setText(imageLayer.getImage().getHeight() + " x " + imageLayer.getImage().getWidth());
-			sizeLabel = new JLabel();
-			sizeLabel.setBounds(new Rectangle(15, 105, 121, 16));
-			sizeLabel.setText("Image size");
-			imageFileValueLabel = new JLabel();
-			imageFileValueLabel.setBounds(new Rectangle(150, 60, 226, 16));
-			imageFileValueLabel.setText(imageLayer.getImageFile().getAbsolutePath());
-			imageFileValueLabel.setToolTipText(imageLayer.getImageFile().getAbsolutePath());
-			imageFileLabel = new JLabel();
-			imageFileLabel.setBounds(new Rectangle(15, 60, 121, 16));
-			imageFileLabel.setText("Image file");
-			layerNameValueLabel = new JLabel();
-			layerNameValueLabel.setBounds(new Rectangle(150, 15, 226, 16));
-			layerNameValueLabel.setText(imageLayer.getName());
-			layerNameLabel = new JLabel();
-			layerNameLabel.setBounds(new Rectangle(15, 15, 121, 16));
-			layerNameLabel.setText("Layer name");
-			infoPanel = new JPanel();
-			infoPanel.setLayout(null);
-			infoPanel.setFont(new Font("Dialog", Font.BOLD, 12));
-			infoPanel.add(layerNameLabel, null);
-			infoPanel.add(layerNameValueLabel, null);
-			infoPanel.add(imageFileLabel, null);
-			infoPanel.add(imageFileValueLabel, null);
-			infoPanel.add(sizeLabel, null);
-			infoPanel.add(sizeValueLabel, null);
-			infoPanel.add(crsLabel, null);
-			infoPanel.add(crsValueLabel, null);
-			infoPanel.add(extentLabel, null);
-			infoPanel.add(upperLeftLabel, null);
-			infoPanel.add(lowerLeftLabel, null);
-			infoPanel.add(upperRightLabel, null);
-			infoPanel.add(lowerRightLabel, null);
-			infoPanel.add(upperLeftValueLabel, null);
-			infoPanel.add(upperRightValueLabel, null);
-			infoPanel.add(lowerLeftValueLabel, null);
-			infoPanel.add(lowerRightValueLabel, null);
-		}
-		return infoPanel;
-	}
-
-	/**
-	 * This method initializes crsPanel	
-	 * 	
-	 * @return javax.swing.JPanel	
-	 */
-	private JPanel getCrsPanel() {
-		if (crsPanel == null) {
-			currentCRSValueLabel = new JLabel();
-			currentCRSValueLabel.setBounds(new Rectangle(78, 33, 297, 16));
-			String crsDescription = "unknown";
-			try {
-				crsDescription = imageLayer.getSourceRefSys().getIdentifiers().iterator().next().toString();
-			} catch (Exception e) {
-			}
-			currentCRSValueLabel.setText(crsDescription);
-			
-			currentCRSLabel = new JLabel();
-			currentCRSLabel.setBounds(new Rectangle(15, 33, 52, 16));
-			currentCRSLabel.setText("Current:");
-			tabDescriptionLabel = new JLabel();
-			tabDescriptionLabel.setBounds(new Rectangle(15, 9, 361, 16));
-			tabDescriptionLabel.setText("Set here the source reference system of the image");
-			eastingFirstLabel = new JLabel();
-			eastingFirstLabel.setBounds(new Rectangle(315, 210, 76, 46));
-			eastingFirstLabel.setHorizontalTextPosition(SwingConstants.TRAILING);
-			eastingFirstLabel.setHorizontalAlignment(SwingConstants.CENTER);
-			eastingFirstLabel.setText("<html>Easting<br>first</html>");
-			searchFieldLabel = new JLabel();
-			searchFieldLabel.setBounds(new Rectangle(298, 114, 84, 16));
-			searchFieldLabel.setDisplayedMnemonic(KeyEvent.VK_UNDEFINED);
-			searchFieldLabel.setHorizontalTextPosition(SwingConstants.TRAILING);
-			searchFieldLabel.setHorizontalAlignment(SwingConstants.CENTER);
-			searchFieldLabel.setText("Search");
-			defaultCRSLabel = new JLabel();
-			defaultCRSLabel.setBounds(new Rectangle(15, 89, 361, 16));
-			defaultCRSLabel.setText(PluginOperations.defaultSourceCRSDescription);
-			defaultCRSDescriptorLabel = new JLabel();
-			defaultCRSDescriptorLabel.setBounds(new Rectangle(15, 63, 226, 16));
-			defaultCRSDescriptorLabel.setText("Default Reference System:");
-			crsPanel = new JPanel();
-			crsPanel.setLayout(null);
-			crsPanel.add(defaultCRSDescriptorLabel, null);
-			crsPanel.add(defaultCRSLabel, null);
-			crsPanel.add(getSearchField(), null);
-			crsPanel.add(getCrsListScrollPane(), null);
-			crsPanel.add(getUseDefaultCRSButton(), null);
-			crsPanel.add(getApplySelectedCRSButton(), null);
-			crsPanel.add(getSetSelectedCRSAsDefaultButton(), null);
-			crsPanel.add(searchFieldLabel, null);
-			crsPanel.add(getEastingFirstCheckBox(), null);
-			crsPanel.add(eastingFirstLabel, null);
-			crsPanel.add(tabDescriptionLabel, null);
-			crsPanel.add(currentCRSLabel, null);
-			crsPanel.add(currentCRSValueLabel, null);
-		}
-		return crsPanel;
-	}
-
-	/**
-	 * This method initializes okButton	
-	 * 	
-	 * @return javax.swing.JButton	
-	 */
-	private JButton getOkButton() {
-		if (okButton == null) {
-			okButton = new JButton();
-			okButton.setBounds(new Rectangle(134, 5, 136, 31));
-			okButton.setText("OK");
-			okButton.addActionListener(new java.awt.event.ActionListener() {
-				public void actionPerformed(java.awt.event.ActionEvent e) {
-					
-					setVisible(false);
-					dispose();
-				}
-			});
-		}
-		return okButton;
-	}
-
-	/**
-	 * This method initializes searchField	
-	 * 	
-	 * @return javax.swing.JTextField	
-	 */
-	private JTextField getSearchField() {
-		if (searchField == null) {
-			searchField = new JTextField();
-			searchField.setBounds(new Rectangle(13, 111, 282, 20));
-			searchField.setToolTipText("Enter keywords or EPSG codes");
-			searchField.addKeyListener(new java.awt.event.KeyAdapter() {
-				public void keyTyped(java.awt.event.KeyEvent e) {
-					
-					for (Iterator iterator = supportedCRS.iterator(); iterator
-							.hasNext();) {
-						String type = (String) iterator.next();
-						if(type.contains(searchField.getText()))
-						{
-							crsJList.setSelectedIndex(supportedCRS.indexOf(type));
-							crsJList.ensureIndexIsVisible(supportedCRS.indexOf(type));
-							break;
-						}
-						
-					}
-				}
-			});
-		}
-		return searchField;
-	}
-
-	/**
-	 * This method initializes crsListScrollPane	
-	 * 	
-	 * @return javax.swing.JScrollPane	
-	 */
-	private JScrollPane getCrsListScrollPane() {
-		if (crsListScrollPane == null) {
-			crsListScrollPane = new JScrollPane();
-			crsListScrollPane.setBounds(new Rectangle(15, 135, 301, 241));
-			crsListScrollPane.setViewportView(getCrsJList());
-		}
-		return crsListScrollPane;
-	}
-
-	/**
-	 * This method initializes crsJList	
-	 * 	
-	 * @return javax.swing.JList	
-	 */
-	private JList getCrsJList() {
-		if (crsJList == null) {
-			crsJList = new JList(supportedCRS);
-			crsJList.addListSelectionListener(new ListSelectionHandler());
-		}
-		return crsJList;
-	}
-
-	/**
-	 * This method initializes useDefaultCRSButton	
-	 * 	
-	 * @return javax.swing.JButton	
-	 */
-	private JButton getUseDefaultCRSButton() {
-		if (useDefaultCRSButton == null) {
-			useDefaultCRSButton = new JButton();
-			useDefaultCRSButton.setBounds(new Rectangle(253, 54, 118, 28));
-			useDefaultCRSButton.setText("Apply Default");
-			useDefaultCRSButton.addActionListener(new java.awt.event.ActionListener() {
-				public void actionPerformed(java.awt.event.ActionEvent e) {
-					
-					try {
-						
-						setCursor(new Cursor(Cursor.WAIT_CURSOR));
-						if(PluginOperations.defaultSourceCRS != null){
-							imageLayer.resample(PluginOperations.defaultSourceCRS);
-						}else
-						{
-							JOptionPane.showMessageDialog(getContentPane(), "<html>No default reference system available.<br>Please select one from the list</html>");
-						}
-						
-					} catch (NoSuchAuthorityCodeException e1) {
-						// TODO Auto-generated catch block
-						e1.printStackTrace();
-					} catch (FactoryException e1) {
-						// TODO Auto-generated catch block
-						e1.printStackTrace();
-					} catch (IOException e2) {
-						// TODO Auto-generated catch block
-						e2.printStackTrace();
-					}
-					finally{
-						setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
-					}
-				}
-			});
-		}
-		return useDefaultCRSButton;
-	}
-
-	/**
-	 * This method initializes applySelectedCRSButton	
-	 * 	
-	 * @return javax.swing.JButton	
-	 */
-	private JButton getApplySelectedCRSButton() {
-		if (applySelectedCRSButton == null) {
-			applySelectedCRSButton = new JButton();
-			applySelectedCRSButton.setBounds(new Rectangle(315, 135, 69, 61));
-			applySelectedCRSButton.setHorizontalAlignment(SwingConstants.CENTER);
-			applySelectedCRSButton.setHorizontalTextPosition(SwingConstants.TRAILING);
-			applySelectedCRSButton.setText("<html>Apply<br>Selection</html>");
-			applySelectedCRSButton.addActionListener(new java.awt.event.ActionListener() {
-				public void actionPerformed(java.awt.event.ActionEvent e) {
-					
-					String selection = (String) crsJList.getSelectedValue();
-					String code = selection.substring(selection.indexOf("[-") + 2, selection.indexOf("-]"));
-					
-					CoordinateReferenceSystem newRefSys = null;
-					try {
-						newRefSys = CRS.decode(code, eastingFirstCheckBox.isSelected());
-						
-						setCursor(new Cursor(Cursor.WAIT_CURSOR));
-						
-						imageLayer.resample(newRefSys);
-
-					} catch (NoSuchAuthorityCodeException e1) {
-						// TODO Auto-generated catch block
-						e1.printStackTrace();
-					} catch (FactoryException e1) {
-						// TODO Auto-generated catch block
-						e1.printStackTrace();
-					} catch (IOException e2) {
-						// TODO Auto-generated catch block
-						e2.printStackTrace();
-					}
-					finally{
-						setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
-					}
-					
-					
-				}
-			});
-		}
-		return applySelectedCRSButton;
-	}
-
-	/**
-	 * This method initializes setSelectedCRSAsDefaultButton	
-	 * 	
-	 * @return javax.swing.JButton	
-	 */
-	private JButton getSetSelectedCRSAsDefaultButton() {
-		if (setSelectedCRSAsDefaultButton == null) {
-			setSelectedCRSAsDefaultButton = new JButton();
-			setSelectedCRSAsDefaultButton.setBounds(new Rectangle(315, 300, 69, 61));
-			setSelectedCRSAsDefaultButton.setText("<html>Set as<br>Default</html>");
-			setSelectedCRSAsDefaultButton
-					.addActionListener(new java.awt.event.ActionListener() {
-						public void actionPerformed(java.awt.event.ActionEvent e) {
-							
-							if(crsJList.getSelectedValue() != null){
-								String selection = (String) crsJList.getSelectedValue();
-								String code = selection.substring(selection.indexOf("[-") + 2, selection.indexOf("-]"));
-								
-								try {
-									PluginOperations.defaultSourceCRS = CRS.decode(code, eastingFirstCheckBox.isSelected());
-									PluginOperations.defaultSourceCRSDescription = selection;
-									
-									ImageImportPlugin.pluginProps.setProperty("default_crs_eastingfirst", "" + eastingFirstCheckBox.isSelected());
-									ImageImportPlugin.pluginProps.setProperty("default_crs_srid", code);
-									FileWriter fileWriter = new FileWriter(new File(ImageImportPlugin.PLUGINPROPERTIES_PATH));
-									ImageImportPlugin.pluginProps.store(fileWriter, null);
-									fileWriter.close();
-									
-									defaultCRSLabel.setText(selection);
-									
-								} catch (IOException e2) {
-									// TODO Auto-generated catch block
-									e2.printStackTrace();
-								} catch (NoSuchAuthorityCodeException e3) {
-									// TODO Auto-generated catch block
-									e3.printStackTrace();
-								} catch (FactoryException e4) {
-									// TODO Auto-generated catch block
-									e4.printStackTrace();
-								}
-							}else{
-								JOptionPane.showMessageDialog(getContentPane(), "Please make a selection from the list.");
-							}
-
-							
-						}
-					});
-		}
-		return setSelectedCRSAsDefaultButton;
-	}
-	
-	/**
-	 * This method initializes eastingFirstCheckBox	
-	 * 	
-	 * @return javax.swing.JCheckBox	
-	 */
-	private JCheckBox getEastingFirstCheckBox() {
-		if (eastingFirstCheckBox == null) {
-			eastingFirstCheckBox = new JCheckBox();
-			eastingFirstCheckBox.setBounds(new Rectangle(345, 255, 21, 21));
-		}
-		return eastingFirstCheckBox;
-	}
-
-	
-	
-	/**
-	 * Listener setting text in the search field if selection has changed.
-	 *
-	 */
+            
+    }
+
+    /**
+     * This method initializes mainPanel    
+     *  
+     * @return javax.swing.JPanel   
+     */
+    private JPanel getMainPanel() {
+        if (mainPanel == null) {
+            mainPanel = new JPanel();
+            mainPanel.setLayout(null);
+            mainPanel.add(getJPanel(), null);
+            mainPanel.add(getButtonPanel(), null);
+        }
+        return mainPanel;
+    }
+
+    /**
+     * This method initializes jPanel   
+     *  
+     * @return javax.swing.JPanel   
+     */
+    private JPanel getJPanel() {
+        if (jPanel == null) {
+            GridBagConstraints gridBagConstraints = new GridBagConstraints();
+            gridBagConstraints.fill = GridBagConstraints.BOTH;
+            gridBagConstraints.gridy = 0;
+            gridBagConstraints.weightx = 1.0;
+            gridBagConstraints.weighty = 1.0;
+            gridBagConstraints.gridx = 0;
+            jPanel = new JPanel();
+            jPanel.setLayout(new GridBagLayout());
+            jPanel.setBounds(new Rectangle(0, 0, 391, 406));
+            jPanel.add(getJTabbedPane(), gridBagConstraints);
+        }
+        return jPanel;
+    }
+
+    /**
+     * This method initializes buttonPanel  
+     *  
+     * @return javax.swing.JPanel   
+     */
+    private JPanel getButtonPanel() {
+        if (buttonPanel == null) {
+            buttonPanel = new JPanel();
+            buttonPanel.setLayout(null);
+            buttonPanel.setBounds(new Rectangle(0, 405, 391, 46));
+            buttonPanel.add(getOkButton(), null);
+        }
+        return buttonPanel;
+    }
+
+    /**
+     * This method initializes jTabbedPane  
+     *  
+     * @return javax.swing.JTabbedPane  
+     */
+    private JTabbedPane getJTabbedPane() {
+        if (jTabbedPane == null) {
+            jTabbedPane = new JTabbedPane();
+            jTabbedPane.addTab("General Information", null, getInfoPanel(), null);
+            jTabbedPane.addTab("Source Reference System", null, getCrsPanel(), null);
+        }
+        return jTabbedPane;
+    }
+
+    /**
+     * This method initializes infoPanel    
+     *  
+     * @return javax.swing.JPanel   
+     */
+    private JPanel getInfoPanel() {
+        if (infoPanel == null) {
+            lowerRightValueLabel = new JLabel();
+            lowerRightValueLabel.setBounds(new Rectangle(210, 315, 134, 16));
+            lowerRightValueLabel.setHorizontalAlignment(SwingConstants.RIGHT);
+            lowerRightValueLabel.setText((float)imageLayer.getBbox().getMinX() + ", " + (float)imageLayer.getBbox().getMaxY());
+            lowerLeftValueLabel = new JLabel();
+            lowerLeftValueLabel.setBounds(new Rectangle(30, 315, 133, 16));
+            lowerLeftValueLabel.setHorizontalAlignment(SwingConstants.LEFT);
+            lowerLeftValueLabel.setText((float)imageLayer.getBbox().getMinX() + ", " + (float)imageLayer.getBbox().getMinY());
+            upperRightValueLabel = new JLabel();
+            upperRightValueLabel.setBounds(new Rectangle(210, 255, 138, 16));
+            upperRightValueLabel.setHorizontalAlignment(SwingConstants.RIGHT);
+            upperRightValueLabel.setText((float)imageLayer.getBbox().getMaxX() + ", " + (float)imageLayer.getBbox().getMaxY());
+            upperLeftValueLabel = new JLabel();
+            upperLeftValueLabel.setBounds(new Rectangle(30, 255, 133, 16));
+            upperLeftValueLabel.setHorizontalAlignment(SwingConstants.LEFT);
+            upperLeftValueLabel.setText((float)imageLayer.getBbox().getMaxX() + ", " + (float)imageLayer.getBbox().getMinY());
+            lowerRightLabel = new JLabel();
+            lowerRightLabel.setBounds(new Rectangle(287, 344, 74, 16));
+            lowerRightLabel.setText("Lower Right");
+            upperRightLabel = new JLabel();
+            upperRightLabel.setBounds(new Rectangle(285, 225, 91, 16));
+            upperRightLabel.setText("Upper Right");
+            lowerLeftLabel = new JLabel();
+            lowerLeftLabel.setBounds(new Rectangle(15, 345, 92, 16));
+            lowerLeftLabel.setText("Lower Left");
+            upperLeftLabel = new JLabel();
+            upperLeftLabel.setBounds(new Rectangle(15, 224, 91, 16));
+            upperLeftLabel.setText("Upper Left");
+            extentLabel = new JLabel();
+            extentLabel.setBounds(new Rectangle(120, 195, 136, 16));
+            extentLabel.setEnabled(false);
+            extentLabel.setHorizontalAlignment(SwingConstants.CENTER);
+            extentLabel.setDisplayedMnemonic(KeyEvent.VK_UNDEFINED);
+            extentLabel.setText("Extent");
+            crsValueLabel = new JLabel();
+            crsValueLabel.setBounds(new Rectangle(150, 150, 226, 16));
+            
+            String crsDescription = "";
+            try {
+                crsDescription = imageLayer.getBbox().getCoordinateReferenceSystem().getIdentifiers().iterator().next().toString();
+            } catch (Exception e) {
+            }
+            crsValueLabel.setText(crsDescription + "(" + imageLayer.getBbox().getCoordinateReferenceSystem().getName().toString() + ")");
+            
+            crsLabel = new JLabel();
+            crsLabel.setBounds(new Rectangle(15, 150, 118, 16));
+            crsLabel.setText("Reference System");
+            sizeValueLabel = new JLabel();
+            sizeValueLabel.setBounds(new Rectangle(150, 105, 226, 16));
+            sizeValueLabel.setText(imageLayer.getImage().getHeight() + " x " + imageLayer.getImage().getWidth());
+            sizeLabel = new JLabel();
+            sizeLabel.setBounds(new Rectangle(15, 105, 121, 16));
+            sizeLabel.setText("Image size");
+            imageFileValueLabel = new JLabel();
+            imageFileValueLabel.setBounds(new Rectangle(150, 60, 226, 16));
+            imageFileValueLabel.setText(imageLayer.getImageFile().getAbsolutePath());
+            imageFileValueLabel.setToolTipText(imageLayer.getImageFile().getAbsolutePath());
+            imageFileLabel = new JLabel();
+            imageFileLabel.setBounds(new Rectangle(15, 60, 121, 16));
+            imageFileLabel.setText("Image file");
+            layerNameValueLabel = new JLabel();
+            layerNameValueLabel.setBounds(new Rectangle(150, 15, 226, 16));
+            layerNameValueLabel.setText(imageLayer.getName());
+            layerNameLabel = new JLabel();
+            layerNameLabel.setBounds(new Rectangle(15, 15, 121, 16));
+            layerNameLabel.setText("Layer name");
+            infoPanel = new JPanel();
+            infoPanel.setLayout(null);
+            infoPanel.setFont(new Font("Dialog", Font.BOLD, 12));
+            infoPanel.add(layerNameLabel, null);
+            infoPanel.add(layerNameValueLabel, null);
+            infoPanel.add(imageFileLabel, null);
+            infoPanel.add(imageFileValueLabel, null);
+            infoPanel.add(sizeLabel, null);
+            infoPanel.add(sizeValueLabel, null);
+            infoPanel.add(crsLabel, null);
+            infoPanel.add(crsValueLabel, null);
+            infoPanel.add(extentLabel, null);
+            infoPanel.add(upperLeftLabel, null);
+            infoPanel.add(lowerLeftLabel, null);
+            infoPanel.add(upperRightLabel, null);
+            infoPanel.add(lowerRightLabel, null);
+            infoPanel.add(upperLeftValueLabel, null);
+            infoPanel.add(upperRightValueLabel, null);
+            infoPanel.add(lowerLeftValueLabel, null);
+            infoPanel.add(lowerRightValueLabel, null);
+        }
+        return infoPanel;
+    }
+
+    /**
+     * This method initializes crsPanel 
+     *  
+     * @return javax.swing.JPanel   
+     */
+    private JPanel getCrsPanel() {
+        if (crsPanel == null) {
+            currentCRSValueLabel = new JLabel();
+            currentCRSValueLabel.setBounds(new Rectangle(78, 33, 297, 16));
+            String crsDescription = "unknown";
+            try {
+                crsDescription = imageLayer.getSourceRefSys().getIdentifiers().iterator().next().toString();
+            } catch (Exception e) {
+            }
+            currentCRSValueLabel.setText(crsDescription);
+            
+            currentCRSLabel = new JLabel();
+            currentCRSLabel.setBounds(new Rectangle(15, 33, 52, 16));
+            currentCRSLabel.setText("Current:");
+            tabDescriptionLabel = new JLabel();
+            tabDescriptionLabel.setBounds(new Rectangle(15, 9, 361, 16));
+            tabDescriptionLabel.setText("Set here the source reference system of the image");
+            eastingFirstLabel = new JLabel();
+            eastingFirstLabel.setBounds(new Rectangle(315, 210, 76, 46));
+            eastingFirstLabel.setHorizontalTextPosition(SwingConstants.TRAILING);
+            eastingFirstLabel.setHorizontalAlignment(SwingConstants.CENTER);
+            eastingFirstLabel.setText("<html>Easting<br>first</html>");
+            searchFieldLabel = new JLabel();
+            searchFieldLabel.setBounds(new Rectangle(298, 114, 84, 16));
+            searchFieldLabel.setDisplayedMnemonic(KeyEvent.VK_UNDEFINED);
+            searchFieldLabel.setHorizontalTextPosition(SwingConstants.TRAILING);
+            searchFieldLabel.setHorizontalAlignment(SwingConstants.CENTER);
+            searchFieldLabel.setText("Search");
+            defaultCRSLabel = new JLabel();
+            defaultCRSLabel.setBounds(new Rectangle(15, 89, 361, 16));
+            defaultCRSLabel.setText(PluginOperations.defaultSourceCRSDescription);
+            defaultCRSDescriptorLabel = new JLabel();
+            defaultCRSDescriptorLabel.setBounds(new Rectangle(15, 63, 226, 16));
+            defaultCRSDescriptorLabel.setText("Default Reference System:");
+            crsPanel = new JPanel();
+            crsPanel.setLayout(null);
+            crsPanel.add(defaultCRSDescriptorLabel, null);
+            crsPanel.add(defaultCRSLabel, null);
+            crsPanel.add(getSearchField(), null);
+            crsPanel.add(getCrsListScrollPane(), null);
+            crsPanel.add(getUseDefaultCRSButton(), null);
+            crsPanel.add(getApplySelectedCRSButton(), null);
+            crsPanel.add(getSetSelectedCRSAsDefaultButton(), null);
+            crsPanel.add(searchFieldLabel, null);
+            crsPanel.add(getEastingFirstCheckBox(), null);
+            crsPanel.add(eastingFirstLabel, null);
+            crsPanel.add(tabDescriptionLabel, null);
+            crsPanel.add(currentCRSLabel, null);
+            crsPanel.add(currentCRSValueLabel, null);
+        }
+        return crsPanel;
+    }
+
+    /**
+     * This method initializes okButton 
+     *  
+     * @return javax.swing.JButton  
+     */
+    private JButton getOkButton() {
+        if (okButton == null) {
+            okButton = new JButton();
+            okButton.setBounds(new Rectangle(134, 5, 136, 31));
+            okButton.setText("OK");
+            okButton.addActionListener(new java.awt.event.ActionListener() {
+                public void actionPerformed(java.awt.event.ActionEvent e) {
+                    
+                    setVisible(false);
+                    dispose();
+                }
+            });
+        }
+        return okButton;
+    }
+
+    /**
+     * This method initializes searchField  
+     *  
+     * @return javax.swing.JTextField   
+     */
+    private JTextField getSearchField() {
+        if (searchField == null) {
+            searchField = new JTextField();
+            searchField.setBounds(new Rectangle(13, 111, 282, 20));
+            searchField.setToolTipText("Enter keywords or EPSG codes");
+            searchField.addKeyListener(new java.awt.event.KeyAdapter() {
+                public void keyTyped(java.awt.event.KeyEvent e) {
+                    
+                    for (Iterator iterator = supportedCRS.iterator(); iterator
+                            .hasNext();) {
+                        String type = (String) iterator.next();
+                        if(type.contains(searchField.getText()))
+                        {
+                            crsJList.setSelectedIndex(supportedCRS.indexOf(type));
+                            crsJList.ensureIndexIsVisible(supportedCRS.indexOf(type));
+                            break;
+                        }
+                        
+                    }
+                }
+            });
+        }
+        return searchField;
+    }
+
+    /**
+     * This method initializes crsListScrollPane    
+     *  
+     * @return javax.swing.JScrollPane  
+     */
+    private JScrollPane getCrsListScrollPane() {
+        if (crsListScrollPane == null) {
+            crsListScrollPane = new JScrollPane();
+            crsListScrollPane.setBounds(new Rectangle(15, 135, 301, 241));
+            crsListScrollPane.setViewportView(getCrsJList());
+        }
+        return crsListScrollPane;
+    }
+
+    /**
+     * This method initializes crsJList 
+     *  
+     * @return javax.swing.JList    
+     */
+    private JList getCrsJList() {
+        if (crsJList == null) {
+            crsJList = new JList(supportedCRS);
+            crsJList.addListSelectionListener(new ListSelectionHandler());
+        }
+        return crsJList;
+    }
+
+    /**
+     * This method initializes useDefaultCRSButton  
+     *  
+     * @return javax.swing.JButton  
+     */
+    private JButton getUseDefaultCRSButton() {
+        if (useDefaultCRSButton == null) {
+            useDefaultCRSButton = new JButton();
+            useDefaultCRSButton.setBounds(new Rectangle(253, 54, 118, 28));
+            useDefaultCRSButton.setText("Apply Default");
+            useDefaultCRSButton.addActionListener(new java.awt.event.ActionListener() {
+                public void actionPerformed(java.awt.event.ActionEvent e) {
+                    
+                    try {
+                        
+                        setCursor(new Cursor(Cursor.WAIT_CURSOR));
+                        if(PluginOperations.defaultSourceCRS != null){
+                            imageLayer.resample(PluginOperations.defaultSourceCRS);
+                        }else
+                        {
+                            JOptionPane.showMessageDialog(getContentPane(), "<html>No default reference system available.<br>Please select one from the list</html>");
+                        }
+                        
+                    } catch (NoSuchAuthorityCodeException e1) {
+                        // TODO Auto-generated catch block
+                        e1.printStackTrace();
+                    } catch (FactoryException e1) {
+                        // TODO Auto-generated catch block
+                        e1.printStackTrace();
+                    } catch (IOException e2) {
+                        // TODO Auto-generated catch block
+                        e2.printStackTrace();
+                    }
+                    finally{
+                        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
+                    }
+                }
+            });
+        }
+        return useDefaultCRSButton;
+    }
+
+    /**
+     * This method initializes applySelectedCRSButton   
+     *  
+     * @return javax.swing.JButton  
+     */
+    private JButton getApplySelectedCRSButton() {
+        if (applySelectedCRSButton == null) {
+            applySelectedCRSButton = new JButton();
+            applySelectedCRSButton.setBounds(new Rectangle(315, 135, 69, 61));
+            applySelectedCRSButton.setHorizontalAlignment(SwingConstants.CENTER);
+            applySelectedCRSButton.setHorizontalTextPosition(SwingConstants.TRAILING);
+            applySelectedCRSButton.setText("<html>Apply<br>Selection</html>");
+            applySelectedCRSButton.addActionListener(new java.awt.event.ActionListener() {
+                public void actionPerformed(java.awt.event.ActionEvent e) {
+                    
+                    String selection = (String) crsJList.getSelectedValue();
+                    String code = selection.substring(selection.indexOf("[-") + 2, selection.indexOf("-]"));
+                    
+                    CoordinateReferenceSystem newRefSys = null;
+                    try {
+                        newRefSys = CRS.decode(code, eastingFirstCheckBox.isSelected());
+                        
+                        setCursor(new Cursor(Cursor.WAIT_CURSOR));
+                        
+                        imageLayer.resample(newRefSys);
+
+                    } catch (NoSuchAuthorityCodeException e1) {
+                        // TODO Auto-generated catch block
+                        e1.printStackTrace();
+                    } catch (FactoryException e1) {
+                        // TODO Auto-generated catch block
+                        e1.printStackTrace();
+                    } catch (IOException e2) {
+                        // TODO Auto-generated catch block
+                        e2.printStackTrace();
+                    }
+                    finally{
+                        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
+                    }
+                    
+                    
+                }
+            });
+        }
+        return applySelectedCRSButton;
+    }
+
+    /**
+     * This method initializes setSelectedCRSAsDefaultButton    
+     *  
+     * @return javax.swing.JButton  
+     */
+    private JButton getSetSelectedCRSAsDefaultButton() {
+        if (setSelectedCRSAsDefaultButton == null) {
+            setSelectedCRSAsDefaultButton = new JButton();
+            setSelectedCRSAsDefaultButton.setBounds(new Rectangle(315, 300, 69, 61));
+            setSelectedCRSAsDefaultButton.setText("<html>Set as<br>Default</html>");
+            setSelectedCRSAsDefaultButton
+                    .addActionListener(new java.awt.event.ActionListener() {
+                        public void actionPerformed(java.awt.event.ActionEvent e) {
+                            
+                            if(crsJList.getSelectedValue() != null){
+                                String selection = (String) crsJList.getSelectedValue();
+                                String code = selection.substring(selection.indexOf("[-") + 2, selection.indexOf("-]"));
+                                
+                                try {
+                                    PluginOperations.defaultSourceCRS = CRS.decode(code, eastingFirstCheckBox.isSelected());
+                                    PluginOperations.defaultSourceCRSDescription = selection;
+                                    
+                                    ImageImportPlugin.pluginProps.setProperty("default_crs_eastingfirst", "" + eastingFirstCheckBox.isSelected());
+                                    ImageImportPlugin.pluginProps.setProperty("default_crs_srid", code);
+                                    FileWriter fileWriter = new FileWriter(new File(ImageImportPlugin.PLUGINPROPERTIES_PATH));
+                                    ImageImportPlugin.pluginProps.store(fileWriter, null);
+                                    fileWriter.close();
+                                    
+                                    defaultCRSLabel.setText(selection);
+                                    
+                                } catch (IOException e2) {
+                                    // TODO Auto-generated catch block
+                                    e2.printStackTrace();
+                                } catch (NoSuchAuthorityCodeException e3) {
+                                    // TODO Auto-generated catch block
+                                    e3.printStackTrace();
+                                } catch (FactoryException e4) {
+                                    // TODO Auto-generated catch block
+                                    e4.printStackTrace();
+                                }
+                            }else{
+                                JOptionPane.showMessageDialog(getContentPane(), "Please make a selection from the list.");
+                            }
+
+                            
+                        }
+                    });
+        }
+        return setSelectedCRSAsDefaultButton;
+    }
+    
+    /**
+     * This method initializes eastingFirstCheckBox 
+     *  
+     * @return javax.swing.JCheckBox    
+     */
+    private JCheckBox getEastingFirstCheckBox() {
+        if (eastingFirstCheckBox == null) {
+            eastingFirstCheckBox = new JCheckBox();
+            eastingFirstCheckBox.setBounds(new Rectangle(345, 255, 21, 21));
+        }
+        return eastingFirstCheckBox;
+    }
+
+    
+    
+    /**
+     * Listener setting text in the search field if selection has changed.
+     *
+     */
     class ListSelectionHandler implements ListSelectionListener {
         public void valueChanged(ListSelectionEvent e) {
-        	if(e.getValueIsAdjusting())
-        	{
-            	searchField.setText(supportedCRS.get(e.getLastIndex()));
-            	searchField.setEditable(true);
-        	}
+            if(e.getValueIsAdjusting())
+            {
+                searchField.setText(supportedCRS.get(e.getLastIndex()));
+                searchField.setEditable(true);
+            }
         }
     }
Index: applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/LoadImageAction.java
===================================================================
--- applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/LoadImageAction.java	(revision 23184)
+++ applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/LoadImageAction.java	(revision 23187)
@@ -26,45 +26,45 @@
  */
 public class LoadImageAction extends JosmAction {
-	
-	private Logger logger = Logger.getLogger(LoadImageAction.class);
+    
+    private Logger logger = Logger.getLogger(LoadImageAction.class);
 
-	/**
-	 * Constructor...
-	 */
-	public LoadImageAction() {
-		super(tr("Import image"), null, tr("Import georeferenced image"), null, false);
-	}
+    /**
+     * Constructor...
+     */
+    public LoadImageAction() {
+        super(tr("Import image"), null, tr("Import georeferenced image"), null, false);
+    }
 
-	public void actionPerformed(ActionEvent arg0) {
+    public void actionPerformed(ActionEvent arg0) {
 
-		// Choose a file
-		JFileChooser fc = new JFileChooser();
-		fc.setAcceptAllFileFilterUsed(false);
-		int result = fc.showOpenDialog(Main.parent);
-		
-		ImageLayer layer = null;
-		if (result == JFileChooser.APPROVE_OPTION) {
-			logger.info("File choosed:" + fc.getSelectedFile());
-			try {
-				layer = new ImageLayer(fc.getSelectedFile());
-			} catch (LayerCreationCancledException e) {
-				// if user decides that layer should not be created just return.
-				return;
-			}catch (Exception e) {
-				logger.error("Error while creating image layer: \n" + e.getMessage());
-				JOptionPane.showMessageDialog(null, marktr("Error while creating image layer: " + e.getCause()));
-				return;
-				
-			}
-			
-			// Add layer:
-			Main.main.addLayer(layer);
-			LatLon min = new LatLon(layer.getBbox().getMinX(), layer.getBbox().getMinY());
-			LatLon max = new LatLon(layer.getBbox().getMaxX(), layer.getBbox().getMaxY());
-			BoundingXYVisitor boundingXYVisitor = new BoundingXYVisitor();
-			boundingXYVisitor.visit(new Bounds(min, max));
-			Main.map.mapView.recalculateCenterScale(boundingXYVisitor);
-			Main.map.mapView.zoomTo(new Bounds(min, max));
-		}
-	}
+        // Choose a file
+        JFileChooser fc = new JFileChooser();
+        fc.setAcceptAllFileFilterUsed(false);
+        int result = fc.showOpenDialog(Main.parent);
+        
+        ImageLayer layer = null;
+        if (result == JFileChooser.APPROVE_OPTION) {
+            logger.info("File choosed:" + fc.getSelectedFile());
+            try {
+                layer = new ImageLayer(fc.getSelectedFile());
+            } catch (LayerCreationCancledException e) {
+                // if user decides that layer should not be created just return.
+                return;
+            }catch (Exception e) {
+                logger.error("Error while creating image layer: \n" + e.getMessage());
+                JOptionPane.showMessageDialog(null, marktr("Error while creating image layer: " + e.getCause()));
+                return;
+                
+            }
+            
+            // Add layer:
+            Main.main.addLayer(layer);
+            LatLon min = new LatLon(layer.getBbox().getMinX(), layer.getBbox().getMinY());
+            LatLon max = new LatLon(layer.getBbox().getMaxX(), layer.getBbox().getMaxY());
+            BoundingXYVisitor boundingXYVisitor = new BoundingXYVisitor();
+            boundingXYVisitor.visit(new Bounds(min, max));
+            Main.map.mapView.recalculateCenterScale(boundingXYVisitor);
+            Main.map.mapView.zoomTo(new Bounds(min, max));
+        }
+    }
 }
Index: applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/PluginOperations.java
===================================================================
--- applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/PluginOperations.java	(revision 23184)
+++ applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/PluginOperations.java	(revision 23187)
@@ -47,349 +47,349 @@
 public class PluginOperations {
 
-	private static final Logger logger = Logger.getLogger(PluginOperations.class);
-	
-	// contains descriptions of all available CRS
-	static Vector<String> crsDescriptions;
-
-	// the standard native CRS of user images 
-	static CoordinateReferenceSystem defaultSourceCRS;
-	// description of 'defaultSourceCRS'
-	static String defaultSourceCRSDescription;
-	
-	
-	
-	public static enum SUPPORTEDIMAGETYPES {
-		tiff, tif, jpg, jpeg, bmp, png 
-	}
-
-	public static enum POSTFIXES_WORLDFILE {
-		wld, jgw, jpgw, pgw, pngw, tfw, tifw, bpw, bmpw, 
-	};
-	
-	/**
-	 * Reprojects a GridCoverage to a given CRS.
-	 * 
-	 * @param coverage
-	 * @param targetCrs
-	 * @return destination
-	 * @throws FactoryException 
-	 * @throws NoSuchAuthorityCodeException 
-	 */
-	public static GridCoverage2D reprojectCoverage(GridCoverage2D coverage,
-			CoordinateReferenceSystem targetCrs) throws NoSuchAuthorityCodeException, FactoryException {
-
-		// TODO: add category for NO_DATA values in coverage (transparency in
-		// image)
-		
-		GridCoverage2D destination = null;
-
-		DefaultProcessor processor = new DefaultProcessor(null);
-		ParameterValueGroup resampleParams = processor.getOperation("Resample")
-				.getParameters();
-
-		// set parameters
-		resampleParams.parameter("Source").setValue(coverage);
-		resampleParams.parameter("CoordinateReferenceSystem").setValue(
-				targetCrs);
-
-		// resample coverage with given parameters
-		destination = (GridCoverage2D) processor.doOperation(resampleParams);
-
-		return destination;
-	}
-
-	/**
-	 * Creates a org.geotools.coverage.grid.GridCoverage2D from a given file. 
-	 * 
-	 * @param file
-	 * @return
-	 * @throws IOException 
-	 * @throws Exception
-	 */
-	public static GridCoverage2D createGridFromFile(File file, CoordinateReferenceSystem refSys) throws IOException{
-
-		GridCoverage2D coverage = null;
-		
-		if (!file.exists()) throw new FileNotFoundException("File not found.");
-
-		String extension = null;
-		String fileNameWithoutExt = null;
-		int dotPos = file.getAbsolutePath().lastIndexOf(".");
-		extension = file.getAbsolutePath().substring(dotPos);
-		fileNameWithoutExt = file.getAbsolutePath().substring(0, dotPos);
-
-		/*------- switch for file type -----------*/
-		if (extension.equalsIgnoreCase(".tif")
-				|| extension.equalsIgnoreCase(".tiff"))
-		{
-			
-			// try to read GeoTIFF:
-			try{
-				coverage = readGeoTiff(file, refSys);
-				return coverage;
-			}catch (DataSourceException dse) {
-				if(!dse.getMessage().contains("Coordinate Reference System is not available")){
-					dse.printStackTrace();
-				}
-			} catch (FactoryException facte) {
-				logger.fatal("Error while reading from GeoTIFF:", facte);
-				throw new IOException(facte);
-			}
-			
-			// file is no GeoTiff, searching for Worldfile and projection file: 
-			String[] postfixes = {"wld", "tfw", "tifw"};
-			// try to read Worldfile:
-			WorldFileReader tfwReader = null;
-			for (int i = 0; i < postfixes.length; i++) {
-				File prjFile = new File(fileNameWithoutExt + "." + postfixes[i]);
-				if(prjFile.exists()){
-					tfwReader = new WorldFileReader(prjFile);
-				}
-			}
-			if(tfwReader == null){
-				throw new IOException("No Worldfile found.");
-			}
-			
-			if(refSys == null){
-				// if no crs is delivered try to read projection file:
-				refSys = readPrjFile(file);
-				if(refSys == null) throw new IOException("No projection file found.");
-			}
-			
-			BufferedImage img = ImageIO.read(file);
-			
-			// create Envelope
-			double width = (double) (img.getWidth() * tfwReader.getXPixelSize());
-			double height = (double) (img.getHeight() * (-tfwReader.getYPixelSize()));
-			double lowerLeft_x = (double) tfwReader.getXULC();
-			double lowerLeft_y = (double) tfwReader.getYULC() - height;
-			Envelope2D bbox = new Envelope2D(null, new Rectangle2D.Double(lowerLeft_x, lowerLeft_y, width, height));
-			
-			coverage = createGridCoverage(img, bbox, refSys);
-			
-		}
-		// 
-		else if (extension.equalsIgnoreCase(".jpg")
-				|| extension.equalsIgnoreCase(".jpeg"))
-		{
-			String[] postfixes = {"wld", "jgw", "jpgw"};
-			// try to read Worldfile:
-			WorldFileReader tfwReader = null;
-			for (int i = 0; i < postfixes.length; i++) {
-				File prjFile = new File(fileNameWithoutExt + "." + postfixes[i]);
-				if(prjFile.exists()){
-					tfwReader = new WorldFileReader(prjFile);
-				}
-			}
-			if(tfwReader == null) throw new IOException("No Worldfile found.");
-			
-			if(refSys == null){
-				// if no crs is delivered try to read projection file:
-				refSys = readPrjFile(file);
-				if(refSys == null) throw new IOException("No projection file found.");
-			}
-			
-			BufferedImage img = ImageIO.read(file);
-			
-			// create Envelope
-			double width = (double) (img.getWidth() * tfwReader.getXPixelSize());
-			double height = (double) (img.getHeight() * (-tfwReader.getYPixelSize()));
-			double lowerLeft_x = (double) tfwReader.getXULC();
-			double lowerLeft_y = (double) tfwReader.getYULC() - height;
-			Envelope2D bbox = new Envelope2D(null, new Rectangle2D.Double(lowerLeft_x, lowerLeft_y, width, height));
-			
-			coverage = createGridCoverage(img, bbox, refSys);
-			
-		}
-		else if(extension.equalsIgnoreCase(".bmp"))
-		{
-			String[] postfixes = {"wld", "bmpw", "bpw"};
-			// try to read Worldfile:
-			WorldFileReader tfwReader = null;
-			for (int i = 0; i < postfixes.length; i++) {
-				File prjFile = new File(fileNameWithoutExt + "." + postfixes[i]);
-				if(prjFile.exists()){
-					tfwReader = new WorldFileReader(prjFile);
-				}
-			}
-			if(tfwReader == null) throw new IOException("No Worldfile found.");
-
-			if(refSys == null){
-				// if no crs is delivered try to read projection file:
-				refSys = readPrjFile(file);
-				if(refSys == null) throw new IOException("No projection file found.");
-			}
-			
-			BufferedImage img = ImageIO.read(file);
-			
-			// create Envelope
-			double width = (double) (img.getWidth() * tfwReader.getXPixelSize());
-			double height = (double) (img.getHeight() * (-tfwReader.getYPixelSize()));
-			double lowerLeft_x = (double) tfwReader.getXULC();
-			double lowerLeft_y = (double) tfwReader.getYULC() - height;
-			Envelope2D bbox = new Envelope2D(null, new Rectangle2D.Double(lowerLeft_x, lowerLeft_y, width, height));
-			
-			coverage = createGridCoverage(img, bbox, refSys);
-		}
-		else if(extension.equalsIgnoreCase(".png"))
-		{
-			
-			String[] postfixes = {"wld", "pgw", "pngw"};
-			// try to read Worldfile:
-			WorldFileReader tfwReader = null;
-			for (int i = 0; i < postfixes.length; i++) {
-				File prjFile = new File(fileNameWithoutExt + "." + postfixes[i]);
-				if(prjFile.exists()){
-					tfwReader = new WorldFileReader(prjFile);
-				}
-			}
-			if(tfwReader == null) throw new IOException("No Worldfile found.");
-			
-			if(refSys == null){
-				// if no crs is delivered try to read projection file:
-				refSys = readPrjFile(file);
-				if(refSys == null) throw new IOException("No projection file found.");
-			}
-			
-			BufferedImage img = ImageIO.read(file);
-			
-			// create Envelope
-			double width = (double) (img.getWidth() * tfwReader.getXPixelSize());
-			double height = (double) (img.getHeight() * (-tfwReader.getYPixelSize()));
-			double lowerLeft_x = (double) tfwReader.getXULC();
-			double lowerLeft_y = (double) tfwReader.getYULC() - height;
-			Envelope2D bbox = new Envelope2D(null, new Rectangle2D.Double(lowerLeft_x, lowerLeft_y, width, height));
-			
-			coverage = createGridCoverage(img, bbox, refSys);
-		}
-		else{
-			throw new IOException("Image type not supported. Supported formats are: \n" +
-					Arrays.toString(SUPPORTEDIMAGETYPES.values()));
-		}
-
-		return coverage;
-	}
-	
-	/**
-	 * Searches for a projection file (.prj) with the same name of 'file' 
-	 * tries to parse it.
-	 * 
-	 * 
-	 * @param file image file, not the real world file (will be searched)
-	 * @return 
-	 * @throws IOException 
-	 */
-	public static CoordinateReferenceSystem readPrjFile(File file) throws IOException
-	{
-		
-		CoordinateReferenceSystem refSys = null;
-		
-		String prjFilename = null;
-		int dotPos = file.getAbsolutePath().lastIndexOf(".");
-		prjFilename = file.getAbsolutePath().substring(0, dotPos) + ".prj";
-		
-		File prjFile = new File(prjFilename);
-		if(!prjFile.exists()) throw new IOException("No projection file found (.prj) for image '" + file.getName() + "'");
-		logger.debug("Loading .prj file: " + prjFile.getAbsolutePath());
-		
-		StringBuilder sb = new StringBuilder();
-		String content = null;
-		BufferedReader br = new BufferedReader(new FileReader(prjFile));
-		while((content = br.readLine()) != null)
-		{
-			sb.append(content);
-		}
-		
-		try {
-			refSys = CRS.parseWKT(sb.toString().trim());
-		} catch (FactoryException e) {
-			throw new IOException("Unable to parse prj-file: '" + prjFile.getName() + "'");
-		}
-		
-		return refSys;
-		
-	}
-	
-	
-	/**
-	 * Method for external use.
-	 * 
-	 * @param img
-	 * @param bbox
-	 * @param crs
-	 * @return
-	 */
-	public static GridCoverage2D createGridCoverage(BufferedImage img, Envelope2D bbox, CoordinateReferenceSystem crs)
-	{
-		bbox.setCoordinateReferenceSystem(crs);
-		return new GridCoverageFactory().create("", img, bbox);
-	}
-	
-	/**
-	 * Method for reading a GeoTIFF file.
-	 * 
-	 * @param file 
-	 * @param refSys if delivered, the coverage will be forced to use this crs
-	 * @return
-	 * @throws IOException
-	 * @throws FactoryException
-	 */
-	public static GridCoverage2D readGeoTiff(File file, CoordinateReferenceSystem refSys) throws IOException, FactoryException
-	{
-		GridCoverage2D coverage = null;
-		Hints hints = new Hints();
-		if(refSys != null)
-		{
-			hints.put(Hints.DEFAULT_COORDINATE_REFERENCE_SYSTEM, refSys);
-
-		}
-		// dont't use the EPSG-Factory because of wrong behaviour
-		hints.put(Hints.CRS_AUTHORITY_FACTORY, CRS.getAuthorityFactory(true));
-		
-		GeoTiffReader reader = new GeoTiffReader(file, hints);
-		
-		coverage = (GridCoverage2D) reader.read(null);
-		
-		return coverage;
-	}
-	
-	
-	/**
-	 * Loads CRS data from an EPSG database and creates descrptions for each one. 
-	 * 
-	 * @param pluginProps
-	 * @throws Exception
-	 */
-	public static void loadCRSData(Properties pluginProps)
-	{
-		String defaultcrsString = pluginProps.getProperty("default_crs_srid");
-		
-		crsDescriptions = new Vector<String>();
-		Set<String> supportedCodes = CRS.getSupportedCodes("EPSG");
-		CRSAuthorityFactory fac = CRS.getAuthorityFactory(false);
-		
-		for (Iterator iterator = supportedCodes.iterator(); iterator.hasNext();) {
-			String string = (String) iterator.next();
-			try {
-				InternationalString desc = fac.getDescriptionText("EPSG:" + string);
-
-				String description = desc.toString() + " [-EPSG:" + string + "-]";
-				
-				crsDescriptions.add(description);
-				
-				if(defaultcrsString != null && defaultcrsString.equalsIgnoreCase("EPSG:" + string)){
-					boolean isEastingFirst = Boolean.valueOf(pluginProps.getProperty("default_crs_eastingfirst"));
-					defaultSourceCRS = CRS.decode("EPSG:" + string, isEastingFirst);
-					defaultSourceCRSDescription = description;
-				}
-			} catch (NoSuchAuthorityCodeException e) {
-				if(!string.equalsIgnoreCase("WGS84(DD)")){
-					logger.error("Error while loading EPSG data: " + e.getMessage());
-				}
-			} catch (FactoryException e) {
-				logger.error("Error while loading EPSG data: " + e.getMessage());
-			}
-		}
-	}
-	
+    private static final Logger logger = Logger.getLogger(PluginOperations.class);
+    
+    // contains descriptions of all available CRS
+    static Vector<String> crsDescriptions;
+
+    // the standard native CRS of user images 
+    static CoordinateReferenceSystem defaultSourceCRS;
+    // description of 'defaultSourceCRS'
+    static String defaultSourceCRSDescription;
+    
+    
+    
+    public static enum SUPPORTEDIMAGETYPES {
+        tiff, tif, jpg, jpeg, bmp, png 
+    }
+
+    public static enum POSTFIXES_WORLDFILE {
+        wld, jgw, jpgw, pgw, pngw, tfw, tifw, bpw, bmpw, 
+    };
+    
+    /**
+     * Reprojects a GridCoverage to a given CRS.
+     * 
+     * @param coverage
+     * @param targetCrs
+     * @return destination
+     * @throws FactoryException 
+     * @throws NoSuchAuthorityCodeException 
+     */
+    public static GridCoverage2D reprojectCoverage(GridCoverage2D coverage,
+            CoordinateReferenceSystem targetCrs) throws NoSuchAuthorityCodeException, FactoryException {
+
+        // TODO: add category for NO_DATA values in coverage (transparency in
+        // image)
+        
+        GridCoverage2D destination = null;
+
+        DefaultProcessor processor = new DefaultProcessor(null);
+        ParameterValueGroup resampleParams = processor.getOperation("Resample")
+                .getParameters();
+
+        // set parameters
+        resampleParams.parameter("Source").setValue(coverage);
+        resampleParams.parameter("CoordinateReferenceSystem").setValue(
+                targetCrs);
+
+        // resample coverage with given parameters
+        destination = (GridCoverage2D) processor.doOperation(resampleParams);
+
+        return destination;
+    }
+
+    /**
+     * Creates a org.geotools.coverage.grid.GridCoverage2D from a given file. 
+     * 
+     * @param file
+     * @return
+     * @throws IOException 
+     * @throws Exception
+     */
+    public static GridCoverage2D createGridFromFile(File file, CoordinateReferenceSystem refSys) throws IOException{
+
+        GridCoverage2D coverage = null;
+        
+        if (!file.exists()) throw new FileNotFoundException("File not found.");
+
+        String extension = null;
+        String fileNameWithoutExt = null;
+        int dotPos = file.getAbsolutePath().lastIndexOf(".");
+        extension = file.getAbsolutePath().substring(dotPos);
+        fileNameWithoutExt = file.getAbsolutePath().substring(0, dotPos);
+
+        /*------- switch for file type -----------*/
+        if (extension.equalsIgnoreCase(".tif")
+                || extension.equalsIgnoreCase(".tiff"))
+        {
+            
+            // try to read GeoTIFF:
+            try{
+                coverage = readGeoTiff(file, refSys);
+                return coverage;
+            }catch (DataSourceException dse) {
+                if(!dse.getMessage().contains("Coordinate Reference System is not available")){
+                    dse.printStackTrace();
+                }
+            } catch (FactoryException facte) {
+                logger.fatal("Error while reading from GeoTIFF:", facte);
+                throw new IOException(facte);
+            }
+            
+            // file is no GeoTiff, searching for Worldfile and projection file: 
+            String[] postfixes = {"wld", "tfw", "tifw"};
+            // try to read Worldfile:
+            WorldFileReader tfwReader = null;
+            for (int i = 0; i < postfixes.length; i++) {
+                File prjFile = new File(fileNameWithoutExt + "." + postfixes[i]);
+                if(prjFile.exists()){
+                    tfwReader = new WorldFileReader(prjFile);
+                }
+            }
+            if(tfwReader == null){
+                throw new IOException("No Worldfile found.");
+            }
+            
+            if(refSys == null){
+                // if no crs is delivered try to read projection file:
+                refSys = readPrjFile(file);
+                if(refSys == null) throw new IOException("No projection file found.");
+            }
+            
+            BufferedImage img = ImageIO.read(file);
+            
+            // create Envelope
+            double width = (double) (img.getWidth() * tfwReader.getXPixelSize());
+            double height = (double) (img.getHeight() * (-tfwReader.getYPixelSize()));
+            double lowerLeft_x = (double) tfwReader.getXULC();
+            double lowerLeft_y = (double) tfwReader.getYULC() - height;
+            Envelope2D bbox = new Envelope2D(null, new Rectangle2D.Double(lowerLeft_x, lowerLeft_y, width, height));
+            
+            coverage = createGridCoverage(img, bbox, refSys);
+            
+        }
+        // 
+        else if (extension.equalsIgnoreCase(".jpg")
+                || extension.equalsIgnoreCase(".jpeg"))
+        {
+            String[] postfixes = {"wld", "jgw", "jpgw"};
+            // try to read Worldfile:
+            WorldFileReader tfwReader = null;
+            for (int i = 0; i < postfixes.length; i++) {
+                File prjFile = new File(fileNameWithoutExt + "." + postfixes[i]);
+                if(prjFile.exists()){
+                    tfwReader = new WorldFileReader(prjFile);
+                }
+            }
+            if(tfwReader == null) throw new IOException("No Worldfile found.");
+            
+            if(refSys == null){
+                // if no crs is delivered try to read projection file:
+                refSys = readPrjFile(file);
+                if(refSys == null) throw new IOException("No projection file found.");
+            }
+            
+            BufferedImage img = ImageIO.read(file);
+            
+            // create Envelope
+            double width = (double) (img.getWidth() * tfwReader.getXPixelSize());
+            double height = (double) (img.getHeight() * (-tfwReader.getYPixelSize()));
+            double lowerLeft_x = (double) tfwReader.getXULC();
+            double lowerLeft_y = (double) tfwReader.getYULC() - height;
+            Envelope2D bbox = new Envelope2D(null, new Rectangle2D.Double(lowerLeft_x, lowerLeft_y, width, height));
+            
+            coverage = createGridCoverage(img, bbox, refSys);
+            
+        }
+        else if(extension.equalsIgnoreCase(".bmp"))
+        {
+            String[] postfixes = {"wld", "bmpw", "bpw"};
+            // try to read Worldfile:
+            WorldFileReader tfwReader = null;
+            for (int i = 0; i < postfixes.length; i++) {
+                File prjFile = new File(fileNameWithoutExt + "." + postfixes[i]);
+                if(prjFile.exists()){
+                    tfwReader = new WorldFileReader(prjFile);
+                }
+            }
+            if(tfwReader == null) throw new IOException("No Worldfile found.");
+
+            if(refSys == null){
+                // if no crs is delivered try to read projection file:
+                refSys = readPrjFile(file);
+                if(refSys == null) throw new IOException("No projection file found.");
+            }
+            
+            BufferedImage img = ImageIO.read(file);
+            
+            // create Envelope
+            double width = (double) (img.getWidth() * tfwReader.getXPixelSize());
+            double height = (double) (img.getHeight() * (-tfwReader.getYPixelSize()));
+            double lowerLeft_x = (double) tfwReader.getXULC();
+            double lowerLeft_y = (double) tfwReader.getYULC() - height;
+            Envelope2D bbox = new Envelope2D(null, new Rectangle2D.Double(lowerLeft_x, lowerLeft_y, width, height));
+            
+            coverage = createGridCoverage(img, bbox, refSys);
+        }
+        else if(extension.equalsIgnoreCase(".png"))
+        {
+            
+            String[] postfixes = {"wld", "pgw", "pngw"};
+            // try to read Worldfile:
+            WorldFileReader tfwReader = null;
+            for (int i = 0; i < postfixes.length; i++) {
+                File prjFile = new File(fileNameWithoutExt + "." + postfixes[i]);
+                if(prjFile.exists()){
+                    tfwReader = new WorldFileReader(prjFile);
+                }
+            }
+            if(tfwReader == null) throw new IOException("No Worldfile found.");
+            
+            if(refSys == null){
+                // if no crs is delivered try to read projection file:
+                refSys = readPrjFile(file);
+                if(refSys == null) throw new IOException("No projection file found.");
+            }
+            
+            BufferedImage img = ImageIO.read(file);
+            
+            // create Envelope
+            double width = (double) (img.getWidth() * tfwReader.getXPixelSize());
+            double height = (double) (img.getHeight() * (-tfwReader.getYPixelSize()));
+            double lowerLeft_x = (double) tfwReader.getXULC();
+            double lowerLeft_y = (double) tfwReader.getYULC() - height;
+            Envelope2D bbox = new Envelope2D(null, new Rectangle2D.Double(lowerLeft_x, lowerLeft_y, width, height));
+            
+            coverage = createGridCoverage(img, bbox, refSys);
+        }
+        else{
+            throw new IOException("Image type not supported. Supported formats are: \n" +
+                    Arrays.toString(SUPPORTEDIMAGETYPES.values()));
+        }
+
+        return coverage;
+    }
+    
+    /**
+     * Searches for a projection file (.prj) with the same name of 'file' 
+     * tries to parse it.
+     * 
+     * 
+     * @param file image file, not the real world file (will be searched)
+     * @return 
+     * @throws IOException 
+     */
+    public static CoordinateReferenceSystem readPrjFile(File file) throws IOException
+    {
+        
+        CoordinateReferenceSystem refSys = null;
+        
+        String prjFilename = null;
+        int dotPos = file.getAbsolutePath().lastIndexOf(".");
+        prjFilename = file.getAbsolutePath().substring(0, dotPos) + ".prj";
+        
+        File prjFile = new File(prjFilename);
+        if(!prjFile.exists()) throw new IOException("No projection file found (.prj) for image '" + file.getName() + "'");
+        logger.debug("Loading .prj file: " + prjFile.getAbsolutePath());
+        
+        StringBuilder sb = new StringBuilder();
+        String content = null;
+        BufferedReader br = new BufferedReader(new FileReader(prjFile));
+        while((content = br.readLine()) != null)
+        {
+            sb.append(content);
+        }
+        
+        try {
+            refSys = CRS.parseWKT(sb.toString().trim());
+        } catch (FactoryException e) {
+            throw new IOException("Unable to parse prj-file: '" + prjFile.getName() + "'");
+        }
+        
+        return refSys;
+        
+    }
+    
+    
+    /**
+     * Method for external use.
+     * 
+     * @param img
+     * @param bbox
+     * @param crs
+     * @return
+     */
+    public static GridCoverage2D createGridCoverage(BufferedImage img, Envelope2D bbox, CoordinateReferenceSystem crs)
+    {
+        bbox.setCoordinateReferenceSystem(crs);
+        return new GridCoverageFactory().create("", img, bbox);
+    }
+    
+    /**
+     * Method for reading a GeoTIFF file.
+     * 
+     * @param file 
+     * @param refSys if delivered, the coverage will be forced to use this crs
+     * @return
+     * @throws IOException
+     * @throws FactoryException
+     */
+    public static GridCoverage2D readGeoTiff(File file, CoordinateReferenceSystem refSys) throws IOException, FactoryException
+    {
+        GridCoverage2D coverage = null;
+        Hints hints = new Hints();
+        if(refSys != null)
+        {
+            hints.put(Hints.DEFAULT_COORDINATE_REFERENCE_SYSTEM, refSys);
+
+        }
+        // dont't use the EPSG-Factory because of wrong behaviour
+        hints.put(Hints.CRS_AUTHORITY_FACTORY, CRS.getAuthorityFactory(true));
+        
+        GeoTiffReader reader = new GeoTiffReader(file, hints);
+        
+        coverage = (GridCoverage2D) reader.read(null);
+        
+        return coverage;
+    }
+    
+    
+    /**
+     * Loads CRS data from an EPSG database and creates descrptions for each one. 
+     * 
+     * @param pluginProps
+     * @throws Exception
+     */
+    public static void loadCRSData(Properties pluginProps)
+    {
+        String defaultcrsString = pluginProps.getProperty("default_crs_srid");
+        
+        crsDescriptions = new Vector<String>();
+        Set<String> supportedCodes = CRS.getSupportedCodes("EPSG");
+        CRSAuthorityFactory fac = CRS.getAuthorityFactory(false);
+        
+        for (Iterator iterator = supportedCodes.iterator(); iterator.hasNext();) {
+            String string = (String) iterator.next();
+            try {
+                InternationalString desc = fac.getDescriptionText("EPSG:" + string);
+
+                String description = desc.toString() + " [-EPSG:" + string + "-]";
+                
+                crsDescriptions.add(description);
+                
+                if(defaultcrsString != null && defaultcrsString.equalsIgnoreCase("EPSG:" + string)){
+                    boolean isEastingFirst = Boolean.valueOf(pluginProps.getProperty("default_crs_eastingfirst"));
+                    defaultSourceCRS = CRS.decode("EPSG:" + string, isEastingFirst);
+                    defaultSourceCRSDescription = description;
+                }
+            } catch (NoSuchAuthorityCodeException e) {
+                if(!string.equalsIgnoreCase("WGS84(DD)")){
+                    logger.error("Error while loading EPSG data: " + e.getMessage());
+                }
+            } catch (FactoryException e) {
+                logger.error("Error while loading EPSG data: " + e.getMessage());
+            }
+        }
+    }
+    
 }
