Mouse Event Handling

A discussion forum for FXGraphics2D (adds a Java2D API to the JavaFX Canvas).

Mouse Event Handling

Postby yaun » Fri Jun 17, 2016 12:30 pm

When using JFreeChart with a ChartPanel I was able to register a ChartMouseListener. The listener's event provided information about which point in the chart was clicked. With FXGraphics2D I can use the generic setOnMouseClicked of the JavaFx Canvas to register a mouse event handler but the only information I get in the event is the coordinate within the canvas. How can I convert this to the information which point in the dataset was clicked, or is there any other recommended way of doing this?

Thanks
Timm
yaun
 
Posts: 4
Joined: Fri Jun 17, 2016 12:17 pm

Re: Mouse Event Handling

Postby yaun » Fri Jun 17, 2016 1:00 pm

Sorry, I started from the jfreechart example provided FxGraphics2D which was using a simple canvas. Now I discovered that there actually is a ChartCanvas which seems to provide the functionality I was looking for: https://github.com/jfree/jfreechart/tre ... e/chart/fx.

Where do I get the org/jfree/chart/fx part of the distribution? It is not in the maven artifact 'org.jfree:jfreechart:1.0.19' nor in the jfreechart-1.0.19.jar downloaded from the site. Is this not yet build into the release and needs to be taken directly from the source repository?
yaun
 
Posts: 4
Joined: Fri Jun 17, 2016 12:17 pm

Re: Mouse Event Handling

Postby yaun » Fri Jun 17, 2016 3:28 pm

To answer myself here: Use maven to build your own jfreechart.jar with javafx support. Then just use ChartCanvas as a replacement for ChartPanel
yaun
 
Posts: 4
Joined: Fri Jun 17, 2016 12:17 pm

Re: Mouse Event Handling

Postby david.gilbert » Fri Jun 17, 2016 9:57 pm

Glad you found the ChartCanvas class. The JavaFX support is missing from the 1.0.19 build because we're still supporting Java 1.6 and that doesn't include JavaFX. If you want the JavaFX support, there is a build script you can run under JDK 1.8. I would like to get two new JFreeChart releases done, one without JavaFX (v 1.0.20) and one with (v 1.5.0). I have been working on it, but struggling to find enough time.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Ask your company to buy the JFreeChart Developer Guide
:idea: Check out other products sold by my company Object Refinery Limited
david.gilbert
JFreeChart Project Leader
 
Posts: 11652
Joined: Fri Mar 14, 2003 10:29 am


Return to FXGraphics2D

Who is online

Users browsing this forum: No registered users and 1 guest