[Schmitzm-commits] r1478 - in trunk/schmitzm-gt: . src/main/java/de/schmitzm/geotools/feature src/main/java/de/schmitzm/geotools/gui src/main/java/de/schmitzm/geotools/styling src/test/java/de/schmitzm/geotools/feature

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Feb 2 20:42:04 CET 2011


Author: alfonx
Date: 2011-02-02 20:42:02 +0100 (Wed, 02 Feb 2011)
New Revision: 1478

Added:
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/AttributeTypeFactory.java
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/RenderingState.java
Modified:
   trunk/schmitzm-gt/pom.xml
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/FeatureTypeBuilderTableModel.java
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/FeatureUtil.java
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StylingUtil.java
   trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/feature/FeatureUtilTest.java
Log:
Prepared for removal of 
		<dependency>
			<groupId>org.geotools</groupId>
			<artifactId>gt-legacy</artifactId>
			<version>${geotools.version}</version>
			<type>jar</type>
			<scope>compile</scope>
		</dependency>
only 12 compile errors left...

Modified: trunk/schmitzm-gt/pom.xml
===================================================================
--- trunk/schmitzm-gt/pom.xml	2011-02-02 19:30:05 UTC (rev 1477)
+++ trunk/schmitzm-gt/pom.xml	2011-02-02 19:42:02 UTC (rev 1478)
@@ -139,7 +139,7 @@
 
 			<exclusions>
 				<exclusion>
-				<!-- avoiding a version conflict...  -->
+					<!-- avoiding a version conflict... -->
 					<groupId>commons-logging</groupId>
 					<artifactId>commons-logging</artifactId>
 				</exclusion>

Added: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/AttributeTypeFactory.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/AttributeTypeFactory.java	2011-02-02 19:30:05 UTC (rev 1477)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/AttributeTypeFactory.java	2011-02-02 19:42:02 UTC (rev 1478)
@@ -0,0 +1,16 @@
+package de.schmitzm.geotools.feature;
+
+import org.geotools.feature.AttributeTypeBuilder;
+import org.opengis.feature.type.AttributeDescriptor;
+import org.opengis.filter.Filter;
+
+public class AttributeTypeFactory {
+
+	public static AttributeDescriptor newAttributeType(String newName,
+			Class<?> newClass, Boolean newNillable, Filter newRestrictions,
+			Object newDefaultValue, Object newMetaData) {
+		// ...
+		return new AttributeTypeBuilder().buildDescriptor(newName);
+	}
+
+}


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

Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/FeatureTypeBuilderTableModel.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/FeatureTypeBuilderTableModel.java	2011-02-02 19:30:05 UTC (rev 1477)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/FeatureTypeBuilderTableModel.java	2011-02-02 19:42:02 UTC (rev 1478)
@@ -41,7 +41,10 @@
 import javax.swing.JTextField;
 import javax.swing.table.TableModel;
 
+import org.geotools.feature.DefaultAttributeType;
+import org.geotools.feature.FeatureTypeBuilder;
 import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
+import org.geotools.feature.type.GeometricAttributeType;
 import org.opengis.feature.simple.SimpleFeatureType;
 import org.opengis.feature.type.AttributeDescriptor;
 import org.opengis.feature.type.GeometryDescriptor;

Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/FeatureUtil.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/FeatureUtil.java	2011-02-02 19:30:05 UTC (rev 1477)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/FeatureUtil.java	2011-02-02 19:42:02 UTC (rev 1478)
@@ -100,6 +100,7 @@
 import org.opengis.feature.simple.SimpleFeatureType;
 import org.opengis.feature.type.AttributeDescriptor;
 import org.opengis.feature.type.GeometryDescriptor;
+import org.opengis.feature.type.GeometryType;
 import org.opengis.feature.type.Name;
 import org.opengis.filter.Filter;
 import org.opengis.filter.FilterFactory;
@@ -151,7 +152,7 @@
 	 * Prueft, ob ein Attribut ein Geometrie-Attribut ist.
 	 */
 	public static boolean isGeometryAttribute(Object attrType) {
-		return attrType instanceof GeometryAttributeType
+		return attrType instanceof GeometryType
 				|| attrType instanceof GeometryDescriptor;
 	}
 
@@ -311,7 +312,7 @@
 		if (gDesc.getType() == null)
 			return GeometryForm.NONE;
 
-		return getGeometryForm(gDesc.getType().getBinding());
+		return getGeometryForm(gDesc.getType());
 	}
 
 	/**
@@ -320,8 +321,7 @@
 	 * @param geometryType
 	 *            a {@link GeometryAttributeType}
 	 */
-	public static GeometryForm getGeometryForm(
-			GeometryAttributeType geometryType) {
+	public static GeometryForm getGeometryForm(GeometryType geometryType) {
 
 		if (geometryType == null)
 			return GeometryForm.NONE;
@@ -728,7 +728,7 @@
 		for (AttributeDescriptor aType : fType.getAttributeDescriptors()) {
 			AttributeDescriptor aTypeClone = cloneAttributeType(aType, nillable);
 			builder.add(aTypeClone);
-			if (aTypeClone instanceof GeometryAttributeType
+			if (aTypeClone instanceof GeometryDescriptor
 					&& builder.getDefaultGeometry() == null)
 				builder.setDefaultGeometry(aTypeClone.getLocalName());
 		}
@@ -1925,6 +1925,30 @@
 	}
 
 	/**
+	 * @param geoObject
+	 *            Thie object my be a {@link FeatureCollection}, a
+	 *            {@link FeatureSource}, a {@link GeometryType} or a
+	 *            {@link GeometryDescriptor}.
+	 */
+	public static GeometryForm getGeometryForm(Object geoObject) {
+		GeometryForm geometryForm = null;
+		if (geoObject instanceof FeatureCollection) {
+			geometryForm = FeatureUtil
+					.getGeometryForm((FeatureCollection<SimpleFeatureType, SimpleFeature>) geoObject);
+		} else if (geoObject instanceof GeometryType) {
+			geometryForm = FeatureUtil
+					.getGeometryForm((GeometryType) geoObject);
+		} else if (geoObject instanceof GeometryDescriptor) {
+			geometryForm = FeatureUtil
+					.getGeometryForm((GeometryDescriptor) geoObject);
+		} else if (geoObject instanceof FeatureSource) {
+			geometryForm = FeatureUtil
+					.getGeometryForm((FeatureSource<SimpleFeatureType, SimpleFeature>) geoObject);
+		}
+		return geometryForm;
+	}
+
+	/**
 	 * Returns a {@link SimpleFeatureBuilder} for a given schema from cache. If
 	 * schema is not already used, a new builder is created and cached.
 	 * 

Added: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/RenderingState.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/RenderingState.java	2011-02-02 19:30:05 UTC (rev 1477)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/RenderingState.java	2011-02-02 19:42:02 UTC (rev 1478)
@@ -0,0 +1,6 @@
+package de.schmitzm.geotools.gui;
+
+public enum RenderingState {
+	ON_HOLD, RENDERING
+
+}


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

Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StylingUtil.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StylingUtil.java	2011-02-02 19:30:05 UTC (rev 1477)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StylingUtil.java	2011-02-02 19:42:02 UTC (rev 1478)
@@ -60,6 +60,7 @@
 import org.geotools.brewer.color.BrewerPalette;
 import org.geotools.brewer.color.PaletteSuitability;
 import org.geotools.brewer.color.SampleScheme;
+import org.geotools.coverage.AbstractCoverage;
 import org.geotools.coverage.Category;
 import org.geotools.coverage.GridSampleDimension;
 import org.geotools.coverage.grid.GridCoverage2D;
@@ -373,7 +374,7 @@
 	 * 
 	 * @return <code>null</code> wenn der uebergebene ColorMapEntry
 	 *         <code>null</code> ist
-	 *         
+	 * 
 	 *         TODO doppelt mit copy( ColorMapEntry? )
 	 */
 	public static ColorMapEntry cloneColorMapEntry(ColorMapEntry colorMapEntry) {
@@ -640,17 +641,7 @@
 		}
 
 		// We have vector-data. Now let's determine the type...
-		GeometryForm geometryForm = null;
-		if (geoObject instanceof FeatureCollection) {
-			geometryForm = FeatureUtil
-					.getGeometryForm((FeatureCollection<SimpleFeatureType, SimpleFeature>) geoObject);
-		} else if (geoObject instanceof GeometryAttributeType) {
-			geometryForm = FeatureUtil
-					.getGeometryForm((GeometryAttributeType) geoObject);
-		} else if (geoObject instanceof FeatureSource) {
-			geometryForm = FeatureUtil
-					.getGeometryForm((FeatureSource<SimpleFeatureType, SimpleFeature>) geoObject);
-		}
+		GeometryForm geometryForm = FeatureUtil.getGeometryForm(geoObject);
 
 		Symbolizer[] symbolizers = new Symbolizer[0];
 
@@ -831,12 +822,7 @@
 	 *              FeatureUtil.getGeometryForm
 	 */
 	public static Style createDefaultStyle(Object object) {
-		// null !
 
-		if (object instanceof GeometryForm) {
-			return FeatureUtil.createDefaultStyle((GeometryForm) object);
-		}
-
 		if (object instanceof StyledFeaturesInterface)
 			return FeatureUtil
 					.createDefaultStyle(((StyledFeaturesInterface<?>) object)
@@ -847,6 +833,10 @@
 				|| object instanceof StyledRasterInterface)
 			return GridUtil.createDefaultStyle();
 
+		if (object instanceof GeometryForm) {
+			return FeatureUtil.createDefaultStyle((GeometryForm) object);
+		}
+
 		if (object instanceof FeatureCollection)
 			return FeatureUtil
 					.createDefaultStyle((FeatureCollection<SimpleFeatureType, SimpleFeature>) object);
@@ -855,9 +845,8 @@
 			return FeatureUtil.createDefaultStyle(((FeatureSource) object)
 					.getSchema().getGeometryDescriptor());
 
-		if (object instanceof GeometryAttributeType)
-			return FeatureUtil
-					.createDefaultStyle((GeometryAttributeType) object);
+		if (object instanceof GeometryDescriptor)
+			return FeatureUtil.createDefaultStyle((GeometryDescriptor) object);
 
 		LOGGER.warn("createDefaultStyle could not handle " + object
 				+ " and returned an empty (invalid) Style");
@@ -1012,8 +1001,8 @@
 	public static FeatureTypeStyle createSelectionFTStyle(Object geoObject,
 			SelectionStylesTypes type) {
 
-		if (geoObject instanceof GridCoverage2D
-				|| geoObject instanceof org.geotools.coverage.grid.io.AbstractGridCoverage2DReader) {
+		if (geoObject instanceof AbstractCoverage
+				|| geoObject instanceof AbstractGridCoverage2DReader) {
 			// Wenn irgendwann mal selection für raster möglich ist, dann hier
 			// einen schöneren style erstellen.
 			return GridUtil.createDefaultStyle().featureTypeStyles().get(0);
@@ -1026,21 +1015,9 @@
 		}
 
 		// We have vector-data. Now let's determine the type...
-		GeometryForm geometryForm = null;
+		GeometryForm geometryForm = FeatureUtil.getGeometryForm(geoObject);
 
-		if (geoObject instanceof FeatureCollection) {
-			geometryForm = FeatureUtil
-					.getGeometryForm((FeatureCollection<SimpleFeatureType, SimpleFeature>) geoObject);
-		} else if (geoObject instanceof GeometryAttributeType) {
-			geometryForm = FeatureUtil
-					.getGeometryForm((GeometryAttributeType) geoObject);
-		} else if (geoObject instanceof FeatureSource) {
-			geometryForm = FeatureUtil
-					.getGeometryForm((FeatureSource<SimpleFeatureType, SimpleFeature>) geoObject);
-		}
-
 		return createSelectionFTStyle(geometryForm, type);
-
 	}
 
 	/**
@@ -1349,25 +1326,8 @@
 		}
 
 		// We have vector-data. Now let's determine the type...
-		GeometryForm geometryForm = null;
+		GeometryForm geometryForm = FeatureUtil.getGeometryForm(geoObject);
 
-		if (geoObject instanceof FeatureCollection) {
-			geometryForm = FeatureUtil
-					.getGeometryForm((FeatureCollection<SimpleFeatureType, SimpleFeature>) geoObject);
-		} else if (geoObject instanceof GeometryAttributeType) {
-			geometryForm = FeatureUtil
-					.getGeometryForm((GeometryAttributeType) geoObject);
-		} else if (geoObject instanceof FeatureSource) {
-			geometryForm = FeatureUtil
-					.getGeometryForm((FeatureSource<SimpleFeatureType, SimpleFeature>) geoObject);
-		}
-
-		// /**
-		// * Let's see if we have a cached version of the requested style.
-		// */
-		// if (selectionStyles.containsKey(geometryForm))
-		// return selectionStyles.get(geometryForm);
-
 		Style style = STYLE_FACTORY.createStyle();
 		style.featureTypeStyles().add(STYLE_FACTORY.createFeatureTypeStyle());
 		Symbolizer[] symbolizers = new Symbolizer[0];
@@ -1395,15 +1355,12 @@
 			// In case of ANY, create a Style with polygon and point
 			// symbolizers.
 
-			// ls = STYLE_BUILDER.createLineSymbolizer(STYLE_BUILDER
-			// .createStroke(color));
 			polS = STYLE_BUILDER.createPolygonSymbolizer(
 					STYLE_BUILDER.createStroke(color2),
 					STYLE_BUILDER.createFill(color));
 			ps = createPointSymbolizer(color, color2);
 
 			symbolizers = LangUtil.extendArray(symbolizers, polS);
-			// symbolizers = LangUtil.extendArray(symbolizers, ls);
 			symbolizers = LangUtil.extendArray(symbolizers, ps);
 			break;
 		case NONE:
@@ -1411,11 +1368,14 @@
 			throw new IllegalArgumentException("Provide a suitable object.");
 		}
 
-		style.getFeatureTypeStyles()[0].setRules(new Rule[] { STYLE_FACTORY
-				.createRule() });
-		style.getFeatureTypeStyles()[0].getRules()[0]
-				.setSymbolizers(symbolizers);
+		style.featureTypeStyles().get(0).rules().clear();
+		style.featureTypeStyles().get(0).rules()
+				.add(STYLE_FACTORY.createRule());
 
+		style.featureTypeStyles().get(0).rules().get(0).symbolizers().clear();
+		style.featureTypeStyles().get(0).rules().get(0).symbolizers()
+				.addAll(Arrays.asList(symbolizers));
+
 		return style;
 	}
 
@@ -2438,10 +2398,10 @@
 
 			if (!style2file.exists())
 				return true;
-			
+
 			if (style2file.length() == 0l && style1 != null)
 				return true;
-			
+
 			if (style2file.length() == 0l && style1 == null)
 				return false;
 
@@ -3142,36 +3102,36 @@
 		}
 		sym.setGeometryPropertyName(newGpn == null ? null : newGpn.toString());
 	}
