[Schmitzm-commits] r1148 - in trunk: src/schmitzm/geotools/gui src_junit/schmitzm/geotools/gui

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Oct 18 10:11:57 CEST 2010


Author: alfonx
Date: 2010-10-18 10:11:57 +0200 (Mon, 18 Oct 2010)
New Revision: 1148

Modified:
   trunk/src/schmitzm/geotools/gui/XMapPane.java
   trunk/src_junit/schmitzm/geotools/gui/XMapPaneTest.java
Log:


Modified: trunk/src/schmitzm/geotools/gui/XMapPane.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/XMapPane.java	2010-10-18 08:01:02 UTC (rev 1147)
+++ trunk/src/schmitzm/geotools/gui/XMapPane.java	2010-10-18 08:11:57 UTC (rev 1148)
@@ -603,8 +603,9 @@
 		public void propertyChange(PropertyChangeEvent evt) {
 			setRenderLanguage((String) evt.getNewValue());
 			refresh();
-			System.out.println("activeLanguageChangeListener called with lang "+(String) evt.getNewValue());
-			
+			System.out.println("activeLanguageChangeListener called with lang "
+					+ (String) evt.getNewValue());
+
 		}
 	};
 
@@ -612,6 +613,10 @@
 		this(null, null);
 	}
 
+	protected void finalize() throws Throwable {
+		dispose();
+	};
+
 	/**
 	 * full constructor extending JPanel
 	 * 
@@ -1005,13 +1010,16 @@
 	public void dispose() {
 		if (isDisposed())
 			return;
+		
+		disposed = true;
 
+		Translation.removeActiveLangListener(activeLanguageChangeListener);
+
 		setPainting(false);
 
 		resizeTimer.stop();
 		startRenderThreadsTimer.stop();
 
-		disposed = true;
 
 		if (bgExecuter != null) {
 			bgExecuter.cancelTask();

Modified: trunk/src_junit/schmitzm/geotools/gui/XMapPaneTest.java
===================================================================
--- trunk/src_junit/schmitzm/geotools/gui/XMapPaneTest.java	2010-10-18 08:01:02 UTC (rev 1147)
+++ trunk/src_junit/schmitzm/geotools/gui/XMapPaneTest.java	2010-10-18 08:11:57 UTC (rev 1148)
@@ -5,6 +5,8 @@
 
 import org.geotools.filter.function.EnvFunction;
 import org.geotools.geometry.jts.ReferencedEnvelope;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 import org.opengis.filter.FilterFactory2;
 import org.opengis.filter.expression.Function;
@@ -15,11 +17,21 @@
 
 public class XMapPaneTest {
 
+	private XMapPane xMapPane;
+
+	@Before
+	public void before() {
+		xMapPane = new XMapPane();
+	}
+
+	@After
+	public void after() {
+		xMapPane.dispose();
+	}
+
 	@Test
 	public void testBestAllowedMapArea() {
 
-		XMapPane xMapPane = new XMapPane();
-
 		ReferencedEnvelope zeroWidthBBOx = new ReferencedEnvelope(1, 1, 2, 2,
 				GTUtil.WGS84);
 		assertEquals(0., zeroWidthBBOx.getWidth(), 0.);
@@ -35,8 +47,6 @@
 	@Test
 	public void testBestAllowedMapArea2() {
 
-		XMapPane xMapPane = new XMapPane();
-
 		xMapPane.setMaxZoomScale(null);
 
 		assertTrue(xMapPane.getMaxZoomScale() != 1.);
@@ -65,16 +75,15 @@
 	 */
 	@Test
 	public void testChangeRenderLanguageListener() {
-		XMapPane mapPane = new XMapPane();
 
-		mapPane.setRenderLanguage("de");
-		assertEquals("de", mapPane.getRenderLanguage());
-
 		Translation.setActiveLang("ru");
-		assertEquals("ru", mapPane.getRenderLanguage());
+		assertEquals("ru", xMapPane.getRenderLanguage());
 
+		xMapPane.setRenderLanguage("de");
+		assertEquals("de", xMapPane.getRenderLanguage());
+
 		Translation.setActiveLang("fr");
-		assertEquals("fr", mapPane.getRenderLanguage());
+		assertEquals("fr", xMapPane.getRenderLanguage());
 	}
 
 }



More information about the Schmitzm-commits mailing list