Example usage for org.jfree.data.category IntervalCategoryDataset getValue

List of usage examples for org.jfree.data.category IntervalCategoryDataset getValue

Introduction

In this page you can find the example usage for org.jfree.data.category IntervalCategoryDataset getValue.

Prototype

public Number getValue(Comparable rowKey, Comparable columnKey);

Source Link

Document

Returns the value associated with the specified keys.

Usage

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

/**
 * Iterates over the data item of the category dataset to find
 * the range bounds./*from   w w w  .j  a  v  a2 s  .c  o m*/
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param includeInterval  a flag that determines whether or not the
 *                         y-interval is taken into account.
 *
 * @return The range (possibly <code>null</code>).
 *
 * @since 1.0.10
 */
public static Range iterateRangeBounds(CategoryDataset dataset, boolean includeInterval) {
    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;
    int rowCount = dataset.getRowCount();
    int columnCount = dataset.getColumnCount();
    if (includeInterval && dataset instanceof IntervalCategoryDataset) {
        // handle the special case where the dataset has y-intervals that
        // we want to measure
        IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset;
        Number value, lvalue, uvalue;
        for (int row = 0; row < rowCount; row++) {
            for (int column = 0; column < columnCount; column++) {
                value = icd.getValue(row, column);
                double v;
                if ((value != null) && !Double.isNaN(v = value.doubleValue())) {
                    minimum = Math.min(v, minimum);
                    maximum = Math.max(v, maximum);
                }
                lvalue = icd.getStartValue(row, column);
                if (lvalue != null && !Double.isNaN(v = lvalue.doubleValue())) {
                    minimum = Math.min(v, minimum);
                    maximum = Math.max(v, maximum);
                }
                uvalue = icd.getEndValue(row, column);
                if (uvalue != null && !Double.isNaN(v = uvalue.doubleValue())) {
                    minimum = Math.min(v, minimum);
                    maximum = Math.max(v, maximum);
                }
            }
        }
    } else {
        // handle the standard case (plain CategoryDataset)
        for (int row = 0; row < rowCount; row++) {
            for (int column = 0; column < columnCount; column++) {
                Number value = dataset.getValue(row, column);
                if (value != null) {
                    double v = value.doubleValue();
                    if (!Double.isNaN(v)) {
                        minimum = Math.min(minimum, v);
                        maximum = Math.max(maximum, v);
                    }
                }
            }
        }
    }
    if (minimum == Double.POSITIVE_INFINITY) {
        return null;
    } else {
        return new Range(minimum, maximum);
    }
}