(float)Math.PI - (float)Math.PI / 60 + (float)Math.PI / 12, (float)Math.PI / 4 + (float)Math.PI / 120, home.getCamera());
// 6. View from observer
runAction(controller, HomePane.ActionType.VIEW_FROM_OBSERVER, tester);
tester.waitForIdle();
ObserverCamera observerCamera = home.getObserverCamera();
// Check camera is the observer camera
assertSame("Camera isn't observer camera", observerCamera, home.getCamera());
// Check default camera location and angles
assertCoordinatesAndAnglesEqualCameraLocationAndAngles(50, 50, 170,
7 * (float)Math.PI / 4, (float)Math.PI / 16, home.getCamera());
// Change camera location and angles
observerCamera.setX(100);
observerCamera.setY(100);
observerCamera.setYaw(3 * (float)Math.PI / 4);
assertCoordinatesAndAnglesEqualCameraLocationAndAngles(100, 100, 170,
3 * (float)Math.PI / 4, (float)Math.PI / 16, home.getCamera());
// Check observer camera is selected
assertEquals("Wrong selected items count", 1, home.getSelectedItems().size());
assertTrue("Camera isn't selected", home.getSelectedItems().contains(home.getCamera()));
// Try to select wall and observer camera
runAction(controller, HomePane.ActionType.SELECT, tester);
tester.actionClick(planComponent, 50, 50);
tester.actionKeyPress(KeyEvent.VK_SHIFT);
tester.actionClick(planComponent, (int)(140 * planComponent.getScale()),
(int)(140 * planComponent.getScale()));
tester.actionKeyRelease(KeyEvent.VK_SHIFT);
// Check selected items contains only wall
assertEquals("Wrong selected items count", 1, home.getSelectedItems().size());
assertTrue("Wall isn't selected", home.getSelectedItems().contains(wall));
// Select observer camera
Thread.sleep(1000); // Wait 1s to avoid double click
tester.actionClick(planComponent, (int)(140 * planComponent.getScale()),
(int)(140 * planComponent.getScale()));
// Check observer camera is selected
assertEquals("Wrong selected items count", 1, home.getSelectedItems().size());
assertTrue("Camera isn't selected", home.getSelectedItems().contains(home.getCamera()));
// 7. Move observer camera at right and down
tester.actionKeyStroke(KeyEvent.VK_RIGHT);
tester.actionKeyStroke(KeyEvent.VK_DOWN);
// Check camera location and angles
assertCoordinatesAndAnglesEqualCameraLocationAndAngles(100 + 1 / planComponent.getScale(),
100 + 1 / planComponent.getScale(), 170,
3 * (float)Math.PI / 4, (float)Math.PI / 16, home.getCamera());
// 8. Change observer camera yaw by moving its yaw indicator
float [][] cameraPoints = observerCamera.getPoints();
int xYawIndicator = (int)(((40 + (cameraPoints[0][0] + cameraPoints[3][0]) / 2)) * planComponent.getScale());
int yYawIndicator = (int)(((40 + (cameraPoints[0][1] + cameraPoints[3][1]) / 2)) * planComponent.getScale());
tester.actionMousePress(planComponent, new ComponentLocation(
new Point(xYawIndicator, yYawIndicator)));
tester.actionMouseMove(planComponent, new ComponentLocation(
new Point(xYawIndicator + 2, yYawIndicator + 2)));
tester.actionMouseRelease();
// Check camera yaw angle changed
assertCoordinatesAndAnglesEqualCameraLocationAndAngles(100 + 1 / planComponent.getScale(),
100 + 1 / planComponent.getScale(), 170,
2.5156f, (float)Math.PI / 16, home.getCamera());
// Change observer camera pitch by moving its pitch indicator
cameraPoints = observerCamera.getPoints();
int xPitchIndicator = (int)(((40 + (cameraPoints[1][0] + cameraPoints[2][0]) / 2)) * planComponent.getScale());
int yPitchIndicator = (int)(((40 + (cameraPoints[1][1] + cameraPoints[2][1]) / 2)) * planComponent.getScale());
tester.actionMousePress(planComponent, new ComponentLocation(
new Point(xPitchIndicator, yPitchIndicator)));
tester.actionMouseMove(planComponent, new ComponentLocation(
new Point(xPitchIndicator + 2, yPitchIndicator + 2)));
tester.actionMouseRelease();
// Check camera pitch angle changed
assertCoordinatesAndAnglesEqualCameraLocationAndAngles(100 + 1 / planComponent.getScale(),
100 + 1 / planComponent.getScale(), 170,
2.5156f, 0.1639f, home.getCamera());
// 9. Change observer camera location with mouse in 3D view
tester.actionMousePress(component3D, new ComponentLocation(new Point(10, 10)));
tester.actionKeyPress(KeyEvent.VK_ALT);
tester.actionMouseMove(component3D, new ComponentLocation(new Point(10, 20)));
tester.actionKeyRelease(KeyEvent.VK_ALT);
tester.actionMouseRelease();
// Check camera location changed
assertCoordinatesAndAnglesEqualCameraLocationAndAngles(108.657f, 111.4631f, 170,
2.5156f, 0.1639f, home.getCamera());
// 10. Change observer camera yaw with mouse in 3D view
tester.actionMousePress(component3D, new ComponentLocation(new Point(10, 20)));
tester.actionMouseMove(component3D, new ComponentLocation(new Point(20, 20)));
tester.actionMouseRelease();
// Check camera yaw changed
assertCoordinatesAndAnglesEqualCameraLocationAndAngles(108.657f, 111.4631f, 170,
2.5656f, 0.1639f, home.getCamera());
// Change camera pitch with mouse in 3D view
tester.actionMousePress(component3D, new ComponentLocation(new Point(20, 20)));
tester.actionMouseMove(component3D, new ComponentLocation(new Point(20, 30)));
tester.actionMouseRelease();
// Check camera yaw changed
assertCoordinatesAndAnglesEqualCameraLocationAndAngles(108.657f, 111.4631f, 170,
2.5656f, 0.2139f, home.getCamera());
// 11. Edit 3D view modal dialog box
JDialog attributesDialog = showHome3DAttributesPanel(preferences, controller, frame, tester);
// Retrieve Home3DAttributesPanel components
Home3DAttributesPanel panel = (Home3DAttributesPanel)TestUtilities.findComponent(
attributesDialog, Home3DAttributesPanel.class);
Home3DAttributesController panelController =
(Home3DAttributesController)TestUtilities.getField(panel, "controller");
JSpinner observerFieldOfViewSpinner =
(JSpinner)TestUtilities.getField(panel, "observerFieldOfViewSpinner");
JSpinner observerHeightSpinner =
(JSpinner)TestUtilities.getField(panel, "observerHeightSpinner");
ColorButton groundColorButton =
(ColorButton)TestUtilities.getField(panel, "groundColorButton");
ColorButton skyColorButton =
(ColorButton)TestUtilities.getField(panel, "skyColorButton");
JSlider brightnessSlider =
(JSlider)TestUtilities.getField(panel, "brightnessSlider");
JSlider wallsTransparencySlider =
(JSlider)TestUtilities.getField(panel, "wallsTransparencySlider");
// Check edited values
float oldCameraFieldOfView = observerCamera.getFieldOfView();
float oldCameraHeight = observerCamera.getHeight();
int oldGroundColor = home.getEnvironment().getGroundColor();
TextureImage oldGroundTexture = home.getEnvironment().getGroundTexture();
int oldSkyColor = home.getEnvironment().getSkyColor();
int oldLightColor = home.getEnvironment().getLightColor();
float oldWallsAlpha = home.getEnvironment().getWallsAlpha();