First, thanks for going to the effort to port JFreeChart to SWT. It has greatly simplified things for my project. However....
The SWT-based ChartComposite class extends the SWT Composite class, but it immediately creates an SWT Canvas and expands it to fill the entire area of the ChartComposite. The net effect is that standard SWT methods often do not work, since they affect the ChartComposite and not the embedded Canvas. For example, addMouseMoveListener() has no effect, since the Canvas completely obscures the ChartComposite.
Why don't you simply make a ChartCanvas class that directly extends SWT Canvas? This would be much simpler and more in the spirit of SWT design. All of the basic SWT methods inherited from Control etc. would work as expected. I believe that this could be achieved with a simple refactoring, so that all references to the "canvas" field are replaced by "this", with no other modifications.
Or, am I missing some reason that this was not done from the beginning?
--
Peter
SWT ChartComposite vs. ChartCanvas
Hi Peter,
I realized this some time ago when people started to report problem like mouse listener not working and I had to pass the events from the composite onto the canvas. The reason for this is mainly historical, back then I did not know much about SWT, and it sounded just logical since ChartPanel extends JPanel and the equivalent of JPanel in SWT in the Composite class. I'll review the pro/cons of this approach and see if it's worth refactoring.
Btw, this kind of request is better issued by posting a feature request on sourceforge, I'm not browsing the forum everyday.
Regards
/heprom
I realized this some time ago when people started to report problem like mouse listener not working and I had to pass the events from the composite onto the canvas. The reason for this is mainly historical, back then I did not know much about SWT, and it sounded just logical since ChartPanel extends JPanel and the equivalent of JPanel in SWT in the Composite class. I'll review the pro/cons of this approach and see if it's worth refactoring.
Btw, this kind of request is better issued by posting a feature request on sourceforge, I'm not browsing the forum everyday.
Regards
/heprom