Java Code Examples for org.jfree.chart.util.ParamChecks#nullNotPermitted()

The following examples show how to use org.jfree.chart.util.ParamChecks#nullNotPermitted() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChartUtilities.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Saves a chart to a file in PNG format.  This method allows you to pass
 * in a {@link ChartRenderingInfo} object, to collect information about the
 * chart dimensions/entities.  You will need this info if you want to
 * create an HTML image map.
 *
 * @param file  the file (<code>null</code> not permitted).
 * @param chart  the chart (<code>null</code> not permitted).
 * @param width  the image width.
 * @param height  the image height.
 * @param info  the chart rendering info (<code>null</code> permitted).
 * @param encodeAlpha  encode alpha?
 * @param compression  the PNG compression level (0-9).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void saveChartAsPNG(File file, JFreeChart chart,
       int width, int height, ChartRenderingInfo info, boolean encodeAlpha,
       int compression) throws IOException {

    ParamChecks.nullNotPermitted(file, "file");
    ParamChecks.nullNotPermitted(chart, "chart");
    OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
    try {
        writeChartAsPNG(out, chart, width, height, info, encodeAlpha,
                compression);
    }
    finally {
        out.close();
    }

}
 
Example 2
Source File: KeyedObjects2D.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Adds or updates an object.
 *
 * @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);
    }
}
 
Example 3
Source File: Statistics.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the standard deviation of a set of numbers.
 *
 * @param data  the data ({@code null} or zero length array not
 *     permitted).
 *
 * @return The standard deviation of a set of numbers.
 */
public static double getStdDev(Number[] data) {
    ParamChecks.nullNotPermitted(data, "data");
    if (data.length == 0) {
        throw new IllegalArgumentException("Zero length 'data' array.");
    }
    double avg = calculateMean(data);
    double sum = 0.0;

    for (int counter = 0; counter < data.length; counter++) {
        double diff = data[counter].doubleValue() - avg;
        sum = sum + diff * diff;
    }
    return Math.sqrt(sum / (data.length - 1));
}
 
Example 4
Source File: AbstractCategoryItemLabelGenerator.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Generates a for the specified item.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param row  the row index (zero-based).
 * @param column  the column index (zero-based).
 *
 * @return The label (possibly <code>null</code>).
 */
protected String generateLabelString(CategoryDataset dataset,
                                     int row, int column) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    String result;
    Object[] items = createItemArray(dataset, row, column);
    result = MessageFormat.format(this.labelFormat, items);
    return result;

}
 
Example 5
Source File: AbstractCategoryItemLabelGenerator.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * 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 = "-";
}
 
Example 6
Source File: StandardChartTheme.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Applies the settings of this theme to the specified annotation.
 *
 * @param annotation  the annotation.
 */
protected void applyToXYAnnotation(XYAnnotation annotation) {
    ParamChecks.nullNotPermitted(annotation, "annotation");
    if (annotation instanceof XYTextAnnotation) {
        XYTextAnnotation xyta = (XYTextAnnotation) annotation;
        xyta.setFont(this.smallFont);
        xyta.setPaint(this.itemLabelPaint);
    }
}
 
Example 7
Source File: ThermometerPlot.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the range axis for the plot and sends a {@link PlotChangeEvent} to
 * all registered listeners.
 *
 * @param axis  the new axis (<code>null</code> not permitted).
 *
 * @see #getRangeAxis()
 */
public void setRangeAxis(ValueAxis axis) {
    ParamChecks.nullNotPermitted(axis, "axis");
    // plot is registered as a listener with the existing axis...
    this.rangeAxis.removeChangeListener(this);

    axis.setPlot(this);
    axis.addChangeListener(this);
    this.rangeAxis = axis;
    fireChangeEvent();
}
 
Example 8
Source File: StandardEntityCollection.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Adds an entity to the collection.
 *
 * @param entity  the entity (<code>null</code> not permitted).
 */
@Override
public void add(ChartEntity entity) {
    ParamChecks.nullNotPermitted(entity, "entity");
    this.entities.add(entity);
}
 
Example 9
Source File: AbstractRenderer.java    From SIMVA-SoS with Apache License 2.0 3 votes vote down vote up
/**
 * Sets the base shape and, if requested, sends a
 * {@link RendererChangeEvent} to all registered listeners.
 *
 * @param shape  the shape (<code>null</code> not permitted).
 * @param notify  notify listeners?
 *
 * @see #getBaseShape()
 */
public void setBaseShape(Shape shape, boolean notify) {
    ParamChecks.nullNotPermitted(shape, "shape");
    this.baseShape = shape;
    if (notify) {
        fireChangeEvent();
    }
}
 
Example 10
Source File: CategoryAxis.java    From SIMVA-SoS with Apache License 2.0 3 votes vote down vote up
/**
 * Removes the tooltip for the specified category and, if there was a value
 * associated with that category, sends an {@link AxisChangeEvent} to all 
 * registered listeners.
 *
 * @param category  the category (<code>null</code> not permitted).
 *
 * @see #addCategoryLabelToolTip(Comparable, String)
 * @see #clearCategoryLabelToolTips()
 */
public void removeCategoryLabelToolTip(Comparable category) {
    ParamChecks.nullNotPermitted(category, "category");
    if (this.categoryLabelToolTips.remove(category) != null) {
        fireChangeEvent();
    }
}
 
Example 11
Source File: Crosshair.java    From ccu-historian with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Sets the label outline paint and sends a property change event (with the
 * name "labelOutlinePaint") to all registered listeners.
 *
 * @param paint  the paint (<code>null</code> not permitted).
 *
 * @see #getLabelOutlinePaint()
 */
