[Schmitzm-commits] r83 - in trunk/src/schmitzm/geotools: . feature gui

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Apr 22 17:08:51 CEST 2009


Author: alfonx
Date: 2009-04-22 17:08:51 +0200 (Wed, 22 Apr 2009)
New Revision: 83

Modified:
   trunk/src/schmitzm/geotools/GTUtil.java
   trunk/src/schmitzm/geotools/feature/FeatureUtil.java
   trunk/src/schmitzm/geotools/gui/SelectableFeatureTablePane.java
Log:
* Removed the utility classes from GTUtil
* Added new function 
public static GeometryForm getGeometryForm(GeometryAttributeType geometryType) {..} 
to FeaturesUtil

Modified: trunk/src/schmitzm/geotools/GTUtil.java
===================================================================
--- trunk/src/schmitzm/geotools/GTUtil.java	2009-04-22 14:39:50 UTC (rev 82)
+++ trunk/src/schmitzm/geotools/GTUtil.java	2009-04-22 15:08:51 UTC (rev 83)
@@ -178,81 +178,5 @@
     // Subset nur bzgl. des Bereichs in dem auch das Raster liegt
     return JTS.getEnvelope2D(intersetionEnvJTS,crs);
   }
-  
-  /**
-	 * @return <code>true</code> if the given {@link FeatureSource}'s default
-	 *         Geometry contains polygons or multipolygons
-	 */
-	public static boolean isPolygon(FeatureSource featureSource) {
-		return isPolygon(featureSource.getSchema().getDefaultGeometry());
-	}
 
-	/**
-	 * @return <code>true</code> if the given {@link FeatureCollection}'s
-	 *         default Geometry contains polygons or multipolygons
-	 */
-	public static boolean isPolygon(FeatureCollection featureCollection) {
-		return isPolygon(featureCollection.getSchema().getDefaultGeometry());
-	}
-
-	/**
-	 * @return <code>true</code> if the given {@link GeometryAttributeType} is
-	 *         polygon or multipolygon
-	 */
-	public static boolean isPolygon(GeometryAttributeType geometryAttributeType) {
-		return (geometryAttributeType.getBinding() == MultiPolygon.class || geometryAttributeType
-				.getBinding() == Polygon.class);
-	}
-
-	/**
-	 * @return <code>true</code> if the given {@link FeatureSource}'s default
-	 *         Geometry contains points or multipoints
-	 */
-	public static boolean isPoint(FeatureSource featureSource) {
-		return isPoint(featureSource.getSchema().getDefaultGeometry());
-	}
-
-	/**
-	 * @return <code>true</code> if the given {@link FeatureCollection}'s
-	 *         default Geometry contains points or multipoints
-	 */
-	public static boolean isPoint(FeatureCollection featureCollection) {
-		return isPoint(featureCollection.getSchema().getDefaultGeometry());
-	}
-
-	/**
-	 * @return <code>true</code> if the given {@link GeometryAttributeType} is
-	 *         point or multipoint
-	 */
-	public static boolean isPoint(GeometryAttributeType geometryAttributeType) {
-		return (geometryAttributeType.getBinding() == Point.class || geometryAttributeType
-				.getBinding() == MultiPoint.class);
-	}
-
-	/**
-	 * @return <code>true</code> if the given {@link FeatureSource}'s default
-	 *         Geometry contains lines or multilines
-	 */
-	public static boolean isLineString(FeatureSource featureSource) {
-		return isLineString(featureSource.getSchema().getDefaultGeometry());
-	}
-
-	/**
-	 * @return <code>true</code> if the given {@link FeatureCollection}'s
-	 *         default Geometry contains lines or multilines
-	 */
-	public static boolean isLineString(FeatureCollection featureCollection) {
-		return isLineString(featureCollection.getSchema().getDefaultGeometry());
-	}
-
-	/**
-	 * @return <code>true</code> if the given {@link GeometryAttributeType} is
-	 *         line of multiline
-	 */
-	public static boolean isLineString(
-			GeometryAttributeType geometryAttributeType) {
-		return ((geometryAttributeType.getBinding() == LineString.class) || geometryAttributeType
-				.getBinding() == MultiLineString.class);
-	}
-
 }

