< prev index next >

modules/web/src/main/java/com/sun/javafx/webkit/UIClientImpl.java

Print this page
rev 9717 : 8151320: Remove unnecessary addReads from JavaFX


  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.javafx.webkit;
  27 
  28 import static com.sun.glass.ui.Clipboard.DRAG_IMAGE;
  29 import static com.sun.glass.ui.Clipboard.DRAG_IMAGE_OFFSET;
  30 import static com.sun.glass.ui.Clipboard.IE_URL_SHORTCUT_FILENAME;
  31 import static javafx.scene.web.WebEvent.ALERT;
  32 import static javafx.scene.web.WebEvent.RESIZED;
  33 import static javafx.scene.web.WebEvent.STATUS_CHANGED;
  34 import static javafx.scene.web.WebEvent.VISIBILITY_CHANGED;
  35 
  36 import com.sun.javafx.tk.Toolkit;
  37 import com.sun.javafx.web.ModuleHelper;
  38 import com.sun.webkit.UIClient;
  39 import com.sun.webkit.WebPage;
  40 import com.sun.webkit.graphics.WCImage;
  41 import com.sun.webkit.graphics.WCRectangle;
  42 import java.awt.image.BufferedImage;
  43 import java.io.File;
  44 import java.io.IOException;
  45 import java.io.UnsupportedEncodingException;
  46 import java.lang.reflect.Method;
  47 import java.nio.ByteBuffer;
  48 import java.security.AccessControlContext;
  49 import java.security.AccessController;
  50 import java.security.PrivilegedAction;
  51 import java.util.Arrays;
  52 import java.util.List;
  53 import javafx.event.EventHandler;
  54 import javafx.geometry.Rectangle2D;
  55 import javafx.scene.image.Image;
  56 import javafx.scene.input.ClipboardContent;
  57 import javafx.scene.input.DataFormat;


 302         WebView view = accessor.getView();
 303         if (view != null && content != null) {
 304             //TODO: implement native support for Drag Source actions.
 305             Dragboard db = view.startDragAndDrop(TransferMode.ANY);
 306             db.setContent(content);
 307         }
 308         content = null;
 309     }
 310 
 311     @Override public boolean isDragConfirmed() {
 312         return accessor.getView() != null && content != null;
 313     }
 314 
 315     // Method to implement the following via reflection:
 316     //     SwingFXUtils.fromFXImage(img, null)
 317     public static BufferedImage toBufferedImage(Image img) {
 318         try {
 319             Class swingFXUtilsCls = Class.forName("javafx.embed.swing.SwingFXUtils");
 320             Method m_fromFXImage = swingFXUtilsCls.getMethod("fromFXImage",
 321                     Image.class, BufferedImage.class);
 322             Object thisModule = ModuleHelper.getModule(UIClientImpl.class);
 323             ModuleHelper.addReads(thisModule, ModuleHelper.getModule(swingFXUtilsCls));
 324             Object bimg = m_fromFXImage.invoke(null, img, null);
 325             return (BufferedImage)bimg;
 326         } catch (Exception ex) {
 327             ex.printStackTrace(System.err);
 328         }
 329 
 330         // return null upon any exception
 331         return null;
 332     }
 333 
 334 }


  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.javafx.webkit;
  27 
  28 import static com.sun.glass.ui.Clipboard.DRAG_IMAGE;
  29 import static com.sun.glass.ui.Clipboard.DRAG_IMAGE_OFFSET;
  30 import static com.sun.glass.ui.Clipboard.IE_URL_SHORTCUT_FILENAME;
  31 import static javafx.scene.web.WebEvent.ALERT;
  32 import static javafx.scene.web.WebEvent.RESIZED;
  33 import static javafx.scene.web.WebEvent.STATUS_CHANGED;
  34 import static javafx.scene.web.WebEvent.VISIBILITY_CHANGED;
  35 
  36 import com.sun.javafx.tk.Toolkit;

  37 import com.sun.webkit.UIClient;
  38 import com.sun.webkit.WebPage;
  39 import com.sun.webkit.graphics.WCImage;
  40 import com.sun.webkit.graphics.WCRectangle;
  41 import java.awt.image.BufferedImage;
  42 import java.io.File;
  43 import java.io.IOException;
  44 import java.io.UnsupportedEncodingException;
  45 import java.lang.reflect.Method;
  46 import java.nio.ByteBuffer;
  47 import java.security.AccessControlContext;
  48 import java.security.AccessController;
  49 import java.security.PrivilegedAction;
  50 import java.util.Arrays;
  51 import java.util.List;
  52 import javafx.event.EventHandler;
  53 import javafx.geometry.Rectangle2D;
  54 import javafx.scene.image.Image;
  55 import javafx.scene.input.ClipboardContent;
  56 import javafx.scene.input.DataFormat;


 301         WebView view = accessor.getView();
 302         if (view != null && content != null) {
 303             //TODO: implement native support for Drag Source actions.
 304             Dragboard db = view.startDragAndDrop(TransferMode.ANY);
 305             db.setContent(content);
 306         }
 307         content = null;
 308     }
 309 
 310     @Override public boolean isDragConfirmed() {
 311         return accessor.getView() != null && content != null;
 312     }
 313 
 314     // Method to implement the following via reflection:
 315     //     SwingFXUtils.fromFXImage(img, null)
 316     public static BufferedImage toBufferedImage(Image img) {
 317         try {
 318             Class swingFXUtilsCls = Class.forName("javafx.embed.swing.SwingFXUtils");
 319             Method m_fromFXImage = swingFXUtilsCls.getMethod("fromFXImage",
 320                     Image.class, BufferedImage.class);


 321             Object bimg = m_fromFXImage.invoke(null, img, null);
 322             return (BufferedImage)bimg;
 323         } catch (Exception ex) {
 324             ex.printStackTrace(System.err);
 325         }
 326 
 327         // return null upon any exception
 328         return null;
 329     }
 330 
 331 }
< prev index next >