throw new IllegalArgumentException(JaiI18N.getString("Generic0"));
}
// Get a clone of the context's transform
AffineTransform usr2dev = renderContext.getTransform();
RenderingHints hints = renderContext.getRenderingHints();
int type = usr2dev.getType();
if (type == AffineTransform.TYPE_UNIFORM_SCALE ||
type == AffineTransform.TYPE_GENERAL_SCALE) {
int width = (int)Math.ceil(usr2dev.getScaleX()*getWidth());
int height = (int)Math.ceil(usr2dev.getScaleY()*getHeight());
return createScaledRendering(width, height, hints);
}
// Use the square root of the determinant as an estimate of
// the single-axis scale factor.
int height =
(int)Math.ceil(Math.sqrt(usr2dev.getDeterminant())*getHeight());
int res = numSources - 1;
while (res > 0) {
int imh = renderedSource[res].getHeight();
if (imh >= height) {
break;
}
res--;
}
RenderedImage source = renderedSource[res];
double sx = (double)getWidth()/source.getWidth();
double sy = (double)getHeight()/source.getHeight();
AffineTransform transform = new AffineTransform();
transform.translate(-source.getMinX(), -source.getMinY());
transform.scale(sx, sy);
transform.translate(getMinX(), getMinY());
transform.preConcatenate(usr2dev);
Interpolation interp =
Interpolation.getInstance(Interpolation.INTERP_NEAREST);
if (hints != null) {
Object obj = hints.get(JAI.KEY_INTERPOLATION);
if (obj != null) {
interp = (Interpolation)obj;
}
}