@Test
public void testTransform() throws Exception {

    RectRegion r1 = new RectRegion(1, 2, 0, 10);
    RectRegion r2 = new RectRegion(2, 4, 10, 20);
    final XYCoords trans1 = r1.transform(new XYCoords(1.5, 5), r2);
    assertEquals(3.0, trans1.x);
    assertEquals(15.0, trans1.y);
    // try a screen transform:
    RectF screen = new RectF(0, 0, 100, 100);
    PointF result = r1.transform(2, 10, screen, false, true);
    assertEquals(100f, result.x);
    assertEquals(0f, result.y);
    // now transform back to real:
    RectRegion screenRegion = new RectRegion(screen);
    XYCoords result2 = screenRegion.transform(result.x, result.y, r1, false, true);
    assertEquals(2d, result2.x);
    assertEquals(10d, result2.y);
}