[Schmitzm-commits] r2004 - in trunk: schmitzm-core/src/main/java/de/schmitzm/lang schmitzm-core/src/main/java/de/schmitzm/regex schmitzm-gt/src/main/java/de/schmitzm/geotools/gui schmitzm-gt/src/main/java/de/schmitzm/geotools/io schmitzm-gt/src/main/java/de/schmitzm/geotools/styling schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/chartsymbols

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Thu May 24 15:34:18 CEST 2012


Author: alfonx
Date: 2012-05-24 15:34:18 +0200 (Thu, 24 May 2012)
New Revision: 2004

Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java
   trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/JMapEditorPane.java
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/LayeredMapPane.java
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/io/GeoImportUtil.java
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerUtil.java
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StylingUtil.java
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/chartsymbols/ChartGraphic.java
Log:
Documentation and some RegEx-Optimierungen...

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java	2012-05-24 13:25:49 UTC (rev 2003)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java	2012-05-24 13:34:18 UTC (rev 2004)
@@ -85,8 +85,8 @@
  * @version 1.0
  */
 public class LangUtil {
-    private static NumberFormat DEFAULT_DELAY_FORMAT = new DecimalFormat("0.00");
-  
+	private static NumberFormat DEFAULT_DELAY_FORMAT = new DecimalFormat("0.00");
+
 	/** Eine Sekunde in Millisekunden. */
 	public static final long SEC_MILLIS = 1000;
 	/** Eine Minute in Millisekunden. */
@@ -106,10 +106,10 @@
 	final static Pattern onlyZerosRegEx = Pattern.compile("^([\\s0.,]*)$");
 
 	/** Dummy day representing the 01.01.0001. */
-	public static final Date DAY1 = new GregorianCalendar(1,Calendar.JANUARY,1).getTime();
-    /** Dummy day representing the 02.01.0001. */
-    public static final Date DAY2 = new GregorianCalendar(1,Calendar.JANUARY,2).getTime();
-	
+	public static final Date DAY1 = new GregorianCalendar(1, Calendar.JANUARY, 1).getTime();
+	/** Dummy day representing the 02.01.0001. */
+	public static final Date DAY2 = new GregorianCalendar(1, Calendar.JANUARY, 2).getTime();
+
 	/**
 	 * Date formatter for "dd.MM.yyyy [HH:mm:ss]".
 	 */
@@ -361,27 +361,27 @@
 		return combinedDateCal.getTime();
 	}
 
-    /**
-     * Returns a new date which combines the date and time information of several date objects.
-     * 
-     * @param date
-     *            date the date information is taken from
-     * @param time
-     *            time in milliseconds of day
-     */
-    public static Date combineDate(Date date, long timeMillis) {
-      int dayMillis = (int) (timeMillis % DAY_MILLIS);
-      GregorianCalendar cal = new GregorianCalendar();
-      cal.set(Calendar.HOUR_OF_DAY, 0);
-      cal.set(Calendar.MINUTE,      0);
-      cal.set(Calendar.SECOND,      0);
-      cal.set(Calendar.MILLISECOND, 0);
-      cal.add(Calendar.MILLISECOND, dayMillis);
-      Date time = cal.getTime();
-      return combineDate(date, time);
-    }
+	/**
+	 * Returns a new date which combines the date and time information of several date objects.
+	 * 
+	 * @param date
+	 *            date the date information is taken from
+	 * @param time
+	 *            time in milliseconds of day
+	 */
+	public static Date combineDate(Date date, long timeMillis) {
+		int dayMillis = (int) (timeMillis % DAY_MILLIS);
+		GregorianCalendar cal = new GregorianCalendar();
+		cal.set(Calendar.HOUR_OF_DAY, 0);
+		cal.set(Calendar.MINUTE, 0);
+		cal.set(Calendar.SECOND, 0);
+		cal.set(Calendar.MILLISECOND, 0);
+		cal.add(Calendar.MILLISECOND, dayMillis);
+		Date time = cal.getTime();
+		return combineDate(date, time);
+	}
 