public void setLabelOutlinePaint(Paint paint) {
    ParamChecks.nullNotPermitted(paint, "paint");
    Paint old = this.labelOutlinePaint;
    this.labelOutlinePaint = paint;
    this.pcs.firePropertyChange("labelOutlinePaint", old, paint);
}
 
Example 12
Source File: CategoryPlot.java    From SIMVA-SoS with Apache License 2.0 3 votes vote down vote up
/**
 * Returns the index of the specified axis, or <code>-1</code> if the axis
 * is not assigned to the plot.
 *
 * @param axis  the axis (<code>null</code> not permitted).
 *
 * @return The axis index.
 *
 * @see #getRangeAxis(int)
 * @see #getDomainAxisIndex(CategoryAxis)
 *
 * @since 1.0.7
 */
public int getRangeAxisIndex(ValueAxis axis) {
    ParamChecks.nullNotPermitted(axis, "axis");
    int result = findRangeAxisIndex(axis);
    if (result < 0) { // try the parent plot
        Plot parent = getParent();
        if (parent instanceof CategoryPlot) {
            CategoryPlot p = (CategoryPlot) parent;
            result = p.getRangeAxisIndex(axis);
        }
    }
    return result;
}
 
Example 13
Source File: PaintScaleLegend.java    From ccu-historian with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Sets the axis for the paint scale and sends a {@link TitleChangeEvent}
 * to all registered listeners.
 *
 * @param axis  the axis (<code>null</code> not permitted).
 *
 * @see #getAxis()
 */
public void setAxis(ValueAxis axis) {
    ParamChecks.nullNotPermitted(axis, "axis");
    this.axis.removeChangeListener(this);
    this.axis = axis;
    this.axis.addChangeListener(this);
    notifyListeners(new TitleChangeEvent(this));
}
 
Example 14
Source File: AbstractPieItemLabelGenerator.java    From SIMVA-SoS with Apache License 2.0 3 votes vote down vote up
/**
 * Creates an item label generator using the specified number formatters.
 *
 * @param labelFormat  the label format string (<code>null</code> not
 *                     permitted).
 * @param numberFormat  the format object for the values (<code>null</code>
 *                      not permitted).
 * @param percentFormat  the format object for the percentages
 *                       (<code>null</code> not permitted).
 */
protected AbstractPieItemLabelGenerator(String labelFormat, 
        NumberFormat numberFormat, NumberFormat percentFormat) {
    ParamChecks.nullNotPermitted(labelFormat, "labelFormat");
    ParamChecks.nullNotPermitted(numberFormat, "numberFormat");
    ParamChecks.nullNotPermitted(percentFormat, "percentFormat");
    this.labelFormat = labelFormat;
    this.numberFormat = numberFormat;
    this.percentFormat = percentFormat;
}
 
Example 15
Source File: PiePlot.java    From SIMVA-SoS with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the label link style and sends a {@link PlotChangeEvent} to all
 * registered listeners.
 *
 * @param style  the new style (<code>null</code> not permitted).
 *
 * @see #getLabelLinkStyle()
 *
 * @since 1.0.10
 */
public void setLabelLinkStyle(PieLabelLinkStyle style) {
    ParamChecks.nullNotPermitted(style, "style");
    this.labelLinkStyle = style;
    fireChangeEvent();
}
 
Example 16
Source File: Marker.java    From SIMVA-SoS with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the stroke and sends a {@link MarkerChangeEvent} to all registered
 * listeners.
 *
 * @param stroke  the stroke ({@code null}not permitted).
 *
 * @see #getStroke()
 */
public void setStroke(Stroke stroke) {
    ParamChecks.nullNotPermitted(stroke, "stroke");
    this.stroke = stroke;
    notifyListeners(new MarkerChangeEvent(this));
}
 
Example 17
Source File: XYBarRenderer.java    From SIMVA-SoS with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the bar painter and sends a {@link RendererChangeEvent} to all
 * registered listeners.
 *
 * @param painter  the painter (<code>null</code> not permitted).
 *
 * @since 1.0.11
 */
public void setBarPainter(XYBarPainter painter) {
    ParamChecks.nullNotPermitted(painter, "painter");
    this.barPainter = painter;
    fireChangeEvent();
}
 
Example 18
Source File: XYDataItem.java    From SIMVA-SoS with Apache License 2.0 2 votes vote down vote up
/**
 * Constructs a new data item.
 *
 * @param x  the x-value (<code>null</code> NOT permitted).
 * @param y  the y-value (<code>null</code> permitted).
 */
public XYDataItem(Number x, Number y) {
    ParamChecks.nullNotPermitted(x, "x");
    this.x = x;
    this.y = y;
}
 
Example 19
Source File: TextAnnotation.java    From SIMVA-SoS with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the font for the annotation and sends an
 * {@link AnnotationChangeEvent} to all registered listeners.
 *
 * @param font  the font (<code>null</code> not permitted).
 *
 * @see #getFont()
 */
public void setFont(Font font) {
    ParamChecks.nullNotPermitted(font, "font");
    this.font = font;
    fireAnnotationChanged();
}
 
Example 20
Source File: StandardChartTheme.java    From SIMVA-SoS with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the axis label paint.
 *
 * @param paint  the paint (<code>null</code> not permitted).
 *
 * @see #getAxisLabelPaint()
 */
public void setAxisLabelPaint(Paint paint) {
    ParamChecks.nullNotPermitted(paint, "paint");
    this.axisLabelPaint = paint;
}