ingo@2074: package de.intevation.flys.jfree;
ingo@2074:
christian@3155: import java.util.List;
ingo@2074:
ingo@2074: import org.apache.log4j.Logger;
ingo@2074:
ingo@2074: import org.w3c.dom.Document;
ingo@2074:
christian@3155: import org.jfree.data.xy.XYDataItem;
ingo@2074: import org.jfree.data.xy.XYSeries;
ingo@2074:
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:
ingo@2074: public StyledXYSeries(String key, Document theme) {
ingo@2074: this(key, true, theme);
felix@2652: this.label = key.toString();
ingo@2074: }
sascha@3160:
sascha@3160:
christian@3155: public StyledXYSeries(String key, Document theme, XYSeries unstyledSeries) {
christian@3155: this(key, theme);
christian@3155: add(unstyledSeries);
christian@3155: }
ingo@2074:
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: */
ingo@2074: public StyledXYSeries(String key, boolean sorted, Document theme) {
ingo@2074: super(key, sorted);
ingo@2321: setStyle(new XYStyle(theme));
felix@2652: this.label = key.toString();
ingo@2074: }
ingo@2074:
ingo@2074:
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 :