buildDataset();
}
protected void buildDataset()
{
final DefaultCategoryDataset categoryDataset = (DefaultCategoryDataset) getDatasourceValue();
if (isGeneratedReport())
{
buildAutoGeneratedDataSet(categoryDataset);
return;
}
final DataRow dataRow = getDataRow();
final Object categoryObject = dataRow.get(getCategoryColumn());
final Comparable categoryComparable;
if (categoryObject instanceof Comparable)
{
categoryComparable = (Comparable) categoryObject;
}
else
{
// ok, we need some better error management here. Its a
// prototype :)
categoryComparable = ("CATEGORYSETCOLL.USER_ERROR_CATEGORY_NOT_COMPARABLE"); //$NON-NLS-1$
}
// I love to be paranoid!
final String[] seriesNames = getSeriesName();
final int maxIndex = Math.min(seriesNames.length, this.valueColumns.size());
for (int i = 0; i < maxIndex; i++)
{
String seriesName = seriesNames[i];
final String column = (String) valueColumns.get(i);
final Object valueObject = dataRow.get(column);
if (isSeriesColumn())
{
final Object tmp = dataRow.get(seriesName);
if (tmp != null)
{
seriesName = tmp.toString();
}
}
final Number value = (valueObject instanceof Number) ? (Number) valueObject : null;
final Number existingValue = queryExistingValueFromDataSet(categoryDataset, seriesName, categoryComparable);
if (existingValue != null)
{
if (value != null)
{
final double val = value.doubleValue();
categoryDataset.addValue(new Double(val + existingValue.doubleValue()), seriesName, categoryComparable);
}
}
else
{
categoryDataset.addValue(value, seriesName, categoryComparable);
}
}
}