Hi Vincent,
"V. de Weger" <[EMAIL PROTECTED]> wrote on 08/23/2006 05:52:57 AM:
> My aim is however to prevent the resize completely, because it's a wast
of
> time to do the rendering twice ( .. isn't it ??). Is there a way to have
> batik wait for that, or should I take care of that in Swing?
Well, as I understand it this is very hard to avoid completely.
You would have to assume that the resize will take place and I'm
not sure that is a safe assumption.
> Thomas, that's true. The rendering is scheduled again, but when there is
a
> resize in the second run it looks as if it always goes into failed,
i.s.o.
> cancelled.
> I'm trying to understand the rescheduling: in AbstractJGVTComponent I
see a
> listener for a component resize that reschedules the rendering, however
it
> checks for updateRenderingTransform() which always returns false. Am I
> missing something??
Ahhh, I think I see the problem. In the resize handler it avoids
scheduling a new gvtRendering if the result would be the same rendering
as it already had. Except in this case it doesn't have any good rendering
so it really needs to do the rendering...
I think the core of the problem is the handling of 'oldD'. Can you
try replacing the JSVGComponent.updateRenderingTransform function:
protected boolean updateRenderingTransform() {
if ((svgDocument == null) || (gvtRoot == null))
return false;
try {
SVGSVGElement elt = svgDocument.getRootElement();
Dimension d = getSize();
Dimension oldD = prevComponentSize;
prevComponentSize = d;
if (d.width < 1) d.width = 1;
if (d.height < 1) d.height = 1;
final AffineTransform at = calculateViewingTransform
(fragmentIdentifier, elt);
AffineTransform vt = getViewingTransform();
if (at.equals(vt)) {
// No new transform
// Only repaint if size really changed.
return ((oldD == null) ||
(oldD.width != d.width) || (oldD.height !=
d.height));
}
if (!recenterOnResize)
return true;
if (oldD == null) oldD = d;
// Here we map the old center of the component down to
// the user coodinate system with the old viewing
// transform and then back to the screen with the
// new viewing transform. We then adjust the rendering
// transform so it lands in the same place.
Point2D pt = new Point2D.Float(oldD.width/2.0f,
oldD.height/2.0f);
AffineTransform rendAT = getRenderingTransform();
if (rendAT != null) {
try {
AffineTransform invRendAT = rendAT.createInverse();
pt = invRendAT.transform(pt, null);
} catch (NoninvertibleTransformException e) { }
}
if (vt != null) {
try {
AffineTransform invVT = vt.createInverse();
pt = invVT.transform(pt, null);
} catch (NoninvertibleTransformException e) { }
}
if (at != null)
pt = at.transform(pt, null);
if (rendAT != null)
pt = rendAT.transform(pt, null);
// Now figure out how far we need to shift things
// to get the center point to line up again.
float dx = (float)((d.width/2.0f) -pt.getX());
float dy = (float)((d.height/2.0f)-pt.getY());
// Round the values to nearest integer.
dx = (int)((dx < 0)?(dx - .5):(dx + .5));
dy = (int)((dy < 0)?(dy - .5):(dy + .5));
if ((dx != 0) || (dy != 0)) {
rendAT.preConcatenate
(AffineTransform.getTranslateInstance(dx, dy));
setRenderingTransform(rendAT, false);
}
synchronized (this) {
viewingTransform = at;
}
Runnable r = new Runnable() {
AffineTransform myAT = at;
CanvasGraphicsNode myCGN = getCanvasGraphicsNode();
public void run() {
synchronized (JSVGComponent.this) {
myCGN.setViewingTransform(myAT);
if (viewingTransform == myAT)
viewingTransform = null;
}
}
};
UpdateManager um = getUpdateManager();
if (um != null) um.getUpdateRunnableQueue().invokeLater(r);
else r.run();
} catch (BridgeException e) {
userAgent.displayError(e);
}
return true;
}
>
> Vincent
>
>
>
> >
> > This shouldn't really be a problem because it should queue another
> > render request. Is that not happening for some reason?
> >
> >
> >
>
> --
> View this message in context:
http://www.nabble.com/how-to-handle-resize-
> tf2129806.html#a5941300
> Sent from the Batik - Users forum at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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]