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.PickRay; 29 import com.sun.javafx.scene.input.PickResultChooser; 30 import com.sun.javafx.scene.traversal.ParentTraversalEngine; 31 import com.sun.javafx.sg.prism.NGNode; 32 import com.sun.javafx.util.Utils; 33 import javafx.scene.Node; 34 import javafx.scene.Parent; 35 36 /* 37 * Used to access internal methods of Parent. 38 * Note: ParentHelper needs to be a concrete class even though Parent is an 39 * abstract class since user is allowed to subclass Parent. 40 */ 41 public class ParentHelper extends NodeHelper { 42 43 private static final ParentHelper theInstance; 44 private static ParentAccessor parentAccessor; 45 46 static { 47 theInstance = new ParentHelper(); 48 Utils.forceInit(Parent.class); 49 } 50 51 private static ParentHelper getInstance() { 52 return theInstance; 53 } 54 55 public static void initHelper(Parent parent) { 56 setHelper(parent, getInstance()); 57 } 58 59 @Override 60 protected NGNode createPeerImpl(Node node) { 61 return parentAccessor.doCreatePeer(node); 62 } 63 64 @Override 65 protected void updatePeerImpl(Node node) { 66 super.updatePeerImpl(node); 67 parentAccessor.doUpdatePeer(node); 68 } 69 70 public static boolean pickChildrenNode(Parent parent, PickRay pickRay, 71 PickResultChooser result) { 72 return parentAccessor.pickChildrenNode(parent, pickRay, result); 73 } 74 75 public static void setTraversalEngine(Parent parent, ParentTraversalEngine value) { 76 parentAccessor.setTraversalEngine(parent, value); 77 } 78 79 public static ParentTraversalEngine getTraversalEngine(Parent parent) { 80 return parentAccessor.getTraversalEngine(parent); 81 } 82 83 public static void setParentAccessor(final ParentAccessor newAccessor) { 84 if (parentAccessor != null) { 85 throw new IllegalStateException(); 86 } 87 88 parentAccessor = newAccessor; 89 } 90 91 public interface ParentAccessor { 92 NGNode doCreatePeer(Node node); 93 void doUpdatePeer(Node node); 94 boolean pickChildrenNode(Parent parent, PickRay pickRay, PickResultChooser result); 95 void setTraversalEngine(Parent parent, ParentTraversalEngine value); 96 ParentTraversalEngine getTraversalEngine(Parent parent); 97 } 98 99 } | 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.scene.traversal.ParentTraversalEngine; 35 import com.sun.javafx.sg.prism.NGNode; 36 import com.sun.javafx.util.Utils; 37 import java.util.List; 38 import javafx.scene.Node; 39 import javafx.scene.Parent; 40 41 /* 42 * Used to access internal methods of Parent. 43 * Note: ParentHelper needs to be a concrete class even though Parent is an 44 * abstract class since user is allowed to subclass Parent. 45 */ 46 public class ParentHelper extends NodeHelper { 47 48 private static final ParentHelper theInstance; 49 private static ParentAccessor parentAccessor; 50 51 static { 52 theInstance = new ParentHelper(); 53 Utils.forceInit(Parent.class); 54 } 55 56 private static ParentHelper getInstance() { 57 return theInstance; 58 } 59 60 public static void initHelper(Parent parent) { 61 setHelper(parent, getInstance()); 62 } 63 64 public static void superProcessCSS(Node node) { 65 ((ParentHelper) getHelper(node)).superProcessCSSImpl(node); 66 } 67 68 @Override 69 protected NGNode createPeerImpl(Node node) { 70 return parentAccessor.doCreatePeer(node); 71 } 72 73 @Override 74 protected void updatePeerImpl(Node node) { 75 super.updatePeerImpl(node); 76 parentAccessor.doUpdatePeer(node); 77 } 78 79 @Override 80 protected BaseBounds computeGeomBoundsImpl(Node node, BaseBounds bounds, 81 BaseTransform tx) { 82 return parentAccessor.doComputeGeomBounds(node, bounds, tx); 83 } 84 85 @Override 86 protected boolean computeContainsImpl(Node node, double localX, double localY) { 87 return parentAccessor.doComputeContains(node, localX, localY); 88 } 89 90 void superProcessCSSImpl(Node node) { 91 super.processCSSImpl(node); 92 } 93 94 protected void processCSSImpl(Node node) { 95 parentAccessor.doProcessCSS(node); 96 } 97 98 @Override 99 protected Object processMXNodeImpl(Node node, MXNodeAlgorithm alg, MXNodeAlgorithmContext ctx) { 100 return parentAccessor.doProcessMXNode(node, alg, ctx); 101 } 102 103 @Override 104 protected void pickNodeLocalImpl(Node node, PickRay localPickRay, 105 PickResultChooser result) { 106 parentAccessor.doPickNodeLocal(node, localPickRay, result); 107 } 108 109 public static boolean pickChildrenNode(Parent parent, PickRay pickRay, 110 PickResultChooser result) { 111 return parentAccessor.pickChildrenNode(parent, pickRay, result); 112 } 113 114 public static void setTraversalEngine(Parent parent, ParentTraversalEngine value) { 115 parentAccessor.setTraversalEngine(parent, value); 116 } 117 118 public static ParentTraversalEngine getTraversalEngine(Parent parent) { 119 return parentAccessor.getTraversalEngine(parent); 120 } 121 122 public static List<String> getAllParentStylesheets(Parent parent) { 123 return parentAccessor.getAllParentStylesheets(parent); 124 } 125 126 public static void setParentAccessor(final ParentAccessor newAccessor) { 127 if (parentAccessor != null) { 128 throw new IllegalStateException(); 129 } 130 131 parentAccessor = newAccessor; 132 } 133 134 public interface ParentAccessor { 135 NGNode doCreatePeer(Node node); 136 void doUpdatePeer(Node node); 137 boolean doComputeContains(Node node, double localX, double localY); 138 BaseBounds doComputeGeomBounds(Node node, BaseBounds bounds, BaseTransform tx); 139 void doProcessCSS(Node node); 140 Object doProcessMXNode(Node node, MXNodeAlgorithm alg, MXNodeAlgorithmContext ctx); 141 void doPickNodeLocal(Node node, PickRay localPickRay, PickResultChooser result); 142 boolean pickChildrenNode(Parent parent, PickRay pickRay, PickResultChooser result); 143 void setTraversalEngine(Parent parent, ParentTraversalEngine value); 144 ParentTraversalEngine getTraversalEngine(Parent parent); 145 List<String> getAllParentStylesheets(Parent parent); 146 } 147 148 } |