1 /* 2 * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 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.javafx.scene.input; 27 28 import test.com.sun.javafx.scene.input.TestNodeHelper; 29 import com.sun.javafx.geom.BaseBounds; 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.sg.prism.NGGroup; 34 import com.sun.javafx.sg.prism.NGNode; 35 import javafx.geometry.Point2D; 36 import javafx.geometry.Point3D; 37 import javafx.scene.Node; 38 39 /** 40 * Subclass of javafx.scene.Node used for input testing. 41 */ 42 public class TestNode extends Node { 43 static { 44 // This is used by classes in different packages to get access to 45 // private and package private methods. 46 TestNodeHelper.setTestNodeAccessor(new TestNodeHelper.TestNodeAccessor() { 47 @Override 48 public NGNode doCreatePeer(Node node) { 49 return ((TestNode) node).doCreatePeer(); 50 } 51 }); 52 } 53 54 private float offsetInScene; 55 56 { 57 // To initialize the class helper at the begining each constructor of this class 58 TestNodeHelper.initHelper(this); 59 } 60 public TestNode() { 61 } 62 63 public TestNode(float offsetInScene) { 64 this.offsetInScene = offsetInScene; 65 } 66 67 @Override 68 public Point2D sceneToLocal(double x, double y) { 69 return new Point2D(x - offsetInScene, y - offsetInScene); 70 } 71 72 @Override 73 public Point2D localToScene(double x, double y) { 74 return new Point2D(x + offsetInScene, y + offsetInScene); 75 } 76 77 @Override 78 public Point3D sceneToLocal(double x, double y, double z) { 79 return new Point3D(x - offsetInScene, y - offsetInScene, z); 80 } 81 82 @Override 83 public Point3D localToScene(double x, double y, double z) { 84 return new Point3D(x + offsetInScene, y + offsetInScene, z); 85 } 86 87 @Override 88 protected boolean impl_computeContains(double f, double f1) { 89 return false; 90 } 91 92 @Override 93 public BaseBounds impl_computeGeomBounds(BaseBounds bd, BaseTransform bt) { 94 return null; 95 } 96 97 private NGNode doCreatePeer() { 98 return new NGGroup(); 99 } 100 101 @Override 102 public Object impl_processMXNode(MXNodeAlgorithm alg, MXNodeAlgorithmContext ctx) { 103 return null; 104 } 105 }