List of usage examples for org.jfree.chart.util Args nullNotPermitted
public static void nullNotPermitted(Object param, String name)
From source file:org.jfree.data.DataUtils.java
/** * Returns a clone of the specified array. * * @param source the source array ({@code null} not permitted). * * @return A clone of the array./*from w ww . j a v a 2 s .com*/ * * @since 1.0.13 */ public static double[][] clone(double[][] source) { Args.nullNotPermitted(source, "source"); double[][] clone = new double[source.length][]; for (int i = 0; i < source.length; i++) { if (source[i] != null) { double[] row = new double[source[i].length]; System.arraycopy(source[i], 0, row, 0, source[i].length); clone[i] = row; } } return clone; }
From source file:org.jfree.data.general.HeatMapUtils.java
/** * Creates an image that displays the values from the specified dataset. * * @param dataset the dataset ({@code null} not permitted). * @param paintScale the paint scale for the z-values ({@code null} * not permitted)./*from w w w .ja v a2 s. c o m*/ * * @return A buffered image. */ public static BufferedImage createHeatMapImage(HeatMapDataset dataset, PaintScale paintScale) { Args.nullNotPermitted(dataset, "dataset"); Args.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.DataUtils.java
/** * Returns the total of the values in one column of the supplied data * table.//from www . j ava 2 s .co m * * @param data the table of values ({@code null} not permitted). * @param column the column index (zero-based). * * @return The total of the values in the specified column. */ public static double calculateColumnTotal(Values2D data, int column) { Args.nullNotPermitted(data, "data"); double total = 0.0; int rowCount = data.getRowCount(); for (int r = 0; r < rowCount; r++) { Number n = data.getValue(r, column); if (n != null) { total += n.doubleValue(); } } return total; }
From source file:org.jfree.data.DataUtils.java
/** * Returns the total of the values in one column of the supplied data * table by taking only the row numbers in the array into account. * * @param data the table of values ({@code null} not permitted). * @param column the column index (zero-based). * @param validRows the array with valid rows (zero-based). * * @return The total of the valid values in the specified column. * * @since 1.0.13/*from ww w. jav a 2 s . c o m*/ */ public static double calculateColumnTotal(Values2D data, int column, int[] validRows) { Args.nullNotPermitted(data, "data"); double total = 0.0; int rowCount = data.getRowCount(); for (int v = 0; v < validRows.length; v++) { int row = validRows[v]; if (row < rowCount) { Number n = data.getValue(row, column); if (n != null) { total += n.doubleValue(); } } } return total; }
From source file:org.jfree.data.DataUtils.java
/** * Returns the total of the values in one row of the supplied data * table./*from w ww .j ava 2s . c o m*/ * * @param data the table of values ({@code null} not permitted). * @param row the row index (zero-based). * * @return The total of the values in the specified row. */ public static double calculateRowTotal(Values2D data, int row) { Args.nullNotPermitted(data, "data"); double total = 0.0; int columnCount = data.getColumnCount(); for (int c = 0; c < columnCount; c++) { Number n = data.getValue(row, c); if (n != null) { total += n.doubleValue(); } } return total; }
From source file:org.jfree.data.DataUtils.java
/** * Returns the total of the values in one row of the supplied data * table by taking only the column numbers in the array into account. * * @param data the table of values ({@code null} not permitted). * @param row the row index (zero-based). * @param validCols the array with valid cols (zero-based). * * @return The total of the valid values in the specified row. * * @since 1.0.13//from w w w . j a v a2 s . c o m */ public static double calculateRowTotal(Values2D data, int row, int[] validCols) { Args.nullNotPermitted(data, "data"); double total = 0.0; int colCount = data.getColumnCount(); for (int v = 0; v < validCols.length; v++) { int col = validCols[v]; if (col < colCount) { Number n = data.getValue(row, col); if (n != null) { total += n.doubleValue(); } } } return total; }
From source file:org.jfree.data.DataUtils.java
/** * Constructs an array of {@code Number} objects from an array of * {@code double} primitives.//ww w .j a v a 2 s.co m * * @param data the data ({@code null} not permitted). * * @return An array of {@code double}. */ public static Number[] createNumberArray(double[] data) { Args.nullNotPermitted(data, "data"); Number[] result = new Number[data.length]; for (int i = 0; i < data.length; i++) { result[i] = new Double(data[i]); } return result; }
From source file:org.jfree.data.DataUtils.java
/** * Constructs an array of arrays of {@code Number} objects from a * corresponding structure containing {@code double} primitives. * * @param data the data ({@code null} not permitted). * * @return An array of {@code double}./*from w w w. ja v a 2 s . c om*/ */ public static Number[][] createNumberArray2D(double[][] data) { Args.nullNotPermitted(data, "data"); int l1 = data.length; Number[][] result = new Number[l1][]; for (int i = 0; i < l1; i++) { result[i] = createNumberArray(data[i]); } return result; }
From source file:org.jfree.data.DataUtils.java
/** * Returns a {@link KeyedValues} instance that contains the cumulative * percentage values for the data in another {@link KeyedValues} instance. * <p>/* www .j a va 2 s.co m*/ * The percentages are values between 0.0 and 1.0 (where 1.0 = 100%). * * @param data the data ({@code null} not permitted). * * @return The cumulative percentages. */ public static KeyedValues getCumulativePercentages(KeyedValues data) { Args.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.general.DatasetUtils.java
/** * Calculates the total of all the values in a {@link PieDataset}. If * the dataset contains negative or {@code null} values, they are * ignored.//from w w w . j av a2 s .com * * @param dataset the dataset ({@code null} not permitted). * * @return The total. */ public static double calculatePieDatasetTotal(PieDataset dataset) { Args.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; }