int bx = 0;
int by = 0;
int bw = mw;
int bh = mh;
Point2D tl = new Point2D(0, 0);
Point2D tr = new Point2D(mw, 0);
Point2D br = new Point2D(mw, mh);
Point2D bl = new Point2D(0, mh);
int cx = (int) (mw * tcx);
int cy = (int) (mh * tcy);
double rot = rotate.get();
if (rot != 0.0) {
tl = rotatePoint(cx, cy, 0, 0, rot);
tr = rotatePoint(cx, cy, bw, 0, rot);
br = rotatePoint(cx, cy, bw, bh, rot);
bl = rotatePoint(cx, cy, 0, bh, rot);
}
double sx = scaleX.get();
double sy = scaleY.get();
if (sx != 1.0 || sy != 1.0) {
tl = scalePoint(cx, cy, tl.getX(), tl.getY(), sx, sy);
tr = scalePoint(cx, cy, tr.getX(), tr.getY(), sx, sy);
br = scalePoint(cx, cy, br.getX(), br.getY(), sx, sy);
bl = scalePoint(cx, cy, bl.getX(), bl.getY(), sx, sy);
}
int minX = Math.min(Math.min(tl.getX(), tr.getX()), Math.min(br.getX(), bl.getX()));
int minY = Math.min(Math.min(tl.getY(), tr.getY()), Math.min(br.getY(), bl.getY()));
int maxX = Math.max(Math.max(tl.getX(), tr.getX()), Math.max(br.getX(), bl.getX()));
int maxY = Math.max(Math.max(tl.getY(), tr.getY()), Math.max(br.getY(), bl.getY()));
bw = maxX - minX;
bh = maxY - minY;
bx = minX;
by = minY;