annotate gnv-artifacts/src/main/java/de/intevation/gnv/raster/Palette.java @ 1106:8ce8979f51df

Added the transition chain for the external mapviewer call (issue318). gnv-artifacts/trunk@1237 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 29 Jun 2010 07:09:13 +0000
parents feae2f9d6c6f
children f953c9a559d8
rev   line source
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.gnv.raster;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
779
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
3 import de.intevation.gnv.raster.Raster.ValueToIndex;
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
4
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
5 import java.awt.Color;
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
6
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
7 import java.util.Arrays;
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
8
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
9 import org.apache.log4j.Logger;
b1f5f2a8840f Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 778
diff changeset
10
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 import org.w3c.dom.Document;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 import org.w3c.dom.Element;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 import org.w3c.dom.NodeList;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15 /**
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
16 * Lookup mechanism to map double values from a list of
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
17 * ranges onto a set of colors and vice versa.
780
c4156275c1e1 Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 779
diff changeset
18 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 */
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 public class Palette
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21 implements ValueToIndex
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 483
diff changeset
22 {
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
23 private static Logger log = Logger.getLogger(Palette.class);
447
92b7ccbf6163 Improved generation of iso lines in vertical cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 438
diff changeset
24
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
25 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
26 * An entry in the lookup table.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
27 */
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 483
diff changeset
28 public static final class Entry
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 implements Comparable
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 private Entry left;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 private Entry right;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 private int index;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35
483
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
36 private int externalIndex;
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
37
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 private double from;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39 private double to;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 private String description;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 private Color color;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
45 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
46 * Default constructor
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
47 */
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 public Entry() {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
51 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
52 * Copy constructor
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
53 * @param other The entry to copy.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
54 */
435
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
55 public Entry(Entry other) {
483
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
56 index = other.index;
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
57 externalIndex = other.externalIndex;
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
58 from = other.from;
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
59 to = other.to;
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
60 description = other.description;
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
61 color = other.color;
435
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
62 }
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
63
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
64 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
65 * Constructor to set the palette index, the exteral index,
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
66 * the value range, the color and the description.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
67 * @param index The pallette index
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
68 * @param externalIndex The external index
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
69 * @param from Start of the interval
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
70 * @param to End of the interval
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
71 * @param color The color belonging to this interval.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
72 * @param description The description of this range.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
73 */
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
74 public Entry(
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 483
diff changeset
75 int index,
483
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
76 int externalIndex,
778
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 483
diff changeset
77 double from,
9a828e5a2390 Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 483
diff changeset
78 double to,
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
79 Color color,
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
80 String description
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
81 ) {
483
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
82 this.index = index;
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
83 this.externalIndex = externalIndex;
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
84 this.from = from;
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
85 this.to = to;
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
86 this.color = color;
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
87 this.description = description;
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
88 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
89
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
90 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
91 * Compares two entries by the start point of the interval.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
92 * @param other
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 801
diff changeset
93 * @return -1 if this start point is before other. +1 if this
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
94 * start point is after, else 0.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
95 */
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
96 public int compareTo(Object other) {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
97 Entry e = (Entry)other;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
98 if (from < e.from) return -1;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
99 if (from > e.from) return +1;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
100 return 0;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
101 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
102
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
103 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
104 * The starting point of the interval.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
105 * @return The starting point.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
106 */
448
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
107 public double getFrom() {
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
108 return from;
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
109 }
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
110
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
111 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
112 * The end point of the interval.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
113 * @return The end point.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
114 */
448
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
115 public double getTo() {
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
116 return to;
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
117 }
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
118
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
119 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
120 * The color of the entry.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
121 * @return The color.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
122 */
449
c7ca2fce041f Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 448
diff changeset
123 public Color getColor() {
c7ca2fce041f Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 448
diff changeset
124 return color;
c7ca2fce041f Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 448
diff changeset
125 }
c7ca2fce041f Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 448
diff changeset
126
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
127 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
128 * The external index of this entry. Useful to model
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
129 * external joins.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
130 * @return The external index.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
131 */
483
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
132 public int getExternalIndex() {
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
133 return externalIndex;
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
134 }
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
135
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
136 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
137 * Searches for an entry which has a range that contains
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
138 * the given value.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
139 * @param value The value to be searched.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
140 * @return The entry containing the value or null if no such
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
141 * entry exists.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
142 */
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
143 public Entry locateEntry(double value) {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
144 Entry current = this;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
145 while (current != null) {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
146 boolean b = value >= current.from;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
147 if (b && value <= current.to) {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
148 return current;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
149 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
150 current = b
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
151 ? current.right
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
152 : current.left;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
153 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
154 return null;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
155 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
156
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
157 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
158 * Returns the palette index for a given value.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
159 * @param value The value to search.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
160 * @return The index of the palette entry or -1 if
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
161 * no such entry exists.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
162 */
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
163 public int locate(double value) {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
164 Entry entry = locateEntry(value);
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
165 return entry != null
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
166 ? entry.index
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
167 : -1;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
168 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
169
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
170 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
171 * Searches for an interval with a given index.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
172 * @param index The index to be searched.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
173 * @return The entry with the given index or null if no
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
174 * such entry exists.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
175 */
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
176 public Entry findByIndex(int index) {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
177 Entry current = this;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
178 while (current != null) {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
179 if (current.index == index) {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
180 break;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
181 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
182 current = index < current.index
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
183 ? current.left
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
184 : current.right;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
185 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
186 return current;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
187 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
188
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
189 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
190 * The description of this entry.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
191 * @return The description.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
192 */
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
193 public String getDescription() {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
194 return description;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
195 }
435
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
196
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
197 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
198 * Determines if the range of this entry has
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
199 * infinitive length.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
200 * @return true if the range of this entry has infinitive
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
201 * length else false.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
202 */
435
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
203 public boolean isInfinity() {
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
204 return from == -Double.MAX_VALUE
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
205 || to == Double.MAX_VALUE;
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
206 }
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
207 } // class Entry
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
208
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
209 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
210 * Internal table of the entrys.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
211 */
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
212 protected Entry [] entries;
803
feae2f9d6c6f Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 801
diff changeset
213
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
214 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
215 * Root of the entry tree used to map values to entries.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
216 */
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
217 protected Entry lookup;
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
218
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
219 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
220 * The list of colors used by this palette.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
221 */
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
222 protected Color [] rgbs;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
223
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
224 private Entry buildLookup(Entry [] entries, int lo, int hi) {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
225 if (lo > hi) {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
226 return null;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
227 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
228 int mid = (lo + hi)/2;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
229 Entry entry = entries[mid];
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
230 entry.left = buildLookup(entries, lo, mid-1);
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
231 entry.right = buildLookup(entries, mid+1, hi);
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
232 return entry;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
233 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
234
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
235 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
236 * Default constructor.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
237 */
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
238 public Palette() {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
239 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
240
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
241 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
242 * Constructor to create the palette from an XML document.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
243 * @param document The document with palette information.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
244 */
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
245 public Palette(Document document) {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
246
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
247 NodeList rangeNodes = document.getElementsByTagName("range");
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
248
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
249 entries = new Entry[rangeNodes.getLength()];
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
250 rgbs = new Color[entries.length];
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
251
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
252 for (int i = 0; i < entries.length; ++i) {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
253 Element rangeElement = (Element)rangeNodes.item(i);
483
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
254 double from = doubleValue(rangeElement.getAttribute("from"));
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
255 double to = doubleValue(rangeElement.getAttribute("to"));
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
256 int extIndex = intValue(rangeElement.getAttribute("index"), i);
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
257 Color color = color(rangeElement.getAttribute("rgb"));
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
258 String desc = rangeElement.getAttribute("description");
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
259 if (from > to) { double t = from; from = to; to = t; }
483
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
260 entries[i] = new Entry(i, extIndex, from, to, color, desc);
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
261 rgbs[i] = color;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
262 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
263
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
264 buildLookup();
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
265 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
266
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
267 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
268 * Constructor to split a given palette into a given number of
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
269 * equal sized sub entries. Ranges of infinitive length are not
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
270 * splitted.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
271 * @param original The source palette.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
272 * @param N The number of chunks to split single ranges into.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
273 */
435
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
274 public Palette(Palette original, int N) {
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
275 if (N < 2) {
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
276 throw new IllegalArgumentException("N < 2");
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
277 }
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
278
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
279 Entry [] origEntries = original.entries;
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
280
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
281 int newSize = 0;
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
282 for (int i = 0; i < origEntries.length; ++i) {
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
283 // cannot split infinity intervals
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
284 newSize += origEntries[i].isInfinity() ? 1 : N;
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
285 }
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
286
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
287 entries = new Entry[newSize];
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
288 rgbs = new Color[newSize];
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
289
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
290 for (int i = 0, j = 0; i < origEntries.length; ++i) {
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
291 Entry origEntry = origEntries[i];
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
292 if (origEntry.isInfinity()) {
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
293 // infinity intervals are just copied
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
294 Entry nEntry = new Entry(origEntry);
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
295 entries[j] = nEntry;
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
296 rgbs[j] = nEntry.color;
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
297 nEntry.index = j++;
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
298 }
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
299 else {
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
300 // split interval into N parts
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
301 double from = origEntry.from;
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
302 double to = origEntry.to;
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
303 double delta = (to - from)/N;
447
92b7ccbf6163 Improved generation of iso lines in vertical cross section.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 438
diff changeset
304 for (int k = 0; k < N; ++k) {
435
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
305 Entry nEntry = new Entry(origEntry);
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
306 nEntry.from = from;
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
307 nEntry.to = from + delta;
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
308 from += delta;
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
309 entries[j] = nEntry;
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
310 rgbs[j] = nEntry.color;
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
311 nEntry.index = j++;
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
312 }
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
313 } // limited interval
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
314 } // for all original entries
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
315
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
316 buildLookup();
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
317 }
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
318
483
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
319 private static final int intValue(String s, int def) {
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
320 if (s == null || (s = s.trim()).length() == 0) {
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
321 return def;
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
322 }
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
323 try {
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
324 return Integer.parseInt(s);
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
325 }
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
326 catch (NumberFormatException nfe) {
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
327 log.error(nfe.getLocalizedMessage(), nfe);
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
328 }
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
329 return def;
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
330 }
c8089cd7d777 Added explicit index scheme to palette classes to allow external references.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 449
diff changeset
331
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
332 private static final double doubleValue(String s) {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
333 if (s == null || (s = s.trim()).length() == 0) {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
334 return 0d;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
335 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
336 if ((s = s.toLowerCase()).startsWith("-inf")) {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
337 return -Double.MAX_VALUE; // XXX: Not using Double.NEGATIVE_INFINITY!
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
338 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
339
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
340 if (s.startsWith("inf")) {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
341 return Double.MAX_VALUE; // XXX: Not using Double.NEGATIVE_INFINITY!
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
342 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
343
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
344 return Double.parseDouble(s);
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
345 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
346
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
347 private static final Color color(String s) {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
348 if (s == null || (s = s.trim()).length() == 0) {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
349 return null;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
350 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
351 return Color.decode(s);
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
352 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
353
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
354
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
355 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
356 * Internal method to build the lookup tree.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
357 */
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
358 protected void buildLookup() {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
359 Arrays.sort(entries);
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
360 lookup = buildLookup(entries, 0, entries.length-1);
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
361 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
362
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
363 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
364 * Creates a new palette which has ranges that are subdivided
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
365 * into a given number of sub ranges each.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
366 * @param N The number od sub divisions of each range.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
367 * @return The new created palette.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
368 */
435
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
369 public Palette subdivide(int N) {
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
370 return new Palette(this, N);
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
371 }
67091b17462d Added code to split palette interval into equal sized parts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
372
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
373 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
374 * Return the number of entries in this palette.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
375 * @return The number of entries.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
376 */
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
377 public int getSize() {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
378 return rgbs.length;
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
379 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
380
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
381 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
382 * Return the color of an entry for a given index.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
383 * @param index The index.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
384 * @return The color.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
385 */
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
386 public Color getColor(int index) {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
387 return rgbs[index];
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
388 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
389
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
390 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
391 * Return the RGB value
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
392 * @param index of an entry for a given index.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
393 * @return rgb value
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
394 */
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
395 public int indexToRGB(int index) {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
396 return rgbs[index].getRGB();
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
397 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
398
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
399 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
400 * Searches for the index of an entry which contains the
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
401 * given value.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
402 * @param value The value to be searched.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
403 * @return The index of the entry or -1 if no entry is found.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
404 */
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
405 public int toIndex(double value) {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
406 return lookup.locate(value);
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
407 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
408
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
409 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
410 * Searches for the an entry which contains the given value.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
411 * @param value The value to be searched.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
412 * @return The entry which contains the value or null if
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
413 * no such entry is found.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
414 */
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
415 public Entry getEntry(double value) {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
416 return lookup.locateEntry(value);
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
417 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
418
801
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
419 /**
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
420 * Searches the entry for a given index.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
421 * @param index The index of the entry.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
422 * @return The entry or null if no such entry is found.
d766fe2d917a More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
423 */
424
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
424 public Entry getEntryByIndex(int index) {
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
425 return lookup.findByIndex(index);
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
426 }
21fbd254db71 Added support for converting 2D rasters into polygons.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
427 }
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
428 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org