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: import org.w3c.dom.Document; christian@3254: teichmann@5831: import org.dive4elements.river.utils.ThemeUtil; 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: christian@3254: public StyledDomainMarker(double start, double end, Document theme) { christian@3254: super(start, end); sascha@3256: christian@3254: backgroundColor = ThemeUtil.parseColor( rrenkert@4686: ThemeUtil.getAreaBackgroundColorString(theme)); 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: christian@3889: int alpha = 100 - ThemeUtil.parseInteger( rrenkert@4686: ThemeUtil.getAreaTransparencyString(theme), 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 :