modules/graphics/src/main/java/com/sun/javafx/scene/SceneHelper.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -24,28 +24,74 @@
  */
 
 package com.sun.javafx.scene;
 
 import com.sun.glass.ui.Accessible;
+import com.sun.javafx.tk.TKPulseListener;
+import com.sun.javafx.tk.TKScene;
+import com.sun.javafx.util.Utils;
 import javafx.scene.Camera;
 import javafx.scene.Node;
 import javafx.scene.Parent;
 import javafx.scene.Scene;
+import javafx.scene.input.KeyEvent;
+import javafx.scene.input.MouseEvent;
+import javafx.stage.Window;
 
 /**
  * Used to access internal scene methods.
  */
 public final class SceneHelper {
     private static SceneAccessor sceneAccessor;
 
     static {
-        forceInit(Scene.class);
+        Utils.forceInit(Scene.class);
     }
 
     private SceneHelper() {
     }
 
+    public static void enableInputMethodEvents(Scene scene, boolean enable) {
+        sceneAccessor.enableInputMethodEvents(scene, enable);
+    }
+
+    public static void processKeyEvent(Scene scene, KeyEvent e) {
+        sceneAccessor.processKeyEvent(scene, e);
+    }
+
+    public static void processMouseEvent(Scene scene, MouseEvent e) {
+        sceneAccessor.processMouseEvent(scene, e);
+    }
+
+    public static void preferredSize(Scene scene) {
+        sceneAccessor.preferredSize(scene);
+    }
+
+    public static void disposePeer(Scene scene) {
+        sceneAccessor.disposePeer(scene);
+    }
+
+    public static void initPeer(Scene scene) {
+        sceneAccessor.initPeer(scene);
+    }
+
+    public static void setWindow(Scene scene, Window window) {
+        sceneAccessor.setWindow(scene, window);
+    }
+
+    public static TKPulseListener getScenePulseListener(Scene scene) {
+        return sceneAccessor.getScenePulseListener(scene);
+    }
+
+    public static TKScene getPeer(Scene scene) {
+        return sceneAccessor.getPeer(scene);
+    }
+
+    public static void setAllowPGAccess(boolean flag) {
+        sceneAccessor.setAllowPGAccess(flag);
+    }
+
     public static void setPaused(final boolean paused) {
         sceneAccessor.setPaused(paused);
     }
 
     public static void parentEffectiveOrientationInvalidated(

@@ -77,10 +123,30 @@
         if (sceneAccessor == null) throw new IllegalStateException();
         return sceneAccessor;
     }
 
     public interface SceneAccessor {
+        void enableInputMethodEvents(Scene scene, boolean enable);
+
+        void processKeyEvent(Scene scene, KeyEvent e);
+
+        void processMouseEvent(Scene scene, MouseEvent e);
+
+        void preferredSize(Scene scene);
+
+        void disposePeer(Scene scene);
+
+        void initPeer(Scene scene);
+
+        void setWindow(Scene scene, Window window);
+
+        TKPulseListener getScenePulseListener(Scene scene);
+
+        TKScene getPeer(Scene scene);
+
+        void setAllowPGAccess(boolean flag);
+
         void setPaused(boolean paused);
 
         void parentEffectiveOrientationInvalidated(Scene scene);
 
         Camera getEffectiveCamera(Scene scene);

@@ -90,14 +156,6 @@
         void setTransientFocusContainer(Scene scene, Node node);
 
         Accessible getAccessible(Scene scene);
     }
 
-    private static void forceInit(final Class<?> classToInit) {
-        try {
-            Class.forName(classToInit.getName(), true,
-                          classToInit.getClassLoader());
-        } catch (final ClassNotFoundException e) {
-            throw new AssertionError(e);  // Can't happen
-        }
-    }
 }