/**
* Gets the bounding box for the output of <code>AffineOpImage</code>.
* This method satisfies the implementation of CRIF.
*/
public Rectangle2D getBounds2D(ParameterBlock paramBlock) {
RenderableImage source = paramBlock.getRenderableSource(0);
Object arg0 = paramBlock.getObjectParameter(0);
AffineTransform forward_tr = (AffineTransform)arg0;
Object arg1 = paramBlock.getObjectParameter(1);
Interpolation interp = (Interpolation)arg1;
// Get the affine transform
double tr[];
tr = new double[6];
forward_tr.getMatrix(tr);
//
// Check and see if the affine transform is doing a copy.
//
if ((tr[0] == 1.0) &&
(tr[3] == 1.0) &&
(tr[2] == 0.0) &&
(tr[1] == 0.0) &&
(tr[4] == 0.0) &&
(tr[5] == 0.0)) {
return new Rectangle2D.Float(source.getMinX(),
source.getMinY(),
source.getWidth(),
source.getHeight());
}
//
// Check and see if the affine transform is in fact doing
// a Translate operation.
//
if ((tr[0] == 1.0) &&
(tr[3] == 1.0) &&
(tr[2] == 0.0) &&
(tr[1] == 0.0) &&
(Math.abs(tr[4] - (int) tr[4]) < TOLERANCE) &&
(Math.abs(tr[5] - (int) tr[5]) < TOLERANCE)) {
return new Rectangle2D.Float(source.getMinX() + (float)tr[4],
source.getMinY() + (float)tr[5],
source.getWidth(),
source.getHeight());
}
//
// Check and see if the affine transform is in fact doing
// a Scale operation.
//
if ((tr[0] > 0.0) &&
(tr[2] == 0.0) &&
(tr[1] == 0.0) &&
(tr[3] > 0.0)) {
// Get the source dimensions
float x0 = (float)source.getMinX();
float y0 = (float)source.getMinY() ;
float w = (float)source.getWidth();
float h = (float)source.getHeight();
// Forward map the source using x0, y0, w and h
float d_x0 = x0 * (float)tr[0] + (float)tr[4];
float d_y0 = y0 * (float)tr[3] + (float)tr[5];
float d_w = w * (float)tr[0];
float d_h = h * (float)tr[3];
return new Rectangle2D.Float(d_x0,
d_y0,
d_w,
d_h);
}
// It's an Affine
//
// Get sx0,sy0 coordinates and width & height of the source
//
float sx0 = (float) source.getMinX();
float sy0 = (float) source.getMinY();
float sw = (float) source.getWidth();
float sh = (float) source.getHeight();
//
// The 4 points (clockwise order) are
// (sx0, sy0), (sx0+sw, sy0)
// (sx0, sy0+sh), (sx0+sw, sy0+sh)