Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/raster/IsoAttributeGenerator.java @ 540:80630520e25a
merged gnv-artifacts/0.4
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:13:49 +0200 |
parents | f7038820df2e |
children | c4156275c1e1 |
comparison
equal
deleted
inserted
replaced
415:9f4a0b990d27 | 540:80630520e25a |
---|---|
1 package de.intevation.gnv.raster; | |
2 | |
3 /** | |
4 * @author Sascha L. Teichmann (sascha.teichmann@intevation.de) | |
5 */ | |
6 public class IsoAttributeGenerator | |
7 implements IsoProducer.AttributeGenerator | |
8 { | |
9 protected Palette palette; | |
10 | |
11 public IsoAttributeGenerator() { | |
12 } | |
13 | |
14 public IsoAttributeGenerator(Palette palette) { | |
15 this.palette = palette; | |
16 } | |
17 | |
18 public Object generateAttribute(int neighbor1, int neighbor2) { | |
19 Palette.Entry e1 = palette.getEntryByIndex(neighbor1); | |
20 Palette.Entry e2 = palette.getEntryByIndex(neighbor2); | |
21 | |
22 if (e1 == null || e2 == null) { | |
23 return null; | |
24 } | |
25 | |
26 double e1t = e1.getFrom(); | |
27 double e2f = e2.getTo(); | |
28 | |
29 return Double.valueOf(e2f >= e1t | |
30 ? 0.5d*(e1t+e2f) | |
31 : 0.5d*(e2.getTo()+e1.getFrom())); | |
32 } | |
33 } | |
34 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: |