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; ingo@2074: christian@3155: import java.util.List; ingo@2074: ingo@2074: import org.apache.log4j.Logger; teichmann@6905: import org.dive4elements.river.themes.ThemeDocument; ingo@2074: christian@3155: import org.jfree.data.xy.XYDataItem; ingo@2074: import org.jfree.data.xy.XYSeries; ingo@2074: sascha@7541: import java.awt.Shape; sascha@7541: ingo@2074: /** ingo@2321: * @author Ingo Weinzierl ingo@2074: */ felix@2652: public class StyledXYSeries extends XYSeries implements StyledSeries, HasLabel { ingo@2074: ingo@2074: private static final Logger logger = Logger.getLogger(StyledXYSeries.class); ingo@2074: ingo@2321: protected Style style; ingo@2321: felix@2652: /** If this Series is to be labelled, use this String as label. */ felix@2652: protected String label; felix@2652: ingo@2074: teichmann@6905: public StyledXYSeries(String key, ThemeDocument theme) { sascha@7541: this(key, true, theme, (Shape)null); ingo@2074: } sascha@3160: sascha@3160: teichmann@6905: public StyledXYSeries(String key, ThemeDocument theme, XYSeries unstyledSeries) { christian@3155: this(key, theme); christian@3155: add(unstyledSeries); christian@3155: } ingo@2074: sascha@7541: public StyledXYSeries(String key, boolean sorted, ThemeDocument theme) { sascha@7541: this(key, sorted, theme, (Shape)null); sascha@7541: } sascha@7541: sascha@7541: sascha@7541: public StyledXYSeries(String key, ThemeDocument theme, Shape shape) { sascha@7541: this(key, true, theme, shape); sascha@7541: } ingo@2074: ingo@2074: /** ingo@2074: * @param sorted whether or not to sort the points. Sorting will move NANs ingo@2074: * to one extrema which can cause problems in certain ingo@2074: * algorithms. ingo@2074: */ sascha@7541: public StyledXYSeries(String key, boolean sorted, ThemeDocument theme, Shape shape) { ingo@2074: super(key, sorted); sascha@7541: setStyle(new XYStyle(theme, shape)); felix@2652: this.label = key.toString(); ingo@2074: } ingo@2074: teichmann@6876: public StyledXYSeries( sascha@7541: String key, sascha@7541: boolean sorted, sascha@7541: boolean allowDuplicateXValues, teichmann@6905: ThemeDocument theme teichmann@6876: ) { sascha@7541: this(key, sorted, allowDuplicateXValues, theme, (Shape)null); sascha@7541: } sascha@7541: sascha@7541: public StyledXYSeries( sascha@7541: String key, sascha@7541: boolean sorted, sascha@7541: boolean allowDuplicateXValues, sascha@7541: ThemeDocument theme, sascha@7541: Shape shape sascha@7541: ) { teichmann@6876: super(key, sorted, allowDuplicateXValues); sascha@7541: setStyle(new XYStyle(theme, shape)); teichmann@6876: this.label = key.toString(); teichmann@6876: } teichmann@6876: teichmann@6876: ingo@2321: @Override ingo@2321: public void setStyle(Style style) { ingo@2321: this.style = style; ingo@2076: } ingo@2076: ingo@2076: ingo@2321: @Override ingo@2321: public Style getStyle() { ingo@2321: return style; ingo@2074: } felix@2652: sascha@3076: felix@2652: @Override felix@2652: public String getLabel() { felix@2652: return label; felix@2652: } felix@2652: felix@2652: @Override felix@2652: public void setLabel(String label) { felix@2652: this.label = label; felix@2652: } sascha@3160: christian@3155: protected void add(XYSeries series) { christian@3155: List items = series.getItems(); christian@3155: add(items); christian@3155: } sascha@3160: christian@3155: protected void add(List items) { christian@3155: for(XYDataItem item : items) { christian@3155: add(item.getXValue(), item.getYValue()); christian@3155: } christian@3155: } ingo@2074: } ingo@2074: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :