Ok, now this version uses PaintingTransform, so it is much faster (but ugly)
and looks like the actions by the default interactors. (this version uses
ctrl-key + mousewheel to zoom)
----------------------------------------------------------
public void mouseWheelMoved(MouseWheelEvent e) {
finished = false;
JGVTComponent c = (JGVTComponent)e.getSource();
c.requestFocus();
xStart = e.getX();
yStart = e.getY();
double s;
if (e.getWheelRotation() < 0) {
s = 1.25;
}
else {
s = 0.8;
}
AffineTransform ot;
double tx = -xStart * (s - 1.0);
double ty = -yStart * (s - 1.0);
if(c.getPaintingTransform() != null) {
ot = c.getPaintingTransform();
AffineTransform st = AffineTransform.getTranslateInstance(tx,
ty);
AffineTransform at = AffineTransform.getScaleInstance(s,s);
ot.preConcatenate(at);
ot.preConcatenate(st);
}
else {
ot = AffineTransform.getTranslateInstance(tx, ty);
ot.scale(s, s);
}
c.setPaintingTransform(ot);
}
public void keyReleased(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_CONTROL) {
finished = true;
JGVTComponent c = (JGVTComponent)e.getSource();
AffineTransform pt = c.getPaintingTransform();
if (pt != null) {
AffineTransform rt =
(AffineTransform)c.getRenderingTransform().clone();
rt.preConcatenate(pt);
c.setRenderingTransform(rt);
}
}
}
--------------------------------------------------------
iphar wrote:
>
> I thought this code is maybe a little bit faster - but still not optimal.
> The problem in both versions is certainly that there is a call to
> setRenderingTransform() all the time instead of setPaintingTransform()
> like in the default interactors.
>
--
View this message in context:
http://www.nabble.com/Zoom-on-mouse-wheel-tp18171181p23538815.html
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]