[Schmitzm-commits] r1699 - trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Aug 30 21:12:51 CEST 2011


Author: alfonx
Date: 2011-08-30 21:12:51 +0200 (Tue, 30 Aug 2011)
New Revision: 1699

Modified:
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerUtil.java
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StylingUtil.java
Log:
Ein paar Konstanten von GP in Schmitzm verschoben um StylingUtil.optimize(Style) zu implementieren...

Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerUtil.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerUtil.java	2011-08-30 09:30:25 UTC (rev 1698)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerUtil.java	2011-08-30 19:12:51 UTC (rev 1699)
@@ -72,12 +72,12 @@
 import org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer;
 import org.geotools.styling.ColorMap;
 import org.geotools.styling.ColorMapEntry;
-import org.geotools.styling.ContrastEnhancement;
 import org.geotools.styling.FeatureTypeStyle;
 import org.geotools.styling.RasterSymbolizer;
 import org.geotools.styling.Rule;
 import org.geotools.styling.SelectedChannelType;
 import org.geotools.styling.Style;
+import org.geotools.styling.Symbolizer;
 import org.jdom.Document;
 import org.jdom.Element;
 import org.jdom.input.SAXBuilder;
@@ -111,21 +111,24 @@
 import de.schmitzm.swing.SwingUtil;
 
 /**
- * This class provides static helper methods for dealing with {@link StyledLayerInterface} stuff.
+ * This class provides static helper methods for dealing with
+ * {@link StyledLayerInterface} stuff.
  * 
- * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a> (University of Bonn/Germany)
+ * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
+ *         (University of Bonn/Germany)
  * @version 1.0
  */
 public class StyledLayerUtil {
-	private static final Logger LOGGER = Logger.getLogger(StyledLayerUtil.class.getName());
+	private static final Logger LOGGER = Logger.getLogger(StyledLayerUtil.class
+			.getName());
 	private static final SAXBuilder SAX_BUILDER = new SAXBuilder();
 	private static final XMLOutputter XML_OUTPUTTER = new XMLOutputter();
 
 	final public static String DONT_IMPORT_MARKER_STRING = "DONTIMPORT";
 
 	/**
-	 * Tries to load a style from the file denoted in {@link #getSldFile()}. If the file doesn't exits, return
-	 * <code>null</code>;
+	 * Tries to load a style from the file denoted in {@link #getSldFile()}. If
+	 * the file doesn't exits, return <code>null</code>;
 	 * 
 	 * @return <code>true</code> is style was loaded
 	 */
@@ -143,7 +146,8 @@
 	}
 
 	/**
-	 * Is appended to the name of a rule, this rule shall not be shown in the legend
+	 * Is appended to the name of a rule, this rule shall not be shown in the
+	 * legend
 	 */
 	public final static String HIDE_IN_LAYER_LEGEND_HINT = "HIDE_IN_LEGEND";
 
@@ -162,32 +166,39 @@
 	private static FilterFactory2 ff = FilterUtil.FILTER_FAC2;
 
 	/**
-	 * Creates a Geotools {@link MapLayer} from an object. If the object is a {@link StyledLayerInterface} then its
-	 * sytle is used. In case of direct Geotools objects ({@link GridCoverage2D}, {@link AbstractGridCoverage2DReader},
-	 * {@link FeatureCollection}) a default style is generated.
+	 * Creates a Geotools {@link MapLayer} from an object. If the object is a
+	 * {@link StyledLayerInterface} then its sytle is used. In case of direct
+	 * Geotools objects ({@link GridCoverage2D},
+	 * {@link AbstractGridCoverage2DReader}, {@link FeatureCollection}) a
+	 * default style is generated.
 	 * 
 	 * @param object
 	 *            an Object
 	 * @exception Exception
-	 *                if {@code null} is given as object or an error occurs during layer creation
+	 *                if {@code null} is given as object or an error occurs
+	 *                during layer creation
 	 */
 	public static MapLayer createMapLayer(final Object object) throws Exception {
 		return createMapLayer(object, null);
 	}
 
 	/**
-	 * Creates a Geotools {@link MapLayer} from an object. If the object is a {@link StyledLayerInterface} then its
-	 * sytle is used. In case of direct Geotools objects ({@link GridCoverage2D}, {@link AbstractGridCoverage2DReader},
-	 * {@link FeatureCollection}) a default style is generated.
+	 * Creates a Geotools {@link MapLayer} from an object. If the object is a
+	 * {@link StyledLayerInterface} then its sytle is used. In case of direct
+	 * Geotools objects ({@link GridCoverage2D},
+	 * {@link AbstractGridCoverage2DReader}, {@link FeatureCollection}) a
+	 * default style is generated.
 	 * 
 	 * @param object
 	 *            an Object
 	 * @param forcedStyle
 	 *            (SLD-)Style to force for the object
 	 * @exception Exception
-	 *                if {@code null} is given as object or an error occurs during layer creation
+	 *                if {@code null} is given as object or an error occurs
+	 *                during layer creation
 	 */
