List of usage examples for org.jfree.chart.util ParamChecks nullNotPermitted
public static void nullNotPermitted(Object param, String name)
IllegalArgumentException
if the supplied param
is null
. From source file:org.jfree.data.statistics.BoxAndWhiskerCalculator.java
/** * Calculates the statistics required for a {@link BoxAndWhiskerItem} * from a list of <code>Number</code> objects. Any items in the list * that are <code>null</code>, not an instance of <code>Number</code>, or * equivalent to <code>Double.NaN</code>, will be ignored. * * @param values a list of numbers (a <code>null</code> list is not * permitted).//from w w w . j a v a 2 s . com * @param stripNullAndNaNItems a flag that controls the handling of null * and NaN items. * * @return A box-and-whisker item. * * @since 1.0.3 */ public static BoxAndWhiskerItem calculateBoxAndWhiskerStatistics(List values, boolean stripNullAndNaNItems) { ParamChecks.nullNotPermitted(values, "values"); List vlist; if (stripNullAndNaNItems) { 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); } } } } else { vlist = values; } Collections.sort(vlist); double mean = Statistics.calculateMean(vlist, false); double median = Statistics.calculateMedian(vlist, false); double q1 = calculateQ1(vlist); double q3 = calculateQ3(vlist); double interQuartileRange = q3 - q1; double upperOutlierThreshold = q3 + (interQuartileRange * 1.5); double lowerOutlierThreshold = q1 - (interQuartileRange * 1.5); double upperFaroutThreshold = q3 + (interQuartileRange * 2.0); double lowerFaroutThreshold = q1 - (interQuartileRange * 2.0); double minRegularValue = Double.POSITIVE_INFINITY; double maxRegularValue = Double.NEGATIVE_INFINITY; double minOutlier = Double.POSITIVE_INFINITY; double maxOutlier = Double.NEGATIVE_INFINITY; List outliers = new ArrayList(); Iterator iterator = vlist.iterator(); while (iterator.hasNext()) { Number number = (Number) iterator.next(); double value = number.doubleValue(); if (value > upperOutlierThreshold) { outliers.add(number); if (value > maxOutlier && value <= upperFaroutThreshold) { maxOutlier = value; } } else if (value < lowerOutlierThreshold) { outliers.add(number); if (value < minOutlier && value >= lowerFaroutThreshold) { minOutlier = value; } } else { minRegularValue = Math.min(minRegularValue, value); maxRegularValue = Math.max(maxRegularValue, value); } minOutlier = Math.min(minOutlier, minRegularValue); maxOutlier = Math.max(maxOutlier, maxRegularValue); } return new BoxAndWhiskerItem(new Double(mean), new Double(median), new Double(q1), new Double(q3), new Double(minRegularValue), new Double(maxRegularValue), new Double(minOutlier), new Double(maxOutlier), outliers); }
From source file:org.jfree.data.DefaultKeyedValue.java
/** * Creates a new (key, value) item.// ww w . jav a2 s .co m * * @param key the key (should be immutable, <code>null</code> not * permitted). * @param value the value (<code>null</code> permitted). */ public DefaultKeyedValue(Comparable key, Number value) { ParamChecks.nullNotPermitted(key, "key"); this.key = key; this.value = value; }
From source file:org.jfree.data.gantt.TaskSeries.java
/** * Adds a task to the series and sends a * {@link org.jfree.data.general.SeriesChangeEvent} to all registered * listeners./*from w w w. ja va 2 s .c o m*/ * * @param task the task (<code>null</code> not permitted). */ public void add(Task task) { ParamChecks.nullNotPermitted(task, "task"); this.tasks.add(task); fireSeriesChanged(); }
From source file:org.jfree.data.xy.OHLCDataItem.java
/** * Creates a new item.//w w w . j ava 2 s. c o m * * @param date the date (<code>null</code> not permitted). * @param open the open value. * @param high the high value. * @param low the low value. * @param close the close value. * @param volume the volume. */ public OHLCDataItem(Date date, double open, double high, double low, double close, double volume) { ParamChecks.nullNotPermitted(date, "date"); this.date = date; this.open = new Double(open); this.high = new Double(high); this.low = new Double(low); this.close = new Double(close); this.volume = new Double(volume); }
From source file:org.jfree.data.xy.VectorSeriesCollection.java
/** * Adds a series to the collection and sends a {@link DatasetChangeEvent} * to all registered listeners.//from ww w. ja va 2 s. c om * * @param series the series (<code>null</code> not permitted). */ public void addSeries(VectorSeries series) { ParamChecks.nullNotPermitted(series, "series"); this.data.add(series); series.addChangeListener(this); fireDatasetChanged(); }
From source file:org.jfree.data.xy.XIntervalSeriesCollection.java
/** * Adds a series to the collection and sends a {@link DatasetChangeEvent} * to all registered listeners.// w w w . ja v a 2 s .c om * * @param series the series (<code>null</code> not permitted). */ public void addSeries(XIntervalSeries series) { ParamChecks.nullNotPermitted(series, "series"); this.data.add(series); series.addChangeListener(this); fireDatasetChanged(); }
From source file:org.jfree.data.gantt.Task.java
/** * Creates a new task.//ww w .j a va2 s . c o m * * @param description the task description (<code>null</code> not * permitted). * @param duration the task duration (<code>null</code> permitted). */ public Task(String description, TimePeriod duration) { ParamChecks.nullNotPermitted(description, "description"); this.description = description; this.duration = duration; this.percentComplete = null; this.subtasks = new java.util.ArrayList(); }
From source file:org.jfree.data.xy.YIntervalSeriesCollection.java
/** * Adds a series to the collection and sends a {@link DatasetChangeEvent} * to all registered listeners.//from w ww .j a va2 s .com * * @param series the series (<code>null</code> not permitted). */ public void addSeries(YIntervalSeries series) { ParamChecks.nullNotPermitted(series, "series"); this.data.add(series); series.addChangeListener(this); fireDatasetChanged(); }
From source file:org.jfree.data.general.HeatMapUtilities.java
/** * Creates an image that displays the values from the specified dataset. * * @param dataset the dataset (<code>null</code> not permitted). * @param paintScale the paint scale for the z-values (<code>null</code> * not permitted)./*ww w . java 2 s .c om*/ * * @return A buffered image. */ public static BufferedImage createHeatMapImage(HeatMapDataset dataset, PaintScale paintScale) { ParamChecks.nullNotPermitted(dataset, "dataset"); ParamChecks.nullNotPermitted(paintScale, "paintScale"); int xCount = dataset.getXSampleCount(); int yCount = dataset.getYSampleCount(); BufferedImage image = new BufferedImage(xCount, yCount, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = image.createGraphics(); for (int xIndex = 0; xIndex < xCount; xIndex++) { for (int yIndex = 0; yIndex < yCount; yIndex++) { double z = dataset.getZValue(xIndex, yIndex); Paint p = paintScale.getPaint(z); g2.setPaint(p); g2.fillRect(xIndex, yCount - yIndex - 1, 1, 1); } } return image; }
From source file:org.jfree.data.xy.XYIntervalSeriesCollection.java
/** * Adds a series to the collection and sends a {@link DatasetChangeEvent} * to all registered listeners./*from w w w.ja v a 2 s . co m*/ * * @param series the series (<code>null</code> not permitted). */ public void addSeries(XYIntervalSeries series) { ParamChecks.nullNotPermitted(series, "series"); this.data.add(series); series.addChangeListener(this); fireDatasetChanged(); }