[Schmitzm-commits] r1436 - in trunk/schmitzm-gt/src: main/java/de/schmitzm/geotools/gui test/java/de/schmitzm/geotools test/java/de/schmitzm/geotools/gui

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Jan 27 13:34:14 CET 2011


Author: alfonx
Date: 2011-01-27 13:34:14 +0100 (Thu, 27 Jan 2011)
New Revision: 1436

Added:
   trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/gui/
   trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/gui/GridPanelFormatterTest.java
   trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/gui/ScalePanelTest.java
   trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/gui/XMapPaneTest.java
Modified:
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/XMapPaneTool.java
Log:


Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/XMapPaneTool.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/XMapPaneTool.java	2011-01-27 12:30:43 UTC (rev 1435)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/XMapPaneTool.java	2011-01-27 12:34:14 UTC (rev 1436)
@@ -227,7 +227,7 @@
 	static {
 		ZOOM_IN.icon = new ImageIcon(
 				XMapPaneTool.class
-						.getResource("/skrueger/geotools/resource/icons/zoom_in.png"));
+						.getResource("/de/schmitzm/geotools/gui/resource/icons/zoom_in.png"));
 		ZOOM_IN.toolTip = R("MapPaneButtons.ZoomIn.TT");
 		ZOOM_IN.cursor = SwingUtil.ZOOMIN_CURSOR;
 
@@ -249,7 +249,7 @@
 	static {
 		ZOOM_OUT.icon = new ImageIcon(
 				XMapPaneTool.class
-						.getResource("/skrueger/geotools/resource/icons/zoom_out.png"));
+						.getResource("/de/schmitzm/geotools/gui/resource/icons/zoom_out.png"));
 		ZOOM_OUT.toolTip = R("MapPaneButtons.ZoomOut.TT");
 		ZOOM_OUT.cursor = SwingUtil.ZOOMOUT_CURSOR;
 
@@ -274,7 +274,7 @@
 	static {
 		PAN.icon = new ImageIcon(
 				XMapPaneTool.class
-						.getResource("/skrueger/geotools/resource/icons/pan.png"));
+						.getResource("/de/schmitzm/geotools/gui/resource/icons/pan.png"));
 		PAN.toolTip = R("MapPaneButtons.Pan.TT");
 		PAN.cursor = SwingUtil.PAN_CURSOR;
 
@@ -296,7 +296,7 @@
 	static {
 		SELECTION_TOP_LAYER.icon = new ImageIcon(
 				XMapPaneTool.class
-						.getResource("/skrueger/geotools/resource/icons/selection_set.png"));
+						.getResource("/de/schmitzm/geotools/gui/resource/icons/selection_set.png"));
 
 		SELECTION_TOP_LAYER.cursor = SwingUtil.SELECTION_SET_CURSOR;
 
@@ -321,7 +321,7 @@
 	static {
 		SELECTION_ONE_FROM_TOP_LAYER.icon = new ImageIcon(
 				XMapPaneTool.class
-						.getResource("/skrueger/geotools/resource/icons/selection_set.png"));
+						.getResource("/de/schmitzm/geotools/gui/resource/icons/selection_set.png"));
 
 		SELECTION_ONE_FROM_TOP_LAYER.cursor = SwingUtil.SELECTION_SET_CURSOR;
 
@@ -346,7 +346,7 @@
 	static {
 		SELECTION_ALL_LAYERS.icon = new ImageIcon(
 				XMapPaneTool.class
-						.getResource("/skrueger/geotools/resource/icons/selection_set.png"));
+						.getResource("/de/schmitzm/geotools/gui/resource/icons/selection_set.png"));
 
 		SELECTION_ALL_LAYERS.cursor = SwingUtil.SELECTION_SET_CURSOR;
 
