if (property == null ||
property.equals(java.awt.Image.UndefinedProperty) ||
!(property instanceof ROI)) {
return java.awt.Image.UndefinedProperty;
}
ROI srcROI = (ROI)property;
// Retrieve the Interpolation object.
Interpolation interp = (Interpolation)pb.getObjectParameter(4);
// 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());
}
// Set the nearest neighbor interpolation object.
Interpolation interpNN = interp instanceof InterpolationNearest ?
interp :
Interpolation.getInstance(Interpolation.INTERP_NEAREST);
// Retrieve the operation parameters.
float sv = pb.getFloatParameter(0);
EnumeratedParameter shearDir =
(EnumeratedParameter)pb.getObjectParameter(1);
float tx = pb.getFloatParameter(2);
float ty = pb.getFloatParameter(3);
// Create an equivalent transform.
AffineTransform transform =
new AffineTransform(1.0,
shearDir == ShearDescriptor.SHEAR_VERTICAL ? sv : 0,
shearDir == ShearDescriptor.SHEAR_HORIZONTAL ? sv : 0,
1.0,
shearDir == ShearDescriptor.SHEAR_HORIZONTAL ? tx : 0,
shearDir == ShearDescriptor.SHEAR_VERTICAL ? ty : 0);
// Create the sheared ROI.
ROI dstROI = srcROI.transform(transform);
// Retrieve the destination bounds.
Rectangle dstBounds = op.getBounds();
// If necessary, clip the sheared ROI to the destination bounds.
if(!dstBounds.contains(dstROI.getBounds())) {
dstROI = dstROI.intersect(new ROIShape(dstBounds));
}
// Return the sheared and possibly clipped ROI.
return dstROI;
}