Package prezoom.controller
Class CameraManager
- java.lang.Object
-
- prezoom.controller.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 Summary
Fields Modifier and Type Field Description static CameraInfoIcur_CamInfothe info for the current statestatic CameraInfoIpresentationCamerathe camera location used to navigate in the present canvas during presentation, but not affect the stored state cameraprotected static ArrayList<CameraInfoI>state_CamInfo_listthe array that stores info of each statestatic booleanupdatedCameraInfoif camera info updated sets it to true
-
Constructor Summary
Constructors Constructor Description CameraManager()
-
Method Summary
Modifier and Type Method Description static voiddeleteCamState(int state)delete a given state formstate_CamInfo_liststatic CameraInfoIgetCorrectCamera()get the current camera infoprivate static CameraInfoIgetCur_CamInfoFromList()get the camera info for the current stateprivate static intgetCurrent_State()get the current state indexstatic voidinitializePresentationCamera()set the location of presentation camerastatic voidinsertCamState()insert a new camera info of a new state intostate_CamInfo_listat the current state index.static voidmoveCamera(Graphics2D g2)move the camera to the stored locationstatic voidmoveCamera(Graphics2D g2, double cam_x_offset, double cam_y_offset, double zoomFactor)move the camera to the given locationstatic Point2DtoViewCoordinates(double wX, double wY)from world coordinate to view coordinate according to current camera locationstatic Point2DtoWorldCoordinates(Point point)from view coordinate to world coordinate according to current camera locationstatic voidupdateCur_CamInfo()update thecur_CamInfo.
-
-
-
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
-
-
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 paintcam_x_offset- x offsetcam_y_offset- y offsetzoomFactor- 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 XwY- 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
-
getCorrectCamera
public static CameraInfoI getCorrectCamera()
get the current camera info- Returns:
cur_CamInfoif not presenting,presentationCameraif presenting
-
updateCur_CamInfo
public static void updateCur_CamInfo()
update thecur_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 intostate_CamInfo_listat 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 formstate_CamInfo_list- Parameters:
state- the state to be deleted
-
-