Assign custom keys to zooming/panning

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
bruedge
Posts: 5
Joined: Wed Mar 05, 2014 1:29 pm
antibot: No, of course not.

Assign custom keys to zooming/panning

Post by bruedge » Wed Mar 12, 2014 11:33 am

Hello,

like the person in this thread:
viewtopic.php?f=3&t=116797&p=177379&hil ... an#p177379
I would like to change the keys which trigger certain actions. For example, panning should simply work by dragging with the left mouse button, and the "zoom by selecting" just by hitting the right mouse button.
However, in ChartPanel, panMask cannot be accessed, which seems to make it impossible for me to change this mask or the key trigger for panning in general.
Why isn't panMask protected or at least provides a protected setter? Then derived classes had a way to change this behavior.

I also don't understand why the logic for zooming in ChartPanel -> mouseClicked/mouseDragged/mouseReleased does not look for some mask as well, so that one could change the keys that trigger that zooming. It can be turned off, but I just want it to happen only on right click.
I can f.e. override mouseReleased like this:

Code: Select all

boolean rightMouseClick = SwingUtilities.isRightMouseButton(e);
    boolean domainZoomable = isDomainZoomable();
    boolean rangeZoomable = isRangeZoomable();
    if(!rightMouseClick)
    {
      setMouseZoomable(false);
    }
    super.mouseReleased(e);
    if(!rightMouseClick)
    {
      setDomainZoomable(domainZoomable);
      setRangeZoomable(rangeZoomable);
    }
Basically turning off zoomable while calling the super method. But this obviously doesn't feel like a clean way to do this.

Any suggestions for this problem?

Best regards,
Daniel

bruedge
Posts: 5
Joined: Wed Mar 05, 2014 1:29 pm
antibot: No, of course not.

Re: Assign custom keys to zooming/panning

Post by bruedge » Mon Mar 17, 2014 3:19 pm

Is there any consideration of applying the points I spoke about in the next library version? Should I file a "bug report" (if that's possible)? The inability to assign alternative keys to these actions basically prohibits our company from using this library.

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

Re: Assign custom keys to zooming/panning

Post by david.gilbert » Mon Mar 17, 2014 7:14 pm

bruedge wrote:Is there any consideration of applying the points I spoke about in the next library version?
It won't be resolved in JFreeChart 1.0.18. But you should check out the code in the JFreeChart-FSE repo at GitHub because this version of JFreeChart includes my attempt (from a few years back) to solve this issue:

https://github.com/jfree/jfreechart-fse

I plan to clean up this code and release it as JFreeChart 2, starting with some pre-release versions so that there is some opportunity to deal with API mistakes before JFreeChart 2.0 is officially released. I can't put a timetable on that, unfortunately, because I have to give priority to work-that-pays-the-bills.
bruedge wrote:The inability to assign alternative keys to these actions basically prohibits our company from using this library.
That's a problem, but probably more for you than for me. You have 100% of the source code, so you are in just as good a position as me to fix the problem, perhaps even a better position because your company is paying you.
David Gilbert
JFreeChart Project Leader

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

bruedge
Posts: 5
Joined: Wed Mar 05, 2014 1:29 pm
antibot: No, of course not.

Re: Assign custom keys to zooming/panning

Post by bruedge » Tue Mar 18, 2014 10:05 am

david.gilbert wrote:
bruedge wrote:The inability to assign alternative keys to these actions basically prohibits our company from using this library.
That's a problem, but probably more for you than for me. You have 100% of the source code, so you are in just as good a position as me to fix the problem, perhaps even a better position because your company is paying you.
I wasn't quite aware that I am allowed to change a library licensed under the LGPL and then use it in commercial software. I then have to release this new version under the LGPL again, is that correct? I might take a look at how this has to be done.

Locked