[Schmitzm-commits] r390 - branches/1.0-gt2-2.6/src/schmitzm/geotools/styling

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sun Sep 13 10:52:14 CEST 2009


Author: alfonx
Date: 2009-09-13 10:52:13 +0200 (Sun, 13 Sep 2009)
New Revision: 390

Modified:
   branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java
Log:
* After reading a Style from File we have to close the Stream in a finally block.

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-13 08:37:26 UTC (rev 389)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java	2009-09-13 08:52:13 UTC (rev 390)
@@ -373,16 +373,15 @@
 						colorMapMax + 1, colorMapMax + 2), new NumberRange(
 						colorMapMax + 1, higherEnd)));
 		if (colorMapMin < colorMapMax)
-			categories.put(colorMapMin - 10, new Category(
-					"_autoNoData2_",
+			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),
+					// new NumberRange(colorMapMax + 3, colorMapMax + 4),
 					NumberRange.create(lowerStart, colorMapMin - 1)
-//					new NumberRange(lowerStart, colorMapMin - 1)
-			));
+			// new NumberRange(lowerStart, colorMapMin - 1)
+					));
 
 		// Create the GridSampleDimension
 		GridSampleDimension gsd = new GridSampleDimension(name, categories
@@ -439,119 +438,137 @@
 				return entry;
 		return null;
 	}
-	
+
 	/**
-	 * 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
+	 * 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) {
-	  if ( sourceColorMap == null || destColormap == null )
-	    return;
-	  destColormap.setExtendedColors( sourceColorMap.getExtendedColors() );
-	  destColormap.setType( sourceColorMap.getType() );
+	public static void applyColorMapProperties(ColorMap sourceColorMap,
+			ColorMap destColormap) {
+		if (sourceColorMap == null || destColormap == null)
+			return;
+		destColormap.setExtendedColors(sourceColorMap.getExtendedColors());
+		destColormap.setType(sourceColorMap.getType());
 	}
-	
+
 	/**
-	 * 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 idx      the entry index 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 idx
+	 *            the entry index to remove
 	 */
 	public static ColorMap removeColorMapEntry(ColorMap colorMap, int idx) {
-      ColorMap newColorMap = new ColorMapImpl();
-      applyColorMapProperties(colorMap, newColorMap);
+		ColorMap newColorMap = new ColorMapImpl();
+		applyColorMapProperties(colorMap, newColorMap);
 
-      ColorMapEntry[] entry = colorMap.getColorMapEntries();
-      for (int i=0; i<entry.length; i++)
-        if ( i != idx )
-          newColorMap.addColorMapEntry(entry[i]);
-      
-      return newColorMap;
+		ColorMapEntry[] entry = colorMap.getColorMapEntries();
+		for (int i = 0; i < entry.length; i++)
+			if (i != idx)
+				newColorMap.addColorMapEntry(entry[i]);
+
+		return newColorMap;
 	}
-	
-    /**
-     * 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) {
-      ColorMap newColorMap = new ColorMapImpl();
-      applyColorMapProperties(colorMap, newColorMap);
 
-      ColorMapEntry[] entry = colorMap.getColorMapEntries();
-      for (int i=0; i<entry.length; i++)
-        if ( entry[i] != colorMapEntry )
-          newColorMap.addColorMapEntry(entry[i]);
-      
-      return newColorMap;
-    }
+	/**
+	 * 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) {
+		ColorMap newColorMap = new ColorMapImpl();
+		applyColorMapProperties(colorMap, newColorMap);
 
-    /**
-     * 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) {
-      colorMap.addColorMapEntry(colorMapEntry);
-      return sortColorMap(colorMap);
-    }
+		ColorMapEntry[] entry = colorMap.getColorMapEntries();
+		for (int i = 0; i < entry.length; i++)
+			if (entry[i] != colorMapEntry)
+				newColorMap.addColorMapEntry(entry[i]);
 
-    /**
-     * Sorts a {@link ColorMap} according to the value of its
-     * entries.
-     * @param colorMap the color map to sort
-     */
-    public static ColorMap sortColorMap(ColorMap colorMap) {
-      ColorMap newColorMap = new ColorMapImpl();
-      applyColorMapProperties(colorMap, newColorMap);
+		return newColorMap;
+	}
 
