knowm / XChart

XChart is a light-weight Java library for plotting data.
http://knowm.org/open-source/xchart
Apache License 2.0
1.5k stars 397 forks source link

Can we get a "no default interaction" superclass of XChartPanel? #532

Open gbl opened 3 years ago

gbl commented 3 years ago

Right now, the default, and only, constructor of XChartPanel adds a lot of mouse listeners and keyboard shortcuts to the panel. Removing those is a bit tedious if you don't want the default behaviour.

Would it be possible to

a) move the mouse listeners, mouse motion listeners, and keyboard shortcuts into separate, overridable methods, like initPopupMenu, initTooltips, initCursor, initKeyStrokes that get called from the constructor, so you can subclass XChartPanel, overriding these methods with NOPs or your own versions

or

b) add a glue class NoDefaultInteractionXChartPanel between XChartPanel and JPanel that has what's neccesary to display, but not interact, with the panel? (paintComponent, getChart, getPreferredSize)?

Of course I could just create my own class and copy/paste the few methods into it, but an "official" version would be a bit less fragile in the future.

timmolter commented 3 years ago

Thanks for the suggestion. I'll think about it.