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.Week.java

/**
 * Creates a time period for the week in which the specified date/time
 * falls, calculated relative to the specified time zone.
 *
 * @param time  the date/time (<code>null</code> not permitted).
 * @param zone  the time zone (<code>null</code> not permitted).
 * @param locale  the locale (<code>null</code> not permitted).
 *
 * @since 1.0.7/*from   ww w . j a  va  2  s . c om*/
 */
public Week(Date time, TimeZone zone, Locale locale) {
    ParamChecks.nullNotPermitted(time, "time");
    ParamChecks.nullNotPermitted(zone, "zone");
    ParamChecks.nullNotPermitted(locale, "locale");
    Calendar calendar = Calendar.getInstance(zone, locale);
    calendar.setTime(time);

    // sometimes the last few days of the year are considered to fall in
    // the *first* week of the following year.  Refer to the Javadocs for
    // GregorianCalendar.
    int tempWeek = calendar.get(Calendar.WEEK_OF_YEAR);
    if (tempWeek == 1 && calendar.get(Calendar.MONTH) == Calendar.DECEMBER) {
        this.week = 1;
        this.year = (short) (calendar.get(Calendar.YEAR) + 1);
    } else {
        this.week = (byte) Math.min(tempWeek, LAST_WEEK_IN_YEAR);
        int yyyy = calendar.get(Calendar.YEAR);
        // alternatively, sometimes the first few days of the year are
        // considered to fall in the *last* week of the previous year...
        if (calendar.get(Calendar.MONTH) == Calendar.JANUARY && this.week >= 52) {
            yyyy--;
        }
        this.year = (short) yyyy;
    }
    peg(calendar);
}

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

/**
 * Returns a {@link KeyedValues} instance that contains the cumulative
 * percentage values for the data in another {@link KeyedValues} instance.
 * <p>//w ww. j  av  a2  s .c o  m
 * The percentages are values between 0.0 and 1.0 (where 1.0 = 100%).
 *
 * @param data  the data (<code>null</code> not permitted).
 *
 * @return The cumulative percentages.
 */
public static KeyedValues getCumulativePercentages(KeyedValues data) {
    ParamChecks.nullNotPermitted(data, "data");
    DefaultKeyedValues result = new DefaultKeyedValues();
    double total = 0.0;
    for (int i = 0; i < data.getItemCount(); i++) {
        Number v = data.getValue(i);
        if (v != null) {
            total = total + v.doubleValue();
        }
    }
    double runningTotal = 0.0;
    for (int i = 0; i < data.getItemCount(); i++) {
        Number v = data.getValue(i);
        if (v != null) {
            runningTotal = runningTotal + v.doubleValue();
        }
        result.addValue(data.getKey(i), new Double(runningTotal / total));
    }
    return result;
}

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

/**
 * Adds or updates an object./*  ww  w.ja  v a2 s.  c o  m*/
 *
 * @param object  the object.
 * @param rowKey  the row key (<code>null</code> not permitted).
 * @param columnKey  the column key (<code>null</code> not permitted).
 */
public void setObject(Object object, Comparable rowKey, Comparable columnKey) {
    ParamChecks.nullNotPermitted(rowKey, "rowKey");
    ParamChecks.nullNotPermitted(columnKey, "columnKey");
    KeyedObjects row;
    int rowIndex = this.rowKeys.indexOf(rowKey);
    if (rowIndex >= 0) {
        row = (KeyedObjects) this.rows.get(rowIndex);
    } else {
        this.rowKeys.add(rowKey);
        row = new KeyedObjects();
        this.rows.add(row);
    }
    row.setObject(columnKey, object);
    int columnIndex = this.columnKeys.indexOf(columnKey);
    if (columnIndex < 0) {
        this.columnKeys.add(columnKey);
    }
}

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

/**
 * Adds a data item to the series and sends a {@link SeriesChangeEvent} to
 * all registered listeners./*from w  ww . j  ava 2 s .  c  o  m*/
 *
 * @param item  the item (<code>null</code> not permitted).
 */
public void add(TimePeriodValue item) {
    ParamChecks.nullNotPermitted(item, "item");
    this.data.add(item);
    updateBounds(item.getPeriod(), this.data.size() - 1);
    fireSeriesChanged();
}

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