-      // Put all color map entries in a sorted map (with
-      // collision lists!)
-      SortedMap<Double,Vector<ColorMapEntry>> sortedEntries = new TreeMap<Double, Vector<ColorMapEntry>>();
-      for (ColorMapEntry entry : colorMap.getColorMapEntries()) {
-        double quantity = getQuantityFromColorMapEntry(entry);
-        Vector<ColorMapEntry> collisionList = sortedEntries.get( quantity );
-        if ( collisionList == null ) {
-          collisionList = new Vector<ColorMapEntry>();
-          sortedEntries.put(quantity, collisionList);
-        }
-        collisionList.add(entry);
-      }
-      
-      // According to the order of the sorted map, put all
-      // color map entries to the new ColorMap
-      for (Vector<ColorMapEntry> collisionList : sortedEntries.values())
-        for (ColorMapEntry entry : collisionList)
-          newColorMap.addColorMapEntry(entry);
-      
-      return newColorMap;
-    }
+	/**
+	 * 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) {
+		colorMap.addColorMapEntry(colorMapEntry);
+		return sortColorMap(colorMap);
+	}
 
-    /**
+	/**
+	 * Sorts a {@link ColorMap} according to the value of its entries.
+	 * 
+	 * @param colorMap
+	 *            the color map to sort
+	 */
+	public static ColorMap sortColorMap(ColorMap colorMap) {
+		ColorMap newColorMap = new ColorMapImpl();
+		applyColorMapProperties(colorMap, newColorMap);
+
+		// Put all color map entries in a sorted map (with
+		// collision lists!)
+		SortedMap<Double, Vector<ColorMapEntry>> sortedEntries = new TreeMap<Double, Vector<ColorMapEntry>>();
+		for (ColorMapEntry entry : colorMap.getColorMapEntries()) {
+			double quantity = getQuantityFromColorMapEntry(entry);
+			Vector<ColorMapEntry> collisionList = sortedEntries.get(quantity);
+			if (collisionList == null) {
+				collisionList = new Vector<ColorMapEntry>();
+				sortedEntries.put(quantity, collisionList);
+			}
+			collisionList.add(entry);
+		}
+
+		// According to the order of the sorted map, put all
+		// color map entries to the new ColorMap
+		for (Vector<ColorMapEntry> collisionList : sortedEntries.values())
+			for (ColorMapEntry entry : collisionList)
+				newColorMap.addColorMapEntry(entry);
+
+		return newColorMap;
+	}
+
+	/**
 	 * Returns the color map type specified by a given string.
-	 * @param typeStr a string
+	 * 
+	 * @param typeStr
+	 *            a string
 	 * @see ColorMap#getType()
 	 */
 	public static int getColorMapType(String typeStr) {
-	  if ( typeStr == null )
-	    throw new IllegalArgumentException("Unknown color map type: "+typeStr);
-	  
-	  typeStr = typeStr.trim().toLowerCase();
-	  if ( typeStr.equals("ramp") || typeStr.equals("type_ramp") )
-	    return ColorMap.TYPE_RAMP;
-      if ( typeStr.equals("intervals") || typeStr.equals("type_intervals") )
-        return ColorMap.TYPE_INTERVALS;
-      if ( typeStr.equals("values") || typeStr.equals("type_values") )
-        return ColorMap.TYPE_VALUES;
+		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"))
+			return ColorMap.TYPE_RAMP;
+		if (typeStr.equals("intervals") || typeStr.equals("type_intervals"))
+			return ColorMap.TYPE_INTERVALS;
+		if (typeStr.equals("values") || typeStr.equals("type_values"))
+			return ColorMap.TYPE_VALUES;
+
+		throw new IllegalArgumentException("Unknown color map type: " + typeStr);
 	}
 
 	/**
@@ -561,14 +578,15 @@
 	 *         ist
 	 */
 	public static ColorMap cloneColorMap(ColorMap colorMap) {
-// MS: Leider kommt der DuplicatingStyleVisitor nicht damit klar, dass
-//     der SLDParser Value und Opacity als String setzt. Und selbst wenn
-//     man dies fixed sind Value und Opacity nach dem Clonen NULL.
-//     --> zurueck zu meinem alten Code!! :-)
-//		DuplicatingStyleVisitor duplicatingStyleVisitor = new DuplicatingStyleVisitor();
-//		colorMap.accept(duplicatingStyleVisitor);
-//		ColorMap clone = (ColorMap)duplicatingStyleVisitor.getCopy(); 
-//		return clone;
+		// MS: Leider kommt der DuplicatingStyleVisitor nicht damit klar, dass
+		// der SLDParser Value und Opacity als String setzt. Und selbst wenn
+		// man dies fixed sind Value und Opacity nach dem Clonen NULL.
+		// --> zurueck zu meinem alten Code!! :-)
+		// DuplicatingStyleVisitor duplicatingStyleVisitor = new
+		// DuplicatingStyleVisitor();
+		// colorMap.accept(duplicatingStyleVisitor);
+		// ColorMap clone = (ColorMap)duplicatingStyleVisitor.getCopy();
+		// return clone;
 
 		if (colorMap == null)
 			return null;
@@ -581,21 +599,21 @@
 	}
 
 	/**
-     * Kopiert einen {@link ColorMapEntry}.
-     * 
-     * @return <code>null</code> wenn der uebergebene ColorMapEntry
-     *         <code>null</code> ist
-     */
-    public static ColorMapEntry cloneColorMapEntry(ColorMapEntry colorMapEntry) {
-      if (colorMapEntry == null)
-          return null;
-      
-      return createColorMapEntry(colorMapEntry.getLabel(),
-              getQuantityFromColorMapEntry(colorMapEntry),
-              getColorFromColorMapEntry(colorMapEntry),
-              getOpacityFromColorMapEntry(colorMapEntry));
-    }
+	 * Kopiert einen {@link ColorMapEntry}.
+	 * 
+	 * @return <code>null</code> wenn der uebergebene ColorMapEntry
+	 *         <code>null</code> ist
+	 */
+	public static ColorMapEntry cloneColorMapEntry(ColorMapEntry colorMapEntry) {
+		if (colorMapEntry == null)
+			return null;
 
+		return createColorMapEntry(colorMapEntry.getLabel(),
+				getQuantityFromColorMapEntry(colorMapEntry),
+				getColorFromColorMapEntry(colorMapEntry),
+				getOpacityFromColorMapEntry(colorMapEntry));
+	}
+
 	/**
 	 * Prueft, ob zwei {@link ColorMap}-Instanzen gleich sind.
 	 * 
@@ -695,18 +713,18 @@
 	 * @return <code>null</code> wenn der uebergebene ColorMapEntry
 	 *         <code>null</code> ist
 	 */
-	public static ColorMapEntry  ColorMapEntry(ColorMapEntry colorMapEntry) {
+	public static ColorMapEntry ColorMapEntry(ColorMapEntry colorMapEntry) {
 		DuplicatingStyleVisitor duplicatingStyleVisitor = new DuplicatingStyleVisitor();
 		colorMapEntry.accept(duplicatingStyleVisitor);
-		return (ColorMapEntry)duplicatingStyleVisitor.getCopy();
-		
-//		if (colorMapEntry == null)
-//			return null;
-//
-//		return createColorMapEntry(colorMapEntry.getLabel(),
-//				getQuantityFromColorMapEntry(colorMapEntry),
-//				getColorFromColorMapEntry(colorMapEntry),
-//				getOpacityFromColorMapEntry(colorMapEntry));
+		return (ColorMapEntry) duplicatingStyleVisitor.getCopy();
+
+		// if (colorMapEntry == null)
+		// return null;
+		//
+		// return createColorMapEntry(colorMapEntry.getLabel(),
+		// getQuantityFromColorMapEntry(colorMapEntry),
+		// getColorFromColorMapEntry(colorMapEntry),
+		// getOpacityFromColorMapEntry(colorMapEntry));
 	}
 
 	/**
@@ -1007,16 +1025,9 @@
 	 *         Kr&uuml;ger</a>
 	 */
 	public static Style[] loadSLD(InputStream inputStream) {
-		final InputStream inputStream2 = inputStream;
-		if (inputStream2 == null) {
-			return null;
-		}
 
-		// LOGGER.debug("Loading styles from inputStream...");
-
 		SLDParser stylereader;
-		stylereader = new SLDParser(StylingUtil.STYLE_FACTORY);
-		stylereader.setInput(inputStream);
+		stylereader = new SLDParser(StylingUtil.STYLE_FACTORY, inputStream);
 		Style[] styles = stylereader.readXML();
 
 		if (styles[0] == null) {
@@ -1031,48 +1042,6 @@
 		// This is the main successful exit form loadSLD
 		return styles;
 	}
-//
-//	/**
-//	 * Loads {@link Style}s from a SLD {@link InputStream} without setting a
-//	 * {@link Charset}
-//	 * 
-//	 * @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
-//	 * 
-//	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-//	 *         Kr&uuml;ger</a>
-//	 * 
-//	 * @deprecated
-//	 */
-//	public static Style[] loadSLDOld(InputStream inputStream) {
-//		final InputStream inputStream2 = inputStream;
-//		if (inputStream2 == null) {
-//			return null;
-//		}
-//
-//		// Reader reader = new UTF8Reader(inputStream2);
-//
-//		LOGGER.debug("Loading styles from inputStream...");
-//
-//		SLDParser stylereader;
-//		stylereader = new SLDParser(StylingUtil.STYLE_FACTORY, inputStream2);
-//		Style[] styles = stylereader.readXML();
-//
-//		if (styles[0] == null) {
-//			LOGGER
-//					.warn(" ... no Styles recognized in inputStream. Will return empty styles[] array!");
-//		} else {
-//			LOGGER.debug(" ... loaded " + styles.length
-//					+ " styles from inputStream, first style's name= "
-//					+ styles[0].getName());
-//		}
-//
-//		// This is the main successful exit form loadSLD
-//		return styles;
-//	}
 
 	/**
 	 * Loads {@link Style}s from a SLD {@link File}
@@ -1088,12 +1057,14 @@
 	public static Style[] loadSLD(File sldFile) throws FileNotFoundException {
 		LOGGER.debug("Loading styles from File...");
 
-		final Style[] loadedSLD = loadSLD(new FileInputStream(sldFile));
-
-		// TODO Maybe check if names and titles should be set to default
-		// values...
-
-		return loadedSLD;
+		FileInputStream inputStream = null;
+		try {
+			inputStream = new FileInputStream(sldFile);
+			final Style[] loadedSLD = loadSLD(inputStream);
+			return loadedSLD;
+		} finally {
+			IOUtils.closeQuietly(inputStream);
+		}
 	}
 
 	/**
@@ -1183,8 +1154,8 @@
 	 *         Kr&uuml;ger</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(
@@ -1229,9 +1200,10 @@
 						// gibt einen LineSymbolizer für ein PointLayer an.
 						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 (symb instanceof PointSymbolizer) {
@@ -1480,60 +1452,58 @@
 	public static Style clone(Style style) {
 		DuplicatingStyleVisitor duplicatingStyleVisitor = new DuplicatingStyleVisitor();
 		style.accept(duplicatingStyleVisitor);
-		return (Style)duplicatingStyleVisitor.getCopy();
-		
-//
-//		String xml;
-//		try {
-//			xml = SLDTRANSFORMER.transform(style);
-//
-//			SLDParser stylereader;
-//			stylereader = new SLDParser(StylingUtil.STYLE_FACTORY,
-//					new StringInputStream(xml));
-//			Style[] styles = stylereader.readXML();
-//
-//			return styles[0];
-//		} catch (TransformerException e) {
-//			ExceptionMonitor.show(null, e);
-//			return null;
-//		}
+		return (Style) duplicatingStyleVisitor.getCopy();
+
+		//
+		// String xml;
+		// try {
+		// xml = SLDTRANSFORMER.transform(style);
+		//
+		// SLDParser stylereader;
+		// stylereader = new SLDParser(StylingUtil.STYLE_FACTORY,
+		// new StringInputStream(xml));
+		// Style[] styles = stylereader.readXML();
+		//
+		// return styles[0];
+		// } catch (TransformerException e) {
+		// ExceptionMonitor.show(null, e);
+		// return null;
+		// }
 	}
 
-	
 	/**
-	 * Clones a {@link Symbolizer} using the {@link DuplicatingStyleVisitor}. 
+	 * Clones a {@link Symbolizer} using the {@link DuplicatingStyleVisitor}.
 	 */
 	public static Symbolizer clone(Symbolizer sym) {
 		DuplicatingStyleVisitor duplicatingStyleVisitor = new DuplicatingStyleVisitor();
 		sym.accept(duplicatingStyleVisitor);
-		return (Symbolizer)duplicatingStyleVisitor.getCopy();
+		return (Symbolizer) duplicatingStyleVisitor.getCopy();
 
-//		Style style = STYLE_BUILDER.createStyle(sym); // TODO Mag ich das?
-//
-//		Filter allwaysTrueFilter = FilterUtil.FILTER_FAC2.equals(
-//				FilterUtil.FILTER_FAC2.literal("1"), FilterUtil.FILTER_FAC2
-//						.literal("1"));
-//
-//		style.getFeatureTypeStyles()[0].getRules()[0]
-//				.setFilter(allwaysTrueFilter);
-//
-//		String xml;
-//		try {
-//			xml = SLDTRANSFORMER.transform(style);
-//
-//			SLDParser stylereader;
-//			stylereader = new SLDParser(StylingUtil.STYLE_FACTORY,
-//					new StringInputStream(xml));
-//			Style[] styles = stylereader.readXML();
-//
-//			return (Symbolizer) styles[0].getFeatureTypeStyles()[0].getRules()[0]
-//					.getSymbolizers()[0];
-//		} catch (TransformerException e) {
-//			ExceptionMonitor.show(null, e);
-//			return STYLE_FACTORY.createPointSymbolizer(); // TODO Abhängig vom
-//			// sym geometry type
-//		}
-		
+		// Style style = STYLE_BUILDER.createStyle(sym); // TODO Mag ich das?
+		//
+		// Filter allwaysTrueFilter = FilterUtil.FILTER_FAC2.equals(
+		// FilterUtil.FILTER_FAC2.literal("1"), FilterUtil.FILTER_FAC2
+		// .literal("1"));
+		//
+		// style.getFeatureTypeStyles()[0].getRules()[0]
+		// .setFilter(allwaysTrueFilter);
+		//
+		// String xml;
+		// try {
+		// xml = SLDTRANSFORMER.transform(style);
+		//
+		// SLDParser stylereader;
+		// stylereader = new SLDParser(StylingUtil.STYLE_FACTORY,
+		// new StringInputStream(xml));
+		// Style[] styles = stylereader.readXML();
+		//
+		// return (Symbolizer) styles[0].getFeatureTypeStyles()[0].getRules()[0]
+		// .getSymbolizers()[0];
+		// } catch (TransformerException e) {
+		// ExceptionMonitor.show(null, e);
+		// return STYLE_FACTORY.createPointSymbolizer(); // TODO Abhängig vom
+		// // sym geometry type
+		// }
 
 	}
 
@@ -1548,33 +1518,32 @@
 	public static Graphic clone(Graphic graphic) {
 		DuplicatingStyleVisitor duplicatingStyleVisitor = new DuplicatingStyleVisitor();
 		graphic.accept(duplicatingStyleVisitor);
-		return (Graphic)duplicatingStyleVisitor.getCopy();
-		
-		
-//		try {
-//			PointSymbolizer ps = STYLE_FACTORY.createPointSymbolizer(graphic,
-//					"ACHTUNG");
-//
-//			Style style = STYLE_BUILDER.createStyle(ps);
-//
-//			final String xml = SLDTRANSFORMER.transform(style);
-//
-//			SLDParser stylereader;
-//			stylereader = new SLDParser(StylingUtil.STYLE_FACTORY,
-//					new StringInputStream(xml));
-//			Style[] styles = stylereader.readXML();
-//
-//			PointSymbolizer clonedPs = (PointSymbolizer) styles[0]
-//					.getFeatureTypeStyles()[0].getRules()[0].getSymbolizers()[0];
-//
-//			Graphic clonedG = clonedPs.getGraphic();
-//
-//			return clonedG;
-//
-//		} catch (TransformerException e) {
-//			LOGGER.error("Cloning a Graphic", e);
-//		}
-//		return null;
+		return (Graphic) duplicatingStyleVisitor.getCopy();
+
+		// try {
+		// PointSymbolizer ps = STYLE_FACTORY.createPointSymbolizer(graphic,
+		// "ACHTUNG");
+		//
+		// Style style = STYLE_BUILDER.createStyle(ps);
+		//
+		// final String xml = SLDTRANSFORMER.transform(style);
+		//
+		// SLDParser stylereader;
+		// stylereader = new SLDParser(StylingUtil.STYLE_FACTORY,
+		// new StringInputStream(xml));
+		// Style[] styles = stylereader.readXML();
+		//
+		// PointSymbolizer clonedPs = (PointSymbolizer) styles[0]
+		// .getFeatureTypeStyles()[0].getRules()[0].getSymbolizers()[0];
+		//
+		// Graphic clonedG = clonedPs.getGraphic();
+		//
+		// return clonedG;
+		//
+		// } catch (TransformerException e) {
+		// LOGGER.error("Cloning a Graphic", e);
+		// }
+		// return null;
 	}
 
 	/**
@@ -1892,7 +1861,8 @@
 				// The labeltext is read from the SLD. Its either the title
 				// directly, or interpreted as OneLine Code
 				// ****************************************************************************
-//				final String rawText = rule.getDescription().getTitle().toString();
+				// final String rawText =
+				// rule.getDescription().getTitle().toString();
 				final String rawText = rule.getTitle();
 
 				Translation labelT = new Translation();



More information about the Schmitzm-commits mailing list