Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/jfree/ColorMapper.java @ 8910:d9c89651bd67
Area chart layers may now have an 'arebgpattern'. Real pattern yet to be defined.
author | gernotbelger |
---|---|
date | Thu, 22 Feb 2018 18:46:37 +0100 |
parents | |
children | 5dacb6ea75a1 |
comparison
equal
deleted
inserted
replaced
8909:31dff17c6828 | 8910:d9c89651bd67 |
---|---|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 package org.dive4elements.river.jfree; | |
11 | |
12 import java.awt.Color; | |
13 import java.awt.image.LookupTable; | |
14 | |
15 final class ColorMapper extends LookupTable { | |
16 | |
17 private final int[] from; | |
18 private final int[] to; | |
19 | |
20 public ColorMapper(final Color from, final Color to) { | |
21 super(0, 4); | |
22 | |
23 this.from = new int[] { from.getRed(), from.getGreen(), from.getBlue(), from.getAlpha(), }; | |
24 this.to = new int[] { to.getRed(), to.getGreen(), to.getBlue(), to.getAlpha(), }; | |
25 } | |
26 | |
27 @Override | |
28 public int[] lookupPixel(final int[] src, final int[] dest) { | |
29 final int[] out = dest == null ? new int[src.length] : dest; | |
30 | |
31 // REMARK: only compare rgb, so we even keep the transparency level | |
32 if (src[0] == this.from[0] && src[1] == this.from[1] && src[2] == this.from[2]) { | |
33 out[0] = this.to[0]; | |
34 out[1] = this.to[1]; | |
35 out[2] = this.to[2]; | |
36 out[2] = src[3]; | |
37 } else { | |
38 System.arraycopy(src, 0, out, 0, src.length); | |
39 } | |
40 | |
41 return out; | |
42 } | |
43 } |