[Schmitzm-commits] r579 - in branches/1.0-gt2-2.6/src: schmitzm/swing skrueger/geotools

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Nov 25 20:14:42 CET 2009


Author: alfonx
Date: 2009-11-25 20:14:40 +0100 (Wed, 25 Nov 2009)
New Revision: 579

Modified:
   branches/1.0-gt2-2.6/src/schmitzm/swing/SwingUtil.java
   branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java
Log:
Resizing the XMapPane keeps the mapArea (as it was in 1.2)


Modified: branches/1.0-gt2-2.6/src/schmitzm/swing/SwingUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/swing/SwingUtil.java	2009-11-25 14:43:57 UTC (rev 578)
+++ branches/1.0-gt2-2.6/src/schmitzm/swing/SwingUtil.java	2009-11-25 19:14:40 UTC (rev 579)
@@ -1078,12 +1078,13 @@
 		Graphics2D graphics = image.createGraphics();
 		if (bgColor != null)
 			graphics.setBackground(bgColor);
-		Composite composite = graphics.getComposite();
-		graphics.setComposite(AlphaComposite.Clear);
-		Rectangle2D.Double rect = new Rectangle2D.Double(0, 0,
-				image.getWidth(), image.getHeight());
-		graphics.fill(rect);
-		graphics.setComposite(composite);
+		graphics.clearRect(0, 0, image.getWidth(), image.getHeight());
+//		Composite composite = graphics.getComposite();
+//		graphics.setComposite(AlphaComposite.Clear);
+//		Rectangle2D.Double rect = new Rectangle2D.Double(0, 0,
+//				image.getWidth(), image.getHeight());
+//		graphics.fill(rect);
+//		graphics.setComposite(composite);
 	}
 
 	/**

Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java	2009-11-25 14:43:57 UTC (rev 578)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java	2009-11-25 19:14:40 UTC (rev 579)
@@ -513,7 +513,7 @@
 	 * A flag indicating, that the image size has changed and the buffered
 	 * images are not big enough any more
 	 **/
-	protected boolean paneResized = true;
+	protected boolean paneResized = false;
 
 	private BufferedImage preFinalImage;
 
@@ -619,23 +619,22 @@
 						if (!isWellDefined())
 							return;
 
-//						LOGGER.debug("resizeTimer performed");
+						// LOGGER.debug("resizeTimer performed");
 
-						final Rectangle bounds = getVisibleRect();
+//						final Rectangle bounds = getVisibleRect();
 						//
 						// 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);
 
-						if (setMapArea(geoMapArea)) {
-//							LOGGER.debug("  maparea changed");
-							paneResized = true;
+						paneResized = true;
+						
+						if (setMapArea(getMapArea())) {
+							
 						}
-//						else 
-//							LOGGER.debug("  maparea NOT changed");
 					}
 				});
 		resizeTimer.setRepeats(false);
@@ -650,11 +649,11 @@
 				// Seems to be called twice with the same size..
 				if (oldVisibleRect != null
 						&& oldVisibleRect.equals(getVisibleRect())) {
-//					LOGGER.debug("skipping resize.");
+					// LOGGER.debug("skipping resize.");
 					return;
 				}
 
-//				LOGGER.debug("resized: " + getVisibleRect());
+				// LOGGER.debug("resized: " + getVisibleRect());
 				resizeTimer.restart();
 				oldVisibleRect = getVisibleRect();
 			}
@@ -799,7 +798,7 @@
 			if (newArea.getMaxY() > maxAllowedExtend.getMaxY()) {
 				final 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
@@ -1061,10 +1060,11 @@
 	 * Lazyly initializes a {@link BufferedImage} for the background renderer.
 	 */
 	private Image getBgImage() {
-		//
-		// if (bgImage == null) {
-		// bgImage = createImage(getBounds().width, getBounds().height);
-		// }
+		if (bgImage == null) {
+			bgImage = new BufferedImage(getVisibleRect().width,
+					getVisibleRect().height, IMAGETYPE);
+			SwingUtil.clearImage(finalImage, getMapBackgroundColor());
+		}
 
 		return bgImage;
 	}
@@ -1082,6 +1082,7 @@
 			// Rectangle curPaintArea = getVisibleRect();
 			finalImage = new BufferedImage(getVisibleRect().width,
 					getVisibleRect().height, IMAGETYPE);
+			SwingUtil.clearImage(finalImage, getMapBackgroundColor());
 
 			requestStartRendering();
 		}
@@ -1100,6 +1101,7 @@
 		if (localImage == null) {
 			localImage = new BufferedImage(getVisibleRect().width,
 					getVisibleRect().height, IMAGETYPE_withAlpha);
+			SwingUtil.clearImage(localImage, getMapBackgroundColor());
 		}
 
 		return localImage;
@@ -1201,12 +1203,11 @@
 				return null;
 			}
 
-			
-// Vergrößerung um 10% nochmal rausgenommen
-//			// // Kartenbereich um 10% vergroessern
-//			return JTSUtil.fixAspectRatio(getVisibleRect(), JTSUtil
-//					.expandEnvelope(layerBounds, 0.1), true);
-			
+			// Vergrößerung um 10% nochmal rausgenommen
+			// // // Kartenbereich um 10% vergroessern
+			// return JTSUtil.fixAspectRatio(getVisibleRect(), JTSUtil
+			// .expandEnvelope(layerBounds, 0.1), true);
+
 			return JTSUtil.fixAspectRatio(getVisibleRect(), layerBounds, true);
 		}
 		return maxExtend;
@@ -1425,7 +1426,7 @@
 	 * Called by the {@link RenderingExecutor} when rendering was cancelled.
 	 */
 	public void onRenderingCancelled() {
-//		LOGGER.debug("Rendering cancelled");
+		// LOGGER.debug("Rendering cancelled");
 		repaintTimer.stop();
 	}
 
@@ -1434,7 +1435,7 @@
 	 * completed.
 	 */
 	public void onRenderingCompleted() {
-//		LOGGER.debug("complete");
+		// LOGGER.debug("complete");
 
 		repaintTimer.stop();
 
@@ -1486,6 +1487,12 @@
 
 		if (!isWellDefined())
 			return;
+		
+		if (paneResized) {
+			((Graphics2D)g).setBackground(getMapBackgroundColor());
+			g.clearRect(0, 0, getVisibleRect().width, getVisibleRect().height);
+		}
+			
 
 		// super.paintComponent(g); // candidate for removal
 



More information about the Schmitzm-commits mailing list