Posted by cdouglass
on July 23, 2008 at 7:44 PM PDT
I'd like an image to zoom in/out on mouse wheel rotation (why it was called mouseWheelMoved is beyond me -- what about those wheels that also tilt? huh? they "move" without rotating...).
Anyway, back to my point.
I can bind scaleX and scaleY of the Node to the variable targetScale and then in the mouseWheelMoved() function:
targetScale -= (event.getWheelRotation() * 0.1);<br />
(and I won't even mention that I'm getting the "mouseWheelRotation" inside the "mouseWheelMoved" function. Well, ok, I did mention it, but parenthetically).
This works fine, except that it always scales around 0,0. I want it to scale around the mouse pointer.
In Java I would just translate the image, scale it, and then translate it back. How do I do that in JavaFX?
I've tried binding a couple of values to an x,y in a Transform.translate(). No difference. I tried binding a couple of values to translateX and translateY of the Node, still scales around 0,0.