< prev index next >

modules/web/src/main/java/com/sun/java/scene/web/WebViewHelper.java

Print this page




   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  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.java.scene.web;
  27 



  28 import com.sun.javafx.scene.ParentHelper;

  29 import com.sun.javafx.sg.prism.NGNode;
  30 import com.sun.javafx.util.Utils;
  31 import javafx.scene.web.WebView;
  32 import javafx.scene.Node;
  33 
  34 /**
  35  * Used to access internal methods of WebView.
  36  */
  37 public class WebViewHelper extends ParentHelper {
  38 
  39     private static final WebViewHelper theInstance;
  40     private static WebViewAccessor webViewAccessor;
  41 
  42     static {
  43         theInstance = new WebViewHelper();
  44         Utils.forceInit(WebView.class);
  45     }
  46 
  47     private static WebViewHelper getInstance() {
  48         return theInstance;
  49     }
  50 
  51     public static void initHelper(WebView webView) {
  52         setHelper(webView, getInstance());
  53     }
  54 
  55     @Override
  56     protected NGNode createPeerImpl(Node node) {
  57         return webViewAccessor.doCreatePeer(node);
  58     }
  59 
  60     @Override
  61     protected void updatePeerImpl(Node node) {
  62         super.updatePeerImpl(node);
  63         webViewAccessor.doUpdatePeer(node);
  64     }
  65 






















  66     public static void setWebViewAccessor(final WebViewAccessor newAccessor) {
  67         if (webViewAccessor != null) {
  68             throw new IllegalStateException();
  69         }
  70 
  71         webViewAccessor = newAccessor;
  72     }
  73 
  74     public interface WebViewAccessor {
  75         NGNode doCreatePeer(Node node);
  76         void doUpdatePeer(Node node);




  77     }
  78 
  79 }


   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  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.java.scene.web;
  27 
  28 import com.sun.javafx.geom.BaseBounds;
  29 import com.sun.javafx.geom.PickRay;
  30 import com.sun.javafx.geom.transform.BaseTransform;
  31 import com.sun.javafx.scene.ParentHelper;
  32 import com.sun.javafx.scene.input.PickResultChooser;
  33 import com.sun.javafx.sg.prism.NGNode;
  34 import com.sun.javafx.util.Utils;
  35 import javafx.scene.web.WebView;
  36 import javafx.scene.Node;
  37 
  38 /**
  39  * Used to access internal methods of WebView.
  40  */
  41 public class WebViewHelper extends ParentHelper {
  42 
  43     private static final WebViewHelper theInstance;
  44     private static WebViewAccessor webViewAccessor;
  45 
  46     static {
  47         theInstance = new WebViewHelper();
  48         Utils.forceInit(WebView.class);
  49     }
  50 
  51     private static WebViewHelper getInstance() {
  52         return theInstance;
  53     }
  54 
  55     public static void initHelper(WebView webView) {
  56         setHelper(webView, getInstance());
  57     }
  58 
  59     @Override
  60     protected NGNode createPeerImpl(Node node) {
  61         return webViewAccessor.doCreatePeer(node);
  62     }
  63 
  64     @Override
  65     protected void updatePeerImpl(Node node) {
  66         super.updatePeerImpl(node);
  67         webViewAccessor.doUpdatePeer(node);
  68     }
  69 
  70     protected void transformsChangedImpl(Node node) {
  71         super.transformsChangedImpl(node);
  72         webViewAccessor.doTransformsChanged(node);
  73     }
  74 
  75     @Override
  76     protected BaseBounds computeGeomBoundsImpl(Node node, BaseBounds bounds,
  77             BaseTransform tx) {
  78         return webViewAccessor.doComputeGeomBounds(node, bounds, tx);
  79     }
  80 
  81     @Override
  82     protected boolean computeContainsImpl(Node node, double localX, double localY) {
  83         return webViewAccessor.doComputeContains(node, localX, localY);
  84     }
  85 
  86     @Override
  87     protected void pickNodeLocalImpl(Node node, PickRay localPickRay,
  88             PickResultChooser result) {
  89         webViewAccessor.doPickNodeLocal(node, localPickRay, result);
  90     }
  91 
  92     public static void setWebViewAccessor(final WebViewAccessor newAccessor) {
  93         if (webViewAccessor != null) {
  94             throw new IllegalStateException();
  95         }
  96 
  97         webViewAccessor = newAccessor;
  98     }
  99 
 100     public interface WebViewAccessor {
 101         NGNode doCreatePeer(Node node);
 102         void doUpdatePeer(Node node);
 103         void doTransformsChanged(Node node);
 104         BaseBounds doComputeGeomBounds(Node node, BaseBounds bounds, BaseTransform tx);
 105         boolean doComputeContains(Node node, double localX, double localY);
 106         void doPickNodeLocal(Node node, PickRay localPickRay, PickResultChooser result);
 107     }
 108 
 109 }
< prev index next >