Class CameraManager


  • public class CameraManager
    extends Object
    This class is the manager to manage all the camera related functions, including movement, info, states.
    Author:
    Zhijie Lan

    create date: 2020/11/4 changed: Abhishek Sharma

    updatedCameraInfo added to track if camera is updated

    • Field Detail

      • state_CamInfo_list

        protected static ArrayList<CameraInfoI> state_CamInfo_list
        the array that stores info of each state
      • cur_CamInfo

        public static CameraInfoI cur_CamInfo
        the info for the current state
      • updatedCameraInfo

        public static boolean updatedCameraInfo
        if camera info updated sets it to true
      • presentationCamera

        public static CameraInfoI presentationCamera
        the camera location used to navigate in the present canvas during presentation, but not affect the stored state camera
    • Constructor Detail

      • CameraManager

        public CameraManager()
    • Method Detail

      • moveCamera

        public static void moveCamera​(Graphics2D g2,
                                      double cam_x_offset,
                                      double cam_y_offset,
                                      double zoomFactor)
        move the camera to the given location
        Parameters:
        g2 - the Graphics to paint
        cam_x_offset - x offset
        cam_y_offset - y offset
        zoomFactor - zoom index
      • moveCamera

        public static void moveCamera​(Graphics2D g2)
        move the camera to the stored location
        Parameters:
        g2 - the Graphics to paint
      • toWorldCoordinates

        public static Point2D toWorldCoordinates​(Point point)
        from view coordinate to world coordinate according to current camera location
        Parameters:
        point - view coordinate
        Returns:
        world coordinate
      • toViewCoordinates

        public static Point2D toViewCoordinates​(double wX,
                                                double wY)
        from world coordinate to view coordinate according to current camera location
        Parameters:
        wX - world coordinate X
        wY - world coordinate Y
        Returns:
        view coordinate
      • initializePresentationCamera

        public static void initializePresentationCamera()
        set the location of presentation camera
      • getCurrent_State

        private static int getCurrent_State()
        get the current state index
        Returns:
        current state index
      • getCur_CamInfoFromList

        private static CameraInfoI getCur_CamInfoFromList()
        get the camera info for the current state
        Returns:
        the current camera info
      • updateCur_CamInfo

        public static void updateCur_CamInfo()
        update the cur_CamInfo. and add interpolation from previous value to the current value
      • insertCamState

        public static void insertCamState()
        insert a new camera info of a new state into state_CamInfo_list at the current state index. The new camera info will clone the previous info of the current state
      • deleteCamState

        public static void deleteCamState​(int state)
        delete a given state form state_CamInfo_list
        Parameters:
        state - the state to be deleted