[Schmitzm-commits] r406 - in branches/1.0-gt2-2.6/src: schmitzm/geotools/styling skrueger/geotools

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Sep 14 20:06:28 CEST 2009


Author: alfonx
Date: 2009-09-14 20:06:27 +0200 (Mon, 14 Sep 2009)
New Revision: 406

Modified:
   branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java
   branches/1.0-gt2-2.6/src/skrueger/geotools/StyledLayerUtil.java
Log:
* GP-Feature: Improved Raster SLD editing in 

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java	2009-09-14 15:43:28 UTC (rev 405)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java	2009-09-14 18:06:27 UTC (rev 406)
@@ -397,23 +397,37 @@
 	 * @return <code>null</code> wenn der Style nicht auf einem
 	 *         {@link RasterSymbolizer} basiert.
 	 */
-	public static ColorMap getColorMapFromStyle(Style style) {
+	public static ColorMap getColorMapFromStyle(final Style style) {
+		final List<ColorMap> colorMapsFromStyle = getColorMapsFromStyle(style);
+		if (colorMapsFromStyle.size()>0) return colorMapsFromStyle.get(0);
+		else return null;
 
+	}
+
+	/**
+	 * 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
+	 * @return Leere Liste wenn keine RasterSymbolizer enthalten ist.
+	 */
+	public static List<ColorMap> getColorMapsFromStyle(Style style) {
+
 		if (style == null)
 			style = GridUtil.createDefaultStyle();
 
-		FeatureTypeStyle[] fts = style.getFeatureTypeStyles();
-		if (fts == null || fts.length == 0)
-			return null;
-		Rule[] rule = fts[0].getRules();
-		if (rule == null || rule.length == 0)
-			return null;
-		Symbolizer[] symb = rule[0].getSymbolizers();
-		if (symb == null || symb.length == 0
-				|| !(symb[0] instanceof RasterSymbolizer))
-			return null;
-		return ((RasterSymbolizer) symb[0]).getColorMap();
+		final List<RasterSymbolizer> rasterSymbolizers = getRasterSymbolizers(style);
 
+		final List<ColorMap> colorMaps = new ArrayList<ColorMap>();
+
+		for (final RasterSymbolizer rs : rasterSymbolizers) {
+			if (rs.getColorMap() != null) {
+				colorMaps.add(rs.getColorMap());
+			}
+		}
+
+		return colorMaps;
 	}
 
 	/**

Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/StyledLayerUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/StyledLayerUtil.java	2009-09-14 15:43:28 UTC (rev 405)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/StyledLayerUtil.java	2009-09-14 18:06:27 UTC (rev 406)
@@ -1020,7 +1020,7 @@
 		 */
 		ColorModel colorModel = null;
 		if (!isStyleable(styledRaster)
-				|| (isStyleable(styledRaster) && styledRaster.getStyle() != null)) {
+				|| (isStyleable(styledRaster) && styledRaster.getStyle() == null)) {
 			colorModel = getColorModel(styledRaster);
 		}
 



More information about the Schmitzm-commits mailing list