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.category.CategoryToPieDataset.java

/**
 * An adaptor class that converts any {@link CategoryDataset} into a
 * {@link PieDataset}, by taking the values from a single row or column.
 * <p>// w  ww. j a  va2s. c  o  m
 * If <code>source</code> is <code>null</code>, the created dataset will
 * be empty.
 *
 * @param source  the source dataset (<code>null</code> permitted).
 * @param extract  extract data from rows or columns? (<code>null</code>
 *                 not permitted).
 * @param index  the row or column index.
 */
public CategoryToPieDataset(CategoryDataset source, TableOrder extract, int index) {
    ParamChecks.nullNotPermitted(extract, "extract");
    this.source = source;
    if (this.source != null) {
        this.source.addChangeListener(this);
    }
    this.extract = extract;
    this.index = index;
}

From source file:org.jfree.data.statistics.DefaultMultiValueCategoryDataset.java

/**
 * Adds a list of values to the dataset (<code>null</code> and Double.NaN
 * items are automatically removed) and sends a {@link DatasetChangeEvent}
 * to all registered listeners.//from w  ww  .  j  a va2  s .c o  m
 *
 * @param values  a list of values (<code>null</code> not permitted).
 * @param rowKey  the row key (<code>null</code> not permitted).
 * @param columnKey  the column key (<code>null</code> not permitted).
 */
public void add(List values, Comparable rowKey, Comparable columnKey) {

    ParamChecks.nullNotPermitted(values, "values");
    ParamChecks.nullNotPermitted(rowKey, "rowKey");
    ParamChecks.nullNotPermitted(columnKey, "columnKey");
    List vlist = new ArrayList(values.size());
    Iterator iterator = values.listIterator();
    while (iterator.hasNext()) {
        Object obj = iterator.next();
        if (obj instanceof Number) {
            Number n = (Number) obj;
            double v = n.doubleValue();
            if (!Double.isNaN(v)) {
                vlist.add(n);
            }
        }
    }
    Collections.sort(vlist);
    this.data.addObject(vlist, rowKey, columnKey);

    if (vlist.size() > 0) {
        double maxval = Double.NEGATIVE_INFINITY;
        double minval = Double.POSITIVE_INFINITY;
        for (int i = 0; i < vlist.size(); i++) {
            Number n = (Number) vlist.get(i);
            double v = n.doubleValue();
            minval = Math.min(minval, v);
            maxval = Math.max(maxval, v);
        }

        // update the cached range values...
        if (this.maximumRangeValue == null) {
            this.maximumRangeValue = new Double(maxval);
        } else if (maxval > this.maximumRangeValue.doubleValue()) {
            this.maximumRangeValue = new Double(maxval);
        }

        if (this.minimumRangeValue == null) {
            this.minimumRangeValue = new Double(minval);
        } else if (minval < this.minimumRangeValue.doubleValue()) {
            this.minimumRangeValue = new Double(minval);
        }
        this.rangeBounds = new Range(this.minimumRangeValue.doubleValue(),
                this.maximumRangeValue.doubleValue());
    }

    fireDatasetChanged();
}

From source file:org.jfree.data.time.ohlc.OHLCSeriesCollection.java

/**
 * Sets the position within each time period that is used for the X values
 * when the collection is used as an {@link XYDataset}, then sends a
 * {@link DatasetChangeEvent} is sent to all registered listeners.
 *
 * @param anchor  the anchor position (<code>null</code> not permitted).
 *
 * @since 1.0.11//from w w  w .j  ava2  s . c  o  m
 */
public void setXPosition(TimePeriodAnchor anchor) {
    ParamChecks.nullNotPermitted(anchor, "anchor");
    this.xPosition = anchor;
    notifyListeners(new DatasetChangeEvent(this, this));
}

From source file:org.jfree.data.time.ohlc.OHLCSeries.java

/**
 * Adds a data item to the series.  The values from the item passed to
 * this method will be copied into a new object.
 * //from   ww w.j a  v a2  s.c  o m
 * @param item  the item (<code>null</code> not permitted).
 * 
 * @since 1.0.17
 */
public void add(OHLCItem item) {
    ParamChecks.nullNotPermitted(item, "item");
    add(item.getPeriod(), item.getOpenValue(), item.getHighValue(), item.getLowValue(), item.getCloseValue());
}

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

/**
 * Creates a new dataset by copying data from a {@link KeyedValues}
 * instance.//from  ww  w . ja  v  a2 s . c om
 *
 * @param data  the data (<code>null</code> not permitted).
 */
