Example usage for org.jfree.chart.util ParamChecks nullNotPermitted

List of usage examples for org.jfree.chart.util ParamChecks nullNotPermitted

Introduction

In this page you can find the example usage for org.jfree.chart.util ParamChecks nullNotPermitted.

Prototype

public static void nullNotPermitted(Object param, String name) 

Source Link

Document

Throws an IllegalArgumentException if the supplied param is null.

Usage

From source file:org.jfree.data.time.TimeSeries.java

/**
 * Creates a new timeseries by copying a subset of the data in this time
 * series.//  w  ww.  ja v  a  2s.c o m
 *
 * @param start  the first time period to copy (<code>null</code> not
 *         permitted).
 * @param end  the last time period to copy (<code>null</code> not
 *         permitted).
 *
 * @return A time series containing a copy of this time series from start
 *         until end.
 *
 * @throws CloneNotSupportedException if there is a cloning problem.
 */
public TimeSeries createCopy(RegularTimePeriod start, RegularTimePeriod end) throws CloneNotSupportedException {

    ParamChecks.nullNotPermitted(start, "start");
    ParamChecks.nullNotPermitted(end, "end");
    if (start.compareTo(end) > 0) {
        throw new IllegalArgumentException("Requires start on or before end.");
    }
    boolean emptyRange = false;
    int startIndex = getIndex(start);
    if (startIndex < 0) {
        startIndex = -(startIndex + 1);
        if (startIndex == this.data.size()) {
            emptyRange = true; // start is after last data item
        }
    }
    int endIndex = getIndex(end);
    if (endIndex < 0) { // end period is not in original series
        endIndex = -(endIndex + 1); // this is first item AFTER end period
        endIndex = endIndex - 1; // so this is last item BEFORE end
    }
    if ((endIndex < 0) || (endIndex < startIndex)) {
        emptyRange = true;
    }
    if (emptyRange) {
        TimeSeries copy = (TimeSeries) super.clone();
        copy.data = new java.util.ArrayList();
        return copy;
    }
    return createCopy(startIndex, endIndex);
}

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

/**
 * Returns the range of values in the z-dimension for the dataset.  This
 * method is the partner for the/*  w w  w .j a  v  a  2s  .  co m*/
 * {@link #findRangeBounds(XYDataset, boolean)} and
 * {@link #findDomainBounds(XYDataset, boolean)} methods.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param includeInterval  a flag that determines whether or not the
 *                         z-interval is taken into account.
 *
 * @return The range (possibly <code>null</code>).
 */
public static Range findZBounds(XYZDataset dataset, boolean includeInterval) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    Range result = iterateZBounds(dataset, includeInterval);
    return result;
}

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

/**
 * Finds the bounds of the z-values in the specified dataset, including
 * only those series that are listed in visibleSeriesKeys, and those items
 * whose x-values fall within the specified range.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param visibleSeriesKeys  the keys for the visible series
 *     (<code>null</code> not permitted).
 * @param xRange  the x-range (<code>null</code> not permitted).
 * @param includeInterval  include the z-interval (if the dataset has a
 *     z-interval)./*w w  w  .  ja va  2s  . c om*/
 *
 * @return The data bounds.
 */
public static Range findZBounds(XYZDataset dataset, List visibleSeriesKeys, Range xRange,
        boolean includeInterval) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    Range result = iterateToFindZBounds(dataset, visibleSeriesKeys, xRange, includeInterval);
    return result;
}

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

/**
 * Returns the range of x-values in the specified dataset for the
 * data items belonging to the visible series.
 * /* ww w. j  a va2s. co m*/
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param visibleSeriesKeys  the visible series keys (<code>null</code> not
 *     permitted).
 * @param includeInterval  a flag that determines whether or not the
 *     y-interval for the dataset is included (this only applies if the
 *     dataset is an instance of IntervalXYDataset).
 * 
 * @return The x-range (possibly <code>null</code>).
 * 
 * @since 1.0.13
 */
