afreechart/src/main/java/org/afree/data/general/DatasetUtilities.java
/**
     * Iterates over the data items of the xy dataset to find the range bounds.
     * 
     * @param dataset
     *            the dataset (<code>null</code> not permitted).
     * @param includeInterval
     *            a flag that determines, for an {@link IntervalXYDataset},
     *            whether the y-interval or just the y-value is used to
     *            determine the overall range.
     * 
     * @return The range (possibly <code>null</code>).
     * 
     * @since JFreeChart 1.0.10
     */
Iterates over the data items of the xy dataset to find the range bounds.

@param dataset
the dataset (null not permitted).
@param includeInterval
a flag that determines, for an  IntervalXYDataset,
whether the y-interval or just the y-value is used to
determine the overall range.

@return The range (possibly null).


Iterates over the data items of the xy dataset to find the range bounds . @param dataset the dataset ( null not permitted ) . @param includeInterval a flag that determines for an IntervalXYDataset whether the y - interval or just the y - value is used to determine the overall range . @return The range ( possibly null ) .
public static Range iterateRangeBounds(XYDataset dataset,
            boolean includeInterval) {
        double minimum = Double.POSITIVE_INFINITY;
        double maximum = Double.NEGATIVE_INFINITY;
        int seriesCount = dataset.getSeriesCount();
        if (includeInterval && dataset instanceof IntervalXYDataset) {
            IntervalXYDataset ixyd = (IntervalXYDataset) dataset;
            for (int series = 0; series < seriesCount; series++) {
                int itemCount = dataset.getItemCount(series);
                for (int item = 0; item < itemCount; item++) {
                    double lvalue = ixyd.getStartYValue(series, item);
                    double uvalue = ixyd.getEndYValue(series, item);
                    if (!Double.isNaN(lvalue)) {
                        minimum = Math.min(minimum, lvalue);
                    }
                    if (!Double.isNaN(uvalue)) {
                        maximum = Math.max(maximum, uvalue);
                    }
                }
            }
        } else if (includeInterval && dataset instanceof OHLCDataset) {
            OHLCDataset ohlc = (OHLCDataset) dataset;
            for (int series = 0; series < seriesCount; series++) {
                int itemCount = dataset.getItemCount(series);
                for (int item = 0; item < itemCount; item++) {
                    double lvalue = ohlc.getLowValue(series, item);
                    double uvalue = ohlc.getHighValue(series, item);
                    if (!Double.isNaN(lvalue)) {
                        minimum = Math.min(minimum, lvalue);
                    }
                    if (!Double.isNaN(uvalue)) {
                        maximum = Math.max(maximum, uvalue);
                    }
                }
            }
        } else {
            for (int series = 0; series < seriesCount; series++) {
                int itemCount = dataset.getItemCount(series);
                for (int item = 0; item < itemCount; item++) {
                    double value = dataset.getYValue(series, item);
                    if (!Double.isNaN(value)) {
                        minimum = Math.min(minimum, value);
                        maximum = Math.max(maximum, value);
                    }
                }
            }
        }
        if (minimum == Double.POSITIVE_INFINITY) {
            return null;
        } else {
            return new Range(minimum, maximum);
        }
    }
public static Range iterateRangeBounds ( XYDataset dataset , boolean includeInterval ) { double minimum = Double . POSITIVE_INFINITY ; double maximum = Double . NEGATIVE_INFINITY ; int seriesCount = dataset . getSeriesCount ( ) ; if ( includeInterval && dataset instanceof IntervalXYDataset ) { IntervalXYDataset ixyd = ( IntervalXYDataset ) dataset ; for ( int series = 0 ; series < seriesCount ; series ++ ) { int itemCount = dataset . getItemCount ( series ) ; for ( int item = 0 ; item < itemCount ; item ++ ) { double lvalue = ixyd . getStartYValue ( series , item ) ; double uvalue = ixyd . getEndYValue ( series , item ) ; if ( ! Double . isNaN ( lvalue ) ) { minimum = Math . min ( minimum , lvalue ) ; } if ( ! Double . isNaN ( uvalue ) ) { maximum = Math . max ( maximum , uvalue ) ; } } } } else if ( includeInterval && dataset instanceof OHLCDataset ) { OHLCDataset ohlc = ( OHLCDataset ) dataset ; for ( int series = 0 ; series < seriesCount ; series ++ ) { int itemCount = dataset . getItemCount ( series ) ; for ( int item = 0 ; item < itemCount ; item ++ ) { double lvalue = ohlc . getLowValue ( series , item ) ; double uvalue = ohlc . getHighValue ( series , item ) ; if ( ! Double . isNaN ( lvalue ) ) { minimum = Math . min ( minimum , lvalue ) ; } if ( ! Double . isNaN ( uvalue ) ) { maximum = Math . max ( maximum , uvalue ) ; } } } } else { for ( int series = 0 ; series < seriesCount ; series ++ ) { int itemCount = dataset . getItemCount ( series ) ; for ( int item = 0 ; item < itemCount ; item ++ ) { double value = dataset . getYValue ( series , item ) ; if ( ! Double . isNaN ( value ) ) { minimum = Math . min ( minimum , value ) ; maximum = Math . max ( maximum , value ) ; } } } } if ( minimum == Double . POSITIVE_INFINITY ) { return null ; } else { return new Range ( minimum , maximum ) ; } }
Iterates over the data items of the xy dataset to find the range bounds.
Iterates over the data items of the xy dataset to find the range bounds .
// handle three cases by dataset type // handle special case of IntervalXYDataset // handle special case of OHLCDataset // standard case - plain XYDataset