[Schmitzm-commits] r1358 - in trunk: src/schmitzm/geotools/styling src/schmitzm/lang src_junit/schmitzm/geotools/styling

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sat Dec 25 13:28:47 CET 2010


Author: alfonx
Date: 2010-12-25 13:28:45 +0100 (Sat, 25 Dec 2010)
New Revision: 1358

Modified:
   trunk/src/schmitzm/geotools/styling/StylingUtil.java
   trunk/src/schmitzm/lang/LangUtil.java
   trunk/src_junit/schmitzm/geotools/styling/StylingUtilTest.java
Log:
Christmas code cleanup ...

Modified: trunk/src/schmitzm/geotools/styling/StylingUtil.java
===================================================================
--- trunk/src/schmitzm/geotools/styling/StylingUtil.java	2010-12-20 00:52:42 UTC (rev 1357)
+++ trunk/src/schmitzm/geotools/styling/StylingUtil.java	2010-12-25 12:28:45 UTC (rev 1358)
@@ -328,7 +328,7 @@
 	 * @param style
 	 *            the {@link Style} to be copied.
 	 */
-	public static Style clone(Style style) {
+	public static Style copy(Style style) {
 		DuplicatingStyleVisitor duplicatingStyleVisitor = new DuplicatingStyleVisitor();
 		style.accept(duplicatingStyleVisitor);
 		return (Style) duplicatingStyleVisitor.getCopy();
@@ -337,7 +337,7 @@
 	/**
 	 * Clones a {@link Symbolizer} using the {@link DuplicatingStyleVisitor}.
 	 */
-	public static Symbolizer clone(Symbolizer sym) {
+	public static Symbolizer copy(Symbolizer sym) {
 		DuplicatingStyleVisitor duplicatingStyleVisitor = new DuplicatingStyleVisitor();
 		sym.accept(duplicatingStyleVisitor);
 		return (Symbolizer) duplicatingStyleVisitor.getCopy();
@@ -376,6 +376,8 @@
 	 * 
 	 * @return <code>null</code> wenn der uebergebene ColorMapEntry
 	 *         <code>null</code> ist
+	 *         
+	 *         TODO doppelt mit copy( ColorMapEntry? )
 	 */
 	public static ColorMapEntry cloneColorMapEntry(ColorMapEntry colorMapEntry) {
 		if (colorMapEntry == null)
@@ -434,12 +436,10 @@
 	 * @return <code>null</code> wenn der uebergebene ColorMapEntry
 	 *         <code>null</code> ist
 	 */
-	public static ColorMapEntry ColorMapEntry(ColorMapEntry colorMapEntry) {
+	public static ColorMapEntry copy(ColorMapEntry colorMapEntry) {
 		DuplicatingStyleVisitor duplicatingStyleVisitor = new DuplicatingStyleVisitor();
 		colorMapEntry.accept(duplicatingStyleVisitor);
 		return (ColorMapEntry) duplicatingStyleVisitor.getCopy();
-
-		// if (colorMapEntry == null)
 		// return null;
 		//
 		// return createColorMapEntry(colorMapEntry.getLabel(),
@@ -475,36 +475,6 @@
 		return true;
 	}
 
-	/***************************************************************************
-	 * Copies all Values from one {@link TextSymbolizer} to another
-	 * {@link TextSymbolizer}
-	 * 
-	 * @param from
-	 *            {@link TextSymbolizer} source
-	 * @param to
-	 *            {@link TextSymbolizer} target. May not be <code>null</code>.
-	 * 
-	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
-	 */
-	public static void copyAllValues(final TextSymbolizer from,
-			final TextSymbolizer to) {
-		to.setLabel(from.getLabel());
-		to.setPriority(from.getPriority());
-
-		// TODO Does not copy all that has to be copied!
-
-		final FilterFactory2 ff2 = FeatureUtil.FILTER_FACTORY2;
-
-		to.getFonts()[0].setFontFamily(ff2.literal(from.getFonts()[0]
-				.getFontFamily().toString()));
-		to.getFonts()[0].setFontSize(ff2.literal(from.getFonts()[0]
-				.getFontSize().toString()));
-		to.getFonts()[0].setFontWeight(ff2.literal(from.getFonts()[0]
-				.getFontWeight().toString()));
-		to.getFonts()[0].setFontStyle(ff2.literal(from.getFonts()[0]
-				.getFontStyle().toString()));
-	}
-
 	/**
 	 * Since GT2.6, the AttributeNames are case sensitive. Also the raster
 	 * Styles need GeometryProperty set to "geom" to work. This method checks
@@ -642,9 +612,6 @@
 
 			@Override
 			public void visit(TextSymbolizer sym) {
-				// sym.setGeometryPropertyName(FeatureUtil
-				// .findBestMatchingAttributeFallBackFirst(schema,
-				// sym.getGeometryPropertyName()).getLocalPart());
 				correctGeometryPropertyname(schema, sym);
 
 				if (sym.getLabel() != null)

Modified: trunk/src/schmitzm/lang/LangUtil.java
===================================================================
--- trunk/src/schmitzm/lang/LangUtil.java	2010-12-20 00:52:42 UTC (rev 1357)
+++ trunk/src/schmitzm/lang/LangUtil.java	2010-12-25 12:28:45 UTC (rev 1358)
@@ -1472,7 +1472,7 @@
 			return Logger.getLogger(((Class) object).getName());
 		return Logger.getLogger(object.getClass().getName());
 	}
-
+	
 	/**
 	 * Erzeugt einen Error- und einen Debug-Eintrag in einem Logger. Der
 	 * Error-Eintrag erhaelt nur die Meldung, der Debug-Eintrag auch die

Modified: trunk/src_junit/schmitzm/geotools/styling/StylingUtilTest.java
===================================================================
--- trunk/src_junit/schmitzm/geotools/styling/StylingUtilTest.java	2010-12-20 00:52:42 UTC (rev 1357)
+++ trunk/src_junit/schmitzm/geotools/styling/StylingUtilTest.java	2010-12-25 12:28:45 UTC (rev 1358)
@@ -170,11 +170,26 @@
 
 	@Test
 	public void testCorrectGeometryPropertynamePolygon() throws IOException {
-		PolygonSymbolizer ps = StylingUtil.STYLE_BUILDER.createPolygonSymbolizer();
-		FeatureSource<SimpleFeatureType, SimpleFeature> fs = TestingUtil.TestDatasetsVector.polygonSnow.getFeatureSource();
+		PolygonSymbolizer ps = StylingUtil.STYLE_BUILDER
+				.createPolygonSymbolizer();
+		FeatureSource<SimpleFeatureType, SimpleFeature> fs = TestingUtil.TestDatasetsVector.polygonSnow
+				.getFeatureSource();
 		assertNull(ps.getGeometryPropertyName());
 		StylingUtil.correctGeometryPropertyname(fs.getSchema(), ps);
 		assertEquals("the_geom", ps.getGeometryPropertyName());
 	}
 
+	@Test
+	public void testCopyColorMapEntry() {
+		ColorMapEntry cme = StylingUtil.createColorMapEntry("aLabel", 102.,
+				Color.RED, .8);
+
+		ColorMapEntry cme2 = StylingUtil.copy(cme);
+
+		assertEquals(cme.getLabel(), cme2.getLabel());
+		assertEquals(cme.getQuantity(), cme2.getQuantity());
+		assertEquals(cme.getOpacity(), cme2.getOpacity());
+		assertEquals(cme.getColor(), cme2.getOpacity());
+	}
+
 }



More information about the Schmitzm-commits mailing list