public static Range iterateToFindDomainBounds(XYDataset dataset, List visibleSeriesKeys,
        boolean includeInterval) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    ParamChecks.nullNotPermitted(visibleSeriesKeys, "visibleSeriesKeys");

    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;

    if (includeInterval && dataset instanceof IntervalXYDataset) {
        // handle special case of IntervalXYDataset
        IntervalXYDataset ixyd = (IntervalXYDataset) dataset;
        Iterator iterator = visibleSeriesKeys.iterator();
        while (iterator.hasNext()) {
            Comparable seriesKey = (Comparable) iterator.next();
            int series = dataset.indexOf(seriesKey);
            int itemCount = dataset.getItemCount(series);
            for (int item = 0; item < itemCount; item++) {
                double lvalue = ixyd.getStartXValue(series, item);
                double uvalue = ixyd.getEndXValue(series, item);
                if (!Double.isNaN(lvalue)) {
                    minimum = Math.min(minimum, lvalue);
                }
                if (!Double.isNaN(uvalue)) {
                    maximum = Math.max(maximum, uvalue);
                }
            }
        }
    } else {
        // standard case - plain XYDataset
        Iterator iterator = visibleSeriesKeys.iterator();
        while (iterator.hasNext()) {
            Comparable seriesKey = (Comparable) iterator.next();
            int series = dataset.indexOf(seriesKey);
            int itemCount = dataset.getItemCount(series);
            for (int item = 0; item < itemCount; item++) {
                double x = dataset.getXValue(series, item);
                if (!Double.isNaN(x)) {
                    minimum = Math.min(minimum, x);
                    maximum = Math.max(maximum, x);
                }
            }
        }
    }

    if (minimum == Double.POSITIVE_INFINITY) {
        return null;
    } else {
        return new Range(minimum, maximum);
    }
}

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

/**
 * Returns the range of y-values in the specified dataset for the
 * data items belonging to the visible series and with x-values in the
 * given range./*from w w  w .  j a  v a 2 s. co  m*/
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param visibleSeriesKeys  the visible series keys (<code>null</code> not
 *     permitted).
 * @param xRange  the x-range (<code>null</code> not permitted).
 * @param includeInterval  a flag that determines whether or not the
 *     y-interval for the dataset is included (this only applies if the
 *     dataset is an instance of IntervalXYDataset).
 *
 * @return The y-range (possibly <code>null</code>).
 *
 * @since 1.0.13
 */