@@ -372,7 +372,7 @@
 	static {
 		INFO.icon = new ImageIcon(
 				XMapPaneTool.class
-						.getResource("/skrueger/geotools/resource/icons/info.png"));
+						.getResource("/de/schmitzm/geotools/gui/resource/icons/info.png"));
 
 		INFO.toolTip = R("MapPaneButtons.Info.TT");
 		INFO.cursor = SwingUtil.INFO_CURSOR;
@@ -394,7 +394,7 @@
 	static {
 		SELECTION_ADD.icon = new ImageIcon(
 				XMapPaneTool.class
-						.getResource("/skrueger/geotools/resource/icons/selection_add.png"));
+						.getResource("/de/schmitzm/geotools/gui/resource/icons/selection_add.png"));
 
 		SELECTION_ADD.toolTip = R("MapPaneButtons.Selection.AddSelection.TT"); // TODO
 		// move
@@ -423,7 +423,7 @@
 	static {
 		SELECTION_REMOVE.icon = new ImageIcon(
 				XMapPaneTool.class
-						.getResource("/skrueger/geotools/resource/icons/selection_remove.png"));
+						.getResource("/de/schmitzm/geotools/gui/resource/icons/selection_remove.png"));
 
 		SELECTION_REMOVE.toolTip = R("MapPaneButtons.Selection.RemoveSelection.TT"); // TODO
 		// move
@@ -452,7 +452,7 @@
 	static {
 		SELECTION_SET.icon = new ImageIcon(
 				XMapPaneTool.class
-						.getResource("/skrueger/geotools/resource/icons/selection_set.png"));
+						.getResource("/de/schmitzm/geotools/gui/resource/icons/selection_set.png"));
 
 		SELECTION_SET.toolTip = R("MapPaneButtons.Selection.SetSelection.TT"); // TODO
 		// move

Added: trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/gui/GridPanelFormatterTest.java
===================================================================
--- trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/gui/GridPanelFormatterTest.java	2011-01-27 12:30:43 UTC (rev 1435)
+++ trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/gui/GridPanelFormatterTest.java	2011-01-27 12:34:14 UTC (rev 1436)
@@ -0,0 +1,56 @@
+package de.schmitzm.geotools.gui;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import de.schmitzm.testing.TestingClass;
+public class GridPanelFormatterTest extends TestingClass {
+
+	XMapPane xMapPane = null;
+
+	@Before
+	public void setupBeforeTest() {
+		xMapPane = new XMapPane();
+	}
+
+	@Test
+	public void testGetWidthForVertical_LatLon() {
+		GridPanelFormatter_LatLon1 gridPanelFormatterLatLon1 = new GridPanelFormatter_LatLon1();
+
+		GridPanel gridPanel = new GridPanel(GridPanel.VERTICAL, xMapPane);
+
+		int widthForVertical = gridPanelFormatterLatLon1
+				.getWidthForVertical(gridPanel);
+
+		assertTrue(widthForVertical > 1);
+
+	}
+
+	@Test
+	public void testGetWidthForVertical_DHDN() {
+		GridPanelFormatter_DHDN gridPanelFormatterDHDN = new GridPanelFormatter_DHDN();
+
+		GridPanel gridPanel = new GridPanel(GridPanel.VERTICAL, xMapPane);
+
+		int widthForVertical = gridPanelFormatterDHDN
+				.getWidthForVertical(gridPanel);
+
+		assertTrue(widthForVertical > 1);
+
+	}
+
+	@Test
+	public void testGetHeightForHorizontal() {
+		GridPanelFormatter_LatLon1 gridPanelFormatterLatLon1 = new GridPanelFormatter_LatLon1();
+
+		GridPanel gridPanel = new GridPanel(GridPanel.HORIZONTAL, xMapPane);
+
+		int heightForHorizontal = gridPanelFormatterLatLon1
+				.getHeightForHorizontal(gridPanel);
+
+		assertTrue(heightForHorizontal > 1);
+	}
+
+}
\ No newline at end of file


Property changes on: trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/gui/GridPanelFormatterTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id URL
Name: svn:eol-style
   + native

Added: trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/gui/ScalePanelTest.java
===================================================================
--- trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/gui/ScalePanelTest.java	2011-01-27 12:30:43 UTC (rev 1435)
+++ trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/gui/ScalePanelTest.java	2011-01-27 12:34:14 UTC (rev 1436)
@@ -0,0 +1,41 @@
+package de.schmitzm.geotools.gui;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+import de.schmitzm.data.DistanceUnit;
+import de.schmitzm.geotools.gui.ScalePanel.ScaleUnits;
+import de.schmitzm.testing.TestingClass;
+public class ScalePanelTest extends TestingClass {
+
+  @Test
+  public void testScalePanel_DistanceUnit() {
+    assertEquals(0.001,DistanceUnit.METERS.getConversionFactor(DistanceUnit.KM),0.0);
+    assertEquals(1000.0,DistanceUnit.KM.getConversionFactor(DistanceUnit.METERS),0.0);
+    
+    assertEquals(1.609344,DistanceUnit.MILES.getConversionFactor(DistanceUnit.KM),0.0);
+    assertEquals(1/1.609344,DistanceUnit.KM.getConversionFactor(DistanceUnit.MILES),0.0);
+
+    assertEquals(1760,DistanceUnit.MILES.getConversionFactor(DistanceUnit.YARDS),0.0);
+    assertEquals(1/1760.0,DistanceUnit.YARDS.getConversionFactor(DistanceUnit.MILES),0.0);
+
+    assertEquals(3,DistanceUnit.YARDS.getConversionFactor(DistanceUnit.FEET),0.0);
+    assertEquals(1/3.0,DistanceUnit.FEET.getConversionFactor(DistanceUnit.YARDS),0.0);
+
+    assertEquals(1760*3,DistanceUnit.MILES.getConversionFactor(DistanceUnit.FEET),0.0);
+    assertEquals(1/(1760.0*3),DistanceUnit.FEET.getConversionFactor(DistanceUnit.MILES),0.0);
+
+    assertEquals(0.9144,DistanceUnit.YARDS.getConversionFactor(DistanceUnit.METERS),0.0001);
+    assertEquals(1.0936133,DistanceUnit.METERS.getConversionFactor(DistanceUnit.YARDS),0.000001);
+
+    assertEquals(3.2808399,DistanceUnit.METERS.getConversionFactor(DistanceUnit.FEET),0.001);
+    assertEquals(1/3.2808399,DistanceUnit.FEET.getConversionFactor(DistanceUnit.METERS),0.001);
+
+    assertEquals(1.234,DistanceUnit.METERS.convertDistanceTo(1234, DistanceUnit.KM),0.0);
+    assertEquals(12070.08,DistanceUnit.MILES.convertDistanceTo(7.5, DistanceUnit.METERS),0.0);
+    
+    System.out.println( ScalePanel.convertScaleToLabelUnit(1.68, DistanceUnit.MILES, ScaleUnits.US));
+  }
+
+}
\ No newline at end of file


Property changes on: trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/gui/ScalePanelTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id URL
Name: svn:eol-style
   + native

Added: trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/gui/XMapPaneTest.java
===================================================================
--- trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/gui/XMapPaneTest.java	2011-01-27 12:30:43 UTC (rev 1435)
+++ trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/gui/XMapPaneTest.java	2011-01-27 12:34:14 UTC (rev 1436)
@@ -0,0 +1,120 @@
+package de.schmitzm.geotools.gui;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.awt.Dimension;
+
+import org.geotools.data.FeatureSource;
+import org.geotools.filter.function.EnvFunction;
+import org.geotools.geometry.jts.ReferencedEnvelope;
+import org.geotools.map.DefaultMapLayer;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.opengis.feature.simple.SimpleFeature;
+import org.opengis.feature.simple.SimpleFeatureType;
+import org.opengis.filter.FilterFactory2;
+import org.opengis.filter.expression.Function;
+
+import de.schmitzm.geotools.GTUtil;
+import de.schmitzm.geotools.feature.FeatureUtil;
+import de.schmitzm.geotools.styling.StylingUtil;
+import de.schmitzm.geotools.testing.GTTestingUtil;
+import de.schmitzm.i18n.Translation;
+import de.schmitzm.testing.TestingClass;
+
+public class XMapPaneTest extends TestingClass {
+
+	private XMapPane xMapPane;
+
+	@Before
+	public void before() {
+		xMapPane = new XMapPane();
+	}
+
+	@After
+	public void after() {
+		xMapPane.dispose();
+	}
+
+	@Test
+	public void testBestAllowedMapArea() {
+
+		ReferencedEnvelope zeroWidthBBOx = new ReferencedEnvelope(1, 1, 2, 2,
+				GTUtil.WGS84);
+		assertEquals(0., zeroWidthBBOx.getWidth(), 0.);
+		assertEquals(0., zeroWidthBBOx.getHeight(), 0.);
+		ReferencedEnvelope corrected = xMapPane
+				.bestAllowedMapArea(zeroWidthBBOx);
+
+		assertTrue(corrected.getWidth() > 0.);
+		assertTrue(corrected.getHeight() > 0.);
+
+	}
+
+	@Test
+	public void testBestAllowedMapArea2() {
+
+		xMapPane.setMaxZoomScale(null);
+
+		assertTrue(xMapPane.getMaxZoomScale() != 1.);
+		assertTrue(xMapPane.getMaxZoomScale() < 1.);
+		assertTrue(xMapPane.getMaxZoomScale() == Double.MIN_VALUE);
+	}
+
+	@Test
+	public void testSetRenderLanguage() {
+		EnvFunction.setLocalValue(XMapPane.ENV_LANG, "de");
+		FilterFactory2 ff = FeatureUtil.FILTER_FACTORY2;
+
+		Function function = ff.function("env", ff.literal(XMapPane.ENV_LANG),
+				ff.literal("xx"));
+
+		System.out.println(function);
+
+		Object evaluated = function.evaluate(null);
+
+		System.out.println(evaluated);
+	}
+
+	/**
+	 * WHen the active language is change in {@link Translation}, it shoudl
+	 * automatically change in any {@link XMapPane}.
+	 */
+	@Test
+	public void testChangeRenderLanguageListener() {
+
+		Translation.setActiveLang("ru");
+		assertEquals("ru", xMapPane.getRenderLanguage());
+
+		xMapPane.setRenderLanguage("de");
+		assertEquals("de", xMapPane.getRenderLanguage());
+
+		Translation.setActiveLang("fr");
+		assertEquals("fr", xMapPane.getRenderLanguage());
+	}
+
+	@Test
+	public void testScaleDenominatorToScale() throws Throwable {
+
+		if (!isInteractive())
+			return;
+
+		FeatureSource<SimpleFeatureType, SimpleFeature> fs = GTTestingUtil.TestDatasetsVector.countryShp
+				.getFeatureSource();
+
+		xMapPane.getMapContext().addLayer(
+				new DefaultMapLayer(fs, StylingUtil.createDefaultStyle(fs)));
+
+		xMapPane.setPreferredSize(new Dimension(500, 500));
+		GTTestingUtil.testGui(xMapPane);
+
+		double s = xMapPane.getScale();
+
+		double sd = xMapPane.getScaleDenominator();
+		Double s2 = xMapPane.calculateScaleDenominatortoScale(sd,
+				xMapPane.getWidth());
+		assertEquals(s, s2, 0.00001);
+	}
+}
\ No newline at end of file


Property changes on: trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/gui/XMapPaneTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id URL
Name: svn:eol-style
   + native



More information about the Schmitzm-commits mailing list