view flys-artifacts/src/main/java/de/intevation/flys/exports/ChartHelper.java @ 2240:e9173de1026c

The HistoricalDischargeCurveGenerator now creates new AxisDataset objects and new TimeSeriesCollections for each Facet. flys-artifacts/trunk@3887 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 02 Feb 2012 16:39:50 +0000
parents 60615235e951
children 2b232871ba28
line wrap: on
line source
package de.intevation.flys.exports;

import org.jfree.data.Range;
import org.jfree.data.xy.XYDataset;


/**
 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
 */
public class ChartHelper {

    /**
     * This method returns the ranges of the XYDataset <i>dataset</i> as array
     * with [xrange, yrange].
     *
     * @param dataset The dataset which should be evaluated.
     *
     * @return an array with x and y ranges.
     */
    public static Range[] getRanges(XYDataset dataset) {
        if (dataset == null) {
            return null;
        }

        double minX = Double.MAX_VALUE;
        double maxX = -Double.MAX_VALUE;
        double minY = Double.MAX_VALUE;
        double maxY = -Double.MAX_VALUE;

        for (int i = 0, m = dataset.getSeriesCount(); i < m; i++) {
            for (int j = 0, n = dataset.getItemCount(i); j < n; j++) {
                double x = dataset.getXValue(i, j);
                double y = dataset.getYValue(i, j);

                if (x < minX) {
                    minX = x;
                }

                if (x > maxX) {
                    maxX = x;
                }

                if (y < minY) {
                    minY = y;
                }

                if (y > maxY) {
                    maxY = y;
                }
            }
        }

        return new Range[] { new Range(minX, maxX), new Range(minY, maxY) };
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org