-    /**
+	/**
 	 * Returns a {@link Date} which represents the given day and time in GMT time zone.<br>
 	 * <b>For example:</b><br>
 	 * The given date is 01.01.2011, 00:00 (in CET). Then this method returns 01.01.2011, 01:00, because the timezone
@@ -475,16 +475,16 @@
 			dateStr = dateStr.trim();
 			for (DateFormat format : formats)
 				try {
-				    if ( format instanceof SimpleDateFormat ) {
-				      // Datum im Format "dd-mm-yyyy" verursacht fuer Format 
-				      // "yyyy-mm-dd" KEINE Exception sondern fuehrt zu falschem Datum
-				      // --> Pruefen, ob (erste) Position des "-" in Pattern mit (erster)
-				      //     Position des "-" im Datums-String uebereinstimmt.
-				      String pattern = ((SimpleDateFormat)format).toPattern();
-				      if ( pattern.indexOf('-') != dateStr.indexOf('-') ||
-				           pattern.indexOf('.') != dateStr.indexOf('.') )
-				        continue;
-				    }
+					if (format instanceof SimpleDateFormat) {
+						// Datum im Format "dd-mm-yyyy" verursacht fuer Format
+						// "yyyy-mm-dd" KEINE Exception sondern fuehrt zu falschem Datum
+						// --> Pruefen, ob (erste) Position des "-" in Pattern mit (erster)
+						// Position des "-" im Datums-String uebereinstimmt.
+						String pattern = ((SimpleDateFormat) format).toPattern();
+						if (pattern.indexOf('-') != dateStr.indexOf('-')
+								|| pattern.indexOf('.') != dateStr.indexOf('.'))
+							continue;
+					}
 					Date date = format.parse(dateStr);
 					return date;
 				} catch (Exception err) {
@@ -497,28 +497,32 @@
 
 	/**
 	 * Returns the delay (since a start time) in seconds.
-	 * @param startMillis start offset
+	 * 
+	 * @param startMillis
+	 *            start offset
 	 */
-    public static double getDelaySeconds(long startMillis) {
-      long delayMillis = System.currentTimeMillis() - startMillis;
-      double delaySecs = delayMillis*1.0 / SEC_MILLIS;
-      return delaySecs;
-    }
+	public static double getDelaySeconds(long startMillis) {
+		long delayMillis = System.currentTimeMillis() - startMillis;
+		double delaySecs = delayMillis * 1.0 / SEC_MILLIS;
+		return delaySecs;
+	}
 
-    /**
-     * Returns the delay (since a start time) in seconds.
-     * @param startMillis start offset
-     * @param format formatter to format the seconds value (if {@code null} a format with
-     *               2 fraction digits is used)
-     */
-    public static String getDelaySeconds(long startMillis, NumberFormat format) {
-      if ( format == null )
-        format = DEFAULT_DELAY_FORMAT;
-      double delaySecs = getDelaySeconds(startMillis);
-      return format.format(delaySecs);
-    }
+	/**
+	 * Returns the delay (since a start time) in seconds.
+	 * 
+	 * @param startMillis
+	 *            start offset
+	 * @param format
+	 *            formatter to format the seconds value (if {@code null} a format with 2 fraction digits is used)
+	 */
+	public static String getDelaySeconds(long startMillis, NumberFormat format) {
+		if (format == null)
+			format = DEFAULT_DELAY_FORMAT;
+		double delaySecs = getDelaySeconds(startMillis);
+		return format.format(delaySecs);
+	}
 
