{
super.encodeEnd(context);
UIChart chart = (UIChart) findITextParent(getParent(), UIChart.class);
if (chart != null) {
Dataset dataset = chart.getDataset();
if (dataset instanceof DefaultPieDataset) {
DefaultPieDataset piedata = (DefaultPieDataset) dataset;
piedata.setValue(getKey(), getNumericValue());
PiePlot plot = (PiePlot) chart.getChart().getPlot();
if (getExplodedPercent() != null) {
plot.setExplodePercent(getKey(), getExplodedPercent());
}
if (UIChart.findColor(getSectionPaint()) != null) {
plot.setSectionPaint(getKey(), UIChart.findColor(getSectionPaint()));
}
if (UIChart.findColor(getSectionOutlinePaint()) != null) {
plot.setSectionOutlinePaint(getKey(), UIChart.findColor(getSectionOutlinePaint()));
}
if (UIChart.findStroke(getSectionOutlineStroke()) != null) {
plot.setSectionOutlineStroke(getKey(), UIChart.findStroke(getSectionOutlineStroke()));
}
} else if (dataset instanceof DefaultCategoryDataset) {
DefaultCategoryDataset data = (DefaultCategoryDataset) dataset;
//CategoryPlot plot = (CategoryPlot) chart.getChart().getPlot();
data.addValue(getNumericValue(), getSeries(), getKey());
} else {
throw new RuntimeException("Cannot add data to dataset of type " + dataset.getClass());
}
}
}