You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by de...@apache.org on 2012/05/12 19:08:55 UTC
svn commit: r1337593 -
/xmlgraphics/batik/trunk/sources/org/apache/batik/swing/svg/JSVGComponent.java
Author: deweese
Date: Sat May 12 17:08:55 2012
New Revision: 1337593
URL: http://svn.apache.org/viewvc?rev=1337593&view=rev
Log:
Even when recenterOnResize isn't set make sure to update with the new
viewing transform.
Modified:
xmlgraphics/batik/trunk/sources/org/apache/batik/swing/svg/JSVGComponent.java
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/swing/svg/JSVGComponent.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/swing/svg/JSVGComponent.java?rev=1337593&r1=1337592&r2=1337593&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/swing/svg/JSVGComponent.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/swing/svg/JSVGComponent.java Sat May 12 17:08:55 2012
@@ -999,46 +999,46 @@ public class JSVGComponent extends JGVTC
return ((oldD.width != d.width) || (oldD.height != d.height));
}
- if (!recenterOnResize)
- return true;
-
- // 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);
+ if (recenterOnResize) {
+ // 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;
}