-    /***************************************************************************
-     * 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:skpublic 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());
+	/***************************************************************************
+	 * 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:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
+	 */
 
-            // TODO Does not copy all that has to be copied!
+	public static void copyAllValues(final TextSymbolizer from,
+			final TextSymbolizer to) {
+		to.setLabel(from.getLabel());
+		to.setPriority(from.getPriority());
 
-            final FilterFactory2 ff2 = FeatureUtil.FILTER_FACTORY2;
+		// TODO Does not copy all that has to be copied!
 
-            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()));
-    }
+		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()));
+	}
 
 }

Modified: trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/feature/FeatureUtilTest.java
===================================================================
--- trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/feature/FeatureUtilTest.java	2011-02-02 19:30:05 UTC (rev 1477)
+++ trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/feature/FeatureUtilTest.java	2011-02-02 19:42:02 UTC (rev 1478)
@@ -18,11 +18,11 @@
 import org.geotools.data.FeatureSource;
 import org.geotools.data.shapefile.ShapefileDataStore;
 import org.geotools.feature.FeatureCollection;
-import org.geotools.feature.GeometryAttributeType;
 import org.junit.Test;
 import org.opengis.feature.simple.SimpleFeature;
 import org.opengis.feature.simple.SimpleFeatureType;
 import org.opengis.feature.type.GeometryDescriptor;
+import org.opengis.feature.type.GeometryType;
 
 import com.vividsolutions.jts.geom.Geometry;
 import com.vividsolutions.jts.geom.Point;
@@ -32,6 +32,7 @@
 import de.schmitzm.geotools.io.GeoImportUtil;
 import de.schmitzm.geotools.testing.GTTestingUtil.TestDatasetsVector;
 import de.schmitzm.testing.TestingClass;
+
 public class FeatureUtilTest extends TestingClass {
 
 	@Test
@@ -249,7 +250,7 @@
 		gf = FeatureUtil.getGeometryForm((FeatureSource) null);
 		assertEquals(GeometryForm.NONE, gf);
 
-		gf = FeatureUtil.getGeometryForm((GeometryAttributeType) null);
+		gf = FeatureUtil.getGeometryForm((GeometryType) null);
 		assertEquals(GeometryForm.NONE, gf);
 
 		gf = FeatureUtil.getGeometryForm((GeometryDescriptor) null);



More information about the Schmitzm-commits mailing list