Feature #1193

Updated by Sebastien Jacquot almost 5 years ago

Improve the scale and pan behavior in JFC charts engine.

2 problems:

* *#1* - zoom out puts blank space between axis and chart when the chart is reduced => is it really a problem ?
* *#2* - the scaling function with category chart (charts with labels and not numbers on X axis) only works on Y axis in JFC making this function almost useless

h3. Solution 1

*#1 - blank space*
A simple way to keep axis stuck near the chart even if it's reduced is to play with the TickLabelInset while zooming/scaling. It may needs to extend the ChartPanel class and/or modify the JFC class MouseWheelHandler.
Eg. for changing the bottom label inset, should be called when scaling (and panning ?):
plot.getDomainAxis().setTickLabelInsets(new RectangleInsets(0, 0, 100, 0));

Other (better ?) way could be to redefine the behavior of XYPlot.zoomDomainAxes() or resizeRange() method of Axis.

h3. Solution 2

*#1 - blank space*
When zooming out and the chart becomes smaller than the ChartPanel dimensions, switch to an "Image zoom" mode meaning that the axes unit ticks do not update themselves anymore and all entities are reduced (even label texts, titles, legends, etc.) as a raster image scaling.
When zooming in and the chart becomes bigger than the ChartPanel dimensions, restore the original JFC behavior.

h3. Resolution

* *#2 - zoom on both axis X and Y*
I switched from category charts to XY charts for Partition dimensions and Specificities bar plot and line chart. I put some symbols instead of numeric values on X axis and implemented new renderers to manage the scaling and drawing of ticks and labels. axis.

h3. Validation test

* create some partition dimensions bar plot, specificities bar plot ("Draw bars" preference) and specificities line chart ("Draw curve" preference)
* see the behavior when zooming in, zooming out and panning
* see the behavior when resizing the editor/tab
* try on some large charts too because the new behavior hides some X axis labels to always make them readable