RectangleF { public RectangleF translate(RectangleF src, RectangleF dest) { update( translate(x, src.x, src.x+src.width, dest.x, dest.x+dest.width), translate(y, src.y, src.y+src.height, dest.y, dest.y+dest.height), translate(width, src.x, src.x+src.width, dest.x, dest.x+dest.width), translate(height, src.y, src.y+src.height, dest.y, dest.y+dest.height)); return this; } RectangleF(float x, float y, float width, float height);  RectangleF(); boolean update(float x, float y, float w, float h); RectangleF copy(); Rectangle asIntRect(); RectangleF translateImmutable(RectangleF src, RectangleF dest); RectangleF translate(RectangleF src, RectangleF dest); RectangleF aspectRatioScale(RectangleF dest); RectangleF aspectRatioScaleImmutable(RectangleF dest); RectangleF scale(float scale); RectangleF scaleImmutable(float scale); RectangleF centerImmutable(RectangleF dest); RectangleF center(RectangleF dest); @Override String toString(); DimensionF getDimension(); @Override boolean equals(Object o); @Override int hashCode(); boolean update(RectangleF srcRect); boolean update(Rectangle srcRect); float getAR(); RectangleF position(int x, int y); RectangleF updateHeightUsingAspectRatio(float ar); RectangleF updateWidthUsingAspectRatio(float ar); public float x; public float y; public float width; public float height; }
@Test public void testTranslate() throws Exception { RectangleF r = new RectangleF(10,10,90,90); Rectangle test = r.translateImmutable(new RectangleF(0,0,100,100), new RectangleF(0,0,10,10)).asIntRect(); assertEquals(1, test.x); assertEquals(1, test.y); assertEquals(9, test.width); assertEquals(9, test.height); }