Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledDomainMarker.java @ 3254:9a4707ec7800
Add styles for W(t) chart domain markers
flys-artifacts/trunk@4888 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Fri, 06 Jul 2012 14:45:23 +0000 |
parents | |
children | 17ca0a43027a |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/StyledDomainMarker.java Fri Jul 06 14:45:23 2012 +0000 @@ -0,0 +1,46 @@ +package de.intevation.flys.jfree; + +import de.intevation.flys.utils.ThemeUtil; + +import java.awt.Color; + +import org.jfree.chart.plot.IntervalMarker; +import org.w3c.dom.Document; + +/** + * Marker that represents a highlighted interval. + * @author <a href="mailto:christian.lins@intevation.de">Christian Lins</a> + */ +public class StyledDomainMarker extends IntervalMarker { + + private static final long serialVersionUID = -4369410661339512342L; + + private final Color fillColor, backgroundColor; + + public StyledDomainMarker(double start, double end, Document theme) { + super(start, end); + + backgroundColor = ThemeUtil.parseColor( + ThemeUtil.getBackgroundColorString(theme)); + fillColor = ThemeUtil.parseColor( + ThemeUtil.getFillColorString(theme)); + useSecondColor(false); + + int alpha = ThemeUtil.parseInteger(ThemeUtil.getTransparencyAlpha(theme), 128); + setAlpha(alpha / 255.0f); + } + + /** + * To properly differentiate several styled domain markers side by side, + * we can use this switch to toggle between two colors. + * @param secondColor + */ + public void useSecondColor(boolean secondColor) { + if(secondColor) { + setPaint(backgroundColor); + } + else { + setPaint(fillColor); + } + } +}