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.general.DatasetUtilities.java
/** * Returns the bounds of the x-values in the specified <code>dataset</code> * taking into account only the visible series and including any x-interval * if requested.// w ww.j ava 2s . c o m * * @param dataset the dataset (<code>null</code> not permitted). * @param visibleSeriesKeys the visible series keys (<code>null</code> * not permitted). * @param includeInterval include the x-interval (if any)? * * @return The bounds (or <code>null</code> if the dataset contains no * values. * * @since 1.0.13 */ public static Range findDomainBounds(XYDataset dataset, List visibleSeriesKeys, boolean includeInterval) { ParamChecks.nullNotPermitted(dataset, "dataset"); Range result; if (dataset instanceof XYDomainInfo) { XYDomainInfo info = (XYDomainInfo) dataset; result = info.getDomainBounds(visibleSeriesKeys, includeInterval); } else { result = iterateToFindDomainBounds(dataset, visibleSeriesKeys, includeInterval); } return result; }
From source file:org.jfree.data.general.DatasetUtilities.java
/** * Iterates over the items in an {@link XYDataset} to find * the range of x-values.//ww w. j a v a 2 s . co m * * @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>). */ public static Range iterateDomainBounds(XYDataset dataset, boolean includeInterval) { ParamChecks.nullNotPermitted(dataset, "dataset"); double minimum = Double.POSITIVE_INFINITY; double maximum = Double.NEGATIVE_INFINITY; int seriesCount = dataset.getSeriesCount(); double lvalue, 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++) { double value = intervalXYData.getXValue(series, item); lvalue = intervalXYData.getStartXValue(series, item); uvalue = intervalXYData.getEndXValue(series, item); if (!Double.isNaN(value)) { minimum = Math.min(minimum, value); maximum = Math.max(maximum, value); } if (!Double.isNaN(lvalue)) { minimum = Math.min(minimum, lvalue); maximum = Math.max(maximum, lvalue); } if (!Double.isNaN(uvalue)) { minimum = Math.min(minimum, 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); } }
From source file:org.jfree.data.general.DatasetUtilities.java
/** * Returns the range of values in the range for the dataset. * * @param dataset the dataset (<code>null</code> not permitted). * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The range (possibly <code>null</code>). */// w w w. j av a 2s . co m public static Range findRangeBounds(CategoryDataset dataset, boolean includeInterval) { ParamChecks.nullNotPermitted(dataset, "dataset"); Range result; if (dataset instanceof RangeInfo) { RangeInfo info = (RangeInfo) dataset; result = info.getRangeBounds(includeInterval); } else { result = iterateRangeBounds(dataset, includeInterval); } return result; }
From source file:org.jfree.data.general.DatasetUtilities.java
/** * Finds the bounds of the y-values in the specified dataset, including * only those series that are listed in visibleSeriesKeys. * * @param dataset the dataset (<code>null</code> not permitted). * @param visibleSeriesKeys the keys for the visible series * (<code>null</code> not permitted). * @param includeInterval include the y-interval (if the dataset has a * y-interval).//from ww w. j a va 2 s . co m * * @return The data bounds. * * @since 1.0.13 */ public static Range findRangeBounds(CategoryDataset dataset, List visibleSeriesKeys, boolean includeInterval) { ParamChecks.nullNotPermitted(dataset, "dataset"); Range result; if (dataset instanceof CategoryRangeInfo) { CategoryRangeInfo info = (CategoryRangeInfo) dataset; result = info.getRangeBounds(visibleSeriesKeys, includeInterval); } else { result = iterateToFindRangeBounds(dataset, visibleSeriesKeys, includeInterval); } return result; }
From source file:org.jfree.data.time.TimeSeries.java
/** * Adds or updates an item in the times series and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param item the data item (<code>null</code> not permitted). * * @return A copy of the overwritten data item, or <code>null</code> if no * item was overwritten./*ww w . j a v a 2 s. c om*/ * * @since 1.0.14 */ public TimeSeriesDataItem addOrUpdate(TimeSeriesDataItem item) { ParamChecks.nullNotPermitted(item, "item"); Class periodClass = item.getPeriod().getClass(); if (this.timePeriodClass == null) { this.timePeriodClass = periodClass; } else if (!this.timePeriodClass.equals(periodClass)) { String msg = "You are trying to add data where the time " + "period class is " + periodClass.getName() + ", but the TimeSeries is expecting an instance of " + this.timePeriodClass.getName() + "."; throw new SeriesException(msg); } TimeSeriesDataItem overwritten = null; int index = Collections.binarySearch(this.data, item); if (index >= 0) { TimeSeriesDataItem existing = (TimeSeriesDataItem) this.data.get(index); overwritten = (TimeSeriesDataItem) existing.clone(); // figure out if we need to iterate through all the y-values // to find the revised minY / maxY boolean iterate = false; Number oldYN = existing.getValue(); double oldY = oldYN != null ? oldYN.doubleValue() : Double.NaN; if (!Double.isNaN(oldY)) { iterate = oldY <= this.minY || oldY >= this.maxY; } existing.setValue(item.getValue()); if (iterate) { updateMinMaxYByIteration(); } else if (item.getValue() != null) { double yy = item.getValue().doubleValue(); this.minY = minIgnoreNaN(this.minY, yy); this.maxY = maxIgnoreNaN(this.maxY, yy); } } else { item = (TimeSeriesDataItem) item.clone(); this.data.add(-index - 1, item); updateBoundsForAddedItem(item); // check if this addition will exceed the maximum item count... if (getItemCount() > this.maximumItemCount) { TimeSeriesDataItem d = (TimeSeriesDataItem) this.data.remove(0); updateBoundsForRemovedItem(d); } } removeAgedItems(false); // remove old items if necessary, but // don't notify anyone, because that // happens next anyway... fireSeriesChanged(); return overwritten; }
From source file:org.jfree.data.general.DatasetUtilities.java
/** * Returns the range of values in the range for the dataset. This method * is the partner for the {@link #findDomainBounds(XYDataset, boolean)} * method.//from ww w . j a va 2 s .c o m * * @param dataset the dataset (<code>null</code> not permitted). * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The range (possibly <code>null</code>). */ public static Range findRangeBounds(XYDataset dataset, boolean includeInterval) { ParamChecks.nullNotPermitted(dataset, "dataset"); Range result; if (dataset instanceof RangeInfo) { RangeInfo info = (RangeInfo) dataset; result = info.getRangeBounds(includeInterval); } else { result = iterateRangeBounds(dataset, includeInterval); } return result; }
From source file:org.jfree.data.general.DatasetUtilities.java
/** * Finds the bounds of the y-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 y-interval (if the dataset has a * y-interval).//from w ww.java 2 s . c om * * @return The data bounds. * * @since 1.0.13 */ public static Range findRangeBounds(XYDataset dataset, List visibleSeriesKeys, Range xRange, boolean includeInterval) { ParamChecks.nullNotPermitted(dataset, "dataset"); Range result; if (dataset instanceof XYRangeInfo) { XYRangeInfo info = (XYRangeInfo) dataset; result = info.getRangeBounds(visibleSeriesKeys, xRange, includeInterval); } else { result = iterateToFindRangeBounds(dataset, visibleSeriesKeys, xRange, includeInterval); } return result; }
From source file:org.jfree.experimental.swt.SWTGraphics2D.java
/** * Draws an image.//from www . j av a2s. co m * * @param image (<code>null</code> not permitted). * @param x the x-coordinate. * @param y the y-coordinate. * @param bgcolor the background color. * @param observer an image observer. * * @return A boolean. */ public boolean drawImage(Image image, int x, int y, Color bgcolor, ImageObserver observer) { ParamChecks.nullNotPermitted(image, "image"); int w = image.getWidth(null); int h = image.getHeight(null); if (w == -1 || h == -1) { return false; } Paint savedPaint = getPaint(); fill(new Rectangle2D.Double(x, y, w, h)); setPaint(savedPaint); return drawImage(image, x, y, observer); }
From source file:org.jfree.experimental.swt.SWTGraphics2D.java
/** * Draws an image.//from ww w .ja v a 2 s. c o m * * @param image the image (<code>null</code> not permitted). * @param x the x-coordinate. * @param y the y-coordinate. * @param width the width. * @param height the height. * @param bgcolor the background colour. * @param observer an image observer. * * @return A boolean. */ public boolean drawImage(Image image, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) { ParamChecks.nullNotPermitted(image, "image"); int w = image.getWidth(null); int h = image.getHeight(null); if (w == -1 || h == -1) { return false; } Paint savedPaint = getPaint(); fill(new Rectangle2D.Double(x, y, w, h)); setPaint(savedPaint); return drawImage(image, x, y, width, height, observer); }
From source file:org.jfree.data.general.DatasetUtilities.java
/** * Iterates over the data item of the category dataset to find * the range bounds./* w w w . j a va2 s.c o m*/ * * @param dataset the dataset (<code>null</code> not permitted). * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * @param visibleSeriesKeys the visible series keys. * * @return The range (possibly <code>null</code>). * * @since 1.0.13 */ public static Range iterateToFindRangeBounds(CategoryDataset dataset, List visibleSeriesKeys, boolean includeInterval) { ParamChecks.nullNotPermitted(dataset, "dataset"); ParamChecks.nullNotPermitted(visibleSeriesKeys, "visibleSeriesKeys"); double minimum = Double.POSITIVE_INFINITY; double maximum = Double.NEGATIVE_INFINITY; int columnCount = dataset.getColumnCount(); if (includeInterval && dataset instanceof BoxAndWhiskerCategoryDataset) { // handle special case of BoxAndWhiskerDataset BoxAndWhiskerCategoryDataset bx = (BoxAndWhiskerCategoryDataset) dataset; Iterator iterator = visibleSeriesKeys.iterator(); while (iterator.hasNext()) { Comparable seriesKey = (Comparable) iterator.next(); int series = dataset.getRowIndex(seriesKey); int itemCount = dataset.getColumnCount(); for (int item = 0; item < itemCount; item++) { Number lvalue = bx.getMinRegularValue(series, item); if (lvalue == null) { lvalue = bx.getValue(series, item); } Number uvalue = bx.getMaxRegularValue(series, item); if (uvalue == null) { uvalue = bx.getValue(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 IntervalCategoryDataset) { // handle the special case where the dataset has y-intervals that // we want to measure IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset; Number lvalue, uvalue; Iterator iterator = visibleSeriesKeys.iterator(); while (iterator.hasNext()) { Comparable seriesKey = (Comparable) iterator.next(); int series = dataset.getRowIndex(seriesKey); for (int column = 0; column < columnCount; column++) { lvalue = icd.getStartValue(series, column); uvalue = icd.getEndValue(series, column); if (lvalue != null && !Double.isNaN(lvalue.doubleValue())) { minimum = Math.min(minimum, lvalue.doubleValue()); } if (uvalue != null && !Double.isNaN(uvalue.doubleValue())) { maximum = Math.max(maximum, uvalue.doubleValue()); } } } } else if (includeInterval && dataset instanceof MultiValueCategoryDataset) { // handle the special case where the dataset has y-intervals that // we want to measure MultiValueCategoryDataset mvcd = (MultiValueCategoryDataset) dataset; Iterator iterator = visibleSeriesKeys.iterator(); while (iterator.hasNext()) { Comparable seriesKey = (Comparable) iterator.next(); int series = dataset.getRowIndex(seriesKey); for (int column = 0; column < columnCount; column++) { List values = mvcd.getValues(series, column); Iterator valueIterator = values.iterator(); while (valueIterator.hasNext()) { Object o = valueIterator.next(); if (o instanceof Number) { double v = ((Number) o).doubleValue(); if (!Double.isNaN(v)) { minimum = Math.min(minimum, v); maximum = Math.max(maximum, v); } } } } } } else if (includeInterval && dataset instanceof StatisticalCategoryDataset) { // handle the special case where the dataset has y-intervals that // we want to measure StatisticalCategoryDataset scd = (StatisticalCategoryDataset) dataset; Iterator iterator = visibleSeriesKeys.iterator(); while (iterator.hasNext()) { Comparable seriesKey = (Comparable) iterator.next(); int series = dataset.getRowIndex(seriesKey); for (int column = 0; column < columnCount; column++) { Number meanN = scd.getMeanValue(series, column); if (meanN != null) { double std = 0.0; Number stdN = scd.getStdDevValue(series, column); if (stdN != null) { std = stdN.doubleValue(); if (Double.isNaN(std)) { std = 0.0; } } double mean = meanN.doubleValue(); if (!Double.isNaN(mean)) { minimum = Math.min(minimum, mean - std); maximum = Math.max(maximum, mean + std); } } } } } else { // handle the standard case (plain CategoryDataset) Iterator iterator = visibleSeriesKeys.iterator(); while (iterator.hasNext()) { Comparable seriesKey = (Comparable) iterator.next(); int series = dataset.getRowIndex(seriesKey); for (int column = 0; column < columnCount; column++) { Number value = dataset.getValue(series, column); if (value != null) { double v = value.doubleValue(); if (!Double.isNaN(v)) { minimum = Math.min(minimum, v); maximum = Math.max(maximum, v); } } } } } if (minimum == Double.POSITIVE_INFINITY) { return null; } else { return new Range(minimum, maximum); } }