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

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

Introduction

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

Prototype

public double getYValue(int series, int item);

Source Link

Document

Returns the y-value (as a double primitive) for an item within a series.

Usage

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

/**
 * Calculates the stacked values (one positive and one negative) of all
 * series up to, but not including, <code>series</code> for the specified
 * item. It returns [0.0, 0.0] if <code>series</code> is the first series.
 *
 * @param dataset the dataset (<code>null</code> not permitted).
 * @param series the series index./*from ww w. ja v a 2 s  .com*/
 * @param index the item index.
 * @return An array containing the cumulative negative and positive values
 *         for all series values up to but excluding <code>series</code>
 *         for <code>index</code>.
 */
private double[] getStackValues(TableXYDataset dataset, int series, int index) {
    double[] result = new double[2];
    for (int i = 0; i < series; i++) {
        double v = dataset.getYValue(i, index);
        if (!Double.isNaN(v)) {
            if (v >= 0.0) {
                result[1] += v;
            } else {
                result[0] += v;
            }
        }
    }
    return result;
}

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  ava 2 s .  com
 *
 * @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 www . j  a va 2  s.c  o 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.//w  w w . ja v  a 2  s  .co  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;
    }
}