本文整理汇总了Java中org.jfree.chart.util.ParamChecks类的典型用法代码示例。如果您正苦于以下问题:Java ParamChecks类的具体用法?Java ParamChecks怎么用?Java ParamChecks使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParamChecks类属于org.jfree.chart.util包,在下文中一共展示了ParamChecks类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculatePieDatasetTotal
import org.jfree.chart.util.ParamChecks; //导入依赖的package包/类
/**
* Calculates the total of all the values in a {@link PieDataset}. If
* the dataset contains negative or <code>null</code> values, they are
* ignored.
*
* @param dataset the dataset (<code>null</code> not permitted).
*
* @return The total.
*/
public static double calculatePieDatasetTotal(PieDataset dataset) {
ParamChecks.nullNotPermitted(dataset, "dataset");
List keys = dataset.getKeys();
double totalValue = 0;
Iterator iterator = keys.iterator();
while (iterator.hasNext()) {
Comparable current = (Comparable) iterator.next();
if (current != null) {
Number value = dataset.getValue(current);
double v = 0.0;
if (value != null) {
v = value.doubleValue();
}
if (v > 0) {
totalValue = totalValue + v;
}
}
}
return totalValue;
}
示例2: remove
import org.jfree.chart.util.ParamChecks; //导入依赖的package包/类
/**
* Removes a subplot from the combined chart and sends a
* {@link PlotChangeEvent} to all registered listeners.
*
* @param subplot the subplot (<code>null</code> not permitted).
*/
public void remove(XYPlot subplot) {
ParamChecks.nullNotPermitted(subplot, "subplot");
int position = -1;
int size = this.subplots.size();
int i = 0;
while (position == -1 && i < size) {
if (this.subplots.get(i) == subplot) {
position = i;
}
i++;
}
if (position != -1) {
this.subplots.remove(position);
subplot.setParent(null);
subplot.removeChangeListener(this);
ValueAxis domain = getDomainAxis();
if (domain != null) {
domain.configure();
}
fireChangeEvent();
}
}
示例3: removeRangeMarker
import org.jfree.chart.util.ParamChecks; //导入依赖的package包/类
/**
* Removes a marker for a specific dataset/renderer and sends a
* {@link PlotChangeEvent} to all registered listeners.
*
* @param index the dataset/renderer index.
* @param marker the marker.
* @param layer the layer (foreground or background).
* @param notify notify listeners.
*
* @return A boolean indicating whether or not the marker was actually
* removed.
*
* @since 1.0.10
*
* @see #addRangeMarker(int, Marker, Layer, boolean)
*/
public boolean removeRangeMarker(int index, Marker marker, Layer layer,
boolean notify) {
ParamChecks.nullNotPermitted(marker, "marker");
ArrayList markers;
if (layer == Layer.FOREGROUND) {
markers = (ArrayList) this.foregroundRangeMarkers.get(new Integer(
index));
} else {
markers = (ArrayList) this.backgroundRangeMarkers.get(new Integer(
index));
}
if (markers == null) {
return false;
}
boolean removed = markers.remove(marker);
if (removed && notify) {
fireChangeEvent();
}
return removed;
}
示例4: createXYLineChart
import org.jfree.chart.util.ParamChecks; //导入依赖的package包/类
/**
* Creates a line chart (based on an {@link XYDataset}) with default
* settings.
*
* @param title the chart title (<code>null</code> permitted).
* @param xAxisLabel a label for the X-axis (<code>null</code> permitted).
* @param yAxisLabel a label for the Y-axis (<code>null</code> permitted).
* @param dataset the dataset for the chart (<code>null</code> permitted).
* @param orientation the plot orientation (horizontal or vertical)
* (<code>null</code> NOT permitted).
* @param legend a flag specifying whether or not a legend is required.
* @param tooltips configure chart to generate tool tips?
* @param urls configure chart to generate URLs?
*
* @return The chart.
*/
public static JFreeChart createXYLineChart(String title, String xAxisLabel,
String yAxisLabel, XYDataset dataset, PlotOrientation orientation,
boolean legend, boolean tooltips, boolean urls) {
ParamChecks.nullNotPermitted(orientation, "orientation");
NumberAxis xAxis = new NumberAxis(xAxisLabel);
xAxis.setAutoRangeIncludesZero(false);
NumberAxis yAxis = new NumberAxis(yAxisLabel);
XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
plot.setOrientation(orientation);
if (tooltips) {
renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
}
if (urls) {
renderer.setURLGenerator(new StandardXYURLGenerator());
}
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
plot, legend);
currentTheme.apply(chart);
return chart;
}
示例5: CategoryLineAnnotation
import org.jfree.chart.util.ParamChecks; //导入依赖的package包/类
/**
* Creates a new annotation that draws a line between (category1, value1)
* and (category2, value2).
*
* @param category1 the category (<code>null</code> not permitted).
* @param value1 the value.
* @param category2 the category (<code>null</code> not permitted).
* @param value2 the value.
* @param paint the line color (<code>null</code> not permitted).
* @param stroke the line stroke (<code>null</code> not permitted).
*/
public CategoryLineAnnotation(Comparable category1, double value1,
Comparable category2, double value2,
Paint paint, Stroke stroke) {
super();
ParamChecks.nullNotPermitted(category1, "category1");
ParamChecks.nullNotPermitted(category2, "category2");
ParamChecks.nullNotPermitted(paint, "paint");
ParamChecks.nullNotPermitted(stroke, "stroke");
this.category1 = category1;
this.value1 = value1;
this.category2 = category2;
this.value2 = value2;
this.paint = paint;
this.stroke = stroke;
}
示例6: AbstractCategoryItemLabelGenerator
import org.jfree.chart.util.ParamChecks; //导入依赖的package包/类
/**
* Creates a label generator with the specified date formatter.
*
* @param labelFormat the label format string (<code>null</code> not
* permitted).
* @param formatter the date formatter (<code>null</code> not permitted).
*/
protected AbstractCategoryItemLabelGenerator(String labelFormat,
DateFormat formatter) {
ParamChecks.nullNotPermitted(labelFormat, "labelFormat");
ParamChecks.nullNotPermitted(formatter, "formatter");
this.labelFormat = labelFormat;
this.numberFormat = null;
this.percentFormat = NumberFormat.getPercentInstance();
this.dateFormat = formatter;
this.nullValueString = "-";
}
示例7: findCumulativeRangeBounds
import org.jfree.chart.util.ParamChecks; //导入依赖的package包/类
/**
* Calculates the range of values for a dataset where each item is the
* running total of the items for the current series.
*
* @param dataset the dataset (<code>null</code> not permitted).
*
* @return The range.
*
* @see #findRangeBounds(CategoryDataset)
*/
public static Range findCumulativeRangeBounds(CategoryDataset dataset) {
ParamChecks.nullNotPermitted(dataset, "dataset");
boolean allItemsNull = true; // we'll set this to false if there is at
// least one non-null data item...
double minimum = 0.0;
double maximum = 0.0;
for (int row = 0; row < dataset.getRowCount(); row++) {
double runningTotal = 0.0;
for (int column = 0; column <= dataset.getColumnCount() - 1;
column++) {
Number n = dataset.getValue(row, column);
if (n != null) {
allItemsNull = false;
double value = n.doubleValue();
if (!Double.isNaN(value)) {
runningTotal = runningTotal + value;
minimum = Math.min(minimum, runningTotal);
maximum = Math.max(maximum, runningTotal);
}
}
}
}
if (!allItemsNull) {
return new Range(minimum, maximum);
}
else {
return null;
}
}
示例8: createMovingAverage
import org.jfree.chart.util.ParamChecks; //导入依赖的package包/类
/**
* Creates a new {@link XYDataset} containing the moving averages of each
* series in the <code>source</code> dataset.
*
* @param source the source dataset.
* @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;
}
示例9: setLast
import org.jfree.chart.util.ParamChecks; //导入依赖的package包/类
/**
* Sets the last time period in the axis range and sends an
* {@link AxisChangeEvent} to all registered listeners.
*
* @param last the time period (<code>null</code> not permitted).
*/
public void setLast(RegularTimePeriod last) {
ParamChecks.nullNotPermitted(last, "last");
this.last = last;
this.last.peg(this.calendar);
fireChangeEvent();
}
示例10: add
import org.jfree.chart.util.ParamChecks; //导入依赖的package包/类
/**
* Adds a data item to the series and sends a {@link SeriesChangeEvent} to
* all registered listeners.
*
* @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();
}
示例11: setMaximumDate
import org.jfree.chart.util.ParamChecks; //导入依赖的package包/类
/**
* Sets the maximum date visible on the axis and sends an
* {@link AxisChangeEvent} to all registered listeners. If
* <code>maximumDate</code> is on or before the current minimum date for
* the axis, the minimum date will be shifted to preserve the current
* length of the axis.
*
* @param maximumDate the date (<code>null</code> not permitted).
*
* @see #getMinimumDate()
* @see #setMinimumDate(Date)
*/
public void setMaximumDate(Date maximumDate) {
ParamChecks.nullNotPermitted(maximumDate, "maximumDate");
// check the new maximum date relative to the current minimum date
Date minDate = getMinimumDate();
long minMillis = minDate.getTime();
long newMaxMillis = maximumDate.getTime();
if (minMillis >= newMaxMillis) {
Date oldMax = getMaximumDate();
long length = oldMax.getTime() - minMillis;
minDate = new Date(newMaxMillis - length);
}
setRange(new DateRange(minDate, maximumDate), true, false);
fireChangeEvent();
}
示例12: findSubplot
import org.jfree.chart.util.ParamChecks; //导入依赖的package包/类
/**
* Returns the subplot (if any) that contains the (x, y) point (specified
* in Java2D space).
*
* @param info the chart rendering info (<code>null</code> not permitted).
* @param source the source point (<code>null</code> not permitted).
*
* @return A subplot (possibly <code>null</code>).
*/
public XYPlot findSubplot(PlotRenderingInfo info, Point2D source) {
ParamChecks.nullNotPermitted(info, "info");
ParamChecks.nullNotPermitted(source, "source");
XYPlot result = null;
int subplotIndex = info.getSubplotIndex(source);
if (subplotIndex >= 0) {
result = (XYPlot) this.subplots.get(subplotIndex);
}
return result;
}
示例13: getSlope
import org.jfree.chart.util.ParamChecks; //导入依赖的package包/类
/**
* Finds the slope of a regression line using least squares.
*
* @param xData the x-values ({@code null} not permitted).
* @param yData the y-values ({@code null} not permitted).
*
* @return The slope.
*/
public static double getSlope(Number[] xData, Number[] yData) {
ParamChecks.nullNotPermitted(xData, "xData");
ParamChecks.nullNotPermitted(yData, "yData");
if (xData.length != yData.length) {
throw new IllegalArgumentException("Array lengths must be equal.");
}
// ********* stat function for linear slope ********
// y = a + bx
// a = ybar - b * xbar
// sum(x * y) - (sum (x) * sum(y)) / n
// b = ------------------------------------
// sum (x^2) - (sum(x)^2 / n
// *************************************************
// sum of x, x^2, x * y, y
double sx = 0.0, sxx = 0.0, sxy = 0.0, sy = 0.0;
int counter;
for (counter = 0; counter < xData.length; counter++) {
sx = sx + xData[counter].doubleValue();
sxx = sxx + Math.pow(xData[counter].doubleValue(), 2);
sxy = sxy + yData[counter].doubleValue()
* xData[counter].doubleValue();
sy = sy + yData[counter].doubleValue();
}
return (sxy - (sx * sy) / counter) / (sxx - (sx * sx) / counter);
}
示例14: SpiderWebPlot
import org.jfree.chart.util.ParamChecks; //导入依赖的package包/类
/**
* Creates a new spider web plot with the given dataset.
*
* @param dataset the dataset.
* @param extract controls how data is extracted ({@link TableOrder#BY_ROW}
* or {@link TableOrder#BY_COLUMN}).
*/
public SpiderWebPlot(CategoryDataset dataset, TableOrder extract) {
super();
ParamChecks.nullNotPermitted(extract, "extract");
this.dataset = dataset;
if (dataset != null) {
dataset.addChangeListener(this);
}
this.dataExtractOrder = extract;
this.headPercent = DEFAULT_HEAD;
this.axisLabelGap = DEFAULT_AXIS_LABEL_GAP;
this.axisLinePaint = Color.black;
this.axisLineStroke = new BasicStroke(1.0f);
this.interiorGap = DEFAULT_INTERIOR_GAP;
this.startAngle = DEFAULT_START_ANGLE;
this.direction = Rotation.CLOCKWISE;
this.maxValue = DEFAULT_MAX_VALUE;
this.seriesPaint = null;
this.seriesPaintList = new PaintList();
this.baseSeriesPaint = null;
this.seriesOutlinePaint = null;
this.seriesOutlinePaintList = new PaintList();
this.baseSeriesOutlinePaint = DEFAULT_OUTLINE_PAINT;
this.seriesOutlineStroke = null;
this.seriesOutlineStrokeList = new StrokeList();
this.baseSeriesOutlineStroke = DEFAULT_OUTLINE_STROKE;
this.labelFont = DEFAULT_LABEL_FONT;
this.labelPaint = DEFAULT_LABEL_PAINT;
this.labelGenerator = new StandardCategoryItemLabelGenerator();
this.legendItemShape = DEFAULT_LEGEND_ITEM_CIRCLE;
}
示例15: setVerticalAlignment
import org.jfree.chart.util.ParamChecks; //导入依赖的package包/类
/**
* Sets the vertical alignment for the title, and notifies any registered
* listeners of the change.
*
* @param alignment the new vertical alignment (TOP, MIDDLE or BOTTOM,
* <code>null</code> not permitted).
*/
public void setVerticalAlignment(VerticalAlignment alignment) {
ParamChecks.nullNotPermitted(alignment, "alignment");
if (this.verticalAlignment != alignment) {
this.verticalAlignment = alignment;
notifyListeners(new TitleChangeEvent(this));
}
}