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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Oct 27 13:57:59 CET 2009


Author: alfonx
Date: 2009-10-27 13:57:58 +0100 (Tue, 27 Oct 2009)
New Revision: 504

Modified:
   branches/1.0-gt2-2.6/src/gtmig/org/geotools/swing/JMapPane.java
Log:
* Better documentation for methods setMaxZoomScale and setMinZoomScale

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-27 11:00:09 UTC (rev 503)
+++ branches/1.0-gt2-2.6/src/gtmig/org/geotools/swing/JMapPane.java	2009-10-27 12:57:58 UTC (rev 504)
@@ -230,23 +230,23 @@
 		Map<Object, Object> hints = new HashMap<Object, Object>();
 
 		this.renderer = renderer;
-//MS: Apply hint also for ShapeFileRenderer
-//		if (renderer instanceof StreamingRenderer) {
-			hints = renderer.getRendererHints();
-			if (hints == null) {
-				hints = new HashMap<Object, Object>();
-			}
-			if (hints.containsKey(StreamingRenderer.LABEL_CACHE_KEY)) {
-				labelCache = (LabelCache) hints
-						.get(StreamingRenderer.LABEL_CACHE_KEY);
-			} else {
-				hints.put(StreamingRenderer.LABEL_CACHE_KEY, labelCache);
-			}
+		// MS: Apply hint also for ShapeFileRenderer
+		// if (renderer instanceof StreamingRenderer) {
+		hints = renderer.getRendererHints();
+		if (hints == null) {
+			hints = new HashMap<Object, Object>();
+		}
+		if (hints.containsKey(StreamingRenderer.LABEL_CACHE_KEY)) {
+			labelCache = (LabelCache) hints
+					.get(StreamingRenderer.LABEL_CACHE_KEY);
+		} else {
+			hints.put(StreamingRenderer.LABEL_CACHE_KEY, labelCache);
+		}
 
-			hints.put("memoryPreloadingEnabled", Boolean.TRUE);
+		hints.put("memoryPreloadingEnabled", Boolean.TRUE);
 
-			renderer.setRendererHints(hints);
-//		}
+		renderer.setRendererHints(hints);
+		// }
 
 		if (this.context != null) {
 			this.renderer.setContext(this.context);
@@ -567,14 +567,13 @@
 	protected void processDrag(final int x1, final int y1, final int x2,
 			final int y2, final MouseEvent e) {
 
-
 		/****
 		 * If no layers exist, we ignore the drag.
 		 */
 		if (context.getLayerCount() <= 0) {
 			return;
 		}
-		
+
 		// System.out.println("processing drag from " + x1 + "," + y1 + " -> "
 		// + x2 + "," + y2);
 		if ((x1 == x2) && (y1 == y2)) {
@@ -620,7 +619,6 @@
 			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
@@ -866,7 +864,8 @@
 
 		/**
 		 * 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
+		 * easily fail. We allow to grow here, because we don't check against
+		 * the maxExtend
 		 */
 		env = JTSUtil.fixAspectRatio(this.getBounds(), env, true);
 
@@ -905,7 +904,12 @@
 		}
 
 		Envelope maxAllowedExtend = getMaxExtend();
-		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()) ) {
+		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())) {
 			/*
 			 * If a maxExtend is set, we have to honour that...
 			 */
@@ -913,44 +917,46 @@
 			// Exceeds top? Move down and maybe cut
 			if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) {
 				double divY = newArea.getMaxY() - maxAllowedExtend.getMaxY();
-//				LOGGER.debug("Moving area down by " + divY);
+				// LOGGER.debug("Moving area down by " + divY);
 
 				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!");
+					// 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()));
 
-//					LOGGER.debug("and fix aspect ratio");
+					// LOGGER.debug("and fix aspect ratio");
 
-					newArea = JTSUtil.fixAspectRatio(this.getBounds(), newArea, false);
+					newArea = JTSUtil.fixAspectRatio(this.getBounds(), newArea,
+							false);
 				}
 			}
 
 			// Exceeds bottom? Move up and maybe cut
 			if (newArea.getMinY() < maxAllowedExtend.getMinY()) {
 				double divY = newArea.getMinY() - maxAllowedExtend.getMinY();
-//				LOGGER.debug("Moving area up by " + divY);
+				// LOGGER.debug("Moving area up by " + divY);
 
 				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!");
+					// 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
 							.getMaxX(), maxAllowedExtend.getMaxY()));
 