-	public static MapLayer createMapLayer(Object object, final Style forcedStyle) throws Exception {
+	public static MapLayer createMapLayer(Object object, final Style forcedStyle)
+			throws Exception {
 		MapLayer layer = null;
 		Style style = null;
 		if (object instanceof StyledLayerInterface) {
@@ -202,34 +213,40 @@
 		if (object instanceof GridCoverage2D)
 			layer = new DefaultMapLayer((GridCoverage2D) object, style);
 		if (object instanceof AbstractGridCoverage2DReader)
-			layer = new DefaultMapLayer((AbstractGridCoverage2DReader) object, style);
+			layer = new DefaultMapLayer((AbstractGridCoverage2DReader) object,
+					style);
 		if (object instanceof FeatureCollection)
 			layer = new DefaultMapLayer((FeatureCollection) object, style);
 
 		if (layer == null)
-			throw new Exception("Can not create MapLayer from " + (object == null ? "null" : object.getClass()));
+			throw new Exception("Can not create MapLayer from "
+					+ (object == null ? "null" : object.getClass()));
 
 		return layer;
 	}
 
 	/**
-	 * Creates an default instance of {@link StyledLayerInterface} for a Geotools object ({@link GridCoverage2D},
-	 * {@link FeatureCollection}) with a default style.
+	 * Creates an default instance of {@link StyledLayerInterface} for a
+	 * Geotools object ({@link GridCoverage2D}, {@link FeatureCollection}) with
+	 * a default style.
 	 * 
 	 * @param object
 	 *            an Object
 	 * @param title
 	 *            title for the object
 	 * @exception UnsupportedOperationException
-	 *                if {@code null} is given as object or an error occurs during creation
+	 *                if {@code null} is given as object or an error occurs
+	 *                during creation
 	 */
-	public static StyledLayerInterface<?> createStyledLayer(final Object object, final String title) {
+	public static StyledLayerInterface<?> createStyledLayer(
+			final Object object, final String title) {
 		return createStyledLayer(object, title, null);
 	}
 
 	/**
-	 * Creates an default instance of {@link StyledLayerInterface} for a Geotools object ({@link GridCoverage2D},
-	 * {@link FeatureCollection}) with a given style.
+	 * Creates an default instance of {@link StyledLayerInterface} for a
+	 * Geotools object ({@link GridCoverage2D}, {@link FeatureCollection}) with
+	 * a given style.
 	 * 
 	 * @param object
 	 *            an Object
@@ -238,24 +255,30 @@
 	 * @param style
 	 *            style and meta data for the object
 	 * @exception UnsupportedOperationException
-	 *                if {@code null} is given as object or an error occurs during creation
+	 *                if {@code null} is given as object or an error occurs
+	 *                during creation
 	 */
-	public static StyledLayerInterface<?> createStyledLayer(final Object object, final String title,
+	public static StyledLayerInterface<?> createStyledLayer(
+			final Object object, final String title,
 			final StyledLayerStyle style) {
 		StyledLayerInterface<?> styledLayer = null;
 
 		final String id = (title != null) ? title : "defaultID";
 
 		if (object instanceof GridCoverage2D)
-			styledLayer = new StyledGridCoverage((GridCoverage2D) object, id, title, style);
+			styledLayer = new StyledGridCoverage((GridCoverage2D) object, id,
+					title, style);
 		else if (object instanceof AbstractGridCoverage2DReader)
-			styledLayer = new StyledGridCoverageReader((AbstractGridCoverage2DReader) object, id, title, style);
+			styledLayer = new StyledGridCoverageReader(
+					(AbstractGridCoverage2DReader) object, id, title, style);
 		else if (object instanceof FeatureCollection)
-			styledLayer = new StyledFeatureCollection((FeatureCollection) object, id, title, style);
+			styledLayer = new StyledFeatureCollection(
+					(FeatureCollection) object, id, title, style);
 
 		if (styledLayer == null)
-			throw new UnsupportedOperationException("Can not create StyledLayerInterface object from "
-					+ (object == null ? "null" : object.getClass()));
+			throw new UnsupportedOperationException(
+					"Can not create StyledLayerInterface object from "
+							+ (object == null ? "null" : object.getClass()));
 
 		return styledLayer;
 	}
@@ -266,12 +289,15 @@
 	 * @param amdMap
 	 *            AttributeMetaData-Map
 	 * @param visible
-	 *            indicated whether the visible or invisible entries are returned
+	 *            indicated whether the visible or invisible entries are
+	 *            returned
 	 * 
-	 *            TODO replace with {@link AttributeMetadataMap#sortedValuesVisibleOnly()}
+	 *            TODO replace with
+	 *            {@link AttributeMetadataMap#sortedValuesVisibleOnly()}
 	 */
 	public static AttributeMetadataMap<? extends AttributeMetadataInterface> getVisibleAttributeMetaData(
-			final AttributeMetadataMap<? extends AttributeMetadataInterface> amdMap, final boolean visible) {
+			final AttributeMetadataMap<? extends AttributeMetadataInterface> amdMap,
+			final boolean visible) {
 
 		final AttributeMetadataMap<AttributeMetadataInterface> filteredMap = (AttributeMetadataMap<AttributeMetadataInterface>) amdMap
 				.clone();
@@ -287,21 +313,25 @@
 	}
 
 	/**
-	 * Parses a {@link AttributeMetadataImpl} object from an JDOM- {@link Element}. This method works like {@link
+	 * Parses a {@link AttributeMetadataImpl} object from an JDOM-
+	 * {@link Element}. This method works like {@link
 	 * AMLImport#parseDataAttribute(org.w3c.dom.Node}, but for JDOM.
 	 * 
-	 * TODO 20.11.2009, SK: There are some new attribute weight, functiona, functionX and nodata in AttributeMetaData
-	 * that should be parsed/exported too. but this method is only used by ISDSS, which is not supporting that stuff
-	 * anyways.
+	 * TODO 20.11.2009, SK: There are some new attribute weight, functiona,
+	 * functionX and nodata in AttributeMetaData that should be parsed/exported
+	 * too. but this method is only used by ISDSS, which is not supporting that
+	 * stuff anyways.
 	 * 
 	 * @param element
 	 *            {@link Element} to parse
 	 */
-	public static AttributeMetadataImpl parseAttributeMetaData(final Element element) {
+	public static AttributeMetadataImpl parseAttributeMetaData(
+			final Element element) {
 		final String namespace = element.getAttributeValue("namespace");
 		final String localname = element.getAttributeValue("localname");
 		final NameImpl aName = new NameImpl(namespace, localname);
-		final Boolean visible = Boolean.valueOf(element.getAttributeValue("visible"));
+		final Boolean visible = Boolean.valueOf(element
+				.getAttributeValue("visible"));
 		final String unit = element.getAttributeValue("unit");
 
 		Translation name = new Translation();
@@ -319,17 +349,22 @@
 	}
 
 	/**
-	 * Parses a {@link AttributeMetadataImpl} map from an JDOM-{@link Element} with {@code <attribute>}-childs.
+	 * Parses a {@link AttributeMetadataImpl} map from an JDOM-{@link Element}
+	 * with {@code <attribute>}-childs.
 	 * 
 	 * @param element
 	 *            {@link Element} to parse
 	 * 
-	 *            TODO Since GP 1.3 the {@link AttributeMetadataImpl} class has more attributes which are not used by
-	 *            Xulu/ISDSS. GP exports/imports the AMD via AMLExporter and AMLImporter classes. (SK, 3.2.2010) *
+	 *            TODO Since GP 1.3 the {@link AttributeMetadataImpl} class has
+	 *            more attributes which are not used by Xulu/ISDSS. GP
+	 *            exports/imports the AMD via AMLExporter and AMLImporter
+	 *            classes. (SK, 3.2.2010) *
 	 */
-	public static AttributeMetadataMap parseAttributeMetaDataMap(final Element element) {
+	public static AttributeMetadataMap parseAttributeMetaDataMap(
+			final Element element) {
 		final AttributeMetadataMap metaData = new AttributeMetadataImplMap();
-		final List<Element> attributesElements = element.getChildren(ELEM_NAME_ATTRIBUTE);
+		final List<Element> attributesElements = element
+				.getChildren(ELEM_NAME_ATTRIBUTE);
 		for (final Element attibuteElement : attributesElements) {
 			final AttributeMetadataImpl attrMetaData = parseAttributeMetaData(attibuteElement);
 			metaData.put(attrMetaData.getName(), attrMetaData);
@@ -344,23 +379,29 @@
 	 *            {@link URL} to parse
 	 * @see #parseAttributeMetaData(Element)
 	 */
-	public static AttributeMetadataMap loadAttributeMetaDataMap(final URL documentUrl) throws Exception {
+	public static AttributeMetadataMap loadAttributeMetaDataMap(
+			final URL documentUrl) throws Exception {
 		final Document document = SAX_BUILDER.build(documentUrl);
 		return parseAttributeMetaDataMap(document.getRootElement());
 	}
 
 	/**
-	 * Creates an JDOM {@link Element} for the given {@link AttributeMetadataImpl} object.
+	 * Creates an JDOM {@link Element} for the given
+	 * {@link AttributeMetadataImpl} object.
 	 * 
 	 * @param amd
 	 *            meta data for one attribute
 	 * 
-	 *            TODO Since GP 1.3 the {@link AttributeMetadataImpl} class has more attributes which are not used by
-	 *            Xulu/ISDSS. GP exports/imports the AMD via AMLExporter and AMLImporter classes. (SK, 3.2.2010)
+	 *            TODO Since GP 1.3 the {@link AttributeMetadataImpl} class has
+	 *            more attributes which are not used by Xulu/ISDSS. GP
+	 *            exports/imports the AMD via AMLExporter and AMLImporter
+	 *            classes. (SK, 3.2.2010)
 	 */
-	public static Element createAttributeMetaDataElement(final AttributeMetadataInterface amd) {
+	public static Element createAttributeMetaDataElement(
+			final AttributeMetadataInterface amd) {
 		final Element element = new Element(ELEM_NAME_ATTRIBUTE, AMLURI);
-		element.setAttribute("namespace", String.valueOf(amd.getName().getNamespaceURI()));
+		element.setAttribute("namespace",
+				String.valueOf(amd.getName().getNamespaceURI()));
 		element.setAttribute("localname", String.valueOf(amd.getLocalName()));
 		element.setAttribute("visible", String.valueOf(amd.isVisible()));
 		element.setAttribute("unit", amd.getUnit());
@@ -372,7 +413,8 @@
 	}
 
 	/**
-	 * Creates an JDOM {@link Element} for the given {@link AttributeMetadataImpl} map.
+	 * Creates an JDOM {@link Element} for the given
+	 * {@link AttributeMetadataImpl} map.
 	 * 
 	 * @param amdMap
 	 *            map of attribute meta data
@@ -393,7 +435,8 @@
 	 * @param documentUrl
 	 *            {@link URL} to store the XML
 	 */
-	public static void saveAttributeMetaDataMap(final AttributeMetadataMap amdMap, final URL documentUrl)
+	public static void saveAttributeMetaDataMap(
+			final AttributeMetadataMap amdMap, final URL documentUrl)
 			throws Exception {
 		// Create XML-Document
 		final FileWriter out = new FileWriter(new File(documentUrl.toURI()));
@@ -403,7 +446,8 @@
 	}
 
 	/**
-	 * Parses a {@link RasterLegendData} object from an JDOM-{@link Element}. This method works like {@link
+	 * Parses a {@link RasterLegendData} object from an JDOM-{@link Element}.
+	 * This method works like {@link
 	 * AMLImport#parseRasterLegendData(org.w3c.dom.Node}, but for JDOM.
 	 * 
 	 * @param element
@@ -411,7 +455,8 @@
 	 */
 	public static RasterLegendData parseRasterLegendData(final Element element) {
 
-		final boolean paintGaps = Boolean.valueOf(element.getAttributeValue("paintGaps"));
+		final boolean paintGaps = Boolean.valueOf(element
+				.getAttributeValue("paintGaps"));
 
 		final RasterLegendData rld = new RasterLegendData(paintGaps);
 
@@ -422,10 +467,12 @@
 				continue;
 
 			if (name.equals(ELEM_NAME_RASTERLEGEND)) {
-				final String valueAttr = childElement.getAttributeValue("value");
+				final String valueAttr = childElement
+						.getAttributeValue("value");
 				if (valueAttr == null)
-					throw new UnsupportedOperationException("Attribute 'value' missing for definition of <"
-							+ ELEM_NAME_RASTERLEGEND + ">");
+					throw new UnsupportedOperationException(
+							"Attribute 'value' missing for definition of <"
+									+ ELEM_NAME_RASTERLEGEND + ">");
 				final double value = Double.valueOf(valueAttr);
 
 				// first and only item should be the label
@@ -433,7 +480,8 @@
 				// id label element is missing, the translation is searched
 				// directly
 				// as childs of the rasterLegendItem element
-				final Translation label = parseTranslation(labelElement != null ? labelElement : childElement);
+				final Translation label = parseTranslation(labelElement != null ? labelElement
+						: childElement);
 				rld.put(value, label);
 			}
 		}
@@ -448,18 +496,21 @@
 	 *            {@link URL} to parse
 	 * @see #parseAttributeMetaData(Element)
 	 */
-	public static RasterLegendData loadRasterLegendData(final URL documentUrl) throws Exception {
+	public static RasterLegendData loadRasterLegendData(final URL documentUrl)
+			throws Exception {
 		final Document document = SAX_BUILDER.build(documentUrl);
 		return parseRasterLegendData(document.getRootElement());
 	}
 
 	/**
-	 * Creates an JDOM {@link Element} for the given {@link RasterLegendData} map.
+	 * Creates an JDOM {@link Element} for the given {@link RasterLegendData}
+	 * map.
 	 * 
 	 * @param rld
 	 *            raster legend data
 	 */
-	public static Element createRasterLegendDataElement(final RasterLegendData rld) {
+	public static Element createRasterLegendDataElement(
+			final RasterLegendData rld) {
 		final Element element = new Element(ELEM_NAME_RLD, AMLURI);
 		element.setAttribute("paintGaps", rld.isPaintGaps().toString());
 		for (final Double key : rld.getSortedKeys()) {
@@ -479,13 +530,15 @@
 	 * @param paintGaps
 	 *            indicated whether gaps are painted between the legend items
 	 * @param digits
-	 *            number of digits the grid value classes (and legend) are rounded to (null means no round; >= 0 means
-	 *            digits after comma; < 0 means digits before comma)
+	 *            number of digits the grid value classes (and legend) are
+	 *            rounded to (null means no round; >= 0 means digits after
+	 *            comma; < 0 means digits before comma)
 	 */
-	public static RasterLegendData generateRasterLegendData(final ColorMap colorMap, final boolean paintGaps,
+	public static RasterLegendData generateRasterLegendData(
+			final ColorMap colorMap, final boolean paintGaps,
 			final Integer digits) {
-		final DecimalFormat decFormat = digits != null ? new DecimalFormat(SwingUtil.getNumberFormatPattern(digits))
-				: null;
+		final DecimalFormat decFormat = digits != null ? new DecimalFormat(
+				SwingUtil.getNumberFormatPattern(digits)) : null;
 		final RasterLegendData rld = new RasterLegendData(paintGaps);
 		int idx = 0;
 
@@ -499,7 +552,8 @@
 			// To make the last class limit INCLUSIVE, AtlasStylerRaster repeats
 			// the last CME with the same quantity (=value). This CME can then
 			// be ignored.
-			if (cmes.get(cmes.size() - 1).getQuantity().equals(cmes.get(cmes.size() - 2).getQuantity())) {
+			if (cmes.get(cmes.size() - 1).getQuantity()
+					.equals(cmes.get(cmes.size() - 2).getQuantity())) {
 				// Simply remove the last CME in that case
 				cmes.remove(cmes.size() - 1);
 			}
@@ -507,7 +561,8 @@
 
 		for (final ColorMapEntry cme : cmes) {
 
-			if (idx == cmes.size() - 1 && colorMap.getType() != ColorMap.TYPE_VALUES) {
+			if (idx == cmes.size() - 1
+					&& colorMap.getType() != ColorMap.TYPE_VALUES) {
 				// Ignore the last CME label if not in VALUES mode
 				continue;
 			}
@@ -536,14 +591,16 @@
 	 * @param paintGaps
 	 *            indicated whether gaps are painted between the legend items
 	 * @param digits
-	 *            number of digits the grid value classes (and legend) are rounded to (null means no round; >= 0 means
-	 *            digits after comma; < 0 means digits before comma)
+	 *            number of digits the grid value classes (and legend) are
+	 *            rounded to (null means no round; >= 0 means digits after
+	 *            comma; < 0 means digits before comma)
 	 */
-	public static RasterLegendData generateRasterLegendData(final Style style, final boolean paintGaps,
-			final Integer digits) {
+	public static RasterLegendData generateRasterLegendData(final Style style,
+			final boolean paintGaps, final Integer digits) {
 		final ColorMap colorMap = StylingUtil.getColorMapFromStyle(style);
 		if (colorMap == null)
-			throw new IllegalArgumentException("Color map can not be determined from style!");
+			throw new IllegalArgumentException(
+					"Color map can not be determined from style!");
 		return generateRasterLegendData(colorMap, paintGaps, digits);
 	}
 
@@ -555,7 +612,8 @@
 	 * @param documentUrl
 	 *            {@link URL} to store the XML
 	 */
-	public static void saveRasterLegendData(final RasterLegendData rld, final URL documentUrl) throws Exception {
+	public static void saveRasterLegendData(final RasterLegendData rld,
+			final URL documentUrl) throws Exception {
 		// Create XML-Document
 		final FileWriter out = new FileWriter(new File(documentUrl.toURI()));
 		XML_OUTPUTTER.output(createRasterLegendDataElement(rld), out);
@@ -564,8 +622,9 @@
 	}
 
 	/**
-	 * Parses a {@link Translation} object from an JDOM-{@link Element}. This method works like {@link
-	 * AMLImport#parseTranslation(org.w3c.dom.Node}, but for JDOM.
+	 * Parses a {@link Translation} object from an JDOM-{@link Element}. This
+	 * method works like {@link AMLImport#parseTranslation(org.w3c.dom.Node},
+	 * but for JDOM.
 	 * 
 	 * @param element
 	 *            {@link Element} to parse
@@ -576,7 +635,8 @@
 		if (element == null)
 			return trans;
 
-		for (final Element translationElement : (List<Element>) element.getChildren()) {
+		for (final Element translationElement : (List<Element>) element
+				.getChildren()) {
 			final String name = translationElement.getName();
 			if (name == null)
 				continue;
@@ -612,15 +672,18 @@
 	 * @param translation
 	 *            Translation to store in the Element
 	 */
-	public final static Element createTranslationElement(final String tagname, final Translation translation) {
+	public final static Element createTranslationElement(final String tagname,
+			final Translation translation) {
 		final Element element = new Element(tagname, AMLURI);
 		if (translation == null)
-			throw new UnsupportedOperationException("Translation element can not be created from null!");
+			throw new UnsupportedOperationException(
+					"Translation element can not be created from null!");
 
 		// If only a default translation is set, the <translation
 		// lang="..">..</tranlation>
 		// part is not used
-		if (translation.keySet().size() == 1 && translation.get(Translation.DEFAULT_KEY) != null) {
+		if (translation.keySet().size() == 1
+				&& translation.get(Translation.DEFAULT_KEY) != null) {
 			element.addContent(translation.get(Translation.DEFAULT_KEY));
 			return element;
 		}
@@ -628,7 +691,8 @@
 		// add a <translation lang="..">..</tranlation> part to the element for
 		// all languages
 		for (final String lang : translation.keySet()) {
-			final Element translationElement = new Element(ELEM_NAME_TRANSLATION, AMLURI);
+			final Element translationElement = new Element(
+					ELEM_NAME_TRANSLATION, AMLURI);
 			translationElement.setAttribute("lang", lang);
 			String translationString = translation.get(lang);
 			if (translationString == null)
@@ -648,14 +712,19 @@
 	 * @param style
 	 *            a Style
 	 */
-	public static void setStyledLayerStyle(final StyledLayerInterface styledObject, final StyledLayerStyle<?> style) {
+	public static void setStyledLayerStyle(
+			final StyledLayerInterface styledObject,
+			final StyledLayerStyle<?> style) {
 		// set SLD style
 		styledObject.setStyle(style.getGeoObjectStyle());
 		// set meta data
 		if (styledObject instanceof StyledGridCoverageInterface
-				&& (style.getMetaData() instanceof RasterLegendData || style.getMetaData() == null)) {
-			final RasterLegendData sourceRld = (RasterLegendData) style.getMetaData();
-			final RasterLegendData destRld = ((StyledGridCoverageInterface) styledObject).getLegendMetaData();
+				&& (style.getMetaData() instanceof RasterLegendData || style
+						.getMetaData() == null)) {
+			final RasterLegendData sourceRld = (RasterLegendData) style
+					.getMetaData();
+			final RasterLegendData destRld = ((StyledGridCoverageInterface) styledObject)
+					.getLegendMetaData();
 			if (destRld != null && sourceRld != null) {
 				destRld.setPaintGaps(sourceRld.isPaintGaps());
 				destRld.clear();
@@ -665,7 +734,8 @@
 		}
 		if (styledObject instanceof StyledFeatureCollectionInterface
 				&& (style.getMetaData() instanceof Map || style.getMetaData() == null)) {
-			final AttributeMetadataMap sourceAmd = (AttributeMetadataMap) style.getMetaData();
+			final AttributeMetadataMap sourceAmd = (AttributeMetadataMap) style
+					.getMetaData();
 			final AttributeMetadataMap destAmd = ((StyledFeatureCollectionInterface) styledObject)
 					.getAttributeMetaDataMap();
 			if (destAmd != null && sourceAmd != null) {
@@ -675,53 +745,68 @@
 			return;
 		}
 
-		throw new UnsupportedOperationException("Style is not compatible to object: "
-				+ (style.getMetaData() == null ? null : style.getMetaData().getClass().getSimpleName()) + " <-> "
-				+ (styledObject == null ? null : styledObject.getClass().getSimpleName()));
+		throw new UnsupportedOperationException(
+				"Style is not compatible to object: "
+						+ (style.getMetaData() == null ? null : style
+								.getMetaData().getClass().getSimpleName())
+						+ " <-> "
+						+ (styledObject == null ? null : styledObject
+								.getClass().getSimpleName()));
 	}
 
 	/**
-	 * Returns the style a {@link StyledLayerInterface} as a {@link StyledLayerStyle}.
+	 * Returns the style a {@link StyledLayerInterface} as a
+	 * {@link StyledLayerStyle}.
 	 * 
 	 * @param styledObject
 	 *            a styled object
-	 * @return {@code StyledLayerStyle<RasterLegendData>} for {@link StyledGridCoverageInterface} or
-	 *         {@code StyledLayerStyle<Map<Integer,AttributeMetaData>>} for {@link StyledFeatureCollectionInterface}
+	 * @return {@code StyledLayerStyle<RasterLegendData>} for
+	 *         {@link StyledGridCoverageInterface} or
+	 *         {@code StyledLayerStyle<Map<Integer,AttributeMetaData>>} for
+	 *         {@link StyledFeatureCollectionInterface}
 	 */
-	public static StyledLayerStyle<?> getStyledLayerStyle(final StyledLayerInterface styledObject) {
+	public static StyledLayerStyle<?> getStyledLayerStyle(
+			final StyledLayerInterface styledObject) {
 		if (styledObject instanceof StyledGridCoverageInterface)
 			return getStyledLayerStyle((StyledGridCoverageInterface) styledObject);
 		if (styledObject instanceof StyledFeatureCollectionInterface)
 			return getStyledLayerStyle((StyledFeatureCollectionInterface) styledObject);
-		throw new UnsupportedOperationException("Unknown type of StyledLayerInterface: "
-				+ (styledObject == null ? null : styledObject.getClass().getSimpleName()));
+		throw new UnsupportedOperationException(
+				"Unknown type of StyledLayerInterface: "
+						+ (styledObject == null ? null : styledObject
+								.getClass().getSimpleName()));
 	}
 
 	/**
-	 * Returns the style and raster meta data of a {@link StyledGridCoverageInterface} as a {@link StyledLayerStyle}.
+	 * Returns the style and raster meta data of a
+	 * {@link StyledGridCoverageInterface} as a {@link StyledLayerStyle}.
 	 * 
 	 * @param styledGC
 	 *            a styled grid coverage
 	 */
-	public static StyledLayerStyle<RasterLegendData> getStyledLayerStyle(final StyledGridCoverageInterface styledGC) {
-		return new StyledLayerStyle<RasterLegendData>(styledGC.getStyle(), styledGC.getLegendMetaData());
+	public static StyledLayerStyle<RasterLegendData> getStyledLayerStyle(
+			final StyledGridCoverageInterface styledGC) {
+		return new StyledLayerStyle<RasterLegendData>(styledGC.getStyle(),
+				styledGC.getLegendMetaData());
 	}
 
 	/**
-	 * Returns the style and attribute meta data of a {@link StyledFeatureCollectionInterface} as a
-	 * {@link StyledLayerStyle}.
+	 * Returns the style and attribute meta data of a
+	 * {@link StyledFeatureCollectionInterface} as a {@link StyledLayerStyle}.
 	 * 
 	 * @param styledFC
 	 *            a styled feature collection
 	 */
 	public static StyledLayerStyle<AttributeMetadataMap> getStyledLayerStyle(
 			final StyledFeatureCollectionInterface styledFC) {
-		return new StyledLayerStyle<AttributeMetadataMap>(styledFC.getStyle(), styledFC.getAttributeMetaDataMap());
+		return new StyledLayerStyle<AttributeMetadataMap>(styledFC.getStyle(),
+				styledFC.getAttributeMetaDataMap());
 	}
 
 	/**
-	 * Loads a {@linkplain Style SLD-Style} and {@linkplain RasterLegendData Raster-LegendData} for a given geo-object
-	 * (raster) source. The SLD file must be present. A missing raster legend-data file is tolerated.
+	 * Loads a {@linkplain Style SLD-Style} and {@linkplain RasterLegendData
+	 * Raster-LegendData} for a given geo-object (raster) source. The SLD file
+	 * must be present. A missing raster legend-data file is tolerated.
 	 * 
 	 * @param geoObjectURL
 	 *            URL of the (already read) raster object
@@ -731,12 +816,13 @@
 	 *            file extention for the raster legend-data file
 	 * @return {@code null} in case of any error
 	 */
-	public static StyledLayerStyle<RasterLegendData> loadStyledRasterStyle(final URL geoObjectURL, final String sldExt,
-			final String rldExt) {
+	public static StyledLayerStyle<RasterLegendData> loadStyledRasterStyle(
+			final URL geoObjectURL, final String sldExt, final String rldExt) {
 		RasterLegendData metaData = null;
 		Style sldStyle = null;
 		try {
-			final Style[] styles = StylingUtil.loadSLD(IOUtil.changeUrlExt(geoObjectURL, sldExt));
+			final Style[] styles = StylingUtil.loadSLD(IOUtil.changeUrlExt(
+					geoObjectURL, sldExt));
 			// SLD must be present
 			if (styles == null || styles.length == 0)
 				return null;
@@ -748,7 +834,8 @@
 		}
 
 		try {
-			metaData = StyledLayerUtil.loadRasterLegendData(IOUtil.changeUrlExt(geoObjectURL, rldExt));
+			metaData = StyledLayerUtil.loadRasterLegendData(IOUtil
+					.changeUrlExt(geoObjectURL, rldExt));
 		} catch (final FileNotFoundException err) {
 			// ignore missing raster legend data
 		} catch (final Exception err) {
@@ -760,9 +847,10 @@
 	}
 
 	/**
-	 * Loads a {@linkplain Style SLD-Style} from a {@code .sld} file and {@linkplain RasterLegendData Raster-LegendData}
-	 * from a {@code .rld} file for a given geo-object (raster) source. The SLD file must be present. A missing raster
-	 * legend-data file is tolerated.
+	 * Loads a {@linkplain Style SLD-Style} from a {@code .sld} file and
+	 * {@linkplain RasterLegendData Raster-LegendData} from a {@code .rld} file
+	 * for a given geo-object (raster) source. The SLD file must be present. A
+	 * missing raster legend-data file is tolerated.
 	 * 
 	 * @param geoObjectURL
 	 *            URL of the (already read) raster object
@@ -772,13 +860,16 @@
 	 *            file extention for the raster legend-data file
 	 * @return {@code null} in case of any error
 	 */
-	public static StyledLayerStyle<RasterLegendData> loadStyledRasterStyle(final URL geoObjectURL) {
+	public static StyledLayerStyle<RasterLegendData> loadStyledRasterStyle(
+			final URL geoObjectURL) {
 		return loadStyledRasterStyle(geoObjectURL, "sld", "rld");
 	}
 
 	/**
-	 * Loads a {@linkplain Style SLD-Style} and a {@linkplain AttributeMetadataImpl AttributeMetaData-Map} for a given
-	 * geo-object (feature) source. The SLD file must be present. A missing attribute meta-data file is tolerated.
+	 * Loads a {@linkplain Style SLD-Style} and a
+	 * {@linkplain AttributeMetadataImpl AttributeMetaData-Map} for a given
+	 * geo-object (feature) source. The SLD file must be present. A missing
+	 * attribute meta-data file is tolerated.
 	 * 
 	 * @param geoObjectURL
 	 *            URL of the (already read) feature object
@@ -788,12 +879,13 @@
 	 *            file extention for the raster legend-data file
 	 * @return {@code null} in case of any error
 	 */
-	public static StyledLayerStyle<AttributeMetadataMap> loadStyledFeatureStyle(final URL geoObjectURL,
-			final String sldExt, final String rldExt) {
+	public static StyledLayerStyle<AttributeMetadataMap> loadStyledFeatureStyle(
+			final URL geoObjectURL, final String sldExt, final String rldExt) {
 		AttributeMetadataMap metaData = null;
 		Style sldStyle = null;
 		try {
-			final Style[] styles = StylingUtil.loadSLD(IOUtil.changeUrlExt(geoObjectURL, sldExt));
+			final Style[] styles = StylingUtil.loadSLD(IOUtil.changeUrlExt(
+					geoObjectURL, sldExt));
 			// SLD must be present
 			if (styles == null || styles.length == 0)
 				return null;
@@ -805,7 +897,8 @@
 		}
 
 		try {
-			metaData = StyledLayerUtil.loadAttributeMetaDataMap(IOUtil.changeUrlExt(geoObjectURL, rldExt));
+			metaData = StyledLayerUtil.loadAttributeMetaDataMap(IOUtil
+					.changeUrlExt(geoObjectURL, rldExt));
 		} catch (final FileNotFoundException err) {
 			// ignore missing attribute meta data
 		} catch (final Exception err) {
@@ -818,9 +911,10 @@
 	}
 
 	/**
-	 * Loads a {@linkplain Style SLD-Style} from a {@code .sld} file and {@linkplain AttributeMetadataImpl
-	 * AttributeMetaData-Map} from a {@code .amd} file for a given geo-object (feature) source. The SLD file must be
-	 * present. A missing attribute meta-data file is tolerated.
+	 * Loads a {@linkplain Style SLD-Style} from a {@code .sld} file and
+	 * {@linkplain AttributeMetadataImpl AttributeMetaData-Map} from a
+	 * {@code .amd} file for a given geo-object (feature) source. The SLD file
+	 * must be present. A missing attribute meta-data file is tolerated.
 	 * 
 	 * @param geoObjectURL
 	 *            URL of the (already read) feature object
@@ -830,13 +924,14 @@
 	 *            file extention for the raster legend-data file
 	 * @return {@code null} in case of any error
 	 */
-	public static StyledLayerStyle<AttributeMetadataMap> loadStyledFeatureStyle(final URL geoObjectURL) {
+	public static StyledLayerStyle<AttributeMetadataMap> loadStyledFeatureStyle(
+			final URL geoObjectURL) {
 		return loadStyledFeatureStyle(geoObjectURL, "sld", "amd");
 	}
 
 	/**
-	 * Stores a {@linkplain Style SLD-Style} and {@linkplain RasterLegendData Raster-LegendData} for a given geo-object
-	 * (raster) source.
+	 * Stores a {@linkplain Style SLD-Style} and {@linkplain RasterLegendData
+	 * Raster-LegendData} for a given geo-object (raster) source.
 	 * 
 	 * @param style
 	 *            style to save
@@ -847,40 +942,47 @@
 	 * @param mdExt
 	 *            file extention for the meta-data file
 	 */
-	public static <T> void saveStyledLayerStyle(final StyledLayerStyle<T> style, final URL geoObjectURL,
+	public static <T> void saveStyledLayerStyle(
+			final StyledLayerStyle<T> style, final URL geoObjectURL,
 			final String sldExt, final String mdExt) throws Exception {
 		// Store the SLD
 		final Style sldStyle = style.getGeoObjectStyle();
 		if (sldStyle != null) {
-			StylingUtil.saveStyleToSld(sldStyle, IOUtil.changeFileExt(new File(geoObjectURL.toURI()), sldExt));
+			StylingUtil.saveStyleToSld(sldStyle, IOUtil.changeFileExt(new File(
+					geoObjectURL.toURI()), sldExt));
 		}
 
 		// Store the meta data
 		final T metaData = style.getMetaData();
 		if (metaData != null) {
 			if (metaData instanceof RasterLegendData) {
-				saveRasterLegendData((RasterLegendData) metaData, IOUtil.changeUrlExt(geoObjectURL, mdExt));
+				saveRasterLegendData((RasterLegendData) metaData,
+						IOUtil.changeUrlExt(geoObjectURL, mdExt));
 				// } else if ( metaData instanceof
 				// Map<Integer,AttributeMetaData> ) { // LEIDER NICHT
 				// KOMPILIERBAR!!
 			} else if (metaData instanceof Map) {
-				saveAttributeMetaDataMap((AttributeMetadataMap) metaData, IOUtil.changeUrlExt(geoObjectURL, mdExt));
+				saveAttributeMetaDataMap((AttributeMetadataMap) metaData,
+						IOUtil.changeUrlExt(geoObjectURL, mdExt));
 			} else
-				throw new UnsupportedOperationException("Export for meta data not yet supported: "
-						+ metaData.getClass().getSimpleName());
+				throw new UnsupportedOperationException(
+						"Export for meta data not yet supported: "
+								+ metaData.getClass().getSimpleName());
 		}
 	}
 
 	/**
-	 * Stores the {@linkplain Style SLD-Style} to a {@code .sld} file and the meta data ({@link RasterLegendData} or
-	 * {@link AttributeMetadataImpl}) to a {@code .rld} or {@code .amd} file. for a given geo-object source.
+	 * Stores the {@linkplain Style SLD-Style} to a {@code .sld} file and the
+	 * meta data ({@link RasterLegendData} or {@link AttributeMetadataImpl}) to
+	 * a {@code .rld} or {@code .amd} file. for a given geo-object source.
 	 * 
 	 * @param style
 	 *            style to save
 	 * @param geoObjectURL
 	 *            URL of the (already read) raster object
 	 */
-	public static void saveStyledLayerStyle(final StyledLayerStyle<?> style, final URL geoObjectURL) throws Exception {
+	public static void saveStyledLayerStyle(final StyledLayerStyle<?> style,
+			final URL geoObjectURL) throws Exception {
 		if (style.getMetaData() instanceof RasterLegendData)
 			saveStyledLayerStyle(style, geoObjectURL, "sld", "rld");
 		else
@@ -888,23 +990,26 @@
 	}
 
 	/**
-	 * Creates a {@link JPanel} that shows a legend for a list of {@link FeatureTypeStyle}s and a targeted featureType
+	 * Creates a {@link JPanel} that shows a legend for a list of
+	 * {@link FeatureTypeStyle}s and a targeted featureType
 	 * 
 	 * @param style
 	 *            The Style to presented in this legend
 	 * @param featureType
 	 *            If this a legend for Point, Polygon or Line? Or ANY or NONE?
 	 * @param scaleDenominator
-	 *            <code>null</code> of a Scale Denominator to determine whether a Rule is actually visible in that
-	 *            scale.
+	 *            <code>null</code> of a Scale Denominator to determine whether
+	 *            a Rule is actually visible in that scale.
 	 * 
 	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
-	public static JPanel createLegendSwingPanel(Style style, final SimpleFeatureType featureType, final int iconWidth,
+	public static JPanel createLegendSwingPanel(Style style,
+			final SimpleFeatureType featureType, final int iconWidth,
 			final int iconHeight, Double scaleDenominator) {
 
 		if (featureType == null) {
-			ExceptionDialog.show(new IllegalStateException("featureType is null!"));
+			ExceptionDialog.show(new IllegalStateException(
+					"featureType is null!"));
 			return new JPanel();
 		}
 
@@ -930,16 +1035,23 @@
 			for (final Rule rule : rules) {
 
 				/*
-				 * The MinScaleDenominator and MaxScaleDenominator elements of a Rule define the range of map-rendering
-				 * scales for which the rule should be applied. The schema is: <xsd:element name="MinScaleDenominator"
-				 * type="xsd:double"/> <xsd:element name="MaxScaleDenominator" type="xsd:double"/> The values used are
-				 * actually the scale denominators relative to a “standardized rendering pixel size” (below). For
-				 * example, an element-content value of “10000000” means a scale of 1:10-million. Scientific notation is
-				 * also allowed here (and for all non-integer numbers in SE), so a more convenient value of “10e6” could
-				 * also be used for the element content for this example. The MinScaleDenominator and
-				 * MaxScaleDenominator elements, as their names suggest, are simply the minimum and maximum ranges of
-				 * scale (denominators) of maps for which a rule should apply. The minimum scale is inclusive and the
-				 * maximum scale is exclusive. So, for example, the following scale range:
+				 * The MinScaleDenominator and MaxScaleDenominator elements of a
+				 * Rule define the range of map-rendering scales for which the
+				 * rule should be applied. The schema is: <xsd:element
+				 * name="MinScaleDenominator" type="xsd:double"/> <xsd:element
+				 * name="MaxScaleDenominator" type="xsd:double"/> The values
+				 * used are actually the scale denominators relative to a
+				 * “standardized rendering pixel size” (below). For example, an
+				 * element-content value of “10000000” means a scale of
+				 * 1:10-million. Scientific notation is also allowed here (and
+				 * for all non-integer numbers in SE), so a more convenient
+				 * value of “10e6” could also be used for the element content
+				 * for this example. The MinScaleDenominator and
+				 * MaxScaleDenominator elements, as their names suggest, are
+				 * simply the minimum and maximum ranges of scale (denominators)
+				 * of maps for which a rule should apply. The minimum scale is
+				 * inclusive and the maximum scale is exclusive. So, for
+				 * example, the following scale range:
 				 */
 				if (scaleDenominator != null && scaleDenominator != 0.0
 						&& scaleDenominator < rule.getMinScaleDenominator())
@@ -949,17 +1061,21 @@
 					continue;
 
 				// Check if this RULE shall actually appear in the legend
-				if (rule.getName() != null && rule.getName().contains(HIDE_IN_LAYER_LEGEND_HINT))
+				if (rule.getName() != null
+						&& rule.getName().contains(HIDE_IN_LAYER_LEGEND_HINT))
 					continue;
 
 				/**
-				 * Let's not create a hbox for Rules that only contain TextSymbolizers
+				 * Let's not create a hbox for Rules that only contain
+				 * TextSymbolizers
 				 */
-				if (StylingUtil.getTextSymbolizers(rule.getSymbolizers()).size() == rule.getSymbolizers().length)
+				if (StylingUtil.getTextSymbolizers(rule.getSymbolizers())
+						.size() == rule.getSymbolizers().length)
 					continue;
 
-				final BufferedImage imageForRule = LegendIconFeatureRenderer.getInstance().createImageForRule(rule,
-						featureType, new Dimension(iconWidth, iconHeight));
+				final BufferedImage imageForRule = LegendIconFeatureRenderer
+						.getInstance().createImageForRule(rule, featureType,
+								new Dimension(iconWidth, iconHeight));
 
 				final ImageIcon legendIcon = new ImageIcon(imageForRule);
 
@@ -970,7 +1086,8 @@
 				// hbox.add(Box.createHorizontalStrut(3));
 
 				final Translation labelT = new Translation();
-				labelT.fromOneLine(GTUtil.descriptionTitle(rule.getDescription()));
+				labelT.fromOneLine(GTUtil.descriptionTitle(rule
+						.getDescription()));
 				final JLabel classTitleLabel = new JLabel(labelT.toString());
 
 				panel.add(classTitleLabel, "sgx2");
@@ -982,42 +1099,134 @@
 	}
 
 	/**
-	 * Creates a {@link JComponent} that contains a legend for a given {@link StyledRasterInterface} and a given
-	 * {@link Style}.
+	 * Creates a {@link JComponent} that contains a legend for a given
+	 * {@link StyledRasterInterface} and a given {@link Style}.
 	 * 
 	 * @param style
-	 *            if <code>null</code>, the default {@link Style} is extracetd from the {@link StyledRasterInterface}
+	 *            if <code>null</code>, the default {@link Style} is extracetd
+	 *            from the {@link StyledRasterInterface}
 	 * @param scaleDenominator
-	 *            <code>null</code> of a Scale Denominator to determine whether a Rule is actually visible in that
-	 *            scale.
+	 *            <code>null</code> of a Scale Denominator to determine whether
+	 *            a Rule is actually visible in that scale.
 	 */
-	public static JPanel createLegendSwingPanel(final StyledRasterInterface<?> styledRaster, Style style,
+	public static JPanel createLegendSwingPanel(
+			final StyledRasterInterface<?> styledRaster, Style style,
 			final int iconWidth, final int iconHeight, Double scaleDenominator) {
 
 		// If no style is given, we use the default style for this layer
 		if (style == null)
 			style = styledRaster.getStyle();
 
+		final JPanel panel = new JPanel(new MigLayout("wrap 2, gapy 0"));
+
+		// Schleife über alle Rules, auch wenn Sie aus mehreren FTS kommen:
+
+		StylingUtil.DUPLICATINGSTYLEVISITOR.visit(style);
+		style = (Style)StylingUtil.DUPLICATINGSTYLEVISITOR.getCopy();
+		List<FeatureTypeStyle> fts = new ArrayList<FeatureTypeStyle>( style.featureTypeStyles());
+		Collections.reverse(fts);
+		style.featureTypeStyles().clear();
+		style.featureTypeStyles().addAll(fts);
+		
+		style = StylingUtil.optimizeStyle(style);
+
+		fts = style.featureTypeStyles();
+		if (fts.size() == 0)
+			return panel;
+		
+
+		for (Rule r : fts.get(0).rules()) {
+
+			for (Symbolizer s : r.getSymbolizers()) {
+				if (!(s instanceof RasterSymbolizer))
+					continue;
+				RasterSymbolizer rs = (RasterSymbolizer) s;
+
+				if (rs.getColorMap() != null) {
+					// Ein Colormap Symbolizer
+					addRasterLegendEntries_ColorMap(panel, rs, styledRaster,
+							iconWidth, iconHeight);
+				}
+
+				if (rs.getChannelSelection() != null
+						&& rs.getChannelSelection().getRGBChannels() != null
+						&& rs.getChannelSelection().getRGBChannels().length == 3) {
+					// Ein RGB Symbolizer
+
+					// RED:
+					if (rs.getChannelSelection().getRGBChannels()[0] != null) {
+
+						final JLabel redIconLabel = new JLabel("RED");
+						panel.add(redIconLabel, "sgx1");
+						final JLabel redTitleLabel = new JLabel(
+								rs.getChannelSelection().getRGBChannels()[0]
+										.getChannelName());
+						panel.add(redTitleLabel, "sgx2");
+						redTitleLabel.setLabelFor(redIconLabel);
+					}
+
+					// GREEN:
+					if (rs.getChannelSelection().getRGBChannels()[1] != null) {
+						final JLabel greenIconLabel = new JLabel("GREEN");
+						panel.add(greenIconLabel, "sgx1");
+						final JLabel greenTitleLabel = new JLabel(
+								rs.getChannelSelection().getRGBChannels()[1]
+										.getChannelName());
+						panel.add(greenTitleLabel, "sgx2");
+						greenTitleLabel.setLabelFor(greenIconLabel);
+					}
+
+					// BLUE:
+					if (rs.getChannelSelection().getRGBChannels()[2] != null) {
+						final JLabel blueIconLabel = new JLabel("BLUE");
+						panel.add(blueIconLabel, "sgx1");
+						final JLabel blueTitleLabel = new JLabel(
+								rs.getChannelSelection().getRGBChannels()[2]
+										.getChannelName());
+						panel.add(blueTitleLabel, "sgx2");
+						blueTitleLabel.setLabelFor(blueIconLabel);
+					}
+
+				}
+
+			}
+		}
+
+		//
+
+		return panel;
+	}
+
+	/**
+	 * Adds "Rows" to the given Panel corresponding to the colormap
+	 * 
+	 * @param panel
+	 * @param rs
+	 * @param styledRaster
+	 * @param iconWidth
+	 * @param iconHeight
+	 */
+	private static void addRasterLegendEntries_ColorMap(JPanel panel,
+			RasterSymbolizer rs, StyledRasterInterface<?> styledRaster,
+			final int iconWidth, final int iconHeight) {
+
+		ColorMap colormap = rs.getColorMap();
+
 		/**
 		 * Determine whether a Style is responsible for the coloring
 		 */
 		ColorModel colorModel = null;
-		if (!isStyleable(styledRaster) || (isStyleable(styledRaster) && style == null)) {
+		if (!isStyleable(styledRaster)) {
 			colorModel = getColorModel(styledRaster);
 		}
-		
-		RasterLegendData rasterLegendData = styledRaster.getLegendMetaData();
-		try {
-			rasterLegendData = generateRasterLegendData(style, false, null);
-		} catch (Exception e) {
-			// Keine Colormap?
-			return new JPanel();
-		}
 
-		final List<Double> legendRasterValues = rasterLegendData.getSortedKeys();
-		final Map<Double, GridCoverage2D> sampleRasters = rasterLegendData.createSampleRasters();
+		RasterLegendData rasterLegendData = generateRasterLegendData(colormap,
+				colormap.getType() == ColorMap.TYPE_VALUES ? true : false, null);
 
-		final JPanel panel = new JPanel(new MigLayout("wrap 2, gapy 0"));
+		final List<Double> legendRasterValues = rasterLegendData
+				.getSortedKeys();
+		final Map<Double, GridCoverage2D> sampleRasters = rasterLegendData
+				.createSampleRasters();
 
 		for (Double rValue : legendRasterValues) {
 
@@ -1038,7 +1247,8 @@
 			// ****************************************************************************
 			// Create the actual icon
 			// ****************************************************************************
-			final BufferedImage buffImage = new BufferedImage(iconWidth, iconHeight, BufferedImage.TYPE_INT_ARGB);
+			final BufferedImage buffImage = new BufferedImage(iconWidth,
+					iconHeight, BufferedImage.TYPE_INT_ARGB);
 
 			final Graphics2D graphics = buffImage.createGraphics();
 
@@ -1074,7 +1284,8 @@
 					graphics.setColor(color);
 					graphics.fillRect(0, 0, iconWidth, iconHeight);
 				} catch (final Exception e) {
-					LOGGER.info("Dann nehmen wir halt den GridCoverageRenderer", e);
+					LOGGER.info(
+							"Dann nehmen wir halt den GridCoverageRenderer", e);
 					colorModel = null;
 				}
 			} else {
@@ -1088,33 +1299,36 @@
 				final GridCoverage2D sampleCov = sampleRasters.get(rValue);
 				GridCoverageRenderer renderer;
 				try {
-					renderer = new GridCoverageRenderer(sampleCov.getCoordinateReferenceSystem(),
-							JTSUtil.createEnvelope(sampleCov.getEnvelope()), new Rectangle(iconWidth, iconHeight),
+					renderer = new GridCoverageRenderer(
+							sampleCov.getCoordinateReferenceSystem(),
+							JTSUtil.createEnvelope(sampleCov.getEnvelope()),
+							new Rectangle(iconWidth, iconHeight),
 							(AffineTransform) null);
 				} catch (final Exception e1) {
-					throw new RuntimeException("Creating a GridCoverageRenderer failed:", e1);
+					throw new RuntimeException(
+							"Creating a GridCoverageRenderer failed:", e1);
 				}
 
 				/**
 				 * Iterate over all FeatureTypeStyles.
 				 */
-				final List<RasterSymbolizer> rSymbols = StylingUtil.getRasterSymbolizers(style);
+				try {
 
-				for (final RasterSymbolizer symbolizer : rSymbols) {
-					try {
+					// Wenn ein RasterSymbolizer so konfiguriert ist, dass
+					// er nur ein spezielles Band von mehreren darstellt,
+					// dann muss diese ChannelSelectino hier aufgehoiben
+					// werden, da die samleConverages nur ein Band haben.
+					rs.setChannelSelection(StylingUtil.STYLE_FACTORY
+							.createChannelSelection(new SelectedChannelType[] { StylingUtil.STYLE_FACTORY
+									.createSelectedChannelType(
+											"1",
+											StylingUtil.STYLE_FACTORY
+													.createContrastEnhancement()) }));
 
-						// Wenn ein RasterSymbolizer so konfiguriert ist, dass
-						// er nur ein spezielles Band von mehreren darstellt,
-						// dann muss diese ChannelSelectino hier aufgehoiben
-						// werden, da die samleConverages nur ein Band haben.
-						symbolizer.setChannelSelection(StylingUtil.STYLE_FACTORY
-								.createChannelSelection(new SelectedChannelType[] { StylingUtil.STYLE_FACTORY
-										.createSelectedChannelType("1", (ContrastEnhancement) null) }));
-
-						renderer.paint(graphics, sampleCov, symbolizer);
-					} catch (final Exception ee) {
-						LOGGER.error("Unable to paint " + symbolizer + " into the legend image", ee);
-					}
+					renderer.paint(graphics, sampleCov, rs);
+				} catch (final Exception ee) {
+					LOGGER.error("Unable to paint " + rs
+							+ " into the legend image", ee);
 				}
 			}
 
@@ -1122,26 +1336,28 @@
 			panel.add(iconLabel, "sgx1");
 
 			final JLabel classTitleLabel = new JLabel(labelT.toString());
-			panel.add(classTitleLabel, "sgx2" + (rasterLegendData.isPaintGaps() ? ", gapy 0:0:0 5:5:5" : ""));
+			panel.add(classTitleLabel, "sgx2"
+					+ (rasterLegendData.isPaintGaps() ? ", gapy 0:0:0 5:5:5"
+							: ""));
 			classTitleLabel.setLabelFor(iconLabel);
 
 			if (rasterLegendData.isPaintGaps()) {
-				iconLabel.setBorder(BorderFactory.createLineBorder(Color.black));
+				iconLabel
+						.setBorder(BorderFactory.createLineBorder(Color.black));
 			}
-
 		}
-
-		return panel;
 	}
 
 	/**
-	 * Creates a {@link JComponent} that contains a legend for a given {@link StyledRasterInterface} and a given
-	 * {@link Style}.
+	 * Creates a {@link JComponent} that contains a legend for a given
+	 * {@link StyledRasterInterface} and a given {@link Style}.
 	 * 
 	 * @param style
-	 *            if <code>null</code>, the default {@link Style} is extracetd from the {@link StyledRasterInterface}
+	 *            if <code>null</code>, the default {@link Style} is extracetd
+	 *            from the {@link StyledRasterInterface}
 	 */
-	public static JPanel OLDcreateLegendSwingPanel(final StyledRasterInterface<?> styledRaster, Style style,
+	public static JPanel OLDcreateLegendSwingPanel(
+			final StyledRasterInterface<?> styledRaster, Style style,
 			final int iconWidth, final int iconHeight) {
 
 		// If no style is given, we use the default style for this layer
@@ -1152,13 +1368,17 @@
 		 * Determine whether a Style is responsible for the coloring
 		 */
 		ColorModel colorModel = null;
-		if (!isStyleable(styledRaster) || (isStyleable(styledRaster) && style == null)) {
+		if (!isStyleable(styledRaster)
+				|| (isStyleable(styledRaster) && style == null)) {
 			colorModel = getColorModel(styledRaster);
 		}
 
-		final RasterLegendData rasterLegendData = styledRaster.getLegendMetaData();
-		final List<Double> legendRasterValues = rasterLegendData.getSortedKeys();
-		final Map<Double, GridCoverage2D> sampleRasters = rasterLegendData.createSampleRasters();
+		final RasterLegendData rasterLegendData = styledRaster
+				.getLegendMetaData();
+		final List<Double> legendRasterValues = rasterLegendData
+				.getSortedKeys();
+		final Map<Double, GridCoverage2D> sampleRasters = rasterLegendData
+				.createSampleRasters();
 
 		final JPanel panel = new JPanel(new MigLayout("wrap 2, gapy 0"));
 
@@ -1179,7 +1399,8 @@
 			// ****************************************************************************
 			// Create the actual icon
 			// ****************************************************************************
-			final BufferedImage buffImage = new BufferedImage(iconWidth, iconHeight, BufferedImage.TYPE_INT_ARGB);
+			final BufferedImage buffImage = new BufferedImage(iconWidth,
+					iconHeight, BufferedImage.TYPE_INT_ARGB);
 
 			final Graphics2D graphics = buffImage.createGraphics();
 
@@ -1215,7 +1436,8 @@
 					graphics.setColor(color);
 					graphics.fillRect(0, 0, iconWidth, iconHeight);
 				} catch (final Exception e) {
-					LOGGER.info("Dann nehmen wir halt den GridCoverageRenderer", e);
+					LOGGER.info(
+							"Dann nehmen wir halt den GridCoverageRenderer", e);
 					colorModel = null;
 				}
 			} else {
@@ -1229,23 +1451,28 @@
 				final GridCoverage2D sampleCov = sampleRasters.get(rValue);
 				GridCoverageRenderer renderer;
 				try {
-					renderer = new GridCoverageRenderer(sampleCov.getCoordinateReferenceSystem(),
-							JTSUtil.createEnvelope(sampleCov.getEnvelope()), new Rectangle(iconWidth, iconHeight),
+					renderer = new GridCoverageRenderer(
+							sampleCov.getCoordinateReferenceSystem(),
+							JTSUtil.createEnvelope(sampleCov.getEnvelope()),
+							new Rectangle(iconWidth, iconHeight),
 							(AffineTransform) null);
 				} catch (final Exception e1) {
-					throw new RuntimeException("Creating a GridCoverageRenderer failed:", e1);
+					throw new RuntimeException(
+							"Creating a GridCoverageRenderer failed:", e1);
 				}
 
 				/**
 				 * Iterate over all FeatureTypeStyles.
 				 */
-				final List<RasterSymbolizer> rSymbols = StylingUtil.getRasterSymbolizers(style);
+				final List<RasterSymbolizer> rSymbols = StylingUtil
+						.getRasterSymbolizers(style);
 
 				for (final RasterSymbolizer symbolizer : rSymbols) {
 					try {
 						renderer.paint(graphics, sampleCov, symbolizer);
 					} catch (final Exception ee) {
-						LOGGER.error("Unable to paint " + symbolizer + " into the legend image", ee);
+						LOGGER.error("Unable to paint " + symbolizer
+								+ " into the legend image", ee);
 					}
 				}
 			}
@@ -1254,11 +1481,14 @@
 			panel.add(iconLabel, "sgx1");
 
 			final JLabel classTitleLabel = new JLabel(labelT.toString());
-			panel.add(classTitleLabel, "sgx2" + (rasterLegendData.isPaintGaps() ? ", gapy 0:0:0 5:5:5" : ""));
+			panel.add(classTitleLabel, "sgx2"
+					+ (rasterLegendData.isPaintGaps() ? ", gapy 0:0:0 5:5:5"
+							: ""));
 			classTitleLabel.setLabelFor(iconLabel);
 
 			if (rasterLegendData.isPaintGaps()) {
-				iconLabel.setBorder(BorderFactory.createLineBorder(Color.black));
+				iconLabel
+						.setBorder(BorderFactory.createLineBorder(Color.black));
 			}
 
 		}
@@ -1267,11 +1497,12 @@
 	}
 
 	/**
-	 * Extracts the {@link ColorModel} of any {@link StyledRasterInterface}. May return <code>null</code> if the
-	 * geoobject can not be accessed.
+	 * Extracts the {@link ColorModel} of any {@link StyledRasterInterface}. May
+	 * return <code>null</code> if the geoobject can not be accessed.
 	 */
 	@SuppressWarnings("unchecked")
-	public static ColorModel getColorModel(final StyledRasterInterface<?> styledGrid) {
+	public static ColorModel getColorModel(
+			final StyledRasterInterface<?> styledGrid) {
 		ColorModel colorModel = null;
 		try {
 			final Object geoObject = styledGrid.getGeoObject();
@@ -1280,18 +1511,21 @@
 				colorModel = cov.getRenderedImage().getColorModel();
 			} else if (styledGrid instanceof StyledGridCoverageReaderInterface) {
 
-				final Parameter readGG = new Parameter(AbstractGridFormat.READ_GRIDGEOMETRY2D);
+				final Parameter readGG = new Parameter(
+						AbstractGridFormat.READ_GRIDGEOMETRY2D);
 
-				final ReferencedEnvelope mapExtend = new ReferencedEnvelope(styledGrid.getEnvelope(),
-						styledGrid.getCrs());
+				final ReferencedEnvelope mapExtend = new ReferencedEnvelope(
+						styledGrid.getEnvelope(), styledGrid.getCrs());
 
-				readGG.setValue(new GridGeometry2D(new GeneralGridEnvelope(new Rectangle(0, 0, 1, 1)), mapExtend));
+				readGG.setValue(new GridGeometry2D(new GeneralGridEnvelope(
+						new Rectangle(0, 0, 1, 1)), mapExtend));
 
 				AbstractGridCoverage2DReader aReader;
 				if (geoObject instanceof FeatureCollection) {
 					final FeatureCollection<SimpleFeatureType, SimpleFeature> rFc = (FeatureCollection<SimpleFeatureType, SimpleFeature>) geoObject;
 
-					aReader = (AbstractGridCoverage2DReader) FeatureUtil.getWrappedGeoObject(rFc);
+					aReader = (AbstractGridCoverage2DReader) FeatureUtil
+							.getWrappedGeoObject(rFc);
 
 				} else if (geoObject instanceof AbstractGridCoverage2DReader) {
 					aReader = (AbstractGridCoverage2DReader) geoObject;
@@ -1300,7 +1534,8 @@
 					throw new RuntimeException("need a reader...");
 				//
 
-				final GridCoverage2D cov = aReader.read(new GeneralParameterValue[] { readGG });
+				final GridCoverage2D cov = aReader
+						.read(new GeneralParameterValue[] { readGG });
 				colorModel = cov.getRenderedImage().getColorModel();
 			}
 		} catch (final Exception e) {
@@ -1311,11 +1546,13 @@
 	}
 
 	/**
-	 * @return <code>true</code> if a {@link RasterSymbolizer} can be applied and will have an effect. Some rasters
-	 *         (e.g. GeoTIFF) can come with their own {@link ColorModel} and will ignore any {@link RasterSymbolizer} =
-	 *         SLD.
+	 * @return <code>true</code> if a {@link RasterSymbolizer} can be applied
+	 *         and will have an effect. Some rasters (e.g. GeoTIFF) can come
+	 *         with their own {@link ColorModel} and will ignore any
+	 *         {@link RasterSymbolizer} = SLD.
 	 */
-	public static boolean isStyleable(final StyledRasterInterface<?> styledRaster) {
+	public static boolean isStyleable(
+			final StyledRasterInterface<?> styledRaster) {
 		final ColorModel colorModel = getColorModel(styledRaster);
 
 		// LOGGER.info("The colormodel of " + styledRaster.getTitle() + " is "
@@ -1333,26 +1570,34 @@
 	}
 
 	/**
-	 * Set the given Style as the Style of the {@link MapLayer}, unless the styles are the same (not comparing selection
-	 * stuff). If the {@link MapLayer}s {@link Style} is changed, the selection FTS is kept.<br/>
-	 * Remember {@link MapLayer#setStyle(Style)} triggers an event leading to a repaint, so only use it when needed.
+	 * Set the given Style as the Style of the {@link MapLayer}, unless the
+	 * styles are the same (not comparing selection stuff). If the
+	 * {@link MapLayer}s {@link Style} is changed, the selection FTS is kept.<br/>
+	 * Remember {@link MapLayer#setStyle(Style)} triggers an event leading to a
+	 * repaint, so only use it when needed.
 	 * 
-	 * @return <code>true</code> if the {@link MapLayer}'s {@link Style} has been changed.
+	 * @return <code>true</code> if the {@link MapLayer}'s {@link Style} has
+	 *         been changed.
 	 */
-	public static boolean updateMapLayerStyleIfChangedAndKeepSelection(MapLayer mapLayer, Style style2) {
+	public static boolean updateMapLayerStyleIfChangedAndKeepSelection(
+			MapLayer mapLayer, Style style2) {
 
-		Style mapLayerStyleCleaned = StylingUtil.removeSelectionFeatureTypeStyle(mapLayer.getStyle());
+		Style mapLayerStyleCleaned = StylingUtil
+				.removeSelectionFeatureTypeStyle(mapLayer.getStyle());
 
-		Style newStyleCleaned = StylingUtil.removeSelectionFeatureTypeStyle(style2);
+		Style newStyleCleaned = StylingUtil
+				.removeSelectionFeatureTypeStyle(style2);
 
 		if (StylingUtil.isStyleDifferent(mapLayerStyleCleaned, newStyleCleaned)) {
 
 			// They are different when compared without SELECTION FTS!
 
 			// Now let's copy any SELECTION FTS to the now style
-			FeatureTypeStyle selectionFeatureTypeStyle = StylingUtil.getSelectionFeatureTypeStyle(mapLayer.getStyle());
+			FeatureTypeStyle selectionFeatureTypeStyle = StylingUtil
+					.getSelectionFeatureTypeStyle(mapLayer.getStyle());
 			if (selectionFeatureTypeStyle != null) {
-				newStyleCleaned.featureTypeStyles().add(selectionFeatureTypeStyle);
+				newStyleCleaned.featureTypeStyles().add(
+						selectionFeatureTypeStyle);
 				// newStyleCleaned is not so clean anymore... We just alled a
 				// selcetion FTS
 			}
@@ -1367,15 +1612,18 @@
 	}
 
 	/**
-	 * After loading an atlas, the AttribteMetaData contains whatever is written in the XML. But the DBF may have
-	 * changed! This method checks an {@link AttributeMetadataMap} against a schema and also corrects
-	 * upperCase/lowerCase problems. It will also remove any geometry column attribute metadata.
+	 * After loading an atlas, the AttribteMetaData contains whatever is written
+	 * in the XML. But the DBF may have changed! This method checks an
+	 * {@link AttributeMetadataMap} against a schema and also corrects
+	 * upperCase/lowerCase problems. It will also remove any geometry column
+	 * attribute metadata.
 	 */
 	/**
-	 * After loading an atlas, the AttribteMetaData contains whatever is written in the XML. But the DBF may have
-	 * changed!
+	 * After loading an atlas, the AttribteMetaData contains whatever is written
+	 * in the XML. But the DBF may have changed!
 	 */
-	public static void checkAttribMetaData(AttributeMetadataMap<AttributeMetadataImpl> attributeMetaDataMap,
+	public static void checkAttribMetaData(
+			AttributeMetadataMap<AttributeMetadataImpl> attributeMetaDataMap,
 			SimpleFeatureType schema) {
 
 		if (schema == null)
@@ -1388,9 +1636,11 @@
 
 		for (AttributeMetadataInterface atm : attributeMetaDataMap.values()) {
 
-			AttributeDescriptor foundDescr = schema.getDescriptor(atm.getName());
+			AttributeDescriptor foundDescr = schema
+					.getDescriptor(atm.getName());
 			if (foundDescr == null) {
-				NameImpl bestMatch = FeatureUtil.findBestMatchingAttribute(schema, atm.getLocalName());
+				NameImpl bestMatch = FeatureUtil.findBestMatchingAttribute(
+						schema, atm.getLocalName());
 				if (bestMatch == null)
 					willRemove.add(atm.getName());
 				else
@@ -1413,33 +1663,39 @@
 			if (ad instanceof GeometryDescriptor)
 				continue;
 			if (!attributeMetaDataMap.containsKey(ad.getName())) {
-				attributeMetaDataMap.put(new NameImpl(ad.getName().getNamespaceURI(), ad.getName().getLocalPart()),
-						new AttributeMetadataImpl(ad, schema.getAttributeDescriptors().indexOf(ad),
+				attributeMetaDataMap.put(new NameImpl(ad.getName()
+						.getNamespaceURI(), ad.getName().getLocalPart()),
+						new AttributeMetadataImpl(ad, schema
+								.getAttributeDescriptors().indexOf(ad),
 								attributeMetaDataMap.getLanguages()));
 			}
 		}
 	}
 
 	/**
-	 * Checks every attribute name in the {@link AttributeMetadataMap} for its binding type. It the type is textual, add
-	 * the mrpty string as a NODATA value.
+	 * Checks every attribute name in the {@link AttributeMetadataMap} for its
+	 * binding type. It the type is textual, add the mrpty string as a NODATA
+	 * value.
 	 * 
 	 * @param attributeMetaDataMap
 	 * @param schema
 	 */
 	public static void addEmptyStringToAllTextualAttributes(
-			AttributeMetadataMap<? extends AttributeMetadataInterface> attributeMetaDataMap, SimpleFeatureType schema) {
+			AttributeMetadataMap<? extends AttributeMetadataInterface> attributeMetaDataMap,
+			SimpleFeatureType schema) {
 
 		for (Name name : attributeMetaDataMap.keySet()) {
-			if (String.class.isAssignableFrom(schema.getDescriptor(name).getType().getBinding())) {
+			if (String.class.isAssignableFrom(schema.getDescriptor(name)
+					.getType().getBinding())) {
 				attributeMetaDataMap.get(name).getNodataValues().add("");
 			}
 		}
 	}
 
 	/**
-	 * @return a nicely formatted String containing all NODATA values of any {@link AttributeMetadataInterface} object.
-	 *         Strings are quoted so that any empty {@link String} can be seen.
+	 * @return a nicely formatted String containing all NODATA values of any
+	 *         {@link AttributeMetadataInterface} object. Strings are quoted so
+	 *         that any empty {@link String} can be seen.
 	 */
 	public static String formatNoDataValues(Set<Object> nodataValuesList) {
 		String nicelyFormatted = "";
@@ -1456,17 +1712,20 @@
 					nicelyFormatted += ",";
 				}
 				// Remove the extra comma
-				nicelyFormatted = nicelyFormatted.substring(0, nicelyFormatted.length() - 1);
+				nicelyFormatted = nicelyFormatted.substring(0,
+						nicelyFormatted.length() - 1);
 			}
 		}
 		return nicelyFormatted;
 	}
 
 	/**
-	 * Creates a new {@link AttributeMetadataMap} with instances of {@link AttributeMetadataInterface} for every
-	 * non-geometry attribute. Default NODATA values (like "" for String) are set.
+	 * Creates a new {@link AttributeMetadataMap} with instances of
+	 * {@link AttributeMetadataInterface} for every non-geometry attribute.
+	 * Default NODATA values (like "" for String) are set.
 	 */
-	public static AttributeMetadataMap<AttributeMetadataImpl> createDefaultAttributeMetadataMap(SimpleFeatureType schema) {
+	public static AttributeMetadataMap<AttributeMetadataImpl> createDefaultAttributeMetadataMap(
+			SimpleFeatureType schema) {
 		AttributeMetadataImplMap attMap = new AttributeMetadataImplMap();
 
 		for (int i = 0; i < schema.getAttributeCount(); i++) {
@@ -1479,8 +1738,9 @@
 
 			// TODO AttributeMetadataAS would be nicer, which would not work
 			// with Translations ;-)
-			AttributeMetadataImpl attMetaData = new AttributeMetadataImpl(new NameImpl(attDesc.getName()
-					.getNamespaceURI(), attDesc.getName().getLocalPart()), attMap.getLanguages());
+			AttributeMetadataImpl attMetaData = new AttributeMetadataImpl(
+					new NameImpl(attDesc.getName().getNamespaceURI(), attDesc
+							.getName().getLocalPart()), attMap.getLanguages());
 
 			if (String.class.isAssignableFrom(attDesc.getType().getBinding())) {
 				// For Strings we add the "" as NODATA values
@@ -1493,25 +1753,30 @@
 	}
 
 	/**
-	 * Returns <code>true</code> is changing the zoom from oldScaleDenominator to newScaleDenominator would result in a
-	 * another styling.
+	 * Returns <code>true</code> is changing the zoom from oldScaleDenominator
+	 * to newScaleDenominator would result in a another styling.
 	 * 
 	 * TODO This is not evaluating the AtlasStlyer diabled classes Filters yet!
 	 */
-	public static boolean hasScalechangeAnyEffect(Style style, double oldScaleDenominator, double newScaleDenominator) {
+	public static boolean hasScalechangeAnyEffect(Style style,
+			double oldScaleDenominator, double newScaleDenominator) {
 
 		for (FeatureTypeStyle fts : style.featureTypeStyles()) {
 			for (Rule r : fts.rules()) {
 				double minScale = r.getMinScaleDenominator();
 				double maxScale = r.getMaxScaleDenominator();
-				if (oldScaleDenominator < minScale && newScaleDenominator >= minScale)
+				if (oldScaleDenominator < minScale
+						&& newScaleDenominator >= minScale)
 					return true;
-				if (oldScaleDenominator >= minScale && newScaleDenominator < minScale)
+				if (oldScaleDenominator >= minScale
+						&& newScaleDenominator < minScale)
 					return true;
 
-				if (oldScaleDenominator < maxScale && newScaleDenominator >= maxScale)
+				if (oldScaleDenominator < maxScale
+						&& newScaleDenominator >= maxScale)
 					return true;
-				if (oldScaleDenominator >= maxScale && newScaleDenominator < maxScale)
+				if (oldScaleDenominator >= maxScale
+						&& newScaleDenominator < maxScale)
 					return true;
 			}
 		}

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-08-30 09:30:25 UTC (rev 1698)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StylingUtil.java	2011-08-30 19:12:51 UTC (rev 1699)
@@ -55,7 +55,6 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import javax.management.RuntimeErrorException;
 import javax.measure.unit.Unit;
 import javax.xml.transform.TransformerException;
 
@@ -122,7 +121,6 @@
 import org.geotools.styling.visitor.DuplicatingStyleVisitor;
 import org.geotools.util.NumberRange;
 import org.geotools.xml.Parser;
-import org.hsqldb.lib.HashMap;
 import org.jdom.Element;
 import org.jdom.output.XMLOutputter;
 import org.opengis.coverage.grid.GridCoverage;
@@ -155,12 +153,12 @@
 import de.schmitzm.geotools.selection.FeatureMapLayerSelectionSynchronizer;
 import de.schmitzm.io.IOUtil;
 import de.schmitzm.lang.LangUtil;
-import de.schmitzm.swing.ExceptionDialog;
 
 /**
  * Diese Klasse enthaelt Hilfsfunktionen zum GeoTools-Styling
  * 
- * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a> (University of Bonn/Germany)
+ * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
+ *         (University of Bonn/Germany)
  * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
  * 
  * @version 1.1
@@ -174,7 +172,7 @@
 
 	/** Standard-Instanz eines {@link SLDTransformer}. */
 	public final static SLDTransformer SLDTRANSFORMER = new SLDTransformer();
-
+	
 	static {
 		// @since 1.7: All SLD files are by default created with UTF-8, no
 		// matter what the systems default it.
@@ -185,14 +183,45 @@
 	}
 
 	/** Standard-Instanz einer {@link StyleFactory} */
-	public static final StyleFactory STYLE_FACTORY = CommonFactoryFinder.getStyleFactory(GeoTools.getDefaultHints());
+	public static final StyleFactory STYLE_FACTORY = CommonFactoryFinder
+			.getStyleFactory(GeoTools.getDefaultHints());
 
 	/** Standard-Instanz eines {@link StyleBuilder}. */
-	public static final StyleBuilder STYLE_BUILDER = new StyleBuilder(STYLE_FACTORY);
+	public static final StyleBuilder STYLE_BUILDER = new StyleBuilder(
+			STYLE_FACTORY);
 
-	public static final DuplicatingStyleVisitor DUPLICATINGSTYLEVISITOR = new DuplicatingStyleVisitor(STYLE_FACTORY);
+	public static final FilterFactory2 ff = FeatureUtil.FILTER_FACTORY2;
 
+	public static final DuplicatingStyleVisitor DUPLICATINGSTYLEVISITOR = new DuplicatingStyleVisitor(
+			STYLE_FACTORY);
+	
+	// ** Do not change the value, it is needed to recognize SLD **//
+	static final String ALL_LABEL_CLASSES_ENABLED = "ALL_LABEL_CLASSES_ENABLED";
 	/**
+	 * A Filter to mark that one class/rule has been disabled. Sorry,
+	 * AtlasStyler specifc, but used in Sl #createLegendSwing method
+	 **/
+	public static final PropertyIsEqualTo RL_DISABLED_FILTER = ff.equals(
+			ff.literal("ALL_LABEL_CLASSES_DISABLED"), ff.literal("YES"));
+	/**
+	 * A Filter to mark that one class/rule is enabled
+	 **/
+	public static final PropertyIsEqualTo RL_ENABLED_FILTER = ff.equals(
+			ff.literal(ALL_LABEL_CLASSES_ENABLED),
+			ff.literal(ALL_LABEL_CLASSES_ENABLED));
+
+	// ** Do not change the value, it is needed to recognize SLD **//
+	static final String RL_FILTER_APPLIED_STR = "RL_FILTER_APPLIED";
+
+	/**
+	 * A Filter to mark that one class/rule is enabled
+	 **/
+	public static final PropertyIsEqualTo RL_FILTER_APPLIED_FILTER = ff.equals(
+			ff.literal(RL_FILTER_APPLIED_STR),
+			ff.literal(RL_FILTER_APPLIED_STR));
+
+
+	/**
 	 * Lists a few predefined {@link Style}s usefull to mark selected features.
 	 */
 	public enum SelectionStylesTypes {
@@ -200,14 +229,17 @@
 	}
 
 	/**
-	 * RegEx Patter to read palette information from gdalinfo output, for images wir <code>RGB</code>, @see
-	 * {@link #parseColormapToSld(URL)} @see {@link #parseColormapToSld(File)}
+	 * RegEx Patter to read palette information from gdalinfo output, for images
+	 * wir <code>RGB</code>, @see {@link #parseColormapToSld(URL)} @see
+	 * {@link #parseColormapToSld(File)}
 	 **/
-	public static final Pattern GDALINFO_COLORMAP_RGB = Pattern.compile("^[^\\d]*(\\d+): (\\d+),(\\d+),(\\d+).*$");
+	public static final Pattern GDALINFO_COLORMAP_RGB = Pattern
+			.compile("^[^\\d]*(\\d+): (\\d+),(\\d+),(\\d+).*$");
 
 	/**
-	 * RegEx Patter to read palette information from gdalinfo output, for images wir <code>RGBA</code> @see
-	 * {@link #parseColormapToSld(URL)} @see {@link #parseColormapToSld(File)}
+	 * RegEx Patter to read palette information from gdalinfo output, for images
+	 * wir <code>RGBA</code> @see {@link #parseColormapToSld(URL)} @see
+	 * {@link #parseColormapToSld(File)}
 	 **/
 	public static final Pattern GDALINFO_COLORMAP_RGBA = Pattern
 			.compile("^[^\\d]*(\\d+): (\\d+),(\\d+),(\\d+),(\\d+).*$");
@@ -219,32 +251,40 @@
 	static final Literal size3 = FeatureUtil.FILTER_FACTORY2.literal(3);
 
 	static final Graphic SELECTION_GRAPHIC1 = STYLE_FACTORY.createGraphic(
-			new ExternalGraphic[0],
-			new Mark[] { STYLE_FACTORY.createMark(FeatureUtil.FILTER_FACTORY2.literal("square"), null,
-					STYLE_FACTORY.createFill(STYLE_BUILDER.colorExpression(Color.WHITE)), size1, zeroLit) },
-			new org.geotools.styling.Symbol[0], FeatureUtil.FILTER_FACTORY2.literal(1), size1, zeroLit);
+			new ExternalGraphic[0], new Mark[] { STYLE_FACTORY.createMark(
+					FeatureUtil.FILTER_FACTORY2.literal("square"), null,
+					STYLE_FACTORY.createFill(STYLE_BUILDER
+							.colorExpression(Color.WHITE)), size1, zeroLit) },
+			new org.geotools.styling.Symbol[0], FeatureUtil.FILTER_FACTORY2
+					.literal(1), size1, zeroLit);
 
 	static final Graphic SELECTION_GRAPHIC2 = STYLE_FACTORY.createGraphic(
-			new ExternalGraphic[0],
-			new Mark[] { STYLE_FACTORY.createMark(FeatureUtil.FILTER_FACTORY2.literal("circle"), null,
-					STYLE_FACTORY.createFill(STYLE_BUILDER.colorExpression(Color.BLACK)), size2, zeroLit) },
-			new org.geotools.styling.Symbol[0], FeatureUtil.FILTER_FACTORY2.literal(1), size2, zeroLit);
-	static final Graphic SELECTION_GRAPHIC3 = STYLE_FACTORY
-			.createGraphic(new ExternalGraphic[0],
-					new Mark[] { STYLE_FACTORY.createMark(FeatureUtil.FILTER_FACTORY2.literal("circle"), null,
-							STYLE_FACTORY.createFill(STYLE_BUILDER.colorExpression(Color.YELLOW.brighter())), size3,
-							zeroLit) }, new org.geotools.styling.Symbol[0], FeatureUtil.FILTER_FACTORY2.literal(1),
-					size3, zeroLit);
+			new ExternalGraphic[0], new Mark[] { STYLE_FACTORY.createMark(
+					FeatureUtil.FILTER_FACTORY2.literal("circle"), null,
+					STYLE_FACTORY.createFill(STYLE_BUILDER
+							.colorExpression(Color.BLACK)), size2, zeroLit) },
+			new org.geotools.styling.Symbol[0], FeatureUtil.FILTER_FACTORY2
+					.literal(1), size2, zeroLit);
+	static final Graphic SELECTION_GRAPHIC3 = STYLE_FACTORY.createGraphic(
+			new ExternalGraphic[0], new Mark[] { STYLE_FACTORY.createMark(
+					FeatureUtil.FILTER_FACTORY2.literal("circle"), null,
+					STYLE_FACTORY.createFill(STYLE_BUILDER
+							.colorExpression(Color.YELLOW.brighter())), size3,
+					zeroLit) }, new org.geotools.styling.Symbol[0],
+			FeatureUtil.FILTER_FACTORY2.literal(1), size3, zeroLit);
 
 	static final Graphic BLINK_GRAPHIC1 = STYLE_FACTORY.createGraphic(
-			new ExternalGraphic[0],
-			new Mark[] { STYLE_FACTORY.createMark(FeatureUtil.FILTER_FACTORY2.literal("circle"), null,
-					STYLE_FACTORY.createFill(STYLE_BUILDER.colorExpression(Color.WHITE)), size0, halfLit) },
-			new org.geotools.styling.Symbol[0], FeatureUtil.FILTER_FACTORY2.literal(1), size0, zeroLit);
+			new ExternalGraphic[0], new Mark[] { STYLE_FACTORY.createMark(
+					FeatureUtil.FILTER_FACTORY2.literal("circle"), null,
+					STYLE_FACTORY.createFill(STYLE_BUILDER
+							.colorExpression(Color.WHITE)), size0, halfLit) },
+			new org.geotools.styling.Symbol[0], FeatureUtil.FILTER_FACTORY2
+					.literal(1), size0, zeroLit);
 	private static final FilterFactory FILTER_FACTORY = FeatureUtil.FILTER_FACTORY;
 
 	/**
-	 * THis string is set as the Name of the Rules that describe selected features
+	 * THis string is set as the Name of the Rules that describe selected
+	 * features
 	 **/
 	public static final String SELECTION_RULE_ID = "SelectionRule";
 
@@ -254,28 +294,31 @@
 	private static final String OPTIMIZED_COMMENT = "<!-- This SLD has been exported in an 'optimized' version. This version potentially renders faster, but AtlasStyler will not be able to load it correctly.-->";
 
 	/**
-	 * Unless {@link ColorMap} is not sorted automatically, this method calls {@link #sortColorMap(ColorMap)} after
-	 * inserting the color map entry.
+	 * Unless {@link ColorMap} is not sorted automatically, this method calls
+	 * {@link #sortColorMap(ColorMap)} after inserting the color map entry.
 	 * 
 	 * @param colorMap
 	 *            the color map to extend
 	 * @param colorMapEntry
 	 *            the new entry
 	 */
-	public static ColorMap addColorMapEntryAndSort(ColorMap colorMap, ColorMapEntry colorMapEntry) {
+	public static ColorMap addColorMapEntryAndSort(ColorMap colorMap,
+			ColorMapEntry colorMapEntry) {
 		colorMap.addColorMapEntry(colorMapEntry);
 		return sortColorMap(colorMap);
 	}
 
 	/**
-	 * Applies general properties (color map type and extended colors) to a {@link ColorMap}.
+	 * Applies general properties (color map type and extended colors) to a
+	 * {@link ColorMap}.
 	 * 
 	 * @param sourceColorMap
 	 *            color map the properties are taken from
 	 * @param destColormap
 	 *            color map the properties are set
 	 */
-	public static void applyColorMapProperties(ColorMap sourceColorMap, ColorMap destColormap) {
+	public static void applyColorMapProperties(ColorMap sourceColorMap,
+			ColorMap destColormap) {
 		if (sourceColorMap == null || destColormap == null)
 			return;
 		destColormap.setExtendedColors(sourceColorMap.getExtendedColors());
@@ -283,7 +326,8 @@
 	}
 
 	/**
-	 * Removes all label information from the {@link ColorMapEntry}s of the given {@link ColorMap}
+	 * Removes all label information from the {@link ColorMapEntry}s of the
+	 * given {@link ColorMap}
 	 * 
 	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
@@ -334,7 +378,8 @@
 	/**
 	 * Kopiert eine {@link ColorMap}.
 	 * 
-	 * @return <code>null</code> wenn die uebergebene ColorMap <code>null</code> ist
+	 * @return <code>null</code> wenn die uebergebene ColorMap <code>null</code>
+	 *         ist
 	 */
 	public static ColorMap cloneColorMap(ColorMap colorMap) {
 		// MS: Leider kommt der DuplicatingStyleVisitor nicht damit klar, dass
@@ -361,7 +406,8 @@
 	/**
 	 * Kopiert einen {@link ColorMapEntry}.
 	 * 
-	 * @return <code>null</code> wenn der uebergebene ColorMapEntry <code>null</code> ist
+	 * @return <code>null</code> wenn der uebergebene ColorMapEntry
+	 *         <code>null</code> ist
 	 * 
 	 *         TODO doppelt mit copy( ColorMapEntry? )
 	 */
@@ -369,20 +415,24 @@
 		if (colorMapEntry == null)
 			return null;
 
-		return createColorMapEntry(colorMapEntry.getLabel(), getQuantityFromColorMapEntry(colorMapEntry),
-				getColorFromColorMapEntry(colorMapEntry), getOpacityFromColorMapEntry(colorMapEntry));
+		return createColorMapEntry(colorMapEntry.getLabel(),
+				getQuantityFromColorMapEntry(colorMapEntry),
+				getColorFromColorMapEntry(colorMapEntry),
+				getOpacityFromColorMapEntry(colorMapEntry));
 	}
 
 	/**
-	 * Prueft, ob zwei {@link ColorMapEntry}-Instanzen gleich sind. Dies ist der Fall, wenn ihnen der gleiche Wert, die
-	 * gleiche Farbe, die gleiche Transparenz und das gleiche Label zugeordnet ist.
+	 * Prueft, ob zwei {@link ColorMapEntry}-Instanzen gleich sind. Dies ist der
+	 * Fall, wenn ihnen der gleiche Wert, die gleiche Farbe, die gleiche
+	 * Transparenz und das gleiche Label zugeordnet ist.
 	 * 
 	 * @param cme1
 	 *            ein Farbpaletten-Eintrag
 	 * @param cme2
 	 *            ein anderer Farbpaletten-Eintrag
 	 */
-	public static boolean colorMapEntriesEqual(ColorMapEntry cme1, ColorMapEntry cme2) {
+	public static boolean colorMapEntriesEqual(ColorMapEntry cme1,
+			ColorMapEntry cme2) {
 		if (cme1 == null ^ cme2 == null)
 			return false;
 		if (cme1 == cme2)
@@ -400,7 +450,8 @@
 		// Wert auf Gleichheit testen
 		Double quan1 = getQuantityFromColorMapEntry(cme1);
 		Double quan2 = getQuantityFromColorMapEntry(cme2);
-		if (quan1 == null ^ quan2 == null || quan1 != null && !quan1.equals(quan2))
+		if (quan1 == null ^ quan2 == null || quan1 != null
+				&& !quan1.equals(quan2))
 			return false;
 		// Transparenz auf Gleichheit testen
 		Double op1 = getOpacityFromColorMapEntry(cme1);
@@ -414,7 +465,8 @@
 	/**
 	 * Kopiert einen {@link ColorMapEntry}.
 	 * 
-	 * @return <code>null</code> wenn der uebergebene ColorMapEntry <code>null</code> ist
+	 * @return <code>null</code> wenn der uebergebene ColorMapEntry
+	 *         <code>null</code> ist
 	 */
 	public static ColorMapEntry copy(ColorMapEntry colorMapEntry) {
 		DuplicatingStyleVisitor duplicatingStyleVisitor = new DuplicatingStyleVisitor();
@@ -456,8 +508,9 @@
 	}
 
 	/**
-	 * Since GT2.6, the AttributeNames are case sensitive. Also the raster Styles need GeometryProperty set to "geom" to
-	 * work. This method checks all referenced AttributeNames.
+	 * Since GT2.6, the AttributeNames are case sensitive. Also the raster
+	 * Styles need GeometryProperty set to "geom" to work. This method checks
+	 * all referenced AttributeNames.
 	 * 
 	 * @param Schema
 	 *            may be <code>null</code>, e.g. for raster layers
@@ -469,15 +522,17 @@
 	}
 
 	/**
-	 * Since GT2.6, the AttributeNames are case sensitive. Also the raster Styles need GeometryProperty set to "geom" to
-	 * work. This method checks all referenced AttributeNames and checks them against the schema.
+	 * Since GT2.6, the AttributeNames are case sensitive. Also the raster
+	 * Styles need GeometryProperty set to "geom" to work. This method checks
+	 * all referenced AttributeNames and checks them against the schema.
 	 * 
 	 * @param Schema
 	 *            may be <code>null</code>, e.g. for raster layers
 	 * 
 	 *            TODO Rename to correctStye
 	 */
-	public static Style correctPropertyNames(Style style, final SimpleFeatureType schema) {
+	public static Style correctPropertyNames(Style style,
+			final SimpleFeatureType schema) {
 
 		DuplicatingStyleVisitor dsv = new DuplicatingStyleVisitor() {
 			@Override
@@ -499,8 +554,9 @@
 				} else if (expression instanceof PropertyName) {
 					PropertyName pName = (PropertyName) expression;
 
-					Name correctedName = FeatureUtil.findBestMatchingAttributeFallBackFirst(schema,
-							pName.getPropertyName());
+					Name correctedName = FeatureUtil
+							.findBestMatchingAttributeFallBackFirst(schema,
+									pName.getPropertyName());
 
 					return ff.property(correctedName);
 				}
@@ -515,7 +571,8 @@
 					divFilter.setExpression2(copy(divFilter.getExpression2()));
 				} else if (filter instanceof IsNullImpl) {
 					IsNullImpl isNullFilter = (IsNullImpl) filter;
-					isNullFilter.setExpression1(copy(isNullFilter.getExpression1()));
+					isNullFilter.setExpression1(copy(isNullFilter
+							.getExpression1()));
 				} else if (filter instanceof NotImpl) {
 					NotImpl notFilter = (NotImpl) filter;
 					List<Filter> children = notFilter.getChildren();
@@ -548,7 +605,8 @@
 					// TODO noch viel mehr faelle!!
 					if (filter instanceof IsBetweenImpl) {
 						IsBetweenImpl isbetween = (IsBetweenImpl) filter;
-						isbetween.setExpression(copy(isbetween.getExpression()));
+						isbetween
+								.setExpression(copy(isbetween.getExpression()));
 					}
 
 				}
@@ -605,8 +663,8 @@
 	}
 
 	/**
-	 * @return A {@link FeatureTypeStyle} that can be used style the given geoObject during a blink or highlight
-	 *         process.
+	 * @return A {@link FeatureTypeStyle} that can be used style the given
+	 *         geoObject during a blink or highlight process.
 	 */
 	public static FeatureTypeStyle createBlinkFeatureTypeStyle(Object geoObject) {
 		if (geoObject instanceof GridCoverage2D
@@ -642,52 +700,65 @@
 
 		case NONE:
 		default:
-			throw new IllegalArgumentException("Provide a suitable GeometryForm object, NONE not allowed");
+			throw new IllegalArgumentException(
+					"Provide a suitable GeometryForm object, NONE not allowed");
 		}
 
-		return STYLE_BUILDER.createFeatureTypeStyle(symbolizers, Double.NaN, Double.NaN);
+		return STYLE_BUILDER.createFeatureTypeStyle(symbolizers, Double.NaN,
+				Double.NaN);
 	}
 
-	private static Symbolizer[] createBlinkFeatureTypeStyleLine(Symbolizer[] symbolizers) {
+	private static Symbolizer[] createBlinkFeatureTypeStyleLine(
+			Symbolizer[] symbolizers) {
 		LineSymbolizer ls = STYLE_BUILDER.createLineSymbolizer(Color.red, 6.);
 		symbolizers = LangUtil.extendArray(symbolizers, ls);
 
-		LineSymbolizer ls2 = STYLE_BUILDER.createLineSymbolizer(Color.black, 4.);
+		LineSymbolizer ls2 = STYLE_BUILDER
+				.createLineSymbolizer(Color.black, 4.);
 		symbolizers = LangUtil.extendArray(symbolizers, ls2);
 
-		LineSymbolizer ls3 = STYLE_BUILDER.createLineSymbolizer(Color.white, 2.);
+		LineSymbolizer ls3 = STYLE_BUILDER
+				.createLineSymbolizer(Color.white, 2.);
 		symbolizers = LangUtil.extendArray(symbolizers, ls3);
 		return symbolizers;
 	}
 
-	private static Symbolizer[] createBlinkFeatureTypeStylePolygon(Symbolizer[] symbolizers) {
-		PolygonSymbolizer pol1 = STYLE_BUILDER.createPolygonSymbolizer(STYLE_BUILDER.createStroke(Color.red, 4), null);
+	private static Symbolizer[] createBlinkFeatureTypeStylePolygon(
+			Symbolizer[] symbolizers) {
+		PolygonSymbolizer pol1 = STYLE_BUILDER.createPolygonSymbolizer(
+				STYLE_BUILDER.createStroke(Color.red, 4), null);
 		symbolizers = LangUtil.extendArray(symbolizers, pol1);
 
-		PolygonSymbolizer pol2 = STYLE_BUILDER.createPolygonSymbolizer(STYLE_BUILDER.createStroke(Color.black, 2),
+		PolygonSymbolizer pol2 = STYLE_BUILDER.createPolygonSymbolizer(
+				STYLE_BUILDER.createStroke(Color.black, 2),
 				STYLE_BUILDER.createFill(Color.WHITE, .5));
 		symbolizers = LangUtil.extendArray(symbolizers, pol2);
 		return symbolizers;
 	}
 
-	private static Symbolizer[] createBlinkFeatureTypeStylePoint(Symbolizer[] symbolizers) {
+	private static Symbolizer[] createBlinkFeatureTypeStylePoint(
+			Symbolizer[] symbolizers) {
 		Graphic bg2;
 		Literal size0 = FeatureUtil.FILTER_FACTORY2.literal(26);
 		Literal size1 = FeatureUtil.FILTER_FACTORY2.literal(28);
 
-		Graphic bg1 = STYLE_FACTORY.createGraphic(
-				new ExternalGraphic[0],
-				new Mark[] { STYLE_FACTORY.createMark(FeatureUtil.FILTER_FACTORY2.literal("circle"),
-						STYLE_BUILDER.createStroke(Color.red, 2.), null, size1, halfLit) },
-				new org.geotools.styling.Symbol[0], FeatureUtil.FILTER_FACTORY2.literal(1), size1, zeroLit);
+		Graphic bg1 = STYLE_FACTORY.createGraphic(new ExternalGraphic[0],
+				new Mark[] { STYLE_FACTORY.createMark(
+						FeatureUtil.FILTER_FACTORY2.literal("circle"),
+						STYLE_BUILDER.createStroke(Color.red, 2.), null, size1,
+						halfLit) }, new org.geotools.styling.Symbol[0],
+				FeatureUtil.FILTER_FACTORY2.literal(1), size1, zeroLit);
 
 		PointSymbolizer ps1 = STYLE_FACTORY.createPointSymbolizer();
 		ps1.setGraphic(bg1);
 		symbolizers = LangUtil.extendArray(symbolizers, ps1);
 
-		bg2 = STYLE_FACTORY.createGraphic(new ExternalGraphic[0], new Mark[] { STYLE_FACTORY.createMark(
-				FeatureUtil.FILTER_FACTORY2.literal("circle"), STYLE_BUILDER.createStroke(Color.black, 2.),
-				STYLE_BUILDER.createFill(Color.WHITE, 0.3), size0, halfLit) }, new org.geotools.styling.Symbol[0],
+		bg2 = STYLE_FACTORY.createGraphic(new ExternalGraphic[0],
+				new Mark[] { STYLE_FACTORY.createMark(
+						FeatureUtil.FILTER_FACTORY2.literal("circle"),
+						STYLE_BUILDER.createStroke(Color.black, 2.),
+						STYLE_BUILDER.createFill(Color.WHITE, 0.3), size0,
+						halfLit) }, new org.geotools.styling.Symbol[0],
 				FeatureUtil.FILTER_FACTORY2.literal(1), size0, zeroLit);
 
 		PointSymbolizer ps2 = STYLE_FACTORY.createPointSymbolizer();
@@ -698,11 +769,13 @@
 	}
 
 	/**
-	 * Creates a new {@link BrewerPalette} with only one scheme (which includes all colors). The suitablity of the
-	 * palette is set to "unknown" for all viewer types.
+	 * Creates a new {@link BrewerPalette} with only one scheme (which includes
+	 * all colors). The suitablity of the palette is set to "unknown" for all
+	 * viewer types.
 	 * 
 	 * @param name
-	 *            name for the palette (also the description is set to this value)
+	 *            name for the palette (also the description is set to this
+	 *            value)
 	 * @param colors
 	 *            colors for the palette
 	 */
@@ -715,10 +788,13 @@
 		// set suitability to UNKNOWN for all viewers
 		PaletteSuitability suitability = new PaletteSuitability();
 		try {
-			suitability.setSuitability(colors.length, new String[] { "?", "?", "?", "?", "?", "?" });
+			suitability.setSuitability(colors.length, new String[] { "?", "?",
+					"?", "?", "?", "?" });
 			palette.setPaletteSuitability(suitability);
 		} catch (IOException e) {
-			LOGGER.error("Unabel to PaletteSuitability.setSuitablility for colors.length=" + colors, e);
+			LOGGER.error(
+					"Unabel to PaletteSuitability.setSuitablility for colors.length="
+							+ colors, e);
 		}
 
 		// Create the trivial scheme for the palette (requested colors equals
@@ -751,7 +827,8 @@
 	 * @param opacity
 	 *            Transparenz fuer die Farbe des Farbpaletten-Eintrag
 	 */
-	public static ColorMapEntry createColorMapEntry(String label, Double quantity, Color color, double opacity) {
+	public static ColorMapEntry createColorMapEntry(String label,
+			Double quantity, Color color, double opacity) {
 		ColorMapEntry newEntry = STYLE_FACTORY.createColorMapEntry();
 		try {
 			newEntry.setLabel(label);
@@ -765,23 +842,28 @@
 	}
 
 	/**
-	 * Erstellt einen Default-Style fuer die Klassen/Interfaces: StyledFeaturesInterface, GridCoverage2D,
-	 * FeatureCollection, FeatureSource und GeometryAttributeType.
+	 * Erstellt einen Default-Style fuer die Klassen/Interfaces:
+	 * StyledFeaturesInterface, GridCoverage2D, FeatureCollection, FeatureSource
+	 * und GeometryAttributeType.
 	 * 
 	 * @param object
-	 *            {@link GridCoverage2D}, {@link org.geotools.coverage.grid.io.AbstractGridCoverage2DReader} oder
-	 *            {@link FeatureCollection}
+	 *            {@link GridCoverage2D},
+	 *            {@link org.geotools.coverage.grid.io.AbstractGridCoverage2DReader}
+	 *            oder {@link FeatureCollection}
 	 * @return {@code null} falls kein Style generiert werden kann
 	 * 
-	 * @Deprectated Use FeatureUtil.createDefaultStyle and FeatureUtil.getGeometryForm
+	 * @Deprectated Use FeatureUtil.createDefaultStyle and
+	 *              FeatureUtil.getGeometryForm
 	 */
 	public static Style createDefaultStyle(Object object) {
 
 		if (object instanceof StyledFeaturesInterface)
-			return FeatureUtil.createDefaultStyle(((StyledFeaturesInterface<?>) object).getSchema()
-					.getGeometryDescriptor());
+			return FeatureUtil
+					.createDefaultStyle(((StyledFeaturesInterface<?>) object)
+							.getSchema().getGeometryDescriptor());
 
-		if (object instanceof GridCoverage2D || object instanceof AbstractGridCoverage2DReader
+		if (object instanceof GridCoverage2D
+				|| object instanceof AbstractGridCoverage2DReader
 				|| object instanceof StyledRasterInterface)
 			return GridUtil.createDefaultStyle();
 
@@ -790,15 +872,18 @@
 		}
 
 		if (object instanceof FeatureCollection)
-			return FeatureUtil.createDefaultStyle((FeatureCollection<SimpleFeatureType, SimpleFeature>) object);
+			return FeatureUtil
+					.createDefaultStyle((FeatureCollection<SimpleFeatureType, SimpleFeature>) object);
 
 		if (object instanceof FeatureSource)
-			return FeatureUtil.createDefaultStyle(((FeatureSource) object).getSchema().getGeometryDescriptor());
+			return FeatureUtil.createDefaultStyle(((FeatureSource) object)
+					.getSchema().getGeometryDescriptor());
 
 		if (object instanceof GeometryDescriptor)
 			return FeatureUtil.createDefaultStyle((GeometryDescriptor) object);
 
-		LOGGER.warn("createDefaultStyle could not handle " + object + " and returned an empty (invalid) Style");
+		LOGGER.warn("createDefaultStyle could not handle " + object
+				+ " and returned an empty (invalid) Style");
 		return STYLE_BUILDER.createStyle();
 	}
 
@@ -808,15 +893,19 @@
 	 * @param name
 	 *            Name fuer die {@link GridSampleDimension}
 	 * @param colorMap
-	 *            fuer jeden Eintrag der {@link ColorMap} wird eine {@link Category} erzeugt
+	 *            fuer jeden Eintrag der {@link ColorMap} wird eine
+	 *            {@link Category} erzeugt
 	 * @param noDataValues
-	 *            Werte fuer die zusaetzliche {@link Category Categorys} erstellt werden, welche die transparent
-	 *            dargestellt werden (wenn {@code null} wird keine zusaetzliche {@link Category} erstellt)
+	 *            Werte fuer die zusaetzliche {@link Category Categorys}
+	 *            erstellt werden, welche die transparent dargestellt werden
+	 *            (wenn {@code null} wird keine zusaetzliche {@link Category}
+	 *            erstellt)
 	 * @param unit
-	 *            Einheit der Werte in der {@link GridSampleDimension} (kann {@code null} sein)
+	 *            Einheit der Werte in der {@link GridSampleDimension} (kann
+	 *            {@code null} sein)
 	 */
-	public static GridSampleDimension createDiscreteGridSampleDimension(String name, ColorMap colorMap,
-			double[] noDataValues, Unit<?> unit) {
+	public static GridSampleDimension createDiscreteGridSampleDimension(
+			String name, ColorMap colorMap, double[] noDataValues, Unit<?> unit) {
 		if (colorMap.getColorMapEntries().length == 0)
 			return null;
 
@@ -838,8 +927,9 @@
 			// label = String.valueOf(intValue);
 			if (label == null)
 				label = "";
-			categories.put(intValue, new Category(label, new Color[] { color }, new NumberRange(intValue, intValue),
-					new NumberRange(intValue, intValue)));
+			categories.put(intValue, new Category(label, new Color[] { color },
+					new NumberRange(intValue, intValue), new NumberRange(
+							intValue, intValue)));
 		}
 
 		// If NoData-Value is set, create an additional Category
@@ -857,12 +947,15 @@
 		// double higherEnd = colorMapMax + 10000*colorMapRange;
 		final int lowerStart = Integer.MIN_VALUE;
 		final int higherEnd = Integer.MAX_VALUE;
-		categories.put(colorMapMax + 10, new Category("_autoNoData1_", new Color[] { new Color(0, 0, 0, 0) },
-				new NumberRange(colorMapMax + 1, colorMapMax + 2), new NumberRange(colorMapMax + 1, higherEnd)));
+		categories.put(colorMapMax + 10, new Category("_autoNoData1_",
+				new Color[] { new Color(0, 0, 0, 0) }, new NumberRange(
+						colorMapMax + 1, colorMapMax + 2), new NumberRange(
+						colorMapMax + 1, higherEnd)));
 		if (colorMapMin < colorMapMax)
-			categories.put(colorMapMin - 10, new Category("_autoNoData2_", new Color[] { new Color(0, 0, 0, 0) },
-			// new NumberRange(colorMapMin-2, colorMapMin-1), //
-			// logischer, aber klappt nicht!?
+			categories.put(colorMapMin - 10, new Category("_autoNoData2_",
+					new Color[] { new Color(0, 0, 0, 0) },
+					// new NumberRange(colorMapMin-2, colorMapMin-1), //
+					// logischer, aber klappt nicht!?
 					NumberRange.create(colorMapMax + 3, colorMapMax + 4),
 					// new NumberRange(colorMapMax + 3, colorMapMax + 4),
 					NumberRange.create(lowerStart, colorMapMin - 1)
@@ -870,8 +963,8 @@
 					));
 
 		// Create the GridSampleDimension
-		GridSampleDimension gsd = new GridSampleDimension(name, categories.values().toArray(new Category[0]), unit)
-				.geophysics(true);
+		GridSampleDimension gsd = new GridSampleDimension(name, categories
+				.values().toArray(new Category[0]), unit).geophysics(true);
 
 		for (Category c : gsd.getCategories())
 			LOGGER.debug(c.toString());
@@ -880,7 +973,8 @@
 	}
 
 	/**
-	 * Erzeugt eine {@link Category} fuer die NoData-Werte transparent dargestellt werden.
+	 * Erzeugt eine {@link Category} fuer die NoData-Werte transparent
+	 * dargestellt werden.
 	 * 
 	 * @param geoValue
 	 *            Geo-Wert, der NoData repraesentiert
@@ -890,7 +984,8 @@
 	}
 
 	/**
-	 * Erzeugt eine {@link Category} fuer die NoData-Werte transparent dargestellt werden.
+	 * Erzeugt eine {@link Category} fuer die NoData-Werte transparent
+	 * dargestellt werden.
 	 * 
 	 * @param value
 	 *            Sample-Wert der Category
@@ -898,38 +993,50 @@
 	 *            Geo-Wert, der NoData repraesentiert
 	 */
 	public static Category createNoDataCategory(int value, double geoValue) {
-		return new Category(Vocabulary.formatInternational(VocabularyKeys.NODATA),
-				new Color[] { new Color(0, 0, 0, 0) }, new NumberRange(value, value), new NumberRange(geoValue,
-						geoValue));
+		return new Category(
+				Vocabulary.formatInternational(VocabularyKeys.NODATA),
+				new Color[] { new Color(0, 0, 0, 0) }, new NumberRange(value,
+						value), new NumberRange(geoValue, geoValue));
 	}
 
 	/**
 	 * @param geoObject
-	 *            the {@link GeometryForm} the selection style shall be created for.
+	 *            the {@link GeometryForm} the selection style shall be created
+	 *            for.
 	 * @param type
-	 *            define the look of the selection style by choosing a constant from {@link SelectionStylesTypes}
+	 *            define the look of the selection style by choosing a constant
+	 *            from {@link SelectionStylesTypes}
 	 * 
-	 * @return a {@link Style} that is suitable to identify features of the given type as selected items.
+	 * @return a {@link Style} that is suitable to identify features of the
+	 *         given type as selected items.
 	 */
-	public static FeatureTypeStyle createSelectionFTStyle(GeometryForm geometryForm, SelectionStylesTypes type) {
-		Symbolizer[] symbolizers = createSelectionSymbolizers(geometryForm, type);
+	public static FeatureTypeStyle createSelectionFTStyle(
+			GeometryForm geometryForm, SelectionStylesTypes type) {
+		Symbolizer[] symbolizers = createSelectionSymbolizers(geometryForm,
+				type);
 
-		return STYLE_BUILDER.createFeatureTypeStyle(symbolizers, 0.0, Double.POSITIVE_INFINITY);
+		return STYLE_BUILDER.createFeatureTypeStyle(symbolizers, 0.0,
+				Double.POSITIVE_INFINITY);
 	}
 
 	/**
 	 * @param geoObject
-	 *            {@link GridCoverage2D}, {@link AbstractGridCoverage2DReader}, {@link FeatureCollection},
-	 *            {@link GeometryAttributeType} or {@link FeatureSource}
+	 *            {@link GridCoverage2D}, {@link AbstractGridCoverage2DReader},
+	 *            {@link FeatureCollection}, {@link GeometryAttributeType} or
+	 *            {@link FeatureSource}
 	 * 
 	 * @param type
-	 *            define the look of the selection style by choosing a constant from {@link SelectionStylesTypes}
+	 *            define the look of the selection style by choosing a constant
+	 *            from {@link SelectionStylesTypes}
 	 * 
-	 * @return a {@link Style} that is suitable to identify features of the given type as selected items.
+	 * @return a {@link Style} that is suitable to identify features of the
+	 *         given type as selected items.
 	 */
-	public static FeatureTypeStyle createSelectionFTStyle(Object geoObject, SelectionStylesTypes type) {
+	public static FeatureTypeStyle createSelectionFTStyle(Object geoObject,
+			SelectionStylesTypes type) {
 
-		if (geoObject instanceof AbstractCoverage || geoObject instanceof AbstractGridCoverage2DReader) {
+		if (geoObject instanceof AbstractCoverage
+				|| geoObject instanceof AbstractGridCoverage2DReader) {
 			// Wenn irgendwann mal selection für raster möglich ist, dann hier
 			// einen schöneren style erstellen.
 			return GridUtil.createDefaultStyle().featureTypeStyles().get(0);
@@ -955,7 +1062,8 @@
 	 * @param selectionIds
 	 * @return
 	 */
-	public static Rule createSelectionRule(GeometryForm geometryForm, String idPropertyName, List<String> selectionIds,
+	public static Rule createSelectionRule(GeometryForm geometryForm,
+			String idPropertyName, List<String> selectionIds,
 			SelectionStylesTypes type) {
 
 		if (idPropertyName == null)
@@ -974,7 +1082,8 @@
 		if (selectionIds.size() > 0) {
 			for (String id : selectionIds) {
 				PropertyIsEqualTo equal = FilterUtil.FILTER_FAC2.equals(
-						FilterUtil.FILTER_FAC2.property(idPropertyName), FilterUtil.FILTER_FAC2.literal(id));
+						FilterUtil.FILTER_FAC2.property(idPropertyName),
+						FilterUtil.FILTER_FAC2.literal(id));
 				equals.add(equal);
 			}
 			rule.setFilter(FilterUtil.FILTER_FAC2.or(equals));
@@ -984,14 +1093,16 @@
 		}
 
 		// Symboizers
-		Symbolizer[] symbolizers = createSelectionSymbolizers(geometryForm, type);
+		Symbolizer[] symbolizers = createSelectionSymbolizers(geometryForm,
+				type);
 
 		rule.symbolizers().addAll(Arrays.asList(symbolizers));
 
 		return rule;
 	}
 
-	public static Style createSelectionStyle(Object geoObject, SelectionStylesTypes type) {
+	public static Style createSelectionStyle(Object geoObject,
+			SelectionStylesTypes type) {
 		FeatureTypeStyle fts = createSelectionFTStyle(geoObject, type);
 		Style style = STYLE_FACTORY.createStyle();
 		style.featureTypeStyles().clear();
@@ -1000,7 +1111,8 @@
 
 	}
 
-	public static Symbolizer[] createSelectionSymbolizers(GeometryForm geometryForm, SelectionStylesTypes type) {
+	public static Symbolizer[] createSelectionSymbolizers(
+			GeometryForm geometryForm, SelectionStylesTypes type) {
 		Symbolizer[] symbolizers = new Symbolizer[0];
 
 		double size = 15.;
@@ -1019,7 +1131,8 @@
 			break;
 
 		case POLYGON:
-			symbolizers = addSelectionSymbolizersPolygon(type, symbolizers, size);
+			symbolizers = addSelectionSymbolizersPolygon(type, symbolizers,
+					size);
 			break;
 
 		case LINE:
@@ -1027,7 +1140,8 @@
 			break;
 
 		case ANY:
-			symbolizers = addSelectionSymbolizersPolygon(type, symbolizers, size);
+			symbolizers = addSelectionSymbolizersPolygon(type, symbolizers,
+					size);
 			symbolizers = addSelectionSymbolizersPoint(symbolizers);
 			// symbolizers = addSelectionSymbolizersLine(symbolizers);
 			break;
@@ -1039,17 +1153,19 @@
 		return symbolizers;
 	}
 
-	private static Symbolizer[] addSelectionSymbolizersLine(Symbolizer[] symbolizers) {
+	private static Symbolizer[] addSelectionSymbolizersLine(
+			Symbolizer[] symbolizers) {
 		LineSymbolizer ls = STYLE_BUILDER.createLineSymbolizer(Color.red, 3.);
 		symbolizers = LangUtil.extendArray(symbolizers, ls);
 
-		LineSymbolizer ls2 = STYLE_BUILDER.createLineSymbolizer(Color.white, 1.);
+		LineSymbolizer ls2 = STYLE_BUILDER
+				.createLineSymbolizer(Color.white, 1.);
 		symbolizers = LangUtil.extendArray(symbolizers, ls2);
 		return symbolizers;
 	}
 
-	private static Symbolizer[] addSelectionSymbolizersPolygon(SelectionStylesTypes type, Symbolizer[] symbolizers,
-			double size) {
+	private static Symbolizer[] addSelectionSymbolizersPolygon(
+			SelectionStylesTypes type, Symbolizer[] symbolizers, double size) {
 		String markShapeName = "";
 		if (type == SelectionStylesTypes.LeftTop2RightBottom_lines
 				|| type == SelectionStylesTypes.LeftTop2RightBottom_lines_smallgaps
@@ -1071,7 +1187,8 @@
 				Mark fillMark = STYLE_BUILDER.createMark(markShapeName);
 				fillMark.setStroke(STYLE_BUILDER.createStroke(Color.red, 3.));
 
-				Graphic fillGraphic = STYLE_BUILDER.createGraphic(null, fillMark, null);
+				Graphic fillGraphic = STYLE_BUILDER.createGraphic(null,
+						fillMark, null);
 
 				fillGraphic.setSize(FILTER_FACTORY.literal(size));
 
@@ -1079,33 +1196,39 @@
 				fill.setGraphicFill(fillGraphic);
 			}
 
-			PolygonSymbolizer polS0 = STYLE_BUILDER.createPolygonSymbolizer(outline, fill);
+			PolygonSymbolizer polS0 = STYLE_BUILDER.createPolygonSymbolizer(
+					outline, fill);
 
 			symbolizers = LangUtil.extendArray(symbolizers, polS0);
 		}
 
 		{ // White
-			Stroke outline = STYLE_BUILDER.createStroke(Color.yellow.brighter(), 1);
+			Stroke outline = STYLE_BUILDER.createStroke(
+					Color.yellow.brighter(), 1);
 
 			Fill fill = null;
 
 			if (type != SelectionStylesTypes.Outline_only) {
 				Mark fillMark = STYLE_BUILDER.createMark(markShapeName);
-				fillMark.setStroke(STYLE_BUILDER.createStroke(Color.yellow.brighter(), 1.));
-				Graphic fillGraphic = STYLE_BUILDER.createGraphic(null, fillMark, null);
+				fillMark.setStroke(STYLE_BUILDER.createStroke(
+						Color.yellow.brighter(), 1.));
+				Graphic fillGraphic = STYLE_BUILDER.createGraphic(null,
+						fillMark, null);
 				fillGraphic.setSize(FILTER_FACTORY.literal(size));
 				fill = STYLE_BUILDER.createFill();
 				fill.setGraphicFill(fillGraphic);
 			}
 
-			PolygonSymbolizer polS0 = STYLE_BUILDER.createPolygonSymbolizer(outline, fill);
+			PolygonSymbolizer polS0 = STYLE_BUILDER.createPolygonSymbolizer(
+					outline, fill);
 			// polS0.setGeometry(offsetFunction);
 			symbolizers = LangUtil.extendArray(symbolizers, polS0);
 		}
 		return symbolizers;
 	}
 
-	private static Symbolizer[] addSelectionSymbolizersPoint(Symbolizer[] symbolizers) {
+	private static Symbolizer[] addSelectionSymbolizersPoint(
+			Symbolizer[] symbolizers) {
 		PointSymbolizer ps = STYLE_FACTORY.createPointSymbolizer();
 		ps.setGraphic(SELECTION_GRAPHIC1);
 		symbolizers = LangUtil.extendArray(symbolizers, ps);
@@ -1121,16 +1244,18 @@
 	}
 
 	/**
-	 * Creates a {@link Style} for a {@link Grid} layer from a {@link ColorMap} Title will be set to
-	 * {@link GridUtil#UNTITLED_RASTER_STYLE_TITLE}
+	 * Creates a {@link Style} for a {@link Grid} layer from a {@link ColorMap}
+	 * Title will be set to {@link GridUtil#UNTITLED_RASTER_STYLE_TITLE}
 	 * 
 	 * @param colorMap
 	 *            If null, then defaultStyle for Grid will be used
 	 * @param name
-	 *            The name to give to the Style. null will result in name {@link GridUtil#UNTITLED_RASTER_STYLE_TITLE}
+	 *            The name to give to the Style. null will result in name
+	 *            {@link GridUtil#UNTITLED_RASTER_STYLE_TITLE}
 	 * 
-	 * @return Always a Style that you can apply to a {@link GridCoverage}. Style has name
-	 *         {@link GridUtil#DEFAULT_RASTER_STYLE_NAME} if no colormap was provided.
+	 * @return Always a Style that you can apply to a {@link GridCoverage}.
+	 *         Style has name {@link GridUtil#DEFAULT_RASTER_STYLE_NAME} if no
+	 *         colormap was provided.
 	 * 
 	 * 
 	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
@@ -1145,19 +1270,23 @@
 	 * @param colorMap
 	 *            If null, then defaultStyle for Grid will be used
 	 * @param name
-	 *            The name to give to the Style. null will result in name= {@link GridUtil#UNNAMED_RASTER_STYLE_NAME} or
+	 *            The name to give to the Style. null will result in name=
+	 *            {@link GridUtil#UNNAMED_RASTER_STYLE_NAME} or
 	 *            GridUtil#DEFAULT_RASTER_STYLE_NAME} (if no colorMap is given).
 	 * 
 	 * @param title
 	 *            The Title to give to the Style. null will result in title=
-	 *            {@link GridUtil#UNTITLED_RASTER_STYLE_TITLE} or {@link GridUtil#DEFAULT_RASTER_STYLE_TITLE} (if no
-	 *            colorMap is given)
+	 *            {@link GridUtil#UNTITLED_RASTER_STYLE_TITLE} or
+	 *            {@link GridUtil#DEFAULT_RASTER_STYLE_TITLE} (if no colorMap is
+	 *            given)
 	 * 
-	 * @return Always a {@link Style} that you can be applyed to a {@link GridCoverage}.
+	 * @return Always a {@link Style} that you can be applyed to a
+	 *         {@link GridCoverage}.
 	 * 
 	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
-	public static Style createStyleFromColorMap(ColorMap colorMap, String name, String title) {
+	public static Style createStyleFromColorMap(ColorMap colorMap, String name,
+			String title) {
 		if (colorMap == null)
 			return GridUtil.createDefaultStyle();
 
@@ -1185,7 +1314,8 @@
 		RuleImpl ruleImpl = new RuleImpl(symbolizers) {
 		};
 		Rule[] rules = { ruleImpl };
-		FeatureTypeStyleImpl featureTypeStyleImpl = new FeatureTypeStyleImpl(rules) {
+		FeatureTypeStyleImpl featureTypeStyleImpl = new FeatureTypeStyleImpl(
+				rules) {
 		};
 
 		Style style = STYLE_FACTORY.createStyle();
@@ -1196,7 +1326,8 @@
 	}
 
 	/**
-	 * Erzeugt einen {@link Style} aus einem {@linkplain Element JDOM-Element}, des eine SLD-Definition enthaelt
+	 * Erzeugt einen {@link Style} aus einem {@linkplain Element JDOM-Element},
+	 * des eine SLD-Definition enthaelt
 	 * 
 	 * @param element
 	 *            Element mit SLD-Definition
@@ -1219,7 +1350,8 @@
 		}
 	}
 
-	public static Style createStyleSimple(Object geoObject, Color color, Color color2) {
+	public static Style createStyleSimple(Object geoObject, Color color,
+			Color color2) {
 		if (geoObject instanceof GridCoverage2D
 				|| geoObject instanceof org.geotools.coverage.grid.io.AbstractGridCoverage2DReader) {
 			// Wenn irgendwann mal selection für raster möglich ist, dann hier
@@ -1242,12 +1374,14 @@
 
 			break;
 		case POLYGON:
-			PolygonSymbolizer polS = STYLE_BUILDER.createPolygonSymbolizer(STYLE_BUILDER.createStroke(color2),
+			PolygonSymbolizer polS = STYLE_BUILDER.createPolygonSymbolizer(
+					STYLE_BUILDER.createStroke(color2),
 					STYLE_BUILDER.createFill(color));
 			symbolizers = LangUtil.extendArray(symbolizers, polS);
 
 		case LINE:
-			LineSymbolizer ls = STYLE_BUILDER.createLineSymbolizer(STYLE_BUILDER.createStroke(color));
+			LineSymbolizer ls = STYLE_BUILDER
+					.createLineSymbolizer(STYLE_BUILDER.createStroke(color));
 			symbolizers = LangUtil.extendArray(symbolizers, ls);
 			break;
 
@@ -1255,7 +1389,8 @@
 			// In case of ANY, create a Style with polygon and point
 			// symbolizers.
 
-			polS = STYLE_BUILDER.createPolygonSymbolizer(STYLE_BUILDER.createStroke(color2),
+			polS = STYLE_BUILDER.createPolygonSymbolizer(
+					STYLE_BUILDER.createStroke(color2),
 					STYLE_BUILDER.createFill(color));
 			ps = createPointSymbolizer(color, color2);
 
@@ -1268,60 +1403,75 @@
 		}
 
 		style.featureTypeStyles().get(0).rules().clear();
-		style.featureTypeStyles().get(0).rules().add(STYLE_FACTORY.createRule());
+		style.featureTypeStyles().get(0).rules()
+				.add(STYLE_FACTORY.createRule());
 
 		style.featureTypeStyles().get(0).rules().get(0).symbolizers().clear();
-		style.featureTypeStyles().get(0).rules().get(0).symbolizers().addAll(Arrays.asList(symbolizers));
+		style.featureTypeStyles().get(0).rules().get(0).symbolizers()
+				.addAll(Arrays.asList(symbolizers));
 
 		return style;
 	}
 
-	private static PointSymbolizer createPointSymbolizer(Color color, Color color2) {
-		PointSymbolizer ps = STYLE_BUILDER.createPointSymbolizer(STYLE_BUILDER.createGraphic(null,
-				STYLE_BUILDER.createMark("circle"), null));
-		ps.getGraphic().getMarks()[0].setFill(STYLE_BUILDER.createFill(color, 0.5));
-		ps.getGraphic().getMarks()[0].setSize(STYLE_BUILDER.literalExpression(8.));
+	private static PointSymbolizer createPointSymbolizer(Color color,
+			Color color2) {
+		PointSymbolizer ps = STYLE_BUILDER.createPointSymbolizer(STYLE_BUILDER
+				.createGraphic(null, STYLE_BUILDER.createMark("circle"), null));
+		ps.getGraphic().getMarks()[0].setFill(STYLE_BUILDER.createFill(color,
+				0.5));
+		ps.getGraphic().getMarks()[0].setSize(STYLE_BUILDER
+				.literalExpression(8.));
 		ps.getGraphic().setSize(STYLE_BUILDER.literalExpression(8.));
-		ps.getGraphic().getMarks()[0].setStroke(STYLE_BUILDER.createStroke(color2));
+		ps.getGraphic().getMarks()[0].setStroke(STYLE_BUILDER
+				.createStroke(color2));
 		return ps;
 	}
 
 	/**
-	 * SLD Rules können die Paramter MinScaleDenominator und MaxScaleDenominator enthalten. Dadurch können Elemente für
-	 * manche Zoom-Stufen deaktiviert werden.
+	 * SLD Rules können die Paramter MinScaleDenominator und MaxScaleDenominator
+	 * enthalten. Dadurch können Elemente für manche Zoom-Stufen deaktiviert
+	 * werden.
 	 * 
-	 * Kommentar: "Sichtbarkeit" bezieht es nicht darauf, ob die Elemente auf dem Kartenausschnitt sichtbar sind,
-	 * sondern um die SLD Regeln, welche das SimpleFeature evt. nur Scalenabhängig zeichnen.<br/>
-	 * SK 19.6.2009:Bei einem {@link PolygonSymbolizer} zählt nicht der Rand, sondern nur ob eine Füllung vorhanden ist!
-	 * Man kann dann zwar leider nicht auf ein Rand eines Polygons ohne Fill klicken, aber dafür kann man durch die
-	 * ungefüllte Fläche klicken.
+	 * Kommentar: "Sichtbarkeit" bezieht es nicht darauf, ob die Elemente auf
+	 * dem Kartenausschnitt sichtbar sind, sondern um die SLD Regeln, welche das
+	 * SimpleFeature evt. nur Scalenabhängig zeichnen.<br/>
+	 * SK 19.6.2009:Bei einem {@link PolygonSymbolizer} zählt nicht der Rand,
+	 * sondern nur ob eine Füllung vorhanden ist! Man kann dann zwar leider
+	 * nicht auf ein Rand eines Polygons ohne Fill klicken, aber dafür kann man
+	 * durch die ungefüllte Fläche klicken.
 	 * 
 	 * @param fc
-	 *            Die zu filternde FeatureCollection. Diese wird nicht verändert.
+	 *            Die zu filternde FeatureCollection. Diese wird nicht
+	 *            verändert.
 	 * @param style
-	 *            Der Style, mit dem die Features gerendert werden (z.b. layer.getStyle() )
+	 *            Der Style, mit dem die Features gerendert werden (z.b.
+	 *            layer.getStyle() )
 	 * 
 	 * @param scaleDenominator
-	 *            Der aktuelle ScaleDenomitor für den die Sichtbarkeit ermittelt wird.
+	 *            Der aktuelle ScaleDenomitor für den die Sichtbarkeit ermittelt
+	 *            wird.
 	 * 
 	 * @see RendererUtilities.calculateOGCScale
 	 * 
-	 * @return Eine FeatureCollection in welcher nur die Features enthalten sind, welche bei aktuellen Scale mit dem
-	 *         übergebenen Style gerendert werden.
+	 * @return Eine FeatureCollection in welcher nur die Features enthalten
+	 *         sind, welche bei aktuellen Scale mit dem übergebenen Style
+	 *         gerendert werden.
 	 * 
 	 *         TODO Was ist mit raster?!
 	 * 
-	 *         TODO Das sollte man besser machen: Zuerst die FIlter der sichtbaren regeln raussuchen, und dann direkt am
-	 *         anfang damitmit mitfiltern...
+	 *         TODO Das sollte man besser machen: Zuerst die FIlter der
+	 *         sichtbaren regeln raussuchen, und dann direkt am anfang damitmit
+	 *         mitfiltern...
 	 * 
 	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public static MemoryFeatureCollection filterSLDVisibleOnly(
-			final FeatureCollection<SimpleFeatureType, SimpleFeature> fc, final Style style,
-			final Double scaleDenominator) {
+			final FeatureCollection<SimpleFeatureType, SimpleFeature> fc,
+			final Style style, final Double scaleDenominator) {
 
 		// Eine im Speicher gehaltene FeatureCollection der sichtbaren
-		final MemoryFeatureCollection fcVisible = new MemoryFeatureCollection(fc.getSchema());
+		final MemoryFeatureCollection fcVisible = new MemoryFeatureCollection(
+				fc.getSchema());
 
 		// Prüfen aller Features in der Collection
 		final Iterator<SimpleFeature> fcIt = fc.iterator();
@@ -1335,18 +1485,22 @@
 
 					// Leave out FTSs that are selection related
 					if (fts.getName() != null
-							&& fts.getName().equals(FeatureMapLayerSelectionSynchronizer.SELECTION_STYLING_FTS_NAME))
+							&& fts.getName()
+									.equals(FeatureMapLayerSelectionSynchronizer.SELECTION_STYLING_FTS_NAME))
 						continue;
 
 					final List<Rule> rules = fts.rules();
 
 					for (final Rule rule : rules) {
-						final double maxScaleDenominator = rule.getMaxScaleDenominator();
-						final double minScaleDenominator = rule.getMinScaleDenominator();
+						final double maxScaleDenominator = rule
+								.getMaxScaleDenominator();
+						final double minScaleDenominator = rule
+								.getMinScaleDenominator();
 
 						// 1. Check: Trifft die Rule auf den aktuellen Scale der
 						// JMapPane?
-						if ((minScaleDenominator > scaleDenominator) || (scaleDenominator > maxScaleDenominator)) {
+						if ((minScaleDenominator > scaleDenominator)
+								|| (scaleDenominator > maxScaleDenominator)) {
 							continue;
 						}
 
@@ -1365,21 +1519,25 @@
 						boolean passt = false;
 						for (final Symbolizer symb : rule.getSymbolizers()) {
 
-							final Geometry geom = (Geometry) feature.getDefaultGeometry();
+							final Geometry geom = (Geometry) feature
+									.getDefaultGeometry();
 
-							if ((geom instanceof MultiPoint) || (geom instanceof com.vividsolutions.jts.geom.Point)) {
+							if ((geom instanceof MultiPoint)
+									|| (geom instanceof com.vividsolutions.jts.geom.Point)) {
 								if (symb instanceof PointSymbolizer) {
 									if (((PointSymbolizer) symb).getGraphic() != null)
 										passt = true;
 									break;
 								}
-							} else if ((geom instanceof MultiLineString) || (geom instanceof LineString)) {
+							} else if ((geom instanceof MultiLineString)
+									|| (geom instanceof LineString)) {
 								if (symb instanceof LineSymbolizer) {
 									if (((LineSymbolizer) symb).getStroke() != null)
 										passt = true;
 									break;
 								}
-							} else if ((geom instanceof MultiPolygon) || (geom instanceof Polygon)) {
+							} else if ((geom instanceof MultiPolygon)
+									|| (geom instanceof Polygon)) {
 
 								if (symb instanceof PolygonSymbolizer) {
 									if (((PolygonSymbolizer) symb).getFill() != null)
@@ -1412,16 +1570,22 @@
 		} catch (final java.lang.IllegalStateException e) {
 			LOGGER.error("Iterating over the features", e);
 			/**
-			 * SK: 14.Apri 2009. It happened a few time to that fcIt.hasNext suddenly threw an exception for the
-			 * "africa countries.shp": Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: ShapeType
-			 * changed illegally from Polygon to Undefined at org.geotools.
-			 * data.shapefile.shp.ShapefileReader.nextRecord(ShapefileReader .java:452) at
-			 * org.geotools.data.shapefile.indexed. IndexedShapefileDataStore$Reader
+			 * SK: 14.Apri 2009. It happened a few time to that fcIt.hasNext
+			 * suddenly threw an exception for the "africa countries.shp":
+			 * Exception in thread "AWT-EventQueue-0"
+			 * java.lang.IllegalStateException: ShapeType changed illegally from
+			 * Polygon to Undefined at org.geotools.
+			 * data.shapefile.shp.ShapefileReader.nextRecord(ShapefileReader
+			 * .java:452) at org.geotools.data.shapefile.indexed.
+			 * IndexedShapefileDataStore$Reader
 			 * .next(IndexedShapefileDataStore.java:1272) at
-			 * org.geotools.data.FIDFeatureReader.next(FIDFeatureReader.java:92) at org
-			 * .geotools.data.FilteringFeatureReader.hasNext( FilteringFeatureReader .java:125) at
-			 * org.geotools.data.store.FeatureReaderIterator.hasNext( FeatureReaderIterator.java:44) at
-			 * schmitzm.geotools.feature.FeatureUtil .filterSLDVisibleOnly(FeatureUtil.java:216) *
+			 * org.geotools.data.FIDFeatureReader.next(FIDFeatureReader.java:92)
+			 * at org .geotools.data.FilteringFeatureReader.hasNext(
+			 * FilteringFeatureReader .java:125) at
+			 * org.geotools.data.store.FeatureReaderIterator.hasNext(
+			 * FeatureReaderIterator.java:44) at
+			 * schmitzm.geotools.feature.FeatureUtil
+			 * .filterSLDVisibleOnly(FeatureUtil.java:216) *
 			 * 
 			 */
 		}
@@ -1433,40 +1597,50 @@
 	}
 
 	/**
-	 * SLD Rules können die Paramter MinScaleDenominator und MaxScaleDenominator enthalten. Dadurch können Elemente für
-	 * manche Zoom-Stufen deaktiviert werden.
+	 * SLD Rules können die Paramter MinScaleDenominator und MaxScaleDenominator
+	 * enthalten. Dadurch können Elemente für manche Zoom-Stufen deaktiviert
+	 * werden.
 	 * 
 	 * @param fc
-	 *            Die zu filternde FeatureCollection. Diese wird nicht verändert.
+	 *            Die zu filternde FeatureCollection. Diese wird nicht
+	 *            verändert.
 	 * @param style
-	 *            Der Style, mit dem die Features gerendert werden (z.b. layer.getStyle() )
+	 *            Der Style, mit dem die Features gerendert werden (z.b.
+	 *            layer.getStyle() )
 	 * 
-	 * @return Eine FeatureCollection in welcher nur die Features enthalten sind, welche bei aktuellen Scale mit dem
-	 *         übergebenen Style gerendert werden.
+	 * @return Eine FeatureCollection in welcher nur die Features enthalten
+	 *         sind, welche bei aktuellen Scale mit dem übergebenen Style
+	 *         gerendert werden.
 	 * 
 	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public static FeatureCollection<SimpleFeatureType, SimpleFeature> filterSLDVisibleOnly(
-			final FeatureCollection<SimpleFeatureType, SimpleFeature> fc, final Style style, XMapPane xMapPane) {
+			final FeatureCollection<SimpleFeatureType, SimpleFeature> fc,
+			final Style style, XMapPane xMapPane) {
 
 		if (xMapPane == null || style == null)
 			return new EmptyFeatureCollection(fc.getSchema());
 
 		// Der "scaleDenominator" der aktuellen JMapPane
-		Double scaleDenominator = RendererUtilities.calculateOGCScale(new ReferencedEnvelope(xMapPane.getMapArea(),
-				xMapPane.getMapContext().getCoordinateReferenceSystem()), xMapPane.getBounds().width, null);
+		Double scaleDenominator = RendererUtilities.calculateOGCScale(
+				new ReferencedEnvelope(xMapPane.getMapArea(), xMapPane
+						.getMapContext().getCoordinateReferenceSystem()),
+				xMapPane.getBounds().width, null);
 
 		return filterSLDVisibleOnly(fc, style, scaleDenominator);
 	}
 
 	/**
-	 * Ermittelt fuer einen Wert den {@link ColorMapEntry} aus einer {@link ColorMap}.
+	 * Ermittelt fuer einen Wert den {@link ColorMapEntry} aus einer
+	 * {@link ColorMap}.
 	 * 
 	 * @param value
 	 *            Wert
-	 * @return {@code null}, wenn in der {@link ColorMap} kein expliziter Eintrag fuer den Wert hinterlegt ist
+	 * @return {@code null}, wenn in der {@link ColorMap} kein expliziter
+	 *         Eintrag fuer den Wert hinterlegt ist
 	 */
-	public static ColorMapEntry findColorMapEntry(ColorMap colorMap, double value) {
+	public static ColorMapEntry findColorMapEntry(ColorMap colorMap,
+			double value) {
 		for (ColorMapEntry entry : colorMap.getColorMapEntries())
 			if (value == getQuantityFromColorMapEntry(entry))
 				return entry;
@@ -1480,7 +1654,8 @@
 	 *            Farbpaletten-Eintrag
 	 */
 	public static Color getColorFromColorMapEntry(ColorMapEntry entry) {
-		if (entry == null || entry.getColor() == null || entry.getColor().evaluate(null) == null)
+		if (entry == null || entry.getColor() == null
+				|| entry.getColor().evaluate(null) == null)
 			return null;
 
 		// // Transparenz
@@ -1515,11 +1690,14 @@
 	}
 
 	/**
-	 * Liefert die Farbpalette zu einem Style, wenn der Style aus einem {@link RasterSymbolizer} erzeugt wurde.
+	 * Liefert die Farbpalette zu einem Style, wenn der Style aus einem
+	 * {@link RasterSymbolizer} erzeugt wurde.
 	 * 
 	 * @param style
-	 *            Style Wenn <code>null</code>, dann wird style auf {@link GridUtil}.createDefaultStyle() gesetzt
-	 * @return <code>null</code> wenn der Style nicht auf einem {@link RasterSymbolizer} basiert.
+	 *            Style Wenn <code>null</code>, dann wird style auf
+	 *            {@link GridUtil}.createDefaultStyle() gesetzt
+	 * @return <code>null</code> wenn der Style nicht auf einem
+	 *         {@link RasterSymbolizer} basiert.
 	 */
 	public static ColorMap getColorMapFromStyle(final Style style) {
 		final List<ColorMap> colorMapsFromStyle = getColorMapsFromStyle(style);
@@ -1531,10 +1709,12 @@
 	}
 
 	/**
-	 * Liefert alle Farbpaletten aus einem Style, wenn irgendo {@link RasterSymbolizer} enthalten sind.
+	 * Liefert alle Farbpaletten aus einem Style, wenn irgendo
+	 * {@link RasterSymbolizer} enthalten sind.
 	 * 
 	 * @param style
-	 *            Style Wenn <code>null</code>, dann wird style auf {@link GridUtil}.createDefaultStyle() gesetzt
+	 *            Style Wenn <code>null</code>, dann wird style auf
+	 *            {@link GridUtil}.createDefaultStyle() gesetzt
 	 * @return Leere Liste wenn keine RasterSymbolizer enthalten ist.
 	 */
 	public static List<ColorMap> getColorMapsFromStyle(Style style) {
@@ -1564,7 +1744,8 @@
 	 */
 	public static int getColorMapType(String typeStr) {
 		if (typeStr == null)
-			throw new IllegalArgumentException("Unknown color map type: " + typeStr);
+			throw new IllegalArgumentException("Unknown color map type: "
+					+ typeStr);
 
 		typeStr = typeStr.trim().toLowerCase();
 		if (typeStr.equals("ramp") || typeStr.equals("type_ramp"))
@@ -1608,11 +1789,14 @@
 
         </code>
 	 * 
-	 * Returns the first attribute found in the label expression of the given {@link TextSymbolizer}. If non is found
-	 * for some reason, the method tries to return the first attribute from the schema. We expect the layer to have some
-	 * attributes, because otherwise AS shouldn't even create the LabellingTab.
+	 * Returns the first attribute found in the label expression of the given
+	 * {@link TextSymbolizer}. If non is found for some reason, the method tries
+	 * to return the first attribute from the schema. We expect the layer to
+	 * have some attributes, because otherwise AS shouldn't even create the
+	 * LabellingTab.
 	 */
-	public static PropertyName getFirstPropertyName(final SimpleFeatureType ft, final TextSymbolizer textSymbolizer) {
+	public static PropertyName getFirstPropertyName(final SimpleFeatureType ft,
+			final TextSymbolizer textSymbolizer) {
 		final Expression labelExpression = textSymbolizer.getLabel();
 		try {
 			if (labelExpression instanceof PropertyName) {
@@ -1620,7 +1804,8 @@
 				return (PropertyName) labelExpression;
 			} else if (labelExpression instanceof Function) {
 				final Function filterExpression = (Function) labelExpression;
-				final FilterAttributeExtractor attExVid = new FilterAttributeExtractor(ft);
+				final FilterAttributeExtractor attExVid = new FilterAttributeExtractor(
+						ft);
 
 				attExVid.visit(filterExpression, null);
 
@@ -1635,8 +1820,8 @@
 					prop1 = attributeNames[0];
 				} else {
 
-					if (filterExpression.toString().indexOf(attributeNames[0]) < filterExpression.toString().indexOf(
-							attributeNames[1])) {
+					if (filterExpression.toString().indexOf(attributeNames[0]) < filterExpression
+							.toString().indexOf(attributeNames[1])) {
 						prop1 = attributeNames[0];
 						// prop2 = attributeNames[1];
 					} else {
@@ -1653,11 +1838,13 @@
 		}
 
 		// TODO this is not rockhard.. could NPE
-		return FilterUtil.FILTER_FAC2.property(ft.getAttributeDescriptors().get(1).getLocalName());
+		return FilterUtil.FILTER_FAC2.property(ft.getAttributeDescriptors()
+				.get(1).getLocalName());
 	}
 
 	/**
-	 * @return the {@link Color} used in the {@link Graphic} or null, if an {@link ExternalGraphic} is used.
+	 * @return the {@link Color} used in the {@link Graphic} or null, if an
+	 *         {@link ExternalGraphic} is used.
 	 * 
 	 * @param graphic
 	 *            If <code>null</code> returns <code>null</code>
@@ -1705,7 +1892,8 @@
 	}
 
 	/**
-	 * Super smart metod ;-) Needs to be extended to look at the graphic width and Geometry type.
+	 * Super smart metod ;-) Needs to be extended to look at the graphic width
+	 * and Geometry type.
 	 * 
 	 * @param geometryDescriptor
 	 * @param avgNn
@@ -1716,7 +1904,8 @@
 	}
 
 	/**
-	 * Super smart metod ;-) Needs to be extended to look at the graphic width and Geometry type.
+	 * Super smart metod ;-) Needs to be extended to look at the graphic width
+	 * and Geometry type.
 	 * 
 	 * @param geometryDescriptor
 	 * @param avgNn
@@ -1777,7 +1966,9 @@
 			return 1.0;
 		Object exprValue = expression.evaluate(null);
 
-		return (exprValue instanceof String) ? Double.valueOf((String) exprValue) : ((Number) exprValue).doubleValue();
+		return (exprValue instanceof String) ? Double
+				.valueOf((String) exprValue) : ((Number) exprValue)
+				.doubleValue();
 	}
 
 	/**
@@ -1842,12 +2033,15 @@
 			return null;
 		Object exprValue = expression.evaluate(null);
 
-		return (exprValue instanceof String) ? Double.valueOf((String) exprValue) : ((Number) exprValue).doubleValue();
+		return (exprValue instanceof String) ? Double
+				.valueOf((String) exprValue) : ((Number) exprValue)
+				.doubleValue();
 	}
 
 	/**
-	 * Returns all {@link RasterSymbolizer} that are contained in a {@link Style}. {@link RasterSymbolizer} from
-	 * {@link FeatureTypeStyle}s that are selection related are ignored.
+	 * Returns all {@link RasterSymbolizer} that are contained in a
+	 * {@link Style}. {@link RasterSymbolizer} from {@link FeatureTypeStyle}s
+	 * that are selection related are ignored.
 	 */
 	public static List<RasterSymbolizer> getRasterSymbolizers(Style style) {
 		final List<RasterSymbolizer> rsList = new ArrayList<RasterSymbolizer>();
@@ -1858,10 +2052,12 @@
 		return rsList;
 	}
 
-	public static void getRasterSymbolizers(final List<RasterSymbolizer> rsList, FeatureTypeStyle fts) {
+	public static void getRasterSymbolizers(
+			final List<RasterSymbolizer> rsList, FeatureTypeStyle fts) {
 		// Leave out FTSs that are selection related
 		if (fts.getName() != null
-				&& fts.getName().equals(FeatureMapLayerSelectionSynchronizer.SELECTION_STYLING_FTS_NAME))
+				&& fts.getName()
+						.equals(FeatureMapLayerSelectionSynchronizer.SELECTION_STYLING_FTS_NAME))
 			return;
 
 		for (Rule r : fts.rules()) {
@@ -1877,10 +2073,11 @@
 	 * Geopublisher allows to use one or two attributes for labeling, like
 	 * 
 	 * 
-	 * Returns the second attribute found in the label expression of the given {@link TextSymbolizer} or
-	 * <code>null</code>.
+	 * Returns the second attribute found in the label expression of the given
+	 * {@link TextSymbolizer} or <code>null</code>.
 	 */
-	public static PropertyName getSecondPropertyName(final SimpleFeatureType ft, final TextSymbolizer textSymbolizer) {
+	public static PropertyName getSecondPropertyName(
+			final SimpleFeatureType ft, final TextSymbolizer textSymbolizer) {
 		try {
 
 			final Expression labelExpression = textSymbolizer.getLabel();
@@ -1889,7 +2086,8 @@
 				return null;
 			} else if (labelExpression instanceof Function) {
 				final Function filterExpression = (Function) labelExpression;
-				final FilterAttributeExtractor attExVid = new FilterAttributeExtractor(ft);
+				final FilterAttributeExtractor attExVid = new FilterAttributeExtractor(
+						ft);
 
 				attExVid.visit(filterExpression, null);
 
@@ -1898,8 +2096,8 @@
 					return null;
 
 				String prop2 = null;
-				if (filterExpression.toString().indexOf(attributeNames[0]) < filterExpression.toString().indexOf(
-						attributeNames[1])) {
+				if (filterExpression.toString().indexOf(attributeNames[0]) < filterExpression
+						.toString().indexOf(attributeNames[1])) {
 					prop2 = attributeNames[1];
 				} else {
 					prop2 = attributeNames[0];
@@ -1917,12 +2115,13 @@
 	}
 
 	/**
-	 * Returns <code>null</code> or any {@link FeatureTypeStyle} contained in the given {@link Style} that is SELECTION
-	 * related.
+	 * Returns <code>null</code> or any {@link FeatureTypeStyle} contained in
+	 * the given {@link Style} that is SELECTION related.
 	 * 
 	 * @see {@link FeatureMapLayerSelectionSynchronizer#SELECTION_STYLING_FTS_NAME}
 	 */
-	public static FeatureTypeStyle getSelectionFeatureTypeStyle(final Style style) {
+	public static FeatureTypeStyle getSelectionFeatureTypeStyle(
+			final Style style) {
 
 		if (style == null)
 			return null;
@@ -1933,7 +2132,8 @@
 			FeatureTypeStyle fts = style.featureTypeStyles().get(ii);
 
 			if (fts.getName() != null
-					&& fts.getName().equals(FeatureMapLayerSelectionSynchronizer.SELECTION_STYLING_FTS_NAME)) {
+					&& fts.getName()
+							.equals(FeatureMapLayerSelectionSynchronizer.SELECTION_STYLING_FTS_NAME)) {
 				return style.featureTypeStyles().get(ii);
 			}
 		}
@@ -2035,15 +2235,16 @@
 
 	/**
 	 * @param style
-	 *            A {@link Style} to search for the first {@link TextSymbolizer} that will be used for the given
-	 *            {@link SimpleFeature}.
+	 *            A {@link Style} to search for the first {@link TextSymbolizer}
+	 *            that will be used for the given {@link SimpleFeature}.
 	 * 
 	 * @author Stefan A. Tzeggai (wikisquare.de) für CPA Systems GmbH A. Tzeggai
 	 * 
-	 * @return <code>null</code> or the first {@link TextSymbolizer} found in the style that applies to the
-	 *         {@link SimpleFeature}.
+	 * @return <code>null</code> or the first {@link TextSymbolizer} found in
+	 *         the style that applies to the {@link SimpleFeature}.
 	 */
-	public static TextSymbolizer getTextSymbolizer(final Style style, final SimpleFeature f) {
+	public static TextSymbolizer getTextSymbolizer(final Style style,
+			final SimpleFeature f) {
 		if (f == null)
 			return null;
 		try {
@@ -2078,12 +2279,14 @@
 
 	/**
 	 * @param style
-	 *            A {@link Style} to search for all {@link TextSymbolizer}s . No guarantee, that any one of them will
-	 *            ever be used for any feature (think about filters).
+	 *            A {@link Style} to search for all {@link TextSymbolizer}s . No
+	 *            guarantee, that any one of them will ever be used for any
+	 *            feature (think about filters).
 	 * 
 	 * @author Stefan A. Tzeggai (wikisquare.de) für CPA Systems GmbH A. Tzeggai
 	 * 
-	 * @return {@link List} or all {@link TextSymbolizer}s found in the {@link Style}.
+	 * @return {@link List} or all {@link TextSymbolizer}s found in the
+	 *         {@link Style}.
 	 */
 	public static List<TextSymbolizer> getTextSymbolizers(final Style style) {
 		List<TextSymbolizer> results = new ArrayList<TextSymbolizer>();
@@ -2107,14 +2310,17 @@
 
 	/**
 	 * @param symbolizers
-	 *            List of Symbolizers to search for all {@link TextSymbolizer}s . No guarantee, that any one of them
-	 *            will ever be used for any feature (think about filters).
+	 *            List of Symbolizers to search for all {@link TextSymbolizer}s
+	 *            . No guarantee, that any one of them will ever be used for any
+	 *            feature (think about filters).
 	 * 
 	 * @author Stefan A. Tzeggai (wikisquare.de) für CPA Systems GmbH A. Tzeggai
 	 * 
-	 * @return {@link List} or all {@link TextSymbolizer}s found in the given symbolizers.
+	 * @return {@link List} or all {@link TextSymbolizer}s found in the given
+	 *         symbolizers.
 	 */
-	public static List<TextSymbolizer> getTextSymbolizers(Symbolizer[] symbolizers) {
+	public static List<TextSymbolizer> getTextSymbolizers(
+			Symbolizer[] symbolizers) {
 		List<TextSymbolizer> results = new ArrayList<TextSymbolizer>();
 		try {
 			if (symbolizers != null) {
@@ -2136,14 +2342,17 @@
 
 	/**
 	 * @param style
-	 *            A {@link Style} to search for all {@link TextSymbolizer}s . No guarantee, that any one of them will
-	 *            ever be used for any feature (think about filters).
+	 *            A {@link Style} to search for all {@link TextSymbolizer}s . No
+	 *            guarantee, that any one of them will ever be used for any
+	 *            feature (think about filters).
 	 * 
 	 * @author Stefan A. Tzeggai (wikisquare.de) für CPA Systems GmbH A. Tzeggai
 	 * 
-	 * @return {@link List} or all {@link TextSymbolizer}s found in the {@link Style}.
+	 * @return {@link List} or all {@link TextSymbolizer}s found in the
+	 *         {@link Style}.
 	 */
-	public static List<TextSymbolizer> getVisibleTextSymbolizers(final Style style) {
+	public static List<TextSymbolizer> getVisibleTextSymbolizers(
+			final Style style) {
 		List<TextSymbolizer> results = new ArrayList<TextSymbolizer>();
 		try {
 			if (style != null) {
@@ -2156,8 +2365,9 @@
 							/*
 							 * We are comparing it to AsUtil.alwaysfalsefilter
 							 * 
-							 * public static final PropertyIsEqualTo allwaysFalseFilter = ff2.equals(ff2 .literal("1"),
-							 * ff2.literal("2"));
+							 * public static final PropertyIsEqualTo
+							 * allwaysFalseFilter = ff2.equals(ff2
+							 * .literal("1"), ff2.literal("2"));
 							 */
 							try {
 
@@ -2165,14 +2375,20 @@
 								if (f instanceof And) {
 									And and = (And) f;
 									if (and.getChildren() != null) {
-										Filter candidateF = and.getChildren().get(0);
+										Filter candidateF = and.getChildren()
+												.get(0);
 										if (candidateF instanceof PropertyIsEqualTo) {
 											final PropertyIsEqualTo compare = (PropertyIsEqualTo) candidateF;
 											if (compare.getExpression1() instanceof Literal
 													&& compare.getExpression2() instanceof Literal) {
-												Literal test1 = (Literal) compare.getExpression1();
-												Literal test2 = (Literal) compare.getExpression2();
-												if (test1.toString().equals("1") && test2.toString().equals("2")) {
+												Literal test1 = (Literal) compare
+														.getExpression1();
+												Literal test2 = (Literal) compare
+														.getExpression2();
+												if (test1.toString()
+														.equals("1")
+														&& test2.toString()
+																.equals("2")) {
 													// This TextSymbolizer is
 													// disabled using
 													// ASUtil.allwaysFalseFilter
@@ -2186,7 +2402,9 @@
 									}
 								}
 							} catch (Exception e) {
-								LOGGER.debug("Checking for textSymbolizer allwaysFalseFilter", e);
+								LOGGER.debug(
+										"Checking for textSymbolizer allwaysFalseFilter",
+										e);
 							}
 						}
 
@@ -2210,7 +2428,8 @@
 	 *            The first {@link Style}
 	 * @param style2file
 	 *            A {@link File} pointing to the second {@link Style}
-	 * @return <code>true</code> is they are different, ignoring any XML fomatting.
+	 * @return <code>true</code> is they are different, ignoring any XML
+	 *         fomatting.
 	 */
 	public static boolean isStyleDifferent(Style style1, File style2file) {
 		try {
@@ -2242,7 +2461,8 @@
 	 *            The first {@link Style}
 	 * @param style2
 	 *            The second {@link Style} to compare to
-	 * @return <code>true</code> is they are different, ignoring any XML fomatting.
+	 * @return <code>true</code> is they are different, ignoring any XML
+	 *         fomatting.
 	 */
 	public static boolean isStyleDifferent(Style style1, Style style2) {
 		try {
@@ -2253,8 +2473,8 @@
 			return !style1string.equals(style2string);
 
 		} catch (Exception e) {
-			LOGGER.debug("Compating styles " + style1 + " and " + style2 + " failed. So we assume they are different.",
-					e);
+			LOGGER.debug("Compating styles " + style1 + " and " + style2
+					+ " failed. So we assume they are different.", e);
 			return true;
 		}
 
@@ -2288,7 +2508,8 @@
 	 * @param inputStream
 	 *            {@link InputStream} to read the SLD from
 	 * 
-	 * @return An {@link Array} of {@link Style}s, can be length==0. null if file not exists
+	 * @return An {@link Array} of {@link Style}s, can be length==0. null if
+	 *         file not exists
 	 * 
 	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
@@ -2296,11 +2517,14 @@
 
 		Style[] styles = null;
 		try {
-			SLDParser stylereader = new SLDParser(StylingUtil.STYLE_FACTORY, inputStream);
+			SLDParser stylereader = new SLDParser(StylingUtil.STYLE_FACTORY,
+					inputStream);
 			styles = stylereader.readXML();
 			return styles;
 		} catch (Exception e) {
-			LOGGER.warn(" ... no styles recognized. Return 'new Style[] { null }' ", e);
+			LOGGER.warn(
+					" ... no styles recognized. Return 'new Style[] { null }' ",
+					e);
 			return new Style[] { null };
 		}
 
@@ -2312,8 +2536,8 @@
 	 * @param url
 	 *            {@link URL} to read the SLD from
 	 * 
-	 * @return An {@link Array} of {@link Style}s, can be length==0 if no UserStyles in SLD file. null if file not
-	 *         exists
+	 * @return An {@link Array} of {@link Style}s, can be length==0 if no
+	 *         UserStyles in SLD file. null if file not exists
 	 * 
 	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
@@ -2329,14 +2553,18 @@
 		}
 	}
 
-	public static StyledLayerDescriptor loadStyledLayerDescriptor(InputStream inputStream) {
+	public static StyledLayerDescriptor loadStyledLayerDescriptor(
+			InputStream inputStream) {
 		StyledLayerDescriptor sld = null;
 		try {
-			SLDParser stylereader = new SLDParser(StylingUtil.STYLE_FACTORY, inputStream);
+			SLDParser stylereader = new SLDParser(StylingUtil.STYLE_FACTORY,
+					inputStream);
 			sld = stylereader.parseSLD();
 			return sld;
 		} catch (Exception e) {
-			LOGGER.warn(" ... no StyledLayerDescriptor recognized. Returning null ", e);
+			LOGGER.warn(
+					" ... no StyledLayerDescriptor recognized. Returning null ",
+					e);
 			return sld;
 		}
 	}
@@ -2344,22 +2572,27 @@
 	public static StyledLayerDescriptor loadStyledLayerDescriptor(Reader reader) {
 		StyledLayerDescriptor sld = null;
 		try {
-			SLDParser stylereader = new SLDParser(StylingUtil.STYLE_FACTORY, reader);
+			SLDParser stylereader = new SLDParser(StylingUtil.STYLE_FACTORY,
+					reader);
 			sld = stylereader.parseSLD();
 			return sld;
 		} catch (Exception e) {
-			LOGGER.warn(" ... no StyledLayerDescriptor recognized. Returning null ", e);
+			LOGGER.warn(
+					" ... no StyledLayerDescriptor recognized. Returning null ",
+					e);
 			return sld;
 		}
 	}
 
-	static public ColorMap parseColormapToSld(File colormapFile) throws IOException {
+	static public ColorMap parseColormapToSld(File colormapFile)
+			throws IOException {
 		return parseColormapToSld(DataUtilities.fileToURL(colormapFile));
 	}
 
 	/**
-	 * Creates a Geotools Colormap containing all the Color Palette definitions defined in the File. The File may have
-	 * different formats. Supported formats are<br/>
+	 * Creates a Geotools Colormap containing all the Color Palette definitions
+	 * defined in the File. The File may have different formats. Supported
+	 * formats are<br/>
 	 * <ul>
 	 * <li>gdalinfo output</li>
 	 * </ul>
@@ -2369,7 +2602,9 @@
 	 * 
 	 * TODO Stefan Tzeggai Support gdal xml.aux format!
 	 * 
-	 * @see http ://osgeo-org.1803224.n2.nabble.com/gdal-dev-Color-palette-file-for -use-in-rgb2pct-td4493744.html
+	 * @see http 
+	 *      ://osgeo-org.1803224.n2.nabble.com/gdal-dev-Color-palette-file-for
+	 *      -use-in-rgb2pct-td4493744.html
 	 */
 	static public ColorMap parseColormapToSld(URL url) throws IOException {
 
@@ -2388,56 +2623,66 @@
 
 				Matcher matcher = GDALINFO_COLORMAP_RGBA.matcher(line);
 				if (matcher.find()) {
-					Color color = new Color(Integer.valueOf(matcher.group(2)), Integer.valueOf(matcher.group(3)),
-							Integer.valueOf(matcher.group(4)), Integer.valueOf(matcher.group(5)));
+					Color color = new Color(Integer.valueOf(matcher.group(2)),
+							Integer.valueOf(matcher.group(3)),
+							Integer.valueOf(matcher.group(4)),
+							Integer.valueOf(matcher.group(5)));
 
 					// Arrays verlängern
 					labels = LangUtil.extendArray(labels, "");
 					colors = LangUtil.extendArray(colors, color);
-					quantities = LangUtil.extendArray(quantities, Double.valueOf(matcher.group(1)));
+					quantities = LangUtil.extendArray(quantities,
+							Double.valueOf(matcher.group(1)));
 
 					// Zur nächsten Zeile springen
 					continue;
 				}
 			} catch (Exception e) {
-				LOGGER.warn("Error parsing a line to ColorMapEntry. Line = '" + line + "'. Skipped.", e);
+				LOGGER.warn("Error parsing a line to ColorMapEntry. Line = '"
+						+ line + "'. Skipped.", e);
 			}
 
 			try {
 				Matcher matcher = GDALINFO_COLORMAP_RGB.matcher(line);
 				if (matcher.find()) {
-					Color color = new Color(Integer.valueOf(matcher.group(2)), Integer.valueOf(matcher.group(3)),
+					Color color = new Color(Integer.valueOf(matcher.group(2)),
+							Integer.valueOf(matcher.group(3)),
 							Integer.valueOf(matcher.group(4)));
 
 					// Arrays verlängern
 					labels = LangUtil.extendArray(labels, "");
 					colors = LangUtil.extendArray(colors, color);
-					quantities = LangUtil.extendArray(quantities, Double.valueOf(matcher.group(1)));
+					quantities = LangUtil.extendArray(quantities,
+							Double.valueOf(matcher.group(1)));
 
 					// Zur nächsten Zeile springen
 					continue;
 
 				}
 			} catch (Exception e) {
-				LOGGER.warn("Error parsing a line to ColorMapEntry. Line = '" + line + "'. Skipped.", e);
+				LOGGER.warn("Error parsing a line to ColorMapEntry. Line = '"
+						+ line + "'. Skipped.", e);
 			}
 		}
 
 		int type = ColorMap.TYPE_VALUES;
-		ColorMap createColorMap = STYLE_BUILDER.createColorMap(labels, quantities, colors, type);
+		ColorMap createColorMap = STYLE_BUILDER.createColorMap(labels,
+				quantities, colors, type);
 		return createColorMap;
 	}
 
 	/**
-	 * Unless {@link ColorMap} has no methods to remove an entry this method creates a new {@link ColorMap} with the
-	 * identical entries except the one to remove.
+	 * Unless {@link ColorMap} has no methods to remove an entry this method
+	 * creates a new {@link ColorMap} with the identical entries except the one
+	 * to remove.
 	 * 
 	 * @param colorMap
 	 *            the color map to remove entries from
 	 * @param colorMapEntry
 	 *            the entry to remove
 	 */
-	public static ColorMap removeColorMapEntry(ColorMap colorMap, ColorMapEntry colorMapEntry) {
+	public static ColorMap removeColorMapEntry(ColorMap colorMap,
+			ColorMapEntry colorMapEntry) {
 		ColorMap newColorMap = new ColorMapImpl();
 		applyColorMapProperties(colorMap, newColorMap);
 
@@ -2450,8 +2695,9 @@
 	}
 
 	/**
-	 * Unless {@link ColorMap} has no methods to remove an entry this method creates a new {@link ColorMap} with the
-	 * identical entries except the one to remove.
+	 * Unless {@link ColorMap} has no methods to remove an entry this method
+	 * creates a new {@link ColorMap} with the identical entries except the one
+	 * to remove.
 	 * 
 	 * @param colorMap
 	 *            the color map to remove entries from
@@ -2471,8 +2717,8 @@
 	}
 
 	/**
-	 * Creates a copy of the given {@link Style}, removing any {@link FeatureTypeStyle}s that are only SELECTION
-	 * related.
+	 * Creates a copy of the given {@link Style}, removing any
+	 * {@link FeatureTypeStyle}s that are only SELECTION related.
 	 * 
 	 * @see {@link FeatureMapLayerSelectionSynchronizer#SELECTION_STYLING_FTS_NAME}
 	 */
@@ -2489,7 +2735,8 @@
 			FeatureTypeStyle fts = style.featureTypeStyles().get(ii);
 
 			if (fts.getName() != null
-					&& fts.getName().equals(FeatureMapLayerSelectionSynchronizer.SELECTION_STYLING_FTS_NAME)) {
+					&& fts.getName()
+							.equals(FeatureMapLayerSelectionSynchronizer.SELECTION_STYLING_FTS_NAME)) {
 				cleanStyle.featureTypeStyles().remove(ii);
 				break;
 			}
@@ -2505,11 +2752,13 @@
 	 * @param oldColor
 	 * @param newColor
 	 */
-	public static void replaceFillColor(Fill fill, Color oldColor, Color newColor) {
+	public static void replaceFillColor(Fill fill, Color oldColor,
+			Color newColor) {
 		if (fill == null)
 			return;
 
-		if ((fill.getColor() != null) && (getColorFromExpression(fill.getColor()).equals(oldColor)))
+		if ((fill.getColor() != null)
+				&& (getColorFromExpression(fill.getColor()).equals(oldColor)))
 			fill.setColor(STYLE_BUILDER.colorExpression(newColor));
 
 		replaceGraphicColor(fill.getGraphicFill(), oldColor, newColor);
@@ -2525,7 +2774,8 @@
 	 * 
 	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
-	public static void replaceGraphicColor(Graphic graphic, Color oldColor, Color newColor) {
+	public static void replaceGraphicColor(Graphic graphic, Color oldColor,
+			Color newColor) {
 		if (graphic == null)
 			return;
 
@@ -2547,7 +2797,8 @@
 	 * 
 	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
-	public static void replaceLineSymbolizerColor(LineSymbolizer ps, Color oldColor, Color newColor) {
+	public static void replaceLineSymbolizerColor(LineSymbolizer ps,
+			Color oldColor, Color newColor) {
 		if (ps == null)
 			return;
 
@@ -2559,7 +2810,8 @@
 	 * 
 	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
-	public static void replacePointSymbolizerColor(PointSymbolizer ps, Color oldColor, Color newColor) {
+	public static void replacePointSymbolizerColor(PointSymbolizer ps,
+			Color oldColor, Color newColor) {
 		if (ps == null)
 			return;
 
@@ -2574,7 +2826,8 @@
 	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 * @param ps
 	 */
-	public static void replacePolygonSymbolizerColor(PolygonSymbolizer ps, Color oldColor, Color newColor) {
+	public static void replacePolygonSymbolizerColor(PolygonSymbolizer ps,
+			Color oldColor, Color newColor) {
 		replaceFillColor(ps.getFill(), oldColor, newColor);
 		replaceStrokeColor(ps.getStroke(), oldColor, newColor);
 	}
@@ -2586,11 +2839,14 @@
 	 * @param oldColor
 	 * @param newColor
 	 */
-	public static void replaceStrokeColor(Stroke stroke, Color oldColor, Color newColor) {
+	public static void replaceStrokeColor(Stroke stroke, Color oldColor,
+			Color newColor) {
 		if (stroke == null)
 			return;
 
-		if ((stroke.getColor() != null) && (StylingUtil.getColorFromExpression(stroke.getColor()).equals(oldColor)))
+		if ((stroke.getColor() != null)
+				&& (StylingUtil.getColorFromExpression(stroke.getColor())
+						.equals(oldColor)))
 			stroke.setColor(StylingUtil.STYLE_BUILDER.colorExpression(newColor));
 
 		replaceGraphicColor(stroke.getGraphicFill(), oldColor, newColor);
@@ -2604,7 +2860,8 @@
 	 * 
 	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
-	public static void replaceSymbolizerColor(Symbolizer symb, Color oldColor, Color newColor) {
+	public static void replaceSymbolizerColor(Symbolizer symb, Color oldColor,
+			Color newColor) {
 		if (symb == null)
 			return;
 
@@ -2626,44 +2883,55 @@
 	}
 
 	/**
-	 * Saves the {@link Style} to OGC SLD. Overwrites any existing file. If a FeatureTypeStyle for selection is used, it
-	 * is automatically removed. This method also checks, whether the style is actually differing from any existing
-	 * style in the {@link File}. If there is no difference, the file is not saved again (that is more svn friendly).<br/>
+	 * Saves the {@link Style} to OGC SLD. Overwrites any existing file. If a
+	 * FeatureTypeStyle for selection is used, it is automatically removed. This
+	 * method also checks, whether the style is actually differing from any
+	 * existing style in the {@link File}. If there is no difference, the file
+	 * is not saved again (that is more svn friendly).<br/>
 	 * All text ist converted to UTF-8.
 	 * 
 	 * @param origStyle
-	 *            {@link Style} to save. Any selectino related FeatureTypeStyle will be removed.
+	 *            {@link Style} to save. Any selectino related FeatureTypeStyle
+	 *            will be removed.
 	 * 
 	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 * 
-	 * @return <code>true</code> if the file was really written. <code>false</code> means, that the existing file
-	 *         already contained the same content and was not touched.
+	 * @return <code>true</code> if the file was really written.
+	 *         <code>false</code> means, that the existing file already
+	 *         contained the same content and was not touched.
 	 * @throws IOException
 	 */
-	public static final boolean saveStyleToSld(Style origStyle, File exportFile) throws IOException {
+	public static final boolean saveStyleToSld(Style origStyle, File exportFile)
+			throws IOException {
 		return saveStyleToSld(origStyle, exportFile, false);
 	}
 
 	/**
-	 * Saves the {@link Style} to OGC SLD. Overwrites any existing file. If a FeatureTypeStyle for selection is used, it
-	 * is automatically removed. This method also checks, whether the style is actually differing from any existing
-	 * style in the {@link File}. If there is no difference, the file is not saved again (that is more svn friendly).<br/>
+	 * Saves the {@link Style} to OGC SLD. Overwrites any existing file. If a
+	 * FeatureTypeStyle for selection is used, it is automatically removed. This
+	 * method also checks, whether the style is actually differing from any
+	 * existing style in the {@link File}. If there is no difference, the file
+	 * is not saved again (that is more svn friendly).<br/>
 	 * All text ist converted to UTF-8.
 	 * 
 	 * @param origStyle
-	 *            {@link Style} to save. Any selectino related FeatureTypeStyle will be removed.
+	 *            {@link Style} to save. Any selectino related FeatureTypeStyle
+	 *            will be removed.
 	 * 
 	 * @param optimized
-	 *            If <code>true</code> any redundant information (typically used by AtlasStyler for GUI state and
-	 *            internal information) is thrown away.
+	 *            If <code>true</code> any redundant information (typically used
+	 *            by AtlasStyler for GUI state and internal information) is
+	 *            thrown away.
 	 * 
 	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 * 
-	 * @return <code>true</code> if the file was really written. <code>false</code> means, that the existing file
-	 *         already contained the same content and was not touched.
+	 * @return <code>true</code> if the file was really written.
+	 *         <code>false</code> means, that the existing file already
+	 *         contained the same content and was not touched.
 	 * @throws IOException
 	 */
-	public static final boolean saveStyleToSld(Style origStyle, File exportFile, boolean optimized) throws IOException {
+	public static final boolean saveStyleToSld(Style origStyle,
+			File exportFile, boolean optimized) throws IOException {
 		try {
 
 			// Wenn Datei nicht mit .sld endet, die Dateierweiterung
@@ -2691,7 +2959,8 @@
 				String string = nativeWritten.getBuffer().toString();
 
 				if (optimized) {
-					string = string.replaceFirst("\\<sld", OPTIMIZED_COMMENT + "\n<sld");
+					string = string.replaceFirst("\\<sld", OPTIMIZED_COMMENT
+							+ "\n<sld");
 				}
 				IOUtils.write(string, output, "UTF-8");
 			} finally {
@@ -2700,15 +2969,18 @@
 			}
 
 			LOGGER.debug("Validating stored file " + exportFile + "... ");
-			List<Exception> validateSld = validateSld(new FileInputStream(exportFile));
+			List<Exception> validateSld = validateSld(new FileInputStream(
+					exportFile));
 			if (validateSld.size() > 0) {
-				LOGGER.error(exportFile + " is not valid SLD: " + validateSld.size() + " exceptions");
+				LOGGER.error(exportFile + " is not valid SLD: "
+						+ validateSld.size() + " exceptions");
 			}
 			for (Exception e : validateSld) {
 				LOGGER.warn(exportFile + " " + e.getLocalizedMessage(), e);
 			}
 		} catch (TransformerException te) {
-			LOGGER.warn("TransformerException while saving Style to SLD file " + exportFile, te);
+			LOGGER.warn("TransformerException while saving Style to SLD file "
+					+ exportFile, te);
 			return false;
 		}
 		return true;
@@ -2717,17 +2989,9 @@
 	/**
 	 * United multiple feature type styles that work on the same feature type
 	 */
-	private static Style optimizeStyle(Style style) {
+	public static Style optimizeStyle(Style style) {
 
 		Style oStyle = STYLE_BUILDER.createStyle();
-		
-		// TODO
-		/*
-		 * Wenn ich ein "AND (A,B)" finde, wo A eines meine Immertrue ist, dann mache daraus B 
-		 * Wenn ich ein "AND (A,B)" finde, wo A eines meine False ist, dann schmeisse die ganze Rule weg?!?! 
-		 * Wenn ich ein "ODER(A,A)" finde, dann mache daraus A 
-		 */
-		
 
 		Map<Name, List<Rule>> ftsRules = new java.util.HashMap<Name, List<Rule>>();
 
@@ -2735,17 +2999,48 @@
 			for (Name name : fts.featureTypeNames()) {
 				if (ftsRules.get(name) == null)
 					ftsRules.put(name, fts.rules());
-				else 
+				else
 					ftsRules.get(name).addAll(fts.rules());
 			}
 		}
 
 		for (Name ftsName : ftsRules.keySet()) {
-			oStyle.featureTypeStyles()
-					.add(STYLE_BUILDER.createFeatureTypeStyle(ftsName.toString(),
+			oStyle.featureTypeStyles().add(
+					STYLE_BUILDER.createFeatureTypeStyle(ftsName.toString(),
 							ftsRules.get(ftsName).toArray(new Rule[0])));
 		}
 
+		// In jedem FTS alle Rules durchgehen und Filter vereinfachen
+		for (FeatureTypeStyle fts : oStyle.featureTypeStyles()) {
+			for (Rule r : new ArrayList<Rule>(fts.rules())) {
+				// TODO
+				/*
+				 * Wenn ich ein "AND (A,B)" finde, wo A eines meiner Immertrue
+				 * ist, dann mache daraus B Wenn ich ein "AND (A,B)" finde, wo A
+				 * eines meiner Immerfalse ist, dann schmeisse die ganze Rule
+				 * weg?!?! Wenn ich ein "ODER(A,A)" finde, dann mache daraus A
+				 */
+
+				Filter f = r.getFilter();
+				/*
+				 * <pre> <ogc:And> <ogc:PropertyIsEqualTo>
+				 * <ogc:Literal>ALL_LABEL_CLASSES_DISABLED</ogc:Literal>
+				 * <ogc:Literal>YES</ogc:Literal> </ogc:PropertyIsEqualTo>
+				 * <ogc:PropertyIsEqualTo> <ogc:Literal>1</ogc:Literal>
+				 * <ogc:Literal>1</ogc:Literal> </ogc:PropertyIsEqualTo>
+				 * </ogc:And></pre>
+				 */
+				if (f instanceof AndImpl) {
+					AndImpl and = (AndImpl) f;
+					if (and.getChildren().get(0).equals(RL_DISABLED_FILTER)) {
+						fts.rules().remove(r);
+						continue;
+					}
+				}
+
+			}
+		}
+
 		return oStyle;
 	}
 
@@ -2766,7 +3061,9 @@
 				try {
 					is.close();
 				} catch (IOException e1) {
-					LOGGER.error("Closing the InputStream after the Seriouse Exception failed", e1);
+					LOGGER.error(
+							"Closing the InputStream after the Seriouse Exception failed",
+							e1);
 				}
 			return el;
 		}
@@ -2775,26 +3072,31 @@
 	}
 
 	/**
-	 * True if the given XMl coming from the {@link InputStream} is validates against SLD 1.0
+	 * True if the given XMl coming from the {@link InputStream} is validates
+	 * against SLD 1.0
 	 */
 	public static boolean validates(InputStream is) {
 		return validateSld(is).size() == 0;
 	}
 
 	/**
-	 * Exports the {@link Style} to OGC SLD. If a FeatureTypeStyle for selection is used, it is automatically removed.
+	 * Exports the {@link Style} to OGC SLD. If a FeatureTypeStyle for selection
+	 * is used, it is automatically removed.
 	 * 
 	 * @param exportStyle
-	 *            {@link Style} to save. Any selectino related FeatureTypeStyle will be removed.
+	 *            {@link Style} to save. Any selectino related FeatureTypeStyle
+	 *            will be removed.
 	 * 
 	 * @param optimized
-	 *            If <code>true</code> any redundant information (typically used by AtlasStyler for GUI state and
-	 *            internal information) is thrown away.
+	 *            If <code>true</code> any redundant information (typically used
+	 *            by AtlasStyler for GUI state and internal information) is
+	 *            thrown away.
 	 * 
 	 * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 * @throws TransformerException
 	 */
-	public static final void saveStyleToSLD(Style exportStyle, OutputStream exportStream, boolean optimized)
+	public static final void saveStyleToSLD(Style exportStyle,
+			OutputStream exportStream, boolean optimized)
 			throws TransformerException {
 
 		exportStyle = removeSelectionFeatureTypeStyle(exportStyle);
@@ -2820,8 +3122,9 @@
 	}
 
 	/**
-	 * AtlasStyler has a fixed system that allows to use one or two label attributes. If two are used, the are seperated
-	 * by ": ". This mehtod stes one or two ProperybaName fields.
+	 * AtlasStyler has a fixed system that allows to use one or two label
+	 * attributes. If two are used, the are seperated by ": ". This mehtod stes
+	 * one or two ProperybaName fields.
 	 * 
 	 * @param symbolizer
 	 *            the {@link TextSymbolizer} to call setLabel(Expression) on.
@@ -2830,13 +3133,17 @@
 	 * @param literalLabelField2
 	 *            may be <code>null</code>
 	 */
-	public static void setDoublePropertyName(final TextSymbolizer symbolizer, final PropertyName literalLabelField1,
+	public static void setDoublePropertyName(final TextSymbolizer symbolizer,
+			final PropertyName literalLabelField1,
 			final PropertyName literalLabelField2) {
-		if (literalLabelField2 != null && !literalLabelField2.getPropertyName().isEmpty()
+		if (literalLabelField2 != null
+				&& !literalLabelField2.getPropertyName().isEmpty()
 				&& !literalLabelField2.toString().equalsIgnoreCase("-")) {
 			final Literal trenner = FilterUtil.FILTER_FAC2.literal(": ");
-			final Function f3 = FilterUtil.FILTER_FAC2.function("strConcat", trenner, literalLabelField2);
-			final Function bothExpression = FilterUtil.FILTER_FAC2.function("strConcat", literalLabelField1, f3);
+			final Function f3 = FilterUtil.FILTER_FAC2.function("strConcat",
+					trenner, literalLabelField2);
+			final Function bothExpression = FilterUtil.FILTER_FAC2.function(
+					"strConcat", literalLabelField1, f3);
 			LOGGER.debug("Extended label expression is now: " + bothExpression);
 			symbolizer.setLabel(bothExpression);
 		} else {
@@ -2852,7 +3159,8 @@
 	 * @param opacity
 	 *            Transparenzwert
 	 */
-	public static void setOpacityForColorMapEntry(ColorMapEntry entry, double opacity) {
+	public static void setOpacityForColorMapEntry(ColorMapEntry entry,
+			double opacity) {
 		if (entry != null)
 			entry.setOpacity(STYLE_BUILDER.literalExpression(opacity));
 	}
@@ -2865,7 +3173,8 @@
 	 * @param quantity
 	 *            neuer Wert
 	 */
-	public static void setQuantityForColorMapEntry(ColorMapEntry entry, double quantity) {
+	public static void setQuantityForColorMapEntry(ColorMapEntry entry,
+			double quantity) {
 		if (entry != null)
 			entry.setQuantity(STYLE_BUILDER.literalExpression(quantity));
 	}
@@ -2903,7 +3212,8 @@
 	}
 
 	/**
-	 * Converts a {@link StyledLayerDescriptor} or any of it's subcomponents to XML.
+	 * Converts a {@link StyledLayerDescriptor} or any of it's subcomponents to
+	 * XML.
 	 * 
 	 * @throws TransformerException
 	 */
@@ -2911,7 +3221,8 @@
 		return SLDTRANSFORMER.transform(sld);
 	}
 
-	public static boolean validates(FeatureTypeStyle fts) throws IOException, TransformerException {
+	public static boolean validates(FeatureTypeStyle fts) throws IOException,
+			TransformerException {
 		// Bytestream not file!
 		Style s = STYLE_BUILDER.createStyle();
 		s.featureTypeStyles().add(fts);
@@ -2929,7 +3240,8 @@
 		}
 	}
 
-	public static boolean isStyleDifferent(FeatureTypeStyle fts1, FeatureTypeStyle fts2) {
+	public static boolean isStyleDifferent(FeatureTypeStyle fts1,
+			FeatureTypeStyle fts2) {
 		Style style1 = STYLE_BUILDER.createStyle();
 		style1.featureTypeStyles().add(fts1);
 
@@ -2944,17 +3256,20 @@
 		return xml;
 	}
 
-	public static void correctGeometryPropertyname(final SimpleFeatureType schema, Symbolizer sym) {
+	public static void correctGeometryPropertyname(
+			final SimpleFeatureType schema, Symbolizer sym) {
 		String newGpn = sym.getGeometryPropertyName();
 
 		if (schema != null) {
 			// If we have a schema,
-			GeometryDescriptor geometryDescriptor = schema.getGeometryDescriptor();
+			GeometryDescriptor geometryDescriptor = schema
+					.getGeometryDescriptor();
 			if (geometryDescriptor != null)
 				newGpn = geometryDescriptor.getName().toString();
 
 			if (newGpn != null) {
-				NameImpl found = FeatureUtil.findBestMatchingAttribute(schema, newGpn);
+				NameImpl found = FeatureUtil.findBestMatchingAttribute(schema,
+						newGpn);
 				if (found != null)
 					newGpn = found.getLocalPart();
 				else
@@ -2967,7 +3282,8 @@
 	}
 
 	/***************************************************************************
-	 * Copies all Values from one {@link TextSymbolizer} to another {@link TextSymbolizer}
+	 * Copies all Values from one {@link TextSymbolizer} to another
+	 * {@link TextSymbolizer}
 	 * 
 	 * @param from
 	 *            {@link TextSymbolizer} source
@@ -2977,7 +3293,8 @@
 	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 
-	public static void copyAllValues(final TextSymbolizer from, final TextSymbolizer to) {
+	public static void copyAllValues(final TextSymbolizer from,
+			final TextSymbolizer to) {
 		to.setLabel(from.getLabel());
 		to.setPriority(from.getPriority());
 
@@ -2985,10 +3302,14 @@
 
 		final FilterFactory2 ff2 = FeatureUtil.FILTER_FACTORY2;
 
-		to.getFonts()[0].setFontFamily(ff2.literal(from.getFonts()[0].getFontFamily().toString()));
-		to.getFonts()[0].setFontSize(ff2.literal(from.getFonts()[0].getFontSize().toString()));
-		to.getFonts()[0].setFontWeight(ff2.literal(from.getFonts()[0].getFontWeight().toString()));
-		to.getFonts()[0].setFontStyle(ff2.literal(from.getFonts()[0].getFontStyle().toString()));
+		to.getFonts()[0].setFontFamily(ff2.literal(from.getFonts()[0]
+				.getFontFamily().toString()));
+		to.getFonts()[0].setFontSize(ff2.literal(from.getFonts()[0]
+				.getFontSize().toString()));
+		to.getFonts()[0].setFontWeight(ff2.literal(from.getFonts()[0]
+				.getFontWeight().toString()));
+		to.getFonts()[0].setFontStyle(ff2.literal(from.getFonts()[0]
+				.getFontStyle().toString()));
 	}
 
 }



More information about the Schmitzm-commits mailing list