Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/jfree/ColorMapper.java @ 9576:c5c53e52f190
area pattern transparency sinfo tkh
author | gernotbelger |
---|---|
date | Wed, 07 Nov 2018 14:23:47 +0100 |
parents | 5dacb6ea75a1 |
children |
line wrap: on
line source
/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde * Software engineering by * Björnsen Beratende Ingenieure GmbH * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt * * This file is Free Software under the GNU AGPL (>=v3) * and comes with ABSOLUTELY NO WARRANTY! Check out the * documentation coming with Dive4Elements River for details. */ package org.dive4elements.river.jfree; import java.awt.Color; import java.awt.image.LookupTable; final class ColorMapper extends LookupTable { private final int[] from; private final int[] to; public ColorMapper(final Color from, final Color to) { super(0, 4); this.from = new int[] { from.getRed(), from.getGreen(), from.getBlue(), from.getAlpha(), }; this.to = new int[] { to.getRed(), to.getGreen(), to.getBlue(), to.getAlpha(), }; } @Override public int[] lookupPixel(final int[] src, final int[] dest) { final int[] out = dest == null ? new int[src.length] : dest; // REMARK: only check opacity, because the transparency of the pattern-images is not 100% good if (src[3] > 128) { out[0] = this.to[0]; out[1] = this.to[1]; out[2] = this.to[2]; out[3] = this.to[3]; } else { out[0] = 0; out[1] = 0; out[2] = 0; out[3] = 0; } return out; } }