changeset 2193:587643f3fc09

RT-27479: Remove impl_* methods for RenderToImage and BufferedImage conversion
author kcr
date Thu, 10 Jan 2013 14:50:03 -0800
parents 1743ebb8a2b4
children 0690808f8133
files javafx-ui-common/src/javafx/scene/Scene.java javafx-ui-common/src/javafx/scene/image/Image.java javafx-ui-common/test/unit/javafx/scene/image/ImageTest.java
diffstat 3 files changed, 4 insertions(+), 170 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-common/src/javafx/scene/Scene.java	Thu Jan 10 13:10:31 2013 -0800
+++ b/javafx-ui-common/src/javafx/scene/Scene.java	Thu Jan 10 14:50:03 2013 -0800
@@ -92,7 +92,6 @@
 import com.sun.javafx.cursor.CursorFrame;
 import com.sun.javafx.event.EventQueue;
 import com.sun.javafx.geom.PickRay;
-import com.sun.javafx.geom.transform.Affine2D;
 import com.sun.javafx.geom.transform.BaseTransform;
 import sun.util.logging.PlatformLogger;
 import com.sun.javafx.perf.PerformanceTracker;
@@ -325,7 +324,7 @@
                     return parent.getChildren(); //was impl_getChildren
                 }
                 public Object renderToImage(Scene scene, Object platformImage) {
-                    return scene.renderToImage(platformImage);
+                    return scene.snapshot(null).impl_getPlatformImage();
                 }
             });
             Toolkit.setSceneAccessor(new Toolkit.SceneAccessor() {
@@ -1029,51 +1028,6 @@
         return root;
     }
 
-    /**
-     * This method is superseded by {@link #snapshot(javafx.scene.image.WritableImage)}
-     *
-     * WARNING: This method is not part of the public API and is
-     * subject to change!  It is intended for use by the designer tool only.
-     *
-     * @treatAsPrivate implementation detail
-     * @deprecated This is an internal API that is not intended for use and will be removed in the next version
-     */
-    // SB-dependency: RT-21222 has been filed to track this
-    // TODO: need to ensure that both SceneBuilder and JDevloper have migrated
-    // to new 2.2 public API before we remove this.
-    @Deprecated
-    public Object renderToImage(Object platformImage) {
-        return renderToImage(platformImage, 1.0f);
-    }
-
-    /**
-     * Renders this {@code Scene} to the given platform-specific image
-     * (e.g. a {@code BufferedImage} in the case of the Swing profile)
-     * using the specified scaling factor.
-     * If {@code platformImage} is null, a new platform-specific image
-     * is returned.
-     * If the contents of the scene have not changed since the last time
-     * this method was called, this method returns null.
-     *
-     * WARNING: This method is not part of the public API and is
-     * subject to change!  It is intended for use by the designer tool only.
-     *
-     * @treatAsPrivate implementation detail
-     * @deprecated This is an internal API that is not intended for use and will be removed in the next version
-     */
-    @Deprecated
-    public Object renderToImage(Object platformImage, float scale) {
-        if (!paused) {
-            Toolkit.getToolkit().checkFxUserThread();
-        }
-
-        // NOTE: that we no longer use the passed in platform image. Since this
-        // API is deprecated and will be removed in 3.0 this is not a concern.
-        // Also, we used to return a TK image loader and now we return
-        // the actual TK PlatformImage.
-        return doSnapshot(null, scale).impl_getPlatformImage();
-    }
-
     private void doLayoutPassWithoutPulse(int maxAttempts) {
         for (int i = 0; dirtyLayoutRoots.size() > 0 && i != maxAttempts; ++i) {
             layoutDirtyRoots();
@@ -1165,7 +1119,7 @@
     /**
      * Implementation method for snapshot
      */
-    private WritableImage doSnapshot(WritableImage img, float scale) {
+    private WritableImage doSnapshot(WritableImage img) {
         // TODO: no need to do CSS, layout or sync in the deferred case,
         // if this scene is attached to a visible stage
         doCSSLayoutSyncForSnapshot(getRoot());
@@ -1173,13 +1127,6 @@
         double w = getWidth();
         double h = getHeight();
         BaseTransform transform = BaseTransform.IDENTITY_TRANSFORM;
-        if (scale != 1.0f) {
-            Affine2D tx = new Affine2D();
-            tx.scale(scale, scale);
-            transform = tx;
-            w *= scale;
-            h *= scale;
-        }
 
         return doSnapshot(this, 0, 0, w, h,
                 getRoot(), transform, isDepthBuffer(),
@@ -1268,7 +1215,7 @@
             Toolkit.getToolkit().checkFxUserThread();
         }
 
-        return  doSnapshot(image, 1.0f);
+        return doSnapshot(image);
     }
 
     /**
@@ -1330,7 +1277,7 @@
         // any of them have been rendered.
         final Runnable snapshotRunnable = new Runnable() {
             @Override public void run() {
-                WritableImage img = doSnapshot(theImage, 1.0f);
+                WritableImage img = doSnapshot(theImage);
 //                System.err.println("Calling snapshot callback");
                 SnapshotResult result = new SnapshotResult(img, Scene.this, null);
                 try {
--- a/javafx-ui-common/src/javafx/scene/image/Image.java	Thu Jan 10 13:10:31 2013 -0800
+++ b/javafx-ui-common/src/javafx/scene/image/Image.java	Thu Jan 10 14:50:03 2013 -0800
@@ -1018,57 +1018,6 @@
     }
 
     /**
-     * This method converts a JavaFX Image to the specified image class or
-     * to an image of the same class and the same format as specified image.
-     * If the specified image class is not supported, then null will be returned.
-     *
-     * @param imgType either a Class object that specifies the type of image,
-     *      or an actual image object of the desired type and format.
-     * @treatAsPrivate implementation detail
-     * @deprecated This is an internal API that is not intended for use and will be removed in the next version
-     */
-    // SB-dependency: ?????
-    // TODO: need to ensure that both SceneBuilder and JDevloper have migrated
-    // to new 2.2 public API before we remove this.
-    @Deprecated
-    public Object impl_toExternalImage(Object imgType) {
-        return Toolkit.getToolkit().toExternalImage(impl_getPlatformImage(), imgType);
-    }
-
-    /**
-     * This method converts the specified image to a JavaFX Image.
-     * If the specified image class is not supported, then null will be returned.
-     *
-     * @param extImage - an image to convert.
-     * @treatAsPrivate implementation detail
-     * @deprecated This is an internal API that is not intended for use and will be removed in the next version
-     */
-    // SB-dependency: ?????
-    // TODO: need to ensure that both SceneBuilder and JDevloper have migrated
-    // to new 2.2 public API before we remove this.
-    @Deprecated
-    public static Image impl_fromExternalImage(Object extImage) {
-        return impl_isExternalFormatSupported(extImage.getClass())
-                ? new Image(extImage)
-                : null;
-    }
-
-    /**
-     * This method indicates whether conversion to/from the specified external
-     * format is possible.
-     *
-     * @treatAsPrivate implementation detail
-     * @deprecated This is an internal API that is not intended for use and will be removed in the next version
-     */
-    // SB-dependency: ?????
-    // TODO: need to ensure that both SceneBuilder and JDevloper have migrated
-    // to new 2.2 public API before we remove this.
-    @Deprecated
-    public static boolean impl_isExternalFormatSupported(Class format) {
-        return Toolkit.getToolkit().isExternalFormatSupported(format);
-    }
-
-    /**
      * Indicates whether image is animated.
      */
     boolean isAnimation() {
--- a/javafx-ui-common/test/unit/javafx/scene/image/ImageTest.java	Thu Jan 10 13:10:31 2013 -0800
+++ b/javafx-ui-common/test/unit/javafx/scene/image/ImageTest.java	Thu Jan 10 14:50:03 2013 -0800
@@ -447,68 +447,6 @@
         return lastAsyncImageLoader;
     }
 
-    // lets test following:  ;)
-    // 
-    //  public static boolean impl_isExternalFormatSupported(Class format) {
-    //    return Toolkit.getToolkit().isExternalFormatSupported(format);
-    // }
-    @Test
-    public void isExternalFormatSupportedTest() {
-        toolkit.externalFormatClass = StubToolkit.class;
-        assertFalse(Image.impl_isExternalFormatSupported(null));
-        assertTrue(Image.impl_isExternalFormatSupported(StubToolkit.class));
-        toolkit.externalFormatClass = ImageTest.class;
-        assertFalse(Image.impl_isExternalFormatSupported(StubToolkit.class));
-        assertTrue(Image.impl_isExternalFormatSupported(ImageTest.class));
-    }
-
-    // lets test 
-    //    public Object impl_toExternalImage(Object imgType) {
-    //        return Toolkit.getToolkit().toExternalImage(getPlatformImage(), imgType);
-    //    }
-    @Test
-    public void impl_toExternalImageTest() {
-        final Object fakePlatformImage = "fakePlatformImage";
-        registerImage(fakePlatformImage, 200, 500);
-        final Image image = Image.impl_fromPlatformImage(fakePlatformImage);
-
-        StubPlatformImage spi = (StubPlatformImage) image.impl_getPlatformImage();
-        assertTrue(spi.getSource() == fakePlatformImage);
-
-        final Object format = "image format object";
-        final Object password = "password";
-
-        toolkit.toExternalImagePassword = password;
-
-        Object extImage = image.impl_toExternalImage(format);
-        Object[] data = (Object[]) extImage;
-
-        assertTrue(
-                data.length == 3
-                && data[0] == spi
-                && data[1] == format
-                && data[2] == password);
-    }
-
-    // lets test 
-    //    public Object impl_fromExternalImage(Object image)
-    // it is more comlex
-    // we have to be sure impl_isExternalFormatSupported for image.class.
-    // and until it is not "null" returned
-    @Test
-    public void impl_fromExternalImageTest() {
-        toolkit.externalFormatClass = ImageTest.class;
-        final Object fakeExternalImage = "fakeExternalImage";
-        registerImage(fakeExternalImage, 123, 456);
-
-        assertFalse(Image.impl_isExternalFormatSupported(fakeExternalImage.getClass()));
-        assertNull(Image.impl_fromExternalImage(fakeExternalImage));
-
-        toolkit.externalFormatClass = fakeExternalImage.getClass();
-        final Image image = Image.impl_fromExternalImage(fakeExternalImage);
-        verifyLoadedImage(image, 0, 0, false, false, 123, 456);
-    }
-    
     @Test
     public void createImageFromClasspathTest() {
         final String url = "javafx/scene/image/test.png";