-    /**
+	/**
 	 * Returns an exception stack as string.
 	 */
 	public static String getStackTraceFromException(Throwable err) {
@@ -730,20 +734,21 @@
 	}
 
 	/**
-     * Haengt eine beliebige Anzahl von Strings hintereinander und fuegt zwischen den Strings einen Trenner ein.
-     * {@code null}-Werte werden beruecksichtigt<br>
-     * Bemerkung: Dies ist eine Workaround-Methode, da die die ueberladendenen Methoden mit "Object..."
-     *            nicht von allen Compilern richtig interpretiert werden! 
-     * @param sep
-     *            Trenner
-     * @param str
-     *            aneinanderzuhaengende Stings
-     */
-    public static String stringConcatWithSepIncludeNulls(String sep, Object... str) {
-        return stringConcatWithSep(sep, null, false, str);
-    }
+	 * Haengt eine beliebige Anzahl von Strings hintereinander und fuegt zwischen den Strings einen Trenner ein.
+	 * {@code null}-Werte werden beruecksichtigt<br>
+	 * Bemerkung: Dies ist eine Workaround-Methode, da die die ueberladendenen Methoden mit "Object..." nicht von allen
+	 * Compilern richtig interpretiert werden!
+	 * 
+	 * @param sep
+	 *            Trenner
+	 * @param str
+	 *            aneinanderzuhaengende Stings
+	 */
+	public static String stringConcatWithSepIncludeNulls(String sep, Object... str) {
+		return stringConcatWithSep(sep, null, false, str);
+	}
 
-    /**
+	/**
 	 * Haengt eine beliebige Anzahl von Strings hintereinander und fuegt zwischen den Strings einen Trenner ein.
 	 * 
 	 * @param sep
@@ -862,51 +867,57 @@
 
 	/**
 	 * Transforms map keys according to a mapping.
-	 * @param sourceMap source map
-	 * @param mapping   mapping from source key to destination key (if mapping contains
-	 *                  no value for a key of source map, the original key is used!)
-	 * @param destMap   destination map to put the values in (if {@code null} a new
-	 *                  {@link HashMap} is created)
+	 * 
+	 * @param sourceMap
+	 *            source map
+	 * @param mapping
+	 *            mapping from source key to destination key (if mapping contains no value for a key of source map, the
+	 *            original key is used!)
+	 * @param destMap
+	 *            destination map to put the values in (if {@code null} a new {@link HashMap} is created)
 	 * @return {@code sourceMap} if mapping is {@code null}
 	 */
