Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/raster/IsoAttributeGenerator.java @ 1119:7c4f81f74c47
merged gnv-artifacts
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:00 +0200 |
parents | f953c9a559d8 |
children |
comparison
equal
deleted
inserted
replaced
1027:fca4b5eb8d2f | 1119:7c4f81f74c47 |
---|---|
1 /* | |
2 * Copyright (c) 2010 by Intevation GmbH | |
3 * | |
4 * This program is free software under the LGPL (>=v2.1) | |
5 * Read the file LGPL.txt coming with the software for details | |
6 * or visit http://www.gnu.org/licenses/ if it does not exist. | |
7 */ | |
8 | |
9 package de.intevation.gnv.raster; | |
10 | |
11 /** | |
12 * Generates label attributes for iso lines. It takes the | |
13 * neighboring palette ranges and calculates the mid point | |
14 * between these two ranges. | |
15 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> | |
16 */ | |
17 public class IsoAttributeGenerator | |
18 implements IsoProducer.AttributeGenerator | |
19 { | |
20 /** | |
21 * The palette where to look for the ranges. | |
22 */ | |
23 protected Palette palette; | |
24 | |
25 /** | |
26 * Default constructor. | |
27 */ | |
28 public IsoAttributeGenerator() { | |
29 } | |
30 | |
31 /** | |
32 * Constructor to create an IsoAttributeGenerator with | |
33 * a given lookup palette. | |
34 * @param palette The palette. | |
35 */ | |
36 public IsoAttributeGenerator(Palette palette) { | |
37 this.palette = palette; | |
38 } | |
39 | |
40 public Object generateAttribute(int neighbor1, int neighbor2) { | |
41 Palette.Entry e1 = palette.getEntryByIndex(neighbor1); | |
42 Palette.Entry e2 = palette.getEntryByIndex(neighbor2); | |
43 | |
44 if (e1 == null || e2 == null) { | |
45 return null; | |
46 } | |
47 | |
48 double e1t = e1.getFrom(); | |
49 double e2f = e2.getTo(); | |
50 | |
51 return Double.valueOf(e2f >= e1t | |
52 ? 0.5d*(e1t+e2f) | |
53 : 0.5d*(e2.getTo()+e1.getFrom())); | |
54 } | |
55 } | |
56 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |