Search in sources :

Example 31 with Camera

use of au.gov.asd.tac.constellation.utilities.camera.Camera in project constellation by constellation-app.

the class CameraIOProviderNGTest method testReadObject.

/**
 * Test of readObject method, of class CameraIOProvider.
 */
@Test
public void testReadObject() throws Exception {
    System.out.println("CameraIOProviderNGTest.testReadObject");
    // Create argument captors
    ArgumentCaptor<Integer> captorAtributeId = ArgumentCaptor.forClass(Integer.class);
    ArgumentCaptor<Integer> captorElementId = ArgumentCaptor.forClass(Integer.class);
    ArgumentCaptor<Camera> captorCamera = ArgumentCaptor.forClass(Camera.class);
    // Call method under test with JsonNode.isNull=true and show nothing happens
    resetMocking();
    when(mockJsonNode.isNull()).thenReturn(true);
    instance.readObject(attributeId, elementId, mockJsonNode, mockGraphWriteMethods, null, null, null, null);
    Mockito.verify(mockJsonNode, times(0)).hasNonNull(anyString());
    // Call method under test with JsonNode.isNull=true and show nothing happens
    resetMocking();
    Camera expected = new Camera();
    expected.setVisibilityLow(0.0f);
    expected.setVisibilityHigh(1.0f);
    expected.setMixRatio(2);
    expected.lookAtEye.set(0.0f, 0.1f, 0.2f);
    expected.lookAtCentre.set(1.0f, 1.1f, 1.2f);
    expected.lookAtUp.set(2.0f, 2.1f, 2.2f);
    expected.lookAtRotation.set(3.0f, 3.1f, 3.2f);
    expected.lookAtPreviousEye.set(4.0f, 4.1f, 4.2f);
    expected.lookAtPreviousCentre.set(5.0f, 5.1f, 5.2f);
    expected.lookAtPreviousUp.set(6.0f, 6.1f, 6.2f);
    expected.lookAtPreviousRotation.set(7.0f, 7.1f, 7.2f);
    Frame objFrame = new Frame();
    objFrame.setOrigin(new Vector3f(0.0f, 0.1f, 0.2f));
    objFrame.setForwardVector(new Vector3f(1.0f, 1.1f, 1.2f));
    objFrame.setUpVector(new Vector3f(2.0f, 2.1f, 2.2f));
    expected.setObjectFrame(objFrame);
    expected.boundingBox.set(new Vector3f(0.0f, 0.1f, 0.2f), new Vector3f(1.0f, 1.1f, 1.2f), new Vector3f(2.0f, 2.1f, 2.2f), new Vector3f(3.0f, 3.1f, 3.2f));
    ObjectMapper mapper = new ObjectMapper();
    when(mockJsonNode.isNull()).thenReturn(false);
    final JsonNode testNode = mapper.readTree("{\"look_at_eye\": [0.0, 0.1, 0.2],\"look_at_centre\": [1.0, 1.1, 1.2],\"look_at_up\": [2.0, 2.1, 2.2],\"look_at_rotation\": [3.0, 3.1, 3.2],\"look_at_previous_eye\": [4.0, 4.1, 4.2],\"look_at_previous_centre\": [5.0, 5.1, 5.2],\"look_at_previous_up\": [6.0, 6.1, 6.2],\"look_at_previous_rotation\": [7.0, 7.1, 7.2],\"bounding_box\": {\"is_empty\": false, \"min\": [0.0, 0.1, 0.2], \"max\": [1.0, 1.1, 1.2], \"min2\": [2.0, 2.1, 2.2], \"max2\": [3.0, 3.1, 3.2]},\"frame\": {\"origin\": [0.0, 0.1, 0.2], \"forward\": [1.0, 1.1, 1.2], \"up\": [2.0, 2.1, 2.2]}, \"visibility_low\": 0.0, \"visibility_high\": 1.0, \"mix_ratio\": 2}");
    instance.readObject(attributeId, elementId, testNode, mockGraphWriteMethods, null, null, null, null);
    Mockito.verify(mockGraphWriteMethods, times(1)).setObjectValue(captorAtributeId.capture(), captorElementId.capture(), captorCamera.capture());
    assertEquals((int) captorAtributeId.getValue(), attributeId);
    assertEquals((int) captorElementId.getValue(), elementId);
    assertEquals(expected.areSame(captorCamera.getValue()), true);
}
Also used : Frame(au.gov.asd.tac.constellation.utilities.graphics.Frame) Vector3f(au.gov.asd.tac.constellation.utilities.graphics.Vector3f) JsonNode(com.fasterxml.jackson.databind.JsonNode) Camera(au.gov.asd.tac.constellation.utilities.camera.Camera) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.testng.annotations.Test)

Example 32 with Camera

use of au.gov.asd.tac.constellation.utilities.camera.Camera in project constellation by constellation-app.

the class CameraAttributeDescriptionNGTest method testConvertFromObject.

/**
 * Test of convertFromObject method, of class CameraAttributeDescription.
 */
@Test
public void testConvertFromObject() {
    System.out.println("convertFromObject");
    final CameraAttributeDescription instance = new CameraAttributeDescription();
    final Object nullResult = instance.convertFromObject(null);
    assertNull(nullResult);
    final Object stringResult = instance.convertFromObject("");
    assertTrue(stringResult instanceof Camera);
    final Camera resultCam = (Camera) stringResult;
    assertTrue(resultCam.areSame(new Camera()));
    final Object otherResult = instance.convertFromObject(42);
    // should return itself
    assertEquals(otherResult, 42);
}
Also used : Camera(au.gov.asd.tac.constellation.utilities.camera.Camera) Test(org.testng.annotations.Test)

Aggregations

Camera (au.gov.asd.tac.constellation.utilities.camera.Camera)32 Vector3f (au.gov.asd.tac.constellation.utilities.graphics.Vector3f)11 Test (org.testng.annotations.Test)8 Point (java.awt.Point)5 PanAnimation (au.gov.asd.tac.constellation.graph.interaction.animation.PanAnimation)4 Frame (au.gov.asd.tac.constellation.utilities.graphics.Frame)4 Matrix44f (au.gov.asd.tac.constellation.utilities.graphics.Matrix44f)4 BoundingBox (au.gov.asd.tac.constellation.utilities.camera.BoundingBox)3 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)2 Matrix33f (au.gov.asd.tac.constellation.utilities.graphics.Matrix33f)2 BitSet (java.util.BitSet)2 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)1 SelectionBoxModel (au.gov.asd.tac.constellation.graph.interaction.visual.renderables.SelectionBoxModel)1 DualGraph (au.gov.asd.tac.constellation.graph.locking.DualGraph)1 Blaze (au.gov.asd.tac.constellation.graph.schema.visual.attribute.objects.Blaze)1 DeveloperPreferenceKeys (au.gov.asd.tac.constellation.preferences.DeveloperPreferenceKeys)1 Graphics3DUtilities (au.gov.asd.tac.constellation.utilities.camera.Graphics3DUtilities)1 ConstellationColor (au.gov.asd.tac.constellation.utilities.color.ConstellationColor)1 Vector4f (au.gov.asd.tac.constellation.utilities.graphics.Vector4f)1 InfoTextPanel (au.gov.asd.tac.constellation.utilities.gui.InfoTextPanel)1