comparison gnv-artifacts/src/main/java/de/intevation/gnv/raster/IsoAttributeGenerator.java @ 875:5e9efdda6894

merged gnv-artifacts/1.0
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:13:56 +0200
parents 4abe172be970
children f953c9a559d8
comparison
equal deleted inserted replaced
722:bb3ffe7d719e 875:5e9efdda6894
1 package de.intevation.gnv.raster;
2
3 /**
4 * Generates label attributes for iso lines. It takes the
5 * neighboring palette ranges and calculates the mid point
6 * between these two ranges.
7 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
8 */
9 public class IsoAttributeGenerator
10 implements IsoProducer.AttributeGenerator
11 {
12 /**
13 * The palette where to look for the ranges.
14 */
15 protected Palette palette;
16
17 /**
18 * Default constructor.
19 */
20 public IsoAttributeGenerator() {
21 }
22
23 /**
24 * Constructor to create an IsoAttributeGenerator with
25 * a given lookup palette.
26 * @param palette The palette.
27 */
28 public IsoAttributeGenerator(Palette palette) {
29 this.palette = palette;
30 }
31
32 public Object generateAttribute(int neighbor1, int neighbor2) {
33 Palette.Entry e1 = palette.getEntryByIndex(neighbor1);
34 Palette.Entry e2 = palette.getEntryByIndex(neighbor2);
35
36 if (e1 == null || e2 == null) {
37 return null;
38 }
39
40 double e1t = e1.getFrom();
41 double e2f = e2.getTo();
42
43 return Double.valueOf(e2f >= e1t
44 ? 0.5d*(e1t+e2f)
45 : 0.5d*(e2.getTo()+e1.getFrom()));
46 }
47 }
48 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org