# HG changeset patch # User Sascha L. Teichmann # Date 1263812201 0 # Node ID c8089cd7d777813f05386779f0a56be9a6da743f # Parent 64e65daa65e91116ecde41f406aa759467577cdf Added explicit index scheme to palette classes to allow external references. gnv-artifacts/trunk@558 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 64e65daa65e9 -r c8089cd7d777 gnv-artifacts/ChangeLog --- a/gnv-artifacts/ChangeLog Sun Jan 17 21:26:21 2010 +0000 +++ b/gnv-artifacts/ChangeLog Mon Jan 18 10:56:41 2010 +0000 @@ -1,3 +1,20 @@ +2010-01-18 Sascha L. Teichmann + + * src/main/java/de/intevation/gnv/raster/Palette.java: + load attribute "index" as external index. This + is useful to match color classes with external sources. + If no explicit index is given the order of ranges is + used as external index. + + * doc/conf/palette/flow-velocity.xml, + doc/conf/palette/water-levels.xml, + doc/conf/palette/salinity.xml, + doc/conf/palette/water-temperature.xml: Set explicit + external color class indices. + + * doc/conf/conf.xml: Set ground interpolation of "Horizontalschnitte" + to bilinear. + 2010-01-17 Sascha L. Teichmann * doc/conf/conf.xml: Reduced number of "Horizontalschnitt" diff -r 64e65daa65e9 -r c8089cd7d777 gnv-artifacts/doc/conf/conf.xml --- a/gnv-artifacts/doc/conf/conf.xml Sun Jan 17 21:26:21 2010 +0000 +++ b/gnv-artifacts/doc/conf/conf.xml Mon Jan 18 10:56:41 2010 +0000 @@ -421,6 +421,7 @@ + diff -r 64e65daa65e9 -r c8089cd7d777 gnv-artifacts/doc/conf/palette/flow-velocity.xml --- a/gnv-artifacts/doc/conf/palette/flow-velocity.xml Sun Jan 17 21:26:21 2010 +0000 +++ b/gnv-artifacts/doc/conf/palette/flow-velocity.xml Mon Jan 18 10:56:41 2010 +0000 @@ -1,15 +1,15 @@ - - - - - - - - - - - - + + + + + + + + + + + + diff -r 64e65daa65e9 -r c8089cd7d777 gnv-artifacts/doc/conf/palette/salinity.xml --- a/gnv-artifacts/doc/conf/palette/salinity.xml Sun Jan 17 21:26:21 2010 +0000 +++ b/gnv-artifacts/doc/conf/palette/salinity.xml Mon Jan 18 10:56:41 2010 +0000 @@ -1,31 +1,31 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 64e65daa65e9 -r c8089cd7d777 gnv-artifacts/doc/conf/palette/water-levels.xml --- a/gnv-artifacts/doc/conf/palette/water-levels.xml Sun Jan 17 21:26:21 2010 +0000 +++ b/gnv-artifacts/doc/conf/palette/water-levels.xml Mon Jan 18 10:56:41 2010 +0000 @@ -1,27 +1,27 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff -r 64e65daa65e9 -r c8089cd7d777 gnv-artifacts/doc/conf/palette/water-temperature.xml --- a/gnv-artifacts/doc/conf/palette/water-temperature.xml Sun Jan 17 21:26:21 2010 +0000 +++ b/gnv-artifacts/doc/conf/palette/water-temperature.xml Mon Jan 18 10:56:41 2010 +0000 @@ -1,31 +1,31 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 64e65daa65e9 -r c8089cd7d777 gnv-artifacts/src/main/java/de/intevation/gnv/raster/Palette.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/raster/Palette.java Sun Jan 17 21:26:21 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/raster/Palette.java Mon Jan 18 10:56:41 2010 +0000 @@ -28,6 +28,8 @@ private int index; + private int externalIndex; + private double from; private double to; @@ -39,25 +41,28 @@ } public Entry(Entry other) { - index = other.index; - from = other.from; - to = other.to; - description = other.description; - color = other.color; + index = other.index; + externalIndex = other.externalIndex; + from = other.from; + to = other.to; + description = other.description; + color = other.color; } public Entry( int index, + int externalIndex, double from, double to, Color color, String description ) { - this.index = index; - this.from = from; - this.to = to; - this.color = color; - this.description = description; + this.index = index; + this.externalIndex = externalIndex; + this.from = from; + this.to = to; + this.color = color; + this.description = description; } public int compareTo(Object other) { @@ -79,6 +84,10 @@ return color; } + public int getExternalIndex() { + return externalIndex; + } + public Entry locateEntry(double value) { Entry current = this; while (current != null) { @@ -150,12 +159,13 @@ for (int i = 0; i < entries.length; ++i) { Element rangeElement = (Element)rangeNodes.item(i); - double from = doubleValue(rangeElement.getAttribute("from")); - double to = doubleValue(rangeElement.getAttribute("to")); - Color color = color(rangeElement.getAttribute("rgb")); - String desc = rangeElement.getAttribute("description"); + double from = doubleValue(rangeElement.getAttribute("from")); + double to = doubleValue(rangeElement.getAttribute("to")); + int extIndex = intValue(rangeElement.getAttribute("index"), i); + Color color = color(rangeElement.getAttribute("rgb")); + String desc = rangeElement.getAttribute("description"); if (from > to) { double t = from; from = to; to = t; } - entries[i] = new Entry(i, from, to, color, desc); + entries[i] = new Entry(i, extIndex, from, to, color, desc); rgbs[i] = color; } @@ -207,6 +217,19 @@ buildLookup(); } + private static final int intValue(String s, int def) { + if (s == null || (s = s.trim()).length() == 0) { + return def; + } + try { + return Integer.parseInt(s); + } + catch (NumberFormatException nfe) { + log.error(nfe.getLocalizedMessage(), nfe); + } + return def; + } + private static final double doubleValue(String s) { if (s == null || (s = s.trim()).length() == 0) { return 0d;