[Schmitzm-commits] r431 - branches/1.0-gt2-2.6/src/gtmig/org/geotools/swing

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sun Oct 4 18:56:04 CEST 2009


Author: alfonx
Date: 2009-10-04 18:55:52 +0200 (Sun, 04 Oct 2009)
New Revision: 431

Modified:
   branches/1.0-gt2-2.6/src/gtmig/org/geotools/swing/JMapPane.java
Log:
added checks against NPEs if the context is empty

Modified: branches/1.0-gt2-2.6/src/gtmig/org/geotools/swing/JMapPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/gtmig/org/geotools/swing/JMapPane.java	2009-10-04 14:32:44 UTC (rev 430)
+++ branches/1.0-gt2-2.6/src/gtmig/org/geotools/swing/JMapPane.java	2009-10-04 16:55:52 UTC (rev 431)
@@ -377,6 +377,10 @@
 	 */
 	private Envelope fixAspectRatio(final Rectangle r, final Envelope mapArea,
 			boolean grow) {
+		
+		if (mapArea == null) {
+			LOGGER.warn("mapArea has been null in method fixAspectRatio, returning an unmodified ");
+		}
 
 		final double mapWidth = mapArea.getWidth(); /* get the extent of the map */
 		final double mapHeight = mapArea.getHeight();
@@ -621,12 +625,14 @@
 	protected void processDrag(final int x1, final int y1, final int x2,
 			final int y2, final MouseEvent e) {
 
+
 		/****
-		 * If no layer is availabe we dont want a NullPointerException
+		 * If no layers exist, we ignore the drag.
 		 */
-		if (mapArea == null)
+		if (context.getLayerCount() <= 0) {
 			return;
-
+		}
+		
 		// System.out.println("processing drag from " + x1 + "," + y1 + " -> "
 		// + x2 + "," + y2);
 		if ((x1 == x2) && (y1 == y2)) {
@@ -672,6 +678,8 @@
 			final Coordinate ur = new Coordinate(right, top);
 			// xulu.sc
 			// mapArea = fixAspectRatio(this.getBounds(), new Envelope(ll, ur));
+			
+
 			setMapArea(bestAllowedMapArea(new Envelope(ll, ur)));
 			// xulu.ec
 		} else if (state == JMapPane.ZoomIn) {



More information about the Schmitzm-commits mailing list