Region { public Number transform(double value, Region region2) { return transform(value, region2, false); } Region();  Region(Number v1, Number v2); static Region withDefaults(Region defaults); void setMinMax(Region region); static Number measure(Number v1, Number v2); Number length(); boolean contains(Number value); boolean intersects(Region region); Number center(); Number transform(double value, Region region2); Number transform(double value, Region region2, boolean flip); double transform(double value, double min, double max, boolean flip); Number ratio(Region r2); double ratio(double min, double max); void union(Number value); void union(Region input); void intersect(Region input); boolean intersects(Number line2Min, Number line2Max); boolean isMinSet(); Number getMin(); void setMin(Number min); boolean isMaxSet(); Number getMax(); void setMax(Number max); boolean isDefined(); @Override String toString();  }
@Test public void testTransform() throws Exception { Region r1 = new Region(1, 2); Region r2 = new Region(0, 10); assertEquals(5.0, r1.transform(1.5, r2)); assertEquals(0.0, r1.transform(1, r2)); assertEquals(10.0, r1.transform(2, r2)); Region r3 = new Region(-10, 10); assertEquals(-10.0, r1.transform(1, r3)); }
@Test public void testTransformWithFlip() throws Exception { Region r1 = new Region(1, 2); Region r2 = new Region(0, 10); assertEquals(5.0, r1.transform(1.5, r2, true)); assertEquals(10.0, r1.transform(1, r2, true)); assertEquals(0.0, r1.transform(2, r2, true)); Region r3 = new Region(-10, 10); assertEquals(10.0, r1.transform(1, r3, true)); }