Commit 6014fa2c authored by Sergio Emanuel Rodriguez Rivera's avatar Sergio Emanuel Rodriguez Rivera
Browse files

Mouse Movement comments and variables Javadocs

parent c625ae93
Loading
Loading
Loading
Loading
+27 −73
Original line number Diff line number Diff line
@@ -41,14 +41,19 @@ import static java.lang.Math.*;
 * it includes a real-time FPS counter overlaid on the scene to monitor performance.
 */
public class GraphicsAndWindowsTest extends Application {
    /**
     * Initializes location for anchor or release locations of mouse for drawing slingLine and calculating
     * the release velocity of the figures.
     */
    public double anchorX, anchorY, releaseX, releaseY;

    /**
     * Initializes the line drawn in the application for mouse control.
     */
    private Line slingLine;
    //private double anchorAngleX = 0;
    //private double anchorAngleY = 0;
    //private final DoubleProperty angleX = new SimpleDoubleProperty(0);
    //private final DoubleProperty angleY = new SimpleDoubleProperty(0);
    //public static String[] parameters;
    /**
     * Initializes the MovingObeject list used to manipulate and store the different objects created throughout
     * the application.
     */
    public static MovingObject[] objects;
    /**
     * Starts the JavaFX application.
@@ -147,8 +152,6 @@ public class GraphicsAndWindowsTest extends Application {
        subScene3D.setFill(Color.SILVER);
        subScene3D.setCamera(camera);

        //initMouseControl(group3D, subScene3D);



        /*
@@ -173,11 +176,10 @@ public class GraphicsAndWindowsTest extends Application {

        Scene scene = new Scene(Layers, 1500, 800);

        //setupMouseControl(subScene3D,objects); DELETE THIS LATER IF NOT USED

        double elasticityFactor = 0.5;


        /*
        Mouse event for setting anchors
         */
        ourWindow.setOnMousePressed(mouseEvent -> {
            anchorX = mouseEvent.getX();
            anchorY = mouseEvent.getY();
@@ -192,6 +194,10 @@ public class GraphicsAndWindowsTest extends Application {
            group3D.getChildren().add(slingLine);
        });

        /*
        Mouse event for drawing line as the mouse is dragged through the window.
         */

        ourWindow.setOnMouseDragged(mouseEvent -> {
            double dragX = mouseEvent.getX();
            double dragY = mouseEvent.getY();
@@ -202,6 +208,10 @@ public class GraphicsAndWindowsTest extends Application {
            slingLine.setEndY(dragY);
        });

        /*
        Mouse event to launch object and delete the slingLine drawn on window.
         */

        ourWindow.setOnMouseReleased(mouseEvent -> {
            releaseX = mouseEvent.getX();
            releaseY = mouseEvent.getY();
@@ -220,6 +230,10 @@ public class GraphicsAndWindowsTest extends Application {

        });

        /*
        Key Event to move objects in the z dimension by pressing W and S.
         */

        stage.addEventHandler(KeyEvent.KEY_PRESSED, e->{
            if( e.getCode() == KeyCode.W){
                //System.out.println("SPACE");
@@ -412,67 +426,7 @@ public class GraphicsAndWindowsTest extends Application {
        };
        timer.start();
    }
//    private void initMouseControl(Group group, SubScene scene){
//        Rotate xRotate;
//        Rotate yRotate;
//        group.getTransforms().addAll(
//                xRotate = new Rotate(0, Rotate.X_AXIS),
//                yRotate = new Rotate(0, Rotate.Y_AXIS)
//        );
//        xRotate.angleProperty().bind(angleX);
//        yRotate.angleProperty().bind(angleY);
//
//        scene.setOnMouseClicked(mouseEvent -> {
//            anchorX = mouseEvent.getSceneX();
//            anchorY = mouseEvent.getSceneY();
//            anchorAngleX = angleX.get();
//            anchorAngleY = angleY.get();
//
//        });
//
//        scene.setOnMouseDragged(mouseEvent -> {
//            angleX.set(anchorAngleX - (anchorY - mouseEvent.getSceneY()));
//            angleY.set(anchorAngleY - (anchorX - mouseEvent.getSceneX()));
//
//        });
//    }

//    private void setupMouseControl(SubScene scene, MovingObject[] objects) {
//        anchorX = 0;
//        anchorY = 0;
//        double elasticityFactor = 0.5;
//
//        scene.setOnMousePressed(mouseEvent -> {
//            anchorX = mouseEvent.getX();
//            anchorY = mouseEvent.getY();
//            System.out.println("Mouse pressed at: " + anchorX + ", " + anchorY);
//
//            slingLine = new Line(anchorX, anchorY, anchorX, anchorY);
//            slingLine.setStroke(Color.RED);
//            slingLine.setStrokeWidth(2);
//            ((Group) scene.getRoot()).getChildren().add(slingLine);
//        });
//
//        scene.setOnMouseDragged(mouseEvent -> {
//            double dragX = mouseEvent.getSceneX();
//            double dragY = mouseEvent.getSceneY();
//            System.out.println("Mouse dragged to: " + dragX + ", " + dragY);
//
//            // Update the end of the sling line to the current drag position
//            slingLine.setEndX(dragX);
//            slingLine.setEndY(dragY);
//        });
//
//        scene.setOnMouseReleased(mouseEvent -> {
//            double releaseX = mouseEvent.getSceneX();
//            double releaseY = mouseEvent.getSceneY();
//            System.out.println("Mouse released at: " + releaseX + ", " + releaseY);
//
//            // Remove the sling visualization line
//            ((Group) scene.getRoot()).getChildren().remove(slingLine);
//
//        });
//    }

    /**
     * The entry point of the application. This method is called when the application starts.
     *
−830 B

File deleted.

−8.92 KiB

File deleted.