Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/jfree/AxisDataset.java @ 9496:d8e753d0fdb9
stripedArea introduced for Assessment Scheme/Bewertungsschema
author | gernotbelger |
---|---|
date | Wed, 26 Sep 2018 15:48:05 +0200 |
parents | e5f688820951 |
children | ef5754ba5573 |
line wrap: on
line source
/* Copyright (C) 2013 by Bundesanstalt für Gewässerkunde * Software engineering by Intevation GmbH * * This file is Free Software under the GNU AGPL (>=v3) * and comes with ABSOLUTELY NO WARRANTY! Check out the * documentation coming with Dive4Elements River for details. */ package org.dive4elements.river.jfree; import java.util.ArrayList; import java.util.List; import org.jfree.data.Range; import org.jfree.data.RangeInfo; import org.jfree.data.time.TimeSeriesCollection; import org.jfree.data.xy.XYDataset; /** * Axis datasets. */ public class AxisDataset { /** Symbolic integer, but also coding the priority (0 goes first). */ protected int axisSymbol; /** List of assigned datasets (in order). */ protected List<XYDataset> datasets; /** Range to use to include all given datasets. */ protected Range range; /** Index of axis in plot. */ protected int plotAxisIndex; protected boolean rangeDirty; /** Create AxisDataset. */ public AxisDataset(final int symb) { this.axisSymbol = symb; this.datasets = new ArrayList<>(); } /** Add a dataset to internal list for this axis. */ public void addDataset(final XYDataset dataset) { this.datasets.add(dataset); this.rangeDirty = true; } public void setRange(final Range val) { this.range = val; } /** Get Range for the range axis of this dataset. */ public Range getRange() { if (this.range != null && !this.rangeDirty) { return this.range; } /* Calculate the min / max of all series */ for (final XYDataset dataset : this.datasets) { Range newRange = null; if (dataset instanceof StyledAreaSeriesCollection) { final StyledAreaSeriesCollection areaSeries = (StyledAreaSeriesCollection) dataset; if (areaSeries.shouldCalculateRange()) newRange = areaSeries.getRangeBounds(false); else { /* * For most area themes, we do not include areas in the range calculation because * they are used with very large / small values to draw areas * with axis boundaries */ continue; } } else if (dataset instanceof RangeInfo) { /* The usual case for most series */ newRange = ((RangeInfo) dataset).getRangeBounds(false); } else if (dataset instanceof TimeSeriesCollection) { /* Lalala <3 Jfreechart's class hirarchy */ newRange = ((TimeSeriesCollection) dataset).getRangeBounds(false); } /* Now we only expand as we also only add new data */ if (this.range == null) { this.range = newRange; } else { this.range = Range.combine(this.range, newRange); } } this.rangeDirty = false; return this.range; } /** Get Array of Datasets. */ public XYDataset[] getDatasets() { return this.datasets.toArray(new XYDataset[this.datasets.size()]); } /** True if no datasets given. */ public boolean isEmpty() { return this.datasets.isEmpty(); } /** Set the 'real' axis index that this axis is mapped to. */ public void setPlotAxisIndex(final int axisIndex) { this.plotAxisIndex = axisIndex; } /** Get the 'real' axis index that this axis is mapped to. */ public int getPlotAxisIndex() { return this.plotAxisIndex; } }