@Test
public void testAdapter() {
final AffineTransform atr = AffineTransform.getScaleInstance(0.25, 0.5);
atr.translate(4, 2);
final AffineTransform2D transform = new AffineTransform2D(atr);
final WarpAffine warp = new WarpAffine (atr);
final WarpAdapter adapter = new WarpAdapter("test", transform);
final Random random = new Random(-854734760285695284L);
for (int i=0; i<200; i++) {
Point2D source = new Point2D.Double(random.nextDouble()*100, random.nextDouble()*100);
Point2D expected = warp .mapDestPoint(source);
Point2D computed = adapter.mapDestPoint(source);
assertEquals("X", expected.getX(), computed.getX(), 1E-5);
assertEquals("Y", expected.getY(), computed.getY(), 1E-5);
// Try inverse transform.
expected = warp .mapSourcePoint(source);
computed = adapter.mapSourcePoint(source);
assertEquals("X", expected.getX(), computed.getX(), 1E-5);
assertEquals("Y", expected.getY(), computed.getY(), 1E-5);
// Try warpPoint
final float[] exp = warp .warpPoint((int)source.getX(), (int)source.getY(), null);
final float[] com = adapter.warpPoint((int)source.getX(), (int)source.getY(), null);
assertEquals("X", exp[0], com[0], 1E-5);
assertEquals("Y", exp[1], com[1], 1E-5);
}
}