gillius / jfxutils

JavaFX Utilities - Zoom and Pan Charts and Pane Scaling
Apache License 2.0
68 stars 22 forks source link

JfxUtils utilization, intercept zoom event. #3

Closed Alcariin closed 9 years ago

Alcariin commented 9 years ago

Hello, I wondering myself, how it was possible to intercept the zoom utilisation (wheel mouse or by using the rectangle) because after the new layout, I need to update my labels' positions. So initially I put a listener on the yAxis upper bound, but it generates some display issues. If you have any idea?

Anyway thank you a lot for this great library.

Thomas

brcolow commented 9 years ago
rect.addListener(ScrollEvent.SCROLL, (event) -> {
    System.out.println(event);
});
Alcariin commented 9 years ago

Hi, thanks for your answer but in which file, do you pu this code? I tried in JFXChartUtil file but the ScrollEvent is undefined for the type Rectangle and I guess rect is selectRect for Rectangle.

brcolow commented 9 years ago

In ChartZoomManager.java, after line 175, try this:

handlerManager.addEventHandler(false, ScrollEvent.SCROLL, (event) -> {
    System.out.println(event);
} );
Alcariin commented 9 years ago

It works only to intercept scroll event but I use onMouseRealeased() to intercept zoom from the rectangle. My real issue was how communicate with my controller but I used a singleton and it works fine. Thanks

gillius commented 9 years ago

Is this still an issue? It seems that listening to the axis bound changes should work as this is how the zoom manager manipulates the chart. But, you'd have to listen to all of the 4 bounds to be sure that you've gotten all of the changes since it's possible to just zoom one axis or the other.