[Schmitzm-commits] r553 - branches/1.0-gt2-2.6/src/skrueger/geotools

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Nov 23 22:39:18 CET 2009


Author: alfonx
Date: 2009-11-23 22:39:17 +0100 (Mon, 23 Nov 2009)
New Revision: 553

Modified:
   branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java
Log:
* XMapPane doesn't show rendering-exceptions in the pane by default, but it may be set with new function #setShowExceptions

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-23 15:48:16 UTC (rev 552)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java	2009-11-23 21:39:17 UTC (rev 553)
@@ -554,6 +554,9 @@
 
 	/** Is set if a renderer has an error **/
 	protected ArrayList<Exception> renderingErrors = new ArrayList<Exception>();
+	
+	/** If <code>true</code>, then rendering exceptions are rendererd into the map pane **/
+	private boolean showExceptions= false;
 
 	// /** If {@link #getVisibleRect()} of this {@link JPanel} is not yet
 	// defined, but we are **/
@@ -1411,9 +1414,15 @@
 	 * @see MapPaneListener#onRenderingStopped(org.geotools.swing.event.MapPaneEvent)
 	 */
 	public void onRenderingFailed(final Exception renderingError) {
-		this.renderingErrors.add(renderingError);
+
+		// Store the exceptions so we can show it to the user:
+		if (!(renderingError instanceof java.lang.IllegalArgumentException
+				&& renderingError.getMessage().equals(
+						"Argument \"sourceCRS\" should not be null.")))
+			this.renderingErrors.add(renderingError);
 		if (renderingErrors.size() > 3)
 			renderingErrors.remove(0);
+		
 		repaintTimer.stop();
 		LOGGER.warn("Rendering failed", renderingError);
 		updateFinalImage();
@@ -2191,18 +2200,13 @@
 			y += 24;
 		}
 
-		if (renderingErrors != null) {
+		if (renderingErrors != null && isShowExceptions()) {
 
 			final Color c = graphics.getColor();
 			graphics.setFont(errorFont);
 
 			for (Exception ex : renderingErrors) {
 
-				if (ex instanceof java.lang.IllegalArgumentException
-						&& ex.getMessage().equals(
-								"Argument \"sourceCRS\" should not be null."))
-					continue;
-
 				String errStr = ex.getLocalizedMessage();
 
 				if (errStr == null)
@@ -2364,4 +2368,19 @@
 		setMapArea(newMapArea);
 	}
 
+	/**
+	 * Shall non-fatal rendering exceptions be reported in the mappane or be
+	 * dropped quitely.
+	 */
+	public void setShowExceptions(boolean showExceptions) {
+		this.showExceptions = showExceptions;
+	}
+
+	/**
+	 * Shall exceptions be reported in the mappane?
+	 */
+	public boolean isShowExceptions() {
+		return showExceptions;
+	}
+
 }



More information about the Schmitzm-commits mailing list