-	public static <K,V> Map<K,V> transformMapKeys(Map<K,V> sourceMap, Map<K,K> mapping, Map<K,V> destMap) {
-	  if ( mapping == null )
-	    return sourceMap;
-	  if ( destMap == null )
-	    destMap = new HashMap<K,V>();  
-	  for (K sourceKey : sourceMap.keySet()) {
-	    K destKey = mapping.get(sourceKey);
-	    V  value  = sourceMap.get(sourceKey);
-	    destMap.put(destKey != null ? destKey : sourceKey,value);
-	  }
-	  return destMap;
+	public static <K, V> Map<K, V> transformMapKeys(Map<K, V> sourceMap, Map<K, K> mapping, Map<K, V> destMap) {
+		if (mapping == null)
+			return sourceMap;
+		if (destMap == null)
+			destMap = new HashMap<K, V>();
+		for (K sourceKey : sourceMap.keySet()) {
+			K destKey = mapping.get(sourceKey);
+			V value = sourceMap.get(sourceKey);
+			destMap.put(destKey != null ? destKey : sourceKey, value);
+		}
+		return destMap;
 	}
 
-    /**
-     * Transforms map keys according to a mapping.
-     * @param sourceMap source map
-     * @param mapping   mapping from destination key to source key (if mapping contains
-     *                  no value for a key of source map, the value is irgnored)
-     * @param destMap   destination map to put the values in (if {@code null} a new
-     *                  {@link HashMap} is created)
-     * @return {@code sourceMap} if mapping is {@code null}
-     */
-    public static <K,V> Map<K,V> transformMapKeysInverted(Map<K,V> sourceMap, Map<K,K> mapping, Map<K,V> destMap) {
-      if ( mapping == null )
-        return sourceMap;
-      if ( destMap == null )
-        destMap = new HashMap<K,V>();  
-      for (K destKey : mapping.keySet()) {
-        K sourceKey = mapping.get(destKey);
-        if ( sourceKey != null ) {
-          V  value  = sourceMap.get(sourceKey);
-          destMap.put(destKey,value);
-        }
-      }
-      return destMap;
-    }
+	/**
+	 * Transforms map keys according to a mapping.
+	 * 
+	 * @param sourceMap
+	 *            source map
+	 * @param mapping
+	 *            mapping from destination key to source key (if mapping contains no value for a key of source map, the
+	 *            value is irgnored)
+	 * @param destMap
+	 *            destination map to put the values in (if {@code null} a new {@link HashMap} is created)
+	 * @return {@code sourceMap} if mapping is {@code null}
+	 */
+	public static <K, V> Map<K, V> transformMapKeysInverted(Map<K, V> sourceMap, Map<K, K> mapping, Map<K, V> destMap) {
+		if (mapping == null)
+			return sourceMap;
+		if (destMap == null)
+			destMap = new HashMap<K, V>();
+		for (K destKey : mapping.keySet()) {
+			K sourceKey = mapping.get(destKey);
+			if (sourceKey != null) {
+				V value = sourceMap.get(sourceKey);
+				destMap.put(destKey, value);
+			}
+		}
+		return destMap;
+	}
 
-    /**
+	/**
 	 * Erzeugt einen vorbelegten Array.
 	 * 
 	 * @param count
@@ -2235,19 +2246,17 @@
 		Boolean b = parseStringDefaultNull(str);
 		return b != null ? b : false;
 	}
-	
+
 	/**
-	 * Converts a list to a map which contains the list items as
-	 * keys and corresponding values.
+	 * Converts a list to a map which contains the list items as keys and corresponding values.
 	 */
-	public static <K> Map<K,K> convertToMap(List<K> list) {
-	  Map<K,K> map = new SequentialOrderedMap<K,K>();
-	  for (K item : list)
-	    map.put(item, item);
-	  return map;
+	public static <K> Map<K, K> convertToMap(List<K> list) {
+		Map<K, K> map = new SequentialOrderedMap<K, K>();
+		for (K item : list)
+			map.put(item, item);
+		return map;
 	}
 
-
 	/**
 	 * Removes leading and tailing "\n" newline commands. Very similar: StringUtils.trimToEmpty(string);
 	 * 
@@ -2289,8 +2298,9 @@
 	 * Die Methode basiert auf RegEx. Es wird also kein valides oder wellformed-XML erwartet.
 	 */
 	public static String removeTags(String withTags) {
-		if (withTags == null) return null;
-		
+		if (withTags == null)
+			return null;
+
 		String withoutTags = withTags;
 
 		String re1 = "\\s*<[^>]*>\\s*";
@@ -2323,8 +2333,10 @@
 			regex = regex.substring(1);
 
 		String r2 = pre + "(" + regex + ")" + post;
-		Pattern compile = Pattern.compile(r2);
-		Matcher matcher = compile.matcher(value);
+//		Pattern compile = Pattern.compile(r2);
+//		Matcher matcher = compile.matcher(value);
+		
+		Matcher matcher = RegexCache.getInstance().getMatcher(r2, value);
 		if (!matcher.find())
 			return "";
 
@@ -2359,13 +2371,17 @@
 	/**
 	 * Alle Zeilenumbrüche raus // Geschützte Leerzeichen weg // Tabulator -> Leer
 	 */
-	final static Pattern REMOVE_WHITESPACES_PATTERN = RegexCache.getInstance().getPattern(
-			"[\\n|\\t|\\r|\\u0085|\\u2028|\\u2029|\\u00A0]");
+	final static String REMOVE_WHITESPACES_PATTERN_R = "[\\n|\\t|\\r|\\u0085|\\u2028|\\u2029|\\u00A0]";
+	// final static Pattern REMOVE_WHITESPACES_PATTERN =
+	// RegexCache.getInstance().getPattern(REMOVE_WHITESPACES_PATTERN_R);
 	/**
 	 * Leerzeichen konsolidieren
 	 */
-	final static Pattern REMOVE_WHITESPACES_PATTERN2 = RegexCache.getInstance().getPattern("\\s{2,}");
+	final static String REMOVE_WHITESPACES_PATTERN2_R = "\\s{2,}";
 
+	// final static Pattern REMOVE_WHITESPACES_PATTERN2 = RegexCache.getInstance().getPattern(
+	// REMOVE_WHITESPACES_PATTERN2_R);
+
 	/**
 	 * Fasst Zeilenumbrüche und sonstige Leerräume zu einem einizgen Leerzeichen zusammen.
 	 * 
@@ -2378,7 +2394,10 @@
 		// Alle Zeilenumbrüche raus
 		// Geschützte Leerzeichen weg
 		// Tabulator -> Leer
-		final Matcher matcher = REMOVE_WHITESPACES_PATTERN.matcher(string);
+		// final Matcher matcher = REMOVE_WHITESPACES_PATTERN.matcher(string);
+
+		final Matcher matcher = RegexCache.getInstance().getMatcher(REMOVE_WHITESPACES_PATTERN_R, string);
+
 		string = matcher.replaceAll(" ");
 
 		// matcher = RegexCache.getInstance().getPattern("\\u00A0").matcher(string);
@@ -2388,7 +2407,10 @@
 		// string = matcher.replaceAll(" ");
 
 		// Leerraum konsolidieren
-		return REMOVE_WHITESPACES_PATTERN2.matcher(string).replaceAll(" ");
+		final String result = RegexCache.getInstance().getMatcher(REMOVE_WHITESPACES_PATTERN2_R, string)
+				.replaceAll(" ");
+
+		return result;
 	}
 
 	/**

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java	2012-05-24 13:25:49 UTC (rev 2003)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java	2012-05-24 13:34:18 UTC (rev 2004)
@@ -1,6 +1,8 @@
 package de.schmitzm.regex;
 
+import java.util.Collections;
 import java.util.HashMap;
+import java.util.Map;
 import java.util.regex.MatchResult;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -9,8 +11,8 @@
 import de.schmitzm.lang.LimitedHashMap.TRUNC_METHOD;
 
 /**
- * Cached compilierte Pattern und auch Ergebnisse von RegExes. Use the matchers
- * methods to obtain cached result and add regex to cache automatically.
+ * Cached compilierte Pattern und auch Ergebnisse von RegExes. Use the matchers methods to obtain cached result and add
+ * regex to cache automatically.
  * 
  * @author stranger
  * @author stefan.tzeggai
@@ -18,9 +20,8 @@
 public class RegexCache {
 
 	/**
-	 * Diese Klasse dienst dazu, einen Eintrag im cache liegen zu haben, auch
-	 * wenn keine match gefunden wurde. In dem Falle ist das Feld
-	 * {@link #matcherResult} dann <code>null</code>
+	 * Diese Klasse dienst dazu, einen Eintrag im cache liegen zu haben, auch wenn keine match gefunden wurde. In dem
+	 * Falle ist das Feld {@link #matcherResult} dann <code>null</code>
 	 * 
 	 */
 	static class MyMatchResult {
@@ -33,9 +34,8 @@
 	}
 
 	/**
-	 * TODO Ein String der länger ist als die hier angegebene Anzahl Zeichen wir
-	 * nicht gecached. Die Wahrscheinlichkeit, dass der selbe Sting nochmal
-	 * auftaucht wird als zu gering eingeschätzt. TODO
+	 * TODO Ein String der länger ist als die hier angegebene Anzahl Zeichen wir nicht gecached. Die Wahrscheinlichkeit,
+	 * dass der selbe Sting nochmal auftaucht wird als zu gering eingeschätzt.
 	 **/
 	private static final int CACHE_VALUES_TO_RESULT_MAX_VALUE_LENGTH = 200;
 
@@ -65,14 +65,16 @@
 	public final boolean matches(final String regex, final Object object) {
 		if (object == null)
 			return false;
-		final String value = object instanceof String ? (String) object
-				: object.toString();
-		return result(regex, value) != null;
+		final String value = object instanceof String ? (String) object : object.toString();
+
+		Matcher m = getMatcher(regex, value);
+		return m.find();
+
+		// return result(regex, value) != null;
 	}
 
 	/**
-	 * Liefert eine compiliertes RegEx Pattern aus dem Cache. Wenn es vorher
-	 * nicht existierte wird es erstellt.
+	 * Liefert eine compiliertes RegEx Pattern aus dem Cache. Wenn es vorher nicht existierte wird es erstellt.
 	 */
 	public Pattern getPattern(String regex) {
 		synchronized (patterns) {
@@ -85,28 +87,64 @@
 		}
 	}
 
+	final static Map<String, ThreadLocal<Matcher>> matchersCachedThreadLocalPerRegex = Collections
+			.synchronizedMap(new LimitedHashMap<String, ThreadLocal<Matcher>>(10000, TRUNC_METHOD.OLDEST_GET));
+
 	/**
+	 * Diese Methode ist gedacht um die Erstellung von Matcher-Objekten in der JVM zu reduzieren. Es für bis zu 10000
+	 * RegEx ein Cache verwaltet. Jeder dieser Caches ist ein ThreadLocal-Cache von Matchern. Somit liefert diese Methde
+	 * für die selbe RegEx auf N Threads N unterschiedliche Matcher.<br/>
+	 * Die Matcher werden für die Regex gecached. Wird ein Matcher für eine gecachte Regex mit einem anderen TEXT
+	 * angeforderd, wird zuerst {@link Matcher#reset(CharSequence)} ausgeführt.
+	 */
+	public Matcher getMatcher(final String regex, final String text) {
+		ThreadLocal<Matcher> threadLocal = matchersCachedThreadLocalPerRegex.get(regex);
+
+		synchronized (regex) {
+
+			if (threadLocal == null) {
+
+				threadLocal = new ThreadLocal<Matcher>() {
+
+					@Override
+					protected Matcher initialValue() {
+						return getPattern(regex).matcher(text);
+					}
+				};
+				matchersCachedThreadLocalPerRegex.put(regex, threadLocal);
+			}
+
+		}
+
+		return threadLocal.get().reset(text);
+	}
+
+	/**
 	 * Will throw java exceptions when pattern won't compile.
 	 * 
 	 * @param regex
 	 *            may not be null
 	 * @param value
 	 *            may not be null
-	 * @return <code>null</code> if the pattern didn't match. A
-	 *         {@link MatchResult} otherwise which contains the groups etc.
+	 * @return <code>null</code> if the pattern didn't match. A {@link MatchResult} otherwise which contains the groups
+	 *         etc.
 	 */
 	public final MatchResult result(final String regex, final String value) {
 
+		if (value.length() > CACHE_VALUES_TO_RESULT_MAX_VALUE_LENGTH) {
+			Matcher m = getMatcher(regex, value);
+			boolean found = m.find();
+			return found ? m.toMatchResult() : null;
+		}
+
 		final Pattern pattern = getPattern(regex);
 
 		LimitedHashMap<String, MyMatchResult> m;
 		synchronized (matchers) {
 			m = matchers.get(pattern);
 			if (m == null) {
-				matchers.put(pattern,
-						m = new LimitedHashMap<String, MyMatchResult>(
-								CACHE_VALUES_TO_RESULT_SIZE,
-								TRUNC_METHOD.OLDEST_GET));
+				matchers.put(pattern, m = new LimitedHashMap<String, MyMatchResult>(CACHE_VALUES_TO_RESULT_SIZE,
+						TRUNC_METHOD.OLDEST_GET));
 			}
 		}
 

Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/JMapEditorPane.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/JMapEditorPane.java	2012-05-24 13:25:49 UTC (rev 2003)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/JMapEditorPane.java	2012-05-24 13:34:18 UTC (rev 2004)
@@ -43,7 +43,6 @@
 import org.geotools.feature.FeatureCollection;
 import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
 import org.geotools.map.DefaultMapContext;
-import org.geotools.map.DefaultMapLayer;
 import org.geotools.map.FeatureLayer;
 import org.geotools.map.MapContext;
 import org.geotools.map.MapLayer;

Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/LayeredMapPane.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/LayeredMapPane.java	2012-05-24 13:25:49 UTC (rev 2003)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/LayeredMapPane.java	2012-05-24 13:34:18 UTC (rev 2004)
@@ -44,7 +44,6 @@
 import org.geotools.map.MapContext;
 import org.geotools.map.MapLayer;
 import org.geotools.map.MapUtil;
-import org.geotools.map.event.MapLayerEvent;
 import org.geotools.map.event.MapLayerListEvent;
 import org.geotools.map.event.MapLayerListListener;
 import org.geotools.styling.ColorMap;

Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/io/GeoImportUtil.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/io/GeoImportUtil.java	2012-05-24 13:25:49 UTC (rev 2003)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/io/GeoImportUtil.java	2012-05-24 13:34:18 UTC (rev 2004)
@@ -59,7 +59,6 @@
 import javax.imageio.ImageIO;
 
 import org.apache.commons.lang.NotImplementedException;
-import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.geotools.coverage.grid.GridCoverage2D;
 import org.geotools.coverage.grid.GridCoverageFactory;

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	2012-05-24 13:25:49 UTC (rev 2003)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerUtil.java	2012-05-24 13:34:18 UTC (rev 2004)
@@ -92,7 +92,6 @@
 import org.opengis.parameter.GeneralParameterValue;
 
 import com.vividsolutions.jts.geom.Geometry;
-import com.vividsolutions.jts.geom.Point;
 
 import de.schmitzm.geotools.GTUtil;
 import de.schmitzm.geotools.JTSUtil;

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	2012-05-24 13:25:49 UTC (rev 2003)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StylingUtil.java	2012-05-24 13:34:18 UTC (rev 2004)
@@ -366,7 +366,7 @@
 	}
 
 	/**
-	 * Clones a Style by converting it to XML and reading it back in.
+	 * Clones a Style using the DuplicatingStyleVisitor
 	 * 
 	 * @param style
 	 *            the {@link Style} to be copied.
@@ -3025,11 +3025,13 @@
 	 */
 	public static Style optimizeStyle(Style style, String title) {
 
+		Style style2 = StylingUtil.copy(style);
+
 		Style oStyle = STYLE_BUILDER.createStyle();
 
 		Map<Name, List<Rule>> ftsRules = new java.util.HashMap<Name, List<Rule>>();
 
-		for (FeatureTypeStyle fts : style.featureTypeStyles()) {
+		for (FeatureTypeStyle fts : style2.featureTypeStyles()) {
 			for (Name name : fts.featureTypeNames()) {
 				if (ftsRules.get(name) == null)
 					ftsRules.put(name, fts.rules());

Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/chartsymbols/ChartGraphic.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/chartsymbols/ChartGraphic.java	2012-05-24 13:25:49 UTC (rev 2003)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/chartsymbols/ChartGraphic.java	2012-05-24 13:34:18 UTC (rev 2004)
@@ -30,7 +30,6 @@
 import de.schmitzm.geotools.feature.FeatureUtil;
 import de.schmitzm.geotools.gui.GeotoolsGUIUtil;
 import de.schmitzm.geotools.styling.StylingUtil;
-import de.schmitzm.i18n.Translation;
 import de.schmitzm.regex.RegexCache;
 import de.schmitzm.swing.SwingUtil;
 



More information about the Schmitzm-commits mailing list