public DefaultPieDataset(KeyedValues data) {
    ParamChecks.nullNotPermitted(data, "data");
    this.data = new DefaultKeyedValues();
    for (int i = 0; i < data.getItemCount(); i++) {
        this.data.addValue(data.getKey(i), data.getValue(i));
    }
}

From source file:org.jfree.data.time.ohlc.OHLCItem.java

/**
 * Adds a data item to the series.  The values from the item passed to this method will be copied into a new object.
 * @since  1.0.17/*www  .  j a va  2s  .c o  m*/
 * @param oHLCSeries
 */
public void add(OHLCSeries oHLCSeries) {
    ParamChecks.nullNotPermitted(this, "item");
    oHLCSeries.add(getPeriod(), getOpenValue(), getHighValue(), getLowValue(), getCloseValue());
}

From source file:org.jfree.data.gantt.Task.java

/**
 * Sets the task description./*from ww w . j  av  a2s.  c om*/
 *
 * @param description  the description (<code>null</code> not permitted).
 */
public void setDescription(String description) {
    ParamChecks.nullNotPermitted(description, "description");
    this.description = description;
}

From source file:org.jfree.data.KeyedObjects.java

/**
 * Returns the index for a given key, or <code>-1</code>.
 *
 * @param key  the key (<code>null</code> not permitted).
 *
 * @return The index, or <code>-1</code> if the key is unrecognised.
 *
 * @see #getKey(int)/*from  ww w .j  a  v a 2 s  .  c  om*/
 */
public int getIndex(Comparable key) {
    ParamChecks.nullNotPermitted(key, "key");
    int i = 0;
    Iterator iterator = this.data.iterator();
    while (iterator.hasNext()) {
        KeyedObject ko = (KeyedObject) iterator.next();
        if (ko.getKey().equals(key)) {
            return i;
        }
        i++;
    }
    return -1;
}

From source file:org.jfree.data.xy.DefaultHighLowDataset.java

/**
 * Constructs a new high/low/open/close dataset.
 * <p>//from  www . j a  v a2 s  .c om
 * The current implementation allows only one series in the dataset.
 * This may be extended in a future version.
 *
 * @param seriesKey  the key for the series (<code>null</code> not
 *     permitted).
 * @param date  the dates (<code>null</code> not permitted).
 * @param high  the high values (<code>null</code> not permitted).
 * @param low  the low values (<code>null</code> not permitted).
 * @param open  the open values (<code>null</code> not permitted).
 * @param close  the close values (<code>null</code> not permitted).
 * @param volume  the volume values (<code>null</code> not permitted).
 */
public DefaultHighLowDataset(Comparable seriesKey, Date[] date, double[] high, double[] low, double[] open,
        double[] close, double[] volume) {

    ParamChecks.nullNotPermitted(seriesKey, "seriesKey");
    ParamChecks.nullNotPermitted(date, "date");
    this.seriesKey = seriesKey;
    this.date = date;
    this.high = createNumberArray(high);
    this.low = createNumberArray(low);
    this.open = createNumberArray(open);
    this.close = createNumberArray(close);
    this.volume = createNumberArray(volume);

}

From source file:org.jfree.data.statistics.Statistics.java

/**
 * Returns the mean of a collection of {@code Number} objects.
 *
 * @param values  the values ({@code null} not permitted).
 * @param includeNullAndNaN  a flag that controls whether or not
 *     {@code null} and {@code Double.NaN} values are included
 *     in the calculation (if either is present in the array, the result is
 *     {@link Double#NaN})./*from  w  ww.  j av a 2  s. co  m*/
 *
 * @return The mean.
 *
 * @since 1.0.3
 */
public static double calculateMean(Collection values, boolean includeNullAndNaN) {

    ParamChecks.nullNotPermitted(values, "values");
    int count = 0;
    double total = 0.0;
    Iterator iterator = values.iterator();
    while (iterator.hasNext()) {
        Object object = iterator.next();
        if (object == null) {
            if (includeNullAndNaN) {
                return Double.NaN;
            }
        } else {
            if (object instanceof Number) {
                Number number = (Number) object;
                double value = number.doubleValue();
                if (Double.isNaN(value)) {
                    if (includeNullAndNaN) {
                        return Double.NaN;
                    }
                } else {
                    total = total + number.doubleValue();
                    count = count + 1;
                }
            }
        }
    }
    return total / count;
}