teichmann@5863: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5863: * Software engineering by Intevation GmbH teichmann@5863: * teichmann@5994: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5863: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5994: * documentation coming with Dive4Elements River for details. teichmann@5863: */ teichmann@5863: teichmann@5831: package org.dive4elements.river.jfree; christian@3254: christian@3254: import java.awt.Color; christian@3254: christian@3254: import org.jfree.chart.plot.IntervalMarker; christian@3254: teichmann@6905: import org.dive4elements.river.themes.ThemeDocument; christian@3464: christian@3254: /** christian@3254: * Marker that represents a highlighted interval. christian@3889: * christian@3254: * @author Christian Lins christian@3254: */ christian@3254: public class StyledDomainMarker extends IntervalMarker { christian@3254: christian@3738: private static final long serialVersionUID = -4369417661339512342L; sascha@3256: rrenkert@4686: private final Color backgroundColor, backgroundColor2; sascha@3256: teichmann@6905: public StyledDomainMarker(double start, double end, ThemeDocument theme) { christian@3254: super(start, end); sascha@3256: teichmann@6908: backgroundColor = theme.parseAreaBackgroundColor(); rrenkert@4686: backgroundColor2 = new Color( rrenkert@4686: 255 - backgroundColor.getRed(), rrenkert@4686: 255 - backgroundColor.getGreen(), rrenkert@4686: 255 - backgroundColor.getBlue()); christian@3254: useSecondColor(false); sascha@3256: teichmann@6908: int alpha = 100 - theme.parseAreaTransparency(50); christian@3738: setAlpha(alpha / 100.0f); christian@3254: } sascha@3256: christian@3254: /** christian@3254: * To properly differentiate several styled domain markers side by side, christian@3254: * we can use this switch to toggle between two colors. christian@3254: * @param secondColor christian@3254: */ christian@3254: public void useSecondColor(boolean secondColor) { rrenkert@4686: if(!secondColor) { christian@3464: if(backgroundColor != null) christian@3464: setPaint(backgroundColor); christian@3254: } christian@3254: else { rrenkert@4686: if(backgroundColor2 != null) rrenkert@4686: setPaint(backgroundColor2); christian@3254: } christian@3254: } christian@3254: } sascha@3259: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :