afreechart/src/main/java/org/afree/data/general/DatasetUtilities.java
/**
     * Iterates over the data item of the category dataset to find the range
     * bounds.
     * 
     * @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.
     * @param visibleSeriesKeys
     *            the visible series keys.
     * 
     * @return The range (possibly <code>null</code>).
     * 
     * @since JFreeChart 1.0.13
     */
Iterates over the data item of the category dataset to find the range
bounds.

@param dataset
the dataset (null not permitted).
@param includeInterval
a flag that determines whether or not the y-interval is taken
into account.
@param visibleSeriesKeys
the visible series keys.

@return The range (possibly null).


Iterates over the data item of the category dataset to find the range bounds . @param dataset the dataset ( null not permitted ) . @param includeInterval a flag that determines whether or not the y - interval is taken into account . @param visibleSeriesKeys the visible series keys . @return The range ( possibly null ) .
public static Range iterateToFindRangeBounds(CategoryDataset dataset,
            List visibleSeriesKeys, boolean includeInterval) {
        if (dataset == null) {
            throw new IllegalArgumentException("Null 'dataset' argument.");
        }
        if (visibleSeriesKeys == null) {
            throw new IllegalArgumentException(
                    "Null 'visibleSeriesKeys' argument.");
        }
        double minimum = Double.POSITIVE_INFINITY;
        double maximum = Double.NEGATIVE_INFINITY;
        int columnCount = dataset.getColumnCount();
        if (includeInterval && dataset instanceof BoxAndWhiskerCategoryDataset) {
            BoxAndWhiskerCategoryDataset bx = (BoxAndWhiskerCategoryDataset) dataset;
            Iterator iterator = visibleSeriesKeys.iterator();
            while (iterator.hasNext()) {
                Comparable seriesKey = (Comparable) iterator.next();
                int series = dataset.getRowIndex(seriesKey);
                int itemCount = dataset.getColumnCount();
                for (int item = 0; item < itemCount; item++) {
                    Number lvalue = bx.getMinRegularValue(series, item);
                    if (lvalue == null) {
                        lvalue = bx.getValue(series, item);
                    }
                    Number uvalue = bx.getMaxRegularValue(series, item);
                    if (uvalue == null) {
                        uvalue = bx.getValue(series, item);
                    }
                    if (lvalue != null) {
                        minimum = Math.min(minimum, lvalue.doubleValue());
                    }
                    if (uvalue != null) {
                        maximum = Math.max(maximum, uvalue.doubleValue());
                    }
                }
            }
        } else if (includeInterval
                && dataset instanceof IntervalCategoryDataset) {
            IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset;
            Number lvalue, uvalue;
            Iterator iterator = visibleSeriesKeys.iterator();
            while (iterator.hasNext()) {
                Comparable seriesKey = (Comparable) iterator.next();
                int series = dataset.getRowIndex(seriesKey);
                for (int column = 0; column < columnCount; column++) {
                    lvalue = icd.getStartValue(series, column);
                    uvalue = icd.getEndValue(series, column);
                    if (lvalue != null && !Double.isNaN(lvalue.doubleValue())) {
                        minimum = Math.min(minimum, lvalue.doubleValue());
                    }
                    if (uvalue != null && !Double.isNaN(uvalue.doubleValue())) {
                        maximum = Math.max(maximum, uvalue.doubleValue());
                    }
                }
            }
        } else if (includeInterval
                && dataset instanceof StatisticalCategoryDataset) {
            StatisticalCategoryDataset scd = (StatisticalCategoryDataset) dataset;
            Iterator iterator = visibleSeriesKeys.iterator();
            while (iterator.hasNext()) {
                Comparable seriesKey = (Comparable) iterator.next();
                int series = dataset.getRowIndex(seriesKey);
                for (int column = 0; column < columnCount; column++) {
                    Number meanN = scd.getMeanValue(series, column);
                    if (meanN != null) {
                        double std = 0.0;
                        Number stdN = scd.getStdDevValue(series, column);
                        if (stdN != null) {
                            std = stdN.doubleValue();
                            if (Double.isNaN(std)) {
                                std = 0.0;
                            }
                        }
                        double mean = meanN.doubleValue();
                        if (!Double.isNaN(mean)) {
                            minimum = Math.min(minimum, mean - std);
                            maximum = Math.max(maximum, mean + std);
                        }
                    }
                }
            }
        } else {
            Iterator iterator = visibleSeriesKeys.iterator();
            while (iterator.hasNext()) {
                Comparable seriesKey = (Comparable) iterator.next();
                int series = dataset.getRowIndex(seriesKey);
                for (int column = 0; column < columnCount; column++) {
                    Number value = dataset.getValue(series, 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);
        }
    }
public static Range iterateToFindRangeBounds ( CategoryDataset dataset , List visibleSeriesKeys , boolean includeInterval ) { if ( dataset == null ) { throw new IllegalArgumentException ( "Null 'dataset' argument." ) ; } if ( visibleSeriesKeys == null ) { throw new IllegalArgumentException ( "Null 'visibleSeriesKeys' argument." ) ; } double minimum = Double . POSITIVE_INFINITY ; double maximum = Double . NEGATIVE_INFINITY ; int columnCount = dataset . getColumnCount ( ) ; if ( includeInterval && dataset instanceof BoxAndWhiskerCategoryDataset ) { BoxAndWhiskerCategoryDataset bx = ( BoxAndWhiskerCategoryDataset ) dataset ; Iterator iterator = visibleSeriesKeys . iterator ( ) ; while ( iterator . hasNext ( ) ) { Comparable seriesKey = ( Comparable ) iterator . next ( ) ; int series = dataset . getRowIndex ( seriesKey ) ; int itemCount = dataset . getColumnCount ( ) ; for ( int item = 0 ; item < itemCount ; item ++ ) { Number lvalue = bx . getMinRegularValue ( series , item ) ; if ( lvalue == null ) { lvalue = bx . getValue ( series , item ) ; } Number uvalue = bx . getMaxRegularValue ( series , item ) ; if ( uvalue == null ) { uvalue = bx . getValue ( series , item ) ; } if ( lvalue != null ) { minimum = Math . min ( minimum , lvalue . doubleValue ( ) ) ; } if ( uvalue != null ) { maximum = Math . max ( maximum , uvalue . doubleValue ( ) ) ; } } } } else if ( includeInterval && dataset instanceof IntervalCategoryDataset ) { IntervalCategoryDataset icd = ( IntervalCategoryDataset ) dataset ; Number lvalue , uvalue ; Iterator iterator = visibleSeriesKeys . iterator ( ) ; while ( iterator . hasNext ( ) ) { Comparable seriesKey = ( Comparable ) iterator . next ( ) ; int series = dataset . getRowIndex ( seriesKey ) ; for ( int column = 0 ; column < columnCount ; column ++ ) { lvalue = icd . getStartValue ( series , column ) ; uvalue = icd . getEndValue ( series , column ) ; if ( lvalue != null && ! Double . isNaN ( lvalue . doubleValue ( ) ) ) { minimum = Math . min ( minimum , lvalue . doubleValue ( ) ) ; } if ( uvalue != null && ! Double . isNaN ( uvalue . doubleValue ( ) ) ) { maximum = Math . max ( maximum , uvalue . doubleValue ( ) ) ; } } } } else if ( includeInterval && dataset instanceof StatisticalCategoryDataset ) { StatisticalCategoryDataset scd = ( StatisticalCategoryDataset ) dataset ; Iterator iterator = visibleSeriesKeys . iterator ( ) ; while ( iterator . hasNext ( ) ) { Comparable seriesKey = ( Comparable ) iterator . next ( ) ; int series = dataset . getRowIndex ( seriesKey ) ; for ( int column = 0 ; column < columnCount ; column ++ ) { Number meanN = scd . getMeanValue ( series , column ) ; if ( meanN != null ) { double std = 0.0 ; Number stdN = scd . getStdDevValue ( series , column ) ; if ( stdN != null ) { std = stdN . doubleValue ( ) ; if ( Double . isNaN ( std ) ) { std = 0.0 ; } } double mean = meanN . doubleValue ( ) ; if ( ! Double . isNaN ( mean ) ) { minimum = Math . min ( minimum , mean - std ) ; maximum = Math . max ( maximum , mean + std ) ; } } } } } else { Iterator iterator = visibleSeriesKeys . iterator ( ) ; while ( iterator . hasNext ( ) ) { Comparable seriesKey = ( Comparable ) iterator . next ( ) ; int series = dataset . getRowIndex ( seriesKey ) ; for ( int column = 0 ; column < columnCount ; column ++ ) { Number value = dataset . getValue ( series , 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 ) ; } }
Iterates over the data item of the category dataset to find the range
 bounds.
Iterates over the data item of the category dataset to find the range bounds .
// handle special case of BoxAndWhiskerDataset // handle the special case where the dataset has y-intervals that // we want to measure // handle the special case where the dataset has y-intervals that // we want to measure // handle the standard case (plain CategoryDataset)