diff gnv-artifacts/src/main/java/de/intevation/gnv/raster/Palette.java @ 426:3a0c0ad113d9

Load palettes from configuration. gnv-artifacts/trunk@474 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 22 Dec 2009 10:34:15 +0000
parents 21fbd254db71
children 67091b17462d
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/raster/Palette.java	Mon Dec 21 19:58:17 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/raster/Palette.java	Tue Dec 22 10:34:15 2009 +0000
@@ -97,6 +97,7 @@
     protected Entry [] entries;
     protected Entry    lookup;
     protected Color [] rgbs;
+    protected String   description;
 
     private Entry buildLookup(Entry [] entries, int lo, int hi) {
         if (lo > hi) {
@@ -113,6 +114,12 @@
     }
 
     public Palette(Document document) {
+        this(document, null);
+    }
+
+    public Palette(Document document, String description) {
+
+        this.description = description;
 
         NodeList rangeNodes = document.getElementsByTagName("range");
 
@@ -124,9 +131,9 @@
             double from  = doubleValue(rangeElement.getAttribute("from"));
             double to    = doubleValue(rangeElement.getAttribute("to"));
             Color  color = color(rangeElement.getAttribute("rgb"));
-            String description = rangeElement.getAttribute("description");
+            String desc = rangeElement.getAttribute("description");
             if (from > to) { double t = from; from = to; to = t; }
-            entries[i] = new Entry(i, from, to, color, description);
+            entries[i] = new Entry(i, from, to, color, desc);
             rgbs[i] = color;
         }
 
@@ -161,6 +168,10 @@
         lookup = buildLookup(entries, 0, entries.length-1);
     }
 
+    public String getDescription() {
+        return description;
+    }
+
     public int getSize() {
         return rgbs.length;
     }

http://dive4elements.wald.intevation.org