-//					LOGGER.debug("and fix aspect ratio");
+					// LOGGER.debug("and fix aspect ratio");
 
-					newArea = JTSUtil.fixAspectRatio(this.getBounds(), newArea, false);
+					newArea = JTSUtil.fixAspectRatio(this.getBounds(), newArea,
+							false);
 				}
 			}
 
@@ -959,22 +965,23 @@
 
 				// Move left..
 				double divX = newArea.getMaxX() - maxAllowedExtend.getMaxX();
-//				LOGGER.debug("Moving area left by " + divX);
+				// LOGGER.debug("Moving area left by " + divX);
 
 				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!");
+					// 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()), new Coordinate(newArea
-							.getMaxX(), newArea.getMaxY()));
+					newArea = new Envelope(new Coordinate(maxAllowedExtend
+							.getMinX(), newArea.getMinY()), new Coordinate(
+							newArea.getMaxX(), newArea.getMaxY()));
 
-//					LOGGER.debug("and fix aspect ratio");
+					// LOGGER.debug("and fix aspect ratio");
 
-					newArea = JTSUtil.fixAspectRatio(this.getBounds(), newArea, false);
+					newArea = JTSUtil.fixAspectRatio(this.getBounds(), newArea,
+							false);
 				}
 			}
 
@@ -983,22 +990,23 @@
 
 				// Move right..
 				double divX = newArea.getMinX() - maxAllowedExtend.getMinX();
-//				LOGGER.debug("Moving area right by " + divX);
+				// LOGGER.debug("Moving area right by " + divX);
 
 				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!");
+					// 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(maxAllowedExtend
 							.getMaxX(), newArea.getMaxY()));
 
-//					LOGGER.debug("and fix aspect ratio");
+					// LOGGER.debug("and fix aspect ratio");
 
-					newArea = JTSUtil.fixAspectRatio(this.getBounds(), newArea, false);
+					newArea = JTSUtil.fixAspectRatio(this.getBounds(), newArea,
+							false);
 				}
 			}
 
@@ -1031,24 +1039,29 @@
 
 	/**
 	 * Set the maximum allowed zoom scale. This is the smaller number value of
-	 * the two.
+	 * the two. If <code>null</code> is passed, Double.MINVALUE are used which
+	 * mean there is no restriction.
 	 * 
 	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
 	 *         Kr&uuml;ger</a>
 	 */
 	public void setMaxZoomScale(final Double maxZoomScale) {
-		this.maxZoomScale = maxZoomScale;
+		this.maxZoomScale = maxZoomScale == null ? Double.MIN_VALUE
+				: maxZoomScale;
 	}
 
 	/**
 	 * Set the minimum (nearest) allowed zoom scale. This is the bigger number
-	 * value of the two.
+	 * value of the two. If <code>null</code> is passed, Double.MAXVALUE are
+	 * used which mean there is no restriction.
 	 * 
+	 * 
 	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
 	 *         Kr&uuml;ger</a>
 	 */
 	public void setMinZoomScale(final Double minZoomScale) {
-		this.minZoomScale = minZoomScale;
+		this.minZoomScale = minZoomScale == null ? Double.MAX_VALUE
+				: minZoomScale;
 	}
 
 	/**
@@ -1076,14 +1089,13 @@
 	public Envelope getMaxExtend() {
 		if (maxExtend == null) {
 			try {
-				return JTSUtil.fixAspectRatio(
-				    this.getBounds(),
-	                // Kartenbereich um 10% vergroessern
-				    JTSUtil.expandEnvelope(context.getLayerBounds(), 0.1),
-				    true
-				);
+				return JTSUtil.fixAspectRatio(this.getBounds(),
+						// Kartenbereich um 10% vergroessern
+						JTSUtil.expandEnvelope(context.getLayerBounds(), 0.1),
+						true);
 			} catch (IOException e) {
-				LOGGER.warn(
+				LOGGER
+						.warn(
 								"maxExtend == null; failed to getLayerBounds of context",
 								e);
 			}



More information about the Schmitzm-commits mailing list