Some new patches around zooming and panning

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
uvoigt
Posts: 168
Joined: Mon Aug 23, 2004 10:50 am
Location: Germany

Re: Some new patches around zooming and panning

Post by uvoigt » Mon Jun 23, 2014 1:07 pm

Great!
I was offline for some days but will test the latest patch during the next days.

Edit: Did you update the patch at http://sourceforge.net/p/jfreechart/patches/309/? The last change is from May 21st.

Thanks!
Uli

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: Some new patches around zooming and panning

Post by david.gilbert » Wed Jun 25, 2014 3:53 pm

I have some catching up to do on this thread, but just to let you know this stuff looks very useful.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: Some new patches around zooming and panning

Post by paradoxoff » Wed Jun 25, 2014 9:57 pm

Hi Uli, thanks for the hint. Frankly, I do not know where the patch went.
But now it should be there.

uvoigt
Posts: 168
Joined: Mon Aug 23, 2004 10:50 am
Location: Germany

Re: Some new patches around zooming and panning

Post by uvoigt » Thu Jun 26, 2014 8:05 am

Works like a charme!! Great! Well done! :P

One minor "bug":
On some axis it is possible to start zooming with the mouse within the axis and when moving into the plot the zoom window is painted. But when releasing the mouse the axis is not zoomed. Example: CrosshairDemo2 - the left range axis works well whereas all other axis (domain and right range axis) do not zoom in such a case.

Something general:
I still wonder if the handling of axis.setGlobalPannable(..) is intuitive and useful.
Lets try to explain the function in my words:
plot.setDomainPannable(..) and plot.setRangePannable(..) define if the plot can be panned completely. All axis with isGlobalPannable()==false are not panned however.
No matter how plot.isXXPannable() and axis.isGlobalPannable().. are set: the axis is pannable all the time. It is not possible to prevent an axis from panning.
The default behaviour is: plot.isXXXPannable()==false and axis.isGlobalPannable()==true.

I support you that setGlobalPannable(..) is useful sometimes. It allows to fix one axis while it all other axis can be panned. However it is possible to pan the fixed axis on its own.
From my point of view it should still be possible to disallow panning on an axis completely.
Another downside is that it took me a long time until I understood the interaction between the different pannable flags.

Stop complaining! Here's my new idea: :-)
* plot.setXXXPannable(..) defines if the domain or range axis are pannable
* Using the new methods plot.markAxisSingularPannable(Axis) and plot.unmarkAxisSingularPannable(Axis) it is possible to define if an axis is panned when the whole plot is panned
* All axis are pannable only if the plot.isXXXPannable() flag is true

Advantages:
* All pannable settings are configured at one place (plot).
* There is one global flag (plot.isXXXPannable()) to turn panning on/off.

Maybe this is also not perfect but probably something to think about 8)

uvoigt
Posts: 168
Joined: Mon Aug 23, 2004 10:50 am
Location: Germany

Re: Some new patches around zooming and panning

Post by uvoigt » Mon Jul 21, 2014 1:01 pm

I have updated the patch.

1. Axis were not zoomed when the zoom window on the axis has one negative side although it is not the zoomed side. This was the description of my "One minor bug".
2. Removed the global pannable and zoomable handling. I think it is quite special and the implementation in version 3 of the patch caused that it was always possible to zoom and pan on the axis itself. I don't see an easy solution how to fix that. To get this patch into the freechart distribution it has to be removed from the patch.
3. Fixed some bugs regarding Combined..Plots.

I think the patch (https://sourceforge.net/p/jfreechart/patches/309/ freehchart_zoom_pan_v6.patch) is ready for commit now.
@David: Can you have a look on it? Thanks!

Uli

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: Some new patches around zooming and panning

Post by paradoxoff » Fri Jul 25, 2014 8:33 pm

Hi Uli,
just a few comments/suggestions from my side. Unfortunately, I don´t have time to try your patches.
1. Your private boolean isVerticalAxisForZooming(AxisEntity axEntity) method in the ChartPanel class can probably be omitted with some very mkinor changes to the code: give ValueAxisEntity class a public getter for the axisEdge parameter, then test whether it RectangleEdge.isLeftOrRight. If yes, it should be a vertical axis. Im not sure whether that will work for all plot classes.

2. Regarding the globalXXXable flags for the ValueAxis class: they are a must have for the charts I have to deal with, so I would definitly vote for leaving them in. I see that having a pannable ValueAxis in a non-pannable XYPlot ist not very clean (though I never found it to be confusing). What I would like to suggest: in the pan and zoom-methods of the ValueAxisEntity class, check whether the return value of getAxis().getPlot() is an instance of Zoomable or Pannable. If yes, check its orientation, calculate whether the axisEdge of the entity corresponds to the "domain" or the "range" part of the plot, and only perform the zooming if the respective part is indeed pannable or zoomable.

uvoigt
Posts: 168
Joined: Mon Aug 23, 2004 10:50 am
Location: Germany

Re: Some new patches around zooming and panning

Post by uvoigt » Sat Jul 26, 2014 11:24 am

paradoxoff wrote:Hi Uli,
just a few comments/suggestions from my side. Unfortunately, I don´t have time to try your patches.
1. Your private boolean isVerticalAxisForZooming(AxisEntity axEntity) method in the ChartPanel class can probably be omitted with some very mkinor changes to the code: give ValueAxisEntity class a public getter for the axisEdge parameter, then test whether it RectangleEdge.isLeftOrRight. If yes, it should be a vertical axis. Im not sure whether that will work for all plot classes.
That's a great hint! I don't like the isVerticalAxisForZooming method - it's a hack... I will try next week.
2. Regarding the globalXXXable flags for the ValueAxis class: they are a must have for the charts I have to deal with, so I would definitly vote for leaving them in. I see that having a pannable ValueAxis in a non-pannable XYPlot ist not very clean (though I never found it to be confusing). What I would like to suggest: in the pan and zoom-methods of the ValueAxisEntity class, check whether the return value of getAxis().getPlot() is an instance of Zoomable or Pannable. If yes, check its orientation, calculate whether the axisEdge of the entity corresponds to the "domain" or the "range" part of the plot, and only perform the zooming if the respective part is indeed pannable or zoomable.
I think you can easily include your globalXXXable flags to my patch (with the known drawbacks). I removed them to get a stable and commitable patch. After that has been included to JFreechart we can think about in all details how to include the global flags.

uvoigt
Posts: 168
Joined: Mon Aug 23, 2004 10:50 am
Location: Germany

Re: Some new patches around zooming and panning

Post by uvoigt » Tue Jul 29, 2014 9:53 am

Uploaded v7 of the patch. paradoxoffs idea to use the RectangleEdge for the detction if an axis is horizontal or vertical works and simplifies the code in ChartPanel.

The patch is now "workaround-free".

Locked