@Override public void dispose() { try { // clear our componenents // ... freeze charts if (chart != null) chart.setNotify(false); // ... empty data if (dataset != null) dataset.clear(); // ... dispose chart composites if (chartComposites != null && !chartComposites.isDisposed()) chartComposites.dispose(); if (form != null) form.dispose(); if (toolkit != null) toolkit.dispose(); } catch (RuntimeException e) { e.printStackTrace(); } super.dispose(); }
@Override public void createPartControl(Composite parent) { super.createPartControl(parent); messages.traceTech("init the form...", getClass()); toolkit = new FormToolkit(parent.getDisplay()); parent.setLayout(new FillLayout()); form = toolkit.createScrolledForm(parent); RowLayout layout = new RowLayout(SWT.VERTICAL); layout.center = false; layout.fill = false; layout.pack = true; layout.justify = false; form.getBody().setLayout(layout); form.getBody() .addControlListener( new ControlListener() { @Override public void controlResized(ControlEvent e) { manageResized(); } @Override public void controlMoved(ControlEvent e) {} }); labelIteration = toolkit.createLabel(form.getBody(), "not data displayed yet"); // TODO separator toolkit.createSeparator(form.getBody(), ); compositeCharts = toolkit.createComposite(form.getBody()); compositeCharts.setLayoutData(new RowData()); compositeCharts.setLayout(new GridLayout(1, false)); // create the chart // create dataset dataset = new DefaultCategoryDataset(); // create plot plot = new EnhancedSpiderWebPlot(dataset); plot.setMaxValue(1.0); plot.setWebFilled(true); plot.setInteriorGap(0.2D); plot.setBackgroundPaint(Color.WHITE); // create chart chart = new JFreeChart("1th Pareto front", TextTitle.DEFAULT_FONT, plot, false); LegendTitle legendtitle = new LegendTitle(plot); legendtitle.setPosition(RectangleEdge.BOTTOM); chart.addSubtitle(legendtitle); chart.getPlot().setBackgroundPaint(Color.white); chart.setBackgroundPaint(Color.WHITE); // create host composite chartComposites = new ChartComposite( compositeCharts, SWT.NONE, chart, true // use a buffer ); chartComposites.setSize(preferedWidth, preferedHeight); chartComposites.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); chartComposites.setBackground(compositeCharts.getBackground()); // update display form.getBody().layout(true); form.reflow(true); }