/**
 * Returns the value for the given row and column keys.  This method will
 * throw an {@link UnknownKeyException} if either key is not defined in the
 * data structure.//www.  j  a v  a2  s  .c o m
 *
 * @param rowKey  the row key (<code>null</code> not permitted).
 * @param columnKey  the column key (<code>null</code> not permitted).
 *
 * @return The value (possibly <code>null</code>).
 *
 * @see #addValue(Number, Comparable, Comparable)
 * @see #removeValue(Comparable, Comparable)
 */
@Override
public Number getValue(Comparable rowKey, Comparable columnKey) {
    ParamChecks.nullNotPermitted(rowKey, "rowKey");
    ParamChecks.nullNotPermitted(columnKey, "columnKey");

    // check that the column key is defined in the 2D structure
    if (!(this.columnKeys.contains(columnKey))) {
        throw new UnknownKeyException("Unrecognised columnKey: " + columnKey);
    }

    // now fetch the row data - need to bear in mind that the row
    // structure may not have an entry for the column key, but that we
    // have already checked that the key is valid for the 2D structure
    int row = getRowIndex(rowKey);
    if (row >= 0) {
        DefaultKeyedValues rowData = (DefaultKeyedValues) this.rows.get(row);
        int col = rowData.getIndex(columnKey);
        return (col >= 0 ? rowData.getValue(col) : null);
    } else {
        throw new UnknownKeyException("Unrecognised rowKey: " + rowKey);
    }
}

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

/**
 * Removes a series from the collection and sends
 * a {@link org.jfree.data.general.DatasetChangeEvent}
 * to all registered listeners.//ww w.j  av  a  2s . c o m
 *
 * @param series  the series.
 */
public void remove(TaskSeries series) {
    ParamChecks.nullNotPermitted(series, "series");
    if (this.data.contains(series)) {
        series.removeChangeListener(this);
        this.data.remove(series);
        fireDatasetChanged();
    }
}

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

/**
 * Creates a new {@link XYDataset} containing the moving averages of each
 * series in the <code>source</code> dataset.
 *
 * @param source  the source dataset.// ww w  . ja  va2s.co m
 * @param suffix  the string to append to source series names to create
 *                target series names.
 * @param period  the averaging period.
 * @param skip  the length of the initial skip period.
 *
 * @return The dataset.
 */
public static XYDataset createMovingAverage(XYDataset source, String suffix, double period, double skip) {

    ParamChecks.nullNotPermitted(source, "source");
    XYSeriesCollection result = new XYSeriesCollection();
    for (int i = 0; i < source.getSeriesCount(); i++) {
        XYSeries s = createMovingAverage(source, i, source.getSeriesKey(i) + suffix, period, skip);
        result.addSeries(s);
    }
    return result;
}

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

/**
 * Removes a series from the collection.
 * <P>/*  ww w .  ja va2s  . com*/
 * Notifies all registered listeners that the dataset has changed.
 * </p>
 *
 * @param series the series (<code>null</code>).
 */
public void removeSeries(MatrixSeries series) {
    ParamChecks.nullNotPermitted(series, "series");
    if (this.seriesList.contains(series)) {
        series.removeChangeListener(this);
        this.seriesList.remove(series);
        fireDatasetChanged();
    }
}

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

/**
 * Returns the index of the specified series, or -1 if that series is not
 * present in the dataset./*  w  ww .j  av a 2s  .  com*/
 *
 * @param series  the series (<code>null</code> not permitted).
 *
 * @return The series index.
 *
 * @since 1.0.6
 */
public int indexOf(XYSeries series) {
    ParamChecks.nullNotPermitted(series, "series");
    return this.data.indexOf(series);
}

From source file:de.hs.mannheim.modUro.controller.diagram.fx.ChartCanvas.java

/**
 * Registers a listener to receive {@link ChartMouseEvent} notifications.
 *
 * @param listener  the listener ({@code null} not permitted).
 *//*ww  w.  j a  v a 2 s  .c  o m*/
public void addChartMouseListener(ChartMouseListenerFX listener) {
    ParamChecks.nullNotPermitted(listener, "listener");
    this.chartMouseListeners.add(listener);
}