Search in sources :

Example 1 with StampingMock

use of com.xenoage.zong.musiclayout.stampings.StampingMock in project Zong by Xenoage.

the class ScoreFrameLayoutTest method getLayoutElementAt.

@Test
public void getLayoutElementAt() {
    /* 0    5   10   15    20    | 0
		 *                             
		 *       ***********           2
		 *  +----*   [0]   *     
		 *  |    *         *~~~~~~~    4
		 *  |[1] ***********      |
		 *  +--------+       [2]  |    6
		 *     |                  |
		 *     ~~~~~~~~~~~~~~~~~~~~    8
		 */
    Stamping[] stampings = new Stamping[3];
    StampingMock s1 = new StampingMock(Level.Music, new Rectangle2f(6, 2, 10, 3));
    stampings[0] = s1;
    StampingMock s2 = new StampingMock(Level.Staff, new Rectangle2f(1, 3, 9, 3));
    stampings[1] = s2;
    StampingMock s3 = new StampingMock(Level.EmptySpace, new Rectangle2f(4, 4, 19, 4));
    stampings[2] = s3;
    ScoreFrameLayout layout = new ScoreFrameLayout(null, new ArrayList<>(), alist(stampings), new ArrayList<>());
    // no hit (but empty space)
    assertTrue(isNot(layout.getStampingAt(new Point2f(0, 0)), s1, s2, s3));
    assertTrue(isNot(layout.getStampingAt(new Point2f(3, 7)), s1, s2, s3));
    assertTrue(isNot(layout.getStampingAt(new Point2f(17, 3)), s1, s2, s3));
    // single hit
    assertEquals(s1, layout.getStampingAt(new Point2f(10, 2)));
    assertEquals(s2, layout.getStampingAt(new Point2f(3, 5)));
    assertEquals(s3, layout.getStampingAt(new Point2f(22, 8)));
    // intersection hit
    assertEquals(s1, layout.getStampingAt(new Point2f(15, 4)));
    assertEquals(s2, layout.getStampingAt(new Point2f(5, 5)));
    assertEquals(s1, layout.getStampingAt(new Point2f(8, 4)));
}
Also used : Stamping(com.xenoage.zong.musiclayout.stampings.Stamping) Point2f(com.xenoage.utils.math.geom.Point2f) Rectangle2f(com.xenoage.utils.math.geom.Rectangle2f) StampingMock(com.xenoage.zong.musiclayout.stampings.StampingMock) Test(org.junit.Test)

Aggregations

Point2f (com.xenoage.utils.math.geom.Point2f)1 Rectangle2f (com.xenoage.utils.math.geom.Rectangle2f)1 Stamping (com.xenoage.zong.musiclayout.stampings.Stamping)1 StampingMock (com.xenoage.zong.musiclayout.stampings.StampingMock)1 Test (org.junit.Test)1