changeset 4282:691071d37f9d

Fix for RT-26135: Node Orientation - Combo drop down clipped
author Lubomir Nerad <lubomir.nerad@oracle.com>
date Fri, 12 Jul 2013 14:51:13 +0200
parents 1297b31c4bec
children dea00f4f6753
files modules/graphics/src/main/java/javafx/scene/Node.java modules/graphics/src/stub/java/javafx/scene/NodeTest.java
diffstat 2 files changed, 35 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/javafx/scene/Node.java	Fri Jul 12 14:51:23 2013 +0400
+++ b/modules/graphics/src/main/java/javafx/scene/Node.java	Fri Jul 12 14:51:13 2013 +0200
@@ -4392,6 +4392,26 @@
     void updateLocalToParentTransform() {
         if (transformDirty) {
             localToParentTx.setToIdentity();
+
+            boolean mirror = false;
+            double mirroringCenter = 0;
+            if (hasMirroring()) {
+                final Scene sceneValue = getScene();
+                if ((sceneValue != null) && (sceneValue.getRoot() == this)) {
+                    // handle scene mirroring in this branch
+                    // (must be the last transformation)
+                    mirroringCenter = sceneValue.getWidth() / 2;
+
+                    localToParentTx.translate(mirroringCenter, 0, 0);
+                    localToParentTx.scale(-1, 1);
+                    localToParentTx.translate(-mirroringCenter, 0, 0);
+                } else {
+                    // mirror later
+                    mirror = true;
+                    mirroringCenter = impl_getPivotX();
+                }
+            }
+
             if (getScaleX() != 1 || getScaleY() != 1 || getScaleZ() != 1 || getRotate() != 0) {
                 // recompute pivotX, pivotY and pivotZ
                 double pivotX = impl_getPivotX();
@@ -4412,24 +4432,16 @@
             }
 
             // Check to see whether the node requires mirroring
-            if (hasMirroring()) {
-                final double xOffset = getMirroringCenter();
-                localToParentTx.translate(xOffset, 0, 0);
+            if (mirror) {
+                localToParentTx.translate(mirroringCenter, 0, 0);
                 localToParentTx.scale(-1, 1);
-                localToParentTx.translate(-xOffset, 0, 0);
+                localToParentTx.translate(-mirroringCenter, 0, 0);
             }
 
             transformDirty = false;
         }
     }
 
-    private double getMirroringCenter() {
-        final Scene sceneValue = getScene();
-        return ((sceneValue != null) && (sceneValue.getRoot() == this))
-                   ? sceneValue.getWidth() / 2
-                   : impl_getPivotX();
-    }
-
     /**
      * Transforms in place the specified point from parent coords to local
      * coords. Made package private for the sake of testing.
--- a/modules/graphics/src/stub/java/javafx/scene/NodeTest.java	Fri Jul 12 14:51:23 2013 +0400
+++ b/modules/graphics/src/stub/java/javafx/scene/NodeTest.java	Fri Jul 12 14:51:13 2013 +0200
@@ -35,6 +35,7 @@
 import javafx.beans.property.*;
 import javafx.geometry.BoundingBox;
 import javafx.geometry.Bounds;
+import javafx.geometry.NodeOrientation;
 import javafx.geometry.Point2D;
 import javafx.geometry.Point3D;
 import javafx.scene.effect.DropShadow;
@@ -1273,4 +1274,15 @@
         assertNull(rect.screenToLocal(new Point2D(111, 222)));
         assertNull(rect.screenToLocal(new BoundingBox(111, 222, 3, 4)));
     }
+
+    @Test
+    public void testRootMirroringWithTranslate() {
+        final Group rootGroup = new Group();
+        rootGroup.setTranslateX(20);
+        rootGroup.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT);
+        final Scene scene = new Scene(rootGroup, 200, 200);
+
+        final Point2D trPoint = scene.getRoot().localToScene(0, 0);
+        assertEquals(180, trPoint.getX(), 0.1);
+    }
 }