dataset.setValue("Other" + " "
+ StringUtils.getPercentNumberString(rest), rest);
}
Chart ch = createChart(dataset, title);
ChartCanvas chartCanvas = new ChartCanvas(chart, SWT.DOUBLE_BUFFERED,
true, ch);
if (createLabels) {
Composite bs = formToolkit.createComposite(chart);
GridLayout layout = new GridLayout(1, false);
layout.marginHeight = 20;
bs.setLayout(layout);
for (int a = 0; a < hotSpotsByModule.length; a++) {
double value = getChartValue(calc, hotSpotsByModule[a]);
ImageHyperlink createImageHyperlink = formToolkit
.createImageHyperlink(bs, SWT.NONE);
createImageHyperlink.setText(getChartName(hotSpotsByModule[a]));
final Image image = new Image(Display.getCurrent(), 16, 16);
GC gc = new GC(image);
PiePlot plot = (PiePlot) ch.getPlot();
String key = getChartName(hotSpotsByModule[a]) + " "
+ StringUtils.getPercentNumberString(value);
gc.setBackground(plot.lookupSectionPaint(key, true));
gc.fillRoundRectangle(0, 0, 16, 16, 2, 2);
gc.dispose();
final int b = a;
createImageHyperlink.setImage(image);
createImageHyperlink.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
image.dispose();
}
});
createImageHyperlink
.addHyperlinkListener(new IHyperlinkListener() {
public void linkActivated(HyperlinkEvent e) {
handleOpen(hotSpotsByModule[b]);
}
public void linkEntered(HyperlinkEvent e) {
}
public void linkExited(HyperlinkEvent e) {
}
});
}
bs.setLayoutData(GridDataFactory.fillDefaults().align(GridData.END,
GridData.BEGINNING).grab(false, true).create());
}
chartCanvas.setLayoutData(GridDataFactory.fillDefaults().grab(true,
true).create());
}