sascha@422: package de.intevation.gnv.jfreechart; sascha@422: sascha@422: import java.util.List; sascha@422: import java.util.ArrayList; sascha@422: sascha@422: import org.jfree.data.Range; sascha@422: import org.jfree.data.general.AbstractSeriesDataset; sascha@422: sascha@422: /** sascha@422: * @author Ingo Weinzierl sascha@422: */ sascha@422: public class PolygonDataset sascha@422: extends AbstractSeriesDataset sascha@422: { sascha@422: /** PolygonSeries included in this Dataset */ sascha@422: private List data; sascha@422: sascha@422: sascha@422: public PolygonDataset() { sascha@422: this(null); sascha@422: } sascha@422: sascha@422: sascha@422: public PolygonDataset(PolygonSeries series) { sascha@422: data = new ArrayList(); sascha@422: sascha@422: if (series != null) { sascha@422: data.add(series); sascha@422: } sascha@422: } sascha@422: sascha@422: sascha@422: public void addSeries(PolygonSeries series) { sascha@422: if (series == null) sascha@422: throw new IllegalArgumentException("Null 'series' argument."); sascha@422: sascha@422: data.add(series); sascha@422: } sascha@422: sascha@422: sascha@422: public Range getDomainBounds() { sascha@422: double lower = Double.POSITIVE_INFINITY; sascha@422: double upper = Double.NEGATIVE_INFINITY; sascha@422: int seriesCount = getSeriesCount(); sascha@422: sascha@422: for (int s = 0; s < seriesCount; s++) { sascha@422: PolygonSeries series = getSeries(s); sascha@422: sascha@422: Range domainRange = series.getDomainBounds(); sascha@422: double minX = domainRange.getLowerBound(); sascha@422: if (!Double.isNaN(minX)) { sascha@422: lower = Math.min(lower, minX); sascha@422: } sascha@422: sascha@422: double maxX = domainRange.getUpperBound(); sascha@422: if (!Double.isNaN(maxX)) { sascha@422: upper = Math.max(upper, maxX); sascha@422: } sascha@422: } sascha@422: sascha@422: return new Range(lower, upper); sascha@422: } sascha@422: sascha@422: sascha@422: public Range getRangeBounds() { sascha@422: double lower = Double.POSITIVE_INFINITY; sascha@422: double upper = Double.NEGATIVE_INFINITY; sascha@422: int seriesCount = getSeriesCount(); sascha@422: sascha@422: for (int i = 0; i < seriesCount; i++) { sascha@422: PolygonSeries series = getSeries(i); sascha@422: sascha@422: Range range = series.getRangeBounds(); sascha@422: double minX = range.getLowerBound(); sascha@422: if (!Double.isNaN(minX)) { sascha@422: lower = Math.min(lower, minX); sascha@422: } sascha@422: sascha@422: double maxX = range.getUpperBound(); sascha@422: if (!Double.isNaN(maxX)) { sascha@422: upper = Math.max(upper, maxX); sascha@422: } sascha@422: } sascha@422: sascha@422: return new Range(lower, upper); sascha@422: } sascha@422: sascha@422: sascha@422: public int getSeriesCount() { sascha@422: return data.size(); sascha@422: } sascha@422: sascha@422: sascha@422: public Comparable getSeriesKey(int series) { sascha@422: return ((PolygonSeries)data.get(series)).getKey(); sascha@422: } sascha@422: sascha@422: sascha@422: public PolygonSeries getSeries(int idx) { sascha@422: return (PolygonSeries)data.get(idx); sascha@422: } sascha@422: } sascha@422: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :