Hi Manuel
Why not zooming around the mouse position?
In order to trap mousewheel events I think you should put an invisible
rectangle behind all the other elements in the scene and listen on the root
(with the capture flag set) for the event you're interested in.
Actually here I'm using SVG 1.2, so perhaps this is not possible in SVG 1.1
In the following code getElementCoords and getClientCoords (definitely these
names are not so clear) convert from OS coordinates to SVG scene
coordinates.
I hope everything is clear, and... yes I do understand that the code
could be made
much better!
Luca.
public void handleEvent(Event evt) {
MouseEvent uiEvt = (MouseEvent) evt;
SVGSVGElement root=editor.getRoot();
float scale = root.getCurrentScale();
SVGPoint sceneCoords = editor.getElementCoords(root, uiEvt
.getClientX(), uiEvt.getClientY());
if (uiEvt.getDetail() < 0) {
root.setCurrentScale(scale * 2);
} else {
root.setCurrentScale(scale / 2);
}
SVGPoint newClientCoords = editor.getClientCoords(root,
sceneCoords.getX(), sceneCoords.getY());
SVGPoint t = root.getCurrentTranslate();
t.setX(t.getX() + uiEvt.getClientX() - newClientCoords.getX());
t.setY(t.getY() + uiEvt.getClientY() - newClientCoords.getY());
}
Manuel Brnjic ha scritto:
Hello!
I wrote a simple Application, that displays me a SVG File in a
JSVGCanvas. Now i want to implement a Function for zooming in. But i
want the zoom on a button-click, that means:
1. The user types in the koordinates, for example: x1, y1, x2, y2
(instead of dragging a rect with the mouse)
2. After the user has pressed a button, it should zoom into the chosen
rect
Is this possible? I have no idea how to realize this. It would be nice
if anybody could write me a simple function with 4 parameters (x1,y2,
x2, y2) that i can implement.
MfG Manuel
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]