[Schmitzm-commits] r1512 - in trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools: data/rld styling

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Mar 15 17:35:54 CET 2011


Author: alfonx
Date: 2011-03-15 17:35:53 +0100 (Tue, 15 Mar 2011)
New Revision: 1512

Modified:
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/data/rld/RasterLegendData.java
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerUtil.java
Log:
* RasterLegendData now preserves the order, in which the entries are entered
* EMpty labels will not appear in a raster legends:
			if (I18NUtil.isEmpty(labelT))
				continue;

Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/data/rld/RasterLegendData.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/data/rld/RasterLegendData.java	2011-03-15 13:55:47 UTC (rev 1511)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/data/rld/RasterLegendData.java	2011-03-15 16:35:53 UTC (rev 1512)
@@ -29,12 +29,11 @@
  ******************************************************************************/
 package de.schmitzm.geotools.data.rld;
 
-import java.util.Arrays;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.TreeMap;
 
 import org.apache.log4j.Logger;
 import org.geotools.coverage.grid.GridCoverage2D;
@@ -52,8 +51,8 @@
  * 
  * @author <a href="mailto:tzeggai at wikisquare.de">Stefan Alfons Tzeggai</a>
  */
-public class RasterLegendData extends TreeMap<Double, Translation> implements
-		Copyable<RasterLegendData> {
+public class RasterLegendData extends LinkedHashMap<Double, Translation>
+		implements Copyable<RasterLegendData> {
 	static private final Logger LOGGER = Logger
 			.getLogger(RasterLegendData.class);
 
@@ -83,12 +82,12 @@
 	 * in the legend.
 	 */
 	public List<Double> getSortedKeys() {
-		Double[] array = keySet().toArray(new Double[] {});
+		// Double[] array = keySet().toArray(new Double[] {});
 
-		Arrays.sort(array);
+		// Arrays.sort(array);
 
 		final LinkedList<Double> linkedList = new LinkedList<Double>();
-		for (Double o : array) {
+		for (Double o : keySet()) {
 			linkedList.add(o);
 		}
 

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-03-15 13:55:47 UTC (rev 1511)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerUtil.java	2011-03-15 16:35:53 UTC (rev 1512)
@@ -100,6 +100,7 @@
 import de.schmitzm.geotools.data.amd.AttributeMetadataMap;
 import de.schmitzm.geotools.data.rld.RasterLegendData;
 import de.schmitzm.geotools.feature.FeatureUtil;
+import de.schmitzm.i18n.I18NUtil;
 import de.schmitzm.i18n.Translation;
 import de.schmitzm.io.IOUtil;
 import de.schmitzm.lang.LangUtil;
@@ -1052,7 +1053,12 @@
 		final JPanel panel = new JPanel(new MigLayout("wrap 2, gapy 0"));
 
 		for (final Double rValue : legendRasterValues) {
+			final Translation labelT = rasterLegendData.get(rValue);
 
+			// EMpty labels will not appear in a raster legend
+			if (I18NUtil.isEmpty(labelT))
+				continue;
+
 			// final Dimension ICON_SIZE = new Dimension(iconWidth,
 			// new JLabel().getFontMetrics(new JLabel().getFont())
 			// .getHeight() > 5 ? new JLabel().getFontMetrics(
@@ -1140,7 +1146,6 @@
 			final JLabel iconLabel = new JLabel(new ImageIcon(buffImage));
 			panel.add(iconLabel, "sgx1");
 
-			final Translation labelT = rasterLegendData.get(rValue);
 			final JLabel classTitleLabel = new JLabel(labelT.toString());
 			panel.add(classTitleLabel, "sgx2"
 					+ (rasterLegendData.isPaintGaps() ? ", gapy 0:0:0 5:5:5"



More information about the Schmitzm-commits mailing list