[Schmitzm-commits] r1520 - trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Mar 18 19:50:22 CET 2011
Author: alfonx
Date: 2011-03-18 19:50:21 +0100 (Fri, 18 Mar 2011)
New Revision: 1520
Modified:
trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerUtil.java
Log:
Generating RasterLegendData is now dependent on the typoe of colormap!
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-18 02:06:04 UTC (rev 1519)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/styling/StyledLayerUtil.java 2011-03-18 18:50:21 UTC (rev 1520)
@@ -517,17 +517,26 @@
final DecimalFormat decFormat = digits != null ? new DecimalFormat(
SwingUtil.getNumberFormatPattern(digits)) : null;
final RasterLegendData rld = new RasterLegendData(paintGaps);
+ int idx = 0;
for (final ColorMapEntry cme : colorMap.getColorMapEntries()) {
+
+ if (idx == colorMap.getColorMapEntries().length-1 && colorMap.getType() != ColorMap.TYPE_VALUES) {
+ // Ignore the last CME label if not in VLAUES mode
+ continue;
+ }
+
final double value = StylingUtil.getQuantityFromColorMapEntry(cme);
String label = cme.getLabel();
// if no label is set (e.g. quantitative style),
// use the value as label
- if (label == null || label.equals(""))
+ if (label == null || label.equals("")){
if (digits == null)
label = String.valueOf(value);
else
label = decFormat.format(LangUtil.round(value, digits));
- rld.put(value, new Translation(" " + label));
+ }
+ rld.put(value, new Translation(label));
+ idx++;
}
return rld;
}
@@ -1052,7 +1061,9 @@
final JPanel panel = new JPanel(new MigLayout("wrap 2, gapy 0"));
- for (final Double rValue : legendRasterValues) {
+ for (Double iteratorValue : legendRasterValues) {
+
+ Double rValue = iteratorValue;
final Translation labelT = rasterLegendData.get(rValue);
// EMpty labels will not appear in a raster legend
@@ -1071,6 +1082,8 @@
iconHeight, BufferedImage.TYPE_INT_ARGB);
final Graphics2D graphics = buffImage.createGraphics();
+
+
if (colorModel != null) {
// The colors come from the ColorModel!
More information about the Schmitzm-commits
mailing list