[Schmitzm-commits] r1799 - trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Nov 30 17:26:34 CET 2011


Author: alfonx
Date: 2011-11-30 17:26:33 +0100 (Wed, 30 Nov 2011)
New Revision: 1799

Modified:
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/XMapPane.java
Log:
Avoid NPE wenn beim Zoom bein CRS vorhanden ist

Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/XMapPane.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/XMapPane.java	2011-11-28 13:11:29 UTC (rev 1798)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/XMapPane.java	2011-11-30 16:26:33 UTC (rev 1799)
@@ -89,23 +89,27 @@
 import de.schmitzm.swing.event.MouseInputType;
 
 /**
- * The {@link XMapPane} class uses a Geotools {@link GTRenderer} to paint up to two {@link MapContext}s: a "local"
- * {@link MapContext} and a "background" {@link MapContext}. The idea is, that rendering a background layer made up of
+ * The {@link XMapPane} class uses a Geotools {@link GTRenderer} to paint up to
+ * two {@link MapContext}s: a "local" {@link MapContext} and a "background"
+ * {@link MapContext}. The idea is, that rendering a background layer made up of
  * e.g. OSM data, may take much longer than rendering local data.<br>
- * Every {@link MapContext} is rendered on a {@link Thread} of it's own. Starting/ cancelling these threads is done by
- * the {@link RenderingExecutor}.<br>
+ * Every {@link MapContext} is rendered on a {@link Thread} of it's own.
+ * Starting/ cancelling these threads is done by the {@link RenderingExecutor}.<br>
  * <br>
  * While the renderers are rending the map, a <br>
- * The {@link XMapPane} is based on schmitzm {@link JPanel}, so {@link #print(Graphics)} will automatically set the
- * background of components to pure white.
+ * The {@link XMapPane} is based on schmitzm {@link JPanel}, so
+ * {@link #print(Graphics)} will automatically set the background of components
+ * to pure white.
  * 
  * The XMapPane has a {@link MouseListener} that manages zooming.<br>
- * A logo/icon to float in the lower left corner may be set with {@link #setMapImage(BufferedImage)}<br>
+ * A logo/icon to float in the lower left corner may be set with
+ * {@link #setMapImage(BufferedImage)}<br>
  * 
- * It is recommended to execute {@link #dispose()} when not using the {@link XMapPane} instance anymore, as this way
- * resources are released faster.
+ * It is recommended to execute {@link #dispose()} when not using the
+ * {@link XMapPane} instance anymore, as this way resources are released faster.
  * 
- * @see SelectableXMapPane - an extension of {@link XMapPane} that supports selecting features.
+ * @see SelectableXMapPane - an extension of {@link XMapPane} that supports
+ *      selecting features.
  * 
  */
 public class XMapPane extends JPanel {
@@ -114,8 +118,8 @@
 	private CoordinateReferenceSystem forceCrs;
 
 	/**
-	 * //TODO still unused Allows to set a CRS that should be used for the {@link MapContext}, no matter which CRS the
-	 * bottom layer has.
+	 * //TODO still unused Allows to set a CRS that should be used for the
+	 * {@link MapContext}, no matter which CRS the bottom layer has.
 	 */
 	public void setForceCrs(CoordinateReferenceSystem crs) {
 		forceCrs = crs;
@@ -128,7 +132,8 @@
 	}
 
 	/**
-	 * Allows to set a CRS that should be used for the {@link MapContext}, no matter which CRS the bottom layer has.
+	 * Allows to set a CRS that should be used for the {@link MapContext}, no
+	 * matter which CRS the bottom layer has.
 	 */
 	public CoordinateReferenceSystem getForceCrs() {
 		return forceCrs;
@@ -142,11 +147,14 @@
 	}
 
 	/**
-	 * If {@link #maxExtend} is <code>null</code> the following rules are used to create a default maximum.
+	 * If {@link #maxExtend} is <code>null</code> the following rules are used
+	 * to create a default maximum.
 	 * <ul>
-	 * <li>Values &lt; 0 : don't grow to fit the monitors aspect ratio, no margin</li>
+	 * <li>Values &lt; 0 : don't grow to fit the monitors aspect ratio, no
+	 * margin</li>
 	 * <li>Values 0 : grow to fit the monitors aspect ratio, no margin</li>
-	 * <li>Values &gt; 0 : grow to fit the monitors aspect ratio, and add a relative margin</li>
+	 * <li>Values &gt; 0 : grow to fit the monitors aspect ratio, and add a
+	 * relative margin</li>
 	 * </ul>
 	 * **/
 	private double defaultMaxMapExtendMode = .05;
@@ -161,7 +169,8 @@
 	}
 
 	/**
-	 * If the {@link JPanel} is disabled, it shows nothing and the images are disposed.
+	 * If the {@link JPanel} is disabled, it shows nothing and the images are
+	 * disposed.
 	 */
 	@Override
 	public void setEnabled(boolean enabled) {
@@ -177,20 +186,21 @@
 	private final static Logger LOGGER = Logger.getLogger(XMapPane.class);
 
 	/**
-	 * A flag indicating whether the {@link XMapPane} is accepting repaints from the EDT. @see
-	 * {@link XMapPane#setPainting(boolean))
+	 * A flag indicating whether the {@link XMapPane} is accepting repaints from
+	 * the EDT. @see {@link XMapPane#setPainting(boolean))
 	 **/
 	private boolean acceptsRepaintCalls = true;
 
 	/**
-	 * Main {@link MapContext} that holds all layers that are rendered into the {@link #localImage} by the
-	 * {@link #localRenderer}
+	 * Main {@link MapContext} that holds all layers that are rendered into the
+	 * {@link #localImage} by the {@link #localRenderer}
 	 */
 	MapContext localContext;
 
 	/**
-	 * {@link MapContext} holding the background layers. Use it for layers that CAN take very long for rendering, like
-	 * layer from the Internet: WMS, WFS, OSM...<br>
+	 * {@link MapContext} holding the background layers. Use it for layers that
+	 * CAN take very long for rendering, like layer from the Internet: WMS, WFS,
+	 * OSM...<br>
 	 * <code>null</code> by default.
 	 * 
 	 * @see #setBgContext(MapContext)
@@ -199,8 +209,9 @@
 	MapContext bgContext;
 
 	/**
-	 * While threads are working, calls {@link XMapPane#updateFinalImage()} regularly and {@link #repaint()}. This
-	 * {@link Timer} is stopped when all renderers have finished.
+	 * While threads are working, calls {@link XMapPane#updateFinalImage()}
+	 * regularly and {@link #repaint()}. This {@link Timer} is stopped when all
+	 * renderers have finished.
 	 * 
 	 * @see INITIAL_REPAINT_DELAYAL
 	 * @see #REPEATING_REPAINT_DELAY
@@ -208,28 +219,31 @@
 	final private Timer repaintTimer;
 
 	/**
-	 * The initial delay in milliseconds until the {@link #finalImage} is updated the first time.
+	 * The initial delay in milliseconds until the {@link #finalImage} is
+	 * updated the first time.
 	 */
 	public static final int INITIAL_REPAINT_DELAY = 900;
 
 	/**
-	 * While the {@link #bgExecuter} and {@link #localExecuter} are rendering, the {@link #repaintTimer} is regularly
-	 * updating the {@link #finalImage} with previews.
+	 * While the {@link #bgExecuter} and {@link #localExecuter} are rendering,
+	 * the {@link #repaintTimer} is regularly updating the {@link #finalImage}
+	 * with previews.
 	 */
 	public static final int REPEATING_REPAINT_DELAY = 500;
 
 	/**
-	 * Default delay (milliseconds) before the map will be redrawn when resizing the pane. This is to avoid flickering
-	 * while drag-resizing.
+	 * Default delay (milliseconds) before the map will be redrawn when resizing
+	 * the pane. This is to avoid flickering while drag-resizing.
 	 * 
 	 * @see #resizeTimer
 	 */
 	public static final int DEFAULT_RESIZING_PAINT_DELAY = 600;
 
 	/**
-	 * This not-repeating {@link Timer} is re-started whenever the component is resized. That means => only if the
-	 * component is not resizing for {@link #DEFAULT_RESIZING_PAINT_DELAY} milliseconds, does the {@link XMapPane}
-	 * react.
+	 * This not-repeating {@link Timer} is re-started whenever the component is
+	 * resized. That means => only if the component is not resizing for
+	 * {@link #DEFAULT_RESIZING_PAINT_DELAY} milliseconds, does the
+	 * {@link XMapPane} react.
 	 */
 	private final Timer resizeTimer;
 
@@ -276,19 +290,22 @@
 	final static Font errorFont = new Font("Arial", Font.BOLD, 13);
 
 	/**
-	 * If last average last two renderings took more than that many ms, show the user a scaled preview
+	 * If last average last two renderings took more than that many ms, show the
+	 * user a scaled preview
 	 **/
 	private static final long PRESCALE_MINTIME = 230;
 
 	/**
-	 * The wait message painted into the map while rendering is going on on another thread.
+	 * The wait message painted into the map while rendering is going on on
+	 * another thread.
 	 * 
 	 * @see #addGadgets(Graphics2D, boolean)
 	 */
 	final String waitMsg = SwingUtil.R("WaitMess");
 
 	/**
-	 * Konvertiert die Maus-Koordinaten (relativ zum <code>JMapPane</code>) in Karten-Koordinaten.
+	 * Konvertiert die Maus-Koordinaten (relativ zum <code>JMapPane</code>) in
+	 * Karten-Koordinaten.
 	 * 
 	 * @param e
 	 *            Maus-Ereignis
@@ -299,7 +316,9 @@
 			try {
 				return ((MapMouseEvent) e).getMapPosition();
 			} catch (final Exception err) {
-				LOGGER.error("return ((GeoMouseEvent) e).getMapCoordinate(null).toPoint2D();", err);
+				LOGGER.error(
+						"return ((GeoMouseEvent) e).getMapCoordinate(null).toPoint2D();",
+						err);
 			}
 
 		// aktuelle Geo-Position ueber Transformation des JMapPane berechnen
@@ -313,16 +332,19 @@
 			final AffineTransform at = xMapPane.getScreenToWorld();
 			if (at != null) {
 				Point2D transformed = at.transform(e.getPoint(), null);
-				return new DirectPosition2D(xMapPane.getMapContext().getCoordinateReferenceSystem(),
-						transformed.getX(), transformed.getY());
+				return new DirectPosition2D(xMapPane.getMapContext()
+						.getCoordinateReferenceSystem(), transformed.getX(),
+						transformed.getY());
 			}
 			return null;
 		}
-		throw new IllegalArgumentException("MouseEvent has to be of instance MapMouseEvent or come from an XMapPane");
+		throw new IllegalArgumentException(
+				"MouseEvent has to be of instance MapMouseEvent or come from an XMapPane");
 	}
 
 	/**
-	 * Listens to changes of the "background" {@link MapContext} and triggers repaints where needed.
+	 * Listens to changes of the "background" {@link MapContext} and triggers
+	 * repaints where needed.
 	 */
 	private final MapLayerListListener bgContextListener = new MapLayerListListener() {
 
@@ -357,30 +379,33 @@
 	};
 
 	/**
-	 * This {@link RenderingExecutor} manages the creation and cancellation of up to one {@link Thread} for rendering
-	 * the {@link #localContext}.
+	 * This {@link RenderingExecutor} manages the creation and cancellation of
+	 * up to one {@link Thread} for rendering the {@link #localContext}.
 	 */
 	private final RenderingExecutor localExecuter = new RenderingExecutor(this);
 
 	/**
-	 * This {@link RenderingExecutor} manages the creation and cancellation of up to one {@link Thread} for rendering
-	 * the {@link #bgContext}.
+	 * This {@link RenderingExecutor} manages the creation and cancellation of
+	 * up to one {@link Thread} for rendering the {@link #bgContext}.
 	 */
 	protected RenderingExecutor bgExecuter;
 
 	/**
-	 * The {@link #localRenderer} for the {@link #localContext} uses this {@link Image}.
+	 * The {@link #localRenderer} for the {@link #localContext} uses this
+	 * {@link Image}.
 	 */
 	private BufferedImage localImage;
 
 	/**
-	 * The {@link #bgRenderer} for the {@link #bgContext} uses this {@link Image}.
+	 * The {@link #bgRenderer} for the {@link #bgContext} uses this
+	 * {@link Image}.
 	 */
 	private BufferedImage bgImage;
 
 	/**
-	 * This {@link Image} is a merge of the {@link #bgImage}, {@link #localImage} and
-	 * {@link #addGadgets(Graphics2D, boolean)}. It is updated with {@link #updateFinalImage()} and used for painting in
+	 * This {@link Image} is a merge of the {@link #bgImage},
+	 * {@link #localImage} and {@link #addGadgets(Graphics2D, boolean)}. It is
+	 * updated with {@link #updateFinalImage()} and used for painting in
 	 * {@link #paintComponent(Graphics)}
 	 */
 	private BufferedImage finalImage;
@@ -396,7 +421,8 @@
 	private LogoPosition mapImagePos = LogoPosition.BOTTOMRIGHT;
 
 	/**
-	 * Listens to each layer in the local {@link MapContext} for changes and triggers repaints.
+	 * Listens to each layer in the local {@link MapContext} for changes and
+	 * triggers repaints.
 	 */
 	protected MapLayerListener bgMapLayerListener = new MapLayerAdapter() {
 
@@ -417,27 +443,30 @@
 	};
 
 	/**
-	 * A flag indicating if dispose() was already called. If true, then further use of this {@link SelectableXMapPane}
-	 * is undefined.
+	 * A flag indicating if dispose() was already called. If true, then further
+	 * use of this {@link SelectableXMapPane} is undefined.
 	 */
 	private boolean disposed = false;
 
 	/**
-	 * While dragging, the {@link #updateFinalImage()} method is translating the cached images while setting it
-	 * together.
+	 * While dragging, the {@link #updateFinalImage()} method is translating the
+	 * cached images while setting it together.
 	 **/
 	private final Point imageOrigin = new Point(0, 0);
 	/**
-	 * For every rendering thread started, {@link GTUtil#createGTRenderer(MapContext)} is called to create a new
-	 * renderer. These Java2D rendering hints are passed to the {@link GTRenderer}. The java2dHints are the same for all
-	 * renderers (bg and local).
+	 * For every rendering thread started,
+	 * {@link GTUtil#createGTRenderer(MapContext)} is called to create a new
+	 * renderer. These Java2D rendering hints are passed to the
+	 * {@link GTRenderer}. The java2dHints are the same for all renderers (bg
+	 * and local).
 	 */
 	private RenderingHints java2dHints;
 
 	protected LabelCache labelCache = new LabelCacheImpl();
 
 	/**
-	 * Listens to changes of the "local" {@link MapContext} and triggers repaints where needed.
+	 * Listens to changes of the "local" {@link MapContext} and triggers
+	 * repaints where needed.
 	 */
 	private final MapLayerListListener localContextListener = new MapLayerListListener() {
 
@@ -478,8 +507,9 @@
 	};
 
 	/**
-	 * Listens to each layer in the local {@link MapContext} for changes and triggers repaints. We don't have to listen
-	 * layerChanged, because that is already done in {@link #localContextListener}
+	 * Listens to each layer in the local {@link MapContext} for changes and
+	 * triggers repaints. We don't have to listen layerChanged, because that is
+	 * already done in {@link #localContextListener}
 	 */
 	protected MapLayerListener localMapLayerListener = new MapLayerAdapter() {
 
@@ -511,8 +541,10 @@
 	protected Envelope mapArea = null;
 
 	/**
-	 * A flag set it {@link #setMapArea(Envelope)} to indicated the {@link #paintComponent(Graphics)} method, that the
-	 * image on-screen is associated with {@link #oldMapArea} and may hence be scaled for a quick preview.<br>
+	 * A flag set it {@link #setMapArea(Envelope)} to indicated the
+	 * {@link #paintComponent(Graphics)} method, that the image on-screen is
+	 * associated with {@link #oldMapArea} and may hence be scaled for a quick
+	 * preview.<br>
 	 * The flag is reset
 	 **/
 	private boolean mapAreaChanged = false;
@@ -523,13 +555,15 @@
 	private Color mapBackgroundColor = null;
 
 	/**
-	 * A flag indicating that the shown image is invalid and needs to be re-rendered.
+	 * A flag indicating that the shown image is invalid and needs to be
+	 * re-rendered.
 	 */
 	protected boolean mapImageInvalid = true;
 
 	/**
-	 * Holds a flag for each layer, whether it is regarded or ignored on {@link #SELECT_TOP}, {@link #SELECT_ALL} and
-	 * {@link #SELECT_ONE_FROM_TOP} actions.
+	 * Holds a flag for each layer, whether it is regarded or ignored on
+	 * {@link #SELECT_TOP}, {@link #SELECT_ALL} and {@link #SELECT_ONE_FROM_TOP}
+	 * actions.
 	 */
 	final protected HashMap<MapLayer, Boolean> mapLayerSelectable = new HashMap<MapLayer, Boolean>();
 
@@ -538,7 +572,8 @@
 	 */
 	protected Vector<JMapPaneListener> mapPaneListeners = new Vector<JMapPaneListener>();
 	/**
-	 * If not <code>null</code>, the {@link XMapPane} will not allow to zoom/pan out of that area
+	 * If not <code>null</code>, the {@link XMapPane} will not allow to zoom/pan
+	 * out of that area
 	 **/
 	private Envelope maxExtend = null;
 	private Double maxZoomScale = Double.MIN_VALUE;
@@ -546,17 +581,20 @@
 	private Double minZoomScale = Double.MAX_VALUE;
 
 	/**
-	 * We store the old mapArea for a moment to use it for the "quick scaled preview" in case of ZoomOut
+	 * We store the old mapArea for a moment to use it for the
+	 * "quick scaled preview" in case of ZoomOut
 	 **/
 	protected Envelope oldMapArea = null;
 
 	/**
-	 * We store the old transform for a moment to use it for the "quick scaled preview" in case of ZoomIn
+	 * We store the old transform for a moment to use it for the
+	 * "quick scaled preview" in case of ZoomIn
 	 **/
 	protected AffineTransform oldScreenToWorld = null;
 
 	/**
-	 * A flag indicating, that the image size has changed and the buffered images are not big enough any more
+	 * A flag indicating, that the image size has changed and the buffered
+	 * images are not big enough any more
 	 **/
 	protected boolean paneResized = true;
 
@@ -565,21 +603,25 @@
 	// ** if 0, no quick preview will be shown **/
 	// private int quickPreviewHint = 0;
 
-	private Map<Object, Object> rendererHints = GTUtil.getDefaultGTRendererHints(getLocalRenderer());
+	private Map<Object, Object> rendererHints = GTUtil
+			.getDefaultGTRendererHints(getLocalRenderer());
 
 	/**
-	 * If set to <code>true</code>, the {@link #startRenderThreadsTimer} will start rendering {@link Thread}s
+	 * If set to <code>true</code>, the {@link #startRenderThreadsTimer} will
+	 * start rendering {@link Thread}s
 	 **/
 	private volatile Boolean requestStartRendering = false;
 
 	/**
-	 * Transformation zwischen Fenster-Koordinaten und Karten-Koordinaten (lat/lon)
+	 * Transformation zwischen Fenster-Koordinaten und Karten-Koordinaten
+	 * (lat/lon)
 	 */
 	protected AffineTransform screenToWorld = null;
 
 	/**
-	 * The flag {@link #requestStartRendering} can be set to true by events. This {@link Timer} checks the flag
-	 * regularly and starts one renderer thread.
+	 * The flag {@link #requestStartRendering} can be set to true by events.
+	 * This {@link Timer} checks the flag regularly and starts one renderer
+	 * thread.
 	 */
 	final private Timer startRenderThreadsTimer;
 
@@ -588,18 +630,21 @@
 	/**
 	 * This {@link MouseListener} is managing all zoom related tasks
 	 */
-	private final XMapPaneMouseListener xMapPaneMouseListener = new XMapPaneMouseListener(this);
+	private final XMapPaneMouseListener xMapPaneMouseListener = new XMapPaneMouseListener(
+			this);
 
 	/** Is set if a renderer has an error **/
 	protected ArrayList<Exception> renderingErrors = new ArrayList<Exception>();
 
 	/**
-	 * If <code>true</code>, then rendering exceptions are rendererd into the map pane
+	 * If <code>true</code>, then rendering exceptions are rendererd into the
+	 * map pane
 	 **/
 	private boolean showExceptions = false;
 
 	/**
-	 * Change the render language of this XMapPane when the translation is changed.
+	 * Change the render language of this XMapPane when the translation is
+	 * changed.
 	 */
 	private final PropertyChangeListener activeLanguageChangeListener = new PropertyChangeListener() {
 
@@ -623,14 +668,16 @@
 	 * full constructor extending JPanel
 	 * 
 	 * @param rendererHints
-	 *            may be <code>null</code>. Otherwise a {@link Map<Object, Object>} of {@link RenderingHints} to
-	 *            override the default from {@link GTUtil#getDefaultGTRendererHints(GTRenderer)}
+	 *            may be <code>null</code>. Otherwise a {@link Map<Object,
+	 *            Object>} of {@link RenderingHints} to override the default
+	 *            from {@link GTUtil#getDefaultGTRendererHints(GTRenderer)}
 	 * 
 	 * @param localContext
-	 *            The main {@link MapContext} to use. If <code>null</code>, an empty {@link DefaultMapContext} will be
-	 *            created.
+	 *            The main {@link MapContext} to use. If <code>null</code>, an
+	 *            empty {@link DefaultMapContext} will be created.
 	 */
-	public XMapPane(final MapContext localContext_, final Map<Object, Object> rendererHints) {
+	public XMapPane(final MapContext localContext_,
+			final Map<Object, Object> rendererHints) {
 
 		super(true);
 
@@ -661,41 +708,42 @@
 		setTool(XMapPaneTool.ZOOM_IN);
 
 		/*
-		 * We use a Timer object to avoid rendering delays and flickering when the user is drag-resizing the parent
-		 * container of this map pane.
+		 * We use a Timer object to avoid rendering delays and flickering when
+		 * the user is drag-resizing the parent container of this map pane.
 		 * 
-		 * Using a ComponentListener doesn't work because, unlike a JFrame, the pane receives a stream of events during
-		 * drag-resizing.
+		 * Using a ComponentListener doesn't work because, unlike a JFrame, the
+		 * pane receives a stream of events during drag-resizing.
 		 */
-		resizeTimer = new Timer(DEFAULT_RESIZING_PAINT_DELAY, new ActionListener() {
+		resizeTimer = new Timer(DEFAULT_RESIZING_PAINT_DELAY,
+				new ActionListener() {
 
-			public void actionPerformed(final ActionEvent e) {
-				if (!isWellDefined())
-					return;
+					public void actionPerformed(final ActionEvent e) {
+						if (!isWellDefined())
+							return;
 
-				// LOGGER.debug("resizeTimer performed");
+						// LOGGER.debug("resizeTimer performed");
 
-				// final Rectangle bounds = getMapPaneSize();
-				//
-				// System.out.println("\n\ntimer performs with bounds = "
-				// + bounds);
+						// final Rectangle bounds = getMapPaneSize();
+						//
+						// System.out.println("\n\ntimer performs with bounds = "
+						// + bounds);
 
-				// final Envelope geoMapArea = tranformWindowToGeo(
-				// bounds.x, bounds.y, bounds.x + bounds.width,
-				// bounds.y + bounds.height);
+						// final Envelope geoMapArea = tranformWindowToGeo(
+						// bounds.x, bounds.y, bounds.x + bounds.width,
+						// bounds.y + bounds.height);
 
-				paneResized = true;
-				if (!setMapArea(getMapArea())) {
-					// It's important to request new rendering here.
-					// setMapArea only returns true and only calls
-					// requestStartRendering if the maparea has changed.
-					// But if the component is resized, the maparea
-					// doesn't have to change.
-					requestStartRendering();
-				}
+						paneResized = true;
+						if (!setMapArea(getMapArea())) {
+							// It's important to request new rendering here.
+							// setMapArea only returns true and only calls
+							// requestStartRendering if the maparea has changed.
+							// But if the component is resized, the maparea
+							// doesn't have to change.
+							requestStartRendering();
+						}
 
-			}
-		});
+					}
+				});
 		resizeTimer.setRepeats(false);
 
 		this.addComponentListener(new ComponentAdapter() {
@@ -706,7 +754,8 @@
 			public void componentResized(final ComponentEvent e) {
 
 				// Seems to be called twice with the same size..
-				if (oldVisibleRect != null && oldVisibleRect.equals(getMapPaneSize())) {
+				if (oldVisibleRect != null
+						&& oldVisibleRect.equals(getMapPaneSize())) {
 					// LOGGER.debug("skipping resize.");
 					return;
 				}
@@ -725,7 +774,8 @@
 
 			@Override
 			public void actionPerformed(final ActionEvent e) {
-				if ((!localExecuter.isRunning()) && (bgExecuter != null && !bgExecuter.isRunning())) {
+				if ((!localExecuter.isRunning())
+						&& (bgExecuter != null && !bgExecuter.isRunning())) {
 					repaintTimer.stop();
 				} else {
 					updateFinalImage();
@@ -739,7 +789,8 @@
 		repaintTimer.setRepeats(true);
 
 		/*
-		 * Setting up the startRenderThreadsTimer. This Timer starts automatically.
+		 * Setting up the startRenderThreadsTimer. This Timer starts
+		 * automatically.
 		 */
 		startRenderThreadsTimer = new Timer(100, new ActionListener() {
 
@@ -765,8 +816,8 @@
 	}
 
 	/**
-	 * Propagiert ein Ereignis an alle angeschlossenen Listener. Es gibt verschiedene implementationen von
-	 * {@link XMapPaneEvent}
+	 * Propagiert ein Ereignis an alle angeschlossenen Listener. Es gibt
+	 * verschiedene implementationen von {@link XMapPaneEvent}
 	 * 
 	 * @param e
 	 *            Ereignis
@@ -787,12 +838,15 @@
 	}
 
 	/**
-	 * Korrigiert den {@link Envelope} aka {@code mapArea} auf die beste erlaubte Flaeche damit die
-	 * Massstabsbeschaenkungen noch eingehalten werden, FALLS der uebergeben Envelope nicht schon gueltig sein sollte.<br>
-	 * Since 21. April 09: Before thecalculation starts, the aspect ratio is corrected. This change implies, that
-	 * setMapArea() will most of the time not allow setting to a wrong aspectRatio.<br/>
-	 * This method also checks, that the extend of the mapArea is greater 0! (A BBOX of 0 width and height can result
-	 * froma point layer with just one point and will later crash the WIndowsToMapTransformation)
+	 * Korrigiert den {@link Envelope} aka {@code mapArea} auf die beste
+	 * erlaubte Flaeche damit die Massstabsbeschaenkungen noch eingehalten
+	 * werden, FALLS der uebergeben Envelope nicht schon gueltig sein sollte.<br>
+	 * Since 21. April 09: Before thecalculation starts, the aspect ratio is
+	 * corrected. This change implies, that setMapArea() will most of the time
+	 * not allow setting to a wrong aspectRatio.<br/>
+	 * This method also checks, that the extend of the mapArea is greater 0! (A
+	 * BBOX of 0 width and height can result froma point layer with just one
+	 * point and will later crash the WIndowsToMapTransformation)
 	 * 
 	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
@@ -812,8 +866,9 @@
 		Envelope newArea = null;
 
 		/**
-		 * Correct the aspect Ratio before we check the rest. Otherwise we might easily fail. We allow to grow here,
-		 * because we don't check against the maxExtend
+		 * Correct the aspect Ratio before we check the rest. Otherwise we might
+		 * easily fail. We allow to grow here, because we don't check against
+		 * the maxExtend
 		 */
 		final Rectangle curPaintArea = getMapPaneSize();
 
@@ -845,8 +900,10 @@
 
 		if (newArea == null) {
 
-			final Coordinate ll = new Coordinate(centerX - newWidth2, centerY - newHeight2);
-			final Coordinate ur = new Coordinate(centerX + newWidth2, centerY + newHeight2);
+			final Coordinate ll = new Coordinate(centerX - newWidth2, centerY
+					- newHeight2);
+			final Coordinate ur = new Coordinate(centerX + newWidth2, centerY
+					+ newHeight2);
 
 			newArea = new Envelope(ll, ur);
 		}
@@ -858,9 +915,12 @@
 		/*
 		 * If a maxAllowedExtend is set, we have to honour that...
 		 */
-		while (maxAllowedExtend != null && !maxAllowedExtend.contains(newArea) && newArea != null && !newArea.isNull()
-				&& !Double.isNaN(newArea.getMinX()) && !Double.isNaN(newArea.getMaxX())
-				&& !Double.isNaN(newArea.getMinY()) && !Double.isNaN(newArea.getMaxY())) // Due to Double precision
+		while (maxAllowedExtend != null && !maxAllowedExtend.contains(newArea)
+				&& newArea != null && !newArea.isNull()
+				&& !Double.isNaN(newArea.getMinX())
+				&& !Double.isNaN(newArea.getMaxX())
+				&& !Double.isNaN(newArea.getMinY())
+				&& !Double.isNaN(newArea.getMaxY())) // Due to Double precision
 		// problems, this may
 		// iterate for ever
 		{
@@ -873,43 +933,53 @@
 
 			// Exceeds top? Move down and maybe cut
 			if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) {
-				final double divY = newArea.getMaxY() - maxAllowedExtend.getMaxY();
+				final double divY = newArea.getMaxY()
+						- maxAllowedExtend.getMaxY();
 				// LOGGER.debug("Moving area down by " + divY);
 
-				newArea = new Envelope(new Coordinate(newArea.getMinX(), newArea.getMinY() - divY), new Coordinate(
+				newArea = new Envelope(new Coordinate(newArea.getMinX(),
+						newArea.getMinY() - divY), new Coordinate(
 						newArea.getMaxX(), newArea.getMaxY() - divY));
 
 				if (newArea.getMinY() < maxAllowedExtend.getMinY()) {
 					// LOGGER.debug("Now it exeeds the bottom border.. cut!");
 					// And cut the bottom if it moved out of the area
-					newArea = new Envelope(new Coordinate(newArea.getMinX(), maxAllowedExtend.getMinY()),
-							new Coordinate(newArea.getMaxX(), newArea.getMaxY()));
+					newArea = new Envelope(new Coordinate(newArea.getMinX(),
+							maxAllowedExtend.getMinY()), new Coordinate(
+							newArea.getMaxX(), newArea.getMaxY()));
 
 					// LOGGER.debug("and fix aspect ratio");
 
-					newArea = JTSUtil.fixAspectRatio(getMapPaneSize(),
-							new ReferencedEnvelope(newArea, env.getCoordinateReferenceSystem()), false);
+					newArea = JTSUtil.fixAspectRatio(
+							getMapPaneSize(),
+							new ReferencedEnvelope(newArea, env
+									.getCoordinateReferenceSystem()), false);
 				}
 			}
 
 			// Exceeds bottom? Move up and maybe cut
 			if (newArea.getMinY() < maxAllowedExtend.getMinY()) {
-				final double divY = newArea.getMinY() - maxAllowedExtend.getMinY();
+				final double divY = newArea.getMinY()
+						- maxAllowedExtend.getMinY();
 				// LOGGER.debug("Moving area up by " + divY);
 
-				newArea = new Envelope(new Coordinate(newArea.getMinX(), newArea.getMinY() - divY), new Coordinate(
+				newArea = new Envelope(new Coordinate(newArea.getMinX(),
+						newArea.getMinY() - divY), new Coordinate(
 						newArea.getMaxX(), newArea.getMaxY() - divY));
 
 				if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) {
 					// LOGGER.debug("Now it exeeds the top border.. cut!");
 					// And cut the bottom if it moved out of the area
-					newArea = new Envelope(new Coordinate(newArea.getMinX(), newArea.getMinY()), new Coordinate(
+					newArea = new Envelope(new Coordinate(newArea.getMinX(),
+							newArea.getMinY()), new Coordinate(
 							newArea.getMaxX(), maxAllowedExtend.getMaxY()));
 
 					// LOGGER.debug("and fix aspect ratio");
 
-					newArea = JTSUtil.fixAspectRatio(getMapPaneSize(),
-							new ReferencedEnvelope(newArea, env.getCoordinateReferenceSystem()), false);
+					newArea = JTSUtil.fixAspectRatio(
+							getMapPaneSize(),
+							new ReferencedEnvelope(newArea, env
+									.getCoordinateReferenceSystem()), false);
 				}
 			}
 
@@ -917,22 +987,28 @@
 			if (newArea.getMaxX() > maxAllowedExtend.getMaxX()) {
 
 				// Move left..
-				final double divX = newArea.getMaxX() - maxAllowedExtend.getMaxX();
+				final double divX = newArea.getMaxX()
+						- maxAllowedExtend.getMaxX();
 				// LOGGER.debug("Moving area left by " + divX);
 
-				newArea = new Envelope(new Coordinate(newArea.getMinX() - divX, newArea.getMinY()), new Coordinate(
-						newArea.getMaxX() - divX, newArea.getMaxY()));
+				newArea = new Envelope(new Coordinate(newArea.getMinX() - divX,
+						newArea.getMinY()), new Coordinate(newArea.getMaxX()
+						- divX, newArea.getMaxY()));
 
 				if (newArea.getMinX() < maxAllowedExtend.getMinX()) {
 					// LOGGER.debug("Now it exeeds the left border.. cut!");
 					// And cut the left if it moved out of the area
-					newArea = new Envelope(new Coordinate(maxAllowedExtend.getMinX(), newArea.getMinY()),
+					newArea = new Envelope(
+							new Coordinate(maxAllowedExtend.getMinX(),
+									newArea.getMinY()),
 							new Coordinate(newArea.getMaxX(), newArea.getMaxY()));
 
 					// LOGGER.debug("and fix aspect ratio");
 
-					newArea = JTSUtil.fixAspectRatio(getMapPaneSize(),
-							new ReferencedEnvelope(newArea, env.getCoordinateReferenceSystem()), false);
+					newArea = JTSUtil.fixAspectRatio(
+							getMapPaneSize(),
+							new ReferencedEnvelope(newArea, env
+									.getCoordinateReferenceSystem()), false);
 				}
 			}
 
@@ -940,32 +1016,39 @@
 			if (newArea.getMinX() < maxAllowedExtend.getMinX()) {
 
 				// Move right..
-				final double divX = newArea.getMinX() - maxAllowedExtend.getMinX();
+				final double divX = newArea.getMinX()
+						- maxAllowedExtend.getMinX();
 				// LOGGER.debug("Moving area right by " + divX);
 
-				newArea = new Envelope(new Coordinate(newArea.getMinX() - divX, newArea.getMinY()), new Coordinate(
-						newArea.getMaxX() - divX, newArea.getMaxY()));
+				newArea = new Envelope(new Coordinate(newArea.getMinX() - divX,
+						newArea.getMinY()), new Coordinate(newArea.getMaxX()
+						- divX, newArea.getMaxY()));
 
 				if (newArea.getMaxX() > maxAllowedExtend.getMaxX()) {
 					// LOGGER.debug("Now it exeeds the right border.. cut!");
 					// And cut the left if it moved out of the area
-					newArea = new Envelope(new Coordinate(newArea.getMinX(), newArea.getMinY()), new Coordinate(
+					newArea = new Envelope(new Coordinate(newArea.getMinX(),
+							newArea.getMinY()), new Coordinate(
 							maxAllowedExtend.getMaxX(), newArea.getMaxY()));
 
 					// LOGGER.debug("and fix aspect ratio");
 
-					newArea = JTSUtil.fixAspectRatio(getMapPaneSize(),
-							new ReferencedEnvelope(newArea, env.getCoordinateReferenceSystem()), false);
+					newArea = JTSUtil.fixAspectRatio(
+							getMapPaneSize(),
+							new ReferencedEnvelope(newArea, env
+									.getCoordinateReferenceSystem()), false);
 				}
 			}
 
 		}
 
-		return new ReferencedEnvelope(newArea, env.getCoordinateReferenceSystem());
+		return new ReferencedEnvelope(newArea,
+				env.getCoordinateReferenceSystem());
 	}
 
 	/**
-	 * Should be called when the {@link JMapPane} is not needed no more to help the GarbageCollector
+	 * Should be called when the {@link JMapPane} is not needed no more to help
+	 * the GarbageCollector
 	 * 
 	 * Removes all {@link JMapPaneListener}s that are registered
 	 * 
@@ -996,7 +1079,9 @@
 				try {
 					Thread.sleep(200);
 				} catch (final InterruptedException e) {
-					LOGGER.warn("while XMapPane we are waiting for the localExcutor to stop", e);
+					LOGGER.warn(
+							"while XMapPane we are waiting for the localExcutor to stop",
+							e);
 				}
 			}
 			if (localExecuter.isRunning()) {
@@ -1022,16 +1107,20 @@
 	}
 
 	/**
-	 * Draws a rectangle in XOR mode from the origin at {@link #startPos} to the given point. All in screen coordinates.
+	 * Draws a rectangle in XOR mode from the origin at {@link #startPos} to the
+	 * given point. All in screen coordinates.
 	 */
-	protected void drawRectangle(final Graphics graphics, final Point startPos, final Point e) {
+	protected void drawRectangle(final Graphics graphics, final Point startPos,
+			final Point e) {
 		drawRectangle(graphics, startPos, e, Color.WHITE, false);
 	}
 
 	/**
-	 * Draws a rectangle in XOR mode from the origin at {@link #startPos} to the given point. All in screen coordinates.
+	 * Draws a rectangle in XOR mode from the origin at {@link #startPos} to the
+	 * given point. All in screen coordinates.
 	 */
-	protected void drawRectangle(final Graphics graphics, final Point startPos, final Point e, Color color, boolean fill) {
+	protected void drawRectangle(final Graphics graphics, final Point startPos,
+			final Point e, Color color, boolean fill) {
 
 		if (!isWellDefined())
 			return;
@@ -1058,9 +1147,10 @@
 	}
 
 	/**
-	 * Diretly paints scaled preview into the {@link SelectableXMapPane}. Used to give the user something to look at
-	 * while we are rendering. Method should be called after {@link #setMapArea(Envelope)} has been set to the new
-	 * mapArea and transform has been reset.<br>
+	 * Diretly paints scaled preview into the {@link SelectableXMapPane}. Used
+	 * to give the user something to look at while we are rendering. Method
+	 * should be called after {@link #setMapArea(Envelope)} has been set to the
+	 * new mapArea and transform has been reset.<br>
 	 * 
 	 * @param g
 	 *            Graphics2D to paint the preview into
@@ -1082,7 +1172,8 @@
 			final Rectangle visibleArea = getMapPaneSize();
 
 			// Calculate the oldMapArea in the current WindowCoordinates:
-			final Envelope oldMapWindow = tranformGeoToWindow(oldMapArea.getMinX(), oldMapArea.getMinY(),
+			final Envelope oldMapWindow = tranformGeoToWindow(
+					oldMapArea.getMinX(), oldMapArea.getMinY(),
 					oldMapArea.getMaxX(), oldMapArea.getMaxY());
 
 			final int xx1 = (int) Math.round(oldMapWindow.getMinX());
@@ -1092,16 +1183,21 @@
 
 			graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
 					RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
-			graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
-			graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
+			graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+					RenderingHints.VALUE_ANTIALIAS_OFF);
+			graphics.setRenderingHint(RenderingHints.KEY_RENDERING,
+					RenderingHints.VALUE_RENDER_SPEED);
 
-			graphics.drawImage(getPreFinalImage(), xx1, yy1, xx2, yy2, (int) visibleArea.getMinX(),
-					(int) visibleArea.getMinY(), (int) visibleArea.getMaxX(), (int) visibleArea.getMaxY(),
+			graphics.drawImage(getPreFinalImage(), xx1, yy1, xx2, yy2,
+					(int) visibleArea.getMinX(), (int) visibleArea.getMinY(),
+					(int) visibleArea.getMaxX(), (int) visibleArea.getMaxY(),
 					getMapBackgroundColor(), null);
 
-			final Rectangle painedArea = new Rectangle(xx1, yy1, xx2 - xx1, yy2 - yy1);
+			final Rectangle painedArea = new Rectangle(xx1, yy1, xx2 - xx1, yy2
+					- yy1);
 
-			SwingUtil.clearAround(graphics, painedArea, visibleArea, getMapBackgroundColor());
+			SwingUtil.clearAround(graphics, painedArea, visibleArea,
+					getMapBackgroundColor());
 
 			addGadgets(graphics, true);
 		} catch (Exception e) {
@@ -1127,7 +1223,8 @@
 	 */
 	private Image getBgImage() {
 		if (bgImage == null) {
-			bgImage = new BufferedImage(getMapPaneSize().width, getMapPaneSize().height, IMAGETYPE);
+			bgImage = new BufferedImage(getMapPaneSize().width,
+					getMapPaneSize().height, IMAGETYPE);
 			SwingUtil.clearImage(finalImage, getMapBackgroundColor());
 		}
 
@@ -1145,7 +1242,8 @@
 		//
 		if (finalImage == null) {
 			// Rectangle curPaintArea = getMapPaneSize();
-			finalImage = new BufferedImage(getMapPaneSize().width, getMapPaneSize().height, IMAGETYPE);
+			finalImage = new BufferedImage(getMapPaneSize().width,
+					getMapPaneSize().height, IMAGETYPE);
 			SwingUtil.clearImage(finalImage, getMapBackgroundColor());
 
 			// requestStartRendering();
@@ -1159,7 +1257,8 @@
 	private BufferedImage getLocalImage() {
 
 		if (localImage == null) {
-			localImage = new BufferedImage(getMapPaneSize().width, getMapPaneSize().height, IMAGETYPE_withAlpha);
+			localImage = new BufferedImage(getMapPaneSize().width,
+					getMapPaneSize().height, IMAGETYPE_withAlpha);
 			SwingUtil.clearImage(localImage, getMapBackgroundColor());
 		}
 
@@ -1200,17 +1299,20 @@
 		// TODO is needed at all, this should go to setMapArea maybe
 		if (localContext.getCoordinateReferenceSystem() == null)
 			try {
-				localContext.setCoordinateReferenceSystem(GeoImportUtil.getDefaultCRS());
+				localContext.setCoordinateReferenceSystem(GeoImportUtil
+						.getDefaultCRS());
 			} catch (final Exception e) {
 				throw new RuntimeException("setting context CRS:", e);
 			}
 
-		return new ReferencedEnvelope(mapArea, localContext.getCoordinateReferenceSystem());
+		return new ReferencedEnvelope(mapArea,
+				localContext.getCoordinateReferenceSystem());
 	}
 
 	/**
-	 * Returns the background {@link Color} of the map pane. If not set, the methods looks for a parent component and
-	 * will use its background color. If no parent component is available, WHITE is returned.
+	 * Returns the background {@link Color} of the map pane. If not set, the
+	 * methods looks for a parent component and will use its background color.
+	 * If no parent component is available, WHITE is returned.
 	 **/
 	public Color getMapBackgroundColor() {
 		if (mapBackgroundColor == null) {
@@ -1223,7 +1325,8 @@
 	}
 
 	/**
-	 * Get the BufferedImage to use as a flaoting icon in the lower right corner.
+	 * Get the BufferedImage to use as a flaoting icon in the lower right
+	 * corner.
 	 * 
 	 * @return <code>null</code> if the feature is deactivated.
 	 */
@@ -1232,9 +1335,11 @@
 	}
 
 	/**
-	 * Returns the evelope of the viewable area. The JMapPane will never show anything outside of this extend. If this
-	 * has been set to <code>null</code> via {@link #setMaxExtend(Envelope)}, it tries to return quickly the context's
-	 * bounds. It it takes to long to determine the context bounds, <code>null</code> is returned.
+	 * Returns the evelope of the viewable area. The JMapPane will never show
+	 * anything outside of this extend. If this has been set to
+	 * <code>null</code> via {@link #setMaxExtend(Envelope)}, it tries to return
+	 * quickly the context's bounds. It it takes to long to determine the
+	 * context bounds, <code>null</code> is returned.
 	 * 
 	 * @param maxExtend
 	 *            <code>null</code> to not have this restriction.
@@ -1253,7 +1358,8 @@
 				return null;
 			}
 
-			return JTSUtil.fixAspectRatio(getMapPaneSize(), addDefaultMargin(layerBounds), true);
+			return JTSUtil.fixAspectRatio(getMapPaneSize(),
+					addDefaultMargin(layerBounds), true);
 
 		}
 		return JTSUtil.checkNotZeroArea(maxExtend);
@@ -1282,8 +1388,9 @@
 			if (SPECIAL_LINES_LAYER_ID.equals(layer.getTitle()))
 				continue;
 			/*
-			 * fs = layer.getFeatureSource(); sourceCrs = fs.getSchema().getDefaultGeometry() .getCoordinateSystem();
-			 * env = new ReferencedEnvelope(fs.getBounds(), sourceCrs);
+			 * fs = layer.getFeatureSource(); sourceCrs =
+			 * fs.getSchema().getDefaultGeometry() .getCoordinateSystem(); env =
+			 * new ReferencedEnvelope(fs.getBounds(), sourceCrs);
 			 */
 
 			env = layer.getBounds();
@@ -1292,7 +1399,8 @@
 			} else {
 				try {
 					sourceCrs = env.getCoordinateReferenceSystem();
-					if ((sourceCrs != null) && crs != null && !CRS.equalsIgnoreMetadata(sourceCrs, crs)) {
+					if ((sourceCrs != null) && crs != null
+							&& !CRS.equalsIgnoreMetadata(sourceCrs, crs)) {
 						env = env.transform(crs, true);
 					}
 
@@ -1310,7 +1418,8 @@
 					result = env;
 				} else {
 					try {
-						result.expandToInclude(env.transform(result.getCoordinateReferenceSystem(), true));
+						result.expandToInclude(env.transform(
+								result.getCoordinateReferenceSystem(), true));
 					} catch (Exception e) {
 						LOGGER.error(e);
 					}
@@ -1323,8 +1432,8 @@
 	}
 
 	/**
-	 * Retuns the maximum allowed zoom scale. This is the smaller number value of the two. Defaults to {@link Double}
-	 * .MIN_VALUE
+	 * Retuns the maximum allowed zoom scale. This is the smaller number value
+	 * of the two. Defaults to {@link Double} .MIN_VALUE
 	 * 
 	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
@@ -1333,8 +1442,8 @@
 	}
 
 	/**
-	 * Retuns the minimum allowed zoom scale. This is the bigger number value of the two. Defaults to {@link Double}
-	 * .MAX_VALUE
+	 * Retuns the minimum allowed zoom scale. This is the bigger number value of
+	 * the two. Defaults to {@link Double} .MAX_VALUE
 	 * 
 	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
@@ -1355,10 +1464,11 @@
 	}
 
 	/**
-	 * Liefert eine affine Transformation, um von den Fenster-Koordinaten in die Karten-Koordinaten (Lat/Lon)
-	 * umzurechnen.
+	 * Liefert eine affine Transformation, um von den Fenster-Koordinaten in die
+	 * Karten-Koordinaten (Lat/Lon) umzurechnen.
 	 * 
-	 * @return eine Kopie der aktuellen Transformation; <code>null</code> wenn noch keine Karte angezeigt wird
+	 * @return eine Kopie der aktuellen Transformation; <code>null</code> wenn
+	 *         noch keine Karte angezeigt wird
 	 */
 	public AffineTransform getScreenToWorld() {
 		if (screenToWorld == null)
@@ -1384,16 +1494,17 @@
 	}
 
 	/**
-	 * A flag indicating if dispose() has already been called. If true, then further use of this
-	 * {@link SelectableXMapPane} is undefined.
+	 * A flag indicating if dispose() has already been called. If true, then
+	 * further use of this {@link SelectableXMapPane} is undefined.
 	 */
 	private boolean isDisposed() {
 		return disposed;
 	}
 
 	/**
-	 * Returns whether a layer is regarded or ignored on {@link #SELECT_TOP}, {@link #SELECT_ALL} and
-	 * {@link #SELECT_ONE_FROM_TOP} actions. Returns <code>true</code> if the selectability has not been defined.
+	 * Returns whether a layer is regarded or ignored on {@link #SELECT_TOP},
+	 * {@link #SELECT_ALL} and {@link #SELECT_ONE_FROM_TOP} actions. Returns
+	 * <code>true</code> if the selectability has not been defined.
 	 * 
 	 * @param layer
 	 *            a layer
@@ -1404,8 +1515,8 @@
 	}
 
 	/**
-	 * Return <code>true</code> if a CRS and a {@link #mapArea} are set and the {@link XMapPane} is visible and has
-	 * bounds set.
+	 * Return <code>true</code> if a CRS and a {@link #mapArea} are set and the
+	 * {@link XMapPane} is visible and has bounds set.
 	 */
 	public boolean isWellDefined() {
 		try {
@@ -1511,11 +1622,13 @@
 		// Inform listeners that rendering has completed if have no requests to
 		// start again
 		if (!requestStartRendering)
-			fireMapPaneEvent(new MapRenderingStateEvent(this, RenderingState.ON_HOLD));
+			fireMapPaneEvent(new MapRenderingStateEvent(this,
+					RenderingState.ON_HOLD));
 	}
 
 	/**
-	 * Liefert die Anzahl der Einheiten, die ein Bildschirm-Pixel darstellt. Die Einheit ist die Grundeinheit des CRS
+	 * Liefert die Anzahl der Einheiten, die ein Bildschirm-Pixel darstellt. Die
+	 * Einheit ist die Grundeinheit des CRS
 	 */
 	public double getScale() {
 
@@ -1536,19 +1649,22 @@
 	}
 
 	/**
-	 * Liefert den OGC ScaleDenominator der der aktuellen Skale entspricht. Wenn es einen Fehler gibt 0.0
+	 * Liefert den OGC ScaleDenominator der der aktuellen Skale entspricht. Wenn
+	 * es einen Fehler gibt 0.0
 	 */
 	public double getScaleDenominator() {
 
 		if (getScale() != 0.0)
-			return RendererUtilities.calculateOGCScale(getMapArea(), getWidth(), null);
+			return RendererUtilities.calculateOGCScale(getMapArea(),
+					getWidth(), null);
 		else
 			return 0.0;
 
 	}
 
 	/**
-	 * Called by the {@link RenderingExecutor} when rendering has been completed.
+	 * Called by the {@link RenderingExecutor} when rendering has been
+	 * completed.
 	 * 
 	 * @param l
 	 *            long ms the rendering took
@@ -1572,12 +1688,14 @@
 		// Inform listeners that rendering has completed if have no requests to
 		// start again
 		if (!requestStartRendering)
-			fireMapPaneEvent(new MapRenderingStateEvent(this, RenderingState.ON_HOLD));
+			fireMapPaneEvent(new MapRenderingStateEvent(this,
+					RenderingState.ON_HOLD));
 	}
 
 	/**
-	 * Called by the {@linkplain XMapPane.RenderingTask} when rendering failed. Publishes a {@linkplain XMapPaneEvent}
-	 * of type {@code MapPaneEvent.Type.RENDERING_STOPPED} to listeners.
+	 * Called by the {@linkplain XMapPane.RenderingTask} when rendering failed.
+	 * Publishes a {@linkplain XMapPaneEvent} of type
+	 * {@code MapPaneEvent.Type.RENDERING_STOPPED} to listeners.
 	 * 
 	 * @param renderingError
 	 *            The error that occured during rendering
@@ -1587,8 +1705,9 @@
 	public void onRenderingFailed(final Exception renderingError) {
 
 		// Store the exceptions so we can show it to the user:
-		if (!(renderingError instanceof java.lang.IllegalArgumentException && renderingError.getMessage().equals(
-				"Argument \"sourceCRS\" should not be null.")))
+		if (!(renderingError instanceof java.lang.IllegalArgumentException && renderingError
+				.getMessage().equals(
+						"Argument \"sourceCRS\" should not be null.")))
 			this.renderingErrors.add(renderingError);
 		if (renderingErrors.size() > 3)
 			renderingErrors.remove(0);
@@ -1602,7 +1721,8 @@
 		// Inform listeners that rendering has completed if have no requests to
 		// start again
 		if (!requestStartRendering)
-			fireMapPaneEvent(new MapRenderingStateEvent(this, RenderingState.ON_HOLD));
+			fireMapPaneEvent(new MapRenderingStateEvent(this,
+					RenderingState.ON_HOLD));
 	}
 
 	@Override
@@ -1637,8 +1757,10 @@
 			// If the new mapArea and the oldMapArea intersect, we can draw some
 			// quick scaled preview to make the user feel that something is
 			// happening.
-			if (lastRenderingDuration > PRESCALE_MINTIME && mapAreaChanged && oldMapArea != null
-					&& getMapArea().intersects(oldMapArea) && !getMapArea().equals(oldMapArea) && !paneResized) {
+			if (lastRenderingDuration > PRESCALE_MINTIME && mapAreaChanged
+					&& oldMapArea != null
+					&& getMapArea().intersects(oldMapArea)
+					&& !getMapArea().equals(oldMapArea) && !paneResized) {
 
 				mapAreaChanged = false;
 
@@ -1665,8 +1787,8 @@
 	}
 
 	/**
-	 * If {@link #blinkRenderer} is not <code>null</code>, the blinking features are rendered into the
-	 * {@link Graphics2D}
+	 * If {@link #blinkRenderer} is not <code>null</code>, the blinking features
+	 * are rendered into the {@link Graphics2D}
 	 */
 	private void blink(Graphics2D g2d) {
 		if (blinkRenderer != null) {
@@ -1676,11 +1798,13 @@
 	}
 
 	/**
-	 * Heavily works on releasing all resources related to the four {@link Image}s used to cache the results of the
-	 * different renderers.<br>
-	 * In November 2009 i had some memory leaking problems with {@link XMapPane} . The resources of the buffered images
-	 * were never released. It seem to be important to call the GC right after flushing the images.<br>
-	 * Hence this method may take a while, because it calls the GC up to four times.
+	 * Heavily works on releasing all resources related to the four
+	 * {@link Image}s used to cache the results of the different renderers.<br>
+	 * In November 2009 i had some memory leaking problems with {@link XMapPane}
+	 * . The resources of the buffered images were never released. It seem to be
+	 * important to call the GC right after flushing the images.<br>
+	 * Hence this method may take a while, because it calls the GC up to four
+	 * times.
 	 */
 	private void disposeImages() {
 
@@ -1780,10 +1904,12 @@
 	}
 
 	/**
-	 * Calculate the affine transforms used to convert between world and pixel coordinates. The calculations here are
-	 * very basic and assume a cartesian reference system.
+	 * Calculate the affine transforms used to convert between world and pixel
+	 * coordinates. The calculations here are very basic and assume a cartesian
+	 * reference system.
 	 * <p>
-	 * Tne transform is calculated such that {@code envelope} will be centred in the display
+	 * Tne transform is calculated such that {@code envelope} will be centred in
+	 * the display
 	 * 
 	 * @param envelope
 	 *            the current map extent (world coordinates)
@@ -1799,10 +1925,11 @@
 		if (mapArea == null)
 			return;
 
-		final ReferencedEnvelope refMapEnv = new ReferencedEnvelope(mapArea, getMapContext()
-				.getCoordinateReferenceSystem());
+		final ReferencedEnvelope refMapEnv = new ReferencedEnvelope(mapArea,
+				getMapContext().getCoordinateReferenceSystem());
 
-		worldToScreen = RendererUtilities.worldToScreenTransform(refMapEnv, getMapPaneSize());
+		worldToScreen = RendererUtilities.worldToScreenTransform(refMapEnv,
+				getMapPaneSize());
 
 		try {
 			if (worldToScreen != null)
@@ -1895,34 +2022,41 @@
 	 * Set the new map area.
 	 * 
 	 * @param newMapArea
-	 * @return <code>true</code> if the mapArea has been changed and a repaint has been triggered.
+	 * @return <code>true</code> if the mapArea has been changed and a repaint
+	 *         has been triggered.
 	 */
 	public boolean setMapArea(final Envelope newMapArea) {
 		if (newMapArea == null)
 			return false;
 		if (getMapContext().getCoordinateReferenceSystem() == null)
 			return false;
-		return setMapArea(new ReferencedEnvelope(newMapArea, getMapContext().getCoordinateReferenceSystem()));
+		return setMapArea(new ReferencedEnvelope(newMapArea, getMapContext()
+				.getCoordinateReferenceSystem()));
 	}
 
 	/**
 	 * Set the new map area.
 	 * 
 	 * @param newMapArea
-	 * @return <code>true</code> if the mapArea has been changed and a repaint has been triggered.
+	 * @return <code>true</code> if the mapArea has been changed and a repaint
+	 *         has been triggered.
 	 */
 	public boolean setMapArea(final ReferencedEnvelope newMapArea) {
 
-		if (newMapArea == null || bestAllowedMapArea(newMapArea).equals(mapArea)) {
+		if (newMapArea == null
+				|| bestAllowedMapArea(newMapArea).equals(mapArea)) {
 			// No change.. no need to repaint
 			return false;
 		}
 
 		// Testing, whether NaN or Infinity are used in the newMapArea
-		if (newMapArea.isNull() || Double.isInfinite(newMapArea.getMaxX()) || Double.isInfinite(newMapArea.getMaxY())
-				|| Double.isInfinite(newMapArea.getMinX()) || Double.isInfinite(newMapArea.getMinY())) {
+		if (newMapArea.isNull() || Double.isInfinite(newMapArea.getMaxX())
+				|| Double.isInfinite(newMapArea.getMaxY())
+				|| Double.isInfinite(newMapArea.getMinX())
+				|| Double.isInfinite(newMapArea.getMinY())) {
 			// No change.. ugly new values
-			LOGGER.warn("setMapArea has been called with newArea = " + newMapArea);
+			LOGGER.warn("setMapArea has been called with newArea = "
+					+ newMapArea);
 			return false;
 		}
 
@@ -1932,11 +2066,15 @@
 		if (mapArea != null) {
 			final double tolX = mapArea.getWidth() / 1000.;
 			final double tolY = mapArea.getHeight() / 1000.;
-			if ((candNew.getMinX() - tolX < mapArea.getMinX()) && (mapArea.getMinX() < candNew.getMinX() + tolX)
-					&& (candNew.getMaxX() - tolX < mapArea.getMaxX()) && (mapArea.getMaxX() < candNew.getMaxX() + tolX)
+			if ((candNew.getMinX() - tolX < mapArea.getMinX())
+					&& (mapArea.getMinX() < candNew.getMinX() + tolX)
+					&& (candNew.getMaxX() - tolX < mapArea.getMaxX())
+					&& (mapArea.getMaxX() < candNew.getMaxX() + tolX)
 
-					&& (candNew.getMinY() - tolY < mapArea.getMinY()) && (mapArea.getMinY() < candNew.getMinY() + tolY)
-					&& (candNew.getMaxY() - tolY < mapArea.getMaxY()) && (mapArea.getMaxY() < candNew.getMaxY() + tolY)
+					&& (candNew.getMinY() - tolY < mapArea.getMinY())
+					&& (mapArea.getMinY() < candNew.getMinY() + tolY)
+					&& (candNew.getMaxY() - tolY < mapArea.getMaxY())
+					&& (mapArea.getMaxY() < candNew.getMaxY() + tolY)
 
 			) {
 				// The two mapAreas only differ my 1/1000th.. ignore
@@ -1951,10 +2089,12 @@
 		resetTransforms();
 
 		if (localContext != null) {
-			localContext.setAreaOfInterest(mapArea, localContext.getCoordinateReferenceSystem());
+			localContext.setAreaOfInterest(mapArea,
+					localContext.getCoordinateReferenceSystem());
 		}
 		if (bgContext != null) {
-			bgContext.setAreaOfInterest(mapArea, localContext.getCoordinateReferenceSystem());
+			bgContext.setAreaOfInterest(mapArea,
+					localContext.getCoordinateReferenceSystem());
 		}
 
 		mapAreaChanged = true;
@@ -1987,16 +2127,18 @@
 	}
 
 	/**
-	 * Sets whether a layer is regarded or ignored on {@link #SELECT_TOP}, {@link #SELECT_ALL} and
-	 * {@link #SELECT_ONE_FROM_TOP} actions.
+	 * Sets whether a layer is regarded or ignored on {@link #SELECT_TOP},
+	 * {@link #SELECT_ALL} and {@link #SELECT_ONE_FROM_TOP} actions.
 	 * 
 	 * @param layer
 	 *            a layer
 	 * @param selectable
-	 *            if {@code false} the layer is ignored during the upper mentioned actions. If <code>null</code>, the
-	 *            default (true) will be used.
+	 *            if {@code false} the layer is ignored during the upper
+	 *            mentioned actions. If <code>null</code>, the default (true)
+	 *            will be used.
 	 */
-	public void setMapLayerSelectable(final MapLayer layer, final Boolean selectable) {
+	public void setMapLayerSelectable(final MapLayer layer,
+			final Boolean selectable) {
 		if (selectable == null)
 			mapLayerSelectable.remove(layer);
 		else
@@ -2004,7 +2146,8 @@
 	}
 
 	/**
-	 * Defines an evelope of the viwable area. The JMapPane will never show anything outside of this extend.
+	 * Defines an evelope of the viwable area. The JMapPane will never show
+	 * anything outside of this extend.
 	 * 
 	 * @param maxExtend
 	 *            <code>null</code> to not have this restriction.
@@ -2014,11 +2157,13 @@
 	}
 
 	/**
-	 * Set the maximum allowed zoom scale. This is the smaller number value of the two. If <code>null</code> is passed,
-	 * Double.MINVALUE are used which mean there is no restriction.
+	 * Set the maximum allowed zoom scale. This is the smaller number value of
+	 * the two. If <code>null</code> is passed, Double.MINVALUE are used which
+	 * mean there is no restriction.
 	 */
 	public void setMaxZoomScale(final Double maxZoomScale) {
-		this.maxZoomScale = maxZoomScale == null ? Double.MIN_VALUE : maxZoomScale;
+		this.maxZoomScale = maxZoomScale == null ? Double.MIN_VALUE
+				: maxZoomScale;
 	}
 
 	// /** Stored the time used for the last real rendering in ms. **/
@@ -2030,19 +2175,22 @@
 	private StreamingRenderer blinkRenderer;
 
 	/**
-	 * Set the minimum (nearest) allowed zoom scale. This is the bigger number value of the two. If <code>null</code> is
-	 * passed, Double.MAXVALUE are used which mean there is no restriction.
+	 * Set the minimum (nearest) allowed zoom scale. This is the bigger number
+	 * value of the two. If <code>null</code> is passed, Double.MAXVALUE are
+	 * used which mean there is no restriction.
 	 * 
 	 * 
 	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public void setMinZoomScale(final Double minZoomScale) {
-		this.minZoomScale = minZoomScale == null ? Double.MAX_VALUE : minZoomScale;
+		this.minZoomScale = minZoomScale == null ? Double.MAX_VALUE
+				: minZoomScale;
 	}
 
 	/**
-	 * If <code>true</code>, allow the {@link XMapPane} to process #repaint() requests. Otherwise the map will not paint
-	 * anything and not start any rendering {@link Thread}s.
+	 * If <code>true</code>, allow the {@link XMapPane} to process #repaint()
+	 * requests. Otherwise the map will not paint anything and not start any
+	 * rendering {@link Thread}s.
 	 */
 	public void setPainting(final boolean b) {
 		acceptsRepaintCalls = b;
@@ -2060,7 +2208,8 @@
 	}
 
 	/**
-	 * Configure the {@link XMapPaneTool} that active on the map. Passing <code>null</code> will set the NO_ACTION tool.
+	 * Configure the {@link XMapPaneTool} that active on the map. Passing
+	 * <code>null</code> will set the NO_ACTION tool.
 	 */
 	public void setTool(XMapPaneTool tool) {
 		if (tool == null)
@@ -2071,10 +2220,12 @@
 	}
 
 	/**
-	 * Returns a {@code new Rectangle(getWidth(),getHeight()}, because the complete map should be rendered, even a part
-	 * of the map is currently not visible due to an scrollpane.<br>
-	 * This method is used instead of {@link #getMapPaneSize()}, because of rendering problems when the map pane is
-	 * hidden partly by a scroll pane (in ISDSS).
+	 * Returns a {@code new Rectangle(getWidth(),getHeight()}, because the
+	 * complete map should be rendered, even a part of the map is currently not
+	 * visible due to an scrollpane.<br>
+	 * This method is used instead of {@link #getMapPaneSize()}, because of
+	 * rendering problems when the map pane is hidden partly by a scroll pane
+	 * (in ISDSS).
 	 */
 	public Rectangle getMapPaneSize() {
 		// return getMapPaneSize();
@@ -2103,7 +2254,8 @@
 		// Inform listeners that rendering has completed if have no requests to
 		// start again
 		if (!requestStartRendering)
-			fireMapPaneEvent(new MapRenderingStateEvent(this, RenderingState.RENDERING));
+			fireMapPaneEvent(new MapRenderingStateEvent(this,
+					RenderingState.RENDERING));
 
 		final Rectangle curPaintArea = getMapPaneSize();
 
@@ -2123,8 +2275,9 @@
 			getLocalRenderer().setJava2DHints(getJava2dHints());
 			getLocalRenderer().setRendererHints(getRendererHints());
 
-			final boolean submitted = localExecuter.submit(getMapArea(), curPaintArea, (Graphics2D) getLocalImage()
-					.getGraphics(), getLocalRenderer());
+			final boolean submitted = localExecuter.submit(getMapArea(),
+					curPaintArea, (Graphics2D) getLocalImage().getGraphics(),
+					getLocalRenderer());
 			if (submitted)
 				repaintTimer.restart();
 			else
@@ -2152,7 +2305,8 @@
 	 * @param py
 	 *            Y-Koordinate der BIS-Position
 	 */
-	public Envelope tranformGeoToWindow(final double ox, final double oy, final double px, final double py) {
+	public Envelope tranformGeoToWindow(final double ox, final double oy,
+			final double px, final double py) {
 		final AffineTransform at = getWorldToScreenTransform();
 		Point2D geoO;
 		geoO = at.transform(new Point2D.Double(ox, oy), null);
@@ -2169,7 +2323,8 @@
 	 *            Y-Koordinate der VON-Position
 	 */
 	public Point2D tranformGeoToWindow(final double x, final double y) {
-		return getWorldToScreenTransform().transform(new Point2D.Double(x, y), null);
+		return getWorldToScreenTransform().transform(new Point2D.Double(x, y),
+				null);
 	}
 
 	/**
@@ -2184,7 +2339,8 @@
 	 * @param py
 	 *            Y-Koordinate der BIS-Position
 	 */
-	public Envelope tranformWindowToGeo(final int ox, final int oy, final int px, final int py) {
+	public Envelope tranformWindowToGeo(final int ox, final int oy,
+			final int px, final int py) {
 		final AffineTransform at = getScreenToWorld();
 		if (at == null)
 			return null;
@@ -2194,17 +2350,20 @@
 		// Mmmmm... don't really understand why its x,x,y,y
 		// return new Envelope(geoO.getX(), geoP.getX(), geoO.getY(),
 		// geoP.getY());
-		return new Envelope(new Coordinate(geoO.getX(), geoO.getY()), new Coordinate(geoP.getX(), geoP.getY()));
+		return new Envelope(new Coordinate(geoO.getX(), geoO.getY()),
+				new Coordinate(geoP.getX(), geoP.getY()));
 	}
 
 	/**
-	 * Will update the cursor. If all rendering is finished also stops the {@link #repaintTimer}
+	 * Will update the cursor. If all rendering is finished also stops the
+	 * {@link #repaintTimer}
 	 */
 	public void updateCursor() {
 
 		// if the renderers have stopped, also stop the timer that is updating
 		// the final image
-		if (bgExecuter != null && bgExecuter.isRunning() || localExecuter.isRunning()) {
+		if (bgExecuter != null && bgExecuter.isRunning()
+				|| localExecuter.isRunning()) {
 			setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
 			return;
 		} else {
@@ -2226,18 +2385,21 @@
 	}
 
 	/**
-	 * The renderers are all rendering into their own {@link Image}s. This method combines all images to one
-	 * {@link #finalImage}. The {@link #repaintTimer} is calling this method regularely to update the
+	 * The renderers are all rendering into their own {@link Image}s. This
+	 * method combines all images to one {@link #finalImage}. The
+	 * {@link #repaintTimer} is calling this method regularely to update the
 	 * {@link #finalImage} even if the renderers are still working.
 	 */
 	synchronized protected Image updateFinalImage() {
 
 		// Render the two map images first, into the preFinalImage
 		if (bgExecuter != null) {
-			final Graphics2D preFinalG = (Graphics2D) getPreFinalImage().getGraphics();
+			final Graphics2D preFinalG = (Graphics2D) getPreFinalImage()
+					.getGraphics();
 			preFinalG.setBackground(getMapBackgroundColor());
 
-			preFinalG.drawImage(getBgImage(), 0, 0, getMapBackgroundColor(), null);
+			preFinalG.drawImage(getBgImage(), 0, 0, getMapBackgroundColor(),
+					null);
 
 			// // Draw the local layers image
 			preFinalG.drawImage(getLocalImage(), 0, 0, null);
@@ -2249,12 +2411,15 @@
 
 		final Graphics2D finalG = getFinalImage().createGraphics();
 		finalG.setBackground(getMapBackgroundColor());
-		finalG.drawImage(getPreFinalImage(), getImageOrigin().x, getImageOrigin().y, getMapBackgroundColor(), null);
+		finalG.drawImage(getPreFinalImage(), getImageOrigin().x,
+				getImageOrigin().y, getMapBackgroundColor(), null);
 
 		// When panning, we have to clear the area around the image
-		final Rectangle painedArea = new Rectangle(getImageOrigin().x, getImageOrigin().y, getFinalImage().getWidth(),
-				getFinalImage().getHeight());
-		SwingUtil.clearAround(finalG, painedArea, getMapPaneSize(), getMapBackgroundColor());
+		final Rectangle painedArea = new Rectangle(getImageOrigin().x,
+				getImageOrigin().y, getFinalImage().getWidth(), getFinalImage()
+						.getHeight());
+		SwingUtil.clearAround(finalG, painedArea, getMapPaneSize(),
+				getMapBackgroundColor());
 
 		addGadgets(finalG, false);
 
@@ -2264,13 +2429,14 @@
 	}
 
 	/**
-	 * Paints some optional stuff into the given {@link Graphics2D}. Usually called as the last layer when
-	 * {@link #updateFinalImage()}
+	 * Paints some optional stuff into the given {@link Graphics2D}. Usually
+	 * called as the last layer when {@link #updateFinalImage()}
 	 * 
 	 * @param forceWait
-	 *            if <code>true</code>, a Wait-message will be painted even though the rendering threads may not yet
-	 *            have started. If <code>false</code>, it will only depend on {@link #localExecuter.isRunning} and
-	 *            #bgExecuter.isRunning
+	 *            if <code>true</code>, a Wait-message will be painted even
+	 *            though the rendering threads may not yet have started. If
+	 *            <code>false</code>, it will only depend on
+	 *            {@link #localExecuter.isRunning} and #bgExecuter.isRunning
 	 */
 	private void addGadgets(final Graphics2D graphics, final boolean forceWait) {
 
@@ -2299,7 +2465,8 @@
 		int y = 17;
 
 		// If the rendering process is still running, indicate this is the image
-		if (forceWait || bgExecuter != null && bgExecuter.isRunning() || localExecuter.isRunning()) {
+		if (forceWait || bgExecuter != null && bgExecuter.isRunning()
+				|| localExecuter.isRunning()) {
 
 			y += 8;
 
@@ -2346,20 +2513,24 @@
 	}
 
 	/**
-	 * Sets the {@link #mapArea} to best possibly present the given features. If only one single point is given, the
-	 * window is moved over the point.
+	 * Sets the {@link #mapArea} to best possibly present the given features. If
+	 * only one single point is given, the window is moved over the point.
 	 * 
 	 * @param features
 	 *            if <code>null</code> or size==0, the function doesn nothing.
 	 * 
-	 * @return <code>true</code> if the {@link #mapArea} has changed and rendering has been triggered.
+	 * @return <code>true</code> if the {@link #mapArea} has changed and
+	 *         rendering has been triggered.
 	 */
-	public boolean zoomTo(final FeatureCollection<SimpleFeatureType, SimpleFeature> features) {
+	public boolean zoomTo(
+			final FeatureCollection<SimpleFeatureType, SimpleFeature> features) {
 
 		// if (!isWellDefined()) return;
 
-		final CoordinateReferenceSystem mapCRS = getMapContext().getCoordinateReferenceSystem();
-		final CoordinateReferenceSystem fCRS = features.getSchema().getCoordinateReferenceSystem();
+		final CoordinateReferenceSystem mapCRS = getMapContext()
+				.getCoordinateReferenceSystem();
+		final CoordinateReferenceSystem fCRS = features.getSchema()
+				.getCoordinateReferenceSystem();
 
 		ReferencedEnvelope _mapArea;
 		if (mapArea == null)
@@ -2379,7 +2550,8 @@
 			// bit'
 			final SimpleFeature singleFeature = features.iterator().next();
 
-			if (((Geometry) singleFeature.getDefaultGeometry()).getCoordinates().length > 1) {
+			if (((Geometry) singleFeature.getDefaultGeometry())
+					.getCoordinates().length > 1) {
 				// System.out.println("Zoomed to only pne poylgon");
 				// Poly
 				// TODO max width vs. height
@@ -2406,8 +2578,10 @@
 				}
 			}
 
-			final Coordinate newLeftBottom = new Coordinate(centre.x - width / 2., centre.y - height / 2.);
-			final Coordinate newTopRight = new Coordinate(centre.x + width / 2., centre.y + height / 2.);
+			final Coordinate newLeftBottom = new Coordinate(centre.x - width
+					/ 2., centre.y - height / 2.);
+			final Coordinate newTopRight = new Coordinate(
+					centre.x + width / 2., centre.y + height / 2.);
 
 			final Envelope newMapArea = new Envelope(newLeftBottom, newTopRight);
 
@@ -2432,11 +2606,13 @@
 	}
 
 	private ReferencedEnvelope addDefaultMargin(ReferencedEnvelope bounds) {
-		return JTSUtil.expandEnvelope(bounds, Math.max(0, defaultMaxMapExtendMode));
+		return JTSUtil.expandEnvelope(bounds,
+				Math.max(0, defaultMaxMapExtendMode));
 	}
 
 	private Envelope addDefaultMargin(Envelope bounds) {
-		return JTSUtil.expandEnvelope(bounds, Math.max(0, defaultMaxMapExtendMode));
+		return JTSUtil.expandEnvelope(bounds,
+				Math.max(0, defaultMaxMapExtendMode));
 	}
 
 	/**
@@ -2458,7 +2634,8 @@
 	 *            position in window coordinates
 	 * @param zoomFaktor
 	 *            > 1 for zoom out, < 1 for zoom in. Default is .5
-	 * @retun <code>true</code> if {@link #mapArea} has changed and a repaint is triggered
+	 * @retun <code>true</code> if {@link #mapArea} has changed and a repaint is
+	 *        triggered
 	 */
 	public boolean zoomTo(Point center, Double zoomFaktor) {
 		if (zoomFaktor == null || zoomFaktor == 0.)
@@ -2467,7 +2644,8 @@
 		final Point2D gcenter = getScreenToWorld().transform(center, null);
 		center = null;
 
-		if (Double.isNaN(gcenter.getX()) || Double.isNaN(gcenter.getY()) || Double.isInfinite(gcenter.getX())
+		if (Double.isNaN(gcenter.getX()) || Double.isNaN(gcenter.getY())
+				|| Double.isInfinite(gcenter.getX())
 				|| Double.isInfinite(gcenter.getY())
 
 		) {
@@ -2478,21 +2656,24 @@
 		final Envelope mapArea = getMapArea();
 
 		final Envelope newMapArea = new Envelope(mapArea);
-		newMapArea.expandBy((mapArea.getWidth() * zoomFaktor - mapArea.getWidth()) / 2., (mapArea.getHeight()
-				* zoomFaktor - mapArea.getHeight()) / 2.);
+		newMapArea.expandBy(
+				(mapArea.getWidth() * zoomFaktor - mapArea.getWidth()) / 2.,
+				(mapArea.getHeight() * zoomFaktor - mapArea.getHeight()) / 2.);
 
 		// // Move the newMapArea above the new center if we zoom in:
-		newMapArea.translate(gcenter.getX() - mapArea.centre().x, gcenter.getY() - mapArea.centre().y);
+		newMapArea.translate(gcenter.getX() - mapArea.centre().x,
+				gcenter.getY() - mapArea.centre().y);
 
 		return setMapArea(newMapArea);
 	}
 
 	/**
-	 * Zooms in or out in a way, that the given {@link Point} on the map stays at the same positino in screen
-	 * coordinates.
+	 * Zooms in or out in a way, that the given {@link Point} on the map stays
+	 * at the same positino in screen coordinates.
 	 * 
 	 * @param point
-	 *            fixed {@link Point} in screen coordinates that will be at the same screen position after zoom.
+	 *            fixed {@link Point} in screen coordinates that will be at the
+	 *            same screen position after zoom.
 	 */
 	public boolean zoomTowards(Point point, Double zFactor) {
 		final Point2D mapCoord = getScreenToWorld().transform(point, null);
@@ -2501,29 +2682,36 @@
 	}
 
 	/**
-	 * Zooms in or out in a way, that the given {@link Point} on the map stays at the same positino in screen
-	 * coordinates.
+	 * Zooms in or out in a way, that the given {@link Point} on the map stays
+	 * at the same positino in screen coordinates.
 	 * 
 	 * @param point
-	 *            fixed {@link Point2D} in map CRS coordinates that will be at the same screen position after zoom.
+	 *            fixed {@link Point2D} in map CRS coordinates that will be at
+	 *            the same screen position after zoom.
 	 */
 	public boolean zoomTowards(Point2D coordinate, Double zFactor) {
 		final Point2D mapCoord = coordinate;
 
-		double relX = (mapCoord.getX() - getMapArea().getMinX()) / getMapArea().getWidth();
-		double relY = (mapCoord.getY() - getMapArea().getMinY()) / getMapArea().getHeight();
+		double relX = (mapCoord.getX() - getMapArea().getMinX())
+				/ getMapArea().getWidth();
+		double relY = (mapCoord.getY() - getMapArea().getMinY())
+				/ getMapArea().getHeight();
 
 		// Neuen Karten-Ausschnitt berechnen
-		Coordinate ll = new Coordinate(mapCoord.getX() - getMapArea().getWidth() * relX * zFactor, mapCoord.getY()
+		Coordinate ll = new Coordinate(mapCoord.getX()
+				- getMapArea().getWidth() * relX * zFactor, mapCoord.getY()
 				- getMapArea().getHeight() * relY * zFactor);
-		Coordinate ur = new Coordinate(mapCoord.getX() + getMapArea().getWidth() * (1 - relX) * zFactor,
-				mapCoord.getY() + getMapArea().getHeight() * (1 - relY) * zFactor);
+		Coordinate ur = new Coordinate(mapCoord.getX()
+				+ getMapArea().getWidth() * (1 - relX) * zFactor,
+				mapCoord.getY() + getMapArea().getHeight() * (1 - relY)
+						* zFactor);
 
 		return setMapArea(new Envelope(ll, ur));
 	}
 
 	/**
-	 * Shall non-fatal rendering exceptions be reported in the mappane or be dropped quitely.
+	 * Shall non-fatal rendering exceptions be reported in the mappane or be
+	 * dropped quitely.
 	 */
 	public void setShowExceptions(final boolean showExceptions) {
 		this.showExceptions = showExceptions;
@@ -2541,13 +2729,14 @@
 	}
 
 	/**
-	 * Setzt den Kartenausschnitt auf die Ausdehnung eines bestimmten Layers. Macht nichts, wenn {@code null} uebergeben
-	 * wird.
+	 * Setzt den Kartenausschnitt auf die Ausdehnung eines bestimmten Layers.
+	 * Macht nichts, wenn {@code null} uebergeben wird.
 	 * 
 	 * <br>
 	 * 
 	 * @param switchCrs
-	 *            if <code>true</code>, the mapcontext will be switched to use the CRS of the layer
+	 *            if <code>true</code>, the mapcontext will be switched to use
+	 *            the CRS of the layer
 	 * @param layer
 	 *            ein Layer
 	 */
@@ -2557,25 +2746,34 @@
 		try {
 
 			if (switchCrs) {
-				final FeatureSource<? extends FeatureType, ? extends Feature> featureSource = layer.getFeatureSource();
-				final CoordinateReferenceSystem coordinateReferenceSystem = featureSource.getSchema()
-						.getCoordinateReferenceSystem();
-				getMapContext().setCoordinateReferenceSystem(coordinateReferenceSystem);
+				final FeatureSource<? extends FeatureType, ? extends Feature> featureSource = layer
+						.getFeatureSource();
+				final CoordinateReferenceSystem coordinateReferenceSystem = featureSource
+						.getSchema().getCoordinateReferenceSystem();
+				if (coordinateReferenceSystem != null)
+					getMapContext().setCoordinateReferenceSystem(
+							coordinateReferenceSystem);
 			}
 
 			// BB umrechnen von Layer-CRS in Map-CRS
-			final CoordinateReferenceSystem targetCRS = getMapContext().getCoordinateReferenceSystem();
-			CoordinateReferenceSystem sourceCRS = layer.getFeatureSource().getSchema().getCoordinateReferenceSystem();
+			final CoordinateReferenceSystem targetCRS = getMapContext()
+					.getCoordinateReferenceSystem();
+			CoordinateReferenceSystem sourceCRS = layer.getFeatureSource()
+					.getSchema().getCoordinateReferenceSystem();
 
 			if (sourceCRS == null) {
-				sourceCRS = layer.getFeatureSource().getSchema().getGeometryDescriptor().getCoordinateReferenceSystem();
-				LOGGER.info("CRS for " + layer.getTitle()
-						+ " could not be determined from schema, trying GeometryDescriptor results: " + sourceCRS);
+				sourceCRS = layer.getFeatureSource().getSchema()
+						.getGeometryDescriptor().getCoordinateReferenceSystem();
+				LOGGER.info("CRS for "
+						+ layer.getTitle()
+						+ " could not be determined from schema, trying GeometryDescriptor results: "
+						+ sourceCRS);
 			}
 
 			Envelope mapAreaNew;
 			if (!CRS.equalsIgnoreMetadata(sourceCRS, targetCRS)) {
-				mapAreaNew = JTSUtil.transformEnvelope(layer.getFeatureSource().getBounds(), sourceCRS, targetCRS);
+				mapAreaNew = JTSUtil.transformEnvelope(layer.getFeatureSource()
+						.getBounds(), sourceCRS, targetCRS);
 			} else {
 				try {
 					mapAreaNew = layer.getFeatureSource().getBounds();
@@ -2585,21 +2783,38 @@
 
 					/**
 					 * 
-					 23.10.2009 11:20:50 org.geotools.data.shapefile.shp.PolygonHandler read WARNUNG: only one hole in
-					 * this polygon record ERROR JMapPane zoomToLayer Zoom to layer did not terminate correctly
-					 * java.lang.IllegalArgumentException: Points of LinearRing do not form a closed linestring at
-					 * com.vividsolutions .jts.geom.LinearRing.validateConstruction (LinearRing.java:105) at
-					 * com.vividsolutions.jts.geom.LinearRing .<init>(LinearRing.java:100) at
-					 * com.vividsolutions.jts.geom .GeometryFactory.createLinearRing (GeometryFactory.java:339) at
-					 * org.geotools.data.shapefile. shp.PolygonHandler.read(PolygonHandler.java:188) at org.geotools
-					 * .data.shapefile.shp.ShapefileReader$Record.shape (ShapefileReader.java:106) at
-					 * org.geotools.data.shapefile. ShapefileAttributeReader.next( ShapefileAttributeReader.java:157) at
-					 * org.geotools.data.shapefile .indexed.IndexedShapefileAttributeReader
-					 * .next(IndexedShapefileAttributeReader.java:122) at org.geotools
+					 23.10.2009 11:20:50
+					 * org.geotools.data.shapefile.shp.PolygonHandler read
+					 * WARNUNG: only one hole in this polygon record ERROR
+					 * JMapPane zoomToLayer Zoom to layer did not terminate
+					 * correctly java.lang.IllegalArgumentException: Points of
+					 * LinearRing do not form a closed linestring at
+					 * com.vividsolutions
+					 * .jts.geom.LinearRing.validateConstruction
+					 * (LinearRing.java:105) at
+					 * com.vividsolutions.jts.geom.LinearRing
+					 * .<init>(LinearRing.java:100) at
+					 * com.vividsolutions.jts.geom
+					 * .GeometryFactory.createLinearRing
+					 * (GeometryFactory.java:339) at
+					 * org.geotools.data.shapefile.
+					 * shp.PolygonHandler.read(PolygonHandler.java:188) at
+					 * org.geotools
+					 * .data.shapefile.shp.ShapefileReader$Record.shape
+					 * (ShapefileReader.java:106) at
+					 * org.geotools.data.shapefile.
+					 * ShapefileAttributeReader.next(
+					 * ShapefileAttributeReader.java:157) at
+					 * org.geotools.data.shapefile
+					 * .indexed.IndexedShapefileAttributeReader
+					 * .next(IndexedShapefileAttributeReader.java:122) at
+					 * org.geotools
 					 * .data.FIDFeatureReader.next(FIDFeatureReader.java:96) at
-					 * org.geotools.data.FIDFeatureReader.next(FIDFeatureReader. java:55) at
-					 * org.geotools.data.MaxFeatureReader.next( MaxFeatureReader.java:61) at
-					 * org.geotools.data.MaxFeatureReader .next(MaxFeatureReader.java:61)
+					 * org.geotools.data.FIDFeatureReader.next(FIDFeatureReader.
+					 * java:55) at org.geotools.data.MaxFeatureReader.next(
+					 * MaxFeatureReader.java:61) at
+					 * org.geotools.data.MaxFeatureReader
+					 * .next(MaxFeatureReader.java:61)
 					 **/
 				}
 			}
@@ -2629,7 +2844,11 @@
 	 * A refresh of the map is not done automatically
 	 * 
 	 * @param index
-	 *            Index of the {@link MapLayer} in the {@link MapContext} (from back to top)
+	 *            Index of the {@link MapLayer} in the {@link MapContext} (from
+	 *            back to top)
+	 * @param switchCrs
+	 *            is <code>true</code>, the map's presenmtation CRS is switched
+	 *            to he layers CRS.-
 	 * 
 	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
@@ -2640,8 +2859,9 @@
 	}
 
 	/**
-	 * Zooms the {@link SelectableXMapPane} to the {@link Envelope} of the selected layer. The layer is selected by the
-	 * idx, counting from front to back, like humans would expect in a {@link JList}
+	 * Zooms the {@link SelectableXMapPane} to the {@link Envelope} of the
+	 * selected layer. The layer is selected by the idx, counting from front to
+	 * back, like humans would expect in a {@link JList}
 	 * 
 	 * <br>
 	 * A refresh of the map is not done automatically
@@ -2649,7 +2869,8 @@
 	 * 
 	 * 
 	 * @param index
-	 *            Reverse index of the {@link MapLayer} in the {@link MapContext}
+	 *            Reverse index of the {@link MapLayer} in the
+	 *            {@link MapContext}
 	 * 
 	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
@@ -2658,7 +2879,8 @@
 	}
 
 	/**
-	 * Aktiviert oder deaktiviert das AntiAliasing for diese {@link SelectableXMapPane}. AntiALiasing ist besonders fuer
+	 * Aktiviert oder deaktiviert das AntiAliasing for diese
+	 * {@link SelectableXMapPane}. AntiALiasing ist besonders fuer
 	 * Textbeschriftung sehr schoen, verbraucht aber auch mehr Performance.
 	 * 
 	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
@@ -2670,12 +2892,15 @@
 			java2DHints = GeoTools.getDefaultHints();
 		}
 
-		java2DHints.put(RenderingHints.KEY_ANTIALIASING, aa ? RenderingHints.VALUE_ANTIALIAS_ON
-				: RenderingHints.VALUE_ANTIALIAS_OFF);
-		java2DHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, aa ? RenderingHints.VALUE_TEXT_ANTIALIAS_ON
-				: RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
-		java2DHints.put(RenderingHints.KEY_RENDERING, aa ? RenderingHints.VALUE_RENDER_QUALITY
-				: RenderingHints.VALUE_RENDER_SPEED);
+		java2DHints.put(RenderingHints.KEY_ANTIALIASING,
+				aa ? RenderingHints.VALUE_ANTIALIAS_ON
+						: RenderingHints.VALUE_ANTIALIAS_OFF);
+		java2DHints.put(RenderingHints.KEY_TEXT_ANTIALIASING,
+				aa ? RenderingHints.VALUE_TEXT_ANTIALIAS_ON
+						: RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
+		java2DHints.put(RenderingHints.KEY_RENDERING,
+				aa ? RenderingHints.VALUE_RENDER_QUALITY
+						: RenderingHints.VALUE_RENDER_SPEED);
 
 	}
 
@@ -2684,11 +2909,14 @@
 	}
 
 	/**
-	 * If {@link #maxExtend} is <code>null</code> the following rules are used to create a default maximum.
+	 * If {@link #maxExtend} is <code>null</code> the following rules are used
+	 * to create a default maximum.
 	 * <ul>
-	 * <li>Values &lt; 0 : don't grow to fit the monitors aspect ratio, no margin</li>
+	 * <li>Values &lt; 0 : don't grow to fit the monitors aspect ratio, no
+	 * margin</li>
 	 * <li>Values 0 : grow to fit the monitors aspect ratio, no margin</li>
-	 * <li>Values &gt; 0 : grow to fit the monitors aspect ratio, and add a relative margin</li>
+	 * <li>Values &gt; 0 : grow to fit the monitors aspect ratio, and add a
+	 * relative margin</li>
 	 * </ul>
 	 * **/
 	public void setDefaultMaxMapExtendMode(double defaultMaxMapExtendMode) {
@@ -2696,11 +2924,14 @@
 	}
 
 	/**
-	 * If {@link #maxExtend} is <code>null</code> the following rules are used to create a default maximum.
+	 * If {@link #maxExtend} is <code>null</code> the following rules are used
+	 * to create a default maximum.
 	 * <ul>
-	 * <li>Values &lt; 0 : don't grow to fit the monitors aspect ratio, no margin</li>
+	 * <li>Values &lt; 0 : don't grow to fit the monitors aspect ratio, no
+	 * margin</li>
 	 * <li>Values 0 : grow to fit the monitors aspect ratio, no margin</li>
-	 * <li>Values &gt; 0 : grow to fit the monitors aspect ratio, and add a relative margin</li>
+	 * <li>Values &gt; 0 : grow to fit the monitors aspect ratio, and add a
+	 * relative margin</li>
 	 * </ul>
 	 * **/
 	public double getDefaultMaxMapExtendMode() {
@@ -2716,7 +2947,8 @@
 	private String renderLanguage;
 
 	/**
-	 * The job of the BlinkTimer is to remove the features painted in BLINK style again.
+	 * The job of the BlinkTimer is to remove the features painted in BLINK
+	 * style again.
 	 */
 	private Timer initBlinkTimer() {
 		Timer timer = new Timer(BLINK_TIMER_DEPLAY, new ActionListener() {
@@ -2736,7 +2968,8 @@
 	 * Makes the given {@link SimpleFeature} bink in the map for a moment
 	 */
 	public void blink(SimpleFeature feature) {
-		MemoryFeatureCollection memoryFeatureCollection = new MemoryFeatureCollection(feature.getFeatureType());
+		MemoryFeatureCollection memoryFeatureCollection = new MemoryFeatureCollection(
+				feature.getFeatureType());
 		memoryFeatureCollection.add(feature);
 		blink(memoryFeatureCollection);
 	}
@@ -2744,17 +2977,20 @@
 	/**
 	 * Makes the given {@link FeatureCollection} bink in the map for a moment
 	 */
-	public void blink(FeatureCollection<SimpleFeatureType, SimpleFeature> features) {
+	public void blink(
+			FeatureCollection<SimpleFeatureType, SimpleFeature> features) {
 		{
 			if (stopBlinkTimer != null)
 				stopBlinkTimer.stop();
 			repaint();
 			stopBlinkTimer = initBlinkTimer();
 
-			DefaultMapContext mc = new DefaultMapContext(getMapContext().getCoordinateReferenceSystem());
+			DefaultMapContext mc = new DefaultMapContext(getMapContext()
+					.getCoordinateReferenceSystem());
 
 			Style style = StylingUtil.STYLE_FACTORY.createStyle();
-			style.featureTypeStyles().add(StylingUtil.createBlinkFeatureTypeStyle(features));
+			style.featureTypeStyles().add(
+					StylingUtil.createBlinkFeatureTypeStyle(features));
 
 			// style = StylingUtil.createStyleSimple(features, Color.pink,
 			// Color.WHITE);
@@ -2774,11 +3010,12 @@
 	}
 
 	/**
-	 * Set a specific language for rendering. The value will be inserted into a {@link EnvFunction} variable before
-	 * rendering.
+	 * Set a specific language for rendering. The value will be inserted into a
+	 * {@link EnvFunction} variable before rendering.
 	 * 
 	 * @param e
-	 *            .g. "de" or <code>null</code> (default) if no specific langauge should be set.
+	 *            .g. "de" or <code>null</code> (default) if no specific
+	 *            langauge should be set.
 	 * 
 	 */
 	public void setRenderLanguage(String renderLanguage) {
@@ -2786,11 +3023,12 @@
 	}
 
 	/**
-	 * Return any a specific language set for rendering. The value will be inserted into a {@link EnvFunction} variable
-	 * before rendering.
+	 * Return any a specific language set for rendering. The value will be
+	 * inserted into a {@link EnvFunction} variable before rendering.
 	 * 
 	 * @param e
-	 *            .g. "de" or <code>null</code> (default) if no specific langauge should be set.
+	 *            .g. "de" or <code>null</code> (default) if no specific
+	 *            langauge should be set.
 	 * 
 	 */
 	public String getRenderLanguage() {
@@ -2804,22 +3042,27 @@
 	final static double OGC_DEGREE_TO_METERS = 6378137.0 * 2.0 * Math.PI / 360;
 
 	/**
-	 * Zooms to the given Scale without changing the center of the map (if possible due to mapMaxExtend restrictions.
+	 * Zooms to the given Scale without changing the center of the map (if
+	 * possible due to mapMaxExtend restrictions.
 	 */
 	public void zoomToScaleDenominator(double scaleDenominator) {
 		// if it's geodetic, we're dealing with lat/lon unit measures
-		Double newScale = calculateScaleDenominatortoScale(scaleDenominator, getMapArea().getWidth());
+		Double newScale = calculateScaleDenominatortoScale(scaleDenominator,
+				getMapArea().getWidth());
 
 		double zFactor = newScale / getScale();
 
-		zoomTowards(new Point2D.Double(getMapArea().getMedian(0), getMapArea().getMedian(1)), zFactor);
+		zoomTowards(new Point2D.Double(getMapArea().getMedian(0), getMapArea()
+				.getMedian(1)), zFactor);
 
 	}
 
 	/**
-	 * Converts an OGC ScaleDenominator to a Scale as retuned by {@link #getScale()}
+	 * Converts an OGC ScaleDenominator to a Scale as retuned by
+	 * {@link #getScale()}
 	 */
-	public Double calculateScaleDenominatortoScale(double scaleDenominator, double width2) {
+	public Double calculateScaleDenominatortoScale(double scaleDenominator,
+			double width2) {
 
 		final double d = width2 / RendererUtilities.getDpi(null) * 0.0254;
 		if (getMapArea().getCoordinateReferenceSystem() instanceof GeographicCRS) {



More information about the Schmitzm-commits mailing list