modules/graphics/src/test/java/javafx/scene/Mouse3DTest.java

Print this page
rev 6167 : RT-35330 [Monocle] Remove StubToolkit and replace it with headless glass implementation


   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 javafx.scene;
  27 

  28 import com.sun.javafx.geom.PickRay;
  29 import com.sun.javafx.test.MouseEventGenerator;
  30 import javafx.event.Event;
  31 import javafx.event.EventHandler;
  32 import javafx.event.EventType;
  33 import javafx.geometry.Point2D;
  34 import javafx.geometry.Point3D;
  35 import javafx.scene.input.MouseDragEvent;
  36 import javafx.scene.input.MouseEvent;
  37 import javafx.scene.input.PickResult;
  38 import javafx.scene.shape.Rectangle;
  39 import javafx.scene.shape.Box;
  40 import javafx.scene.shape.CullFace;
  41 import javafx.scene.shape.Cylinder;
  42 import javafx.scene.shape.MeshView;

  43 import javafx.scene.shape.Sphere;
  44 import javafx.scene.shape.TriangleMesh;
  45 import javafx.scene.transform.Rotate;
  46 import javafx.stage.Stage;
  47 import static org.junit.Assert.*;
  48 import org.junit.Test;
  49 


  50 public class Mouse3DTest {
  51 



  52     private static final int NOFACE = PickResult.FACE_UNDEFINED;
  53     private static final double PERSPECTIVE_CAMERA_X = 500;
  54     private static final double PERSPECTIVE_CAMERA_Y = 400;
  55     private static final double PERSPECTIVE_CAMERA_Z = -1492.820323027551;
  56 
  57     private EventHolder<MouseEvent> me = new EventHolder<MouseEvent>();
  58     private EventHolder<MouseEvent> pme = new EventHolder<MouseEvent>();
  59     private EventHolder<MouseEvent> sme = new EventHolder<MouseEvent>();
  60 
  61     /***************** pick ray ********************/
  62     // We use moving camera for the picking tests, so test pick ray sanity first
  63 
  64     @Test
  65     public void shouldComputeCorrectPerspectivePickRay() {
  66         Camera cam = new PerspectiveCamera();
  67         scene(group(), cam, true);
  68         cam.impl_updatePeer();
  69         PickRay pickRay = cam.computePickRay(10, 20, null);
  70         assertEquals(PERSPECTIVE_CAMERA_X, pickRay.getOriginNoClone().x, 0.00001);
  71         assertEquals(PERSPECTIVE_CAMERA_Y, pickRay.getOriginNoClone().y, 0.00001);




   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 javafx.scene;
  27 
  28 import com.sun.javafx.FXUnit;
  29 import com.sun.javafx.geom.PickRay;
  30 import com.sun.javafx.test.MouseEventGenerator;
  31 import javafx.event.Event;
  32 import javafx.event.EventHandler;
  33 import javafx.event.EventType;
  34 import javafx.geometry.Point2D;
  35 import javafx.geometry.Point3D;
  36 import javafx.scene.input.MouseDragEvent;
  37 import javafx.scene.input.MouseEvent;
  38 import javafx.scene.input.PickResult;

  39 import javafx.scene.shape.Box;
  40 import javafx.scene.shape.CullFace;
  41 import javafx.scene.shape.Cylinder;
  42 import javafx.scene.shape.MeshView;
  43 import javafx.scene.shape.Rectangle;
  44 import javafx.scene.shape.Sphere;
  45 import javafx.scene.shape.TriangleMesh;
  46 import javafx.scene.transform.Rotate;
  47 import javafx.stage.Stage;
  48 import org.junit.Rule;
  49 import org.junit.Test;
  50 
  51 import static org.junit.Assert.*;
  52 
  53 public class Mouse3DTest {
  54 
  55     @Rule
  56     public FXUnit fx = new FXUnit();
  57 
  58     private static final int NOFACE = PickResult.FACE_UNDEFINED;
  59     private static final double PERSPECTIVE_CAMERA_X = 500;
  60     private static final double PERSPECTIVE_CAMERA_Y = 400;
  61     private static final double PERSPECTIVE_CAMERA_Z = -1492.820323027551;
  62 
  63     private EventHolder<MouseEvent> me = new EventHolder<MouseEvent>();
  64     private EventHolder<MouseEvent> pme = new EventHolder<MouseEvent>();
  65     private EventHolder<MouseEvent> sme = new EventHolder<MouseEvent>();
  66 
  67     /***************** pick ray ********************/
  68     // We use moving camera for the picking tests, so test pick ray sanity first
  69 
  70     @Test
  71     public void shouldComputeCorrectPerspectivePickRay() {
  72         Camera cam = new PerspectiveCamera();
  73         scene(group(), cam, true);
  74         cam.impl_updatePeer();
  75         PickRay pickRay = cam.computePickRay(10, 20, null);
  76         assertEquals(PERSPECTIVE_CAMERA_X, pickRay.getOriginNoClone().x, 0.00001);
  77         assertEquals(PERSPECTIVE_CAMERA_Y, pickRay.getOriginNoClone().y, 0.00001);