felix@2020: package de.intevation.flys.exports; felix@2020: felix@2020: import java.awt.BasicStroke; felix@2020: import java.awt.Color; felix@2020: import java.awt.Paint; felix@2020: import java.awt.geom.Ellipse2D; felix@2020: felix@2020: import org.apache.log4j.Logger; felix@2020: felix@2020: import org.w3c.dom.Document; felix@2020: felix@2020: import org.jfree.data.xy.XYSeriesCollection; felix@2020: import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; felix@2020: import org.jfree.data.Range; felix@2020: import org.jfree.data.xy.XYSeries; felix@2020: felix@2020: import de.intevation.flys.utils.ThemeUtil; felix@2020: import de.intevation.flys.jfree.StableXYDifferenceRenderer; felix@2020: felix@2020: felix@2020: /** felix@2020: * One or more dataseries to draw a polygon (either "open up/downwards", or felix@2020: * the area between two curves), a theme-document and further display options. felix@2020: * The theme-document will later "style" the graphical representation. felix@2020: * The display options can be used to control the z-order and the axis of the felix@2020: * dataset. felix@2020: */ felix@2020: public class StyledAreaSeriesCollection extends XYSeriesCollection { felix@2020: /** Mode, how to draw/which areas to fill. */ felix@2020: public enum FILL_MODE {UNDER, ABOVE, BETWEEN}; felix@2020: felix@2020: /** MODE in use. */ felix@2020: protected FILL_MODE mode; felix@2020: felix@2020: /** The theme-document with attributes about actual visual representation. */ felix@2020: protected Document theme; felix@2020: felix@2020: /** Own logger. */ felix@2020: private static final Logger logger = felix@2020: Logger.getLogger(StyledAreaSeriesCollection.class); felix@2020: felix@2020: felix@2020: /** felix@2020: * @param theme the theme-document. felix@2020: */ felix@2020: public StyledAreaSeriesCollection(Document theme) { felix@2020: this.theme = theme; felix@2020: this.mode = FILL_MODE.BETWEEN; felix@2020: } felix@2020: felix@2020: felix@2020: /** Gets the Fill mode. */ felix@2020: public FILL_MODE getMode() { felix@2020: return this.mode; felix@2020: } felix@2020: felix@2020: felix@2020: /** Sets the Fill mode. */ felix@2020: public void setMode(FILL_MODE fMode) { felix@2020: this.mode = fMode; felix@2020: } felix@2020: felix@2020: felix@2020: /** felix@2020: * Applies line color, size and type attributes to renderer, also felix@2020: * whether to draw lines and/or points. felix@2020: */ felix@2020: public StableXYDifferenceRenderer applyTheme( felix@2020: StableXYDifferenceRenderer renderer felix@2020: ) { felix@2020: applyFillColor(renderer); felix@2020: applyShowShape(renderer); felix@2020: felix@2020: return renderer; felix@2020: } felix@2020: felix@2020: felix@2020: /** felix@2020: * Blindly (for now) apply the postiviepaint of renderer. felix@2020: */ felix@2020: protected void applyFillColor(StableXYDifferenceRenderer renderer) { felix@2020: Paint paint = ThemeUtil.parseFillColorField(theme); felix@2020: if (paint != null) felix@2020: renderer.setPositivePaint(paint); felix@2020: // TODO set negativepaint? Dependend on the over/under/between settings felix@2020: } felix@2020: felix@2020: /** felix@2020: * Blindly (for now) apply the postiviepaint of renderer. felix@2020: */ felix@2020: protected void applyShowShape(StableXYDifferenceRenderer renderer) { felix@2020: boolean show = ThemeUtil.parseShowBorder(theme); felix@2020: renderer.setShapesVisible(show); felix@2020: } felix@2020: } felix@2020: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :