[Schmitzm-commits] r1035 - trunk/src/schmitzm/geotools/gui

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Sep 22 10:56:53 CEST 2010


Author: alfonx
Date: 2010-09-22 10:56:51 +0200 (Wed, 22 Sep 2010)
New Revision: 1035

Modified:
   trunk/src/schmitzm/geotools/gui/XMapPane.java
Log:
Bug in XMapPane (getVisibleRect()) fixed, which causes the rendering problem when the MapPane was partly hidden by a scroll pane.

Modified: trunk/src/schmitzm/geotools/gui/XMapPane.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/XMapPane.java	2010-09-22 08:55:00 UTC (rev 1034)
+++ trunk/src/schmitzm/geotools/gui/XMapPane.java	2010-09-22 08:56:51 UTC (rev 1035)
@@ -651,7 +651,7 @@
 
 						// LOGGER.debug("resizeTimer performed");
 
-						// final Rectangle bounds = getVisibleRect();
+						// final Rectangle bounds = getMapPaneSize();
 						//
 						// System.out.println("\n\ntimer performs with bounds = "
 						// + bounds);
@@ -683,14 +683,14 @@
 
 				// Seems to be called twice with the same size..
 				if (oldVisibleRect != null
-						&& oldVisibleRect.equals(getVisibleRect())) {
+						&& oldVisibleRect.equals(getMapPaneSize())) {
 					// LOGGER.debug("skipping resize.");
 					return;
 				}
 
-				// LOGGER.debug("resized: " + getVisibleRect());
+				// LOGGER.debug("resized: " + getMapPaneSize());
 				resizeTimer.restart();
-				oldVisibleRect = getVisibleRect();
+				oldVisibleRect = getMapPaneSize();
 			}
 
 		});
@@ -798,7 +798,7 @@
 		 * easily fail. We allow to grow here, because we don't check against
 		 * the maxExtend
 		 */
-		final Rectangle curPaintArea = getVisibleRect();
+		final Rectangle curPaintArea = getMapPaneSize();
 
 		env = JTSUtil.fixAspectRatio(curPaintArea, env, true);
 
@@ -878,7 +878,7 @@
 
 					// LOGGER.debug("and fix aspect ratio");
 
-					newArea = JTSUtil.fixAspectRatio(getVisibleRect(),
+					newArea = JTSUtil.fixAspectRatio(getMapPaneSize(),
 							new ReferencedEnvelope(newArea, env
 									.getCoordinateReferenceSystem()), false);
 				}
@@ -903,7 +903,7 @@
 
 					// LOGGER.debug("and fix aspect ratio");
 
-					newArea = JTSUtil.fixAspectRatio(getVisibleRect(),
+					newArea = JTSUtil.fixAspectRatio(getMapPaneSize(),
 							new ReferencedEnvelope(newArea, env
 									.getCoordinateReferenceSystem()), false);
 				}
@@ -930,7 +930,7 @@
 
 					// LOGGER.debug("and fix aspect ratio");
 
-					newArea = JTSUtil.fixAspectRatio(getVisibleRect(),
+					newArea = JTSUtil.fixAspectRatio(getMapPaneSize(),
 							new ReferencedEnvelope(newArea, env
 									.getCoordinateReferenceSystem()), false);
 				}
@@ -957,7 +957,7 @@
 
 					// LOGGER.debug("and fix aspect ratio");
 
-					newArea = JTSUtil.fixAspectRatio(getVisibleRect(),
+					newArea = JTSUtil.fixAspectRatio(getMapPaneSize(),
 							new ReferencedEnvelope(newArea, env
 									.getCoordinateReferenceSystem()), false);
 				}