public static Range iterateToFindRangeBounds(XYDataset dataset, List visibleSeriesKeys, Range xRange,
        boolean includeInterval) {

    ParamChecks.nullNotPermitted(dataset, "dataset");
    ParamChecks.nullNotPermitted(visibleSeriesKeys, "visibleSeriesKeys");
    ParamChecks.nullNotPermitted(xRange, "xRange");

    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;

    // handle three cases by dataset type
    if (includeInterval && dataset instanceof OHLCDataset) {
        // handle special case of OHLCDataset
        OHLCDataset ohlc = (OHLCDataset) dataset;
        Iterator iterator = visibleSeriesKeys.iterator();
        while (iterator.hasNext()) {
            Comparable seriesKey = (Comparable) iterator.next();
            int series = dataset.indexOf(seriesKey);
            int itemCount = dataset.getItemCount(series);
            for (int item = 0; item < itemCount; item++) {
                double x = ohlc.getXValue(series, item);
                if (xRange.contains(x)) {
                    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 if (includeInterval && dataset instanceof BoxAndWhiskerXYDataset) {
        // handle special case of BoxAndWhiskerXYDataset
        BoxAndWhiskerXYDataset bx = (BoxAndWhiskerXYDataset) dataset;
        Iterator iterator = visibleSeriesKeys.iterator();
        while (iterator.hasNext()) {
            Comparable seriesKey = (Comparable) iterator.next();
            int series = dataset.indexOf(seriesKey);
            int itemCount = dataset.getItemCount(series);
            for (int item = 0; item < itemCount; item++) {
                double x = bx.getXValue(series, item);
                if (xRange.contains(x)) {
                    Number lvalue = bx.getMinRegularValue(series, item);
                    Number uvalue = bx.getMaxRegularValue(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 IntervalXYDataset) {
        // handle special case of IntervalXYDataset
        IntervalXYDataset ixyd = (IntervalXYDataset) dataset;
        Iterator iterator = visibleSeriesKeys.iterator();
        while (iterator.hasNext()) {
            Comparable seriesKey = (Comparable) iterator.next();
            int series = dataset.indexOf(seriesKey);
            int itemCount = dataset.getItemCount(series);
            for (int item = 0; item < itemCount; item++) {
                double x = ixyd.getXValue(series, item);
                if (xRange.contains(x)) {
                    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 {
        // standard case - plain XYDataset
        Iterator iterator = visibleSeriesKeys.iterator();
        while (iterator.hasNext()) {
            Comparable seriesKey = (Comparable) iterator.next();
            int series = dataset.indexOf(seriesKey);
            int itemCount = dataset.getItemCount(series);
            for (int item = 0; item < itemCount; item++) {
                double x = dataset.getXValue(series, item);
                double y = dataset.getYValue(series, item);
                if (xRange.contains(x)) {
                    if (!Double.isNaN(y)) {
                        minimum = Math.min(minimum, y);
                        maximum = Math.max(maximum, y);
                    }
                }
            }
        }
    }
    if (minimum == Double.POSITIVE_INFINITY) {
        return null;
    } else {
        return new Range(minimum, maximum);
    }
}

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

/**
 * Returns the range of z-values in the specified dataset for the
 * data items belonging to the visible series and with x-values in the
 * given range./*from   w  w w .  java  2 s .  com*/
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param visibleSeriesKeys  the visible series keys (<code>null</code> not
 *     permitted).
 * @param xRange  the x-range (<code>null</code> not permitted).
 * @param includeInterval  a flag that determines whether or not the
 *     z-interval for the dataset is included (this only applies if the
 *     dataset has an interval, which is currently not supported).
 *
 * @return The y-range (possibly <code>null</code>).
 */
public static Range iterateToFindZBounds(XYZDataset dataset, List visibleSeriesKeys, Range xRange,
        boolean includeInterval) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    ParamChecks.nullNotPermitted(visibleSeriesKeys, "visibleSeriesKeys");
    ParamChecks.nullNotPermitted(xRange, "xRange");

    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;

    Iterator iterator = visibleSeriesKeys.iterator();
    while (iterator.hasNext()) {
        Comparable seriesKey = (Comparable) iterator.next();
        int series = dataset.indexOf(seriesKey);
        int itemCount = dataset.getItemCount(series);
        for (int item = 0; item < itemCount; item++) {
            double x = dataset.getXValue(series, item);
            double z = dataset.getZValue(series, item);
            if (xRange.contains(x)) {
                if (!Double.isNaN(z)) {
                    minimum = Math.min(minimum, z);
                    maximum = Math.max(maximum, z);
                }
            }
        }
    }

    if (minimum == Double.POSITIVE_INFINITY) {
        return null;
    } else {
        return new Range(minimum, maximum);
    }
}

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

/**
 * Finds the minimum domain (or X) value for the specified dataset.  This
 * is easy if the dataset implements the {@link DomainInfo} interface (a
 * good idea if there is an efficient way to determine the minimum value).
 * Otherwise, it involves iterating over the entire data-set.
 * <p>//from   w w w. j a v  a 2  s .c om
 * Returns <code>null</code> if all the data values in the dataset are
 * <code>null</code>.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 *
 * @return The minimum value (possibly <code>null</code>).
 */
public static Number findMinimumDomainValue(XYDataset dataset) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    Number result;
    // if the dataset implements DomainInfo, life is easy
    if (dataset instanceof DomainInfo) {
        DomainInfo info = (DomainInfo) dataset;
        return new Double(info.getDomainLowerBound(true));
    } else {
        double minimum = Double.POSITIVE_INFINITY;
        int seriesCount = dataset.getSeriesCount();
        for (int series = 0; series < seriesCount; series++) {
            int itemCount = dataset.getItemCount(series);
            for (int item = 0; item < itemCount; item++) {

                double value;
                if (dataset instanceof IntervalXYDataset) {
                    IntervalXYDataset intervalXYData = (IntervalXYDataset) dataset;
                    value = intervalXYData.getStartXValue(series, item);
                } else {
                    value = dataset.getXValue(series, item);
                }
                if (!Double.isNaN(value)) {
                    minimum = Math.min(minimum, value);
                }

            }
        }
        if (minimum == Double.POSITIVE_INFINITY) {
            result = null;
        } else {
            result = new Double(minimum);
        }
    }

    return result;
}

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

/**
 * Returns the maximum domain value for the specified dataset.  This is
 * easy if the dataset implements the {@link DomainInfo} interface (a good
 * idea if there is an efficient way to determine the maximum value).
 * Otherwise, it involves iterating over the entire data-set.  Returns
 * <code>null</code> if all the data values in the dataset are
 * <code>null</code>./*from w w w.  j a v  a 2 s. c o  m*/
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 *
 * @return The maximum value (possibly <code>null</code>).
 */
public static Number findMaximumDomainValue(XYDataset dataset) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    Number result;
    // if the dataset implements DomainInfo, life is easy
    if (dataset instanceof DomainInfo) {
        DomainInfo info = (DomainInfo) dataset;
        return new Double(info.getDomainUpperBound(true));
    }

    // hasn't implemented DomainInfo, so iterate...
    else {
        double maximum = Double.NEGATIVE_INFINITY;
        int seriesCount = dataset.getSeriesCount();
        for (int series = 0; series < seriesCount; series++) {
            int itemCount = dataset.getItemCount(series);
            for (int item = 0; item < itemCount; item++) {

                double value;
                if (dataset instanceof IntervalXYDataset) {
                    IntervalXYDataset intervalXYData = (IntervalXYDataset) dataset;
                    value = intervalXYData.getEndXValue(series, item);
                } else {
                    value = dataset.getXValue(series, item);
                }
                if (!Double.isNaN(value)) {
                    maximum = Math.max(maximum, value);
                }
            }
        }
        if (maximum == Double.NEGATIVE_INFINITY) {
            result = null;
        } else {
            result = new Double(maximum);
        }

    }

    return result;
}

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

/**
 * Returns the minimum range value for the specified dataset.  This is
 * easy if the dataset implements the {@link RangeInfo} interface (a good
 * idea if there is an efficient way to determine the minimum value).
 * Otherwise, it involves iterating over the entire data-set.  Returns
 * <code>null</code> if all the data values in the dataset are
 * <code>null</code>.//  w  w w  .ja  v a 2 s  .c  om
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 *
 * @return The minimum value (possibly <code>null</code>).
 */
public static Number findMinimumRangeValue(CategoryDataset dataset) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    if (dataset instanceof RangeInfo) {
        RangeInfo info = (RangeInfo) dataset;
        return new Double(info.getRangeLowerBound(true));
    }

    // hasn't implemented RangeInfo, so we'll have to iterate...
    else {
        double minimum = Double.POSITIVE_INFINITY;
        int seriesCount = dataset.getRowCount();
        int itemCount = dataset.getColumnCount();
        for (int series = 0; series < seriesCount; series++) {
            for (int item = 0; item < itemCount; item++) {
                Number value;
                if (dataset instanceof IntervalCategoryDataset) {
                    IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset;
                    value = icd.getStartValue(series, item);
                } else {
                    value = dataset.getValue(series, item);
                }
                if (value != null) {
                    minimum = Math.min(minimum, value.doubleValue());
                }
            }
        }
        if (minimum == Double.POSITIVE_INFINITY) {
            return null;
        } else {
            return new Double(minimum);
        }

    }

}

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

/**
 * Returns the minimum range value for the specified dataset.  This is
 * easy if the dataset implements the {@link RangeInfo} interface (a good
 * idea if there is an efficient way to determine the minimum value).
 * Otherwise, it involves iterating over the entire data-set.  Returns
 * <code>null</code> if all the data values in the dataset are
 * <code>null</code>.//  www.j  a va  2  s  . com
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 *
 * @return The minimum value (possibly <code>null</code>).
 */
public static Number findMinimumRangeValue(XYDataset dataset) {
    ParamChecks.nullNotPermitted(dataset, "dataset");

    // work out the minimum value...
    if (dataset instanceof RangeInfo) {
        RangeInfo info = (RangeInfo) dataset;
        return new Double(info.getRangeLowerBound(true));
    }

    // hasn't implemented RangeInfo, so we'll have to iterate...
    else {
        double minimum = Double.POSITIVE_INFINITY;
        int seriesCount = dataset.getSeriesCount();
        for (int series = 0; series < seriesCount; series++) {
            int itemCount = dataset.getItemCount(series);
            for (int item = 0; item < itemCount; item++) {

                double value;
                if (dataset instanceof IntervalXYDataset) {
                    IntervalXYDataset intervalXYData = (IntervalXYDataset) dataset;
                    value = intervalXYData.getStartYValue(series, item);
                } else if (dataset instanceof OHLCDataset) {
                    OHLCDataset highLowData = (OHLCDataset) dataset;
                    value = highLowData.getLowValue(series, item);
                } else {
                    value = dataset.getYValue(series, item);
                }
                if (!Double.isNaN(value)) {
                    minimum = Math.min(minimum, value);
                }

            }
        }
        if (minimum == Double.POSITIVE_INFINITY) {
            return null;
        } else {
            return new Double(minimum);
        }

    }

}