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

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

@return The range (possibly null).
Iterates over the items in an XYDataset to find the range of x - values . @param dataset the dataset ( null not permitted ) . @param includeInterval a flag that determines for an IntervalXYDataset whether the x - interval or just the x - value is used to determine the overall range . @return The range ( possibly null ) .
public static Range iterateDomainBounds(XYDataset dataset,
            boolean includeInterval) {
        if (dataset == null) {
            throw new IllegalArgumentException("Null 'dataset' argument.");
        }
        double minimum = Double.POSITIVE_INFINITY;
        double maximum = Double.NEGATIVE_INFINITY;
        int seriesCount = dataset.getSeriesCount();
        double lvalue;
        double uvalue;
        if (includeInterval && dataset instanceof IntervalXYDataset) {
            IntervalXYDataset intervalXYData = (IntervalXYDataset) dataset;
            for (int series = 0; series < seriesCount; series++) {
                int itemCount = dataset.getItemCount(series);
                for (int item = 0; item < itemCount; item++) {
                    lvalue = intervalXYData.getStartXValue(series, item);
                    uvalue = intervalXYData.getEndXValue(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++) {
                    lvalue = dataset.getXValue(series, item);
                    uvalue = lvalue;
                    if (!Double.isNaN(lvalue)) {
                        minimum = Math.min(minimum, lvalue);
                        maximum = Math.max(maximum, uvalue);
                    }
                }
            }
        }
        if (minimum > maximum) {
            return null;
        } else {
            return new Range(minimum, maximum);
        }
    }
public static Range iterateDomainBounds ( XYDataset dataset , boolean includeInterval ) { if ( dataset == null ) { throw new IllegalArgumentException ( "Null 'dataset' argument." ) ; } double minimum = Double . POSITIVE_INFINITY ; double maximum = Double . NEGATIVE_INFINITY ; int seriesCount = dataset . getSeriesCount ( ) ; double lvalue ; double uvalue ; if ( includeInterval && dataset instanceof IntervalXYDataset ) { IntervalXYDataset intervalXYData = ( IntervalXYDataset ) dataset ; for ( int series = 0 ; series < seriesCount ; series ++ ) { int itemCount = dataset . getItemCount ( series ) ; for ( int item = 0 ; item < itemCount ; item ++ ) { lvalue = intervalXYData . getStartXValue ( series , item ) ; uvalue = intervalXYData . getEndXValue ( 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 ++ ) { lvalue = dataset . getXValue ( series , item ) ; uvalue = lvalue ; if ( ! Double . isNaN ( lvalue ) ) { minimum = Math . min ( minimum , lvalue ) ; maximum = Math . max ( maximum , uvalue ) ; } } } } if ( minimum > maximum ) { return null ; } else { return new Range ( minimum , maximum ) ; } }
Iterates over the items in an {@link XYDataset} to find the range of
 x-values.
Iterates over the items in an { @link XYDataset } to find the range of x - values .