@@ -1092,7 +1092,7 @@
 
 		try {
 
-			final Rectangle visibleArea = getVisibleRect();
+			final Rectangle visibleArea = getMapPaneSize();
 
 			// Calculate the oldMapArea in the current WindowCoordinates:
 			final Envelope oldMapWindow = tranformGeoToWindow(oldMapArea
@@ -1146,8 +1146,8 @@
 	 */
 	private Image getBgImage() {
 		if (bgImage == null) {
-			bgImage = new BufferedImage(getVisibleRect().width,
-					getVisibleRect().height, IMAGETYPE);
+			bgImage = new BufferedImage(getMapPaneSize().width,
+			    getMapPaneSize().height, IMAGETYPE);
 			SwingUtil.clearImage(finalImage, getMapBackgroundColor());
 		}
 
@@ -1164,9 +1164,9 @@
 	private BufferedImage getFinalImage() {
 		//
 		if (finalImage == null) {
-			// Rectangle curPaintArea = getVisibleRect();
-			finalImage = new BufferedImage(getVisibleRect().width,
-					getVisibleRect().height, IMAGETYPE);
+			// Rectangle curPaintArea = getMapPaneSize();
+			finalImage = new BufferedImage(getMapPaneSize().width,
+			    getMapPaneSize().height, IMAGETYPE);
 			SwingUtil.clearImage(finalImage, getMapBackgroundColor());
 
 			// requestStartRendering();
@@ -1180,8 +1180,8 @@
 	private BufferedImage getLocalImage() {
 
 		if (localImage == null) {
-			localImage = new BufferedImage(getVisibleRect().width,
-					getVisibleRect().height, IMAGETYPE_withAlpha);
+			localImage = new BufferedImage(getMapPaneSize().width,
+			    getMapPaneSize().height, IMAGETYPE_withAlpha);
 			SwingUtil.clearImage(localImage, getMapBackgroundColor());
 		}
 
@@ -1283,7 +1283,7 @@
 				return null;
 			}
 
-			return JTSUtil.fixAspectRatio(getVisibleRect(),
+			return JTSUtil.fixAspectRatio(getMapPaneSize(),
 					addDefaultMargin(layerBounds), true);
 
 		}
@@ -1442,9 +1442,9 @@
 				return false;
 			if (getMapContext().getLayerCount() <= 0)
 				return false;
-			if (getVisibleRect().getWidth() == 0)
+			if (getMapPaneSize().getWidth() == 0)
 				return false;
-			if (getVisibleRect().getHeight() == 0)
+			if (getMapPaneSize().getHeight() == 0)
 				return false;
 			// if (getMapArea() == null)
 			// return false;
@@ -1621,8 +1621,8 @@
 		//
 		// if (paneResized) {
 		// // ((Graphics2D) g).setBackground(getMapBackgroundColor());
-		// // g.clearRect(0, 0, getVisibleRect().width,
-		// getVisibleRect().height);
+		// // g.clearRect(0, 0, getMapPaneSize().width,
+		// getMapPaneSize().height);
 		// return;
 		// }
 
@@ -1673,7 +1673,7 @@
 	private void blink(Graphics2D g2d) {
 		if (blinkRenderer != null) {
 			g2d.translate(getImageOrigin().x, getImageOrigin().y);
-			blinkRenderer.paint(g2d, getVisibleRect(), getMapArea());
+			blinkRenderer.paint(g2d, getMapPaneSize(), getMapArea());
 		}
 	}
 
@@ -1729,7 +1729,7 @@
 	// */
 	// public void performPan() {
 	//
-	// final Rectangle winBounds = getVisibleRect();
+	// final Rectangle winBounds = getMapPaneSize();
 	//
 	// winBounds.translate(-imageOrigin.x, -imageOrigin.y);
 	// final Envelope newMapArea = tranformWindowToGeo(winBounds.x,
@@ -1798,7 +1798,7 @@
 	 */
 	private void resetTransforms() {
 		// System.out
-		// .println("paintArea in resetTeansofrms = " + getVisibleRect());
+		// .println("paintArea in resetTeansofrms = " + getMapPaneSize());
 		if (!isWellDefined())
 			return;
 
@@ -1811,7 +1811,7 @@
 		// TODO Die
 
 		worldToScreen = RendererUtilities.worldToScreenTransform(refMapEnv,
-				getVisibleRect());
+		    getMapPaneSize());
 
 		try {
 			if (worldToScreen != null)
@@ -2111,6 +2111,19 @@
 		xMapPaneMouseListener.configure(tool);
 		setCursor(tool.getCursor());
 	}
+	
+	/**
+	 * 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).
+	 */
+	protected Rectangle getMapPaneSize() {
+	  //return getMapPaneSize();
+	  return new Rectangle(getWidth(),getHeight());
+	}
 
 	/**
 	 * Starts rendering on one or two threads
@@ -2137,8 +2150,8 @@
 			fireMapPaneEvent(new MapRenderingStateEvent(this,
 					RenderingState.RENDERING));
 
-		final Rectangle curPaintArea = getVisibleRect();
-
+		final Rectangle curPaintArea = getMapPaneSize();
+		LOGGER.debug("Visible-Rect: " + curPaintArea);
 		/**
 		 * We have to set new renderer
 		 */
@@ -2296,7 +2309,7 @@
 		final Rectangle painedArea = new Rectangle(getImageOrigin().x,
 				getImageOrigin().y, getFinalImage().getWidth(), getFinalImage()
 						.getHeight());
-		SwingUtil.clearAround(finalG, painedArea, getVisibleRect(),
+		SwingUtil.clearAround(finalG, painedArea, getMapPaneSize(),
 				getMapBackgroundColor());
 
 		addGadgets(finalG, false);
@@ -2320,9 +2333,9 @@
 
 		// Paint a logo to the bottom right if available
 		if (mapImage != null) {
-			final Rectangle visibleRect = getVisibleRect();
+			final Rectangle visibleRect = getMapPaneSize();
 			graphics.drawImage(mapImage, visibleRect.width
-					- mapImage.getWidth() - 10, getVisibleRect().height
+					- mapImage.getWidth() - 10, getMapPaneSize().height
 					- mapImage.getHeight() - 10, null);
 		}
 



More information about the Schmitzm-commits mailing list