Logo Search packages:      
Sourcecode: libjfreechart-java version File versions  Download package

static double org::jfree::data::general::DatasetUtilities::calculatePieDatasetTotal ( PieDataset  dataset  )  [inline, static]

Calculates the total of all the values in a PieDataset. If the dataset contains negative or null values, they are ignored.

Parameters:
dataset the dataset (null not permitted).
Returns:
The total.

Definition at line 158 of file DatasetUtilities.java.

References org::jfree::data::KeyedValues::getKeys(), and org::jfree::data::KeyedValues::getValue().

                                                                      {
        if (dataset == null) {
            throw new IllegalArgumentException("Null 'dataset' argument.");
        }
        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;
    }


Generated by  Doxygen 1.6.0   Back to index