1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
private String executableToChart = null;
Composite parentView;
ChartComposite compoChart = null;
JFreeChart chart = null;
public void createPartControl(Composite parent) {
parentView = parent;
if(executableToChart == null){
ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
if(selection instanceof TreeSelection){
TreeSelection ts = (TreeSelection)selection;
TreePath[] treePath = ts.getPaths();
Object oFile = treePath[0].getFirstSegment();
if ((oFile != null) && (oFile instanceof IBinary)) {
IBinary bin = (IBinary) oFile;
IResource f = bin.getResource();
executableToChart = f.getLocation().toString();
}
}
}
createChart(executableToChart, 1);
}
private void createChart(String exe, int i){
DefaultPieDataset data = createDataSet(exe,i);
//create a chart...
chart = null;
chart=ChartFactory.createPieChart( "SamplePieChart", data, true/*legend?*/,true/*tooltips?*/, false/*URLs?*/);
compoChart = null;
compoChart = new ChartComposite(parentView, SWT.NONE, chart, true);
}
// just for test : simple data
private DefaultPieDataset createDataSet(String executable, int test){
//create a dataset...
DefaultPieDataset data=new DefaultPieDataset();
if(test == 1){
data.setValue("Category1",43.2);
data.setValue("Category2",27.9);
data.setValue("Category3",79.5);
}
if(test == 2){
data.setValue("OtherCategory1",63.2);
data.setValue("OtherCategory2",17.9);
data.setValue("OtherCategory3",29.5);
}
return data;
} |
Partager