Example usage for org.jfree.data DataUtilities calculateRowTotal

List of usage examples for org.jfree.data DataUtilities calculateRowTotal

Introduction

In this page you can find the example usage for org.jfree.data DataUtilities calculateRowTotal.

Prototype

public static double calculateRowTotal(Values2D data, int row) 

Source Link

Document

Returns the total of the values in one row of the supplied data table.

Usage

From source file:com.newatlanta.bluedragon.CategoryItemLabelGenerator.java

protected Object[] createItemArray(CategoryDataset dataset, int row, int column) {
    Object[] result = new Object[5];
    result[0] = dataset.getRowKey(row).toString();
    result[1] = dataset.getColumnKey(column).toString();
    Number value = dataset.getValue(row, column);
    if (value != null) {
        if (yAxisSymbols != null) {
            int intValue = value.intValue();
            if (intValue < yAxisSymbols.length)
                result[2] = yAxisSymbols[intValue];
            else//from   www.  j  a va 2s.c  o  m
                result[2] = "???";
        } else if (this.getNumberFormat() != null) {
            result[2] = this.getNumberFormat().format(value);
        } else if (this.getDateFormat() != null) {
            result[2] = this.getDateFormat().format(value);
        }
    } else {
        result[2] = "-"; // this.nullValueString;
    }

    if (value != null) {
        double total = DataUtilities.calculateRowTotal(dataset, row);
        double percent = value.doubleValue() / total;
        result[3] = NumberFormat.getPercentInstance().format(percent);
        if (this.getNumberFormat() != null) {
            result[4] = this.getNumberFormat().format(total);
        } else if (this.getDateFormat() != null) {
            // result[4] = this.getDateFormat().format(total);
        }
    }

    return result;
}