changeset 2196:76c97d9afe5a

RT-27533: node's x pivot used for mirror translation is wrong
author Felipe Heidrich <felipe.heidrich@oracle.com>
date Mon, 14 Jan 2013 09:31:21 -0800
parents d5fa47c76cbb
children 7411d3b17dcb
files javafx-ui-common/src/javafx/scene/text/Text.java
diffstat 1 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-common/src/javafx/scene/text/Text.java	Fri Jan 11 09:03:56 2013 -0800
+++ b/javafx-ui-common/src/javafx/scene/text/Text.java	Mon Jan 14 09:31:21 2013 -0800
@@ -1159,7 +1159,6 @@
             if (impl_mode != Mode.FILL && getStrokeType() != StrokeType.INSIDE) {
                 return super.impl_computeGeomBounds(bounds, tx);
             }
-
             TextLayout layout = getTextLayout();
             bounds = layout.getBounds(getTextSpan(), bounds);
             BaseBounds spanBounds = getSpanBounds();
@@ -1187,7 +1186,20 @@
         float width = textBounds.getWidth();
         float height = textBounds.getHeight();
         float wrappingWidth = (float)getWrappingWidth();
-        if (wrappingWidth > width) width = wrappingWidth;
+        if (wrappingWidth > width) {
+            width = wrappingWidth;
+        } else {
+            /* The following adjustment is necessary for the text bounds to be
+             * relative to the same location as the mirrored bounds returned
+             * by layout.getBounds().
+             */
+            if (wrappingWidth > 0) {
+                NodeOrientation orientation = getEffectiveNodeOrientation();
+                if (orientation == NodeOrientation.RIGHT_TO_LEFT) {
+                    x -= width - wrappingWidth;
+                }
+            }
+        }
         textBounds = new RectBounds(x, y, x + width, y + height);
 
         /* handle stroked text */