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.javafx.scene; 27 28 import com.sun.javafx.sg.prism.NGNode; 29 import com.sun.javafx.util.Utils; 30 import javafx.scene.Camera; 31 import javafx.scene.Node; 32 import javafx.scene.SubScene; 33 34 /** 35 * Used to access internal methods of SubScene. 36 */ 37 public class SubSceneHelper extends NodeHelper { 38 39 private static final SubSceneHelper theInstance; 40 private static SubSceneAccessor subSceneAccessor; 41 42 static { 43 theInstance = new SubSceneHelper(); 44 Utils.forceInit(SubScene.class); 45 } 46 47 private static SubSceneHelper getInstance() { 48 return theInstance; 49 } 50 51 public static void initHelper(SubScene subScene) { 52 setHelper(subScene, getInstance()); 53 } 54 55 @Override 56 protected NGNode createPeerImpl(Node node) { 57 return subSceneAccessor.doCreatePeer(node); 58 } 59 60 @Override 61 protected void updatePeerImpl(Node node) { 62 super.updatePeerImpl(node); 63 subSceneAccessor.doUpdatePeer(node); 64 } 65 66 public static boolean isDepthBuffer(SubScene subScene) { 67 return subSceneAccessor.isDepthBuffer(subScene); 68 } 69 70 public static Camera getEffectiveCamera(SubScene subScene) { 71 return subSceneAccessor.getEffectiveCamera(subScene); 72 } 73 74 public static void setSubSceneAccessor(final SubSceneAccessor newAccessor) { 75 if (subSceneAccessor != null) { 76 throw new IllegalStateException(); 77 } 78 79 subSceneAccessor = newAccessor; 80 } 81 82 public interface SubSceneAccessor { 83 NGNode doCreatePeer(Node node); 84 void doUpdatePeer(Node node); 85 boolean isDepthBuffer(SubScene subScene); 86 Camera getEffectiveCamera(SubScene subScene); 87 } 88 89 } | 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.javafx.scene; 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.jmx.MXNodeAlgorithm; 32 import com.sun.javafx.jmx.MXNodeAlgorithmContext; 33 import com.sun.javafx.scene.input.PickResultChooser; 34 import com.sun.javafx.sg.prism.NGNode; 35 import com.sun.javafx.util.Utils; 36 import javafx.scene.Camera; 37 import javafx.scene.Node; 38 import javafx.scene.SubScene; 39 40 /** 41 * Used to access internal methods of SubScene. 42 */ 43 public class SubSceneHelper extends NodeHelper { 44 45 private static final SubSceneHelper theInstance; 46 private static SubSceneAccessor subSceneAccessor; 47 48 static { 49 theInstance = new SubSceneHelper(); 50 Utils.forceInit(SubScene.class); 51 } 52 53 private static SubSceneHelper getInstance() { 54 return theInstance; 55 } 56 57 public static void initHelper(SubScene subScene) { 58 setHelper(subScene, getInstance()); 59 } 60 61 public static void superProcessCSS(Node node) { 62 ((SubSceneHelper) getHelper(node)).superProcessCSSImpl(node); 63 } 64 65 @Override 66 protected NGNode createPeerImpl(Node node) { 67 return subSceneAccessor.doCreatePeer(node); 68 } 69 70 @Override 71 protected void updatePeerImpl(Node node) { 72 super.updatePeerImpl(node); 73 subSceneAccessor.doUpdatePeer(node); 74 } 75 76 @Override 77 protected BaseBounds computeGeomBoundsImpl(Node node, BaseBounds bounds, 78 BaseTransform tx) { 79 return subSceneAccessor.doComputeGeomBounds(node, bounds, tx); 80 } 81 82 @Override 83 protected boolean computeContainsImpl(Node node, double localX, double localY) { 84 return subSceneAccessor.doComputeContains(node, localX, localY); 85 } 86 87 void superProcessCSSImpl(Node node) { 88 super.processCSSImpl(node); 89 } 90 91 protected void processCSSImpl(Node node) { 92 subSceneAccessor.doProcessCSS(node); 93 } 94 95 @Override 96 protected Object processMXNodeImpl(Node node, MXNodeAlgorithm alg, MXNodeAlgorithmContext ctx) { 97 return subSceneAccessor.doProcessMXNode(node, alg, ctx); 98 } 99 100 @Override 101 protected void pickNodeLocalImpl(Node node, PickRay localPickRay, 102 PickResultChooser result) { 103 subSceneAccessor.doPickNodeLocal(node, localPickRay, result); 104 } 105 106 public static boolean isDepthBuffer(SubScene subScene) { 107 return subSceneAccessor.isDepthBuffer(subScene); 108 } 109 110 public static Camera getEffectiveCamera(SubScene subScene) { 111 return subSceneAccessor.getEffectiveCamera(subScene); 112 } 113 114 public static void setSubSceneAccessor(final SubSceneAccessor newAccessor) { 115 if (subSceneAccessor != null) { 116 throw new IllegalStateException(); 117 } 118 119 subSceneAccessor = newAccessor; 120 } 121 122 public interface SubSceneAccessor { 123 NGNode doCreatePeer(Node node); 124 void doUpdatePeer(Node node); 125 BaseBounds doComputeGeomBounds(Node node, BaseBounds bounds, BaseTransform tx); 126 boolean doComputeContains(Node node, double localX, double localY); 127 void doProcessCSS(Node node); 128 Object doProcessMXNode(Node node, MXNodeAlgorithm alg, MXNodeAlgorithmContext ctx); 129 void doPickNodeLocal(Node node, PickRay localPickRay, 130 PickResultChooser result); 131 boolean isDepthBuffer(SubScene subScene); 132 Camera getEffectiveCamera(SubScene subScene); 133 } 134 135 } |