// Start from the end, to remove the entries and keep the index OK
for (int i=n-1; i>=0; i--) {
if (!toKeep[i]) {
GenericMapper mapper = (GenericMapper)mappers.remove(i);
if (mapper!=null) mapper.removeListener(PieChartShape.this);
DataSource source = (DataSource)mapperSources.remove(i);
if (source!=null) source.removeListener(PieChartShape.this);
dst.removeSource(i);
}
}
}
// Now we match the data set and the list
int len = pcbxcurves.getItemCount();
// first compute max ratio => define JFreeChart 100% and compute 1.0 equivalent
double maxratio = Double.NEGATIVE_INFINITY;
for (int i=0; i<len; ++i) {
CbxEntry e = (CbxEntry)pcbxcurves.getItemAt(i);
maxratio = Math.max(e.ratio, maxratio);
}
double delta = maxratio - 1.0;
// now apply changes
for (int i=0; i<len; ++i) {
CbxEntry e = (CbxEntry)pcbxcurves.getItemAt(i);
dst.setName(i,e.name);
DataSource ds = (DataSource)mapperSources.get(i);
if ((e.source==null) && (ds!=null)) {
ds.removeListener(PieChartShape.this);
ds.removeEndNotificationListener(PieChartShape.this);
}
mapperSources.set(i,e.source);
if (e.source!=null) {
e.source.addListener(PieChartShape.this);
e.source.addEndNotificationListener(PieChartShape.this);