changeset 1831:526513110eba 8.0-b63

Automated merge with ssh://jpgodine@jfxsrc.us.oracle.com//javafx/8.0/MASTER/jfx/rt
author jpgodine@JPGODINE-LAP.st-users.us.oracle.com
date Tue, 30 Oct 2012 09:39:36 -0700
parents f536337e8dc5 3626aad4f2a5
children 8e85e840a981 e901aef78ced d908a2cb4614
files
diffstat 6 files changed, 139 insertions(+), 154 deletions(-) [+]
line wrap: on
line diff
--- a/apps/experiments/ConferenceScheduleApp/src/com/javafx/experiments/scheduleapp/data/JSONParserJP.java	Thu Oct 25 16:36:50 2012 -0700
+++ b/apps/experiments/ConferenceScheduleApp/src/com/javafx/experiments/scheduleapp/data/JSONParserJP.java	Tue Oct 30 09:39:36 2012 -0700
@@ -409,9 +409,8 @@
                         state = QUOTE;
                         continue;
                     case QUOTE_UNICODE:
-                        if (unicode.length() < 3) {
-                            unicode += c;
-                        } else {
+                        unicode += c;
+                        if (unicode.length() == 4) {
                             c = (char) Integer.parseInt(unicode, 16);
                             if(charBufferLength == charBuffer.length) {
                                 char[] newCharBuffer = new char[charBuffer.length*2];
--- a/javafx-ui-common/src/javafx/scene/Node.java	Thu Oct 25 16:36:50 2012 -0700
+++ b/javafx-ui-common/src/javafx/scene/Node.java	Tue Oct 30 09:39:36 2012 -0700
@@ -717,14 +717,56 @@
      *
      * @defaultValue null
      */
-    private ReadOnlyObjectWrapper<Scene> scene;
+    private ReadOnlyObjectWrapper<Scene> scene = new ReadOnlyObjectWrapper<Scene>() {
+
+        private Scene oldScene;
+
+        @Override
+        protected void invalidated() {
+            Scene _scene = get();
+            if (getClip() != null) {
+                getClip().setScene(_scene);
+            }
+            updateCanReceiveFocus();
+            if (isFocusTraversable()) {
+                if (oldScene != null) {
+                    oldScene.unregisterTraversable(Node.this);
+                }
+                if (_scene != null) {
+                    _scene.registerTraversable(Node.this);
+                }
+            }
+            focusSetDirty(oldScene);
+            focusSetDirty(_scene);
+            sceneChanged(oldScene);
+            if (oldScene != _scene) {
+                //Note: no need to remove from scene's dirty list
+                //Scene's is checking if the node's scene is correct
+                impl_reapplyCSS();
+                if (_scene != null && !impl_isDirtyEmpty()) {
+                    _scene.addToDirtyList(Node.this);
+                }
+            }
+            oldScene = _scene;
+        }
+
+        @Override
+        public Object getBean() {
+            return Node.this;
+        }
+
+        @Override
+        public String getName() {
+            return "scene";
+        }
+    };
 
     final void setScene(Scene value) {
-        scenePropertyImpl().set(value);
+        scene.set(value);
     }
 
     public final Scene getScene() {
-        return scene == null ? null : scene.get();
+        return scene.get();
     }
 
     /**
@@ -733,55 +775,7 @@
     void sceneChanged(Scene old) { }
 
     public final ReadOnlyObjectProperty<Scene> sceneProperty() {
-        return scenePropertyImpl().getReadOnlyProperty();
-    }
-
-    private ReadOnlyObjectWrapper<Scene> scenePropertyImpl() {
-        if (scene == null) {
-            scene = new ReadOnlyObjectWrapper<Scene>() {
-                private Scene oldScene;
-
-                @Override
-                protected void invalidated() {
-                    Scene _scene = get();
-                    if (getClip() != null) {
-                        getClip().setScene(_scene);
-                    }
-                    updateCanReceiveFocus();
-                    if (isFocusTraversable()) {
-                        if (oldScene != null) {
-                            oldScene.unregisterTraversable(Node.this);
-                        }
-                        if (_scene != null) {
-                            _scene.registerTraversable(Node.this);
-                        }
-                    }
-                    focusSetDirty(oldScene);
-                    focusSetDirty(_scene);
-                    sceneChanged(oldScene);
-                    if (oldScene != _scene) {
-                        //Note: no need to remove from scene's dirty list
-                        //Scene's is checking if the node's scene is correct
-                        impl_reapplyCSS();
-                        if (_scene != null && !impl_isDirtyEmpty()) {
-                            _scene.addToDirtyList(Node.this);
-                        }
-                    }
-                    oldScene = _scene;
-                }
-
-                @Override
-                public Object getBean() {
-                    return Node.this;
-                }
-
-                @Override
-                public String getName() {
-                    return "scene";
-                }
-            };
-        }
-        return scene;
+        return scene.getReadOnlyProperty();
     }
 
     /**
@@ -3186,10 +3180,17 @@
                         (float) (bounds.getMaxZ() + translateZ));
             }
             return bounds;
-        } else if (tx.is2D()) {
-            // this is a scale / rotate / skew transform
+        } else if (tx.is2D()
+                && (tx.getType()
+                & ~(BaseTransform.TYPE_UNIFORM_SCALE | BaseTransform.TYPE_TRANSLATION
+                | BaseTransform.TYPE_FLIP | BaseTransform.TYPE_QUADRANT_ROTATION)) != 0) {
+            // this is a non-uniform scale / non-quadrant rotate / skew transform
             return impl_computeGeomBounds(bounds, tx);
         } else {
+            // 3D transformations and
+            // selected 2D transformations (unifrom transform, flip, quadrant rotation).
+            // These 2D transformation will yield tight bounds when applied on the pre-computed
+            // geomBounds
             // Note: Transforming the local geomBounds into a 3D space will yield a bounds
             // that isn't as tight as transforming its geometry and compute it bounds.
             updateGeomBounds();
--- a/javafx-ui-common/src/javafx/scene/image/ImageView.java	Thu Oct 25 16:36:50 2012 -0700
+++ b/javafx-ui-common/src/javafx/scene/image/ImageView.java	Tue Oct 30 09:39:36 2012 -0700
@@ -210,6 +210,7 @@
                     }
                     if (dimensionChanged) {
                         impl_geomChanged();
+                        invalidateWidthHeight();
                     }
                     impl_markDirty(DirtyBits.NODE_CONTENTS);
                 }
@@ -286,6 +287,7 @@
         public void invalidated(Observable valueModel) {
             impl_markDirty(DirtyBits.NODE_CONTENTS);
             impl_geomChanged();
+            invalidateWidthHeight();
         }
     };
     /**
@@ -398,6 +400,7 @@
                 protected void invalidated() {
                     impl_markDirty(DirtyBits.NODE_VIEWPORT);
                     impl_geomChanged();
+                    invalidateWidthHeight();
                 }
 
                 @Override
@@ -445,6 +448,7 @@
                 protected void invalidated() {
                     impl_markDirty(DirtyBits.NODE_VIEWPORT);
                     impl_geomChanged();
+                    invalidateWidthHeight();
                 }
 
                 @Override
@@ -509,6 +513,7 @@
                 protected void invalidated() {
                     impl_markDirty(DirtyBits.NODE_VIEWPORT);
                     impl_geomChanged();
+                    invalidateWidthHeight();
                 }
 
                 @Override
@@ -612,6 +617,7 @@
                 protected void invalidated() {
                     impl_markDirty(DirtyBits.NODE_VIEWPORT);
                     impl_geomChanged();
+                    invalidateWidthHeight();
                 }
 
                 @Override
@@ -659,75 +665,63 @@
      */
     @Deprecated
     @Override public BaseBounds impl_computeGeomBounds(BaseBounds bounds, BaseTransform tx) {
+        recomputeWidthHeight();
 
-        // need to figure out the width/height to use for computing bounds
+        bounds = bounds.deriveWithNewBounds((float)getX(), (float)getY(), 0.0f,
+                (float)(getX() + destWidth), (float)(getY() + destHeight), 0.0f);
+        bounds = tx.transform(bounds, bounds);
+        return bounds;
+    }
+    
+    private boolean validWH;
+
+    private void invalidateWidthHeight() {
+        validWH = false;
+    }
+
+    private void recomputeWidthHeight() {
+        if (validWH) {
+            return;
+        }
+        Image localImage = getImage();
+        Rectangle2D localViewport = getViewport();
+
         double w = 0;
         double h = 0;
-        Image localImage = getImage();
-        if (localImage != null) {
+        if (localViewport != null && localViewport.getWidth() > 0 && localViewport.getHeight() > 0) {
+            w = localViewport.getWidth();
+            h = localViewport.getHeight();
+        } else if (localImage != null) {
             w = localImage.getWidth();
             h = localImage.getHeight();
         }
+
         double localFitWidth = getFitWidth();
         double localFitHeight = getFitHeight();
-        double newW = localFitWidth;
-        double newH = localFitHeight;
-        double vw = 0;
-        double vh = 0;
-        Rectangle2D localViewport = getViewport();
-        if (localViewport != null) {
-            vw = localViewport.getWidth();
-            vh = localViewport.getHeight();
-        }
 
-        if (vw > 0 && vh > 0) {
-            w = vw;
-            h = vh;
-        }
-
-        if (localFitWidth <= 0.0 && localFitHeight <= 0.0) {
-            newW = w;
-            newH = h;
-        } else if (isPreserveRatio()) {
-            if (localFitWidth <= 0.0) {
-                newW = (h > 0) ? w * (localFitHeight / h) : 0;
-                newH = localFitHeight;
-            } else if (localFitHeight <= 0.0) {
-                newW = localFitWidth;
-                newH = (w > 0) ? h * (localFitWidth / w) : 0;
+        if (isPreserveRatio() && w > 0 && h > 0 && (localFitWidth > 0 || localFitHeight > 0)) {
+            if (localFitWidth <= 0 || (localFitHeight > 0 && localFitWidth * h > localFitHeight * w)) {
+                w = w * localFitHeight / h;
+                h = localFitHeight;
             } else {
-                if (w == 0.0)
-                    w = localFitWidth;
-                if (h == 0.0)
-                    h = localFitHeight;
-                double scale = Math.min(localFitWidth / w, localFitHeight / h);
-                newW = w * scale;
-                newH = h * scale;
+                h = h * localFitWidth / w;
+                w = localFitWidth;
             }
-        } else if (getFitHeight() <= 0.0) {
-            newH = h;
-        } else if (getFitWidth() <= 0.0) {
-            newW = w;
-        }
-        if (newH < 1) {
-            newH = 1;
-        }
-        if (newW < 1) {
-            newW = 1;
+        } else {
+            if (localFitWidth > 0f) {
+                w = localFitWidth;
+            }
+            if (localFitHeight > 0f) {
+                h = localFitHeight;
+            }
         }
 
         // Store these values for use later in impl_computeContains() to support
         // Node.contains().
-        destWidth = newW;
-        destHeight = newH;
+        destWidth = w;
+        destHeight = h;
 
-        w = newW;
-        h = newH;
-
-        bounds = bounds.deriveWithNewBounds((float)getX(), (float)getY(), 0.0f,
-                (float)(getX() + w), (float)(getY() + h), 0.0f);
-        bounds = tx.transform(bounds, bounds);
-        return bounds;
+        validWH = true;
     }
 
     /**
@@ -739,6 +733,8 @@
         if (getImage() == null) {
             return false;
         }
+
+        recomputeWidthHeight();
         // Local Note bounds contain test is already done by the caller.
         // (Node.contains()).
 
@@ -843,19 +839,18 @@
     }
 
     void updateViewport() {
-
+        recomputeWidthHeight();
         if (getImage() == null || getImage().impl_getPlatformImage() == null) {
             return;
         }
 
         Rectangle2D localViewport = getViewport();
         if (localViewport != null) {
-            getPGImageView().setViewport((float)getFitWidth(), (float)getFitHeight(),
-                    (float)localViewport.getMinX(), (float)localViewport.getMinY(),
-                    (float)localViewport.getWidth(), (float)localViewport.getHeight(), isPreserveRatio());
+            getPGImageView().setViewport((float)localViewport.getMinX(), (float)localViewport.getMinY(),
+                    (float)localViewport.getWidth(), (float)localViewport.getHeight(),
+                    (float)destWidth, (float)destHeight);
         } else {
-            getPGImageView().setViewport((float)getFitWidth(), (float)getFitHeight(), 0, 0, 0, 0,
-                    isPreserveRatio());
+            getPGImageView().setViewport(0, 0, 0, 0, (float)destWidth, (float)destHeight);
         }
     }
 
@@ -875,11 +870,11 @@
         if (impl_isDirty(DirtyBits.NODE_SMOOTH)) {
             getPGImageView().setSmooth(isSmooth());
         }
-        if (impl_isDirty(DirtyBits.NODE_VIEWPORT)) {
-            updateViewport();
-        }
         if (impl_isDirty(DirtyBits.NODE_CONTENTS)) {
             getPGImageView().setImage(getImage()!= null? getImage().impl_getPlatformImage():null);
+        }
+        // The NG part expects this to be called when image changes
+        if (impl_isDirty(DirtyBits.NODE_VIEWPORT) || impl_isDirty(DirtyBits.NODE_CONTENTS)) {
             updateViewport();
         }
     }
--- a/javafx-ui-common/test/unit/javafx/scene/image/ImageViewTest.java	Thu Oct 25 16:36:50 2012 -0700
+++ b/javafx-ui-common/test/unit/javafx/scene/image/ImageViewTest.java	Tue Oct 30 09:39:36 2012 -0700
@@ -82,22 +82,6 @@
     }
 
     @Test
-    public void testPropertyPropagation_fitWidth() throws Exception {
-        NodeTest.testDoublePropertyPropagation(imageView, "fitWidth", 100, 200);
-    }
-
-    @Test
-    public void testPropertyPropagation_fitHeight() throws Exception {
-        NodeTest.testDoublePropertyPropagation(imageView, "fitHeight", 100, 200);
-    }
-
-    @Test
-    public void testPropertyPropagation_preserveRatio() throws Exception {
-        NodeTest.testBooleanPropertyPropagation(
-                imageView, "preserveRatio", true, false);
-    }
-
-    @Test
     public void testPropertyPropagation_image() throws Exception {
         NodeTest.testObjectPropertyPropagation(
                 imageView, "image", "image",
--- a/test-stub-toolkit/src/com/sun/javafx/pgstub/StubFilterable.java	Thu Oct 25 16:36:50 2012 -0700
+++ b/test-stub-toolkit/src/com/sun/javafx/pgstub/StubFilterable.java	Tue Oct 30 09:39:36 2012 -0700
@@ -42,6 +42,16 @@
     }
 
     @Override
+    public int getContentWidth() {
+        return image.getImageInfo().getWidth();
+    }
+
+    @Override
+    public int getContentHeight() {
+        return image.getImageInfo().getHeight();
+    }
+
+    @Override
     public int getPhysicalWidth() {
         return image.getImageInfo().getWidth();
     }
--- a/test-stub-toolkit/src/com/sun/javafx/pgstub/StubImageView.java	Thu Oct 25 16:36:50 2012 -0700
+++ b/test-stub-toolkit/src/com/sun/javafx/pgstub/StubImageView.java	Tue Oct 30 09:39:36 2012 -0700
@@ -40,10 +40,9 @@
     private float y;
     private boolean smooth;
 
-    private float fitWidth;
-    private float fitHeight;
+    private float cw;
+    private float ch;
     private Rectangle2D viewport;
-    private boolean preserveRatio;
 
     @Override
     public void setImage(Object image) {
@@ -73,13 +72,11 @@
     }
 
     @Override
-    public void setViewport(float fitWidth, float fitHeight,
-                            float vx, float vy, float vw, float vh,
-                            boolean preserveRatio) {
-        this.fitWidth = fitWidth;
-        this.fitHeight = fitHeight;
+    public void setViewport(float vx, float vy, float vw, float vh,
+                            float cw, float ch) {
         this.viewport = new Rectangle2D(vx, vy, vw, vh);
-        this.preserveRatio = preserveRatio;
+        this.cw = cw;
+        this.ch = ch;
     }
 
     @Override
@@ -89,19 +86,18 @@
 
     public boolean isSmooth() { return this.smooth; }
 
-    public float getFitWidth() {
-        return fitWidth;
-    }
-
-    public float getFitHeight() {
-        return fitHeight;
-    }
-
     public Rectangle2D getViewport() {
         return viewport;
     }
 
-    public boolean isPreserveRatio() {
-        return preserveRatio;
+    public float getContentWidth() {
+        return cw;
     }
+
+    public float getContentHeight() {
+        return ch;
+    }
+
+
+
 }