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 test.com.sun.javafx.scene; 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.Node; 32 import test.javafx.scene.StructureTest; 33 34 public class StubParentHelper extends ParentHelper { 35 36 private static final StubParentHelper theInstance; 37 private static StubParentAccessor stubParentAccessor; 38 39 static { 40 theInstance = new StubParentHelper(); 41 Utils.forceInit(StructureTest.StubParent.class); 42 } 43 44 private static StubParentHelper getInstance() { 45 return theInstance; 46 } 47 48 public static void initHelper(StructureTest.StubParent stubParent) { 49 setHelper(stubParent, getInstance()); 50 } 51 52 public static void setStubParentAccessor(final StubParentAccessor newAccessor) { 53 if (stubParentAccessor != null) { 54 throw new IllegalStateException(); 55 } 56 57 stubParentAccessor = newAccessor; 58 } 59 60 @Override 61 protected NGNode createPeerImpl(Node node) { 62 return stubParentAccessor.doCreatePeer(node); 63 } 64 65 public interface StubParentAccessor { 66 NGNode doCreatePeer(Node node); 67 } 68 69 } | 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 test.com.sun.javafx.scene; 27 28 import com.sun.javafx.geom.BaseBounds; 29 import com.sun.javafx.geom.transform.BaseTransform; 30 import com.sun.javafx.scene.ParentHelper; 31 import com.sun.javafx.sg.prism.NGNode; 32 import com.sun.javafx.util.Utils; 33 import javafx.scene.Node; 34 import test.javafx.scene.StructureTest; 35 36 public class StubParentHelper extends ParentHelper { 37 38 private static final StubParentHelper theInstance; 39 private static StubParentAccessor stubParentAccessor; 40 41 static { 42 theInstance = new StubParentHelper(); 43 Utils.forceInit(StructureTest.StubParent.class); 44 } 45 46 private static StubParentHelper getInstance() { 47 return theInstance; 48 } 49 50 public static void initHelper(StructureTest.StubParent stubParent) { 51 setHelper(stubParent, getInstance()); 52 } 53 54 public static void setStubParentAccessor(final StubParentAccessor newAccessor) { 55 if (stubParentAccessor != null) { 56 throw new IllegalStateException(); 57 } 58 59 stubParentAccessor = newAccessor; 60 } 61 62 @Override 63 protected NGNode createPeerImpl(Node node) { 64 return stubParentAccessor.doCreatePeer(node); 65 } 66 67 @Override 68 protected BaseBounds computeGeomBoundsImpl(Node node, BaseBounds bounds, 69 BaseTransform tx) { 70 return stubParentAccessor.doComputeGeomBounds(node, bounds, tx); 71 } 72 73 @Override 74 protected boolean computeContainsImpl(Node node, double localX, double localY) { 75 return stubParentAccessor.doComputeContains(node, localX, localY); 76 } 77 78 public interface StubParentAccessor { 79 NGNode doCreatePeer(Node node); 80 BaseBounds doComputeGeomBounds(Node node, BaseBounds bounds, BaseTransform tx); 81 boolean doComputeContains(Node node, double localX, double localY); 82 } 83 84 } |