Example usage for org.jfree.data.xy TableXYDataset getSeriesCount

List of usage examples for org.jfree.data.xy TableXYDataset getSeriesCount

Introduction

In this page you can find the example usage for org.jfree.data.xy TableXYDataset getSeriesCount.

Prototype

public int getSeriesCount();

Source Link

Document

Returns the number of series in the dataset.

Usage

From source file:de.saring.util.gui.jfreechart.StackedRenderer.java

/**
 * Returns the range of values the renderer requires to display all the
 * items from the specified dataset./*from   w  ww .  j a  v  a  2  s . c o  m*/
 *
 * @param dataset the dataset (<code>null</code> permitted).
 * @return The range (or <code>null</code> if the dataset is
 *         <code>null</code> or empty).
 */
@Override
public Range findRangeBounds(XYDataset dataset) {
    if (dataset == null) {
        return null;
    }
    double min = Double.POSITIVE_INFINITY;
    double max = Double.NEGATIVE_INFINITY;
    TableXYDataset d = (TableXYDataset) dataset;
    int itemCount = d.getItemCount();
    for (int i = 0; i < itemCount; i++) {
        double[] stackValues = getStackValues((TableXYDataset) dataset, d.getSeriesCount(), i);
        min = Math.min(min, stackValues[0]);
        max = Math.max(max, stackValues[1]);
    }
    if (min == Double.POSITIVE_INFINITY) {
        return null;
    }
    return new Range(min, max);
}

From source file:org.jfree.data.general.DatasetUtilities.java

/**
 * Calculates the total for the y-values in all series for a given item
 * index.//from w w  w .j  a v  a  2s.co  m
 *
 * @param dataset  the dataset.
 * @param item  the item index.
 *
 * @return The total.
 *
 * @since 1.0.5
 */
public static double calculateStackTotal(TableXYDataset dataset, int item) {
    double total = 0.0;
    int seriesCount = dataset.getSeriesCount();
    for (int s = 0; s < seriesCount; s++) {
        double value = dataset.getYValue(s, item);
        if (!Double.isNaN(value)) {
            total = total + value;
        }
    }
    return total;
}

From source file:org.jfree.data.general.DatasetUtils.java

/**
 * Returns the minimum and maximum values for the dataset's range,
 * assuming that the series are stacked, using the specified base value.
 *
 * @param dataset  the dataset ({@code null} not permitted).
 * @param base  the base value./*from  w  w w.  ja  v  a2  s.  co m*/
 *
 * @return The range ({@code null} if the dataset contains no values).
 */
public static Range findStackedRangeBounds(TableXYDataset dataset, double base) {
    Args.nullNotPermitted(dataset, "dataset");
    double minimum = base;
    double maximum = base;
    for (int itemNo = 0; itemNo < dataset.getItemCount(); itemNo++) {
        double positive = base;
        double negative = base;
        int seriesCount = dataset.getSeriesCount();
        for (int seriesNo = 0; seriesNo < seriesCount; seriesNo++) {
            double y = dataset.getYValue(seriesNo, itemNo);
            if (!Double.isNaN(y)) {
                if (y > 0.0) {
                    positive += y;
                } else {
                    negative += y;
                }
            }
        }
        if (positive > maximum) {
            maximum = positive;
        }
        if (negative < minimum) {
            minimum = negative;
        }
    }
    if (minimum <= maximum) {
        return new Range(minimum, maximum);
    } else {
        return null;
    }
}

From source file:org.jfree.data.general.DatasetUtilities.java

/**
 * Returns the minimum and maximum values for the dataset's range,
 * assuming that the series are stacked, using the specified base value.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param base  the base value./*from w ww. j a  v  a  2 s .c o m*/
 *
 * @return The range (<code>null</code> if the dataset contains no values).
 */
public static Range findStackedRangeBounds(TableXYDataset dataset, double base) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    double minimum = base;
    double maximum = base;
    for (int itemNo = 0; itemNo < dataset.getItemCount(); itemNo++) {
        double positive = base;
        double negative = base;
        int seriesCount = dataset.getSeriesCount();
        for (int seriesNo = 0; seriesNo < seriesCount; seriesNo++) {
            double y = dataset.getYValue(seriesNo, itemNo);
            if (!Double.isNaN(y)) {
                if (y > 0.0) {
                    positive += y;
                } else {
                    negative += y;
                }
            }
        }
        if (positive > maximum) {
            maximum = positive;
        }
        if (negative < minimum) {
            minimum = negative;
        }
    }
    if (minimum <= maximum) {
        return new Range(minimum, maximum);
    } else {
        return null;
    }
}