A class representing nearest-neighbor interpolation. Since nearest-neighbor interpolation is simply pixel copying, and not really interpolation at all, most code that performs nearest-neighbor sampling will want to use special-purpose code. However, this class is provided both as a way to specify such interpolation, with the consumer making use of 'instanceof' to detect the particular class, and as a way to force general Interpolation users to use nearest-neighbor sampling. Note that this interpolator does not actually select the "nearest" pixel, but only uses the truncated integer pixel location (floor). This is an optimization reflecting an assumption about the implementation of the resampler. It is assumed that the conversion of continuous source image coordinates to discrete pixel indices drops the final subtraction of 0.5 for the case of a nearest-neighbor interpolator.
Neighborhoods of sizes 2x1, 1x2, 2x2, 4x1, 1x4, 4x4, Nx1 and 1xN, that is, all the interpolate() methods defined in the Interpolation class, are supported in the interest of simplifying code that handles a number of types of interpolation. In each case, the central sample is returned and the rest are ignored.
The class is marked 'final' so that it may be more easily inlined.