[Schmitzm-commits] r1034 - in branches/2.2.x/src/schmitzm/geotools: feature gui styling

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


Author: mojays
Date: 2010-09-22 10:55:00 +0200 (Wed, 22 Sep 2010)
New Revision: 1034

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

Modified: branches/2.2.x/src/schmitzm/geotools/feature/FeatureUtil.java
===================================================================
--- branches/2.2.x/src/schmitzm/geotools/feature/FeatureUtil.java	2010-09-21 14:40:11 UTC (rev 1033)
+++ branches/2.2.x/src/schmitzm/geotools/feature/FeatureUtil.java	2010-09-22 08:55:00 UTC (rev 1034)
@@ -515,7 +515,7 @@
 	public static SimpleFeature[] featuresToArray(
 			FeatureCollection<SimpleFeatureType, SimpleFeature> fc,
 			boolean includeNullFeatures) {
-		if (fc == null || fc.isEmpty())
+		if (fc == null || fc.size() == 0 /*fc.isEmpty()*/ )
 			return new SimpleFeature[0];
 
 		// long startTime = System.currentTimeMillis();

Modified: branches/2.2.x/src/schmitzm/geotools/gui/XMapPane.java
===================================================================
--- branches/2.2.x/src/schmitzm/geotools/gui/XMapPane.java	2010-09-21 14:40:11 UTC (rev 1033)
+++ branches/2.2.x/src/schmitzm/geotools/gui/XMapPane.java	2010-09-22 08:55:00 UTC (rev 1034)
@@ -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();
 			}
 
 		});
@@ -795,7 +795,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);
 
@@ -875,7 +875,7 @@
 
 					// LOGGER.debug("and fix aspect ratio");
 
-					newArea = JTSUtil.fixAspectRatio(getVisibleRect(),
+					newArea = JTSUtil.fixAspectRatio(getMapPaneSize(),
 							new ReferencedEnvelope(newArea, env
 									.getCoordinateReferenceSystem()), false);
 				}
@@ -900,7 +900,7 @@
 
 					// LOGGER.debug("and fix aspect ratio");
 
-					newArea = JTSUtil.fixAspectRatio(getVisibleRect(),
+					newArea = JTSUtil.fixAspectRatio(getMapPaneSize(),
 							new ReferencedEnvelope(newArea, env
 									.getCoordinateReferenceSystem()), false);
 				}
@@ -927,7 +927,7 @@
 
 					// LOGGER.debug("and fix aspect ratio");
 
-					newArea = JTSUtil.fixAspectRatio(getVisibleRect(),
+					newArea = JTSUtil.fixAspectRatio(getMapPaneSize(),
 							new ReferencedEnvelope(newArea, env
 									.getCoordinateReferenceSystem()), false);
 				}
@@ -954,7 +954,7 @@
 
 					// LOGGER.debug("and fix aspect ratio");
 
-					newArea = JTSUtil.fixAspectRatio(getVisibleRect(),
+					newArea = JTSUtil.fixAspectRatio(getMapPaneSize(),
 							new ReferencedEnvelope(newArea, env
 									.getCoordinateReferenceSystem()), false);
 				}
@@ -1087,7 +1087,7 @@
 		if (getPreFinalImage() == null)
 			return false;
 
-		final Rectangle visibleArea = getVisibleRect();
+		final Rectangle visibleArea = getMapPaneSize();
 
 		// Calculate the oldMapArea in the current WindowCoordinates:
 		final Envelope oldMapWindow = tranformGeoToWindow(oldMapArea.getMinX(),
@@ -1136,8 +1136,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());
 		}
 
@@ -1154,9 +1154,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();
@@ -1170,8 +1170,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());
 		}
 
@@ -1273,7 +1273,7 @@
 				return null;
 			}
 
-			return JTSUtil.fixAspectRatio(getVisibleRect(),
+			return JTSUtil.fixAspectRatio(getMapPaneSize(),
 					addDefaultMargin(layerBounds), true);
 
 		}
@@ -1432,9 +1432,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;
@@ -1611,8 +1611,8 @@
 		//
 		// if (paneResized) {
 		// // ((Graphics2D) g).setBackground(getMapBackgroundColor());
-		// // g.clearRect(0, 0, getVisibleRect().width,
-		// getVisibleRect().height);
+		// // g.clearRect(0, 0, getMapPaneSize().width,
+		// getMapPaneSize().height);
 		// return;
 		// }
 
@@ -1663,7 +1663,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());
 		}
 	}
 
@@ -1719,7 +1719,7 @@
 	// */
 	// public void performPan() {
 	//
-	// final Rectangle winBounds = getVisibleRect();
+	// final Rectangle winBounds = getMapPaneSize();
 	//
 	// winBounds.translate(-imageOrigin.x, -imageOrigin.y);
 	// final Envelope newMapArea = tranformWindowToGeo(winBounds.x,
@@ -1788,7 +1788,7 @@
 	 */
 	private void resetTransforms() {
 		// System.out
-		// .println("paintArea in resetTeansofrms = " + getVisibleRect());
+		// .println("paintArea in resetTeansofrms = " + getMapPaneSize());
 		if (!isWellDefined())
 			return;
 
@@ -1801,7 +1801,7 @@
 		// TODO Die
 
 		worldToScreen = RendererUtilities.worldToScreenTransform(refMapEnv,
-				getVisibleRect());
+		    getMapPaneSize());
 
 		try {
 			if (worldToScreen != null)
@@ -2104,6 +2104,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 #getVisibleRect()}, because
+	 * of rendering problems when the map pane is hidden partly by a
+	 * scroll pane (in ISDSS).
+	 */
+	protected Rectangle getMapPaneSize() {
+	  //return getVisibleRect();
+	  return new Rectangle(getWidth(),getHeight());
+	}
 
 	/**
 	 * Starts rendering on one or two threads
@@ -2130,8 +2143,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
 		 */
@@ -2302,7 +2315,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);
@@ -2326,9 +2339,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);
 		}
 

Modified: branches/2.2.x/src/schmitzm/geotools/styling/StylingUtil.java
===================================================================
--- branches/2.2.x/src/schmitzm/geotools/styling/StylingUtil.java	2010-09-21 14:40:11 UTC (rev 1033)
+++ branches/2.2.x/src/schmitzm/geotools/styling/StylingUtil.java	2010-09-22 08:55:00 UTC (rev 1034)
@@ -898,6 +898,12 @@
 	 */
 	public static Style createStyleFromSLD(Element element) {
 		String xmlDefinition = new XMLOutputter().outputString(element);
+		// TODO: Workaround, because gt2-2.6.x has problems when the
+        //       ColorMapEntries are not in the ascending order according to
+        //       their values
+		// --> maybe we can bring the XML-Elements to an ascending order
+		//     prior to interprete the XML
+		
 		ByteArrayInputStream inputStream = null;
 		try {
 			inputStream = new ByteArrayInputStream(xmlDefinition.getBytes());



More information about the Schmitzm-commits mailing list