!(property instanceof ROI)) {
return java.awt.Image.UndefinedProperty;
}
// Return undefined also if source ROI is empty.
ROI srcROI = (ROI)property;
if (srcROI.getBounds().isEmpty()) {
return java.awt.Image.UndefinedProperty;
}
// Retrieve the Interpolation object.
Interpolation interp = (Interpolation)pb.getObjectParameter(1);
// Determine the effective source bounds.
Rectangle srcBounds = null;
PlanarImage dst = op.getRendering();
if (dst instanceof GeometricOpImage &&
((GeometricOpImage)dst).getBorderExtender() == null) {
srcBounds =
new Rectangle(src.getMinX() + interp.getLeftPadding(),
src.getMinY() + interp.getTopPadding(),
src.getWidth() - interp.getWidth() + 1,
src.getHeight() - interp.getHeight() + 1);
} else {
srcBounds = new Rectangle(src.getMinX(),
src.getMinY(),
src.getWidth(),
src.getHeight());
}
// If necessary, clip the ROI to the effective source bounds.
if(!srcBounds.contains(srcROI.getBounds())) {
srcROI = srcROI.intersect(new ROIShape(srcBounds));
}
// Set the nearest neighbor interpolation object.
Interpolation interpNN = interp instanceof InterpolationNearest ?
interp :
Interpolation.getInstance(Interpolation.INTERP_NEAREST);
// Retrieve the Warp object.
Warp warp = (Warp)pb.getObjectParameter(0);
// Create the warped ROI.
ROI dstROI = new ROI(JAI.create("warp", srcROI.getAsImage(),
warp, interpNN));
// Retrieve the destination bounds.
Rectangle dstBounds = op.getBounds();
// If necessary, clip the warped ROI to the destination bounds.
if(!dstBounds.contains(dstROI.getBounds())) {
dstROI = dstROI.intersect(new ROIShape(dstBounds));
}
// Return the warped and possibly clipped ROI.
return dstROI;
}