[Schmitzm-commits] r1479 - 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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Feb 2 21:30:16 CET 2011


Author: alfonx
Date: 2011-02-02 21:30:14 +0100 (Wed, 02 Feb 2011)
New Revision: 1479

Modified:
   trunk/schmitzm-gt/pom.xml
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/AttributeModificationRule.java
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/AttributeTypeFactory.java
   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/gui/JMapEditorPane.java
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/RenderingState.java
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StylingUtil.java
Log:
Removed gt-legacy from pom.xml:

Ich habe eine de.schmitzm.geotools.feature.AttributeTypeFactory erstellt, die von den Methoden her fast so ist wie die gt-legacy AttributeTypeFactory, dabei aber direkt die neue API benutzt

Modified: trunk/schmitzm-gt/pom.xml
===================================================================
--- trunk/schmitzm-gt/pom.xml	2011-02-02 19:42:02 UTC (rev 1478)
+++ trunk/schmitzm-gt/pom.xml	2011-02-02 20:30:14 UTC (rev 1479)
@@ -59,13 +59,13 @@
 			<scope>compile</scope>
 		</dependency>
 
-		<dependency>
-			<groupId>org.geotools</groupId>
-			<artifactId>gt-legacy</artifactId>
-			<version>${geotools.version}</version>
-			<type>jar</type>
-			<scope>compile</scope>
-		</dependency>
+<!--		<dependency>-->
+<!--			<groupId>org.geotools</groupId>-->
+<!--			<artifactId>gt-legacy</artifactId>-->
+<!--			<version>${geotools.version}</version>-->
+<!--			<type>jar</type>-->
+<!--			<scope>compile</scope>-->
+<!--		</dependency>-->
 
 		<dependency>
 			<groupId>org.geotools</groupId>

Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/AttributeModificationRule.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/AttributeModificationRule.java	2011-02-02 19:42:02 UTC (rev 1478)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/AttributeModificationRule.java	2011-02-02 20:30:14 UTC (rev 1479)
@@ -3,246 +3,284 @@
 import java.util.Set;
 
 import org.geotools.data.FeatureSource;
-import org.geotools.feature.AttributeTypeFactory;
 import org.opengis.feature.simple.SimpleFeature;
 import org.opengis.feature.type.AttributeDescriptor;
 import org.opengis.feature.type.GeometryDescriptor;
 import org.opengis.filter.Filter;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
 
+import com.vividsolutions.jts.geom.Geometry;
+
 import de.schmitzm.geotools.FilterUtil;
 
 /**
- * Defines an attribute modification during the 
+ * Defines an attribute modification during the
  * {@link FeatureUtil#modifyFeatureSource(org.geotools.data.FeatureSource, org.geotools.data.AbstractDataStore, AttributeModificationRule...)}
  * process.
+ * 
  * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
  */
 public class AttributeModificationRule {
-  /** Holds the attribute index in the source {@link FeatureSource}, which
-   *  should be transfered to the destination (and modified).*/
-  protected int attrIdx;
-  /** Holds the new attribute name for the attribute. */
-  protected String newAttrName;
-  /** Holds the new attribute type for the attribute. */
-  protected Class<?> newAttrClass;
-  /** Holds the nillable property for the new attribute. */
-  protected Boolean newAttrNillable;
-  /** Holds attribute values, which are transformed to NULL in the
-   *  modification process. */
-  protected Set<Object> nullValues;
-  /** Holds the value used as NULL alias in the modification process. */
-  protected Object nullValueAlias;
-  
-  /**
-   * Creates a new modification definition
-   * @param attrIdx attribute index in the source {@link FeatureSource}, which
-   *                should be transfered to the destination     
-   * @param newAttrName new attribute name for the attribute in the destination
-   *                    (if {@code null} the origin attribute name is used)
-   * @param newAttrClass new attribute type for the attribute in the destination
-   *                    (if {@code null} the origin attribute type is used)
-   * @param newAttrNillable nillable property for the attribute in the destination
-   *                    (if {@code null} the origin nillable property is used)
-   * @param nullValues values which are transformed to NULL during the modification
-   *                   process (if {@code null} the values are copied unchanged)
-   * @param nullValueAlias value which is used as NULL during the modification
-   *                       process
-   */
-  public AttributeModificationRule(int attrIdx, String newAttrName, Class<?> newAttrClass, Boolean newAttrNillable, Set<Object> nullValues, Object nullValueAlias) {
-    this.attrIdx = attrIdx;
-    this.newAttrName = newAttrName;
-    this.newAttrClass = newAttrClass;
-    this.newAttrNillable = newAttrNillable;
-    this.nullValues = nullValues;
-    this.nullValueAlias = nullValueAlias;
-  }
-  
-  /**
-   * Creates a new modification definition
-   * @param attrIdx attribute index in the source {@link FeatureSource}, which
-   *                should be transfered to the destination     
-   */
-  public AttributeModificationRule(int attrIdx) {
-    this(attrIdx,null,null,null,null,null);
-  }
+	/**
+	 * Holds the attribute index in the source {@link FeatureSource}, which
+	 * should be transfered to the destination (and modified).
+	 */
+	protected int attrIdx;
+	/** Holds the new attribute name for the attribute. */
+	protected String newAttrName;
+	/** Holds the new attribute type for the attribute. */
+	protected Class<?> newAttrClass;
+	/** Holds the nillable property for the new attribute. */
+	protected Boolean newAttrNillable;
+	/**
+	 * Holds attribute values, which are transformed to NULL in the modification
+	 * process.
+	 */
+	protected Set<Object> nullValues;
+	/** Holds the value used as NULL alias in the modification process. */
+	protected Object nullValueAlias;
 
-  /**
-   * Returns the index in the source {@link FeatureSource} this modification rule
-   * is made for.
-   */
-  public int getAttrIdx() {
-    return attrIdx;
-  } 
+	/**
+	 * Creates a new modification definition
+	 * 
+	 * @param attrIdx
+	 *            attribute index in the source {@link FeatureSource}, which
+	 *            should be transfered to the destination
+	 * @param newAttrName
+	 *            new attribute name for the attribute in the destination (if
+	 *            {@code null} the origin attribute name is used)
+	 * @param newAttrClass
+	 *            new attribute type for the attribute in the destination (if
+	 *            {@code null} the origin attribute type is used)
+	 * @param newAttrNillable
+	 *            nillable property for the attribute in the destination (if
+	 *            {@code null} the origin nillable property is used)
+	 * @param nullValues
+	 *            values which are transformed to NULL during the modification
+	 *            process (if {@code null} the values are copied unchanged)
+	 * @param nullValueAlias
+	 *            value which is used as NULL during the modification process
+	 */
+	public AttributeModificationRule(int attrIdx, String newAttrName,
+			Class<?> newAttrClass, Boolean newAttrNillable,
+			Set<Object> nullValues, Object nullValueAlias) {
+		this.attrIdx = attrIdx;
+		this.newAttrName = newAttrName;
+		this.newAttrClass = newAttrClass;
+		this.newAttrNillable = newAttrNillable;
+		this.nullValues = nullValues;
+		this.nullValueAlias = nullValueAlias;
+	}
 
-  /**
-   * Returns the new name for the attribute in the destination {@link FeatureSource}.
-   * @return {@code null} if the origin attribute name is used
-   */
-  public String getNewAttrName() {
-    return newAttrName;
-  }
+	/**
+	 * Creates a new modification definition
+	 * 
+	 * @param attrIdx
+	 *            attribute index in the source {@link FeatureSource}, which
+	 *            should be transfered to the destination
+	 */
+	public AttributeModificationRule(int attrIdx) {
+		this(attrIdx, null, null, null, null, null);
+	}
 
-  /**
-   * Sets the new name for the attribute in the destination {@link FeatureSource}.
-   * If set to {@code null}, the origin attribute name is used.
-   */
-  public void setNewAttrName(String newAttrName) {
-    this.newAttrName = newAttrName;
-  }
+	/**
+	 * Returns the index in the source {@link FeatureSource} this modification
+	 * rule is made for.
+	 */
+	public int getAttrIdx() {
+		return attrIdx;
+	}
 
-  /**
-   * Returns the new type for the attribute in the destination {@link FeatureSource}.
-   * @return {@code null} if the origin attribute type is used
-   */
-  public Class<?> getNewAttrClass() {
-    return newAttrClass;
-  }
-  
-  /**
-   * Sets the new type for the attribute in the destination {@link FeatureSource}.
-   * If set to {@code null}, the origin attribute type is used.
-   */
-  public void setNewAttrClass(Class<?> newAttrClass) {
-    this.newAttrClass = newAttrClass;
-  }
-  
-  /**
-   * Returns whether the attribute in the destination {@link FeatureSource} will
-   * be nillable.
-   * @return {@code null} if the origin nillable property is used
-   */
-  public Boolean getNewAttrNillable() {
-    return newAttrNillable;
-  }
-  
-  /**
-   * Sets whether the attribute in the destination {@link FeatureSource} will
-   * be nillable.
-   * If set to {@code null}, the origin nillable property is used
-   */
-  public void setNewAttrNillable(Boolean newAttrNillable) {
-    this.newAttrNillable = newAttrNillable;
-  }
+	/**
+	 * Returns the new name for the attribute in the destination
+	 * {@link FeatureSource}.
+	 * 
+	 * @return {@code null} if the origin attribute name is used
+	 */
+	public String getNewAttrName() {
+		return newAttrName;
+	}
 
-  /**
-   * Returns the attribute values which are transformed to NULL during the
-   * modification process.
-   * @return {@code null} if the origin attribute values are copied unchanged
-   */
-  public Set<Object> getNullValues() {
-    return nullValues;
-  }
-  /**
-   * Sets the attribute values which are transformed to NULL during the
-   * modification process.
-   * If set to {@code null}, the origin attribute values are copied unchanged
-   */
-  public void setNullValues(Set<Object> nullValues) {
-    this.nullValues = nullValues;
-  }
-  
-  /**
-   * Checks whether a value is a part of {@link #getNullValues()}. 
-   * @param value a value to test
-   * @return {@code false} if no NULL values are set
-   */
-  public boolean isNullValue(Object value) {
-    return nullValues != null && nullValues.contains(value);
-  }
-  
-  /**
-   * Returns the values which is used as NULL during the
-   * modification process.
-   */
-  public Object getNullValueAlias() {
-    return nullValueAlias;
-  }
-  /**
-   * Sets the values which is used as NULL during the
-   * modification process.
-   */
-  public void setNullValueAlias(Object nullValueAlias) {
-    this.nullValueAlias = nullValueAlias;
-  }
+	/**
+	 * Sets the new name for the attribute in the destination
+	 * {@link FeatureSource}. If set to {@code null}, the origin attribute name
+	 * is used.
+	 */
+	public void setNewAttrName(String newAttrName) {
+		this.newAttrName = newAttrName;
+	}
 
-  /**
-   * Applies the modifications defined by this {@link AttributeModificationRule} and
-   * creates a new {@link AttributeDescriptor}.
-   */
-  public AttributeDescriptor applyToAttributeType(AttributeDescriptor sourceAttrDescr) {
-    if ( sourceAttrDescr == null )
-      throw new UnsupportedOperationException("Can not create a new AttributeDescriptor from NULL.");
-    
-    // Change the name
-    String newName = getNewAttrName();
-    if ( newName == null )
-      newName = sourceAttrDescr.getLocalName();
+	/**
+	 * Returns the new type for the attribute in the destination
+	 * {@link FeatureSource}.
+	 * 
+	 * @return {@code null} if the origin attribute type is used
+	 */
+	public Class<?> getNewAttrClass() {
+		return newAttrClass;
+	}
 
-    // Change the type
-    Class<?> newClass = getNewAttrClass();
-    if ( newClass == null )
-      newClass = sourceAttrDescr.getType().getBinding();
-  
-    // Change the nillable propery
-    Boolean newNillable = getNewAttrNillable();
-    if ( newNillable == null )
-      newNillable = sourceAttrDescr.isNillable();
+	/**
+	 * Sets the new type for the attribute in the destination
+	 * {@link FeatureSource}. If set to {@code null}, the origin attribute type
+	 * is used.
+	 */
+	public void setNewAttrClass(Class<?> newAttrClass) {
+		this.newAttrClass = newAttrClass;
+	}
 
-    // Transform the default value to the new type
-    Object newDefaultValue = FeatureUtil.transformAttributeValue(sourceAttrDescr.getDefaultValue(),newClass);
-    
-    // User the meta data from source type
-    Object newMetaData = null;
-    // if it is a GeometryAttributeType, the CRS must be stored
-    // in the meta data
-    if ( FeatureUtil.isGeometryAttribute(sourceAttrDescr) )
-      newMetaData = ((GeometryDescriptor) sourceAttrDescr).getCoordinateReferenceSystem();
+	/**
+	 * Returns whether the attribute in the destination {@link FeatureSource}
+	 * will be nillable.
+	 * 
+	 * @return {@code null} if the origin nillable property is used
+	 */
+	public Boolean getNewAttrNillable() {
+		return newAttrNillable;
+	}
 
-    // User the meta data from source type:
-    // combine the restrictions of the attribute type for the
-    // AttributeTypeFactory
-    Filter newRestrictions = FilterUtil.FILTER_FAC.and(sourceAttrDescr.getType().getRestrictions());
+	/**
+	 * Sets whether the attribute in the destination {@link FeatureSource} will
+	 * be nillable. If set to {@code null}, the origin nillable property is used
+	 */
+	public void setNewAttrNillable(Boolean newAttrNillable) {
+		this.newAttrNillable = newAttrNillable;
+	}
 
-    return AttributeTypeFactory.newAttributeType(
-        newName,
-        newClass,
-        newNillable,
-        newRestrictions,
-        newDefaultValue,
-        newMetaData
-    );
-  }
+	/**
+	 * Returns the attribute values which are transformed to NULL during the
+	 * modification process.
+	 * 
+	 * @return {@code null} if the origin attribute values are copied unchanged
+	 */
+	public Set<Object> getNullValues() {
+		return nullValues;
+	}
 
-  /**
-   * Applies the modifications defined by this {@link AttributeModificationRule} to a
-   * destination feature.
-   * @param sourceFeature feature the value is taken from
-   * @param destFeature feature the value is written to according to
-   *                    modification of attribute name, type, NULL values and NULL alias
-   */
-  public void applyToFeature(SimpleFeature sourceFeature, SimpleFeature destFeature) {
-    if ( destFeature == null )
-      throw new UnsupportedOperationException("Can not apply rules to NULL feature.");
-    if ( sourceFeature == null )
-      throw new UnsupportedOperationException("Can not apply rules from NULL feature.");
+	/**
+	 * Sets the attribute values which are transformed to NULL during the
+	 * modification process. If set to {@code null}, the origin attribute values
+	 * are copied unchanged
+	 */
+	public void setNullValues(Set<Object> nullValues) {
+		this.nullValues = nullValues;
+	}
 
-    // determine source value
-    String sAttrName = sourceFeature.getFeatureType().getDescriptor(getAttrIdx()).getLocalName();
-    Object sValue = sourceFeature.getAttribute( getAttrIdx() );
-    // determine destination value according to NULL values and
-    // NULL alias
-    Object dValue = getNullValueAlias();
-    if ( !isNullValue(sValue))
-      dValue = FeatureUtil.transformAttributeValue(sValue, getNewAttrClass());
-    // set the destination value
-    String newAttrName = getNewAttrName();
-    if (newAttrName == null)
-      newAttrName = sAttrName;
-    destFeature.setAttribute(newAttrName, dValue);
-  }
+	/**
+	 * Checks whether a value is a part of {@link #getNullValues()}.
+	 * 
+	 * @param value
+	 *            a value to test
+	 * @return {@code false} if no NULL values are set
+	 */
+	public boolean isNullValue(Object value) {
+		return nullValues != null && nullValues.contains(value);
+	}
 
+	/**
+	 * Returns the values which is used as NULL during the modification process.
+	 */
+	public Object getNullValueAlias() {
+		return nullValueAlias;
+	}
 
 	/**
+	 * Sets the values which is used as NULL during the modification process.
+	 */
+	public void setNullValueAlias(Object nullValueAlias) {
+		this.nullValueAlias = nullValueAlias;
+	}
+
+	/**
+	 * Applies the modifications defined by this
+	 * {@link AttributeModificationRule} and creates a new
+	 * {@link AttributeDescriptor}.
+	 */
+	public AttributeDescriptor applyToAttributeType(
+			AttributeDescriptor sourceAttrDescr) {
+		if (sourceAttrDescr == null)
+			throw new UnsupportedOperationException(
+					"Can not create a new AttributeDescriptor from NULL.");
+
+		// Change the name
+		String newName = getNewAttrName();
+		if (newName == null)
+			newName = sourceAttrDescr.getLocalName();
+
+		// Change the type
+		Class<?> binding = getNewAttrClass();
+		if (binding == null)
+			binding = sourceAttrDescr.getType().getBinding();
+
+		// Change the nillable propery
+		Boolean newNillable = getNewAttrNillable();
+		if (newNillable == null)
+			newNillable = sourceAttrDescr.isNillable();
+
+		// Transform the default value to the new type
+		Object newDefaultValue = FeatureUtil.transformAttributeValue(
+				sourceAttrDescr.getDefaultValue(), binding);
+
+		// User the meta data from source type
+		CoordinateReferenceSystem crs = null;
+		// if it is a GeometryAttributeType, the CRS must be stored
+		// in the meta data
+		if (FeatureUtil.isGeometryAttribute(sourceAttrDescr))
+			crs = ((GeometryDescriptor) sourceAttrDescr)
+					.getCoordinateReferenceSystem();
+
+		// User the meta data from source type:
+		// combine the restrictions of the attribute type for the
+		// AttributeTypeFactory
+		Filter newRestrictions = FilterUtil.FILTER_FAC.and(sourceAttrDescr
+				.getType().getRestrictions());
+
+		if (crs == null)
+			return AttributeTypeFactory.newAttributeDescriptor(newName,
+					binding, newNillable, newRestrictions, newDefaultValue);
+		else
+			return AttributeTypeFactory.newGeometryAttributeDescriptor(newName,
+					(Class<? extends Geometry>) binding, newNillable,
+					newRestrictions, (Geometry) newDefaultValue, crs);
+	}
+
+	/**
+	 * Applies the modifications defined by this
+	 * {@link AttributeModificationRule} to a destination feature.
+	 * 
+	 * @param sourceFeature
+	 *            feature the value is taken from
+	 * @param destFeature
+	 *            feature the value is written to according to modification of
+	 *            attribute name, type, NULL values and NULL alias
+	 */
+	public void applyToFeature(SimpleFeature sourceFeature,
+			SimpleFeature destFeature) {
+		if (destFeature == null)
+			throw new UnsupportedOperationException(
+					"Can not apply rules to NULL feature.");
+		if (sourceFeature == null)
+			throw new UnsupportedOperationException(
+					"Can not apply rules from NULL feature.");
+
+		// determine source value
+		String sAttrName = sourceFeature.getFeatureType()
+				.getDescriptor(getAttrIdx()).getLocalName();
+		Object sValue = sourceFeature.getAttribute(getAttrIdx());
+		// determine destination value according to NULL values and
+		// NULL alias
+		Object dValue = getNullValueAlias();
+		if (!isNullValue(sValue))
+			dValue = FeatureUtil.transformAttributeValue(sValue,
+					getNewAttrClass());
+		// set the destination value
+		String newAttrName = getNewAttrName();
+		if (newAttrName == null)
+			newAttrName = sAttrName;
+		destFeature.setAttribute(newAttrName, dValue);
+	}
+
+	/**
 	 * Testet ob ein Array mit {@link AttributeModificationRule}s bereits einen
 	 * Eintrag für einen zu prüfenden Namen enthaelt.
 	 */

Modified: 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:42:02 UTC (rev 1478)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/AttributeTypeFactory.java	2011-02-02 20:30:14 UTC (rev 1479)
@@ -1,16 +1,67 @@
 package de.schmitzm.geotools.feature;
 
-import org.geotools.feature.AttributeTypeBuilder;
 import org.opengis.feature.type.AttributeDescriptor;
+import org.opengis.feature.type.AttributeType;
+import org.opengis.feature.type.GeometryDescriptor;
+import org.opengis.feature.type.GeometryType;
 import org.opengis.filter.Filter;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
 
+import com.vividsolutions.jts.geom.Geometry;
+
+/**
+ * This class "simulates" the old AttributeTypeFactory from gt2.4 but uses the
+ * new API.
+ * 
+ * @author stefan
+ */
 public class AttributeTypeFactory {
 
-	public static AttributeDescriptor newAttributeType(String newName,
-			Class<?> newClass, Boolean newNillable, Filter newRestrictions,
-			Object newDefaultValue, Object newMetaData) {
-		// ...
-		return new AttributeTypeBuilder().buildDescriptor(newName);
+	public static AttributeType newAttributeType(String name, Class<?> binding,
+			Boolean nillable, Filter newRestrictions, Object newDefaultValue) {
+
+		FeatureUtil.ATTRTYPE_BUILDER.setName(name);
+		FeatureUtil.ATTRTYPE_BUILDER.setBinding(binding);
+		FeatureUtil.ATTRTYPE_BUILDER.setNillable(nillable);
+		FeatureUtil.ATTRTYPE_BUILDER.addRestriction(newRestrictions);
+		FeatureUtil.ATTRTYPE_BUILDER.setDefaultValue(newDefaultValue);
+		return FeatureUtil.ATTRTYPE_BUILDER.buildType();
 	}
 
+	public static AttributeDescriptor newAttributeDescriptor(String name,
+			Class<?> binding) {
+		return newAttributeDescriptor(name, binding, null, null, null);
+	}
+
+	public static AttributeDescriptor newAttributeDescriptor(String name,
+			Class<?> binding, Boolean nillable, Filter restrictions,
+			Object newDefaultValue) {
+
+		return FeatureUtil.ATTRTYPE_BUILDER.buildDescriptor(
+				name,
+				newAttributeType(name, binding, nillable, restrictions,
+						newDefaultValue));
+	}
+
+	public static GeometryType newGeometryAttributeType(String name,
+			Class<?> binding, Boolean nillable, Filter newRestrictions,
+			Object newDefaultValue, CoordinateReferenceSystem crs) {
+
+		FeatureUtil.ATTRTYPE_BUILDER.setName(name);
+		FeatureUtil.ATTRTYPE_BUILDER.setBinding(binding);
+		FeatureUtil.ATTRTYPE_BUILDER.setNillable(nillable);
+		FeatureUtil.ATTRTYPE_BUILDER.addRestriction(newRestrictions);
+		FeatureUtil.ATTRTYPE_BUILDER.setDefaultValue(newDefaultValue);
+		FeatureUtil.ATTRTYPE_BUILDER.setCRS(crs);
+		return FeatureUtil.ATTRTYPE_BUILDER.buildGeometryType();
+	}
+
+	public static GeometryDescriptor newGeometryAttributeDescriptor(
+			String name, Class<? extends Geometry> binding, Boolean nillable,
+			Filter restrictions, Geometry defaultGeom,
+			CoordinateReferenceSystem crs) {
+		GeometryType gtype = newGeometryAttributeType(name, binding, nillable,
+				restrictions, defaultGeom, crs);
+		return FeatureUtil.ATTRTYPE_BUILDER.buildDescriptor(name, gtype);
+	}
 }

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:42:02 UTC (rev 1478)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/FeatureTypeBuilderTableModel.java	2011-02-02 20:30:14 UTC (rev 1479)
@@ -41,10 +41,7 @@
 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;
@@ -451,8 +448,9 @@
 			if (defaultValue == null && !nillable)
 				defaultValue = FeatureUtil.getDefaultAttributeValue(type);
 
-			AttributeDescriptor aType = AttributeTypeFactory.newAttributeType(
-					name.getValue(), type, nillable, null, defaultValue, null);
+			AttributeDescriptor aType = AttributeTypeFactory
+					.newAttributeDescriptor(name.getValue(), type, nillable,
+							null, defaultValue);
 
 			AutoValueGenerator<?> valueGenerator = null;
 			if (autoValue.getValue()) {

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:42:02 UTC (rev 1478)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/FeatureUtil.java	2011-02-02 20:30:14 UTC (rev 1479)
@@ -73,12 +73,11 @@
 import org.geotools.data.memory.MemoryDataStore;
 import org.geotools.factory.CommonFactoryFinder;
 import org.geotools.factory.GeoTools;
-import org.geotools.feature.AttributeTypeFactory;
+import org.geotools.feature.AttributeTypeBuilder;
 import org.geotools.feature.DefaultFeatureCollection;
 import org.geotools.feature.DefaultFeatureCollections;
 import org.geotools.feature.FeatureCollection;
 import org.geotools.feature.FeatureIterator;
-import org.geotools.feature.GeometryAttributeType;
 import org.geotools.feature.NameImpl;
 import org.geotools.feature.SchemaException;
 import org.geotools.feature.simple.SimpleFeatureBuilder;
@@ -219,9 +218,11 @@
 	public static final GeometryFactory GEOMETRY_FACTORY = new GeometryFactory();
 
 	/** Instance of AttributeTypeFactory. */
-	public static final AttributeTypeFactory ATTRTYPE_FACTORY = AttributeTypeFactory
-			.defaultInstance();
+	public static final AttributeTypeBuilder ATTRTYPE_BUILDER = new AttributeTypeBuilder();
 
+	/** Instance of AttributeTypeFactory. */
+	public static final AttributeTypeFactory ATTRTYPE_FACTORY = new AttributeTypeFactory();
+
 	/** Instance of {@link FilterFactory}. */
 	public static final org.opengis.filter.FilterFactory FILTER_FACTORY = CommonFactoryFinder
 			.getFilterFactory(GeoTools.getDefaultHints());
@@ -756,22 +757,30 @@
 		// Create a default value for the attribute
 		Object defaultValue = nillable ? null : getDefaultAttributeValue(aType);
 
-		Object metaData = null;
-		// if it is a GeometryAttributeType, the CRS must be stored
-		// in the meta data
+		CoordinateReferenceSystem crs = null;
 		if (aType instanceof GeometryDescriptor)
-			metaData = ((GeometryDescriptor) aType)
-					.getCoordinateReferenceSystem();
+			crs = ((GeometryDescriptor) aType).getCoordinateReferenceSystem();
 
 		// combine the restrictions of the attribute type for the
 		// AttributeTypeFactory
 		Filter restrictions = FilterUtil.FILTER_FAC.and(aType.getType()
 				.getRestrictions());
 
-		// Create the clone
-		return AttributeTypeFactory.newAttributeType(aType.getLocalName(),
-				aType.getType().getBinding(), nillable, restrictions,
-				defaultValue, metaData);
+		if (crs == null) {
+			// Create the clone
+			return AttributeTypeFactory.newAttributeDescriptor(
+					aType.getLocalName(), aType.getType().getBinding(),
+					nillable, restrictions, defaultValue);
+
+		} else {
+			// Create the clone as a GeometryAttributeDescriptor
+			final Class<? extends Geometry> binding = (Class<? extends Geometry>) aType
+					.getType().getBinding();
+
+			return AttributeTypeFactory.newGeometryAttributeDescriptor(
+					aType.getLocalName(), binding, nillable, restrictions,
+					(Geometry) defaultValue, crs);
+		}
 	}
 
 	/**
@@ -911,10 +920,10 @@
 						&& builder.getDefaultGeometry() == null)
 					builder.setDefaultGeometry(aType.getLocalName());
 			} catch (IllegalArgumentException err) {
-				builder.add(AttributeTypeFactory.newAttributeType(
+				builder.add(AttributeTypeFactory.newAttributeDescriptor(
 						aType.getLocalName() + "_2", aType.getType()
 								.getBinding(), aType.isNillable(),
-						restrictions, aType.getDefaultValue(), null));
+						restrictions, aType.getDefaultValue()));
 			}
 		}
 		SimpleFeatureType resultType = builder.buildFeatureType();
@@ -1797,9 +1806,9 @@
 						+ columnName + "': " + columnClass.getSimpleName());
 
 			// Add an attribute for the column to the SimpleFeatureType
-			featureTypeFac.add(AttributeTypeFactory.newAttributeType(
+			featureTypeFac.add(AttributeTypeFactory.newAttributeDescriptor(
 					columnName, columnClass, nillable, null, // no restrictions
-					defaultValue, null // no meta data
+					defaultValue// no meta data
 					));
 		}
 		return featureTypeFac.buildFeatureType();
@@ -1830,8 +1839,8 @@
 			Object attrValue = attrValues.get(attrName);
 			Class<?> attrClass = attrValue == null ? defaultAttrClass
 					: attrValue.getClass();
-			featureTypeFac.add(AttributeTypeFactory.newAttributeType(attrName,
-					attrClass));
+			featureTypeFac.add(AttributeTypeFactory.newAttributeDescriptor(
+					attrName, attrClass));
 		}
 		return featureTypeFac.buildFeatureType();
 	}
@@ -1854,76 +1863,81 @@
 	 * Creates a default {@link SimpleFeatureType} for a given {@link Geometry}
 	 * class
 	 * 
-	 * @param geomType
+	 * @param geomBinding
 	 *            LineString.class, Point.class or Polygon.class from com.jts...
 	 * 
-	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
+	 *            TODO: the_geom here is ugly
 	 */
-	public static SimpleFeatureType createFeatureType(final Class<?> geomType,
-			CoordinateReferenceSystem crs) {
+	public static SimpleFeatureType createFeatureType(
+			final Class<?> geomBinding, CoordinateReferenceSystem crs) {
 		// Create the only attribute
-		final AttributeDescriptor geometryAttribut = AttributeTypeFactory
-				.newAttributeType("the_geom", geomType);
 
+		AttributeTypeBuilder ab = new AttributeTypeBuilder();
+		ab.setName("the_geom");
+		ab.setBinding(geomBinding);
+		ab.setCRS(crs);
+		final AttributeDescriptor geometryAttribut = ab.buildDescriptor(
+				"the_geom", ab.buildGeometryType());
+
 		// Create the FeatureType with the only attribute
 		final SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
 		builder.setCRS(crs);
-		CoordinateReferenceSystem crs2 = builder.getCRS();
-		builder.setName(geomType.getSimpleName());
+		builder.setName(geomBinding.getSimpleName());
 		builder.add(geometryAttribut);
 		return builder.buildFeatureType();
 	}
 
-	/**
-	 * Erzeugt einen Geometrie-Attribut-Typ.
-	 * 
-	 * @param geomType
-	 *            Art der Geometrie
-	 * @param defGeom
-	 *            Standard-Wert
-	 * @param crs
-	 *            Koordinatensystem
-	 */
-	public static GeometryAttributeType createGeometryAttributeType(
-			Class<? extends Geometry> geomType, Geometry defGeom,
-			CoordinateReferenceSystem crs) {
-		return createGeometryAttributeType(null, geomType, defGeom, crs);
-	}
+	//
+	// /**
+	// * Erzeugt einen Geometrie-Attribut-Typ.
+	// *
+	// * @param geomType
+	// * Art der Geometrie
+	// * @param defGeom
+	// * Standard-Wert
+	// * @param crs
+	// * Koordinatensystem
+	// */
+	// public static GeometryAttributeType createGeometryAttributeType(
+	// Class<? extends Geometry> geomType, Geometry defGeom,
+	// CoordinateReferenceSystem crs) {
+	// return createGeometryAttributeType(null, geomType, defGeom, crs);
+	// }
 
-	/**
-	 * Erzeugt einen Geometrie-Attribut-Typ.
-	 * 
-	 * @param attrName
-	 *            Name des attribute (wenn {@code null}, wird "the_geom"
-	 *            verwendet)
-	 * @param geomType
-	 *            Art der Geometrie
-	 * @param defGeom
-	 *            Standard-Wert
-	 * @param crs
-	 *            Koordinatensystem
-	 */
-	public static GeometryAttributeType createGeometryAttributeType(
-			String attrName, Class<? extends Geometry> geomType,
-			Geometry defGeom, CoordinateReferenceSystem crs) {
-		// return new GeometricAttributeType(
-		// "the_geom",
-		// geomType,
-		// false,
-		// defGeom,
-		// crs,
-		// null
-		// );
-		if (attrName == null)
-			attrName = "the_geom";
+	// /**
+	// * Erzeugt einen Geometrie-Attribut-Typ.
+	// *
+	// * @param attrName
+	// * Name des attribute (wenn {@code null}, wird "the_geom"
+	// * verwendet)
+	// * @param geomType
+	// * Art der Geometrie
+	// * @param defGeom
+	// * Standard-Wert
+	// * @param crs
+	// * Koordinatensystem
+	// */
+	// public static GeometryAttributeType createGeometryAttributeType(
+	// String attrName, Class<? extends Geometry> geomType,
+	// Geometry defGeom, CoordinateReferenceSystem crs) {
+	// // return new GeometricAttributeType(
+	// // "the_geom",
+	// // geomType,
+	// // false,
+	// // defGeom,
+	// // crs,
+	// // null
+	// // );
+	// if (attrName == null)
+	// attrName = "the_geom";
+	//
+	// return (GeometryAttributeType) AttributeTypeFactory.newAttributeType(
+	// attrName, geomType, false, // nillable
+	// null, // restrictions
+	// defGeom, crs // metadata used for CRS
+	// );
+	// }
 
-		return (GeometryAttributeType) AttributeTypeFactory.newAttributeType(
-				attrName, geomType, false, // nillable
-				null, // restrictions
-				defGeom, crs // metadata used for CRS
-				);
-	}
-
 	/**
 	 * @param geoObject
 	 *            Thie object my be a {@link FeatureCollection}, a

Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/JMapEditorPane.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/JMapEditorPane.java	2011-02-02 19:42:02 UTC (rev 1478)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/JMapEditorPane.java	2011-02-02 20:30:14 UTC (rev 1479)
@@ -41,7 +41,6 @@
 import org.geotools.feature.DefaultFeatureCollection;
 import org.geotools.feature.DefaultFeatureCollections;
 import org.geotools.feature.FeatureCollection;
-import org.geotools.feature.GeometryAttributeType;
 import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
 import org.geotools.map.DefaultMapContext;
 import org.geotools.map.DefaultMapLayer;
@@ -52,6 +51,7 @@
 import org.opengis.feature.simple.SimpleFeature;
 import org.opengis.feature.simple.SimpleFeatureType;
 import org.opengis.feature.type.AttributeDescriptor;
+import org.opengis.feature.type.GeometryDescriptor;
 import org.opengis.geometry.DirectPosition;
 
 import com.vividsolutions.jts.geom.Coordinate;
@@ -63,6 +63,7 @@
 import com.vividsolutions.jts.geom.Polygon;
 
 import de.schmitzm.geotools.GTUtil;
+import de.schmitzm.geotools.feature.AttributeTypeFactory;
 import de.schmitzm.geotools.feature.FeatureUtil;
 import de.schmitzm.geotools.feature.FeatureUtil.GeometryForm;
 import de.schmitzm.geotools.map.event.FeatureModifiedEvent;
@@ -74,916 +75,1072 @@
 import de.schmitzm.swing.input.InputOption;
 import de.schmitzm.swing.input.MultipleOptionPane;
 
-
 /**
- * The {@code JMapEditorPane} extends the {@link SelectableXMapPane} with functionalities
- * to create new vector layers by successively click points via mouse.
- * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a> (University of Bonn/Germany)
+ * The {@code JMapEditorPane} extends the {@link SelectableXMapPane} with
+ * functionalities to create new vector layers by successively click points via
+ * mouse.
+ * 
+ * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
+ *         (University of Bonn/Germany)
  * @version 1.0
  */
 public class JMapEditorPane extends SelectableXMapPane {
-  /** Modes, the editor can be perform.
-   *  @see JMapEditorPane#startEditing(EditorMode, String, Style) */
-  public static enum EditorMode {
-    /** Create a new point layer. */
-    New_Point,
-    /** Create a new linestring layer. */
-    New_Line,
-    /** Create a new polygon layer. */
-    New_Polygon
-  }
+	/**
+	 * Modes, the editor can be perform.
+	 * 
+	 * @see JMapEditorPane#startEditing(EditorMode, String, Style)
+	 */
+	public static enum EditorMode {
+		/** Create a new point layer. */
+		New_Point,
+		/** Create a new linestring layer. */
+		New_Line,
+		/** Create a new polygon layer. */
+		New_Polygon
+	}
 
-  /** Attribute name used for the geometry of new layers. */
-  public static final String GEOMETRY_ATTR = "the_geom";
+	/** Attribute name used for the geometry of new layers. */
+	public static final String GEOMETRY_ATTR = "the_geom";
 
-  /** Default-Style for point layers (blue dots). */
-  public static final Style DEFAULT_POINT_STYLE = FeatureUtil.createPointStyle(Color.BLUE);
-  /** Default-Style for line layers (blue lines). */
-  public static final Style DEFAULT_LINE_STYLE = FeatureUtil.createLineStyle(Color.BLUE,2);
-  /** Default-Style for polygon layers (orange with black borders). */
-  public static final Style DEFAULT_POLYGON_STYLE = FeatureUtil.createPolygonStyle(Color.ORANGE, Color.BLUE, 2);
+	/** Default-Style for point layers (blue dots). */
+	public static final Style DEFAULT_POINT_STYLE = FeatureUtil
+			.createPointStyle(Color.BLUE);
+	/** Default-Style for line layers (blue lines). */
+	public static final Style DEFAULT_LINE_STYLE = FeatureUtil.createLineStyle(
+			Color.BLUE, 2);
+	/** Default-Style for polygon layers (orange with black borders). */
+	public static final Style DEFAULT_POLYGON_STYLE = FeatureUtil
+			.createPolygonStyle(Color.ORANGE, Color.BLUE, 2);
 
-  /** If the edited layer is empty, a dummy feature is inserted, because
-   *  the StreamingRenderer can not handle empty FeatureCollections yet. */
-  private SimpleFeature DUMMY_EDITOR_FEATURE = null;
-  private SimpleFeature DUMMY_LINE_FEATURE = null;
-  private SimpleFeature DUMMY_POINT_FEATURE = null;
+	/**
+	 * If the edited layer is empty, a dummy feature is inserted, because the
+	 * StreamingRenderer can not handle empty FeatureCollections yet.
+	 */
+	private SimpleFeature DUMMY_EDITOR_FEATURE = null;
+	private SimpleFeature DUMMY_LINE_FEATURE = null;
+	private SimpleFeature DUMMY_POINT_FEATURE = null;
 
-  /** The map context of the displayed layer. */
-  protected MapContext mapContext = null;
+	/** The map context of the displayed layer. */
+	protected MapContext mapContext = null;
 
-  /** Contains the additional attributes for new FeatureCollections. */
-  protected SimpleFeatureType additionalAttr = null;
-  /** Contains the {@link InputOption} to specify the additional
-   *  attribute values.  */
-  protected FeatureInputOption attrInputOption = null;
+	/** Contains the additional attributes for new FeatureCollections. */
+	protected SimpleFeatureType additionalAttr = null;
+	/**
+	 * Contains the {@link InputOption} to specify the additional attribute
+	 * values.
+	 */
+	protected FeatureInputOption attrInputOption = null;
 
-  /** The map context where the edited layers are displayed. This
-   *  context is displayed on top of the other layers. */
-  protected MapContext editorMapContext = null;
-  /** The renderer the edited layers are rendered with. */
-  protected GTRenderer editorRenderer = null;
-  /** Holds the {@link Style styles} to display edited layers. */
-  protected Map<GeometryForm,Style> editorStyles = null;
-  /** Holds the operation the editor currently performs. */
-  protected EditorMode editorMode = null;
+	/**
+	 * The map context where the edited layers are displayed. This context is
+	 * displayed on top of the other layers.
+	 */
+	protected MapContext editorMapContext = null;
+	/** The renderer the edited layers are rendered with. */
+	protected GTRenderer editorRenderer = null;
+	/** Holds the {@link Style styles} to display edited layers. */
+	protected Map<GeometryForm, Style> editorStyles = null;
+	/** Holds the operation the editor currently performs. */
+	protected EditorMode editorMode = null;
 
-  /** Holds the {@link SimpleFeatureType} of the edited layer. */
-  protected SimpleFeatureType editorFeatureType = null;
-  /** Holds the kind of geometry of the edited layer. */
-  protected GeometryForm editorGeometryForm = null;
-  /** Holds the {@link FeatureCollection} of the edited layer. */
-  protected FeatureCollection<SimpleFeatureType, SimpleFeature> editorFeatureCollection = null;
-  /** Holds the edited layer. */
-  protected MapLayer editorLayer = null;
+	/** Holds the {@link SimpleFeatureType} of the edited layer. */
+	protected SimpleFeatureType editorFeatureType = null;
+	/** Holds the kind of geometry of the edited layer. */
+	protected GeometryForm editorGeometryForm = null;
+	/** Holds the {@link FeatureCollection} of the edited layer. */
+	protected FeatureCollection<SimpleFeatureType, SimpleFeature> editorFeatureCollection = null;
+	/** Holds the edited layer. */
+	protected MapLayer editorLayer = null;
 
-  /** Holds the {@link SimpleFeatureType} of the new segment (incomplete SimpleFeature)
-   *  displayed as line. */
-  protected SimpleFeatureType segmLineFeatureType = null;
-  /** Holds the {@link FeatureCollection} which holds the new segment
-   *  (incomplete SimpleFeature) displayed as line. */
-  protected DefaultFeatureCollection segmLineFeatureCollection = null;
-  /** Holds the layer, the new segment (incomplete SimpleFeature) is displayed in
-   *  as line. */
-  protected MapLayer segmLineLayer = null;
+	/**
+	 * Holds the {@link SimpleFeatureType} of the new segment (incomplete
+	 * SimpleFeature) displayed as line.
+	 */
+	protected SimpleFeatureType segmLineFeatureType = null;
+	/**
+	 * Holds the {@link FeatureCollection} which holds the new segment
+	 * (incomplete SimpleFeature) displayed as line.
+	 */
+	protected DefaultFeatureCollection segmLineFeatureCollection = null;
+	/**
+	 * Holds the layer, the new segment (incomplete SimpleFeature) is displayed
+	 * in as line.
+	 */
+	protected MapLayer segmLineLayer = null;
 
-  /** Holds the {@link SimpleFeatureType} of the new segment (incomplete SimpleFeature)
-   *  displayed as points. */
-  protected SimpleFeatureType segmPointFeatureType = null;
-  /** Holds the {@link FeatureCollection} which holds the new segment
-   *  (incomplete SimpleFeature) displayed as points. */
-  protected DefaultFeatureCollection segmPointFeatureCollection = null;
-  /** Holds the layer, the new segment (incomplete SimpleFeature) is displayed in
-   *  as points. */
-  protected MapLayer segmPointLayer = null;
+	/**
+	 * Holds the {@link SimpleFeatureType} of the new segment (incomplete
+	 * SimpleFeature) displayed as points.
+	 */
+	protected SimpleFeatureType segmPointFeatureType = null;
+	/**
+	 * Holds the {@link FeatureCollection} which holds the new segment
+	 * (incomplete SimpleFeature) displayed as points.
+	 */
+	protected DefaultFeatureCollection segmPointFeatureCollection = null;
+	/**
+	 * Holds the layer, the new segment (incomplete SimpleFeature) is displayed
+	 * in as points.
+	 */
+	protected MapLayer segmPointLayer = null;
 
+	/**
+	 * Holds the points of the edited segment (incomplete SimpleFeature) which
+	 * can be undone.
+	 */
+	protected Stack<Coordinate> segmUndoPoints = new Stack<Coordinate>();
+	/**
+	 * Holds the undone points of the edited segment (incomplete SimpleFeature)
+	 * which can be redone.
+	 */
+	protected Stack<Coordinate> segmRedoPoints = new Stack<Coordinate>();
+	/**
+	 * Holds the points of former segments (complete Features) which can be
+	 * undone.
+	 */
+	protected Stack<Stack<Coordinate>> globalUndoPoints = new Stack<Stack<Coordinate>>();
+	/**
+	 * Holds the undone points of former segments (complete Features) which can
+	 * be redone.
+	 */
+	protected Stack<Stack<Coordinate>> globalRedoPoints = new Stack<Stack<Coordinate>>();
+	/** Holds the former segments (complete Features) which can be undone. */
+	protected Stack<SimpleFeature> globalUndoFeatures = new Stack<SimpleFeature>();
+	/** Holds the undone segments (complete Features) which can be redone. */
+	protected Stack<SimpleFeature> globalRedoFeatures = new Stack<SimpleFeature>();
 
-  /** Holds the points of the edited segment (incomplete SimpleFeature) which
-   *  can be undone. */
-  protected Stack<Coordinate> segmUndoPoints = new Stack<Coordinate>();
-  /** Holds the undone points of the edited segment (incomplete SimpleFeature) which
-   *  can be redone. */
-  protected Stack<Coordinate> segmRedoPoints = new Stack<Coordinate>();
-  /** Holds the points of former segments (complete Features) which
-   *  can be undone. */
-  protected Stack<Stack<Coordinate>> globalUndoPoints = new Stack<Stack<Coordinate>>();
-  /** Holds the undone points of former segments (complete Features) which
-   *  can be redone. */
-  protected Stack<Stack<Coordinate>> globalRedoPoints = new Stack<Stack<Coordinate>>();
-  /** Holds the former segments (complete Features) which can be undone. */
-  protected Stack<SimpleFeature> globalUndoFeatures = new Stack<SimpleFeature>();
-  /** Holds the undone segments (complete Features) which can be redone. */
-  protected Stack<SimpleFeature> globalRedoFeatures = new Stack<SimpleFeature>();
+	/**
+	 * Defines a map action which reacts on mouse clicks with the editing
+	 * functionality.
+	 */
+	private final XMapPaneAction EDITING_ACTION = new XMapPaneActionAdapter() {
+		@Override
+		public void performClick(XMapPane mapPane, MouseEvent ev,
+				DirectPosition coord) {
+			// Point2D geoCoord = getScreenToWorld().transform(ev.getPoint(),
+			// null);
 
-  /**
-   * Defines a map action which reacts on mouse clicks with the
-   * editing functionality.
-   */
-  private final XMapPaneAction EDITING_ACTION = new XMapPaneActionAdapter() {
-    @Override
-    public void performClick(XMapPane mapPane, MouseEvent ev, DirectPosition coord) {
-//      Point2D geoCoord = getScreenToWorld().transform(ev.getPoint(), null);
-      
-      // Zunaechst Modus auf NULL pruefen, da ansonsten
-      // NullPointerException in switch-Statement
-      if ( editorMode == null )
-        return;
-      switch( editorMode ) {
-        case New_Point:
-        case New_Line:
-        case New_Polygon: addSegment( new Coordinate(coord.getOrdinate(0), coord.getOrdinate(1)) );
-                          break;
-      }
-    }
-  };
-  
-  protected XMapPaneTool EDITING_TOOL = new XMapPaneTool() {
-    @Override
-    public void initTool() {
-      super.initTool();
-      // links Klick -> Editieren
-      setMouseAction( MouseInputType.LClick, EDITING_ACTION );
-      // rechts Klick -> Nichts
-      setMouseAction( MouseInputType.RClick, null);
-      // links Drag -> Zoom In
-      setMouseAction( MouseInputType.LDrag, XMapPaneAction.ZOOM_IN);
-      // rechts Drag -> Nichts
-      setMouseAction( MouseInputType.RDrag, XMapPaneAction.PAN);
-      // Mausrad -> Zoom In
-      setMouseAction( MouseInputType.Wheel, XMapPaneAction.ZOOM_IN);
-    }
-  };
-  
-  
-  
-  /**
-   * Creates a new {@code JMapEditorPane}.
-   */
-  public JMapEditorPane() {
-    this(null);
-  }
+			// Zunaechst Modus auf NULL pruefen, da ansonsten
+			// NullPointerException in switch-Statement
+			if (editorMode == null)
+				return;
+			switch (editorMode) {
+			case New_Point:
+			case New_Line:
+			case New_Polygon:
+				addSegment(new Coordinate(coord.getOrdinate(0),
+						coord.getOrdinate(1)));
+				break;
+			}
+		}
+	};
 
-  /**
-   * Creates a new {@code JMapEditorPane}. This constructor provides the possibility
-   * to use alternative implementations of the internal components.
-   * <b>The specified parameter all can be {@code null}! In this case
-   * the respective default component is used.</b>
-   */
-  public JMapEditorPane(MapContext context) {
-    super(context);
-    this.mapContext = getMapContext();
-    // initalize the editor styles
-    this.editorStyles = new HashMap<GeometryForm, Style>();
-    for (GeometryForm geomForm : GeometryForm.values())
-      this.setEditorStyle(geomForm, null);
+	protected XMapPaneTool EDITING_TOOL = new XMapPaneTool() {
+		@Override
+		public void initTool() {
+			super.initTool();
+			// links Klick -> Editieren
+			setMouseAction(MouseInputType.LClick, EDITING_ACTION);
+			// rechts Klick -> Nichts
+			setMouseAction(MouseInputType.RClick, null);
+			// links Drag -> Zoom In
+			setMouseAction(MouseInputType.LDrag, XMapPaneAction.ZOOM_IN);
+			// rechts Drag -> Nichts
+			setMouseAction(MouseInputType.RDrag, XMapPaneAction.PAN);
+			// Mausrad -> Zoom In
+			setMouseAction(MouseInputType.Wheel, XMapPaneAction.ZOOM_IN);
+		}
+	};
 
-    // no standard action on left mouse button, instead: adding points
-    setTool( EDITING_TOOL );
+	/**
+	 * Creates a new {@code JMapEditorPane}.
+	 */
+	public JMapEditorPane() {
+		this(null);
+	}
 
-    // special map context for the editor layers, so the
-    // editor layers are not shown in "normal" layer list
-    this.editorMapContext = new DefaultMapContext( mapContext.getCoordinateReferenceSystem() );
-    this.editorRenderer   = GTUtil.createGTRenderer(this.editorMapContext);
-    // listen to CRS/Area changes on the "normal" Context to
-    // synchronize the editor context
-    this.mapContext.addMapBoundsListener( new MapContextSynchronizer(editorMapContext) );
+	/**
+	 * Creates a new {@code JMapEditorPane}. This constructor provides the
+	 * possibility to use alternative implementations of the internal
+	 * components. <b>The specified parameter all can be {@code null}! In this
+	 * case the respective default component is used.</b>
+	 */
+	public JMapEditorPane(MapContext context) {
+		super(context);
+		this.mapContext = getMapContext();
+		// initalize the editor styles
+		this.editorStyles = new HashMap<GeometryForm, Style>();
+		for (GeometryForm geomForm : GeometryForm.values())
+			this.setEditorStyle(geomForm, null);
 
-    // create the input option to specify additional attribute values
-    attrInputOption = new FeatureInputOption(null,true,(SimpleFeature)null);
-  }
+		// no standard action on left mouse button, instead: adding points
+		setTool(EDITING_TOOL);
 
-/**
-   * After the actions of the super method, this method paints the
-   * special editor layers in {@link #editorMapContext}.
-   */
-  protected void paintComponent(Graphics g) {
-    resetEditorLayerVisibility();
-    super.paintComponent(g);
-    Rectangle r = getBounds();
-    Rectangle dr = new Rectangle(r.width, r.height);
-    editorRenderer.setContext(editorMapContext);
-    editorRenderer.paint((Graphics2D) g, dr, mapArea);
-  }
+		// special map context for the editor layers, so the
+		// editor layers are not shown in "normal" layer list
+		this.editorMapContext = new DefaultMapContext(
+				mapContext.getCoordinateReferenceSystem());
+		this.editorRenderer = GTUtil.createGTRenderer(this.editorMapContext);
+		// listen to CRS/Area changes on the "normal" Context to
+		// synchronize the editor context
+		this.mapContext.addMapBoundsListener(new MapContextSynchronizer(
+				editorMapContext));
 
-//  /**
-//   * Ignores the actions of the super class for left-clicks.
-//   * Instead this method reacts according to the current
-//   * editor mode.
-//   */
-//  @Override
-//  public void mouseClicked(MouseEvent e) {
-//    Point2D geoCoord = getScreenToWorld().transform(e.getPoint(), null);
-//    // Zunaechst Modus auf NULL pruefen, da ansonsten
-//    // NullPointerException in switch-Statement
-//    if ( editorMode == null )
-//      return;
-//
-//    switch( editorMode ) {
-//      case New_Point:
-//      case New_Line:
-//      case New_Polygon: addSegment( new Coordinate(geoCoord.getX(), geoCoord.getY()) );
-//                        break;
-//    }
-//  }
+		// create the input option to specify additional attribute values
+		attrInputOption = new FeatureInputOption(null, true,
+				(SimpleFeature) null);
+	}
 
-  //**********************************************************************
-  //***** General public methods
-  //**********************************************************************
+	/**
+	 * After the actions of the super method, this method paints the special
+	 * editor layers in {@link #editorMapContext}.
+	 */
+	@Override
+	protected void paintComponent(Graphics g) {
+		resetEditorLayerVisibility();
+		super.paintComponent(g);
+		Rectangle r = getBounds();
+		Rectangle dr = new Rectangle(r.width, r.height);
+		editorRenderer.setContext(editorMapContext);
+		editorRenderer.paint((Graphics2D) g, dr, mapArea);
+	}
 
-  /**
-   * Checks, whether a layer is edited.
-   */
-  public boolean isEditorEnabled() {
-    return editorMode != null;
-  }
+	// /**
+	// * Ignores the actions of the super class for left-clicks.
+	// * Instead this method reacts according to the current
+	// * editor mode.
+	// */
+	// @Override
+	// public void mouseClicked(MouseEvent e) {
+	// Point2D geoCoord = getScreenToWorld().transform(e.getPoint(), null);
+	// // Zunaechst Modus auf NULL pruefen, da ansonsten
+	// // NullPointerException in switch-Statement
+	// if ( editorMode == null )
+	// return;
+	//
+	// switch( editorMode ) {
+	// case New_Point:
+	// case New_Line:
+	// case New_Polygon: addSegment( new Coordinate(geoCoord.getX(),
+	// geoCoord.getY()) );
+	// break;
+	// }
+	// }
 
-  /**
-   * Sets the style for edited layers.
-   * @param geomForm kind of layers the style is set for
-   * @param style a Style (if {@code null} a default style is set, so
-   *              {@link #getEditorStyle(GeometryForm)} never returns null)
-   */
-  public void setEditorStyle(GeometryForm geomForm, Style style) {
-    // If no style is specified, set a default style
-    if ( style == null )
-      switch ( geomForm ) {
-        case POINT:   style = DEFAULT_POINT_STYLE; break;
-        case LINE:    style = DEFAULT_LINE_STYLE; break;
-        case POLYGON: style = DEFAULT_POLYGON_STYLE; break;
-      }
+	// **********************************************************************
+	// ***** General public methods
+	// **********************************************************************
 
-    // Set the style
-    editorStyles.put(geomForm, style);
+	/**
+	 * Checks, whether a layer is edited.
+	 */
+	public boolean isEditorEnabled() {
+		return editorMode != null;
+	}
 
-    // Apply the style also to the current edited layer
-    if ( editorLayer != null && FeatureUtil.getGeometryForm(editorLayer) == geomForm )
-      editorLayer.setStyle(style);
-    if ( segmLineLayer != null && FeatureUtil.getGeometryForm(segmLineLayer) == geomForm )
-      segmLineLayer.setStyle(style);
-    if ( segmPointLayer != null && FeatureUtil.getGeometryForm(segmPointLayer) == geomForm )
-      segmPointLayer.setStyle(style);
-  }
+	/**
+	 * Sets the style for edited layers.
+	 * 
+	 * @param geomForm
+	 *            kind of layers the style is set for
+	 * @param style
+	 *            a Style (if {@code null} a default style is set, so
+	 *            {@link #getEditorStyle(GeometryForm)} never returns null)
+	 */
+	public void setEditorStyle(GeometryForm geomForm, Style style) {
+		// If no style is specified, set a default style
+		if (style == null)
+			switch (geomForm) {
+			case POINT:
+				style = DEFAULT_POINT_STYLE;
+				break;
+			case LINE:
+				style = DEFAULT_LINE_STYLE;
+				break;
+			case POLYGON:
+				style = DEFAULT_POLYGON_STYLE;
+				break;
+			}
 
-  /**
-   * Returns the style for edited layers.
-   * @param geomForm type of layers the style is returned for
-   */
-  public Style getEditorStyle(GeometryForm geomForm) {
-    return this.editorStyles.get(geomForm);
-  }
+		// Set the style
+		editorStyles.put(geomForm, style);
 
-  /**
-   * Returns the style for the current edited layer.
-   */
-  public Style getEditorStyle() {
-    if ( editorGeometryForm == null )
-      return null;
-    return this.editorStyles.get(editorGeometryForm);
-  }
+		// Apply the style also to the current edited layer
+		if (editorLayer != null
+				&& FeatureUtil.getGeometryForm(editorLayer) == geomForm)
+			editorLayer.setStyle(style);
+		if (segmLineLayer != null
+				&& FeatureUtil.getGeometryForm(segmLineLayer) == geomForm)
+			segmLineLayer.setStyle(style);
+		if (segmPointLayer != null
+				&& FeatureUtil.getGeometryForm(segmPointLayer) == geomForm)
+			segmPointLayer.setStyle(style);
+	}
 
-  /**
-   * Sets the additional attributes for new FeatureCollections (besides
-   * the geometric attribute, which is added automatically).
-   * @param fType defines the attributes (If {@code null}, new FeatureCollections
-   *              only contain the geometric attribute)
-   */
-  public void setAdditionalAttributes(SimpleFeatureType fType) {
-    this.additionalAttr = fType;
-  }
+	/**
+	 * Returns the style for edited layers.
+	 * 
+	 * @param geomForm
+	 *            type of layers the style is returned for
+	 */
+	public Style getEditorStyle(GeometryForm geomForm) {
+		return this.editorStyles.get(geomForm);
+	}
 
-  /**
-   * Returns the additional attributes for new FeatureCollections (besides
-   * the geometric attribute, which is added automatically).
-   */
-  public SimpleFeatureType getAdditionalAttributes() {
-    return this.additionalAttr;
-  }
+	/**
+	 * Returns the style for the current edited layer.
+	 */
+	public Style getEditorStyle() {
+		if (editorGeometryForm == null)
+			return null;
+		return this.editorStyles.get(editorGeometryForm);
+	}
 
-  /**
-   * Returns the current editor mode.
-   */
-  public EditorMode getEditorMode() {
-    return this.editorMode;
-  }
+	/**
+	 * Sets the additional attributes for new FeatureCollections (besides the
+	 * geometric attribute, which is added automatically).
+	 * 
+	 * @param fType
+	 *            defines the attributes (If {@code null}, new
+	 *            FeatureCollections only contain the geometric attribute)
+	 */
+	public void setAdditionalAttributes(SimpleFeatureType fType) {
+		this.additionalAttr = fType;
+	}
 
-  /**
-   * Returns the edited layer.
-   */
-  public MapLayer getEditorLayer() {
-    return this.editorLayer;
-  }
+	/**
+	 * Returns the additional attributes for new FeatureCollections (besides the
+	 * geometric attribute, which is added automatically).
+	 */
+	public SimpleFeatureType getAdditionalAttributes() {
+		return this.additionalAttr;
+	}
 
-  /**
-   * Returns the {@link FeatureCollection} of the edited layer.
-   */
-  public FeatureCollection<SimpleFeatureType, SimpleFeature> getEditorFeatureCollection() {
-    return this.editorFeatureCollection;
-  }
+	/**
+	 * Returns the current editor mode.
+	 */
+	public EditorMode getEditorMode() {
+		return this.editorMode;
+	}
 
-  //**********************************************************************
-  //*****  Public Methods controlling the editor operations
-  //**********************************************************************
+	/**
+	 * Returns the edited layer.
+	 */
+	public MapLayer getEditorLayer() {
+		return this.editorLayer;
+	}
 
-  /**
-   * Starts a new layer.
-   * @param mode type of layer
-   * @param layerTitle Title for the new layer
-   * @exception UnsupportedOperationException if no map area is defined yet
-   */
-  public void startEditing(EditorMode mode, String layerTitle) {
-    // to create a new layer, first an existing layer must be
-    // displayed, so that a CRS and geo-position is available
-    // for the new layer
-    if ( getMapArea() == null )
-      throw new UnsupportedOperationException( GeotoolsGUIUtil.RESOURCE.getString("JMapEditorPane.Err.MissingMap") );
-    // cancel active editings
-    cancelEditing();
-    editorMode = mode;
+	/**
+	 * Returns the {@link FeatureCollection} of the edited layer.
+	 */
+	public FeatureCollection<SimpleFeatureType, SimpleFeature> getEditorFeatureCollection() {
+		return this.editorFeatureCollection;
+	}
 
-    // Create new Layers
-    initEditorFeatureCollection(layerTitle);
-    initSegmentFeatureCollection();
-    editorMapContext.addLayer(0,editorLayer);
-    fireMapPaneEvent( new LayerEditStartedEvent(this,editorLayer,this) );
-  }
+	// **********************************************************************
+	// ***** Public Methods controlling the editor operations
+	// **********************************************************************
 
-  /**
-   * Called when the mouse is clicked on map during creating a new layer.
-   * @param coord World coordinates of click position
-   * @param refresh indicates whether the visualization will be refreshed
-   * @param aClearRedo indicates whether the REDO-Stack is cleared (normally {@code true},
-   *                   but {@code false} during REDO operation!)
-   */
-  protected void addSegment(Coordinate coord, boolean refresh, boolean clearRedo) {
-    if ( editorMode != EditorMode.New_Point &&
-         editorMode != EditorMode.New_Line &&
-         editorMode != EditorMode.New_Polygon )
-      return;
+	/**
+	 * Starts a new layer.
+	 * 
+	 * @param mode
+	 *            type of layer
+	 * @param layerTitle
+	 *            Title for the new layer
+	 * @exception UnsupportedOperationException
+	 *                if no map area is defined yet
+	 */
+	public void startEditing(EditorMode mode, String layerTitle) {
+		// to create a new layer, first an existing layer must be
+		// displayed, so that a CRS and geo-position is available
+		// for the new layer
+		if (getMapArea() == null)
+			throw new UnsupportedOperationException(
+					GeotoolsGUIUtil.RESOURCE
+							.getString("JMapEditorPane.Err.MissingMap"));
+		// cancel active editings
+		cancelEditing();
+		editorMode = mode;
 
-    // store the new point for undoing
-    segmUndoPoints.push(coord);
-    // delete all former redo possibilities
-    if ( clearRedo )
-      segmRedoPoints.clear();
-    // recreate the segment FeatureCollection to show the extended line
-    generateSegmentFeatureCollection();
+		// Create new Layers
+		initEditorFeatureCollection(layerTitle);
+		initSegmentFeatureCollection();
+		editorMapContext.addLayer(0, editorLayer);
+		fireMapPaneEvent(new LayerEditStartedEvent(this, editorLayer, this));
+	}
 
-    // finish the feature automatically
-    // - when editing points, because there are no segments for point layer,
-    //   because every point is a new feature
-    // - when editing polygons and reaching the start point
-    if ( editorGeometryForm == GeometryForm.POINT ||
-         editorGeometryForm == GeometryForm.POLYGON && segmUndoPoints.size() > 1 && segmUndoPoints.lastElement().equals(segmUndoPoints.firstElement()) )
-      finishFeature(refresh, clearRedo); // refresh is done by finishFeature()
-    else
-      if ( refresh )
-        refresh();
-  }
+	/**
+	 * Called when the mouse is clicked on map during creating a new layer.
+	 * 
+	 * @param coord
+	 *            World coordinates of click position
+	 * @param refresh
+	 *            indicates whether the visualization will be refreshed
+	 * @param aClearRedo
+	 *            indicates whether the REDO-Stack is cleared (normally
+	 *            {@code true}, but {@code false} during REDO operation!)
+	 */
+	protected void addSegment(Coordinate coord, boolean refresh,
+			boolean clearRedo) {
+		if (editorMode != EditorMode.New_Point
+				&& editorMode != EditorMode.New_Line
+				&& editorMode != EditorMode.New_Polygon)
+			return;
 
-  /**
-   * Called when the mouse is clicked on map during creating a new layer.
-   * @param coord World coordinates of click position
-   */
-  protected void addSegment(Coordinate coord) {
-    addSegment(coord, true, true);
-  }
+		// store the new point for undoing
+		segmUndoPoints.push(coord);
+		// delete all former redo possibilities
+		if (clearRedo)
+			segmRedoPoints.clear();
+		// recreate the segment FeatureCollection to show the extended line
+		generateSegmentFeatureCollection();
 
-  /**
-   * Finishes the editing of the current segment (SimpleFeature).
-   * If no editing operation is currently in progress, this method does nothing.
-   * @param refresh indicates whether the visualization will be refreshed
-   * @param aClearRedo indicates whether the REDO-Stack is cleared (normally {@code true},
-   *                   but {@code false} during REDO operation!)
-   * @exception UnsupportedOperationException if a line or polygon feature can not
-   *            be finished because of less specified points
-   */
-  protected void finishFeature(boolean refresh, boolean clearRedo) {
-    if ( editorMode == null )
-      return;
+		// finish the feature automatically
+		// - when editing points, because there are no segments for point layer,
+		// because every point is a new feature
+		// - when editing polygons and reaching the start point
+		if (editorGeometryForm == GeometryForm.POINT
+				|| editorGeometryForm == GeometryForm.POLYGON
+				&& segmUndoPoints.size() > 1
+				&& segmUndoPoints.lastElement().equals(
+						segmUndoPoints.firstElement()))
+			finishFeature(refresh, clearRedo); // refresh is done by
+												// finishFeature()
+		else if (refresh)
+			refresh();
+	}
 
-    if ( editorGeometryForm == GeometryForm.LINE && segmUndoPoints.size() < 2 )
-      throw new UnsupportedOperationException( GeotoolsGUIUtil.RESOURCE.getString("JMapEditorPane.Err.Line.LessPoints") );
-    if ( editorGeometryForm == GeometryForm.POLYGON && segmUndoPoints.size() < 3 )
-      throw new UnsupportedOperationException( GeotoolsGUIUtil.RESOURCE.getString("JMapEditorPane.Err.Polygon.LessPoints") );
+	/**
+	 * Called when the mouse is clicked on map during creating a new layer.
+	 * 
+	 * @param coord
+	 *            World coordinates of click position
+	 */
+	protected void addSegment(Coordinate coord) {
+		addSegment(coord, true, true);
+	}
 
-    // close a polygon automatically
-    if ( editorGeometryForm == GeometryForm.POLYGON &&
-        !segmUndoPoints.lastElement().equals(segmUndoPoints.firstElement()) ) {
-      addSegment( segmUndoPoints.firstElement(), refresh, clearRedo );
-      return; // !!!! finishFeature(.) is called again by addSegment(..) !!!!
-    }
-    // create a new SimpleFeature from the segment points
-    SimpleFeature feature = createFeature();
-    if ( feature == null )
-      return;
-    fireMapPaneEvent( new FeatureModifiedEvent(this,editorLayer,feature,this) );
+	/**
+	 * Finishes the editing of the current segment (SimpleFeature). If no
+	 * editing operation is currently in progress, this method does nothing.
+	 * 
+	 * @param refresh
+	 *            indicates whether the visualization will be refreshed
+	 * @param aClearRedo
+	 *            indicates whether the REDO-Stack is cleared (normally
+	 *            {@code true}, but {@code false} during REDO operation!)
+	 * @exception UnsupportedOperationException
+	 *                if a line or polygon feature can not be finished because
+	 *                of less specified points
+	 */
+	protected void finishFeature(boolean refresh, boolean clearRedo) {
+		if (editorMode == null)
+			return;
 
-    // update the global undo
-    globalUndoPoints.push( segmUndoPoints );
-    globalUndoFeatures.push( feature );
-    editorFeatureCollection.add( feature );
+		if (editorGeometryForm == GeometryForm.LINE
+				&& segmUndoPoints.size() < 2)
+			throw new UnsupportedOperationException(
+					GeotoolsGUIUtil.RESOURCE
+							.getString("JMapEditorPane.Err.Line.LessPoints"));
+		if (editorGeometryForm == GeometryForm.POLYGON
+				&& segmUndoPoints.size() < 3)
+			throw new UnsupportedOperationException(
+					GeotoolsGUIUtil.RESOURCE
+							.getString("JMapEditorPane.Err.Polygon.LessPoints"));
 
-    // after finishing a SimpleFeature, a new segment is started
-    segmUndoPoints = new Stack<Coordinate>();
-    if ( clearRedo )
-      segmRedoPoints = globalRedoPoints.isEmpty() ? new Stack<Coordinate>() : globalRedoPoints.pop();
-    initSegmentFeatureCollection();
-    // refresh the display
-    if ( refresh )
-      refresh();
-  }
+		// close a polygon automatically
+		if (editorGeometryForm == GeometryForm.POLYGON
+				&& !segmUndoPoints.lastElement().equals(
+						segmUndoPoints.firstElement())) {
+			addSegment(segmUndoPoints.firstElement(), refresh, clearRedo);
+			return; // !!!! finishFeature(.) is called again by addSegment(..)
+					// !!!!
+		}
+		// create a new SimpleFeature from the segment points
+		SimpleFeature feature = createFeature();
+		if (feature == null)
+			return;
+		fireMapPaneEvent(new FeatureModifiedEvent(this, editorLayer, feature,
+				this));
 
-  /**
-   * Finishes the editing of the current segment (SimpleFeature).
-   * If no editing operation is currently in progress, this method does nothing.
-   */
-  public void finishFeature() {
-    finishFeature(true, true);
-  }
+		// update the global undo
+		globalUndoPoints.push(segmUndoPoints);
+		globalUndoFeatures.push(feature);
+		editorFeatureCollection.add(feature);
 
-  /**
-   * Finishes the current editing operation. After that no more operations
-   * on this layer can be performed.
-   * As long as no other editing operation is started, the edited (new) layer is
-   * available by {@link #getEditorLayer()} and {@link #getEditorFeatureCollection()}.
-   * If no editing operation is currently in progress, this method does nothing.
-   */
-  public void finishEditing() {
-    if ( editorMode == null )
-      return;
+		// after finishing a SimpleFeature, a new segment is started
+		segmUndoPoints = new Stack<Coordinate>();
+		if (clearRedo)
+			segmRedoPoints = globalRedoPoints.isEmpty() ? new Stack<Coordinate>()
+					: globalRedoPoints.pop();
+		initSegmentFeatureCollection();
+		// refresh the display
+		if (refresh)
+			refresh();
+	}
 
-    // if current segment is not closed, finish it automatically
-    if ( !segmUndoPoints.isEmpty() )
-      finishFeature();
-    initUndoRedo();
+	/**
+	 * Finishes the editing of the current segment (SimpleFeature). If no
+	 * editing operation is currently in progress, this method does nothing.
+	 */
+	public void finishFeature() {
+		finishFeature(true, true);
+	}
 
-    // move the edited layer to the "real" MapContext
-    editorMapContext.removeLayer(editorLayer);
-    if ( mapContext.indexOf(editorLayer) < 0 ) {
-      mapContext.addLayer(editorLayer);
-      editorLayer.setVisible(true);
-    }
-    fireMapPaneEvent( new LayerEditFinishedEvent(this,editorLayer,this) );
+	/**
+	 * Finishes the current editing operation. After that no more operations on
+	 * this layer can be performed. As long as no other editing operation is
+	 * started, the edited (new) layer is available by {@link #getEditorLayer()}
+	 * and {@link #getEditorFeatureCollection()}. If no editing operation is
+	 * currently in progress, this method does nothing.
+	 */
+	public void finishEditing() {
+		if (editorMode == null)
+			return;
 
-    // initialize the editing variables
-    editorMode = null;
-    editorLayer = null;
-    editorFeatureCollection = null;
-    editorGeometryForm = null;
+		// if current segment is not closed, finish it automatically
+		if (!segmUndoPoints.isEmpty())
+			finishFeature();
+		initUndoRedo();
 
-    // refresh the display
-    refresh();
-  }
+		// move the edited layer to the "real" MapContext
+		editorMapContext.removeLayer(editorLayer);
+		if (mapContext.indexOf(editorLayer) < 0) {
+			mapContext.addLayer(editorLayer);
+			editorLayer.setVisible(true);
+		}
+		fireMapPaneEvent(new LayerEditFinishedEvent(this, editorLayer, this));
 
-  /**
-   * Cancels the current edititing operation. The edited layer is removed.
-   */
-  public void cancelEditing() {
-    if ( editorLayer != null )
-      this.editorMapContext.removeLayer( editorLayer );
-    if ( editorFeatureCollection != null ) {
-      if ( mapContext.indexOf(editorLayer) < 0 ) {
-        // Layer was a new one, so clear it completly
-        editorFeatureCollection.clear();
-        initUndoRedo();
-        fireMapPaneEvent( new LayerEditCanceledEvent(this,null,this) );
-      } else {
-        // Layer was an existing one, so undo all editing operations
-        undoAll();
-        initUndoRedo();
-        fireMapPaneEvent( new LayerEditFinishedEvent(this,editorLayer,this) );
-      }
-    }
-    if ( segmLineFeatureCollection != null )
-      segmLineFeatureCollection.clear();
-    if ( segmPointFeatureCollection != null )
-      segmPointFeatureCollection.clear();
+		// initialize the editing variables
+		editorMode = null;
+		editorLayer = null;
+		editorFeatureCollection = null;
+		editorGeometryForm = null;
 
-    // initialize the editing variables
-    editorMode = null;
-    editorLayer = null;
-    editorFeatureCollection = null;
-    editorGeometryForm = null;
+		// refresh the display
+		refresh();
+	}
 
-    // refresh the display
-    refresh();
-  }
+	/**
+	 * Cancels the current edititing operation. The edited layer is removed.
+	 */
+	public void cancelEditing() {
+		if (editorLayer != null)
+			this.editorMapContext.removeLayer(editorLayer);
+		if (editorFeatureCollection != null) {
+			if (mapContext.indexOf(editorLayer) < 0) {
+				// Layer was a new one, so clear it completly
+				editorFeatureCollection.clear();
+				initUndoRedo();
+				fireMapPaneEvent(new LayerEditCanceledEvent(this, null, this));
+			} else {
+				// Layer was an existing one, so undo all editing operations
+				undoAll();
+				initUndoRedo();
+				fireMapPaneEvent(new LayerEditFinishedEvent(this, editorLayer,
+						this));
+			}
+		}
+		if (segmLineFeatureCollection != null)
+			segmLineFeatureCollection.clear();
+		if (segmPointFeatureCollection != null)
+			segmPointFeatureCollection.clear();
 
-  /**
-   * Makes previously made editing actions undone.
-   * @param count count of operations made undone
-   */
-  public void undoEditing(int count) {
-    for (int i=0; i<count; i++)
-    {
-      if ( segmUndoPoints.isEmpty() ) {
-        if ( globalUndoPoints.isEmpty() )
-          // No more undo operations available
-          break;
-        else {
-          segmUndoPoints = globalUndoPoints.pop();
-          editorFeatureCollection.remove( globalUndoFeatures.peek() );
+		// initialize the editing variables
+		editorMode = null;
+		editorLayer = null;
+		editorFeatureCollection = null;
+		editorGeometryForm = null;
 
-          globalRedoFeatures.push( globalUndoFeatures.pop() );
-          if ( !segmRedoPoints.isEmpty() )
-            globalRedoPoints.push( segmRedoPoints );
-          segmRedoPoints = new Stack<Coordinate>();
+		// refresh the display
+		refresh();
+	}
 
-          // On lines the last point and finish feature operation
-          // are separated, so they also must be undone
-          // separately.
-          if ( editorGeometryForm == GeometryForm.LINE ) {
-            generateSegmentFeatureCollection();
-            continue;
-          }
-        }
-      }
-      segmRedoPoints.push( segmUndoPoints.pop() );
-      generateSegmentFeatureCollection();
-    }
-    refresh();
-  }
+	/**
+	 * Makes previously made editing actions undone.
+	 * 
+	 * @param count
+	 *            count of operations made undone
+	 */
+	public void undoEditing(int count) {
+		for (int i = 0; i < count; i++) {
+			if (segmUndoPoints.isEmpty()) {
+				if (globalUndoPoints.isEmpty())
+					// No more undo operations available
+					break;
+				else {
+					segmUndoPoints = globalUndoPoints.pop();
+					editorFeatureCollection.remove(globalUndoFeatures.peek());
 
-  /**
-   * Makes the last made editing action undone.
-   */
-  public void undoEditing() {
-    undoEditing(1);
-  }
+					globalRedoFeatures.push(globalUndoFeatures.pop());
+					if (!segmRedoPoints.isEmpty())
+						globalRedoPoints.push(segmRedoPoints);
+					segmRedoPoints = new Stack<Coordinate>();
 
-  /**
-   * Makes all made editing action undone.
-   */
-  public void undoAll() {
-    undoEditing( Integer.MAX_VALUE );
-  }
+					// On lines the last point and finish feature operation
+					// are separated, so they also must be undone
+					// separately.
+					if (editorGeometryForm == GeometryForm.LINE) {
+						generateSegmentFeatureCollection();
+						continue;
+					}
+				}
+			}
+			segmRedoPoints.push(segmUndoPoints.pop());
+			generateSegmentFeatureCollection();
+		}
+		refresh();
+	}
 
-  /**
-   * Checks wheater a undo operation can be performed.
-   */
-  public boolean isUndoPossible() {
-    return !segmUndoPoints.isEmpty() || !globalUndoPoints.isEmpty();
-  }
+	/**
+	 * Makes the last made editing action undone.
+	 */
+	public void undoEditing() {
+		undoEditing(1);
+	}
 
-  /**
-   * Restores previous undone editing actions.
-   * @param count count of redo operations
-   */
-  public void redoEditing(int count) {
-    for (int i=0; i<count; i++)
-    {
-      if ( segmRedoPoints.isEmpty() ) {
-        if ( globalRedoPoints.isEmpty() )
-          // No more redo operations available
-          break;
-        else {
-          // Lines must be finished when all segment redo operations
-          // are redone; Points and Polygons must not, because they
-          // were already closed on last addSegment(.) (closing point
-          // of polygon is also a part of the redo stack!)
-          if ( editorGeometryForm == GeometryForm.LINE )
-            finishFeature(false, false);
-          segmRedoPoints = globalRedoPoints.pop();
-        }
-      }
-      addSegment( segmRedoPoints.pop(), false, false );
-    }
-    refresh();
-  }
+	/**
+	 * Makes all made editing action undone.
+	 */
+	public void undoAll() {
+		undoEditing(Integer.MAX_VALUE);
+	}
 
-  /**
-   * Restores the last undone editing action.
-   */
-  public void redoEditing() {
-    redoEditing(1);
-  }
+	/**
+	 * Checks wheater a undo operation can be performed.
+	 */
+	public boolean isUndoPossible() {
+		return !segmUndoPoints.isEmpty() || !globalUndoPoints.isEmpty();
+	}
 
-  /**
-   * Checks wheater a redo operation can be performed.
-   */
-  public boolean isRedoPossible() {
-    // Redo possible if
-    // - some operations of the current segment can be redone
-    // - some operations of former segments can be redone
-    return !segmRedoPoints.isEmpty() || !globalRedoPoints.isEmpty();
-  }
+	/**
+	 * Restores previous undone editing actions.
+	 * 
+	 * @param count
+	 *            count of redo operations
+	 */
+	public void redoEditing(int count) {
+		for (int i = 0; i < count; i++) {
+			if (segmRedoPoints.isEmpty()) {
+				if (globalRedoPoints.isEmpty())
+					// No more redo operations available
+					break;
+				else {
+					// Lines must be finished when all segment redo operations
+					// are redone; Points and Polygons must not, because they
+					// were already closed on last addSegment(.) (closing point
+					// of polygon is also a part of the redo stack!)
+					if (editorGeometryForm == GeometryForm.LINE)
+						finishFeature(false, false);
+					segmRedoPoints = globalRedoPoints.pop();
+				}
+			}
+			addSegment(segmRedoPoints.pop(), false, false);
+		}
+		refresh();
+	}
 
-  //**********************************************************************
-  //*****  Helper methods for the editor operations
-  //**********************************************************************
-  /**
-   * Sets {@link #editorFeatureCollection} and {@link #editorLayer} to completely
-   * new instances.
-   * @param title title for the new layer
-   */
-  protected void initUndoRedo() {
-    // initialize the Undo/Redo-Stacks
-    for ( Stack s : globalRedoPoints ) s.clear();
-    for ( Stack s : globalUndoPoints ) s.clear();
-    globalRedoPoints.clear();
-    globalUndoPoints.clear();
-    globalRedoFeatures.clear();
-    globalUndoFeatures.clear();
-    segmRedoPoints.clear();
-    segmUndoPoints.clear();
-  }
+	/**
+	 * Restores the last undone editing action.
+	 */
+	public void redoEditing() {
+		redoEditing(1);
+	}
 
-  /**
-   * Sets {@link #editorFeatureCollection} and {@link #editorLayer} to completely
-   * new instances.
-   * @param title title for the new layer
-   */
-  protected void initEditorFeatureCollection(String title) {
-    // create the new layer
-    editorFeatureCollection = (DefaultFeatureCollection)DefaultFeatureCollections.newCollection(title);
-    editorFeatureType       = createFeatureType(editorMode, getAdditionalAttributes());
-    DUMMY_EDITOR_FEATURE    = createDummyFeature(editorFeatureType);
-    editorFeatureCollection.add(DUMMY_EDITOR_FEATURE);
-    editorGeometryForm      = FeatureUtil.getGeometryForm(editorFeatureCollection);
-    editorLayer             = new DefaultMapLayer(editorFeatureCollection,getEditorStyle(editorGeometryForm));
-    editorLayer.setTitle(title);
-  }
+	/**
+	 * Checks wheater a redo operation can be performed.
+	 */
+	public boolean isRedoPossible() {
+		// Redo possible if
+		// - some operations of the current segment can be redone
+		// - some operations of former segments can be redone
+		return !segmRedoPoints.isEmpty() || !globalRedoPoints.isEmpty();
+	}
 
-  /**
-   * Clears the {@link FeatureCollection} used to handle the current
-   * edited segment.
-   */
-  protected void initSegmentFeatureCollection() {
-    // initialize the segment to start a new feature
-    if ( segmLineFeatureCollection == null ) {
-      // initialize the objects used to display the
-      // current segment as line
-      segmLineFeatureCollection = (DefaultFeatureCollection)DefaultFeatureCollections.newCollection("SegmentAsLine");
-      segmLineFeatureType       = createFeatureType(LineString.class, null);
-      DUMMY_LINE_FEATURE        = createDummyFeature(segmLineFeatureType);
-      segmLineFeatureCollection.add(DUMMY_LINE_FEATURE);
-      segmLineLayer             = new DefaultMapLayer(segmLineFeatureCollection,getEditorStyle(GeometryForm.LINE));
-      segmLineLayer.setTitle("Line layer for current segment");
-      editorMapContext.addLayer(segmLineLayer);
-      // initialize the objects used to display the
-      // current segment as points
-      segmPointFeatureCollection = (DefaultFeatureCollection)DefaultFeatureCollections.newCollection("SegmentAsPoints");
-      segmPointFeatureType       = createFeatureType(MultiPoint.class, null);
-      DUMMY_POINT_FEATURE        = createDummyFeature(segmPointFeatureType);
-      segmPointFeatureCollection.add(DUMMY_POINT_FEATURE);
-      segmPointLayer             = new DefaultMapLayer(segmPointFeatureCollection,getEditorStyle(GeometryForm.POINT));
-      segmPointLayer.setTitle("Point layer for current segment");
-      editorMapContext.addLayer(segmPointLayer);
-    } else {
-      segmLineFeatureCollection.clear();
-      segmPointFeatureCollection.clear();
-    }
-  }
+	// **********************************************************************
+	// ***** Helper methods for the editor operations
+	// **********************************************************************
+	/**
+	 * Sets {@link #editorFeatureCollection} and {@link #editorLayer} to
+	 * completely new instances.
+	 * 
+	 * @param title
+	 *            title for the new layer
+	 */
+	protected void initUndoRedo() {
+		// initialize the Undo/Redo-Stacks
+		for (Stack s : globalRedoPoints)
+			s.clear();
+		for (Stack s : globalUndoPoints)
+			s.clear();
+		globalRedoPoints.clear();
+		globalUndoPoints.clear();
+		globalRedoFeatures.clear();
+		globalUndoFeatures.clear();
+		segmRedoPoints.clear();
+		segmUndoPoints.clear();
+	}
 
-  /**
-   * Creates a new segment SimpleFeature from the currently selected points.
-   */
-  protected void generateSegmentFeatureCollection() {
-    initSegmentFeatureCollection();
-    // show the segment as single points
-    SimpleFeature segmPointFeature = createSegmentPointFeature();
-    if ( segmPointFeature != null )
-      segmPointFeatureCollection.add( segmPointFeature );
-    // show the segment as a line
-    SimpleFeature segmLineFeature = createSegmentLineFeature();
-    if ( segmLineFeature != null )
-      segmLineFeatureCollection.add( segmLineFeature );
-    // Fire event even if no (real) feature is created!
-    fireMapPaneEvent( new FeatureModifiedEvent(this,segmLineLayer,segmLineFeature,this) );
-  }
+	/**
+	 * Sets {@link #editorFeatureCollection} and {@link #editorLayer} to
+	 * completely new instances.
+	 * 
+	 * @param title
+	 *            title for the new layer
+	 */
+	protected void initEditorFeatureCollection(String title) {
+		// create the new layer
+		editorFeatureCollection = DefaultFeatureCollections
+				.newCollection(title);
+		editorFeatureType = createFeatureType(editorMode,
+				getAdditionalAttributes());
+		DUMMY_EDITOR_FEATURE = createDummyFeature(editorFeatureType);
+		editorFeatureCollection.add(DUMMY_EDITOR_FEATURE);
+		editorGeometryForm = FeatureUtil
+				.getGeometryForm(editorFeatureCollection);
+		editorLayer = new DefaultMapLayer(editorFeatureCollection,
+				getEditorStyle(editorGeometryForm));
+		editorLayer.setTitle(title);
+	}
 
-  /**
-   * Creates a new {@link SimpleFeature Line-SimpleFeature} from the currently selected
-   * segment points.
-   */
-  protected SimpleFeature createSegmentLineFeature() {
-    // Line can only be created with at least 2 points
-    // For point layer the segment is not shown
-    if ( segmUndoPoints.size() < 2 ||
-         editorGeometryForm == GeometryForm.POINT )
-      return null;
+	/**
+	 * Clears the {@link FeatureCollection} used to handle the current edited
+	 * segment.
+	 */
+	protected void initSegmentFeatureCollection() {
+		// initialize the segment to start a new feature
+		if (segmLineFeatureCollection == null) {
+			// initialize the objects used to display the
+			// current segment as line
+			segmLineFeatureCollection = (DefaultFeatureCollection) DefaultFeatureCollections
+					.newCollection("SegmentAsLine");
+			segmLineFeatureType = createFeatureType(LineString.class, null);
+			DUMMY_LINE_FEATURE = createDummyFeature(segmLineFeatureType);
+			segmLineFeatureCollection.add(DUMMY_LINE_FEATURE);
+			segmLineLayer = new DefaultMapLayer(segmLineFeatureCollection,
+					getEditorStyle(GeometryForm.LINE));
+			segmLineLayer.setTitle("Line layer for current segment");
+			editorMapContext.addLayer(segmLineLayer);
+			// initialize the objects used to display the
+			// current segment as points
+			segmPointFeatureCollection = (DefaultFeatureCollection) DefaultFeatureCollections
+					.newCollection("SegmentAsPoints");
+			segmPointFeatureType = createFeatureType(MultiPoint.class, null);
+			DUMMY_POINT_FEATURE = createDummyFeature(segmPointFeatureType);
+			segmPointFeatureCollection.add(DUMMY_POINT_FEATURE);
+			segmPointLayer = new DefaultMapLayer(segmPointFeatureCollection,
+					getEditorStyle(GeometryForm.POINT));
+			segmPointLayer.setTitle("Point layer for current segment");
+			editorMapContext.addLayer(segmPointLayer);
+		} else {
+			segmLineFeatureCollection.clear();
+			segmPointFeatureCollection.clear();
+		}
+	}
 
-    Coordinate[] coord      = segmUndoPoints.toArray(new Coordinate[0]);
-    LineString   lineString = createGeometryFromPoints(LineString.class, coord);
-    try {
-      return FeatureUtil.createFeature(segmLineFeatureType, lineString );
-    } catch (Exception e) {
-      throw new RuntimeException(e);
-    }
-  }
+	/**
+	 * Creates a new segment SimpleFeature from the currently selected points.
+	 */
+	protected void generateSegmentFeatureCollection() {
+		initSegmentFeatureCollection();
+		// show the segment as single points
+		SimpleFeature segmPointFeature = createSegmentPointFeature();
+		if (segmPointFeature != null)
+			segmPointFeatureCollection.add(segmPointFeature);
+		// show the segment as a line
+		SimpleFeature segmLineFeature = createSegmentLineFeature();
+		if (segmLineFeature != null)
+			segmLineFeatureCollection.add(segmLineFeature);
+		// Fire event even if no (real) feature is created!
+		fireMapPaneEvent(new FeatureModifiedEvent(this, segmLineLayer,
+				segmLineFeature, this));
+	}
 
-  /**
-   * Creates a new {@link SimpleFeature MultiPoint-SimpleFeature} from the currently selected
-   * segment points.
-   */
-  protected SimpleFeature createSegmentPointFeature() {
-    // Point can only be created with at least 1 point
-    // For point layer the segment is not shown
-    if ( segmUndoPoints.size() < 1 ||
-         editorGeometryForm == GeometryForm.POINT )
-      return null;
+	/**
+	 * Creates a new {@link SimpleFeature Line-SimpleFeature} from the currently
+	 * selected segment points.
+	 */
+	protected SimpleFeature createSegmentLineFeature() {
+		// Line can only be created with at least 2 points
+		// For point layer the segment is not shown
+		if (segmUndoPoints.size() < 2
+				|| editorGeometryForm == GeometryForm.POINT)
+			return null;
 
-    Coordinate[] coord      = segmUndoPoints.toArray(new Coordinate[0]);
-    MultiPoint   multiPoint = createGeometryFromPoints(MultiPoint.class, coord);
-    try {
-      return FeatureUtil.createFeature(segmPointFeatureType,multiPoint);
-    } catch (Exception e) {
-      throw new RuntimeException(e);
-    }
-  }
+		Coordinate[] coord = segmUndoPoints.toArray(new Coordinate[0]);
+		LineString lineString = createGeometryFromPoints(LineString.class,
+				coord);
+		try {
+			return FeatureUtil.createFeature(segmLineFeatureType, lineString);
+		} catch (Exception e) {
+			throw new RuntimeException(e);
+		}
+	}
 
-  /**
-   * Creates a new SimpleFeature from the currently selected points. The non-geometric
-   * attributes are set to default values.
-   */
-  private SimpleFeature createFeature() {
-    Coordinate[] coord   = segmUndoPoints.toArray(new Coordinate[0]);
-    SimpleFeature      feature = null;
-    try {
-      // if a feature was undone previously use this as
-      // default for the new feature
-      if ( !globalRedoFeatures.isEmpty() )
-        feature = globalRedoFeatures.pop();
-      else {
-        // generate default attribute values
-        Object[] attr = FeatureUtil.getDefaultAttributeValues(editorFeatureType);
-        // replace default attribute values with auto generate
-        // values (for all registered attributes)
-        for (int i=0; i<attr.length; i++) {
-          AttributeDescriptor aType = editorFeatureType.getDescriptor(i);
-          if ( FeatureUtil.getAutoValueGenerator(aType) != null )
-            attr[i] = FeatureUtil.getNextAutoValue(aType);
-        }
-        // create new feature
-        feature = FeatureUtil.createFeature(editorFeatureType,attr);
-      }
-      feature.setDefaultGeometry(
-          createGeometryFromPoints(getGeometryType(editorMode), coord )
-      );
+	/**
+	 * Creates a new {@link SimpleFeature MultiPoint-SimpleFeature} from the
+	 * currently selected segment points.
+	 */
+	protected SimpleFeature createSegmentPointFeature() {
+		// Point can only be created with at least 1 point
+		// For point layer the segment is not shown
+		if (segmUndoPoints.size() < 1
+				|| editorGeometryForm == GeometryForm.POINT)
+			return null;
 
-      if ( feature.getAttributeCount() > 1 ) {
-        attrInputOption.setValue(feature);
-        Object[] value = MultipleOptionPane.showMultipleInputDialog(
-                            this,
-                            GeotoolsGUIUtil.RESOURCE.getString("JMapEditorToolBar.NewFeature.title"),
-                            attrInputOption
-        );
-        if ( value == null )
-          return null;
-      }
-      return feature;
-    } catch (Exception e) {
-      throw new RuntimeException(e);
-    }
+		Coordinate[] coord = segmUndoPoints.toArray(new Coordinate[0]);
+		MultiPoint multiPoint = createGeometryFromPoints(MultiPoint.class,
+				coord);
+		try {
+			return FeatureUtil.createFeature(segmPointFeatureType, multiPoint);
+		} catch (Exception e) {
+			throw new RuntimeException(e);
+		}
+	}
 
-  }
+	/**
+	 * Creates a new SimpleFeature from the currently selected points. The
+	 * non-geometric attributes are set to default values.
+	 */
+	private SimpleFeature createFeature() {
+		Coordinate[] coord = segmUndoPoints.toArray(new Coordinate[0]);
+		SimpleFeature feature = null;
+		try {
+			// if a feature was undone previously use this as
+			// default for the new feature
+			if (!globalRedoFeatures.isEmpty())
+				feature = globalRedoFeatures.pop();
+			else {
+				// generate default attribute values
+				Object[] attr = FeatureUtil
+						.getDefaultAttributeValues(editorFeatureType);
+				// replace default attribute values with auto generate
+				// values (for all registered attributes)
+				for (int i = 0; i < attr.length; i++) {
+					AttributeDescriptor aType = editorFeatureType
+							.getDescriptor(i);
+					if (FeatureUtil.getAutoValueGenerator(aType) != null)
+						attr[i] = FeatureUtil.getNextAutoValue(aType);
+				}
+				// create new feature
+				feature = FeatureUtil.createFeature(editorFeatureType, attr);
+			}
+			feature.setDefaultGeometry(createGeometryFromPoints(
+					getGeometryType(editorMode), coord));
 
+			if (feature.getAttributeCount() > 1) {
+				attrInputOption.setValue(feature);
+				Object[] value = MultipleOptionPane
+						.showMultipleInputDialog(
+								this,
+								GeotoolsGUIUtil.RESOURCE
+										.getString("JMapEditorToolBar.NewFeature.title"),
+								attrInputOption);
+				if (value == null)
+					return null;
+			}
+			return feature;
+		} catch (Exception e) {
+			throw new RuntimeException(e);
+		}
 
-  //**********************************************************************
-  //*****  Helper methods to deal with geometries
-  //**********************************************************************
-  /**
-   * Determines the geometry type to deal with according to the
-   * editor mode.
-   * @param mode editor mode
-   */
-  private static Class<? extends Geometry> getGeometryType(EditorMode mode) {
-    switch( mode ) {
-      case New_Point:   return Point.class;
-      case New_Line:    return LineString.class;
-      case New_Polygon: return Polygon.class;
-    }
-    return null;
-  }
+	}
 
-  /**
-   * Creates a geometry (point, linestring/ring, polygon) from a set of points. If
-   * no points are specified ({@code null}), a default geometry is created.
-   * @param gtype type of geometry
-   * @param coord set of points (can be {@code null})
-   */
-  private static <G extends Geometry> G createGeometryFromPoints(Class<G> gtype, Coordinate[] coord) {
-    // Point
-    if ( gtype.isAssignableFrom( com.vividsolutions.jts.geom.Point.class ) ) {
-      if ( coord == null )
-        coord = new Coordinate[] { new Coordinate() };
-      return (G)FeatureUtil.GEOMETRY_FACTORY.createPoint( coord[0] );
-    }
-    // MultiPoint
-    if ( gtype.isAssignableFrom( com.vividsolutions.jts.geom.MultiPoint.class ) ) {
-      if ( coord == null )
-        coord = new Coordinate[] { new Coordinate() };
-      return (G)FeatureUtil.GEOMETRY_FACTORY.createMultiPoint( coord );
-    }
-    // LineString
-    if ( gtype.isAssignableFrom( com.vividsolutions.jts.geom.LineString.class ) ) {
-      if ( coord != null && coord.length > 2 && coord[0].equals(coord[coord.length-1]) )
-        return (G)FeatureUtil.GEOMETRY_FACTORY.createLinearRing(coord);
-      return (G)FeatureUtil.GEOMETRY_FACTORY.createLineString(coord);
-    }
-    // Polygon
-    if ( gtype.isAssignableFrom( com.vividsolutions.jts.geom.Polygon.class ) ) {
-      LinearRing shell = null;
-      if ( coord != null && coord.length > 2 && coord[0].equals(coord[coord.length-1]) )
-        shell = FeatureUtil.GEOMETRY_FACTORY.createLinearRing(coord);
-      return (G)FeatureUtil.GEOMETRY_FACTORY.createPolygon(shell,null);
-    }
+	// **********************************************************************
+	// ***** Helper methods to deal with geometries
+	// **********************************************************************
+	/**
+	 * Determines the geometry type to deal with according to the editor mode.
+	 * 
+	 * @param mode
+	 *            editor mode
+	 */
+	private static Class<? extends Geometry> getGeometryType(EditorMode mode) {
+		switch (mode) {
+		case New_Point:
+			return Point.class;
+		case New_Line:
+			return LineString.class;
+		case New_Polygon:
+			return Polygon.class;
+		}
+		return null;
+	}
 
-    throw new UnsupportedOperationException("Can not create geometry for "+gtype.getName());
-  }
+	/**
+	 * Creates a geometry (point, linestring/ring, polygon) from a set of
+	 * points. If no points are specified ({@code null}), a default geometry is
+	 * created.
+	 * 
+	 * @param gtype
+	 *            type of geometry
+	 * @param coord
+	 *            set of points (can be {@code null})
+	 */
+	private static <G extends Geometry> G createGeometryFromPoints(
+			Class<G> gtype, Coordinate[] coord) {
+		// Point
+		if (gtype.isAssignableFrom(com.vividsolutions.jts.geom.Point.class)) {
+			if (coord == null)
+				coord = new Coordinate[] { new Coordinate() };
+			return (G) FeatureUtil.GEOMETRY_FACTORY.createPoint(coord[0]);
+		}
+		// MultiPoint
+		if (gtype
+				.isAssignableFrom(com.vividsolutions.jts.geom.MultiPoint.class)) {
+			if (coord == null)
+				coord = new Coordinate[] { new Coordinate() };
+			return (G) FeatureUtil.GEOMETRY_FACTORY.createMultiPoint(coord);
+		}
+		// LineString
+		if (gtype
+				.isAssignableFrom(com.vividsolutions.jts.geom.LineString.class)) {
+			if (coord != null && coord.length > 2
+					&& coord[0].equals(coord[coord.length - 1]))
+				return (G) FeatureUtil.GEOMETRY_FACTORY.createLinearRing(coord);
+			return (G) FeatureUtil.GEOMETRY_FACTORY.createLineString(coord);
+		}
+		// Polygon
+		if (gtype.isAssignableFrom(com.vividsolutions.jts.geom.Polygon.class)) {
+			LinearRing shell = null;
+			if (coord != null && coord.length > 2
+					&& coord[0].equals(coord[coord.length - 1]))
+				shell = FeatureUtil.GEOMETRY_FACTORY.createLinearRing(coord);
+			return (G) FeatureUtil.GEOMETRY_FACTORY.createPolygon(shell, null);
+		}
 
-  /**
-   * Extends a feature type with a default geometry attribute.
-   * @param gtype default geometry of the new feature type
-   * @param ftype a feature type which is extended (can be {@code null})
-   */
-  private SimpleFeatureType createFeatureType(Class<? extends Geometry> gtype, SimpleFeatureType ftype) {
-//    GeometryAttributeType geomAttrType = new GeometricAttributeType(
-//        GEOMETRY_ATTR,
-//        gtype,
-//        false,
-//        createGeometryFromPoints(gtype,null),
-//        mapContext.getCoordinateReferenceSystem(),
-//        null
-//    );
-    GeometryAttributeType geomAttrType = FeatureUtil.createGeometryAttributeType(
-        GEOMETRY_ATTR,
-        gtype,
-        createGeometryFromPoints(gtype,null),
-        mapContext.getCoordinateReferenceSystem()
-    );
-    SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
-    builder.init(ftype);
-    if ( ftype == null )
-      builder.setName( gtype.getSimpleName()+"_feature" );
-    builder.add( geomAttrType ); // automatically sets the default geometry! 
-    
-    return builder.buildFeatureType();
-  }
+		throw new UnsupportedOperationException("Can not create geometry for "
+				+ gtype.getName());
+	}
 
-  /**
-   * Extends a feature type with a default geometry attribute.
-   * @param mode  specifies the the default geometry used for the feature type
-   * @param ftype a feature type which is extended (can be {@code null})
-   */
-  private SimpleFeatureType createFeatureType(EditorMode mode, SimpleFeatureType ftype) {
-    Class<? extends Geometry> gtype = null;
-    switch( mode ) {
-      case New_Point:   gtype = Point.class; break;
-      case New_Line:    gtype = LineString.class; break;
-      case New_Polygon: gtype = Polygon.class; break;
-    }
-    return createFeatureType(gtype,ftype);
-  }
+	/**
+	 * Extends a feature type with a default geometry attribute.
+	 * 
+	 * @param gtype
+	 *            default geometry of the new feature type
+	 * @param ftype
+	 *            a feature type which is extended (can be {@code null})
+	 */
+	private SimpleFeatureType createFeatureType(
+			Class<? extends Geometry> gtype, SimpleFeatureType ftype) {
+		// GeometryAttributeType geomAttrType = new GeometricAttributeType(
+		// GEOMETRY_ATTR,
+		// gtype,
+		// false,
+		// createGeometryFromPoints(gtype,null),
+		// mapContext.getCoordinateReferenceSystem(),
+		// null
+		// );
 
-  /**
-   * Creates a feature with default values for a given feature type.
-   * @param ftype a feature type
-   */
-  private static SimpleFeature createDummyFeature(SimpleFeatureType ftype) {
-    try {
-      return FeatureUtil.createSampleFeature(ftype);
-    } catch (Exception e) {
-      throw new RuntimeException(e);
-    }
-  }
+		// GeometryAttributeType geomAttrType =
+		// (
+		// GEOMETRY_ATTR,
+		// gtype,
+		// createGeometryFromPoints(gtype,null),
+		// mapContext.getCoordinateReferenceSystem()
+		// );
 
-  /**
-   * Checks, whether the editor layer is empty. If it is, a dummy feature is inserted
-   * because the StreamingRenderer can not handle empty Feature-Layers yet
-   * (also if the layer is hidden!).
-   * At the moment, the first a feature is added, the dummy feature is removed, so
-   * is is not displayed any time.
-   */
-  private void resetEditorLayerVisibility() {
-//    if ( 1==1 )
-//      return;
-    // if layer is empty, insert a Dummy-SimpleFeature (and hide the
-    // layer) because the StreamingRenderer can not handle empty
-    // SimpleFeature-Layers yet
-    if ( segmLineFeatureCollection != null && segmLineFeatureCollection.size() == 0 )
-      segmLineFeatureCollection.add( DUMMY_LINE_FEATURE );
-    if ( segmPointFeatureCollection != null && segmPointFeatureCollection.size() == 0 )
-      segmPointFeatureCollection.add( DUMMY_POINT_FEATURE );
-    if ( editorFeatureCollection != null && editorFeatureCollection.size() == 0 )
-      editorFeatureCollection.add( DUMMY_EDITOR_FEATURE );
+		// New without gt-legacy:
+		GeometryDescriptor geomAttrType = AttributeTypeFactory
+				.newGeometryAttributeDescriptor(GEOMETRY_ATTR, gtype, null, null,
+						createGeometryFromPoints(gtype, null),
+						mapContext.getCoordinateReferenceSystem());
 
-    // if the layer is not empty anymore, remove the Dummy-SimpleFeature, so
-    // it is not displayed
-    if ( segmLineFeatureCollection != null && segmLineFeatureCollection.size() == 2 )
-      segmLineFeatureCollection.remove( DUMMY_LINE_FEATURE );
-    if ( segmPointFeatureCollection != null && segmPointFeatureCollection.size() == 2 )
-      segmPointFeatureCollection.remove( DUMMY_POINT_FEATURE );
-    if ( editorFeatureCollection != null && editorFeatureCollection.size() == 2 )
-      editorFeatureCollection.remove( DUMMY_EDITOR_FEATURE );
+		SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
+		builder.init(ftype);
+		if (ftype == null)
+			builder.setName(gtype.getSimpleName() + "_feature");
+		builder.add(geomAttrType); // automatically sets the default geometry!
 
-    // hide the editor layer if it only contains the dummy feature
-    if ( editorLayer != null )
-      editorLayer.setVisible(editorFeatureCollection.size() > 1 || !editorFeatureCollection.contains(DUMMY_EDITOR_FEATURE));
-    if ( segmLineLayer != null )
-      segmLineLayer.setVisible(segmLineFeatureCollection.size() > 1 || !segmLineFeatureCollection.contains(DUMMY_LINE_FEATURE));
-    if ( segmPointLayer != null )
-      segmPointLayer.setVisible(segmPointFeatureCollection.size() > 1 || !segmPointFeatureCollection.contains(DUMMY_POINT_FEATURE));
-  }
+		return builder.buildFeatureType();
+	}
 
+	/**
+	 * Extends a feature type with a default geometry attribute.
+	 * 
+	 * @param mode
+	 *            specifies the the default geometry used for the feature type
+	 * @param ftype
+	 *            a feature type which is extended (can be {@code null})
+	 */
+	private SimpleFeatureType createFeatureType(EditorMode mode,
+			SimpleFeatureType ftype) {
+		Class<? extends Geometry> gtype = null;
+		switch (mode) {
+		case New_Point:
+			gtype = Point.class;
+			break;
+		case New_Line:
+			gtype = LineString.class;
+			break;
+		case New_Polygon:
+			gtype = Polygon.class;
+			break;
+		}
+		return createFeatureType(gtype, ftype);
+	}
+
+	/**
+	 * Creates a feature with default values for a given feature type.
+	 * 
+	 * @param ftype
+	 *            a feature type
+	 */
+	private static SimpleFeature createDummyFeature(SimpleFeatureType ftype) {
+		try {
+			return FeatureUtil.createSampleFeature(ftype);
+		} catch (Exception e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+	/**
+	 * Checks, whether the editor layer is empty. If it is, a dummy feature is
+	 * inserted because the StreamingRenderer can not handle empty
+	 * Feature-Layers yet (also if the layer is hidden!). At the moment, the
+	 * first a feature is added, the dummy feature is removed, so is is not
+	 * displayed any time.
+	 */
+	private void resetEditorLayerVisibility() {
+		// if ( 1==1 )
+		// return;
+		// if layer is empty, insert a Dummy-SimpleFeature (and hide the
+		// layer) because the StreamingRenderer can not handle empty
+		// SimpleFeature-Layers yet
+		if (segmLineFeatureCollection != null
+				&& segmLineFeatureCollection.size() == 0)
+			segmLineFeatureCollection.add(DUMMY_LINE_FEATURE);
+		if (segmPointFeatureCollection != null
+				&& segmPointFeatureCollection.size() == 0)
+			segmPointFeatureCollection.add(DUMMY_POINT_FEATURE);
+		if (editorFeatureCollection != null
+				&& editorFeatureCollection.size() == 0)
+			editorFeatureCollection.add(DUMMY_EDITOR_FEATURE);
+
+		// if the layer is not empty anymore, remove the Dummy-SimpleFeature, so
+		// it is not displayed
+		if (segmLineFeatureCollection != null
+				&& segmLineFeatureCollection.size() == 2)
+			segmLineFeatureCollection.remove(DUMMY_LINE_FEATURE);
+		if (segmPointFeatureCollection != null
+				&& segmPointFeatureCollection.size() == 2)
+			segmPointFeatureCollection.remove(DUMMY_POINT_FEATURE);
+		if (editorFeatureCollection != null
+				&& editorFeatureCollection.size() == 2)
+			editorFeatureCollection.remove(DUMMY_EDITOR_FEATURE);
+
+		// hide the editor layer if it only contains the dummy feature
+		if (editorLayer != null)
+			editorLayer.setVisible(editorFeatureCollection.size() > 1
+					|| !editorFeatureCollection.contains(DUMMY_EDITOR_FEATURE));
+		if (segmLineLayer != null)
+			segmLineLayer.setVisible(segmLineFeatureCollection.size() > 1
+					|| !segmLineFeatureCollection.contains(DUMMY_LINE_FEATURE));
+		if (segmPointLayer != null)
+			segmPointLayer.setVisible(segmPointFeatureCollection.size() > 1
+					|| !segmPointFeatureCollection
+							.contains(DUMMY_POINT_FEATURE));
+	}
+
 }

Modified: 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:42:02 UTC (rev 1478)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/RenderingState.java	2011-02-02 20:30:14 UTC (rev 1479)
@@ -1,6 +1,8 @@
 package de.schmitzm.geotools.gui;
 
+/**
+ * Enumeration for possible rendering states of the {@link XMapPane}.
+ */
 public enum RenderingState {
 	ON_HOLD, RENDERING
-
 }

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:42:02 UTC (rev 1478)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StylingUtil.java	2011-02-02 20:30:14 UTC (rev 1479)
@@ -72,7 +72,6 @@
 import org.geotools.factory.CommonFactoryFinder;
 import org.geotools.factory.GeoTools;
 import org.geotools.feature.FeatureCollection;
-import org.geotools.feature.GeometryAttributeType;
 import org.geotools.feature.NameImpl;
 import org.geotools.filter.AndImpl;
 import org.geotools.filter.BinaryComparisonAbstract;



More information about the Schmitzm-commits mailing list