Search in sources :

Example 1 with FP

use of com.xenoage.zong.layout.frames.FP in project Zong by Xenoage.

the class PageTest method getFPTestUnrotated.

/**
 * Tests the computeFramePosition-method
 * without rotation.
 */
@Test
public void getFPTestUnrotated() {
    Layout layout = createPageWithUnrotatedFrames();
    Page page = layout.getPages().get(0);
    // Test 1
    Point2f p = new Point2f(113, 122);
    FP fp = page.getFP(p);
    assertNotNull(fp);
    assertEquals(frm2, fp.getFrame());
    assertEquals(23, fp.getPosition().x, Delta.DELTA_FLOAT);
    assertEquals(12, fp.getPosition().y, Delta.DELTA_FLOAT);
    // Test 2
    p = new Point2f(122, 108);
    fp = page.getFP(p);
    assertNotNull(fp);
    assertEquals(frm2a, fp.getFrame());
    assertEquals(2, fp.getPosition().x, Delta.DELTA_FLOAT);
    assertEquals(-2, fp.getPosition().y, Delta.DELTA_FLOAT);
    // Test 3
    p = new Point2f(86, 88);
    fp = page.getFP(p);
    assertNull(fp);
}
Also used : Point2f(com.xenoage.utils.math.geom.Point2f) FP(com.xenoage.zong.layout.frames.FP) Test(org.junit.Test)

Example 2 with FP

use of com.xenoage.zong.layout.frames.FP in project Zong by Xenoage.

the class PageTest method getFPTestRotated.

/**
 * Tests the computeFramePosition-method with rotation.
 * See PageTest.odg in this folder.
 */
@Test
public void getFPTestRotated() {
    Layout layout = createPageWithRotatedFrames();
    Page page = layout.getPages().get(0);
    FP fp;
    float delta = 1;
    // Test 1 (yellow)
    fp = page.getFP(p(162.1f, 96.1f));
    assertNull(fp);
    fp = page.getFP(p(163f, 107.3f));
    assertNull(fp);
    fp = page.getFP(p(163f, 100.4f));
    assertNotNull(fp);
    assertEquals(frm1, fp.getFrame());
    Point2f pExpected = p(27, -38);
    assertEquals(pExpected.x, fp.getPosition().x, delta);
    assertEquals(pExpected.y, fp.getPosition().y, delta);
    // Test 2 (green)
    fp = page.getFP(p(137, 145));
    assertEquals(frm1, fp.getFrame());
    fp = page.getFP(p(130, 160));
    assertEquals(frm1, fp.getFrame());
    fp = page.getFP(p(132, 152.1f));
    assertEquals(frm3, fp.getFrame());
    fp = page.getFP(p(137, 152.1f));
    assertEquals(frm3, fp.getFrame());
    // Test 3 (orange)
    fp = page.getFP(p(100, 85));
    assertEquals(frm2, fp.getFrame());
    fp = page.getFP(p(102, 90));
    assertEquals(frm2, fp.getFrame());
    fp = page.getFP(p(102, 95));
    assertEquals(frm2a, fp.getFrame());
    pExpected = p(-2, -4);
    assertEquals(pExpected.x, fp.getPosition().x, delta);
    assertEquals(pExpected.y, fp.getPosition().y, delta);
    fp = page.getFP(p(109, 84));
    assertEquals(frm1, fp.getFrame());
    fp = page.getFP(p(105, 82.1f));
    assertNull(fp);
    // Test 4 (red)
    fp = page.getFP(p(82, 130));
    assertEquals(frm2b, fp.getFrame());
    pExpected = p(-8, -9);
    assertEquals(pExpected.x, fp.getPosition().x, delta);
    assertEquals(pExpected.y, fp.getPosition().y, delta);
    fp = page.getFP(p(76, 127.1f));
    assertEquals(frm2, fp.getFrame());
    fp = page.getFP(p(75, 135));
    assertEquals(frm2, fp.getFrame());
    fp = page.getFP(p(75, 139));
    assertEquals(frm1, fp.getFrame());
    fp = page.getFP(p(75, 144.1f));
    assertEquals(frm3, fp.getFrame());
    fp = page.getFP(p(70, 137.1f));
    assertNull(fp);
}
Also used : Point2f(com.xenoage.utils.math.geom.Point2f) FP(com.xenoage.zong.layout.frames.FP) Test(org.junit.Test)

Aggregations

Point2f (com.xenoage.utils.math.geom.Point2f)2 FP (com.xenoage.zong.layout.frames.FP)2 Test (org.junit.Test)2