Modified: trunk/src/schmitzm/geotools/feature/FeatureUtil.java
===================================================================
--- trunk/src/schmitzm/geotools/feature/FeatureUtil.java	2009-04-22 14:39:50 UTC (rev 82)
+++ trunk/src/schmitzm/geotools/feature/FeatureUtil.java	2009-04-22 15:08:51 UTC (rev 83)
@@ -131,24 +131,35 @@
   public static GeometryForm getGeometryForm(FeatureType fType) {
     if ( fType.getDefaultGeometry() == null )
       return null;
+    
+    GeometryAttributeType geometryType = fType.getDefaultGeometry();
+	return getGeometryForm(geometryType);
+  }
 
-    Class geomType = fType.getDefaultGeometry().getType();
-    // POINT
-    if ( Point.class.isAssignableFrom(geomType) ||
-        MultiPoint.class.isAssignableFrom(geomType) )
-     return GeometryForm.POINT;
-    // LINE
-    if ( LineString.class.isAssignableFrom(geomType) ||
-         MultiLineString.class.isAssignableFrom(geomType) )
-      return GeometryForm.LINE;
-    // POLYGON
-    if ( Polygon.class.isAssignableFrom(geomType) ||
-         MultiPolygon.class.isAssignableFrom(geomType) )
-      return GeometryForm.POLYGON;
+  /**
+	 * Determines the kind of geometry of a {@link GeometryAttributeType}.
+	 * 
+	 * @param geometryType
+	 *            a {@link GeometryAttributeType}
+	 */
+	public static GeometryForm getGeometryForm(
+			GeometryAttributeType geometryType) {
+		final Class geomType = geometryType.getType();
 
-    throw new UnsupportedOperationException("Unknown geometry type: "+geomType.getName());
-  }
+		if (Point.class.isAssignableFrom(geomType)
+				|| MultiPoint.class.isAssignableFrom(geomType))
+			return GeometryForm.POINT;
+		else if (LineString.class.isAssignableFrom(geomType)
+				|| MultiLineString.class.isAssignableFrom(geomType))
+			return GeometryForm.LINE;
+		else if (Polygon.class.isAssignableFrom(geomType)
+				|| MultiPolygon.class.isAssignableFrom(geomType))
+			return GeometryForm.POLYGON;
 
+		throw new UnsupportedOperationException("Unknown geometry type: "
+				+ geomType.getName());
+	}
+
   /**
    * Determines the kind of geometry of a {@link FeatureCollection}.
    * @param fc a feature collection
@@ -1138,5 +1149,6 @@
 //      gcArr[i] = (GeometryCollection)gcVec.elementAt(i);
 //    return gcArr;
 //  }
+  
 }
 

Modified: trunk/src/schmitzm/geotools/gui/SelectableFeatureTablePane.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/SelectableFeatureTablePane.java	2009-04-22 14:39:50 UTC (rev 82)
+++ trunk/src/schmitzm/geotools/gui/SelectableFeatureTablePane.java	2009-04-22 15:08:51 UTC (rev 83)
@@ -35,6 +35,7 @@
 import org.geotools.feature.FeatureCollection;
 
 import schmitzm.geotools.GTUtil;
+import schmitzm.geotools.feature.FeatureUtil;
 
 /**
  * Extends the {@link FeatureTablePane} with buttons and functionality to select
@@ -135,14 +136,18 @@
 		int totalAnz = getFeatureCollection().size();
 		String localizedGeometryTypeName = "rows";
 		
-		if ( GTUtil.isPolygon(getFeatureCollection())){
+		switch ( FeatureUtil.getGeometryForm(getFeatureCollection()) ){
+		case LINE:
+			localizedGeometryTypeName = GeotoolsGUIUtil.R("schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus.lines");
+			break;
+		case POLYGON:
 			localizedGeometryTypeName = GeotoolsGUIUtil.R("schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus.polygons");
-		} else if ( GTUtil.isPoint(getFeatureCollection())){
+			break;
+		case POINT:
 			localizedGeometryTypeName = GeotoolsGUIUtil.R("schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus.points");
-		}else if ( GTUtil.isLineString(getFeatureCollection())){
-			localizedGeometryTypeName = GeotoolsGUIUtil.R("schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus.lines");
+			break;
 		}
-	
+		
 		statusLabel.setText( GeotoolsGUIUtil.R("schmitzm.geotools.gui.SelectableFeatureTablePane.selectionStatus", selectedAnz, totalAnz,localizedGeometryTypeName));
 		
 		return statusLabel;



More information about the Schmitzm-commits mailing list