* (dataX, dataY).
*/
private void findNearestPt(double dataX, double dataY, int datasetIndex,
DistanceFormula df, NearestPoint np) {
MipMap currMipMap = plotRenderer
.getDrawableDataset(datasetIndex).currMipMap;
// Find index of data point closest to the right of dataX at the current MIP level
int closestPtToRight = Util.binarySearch(currMipMap.getDomain(), dataX);
double sx = domainToScreenX(dataX, datasetIndex);
double sy = rangeToScreenY(dataY, datasetIndex);
Tuple2D tupleRight = currMipMap.getTuple(closestPtToRight);
double rx = domainToScreenX(tupleRight.getDomain(), datasetIndex);
double ry = rangeToScreenY(tupleRight, datasetIndex, 0);
int nearestHoverPt;
if (closestPtToRight == 0) {
nearestHoverPt = closestPtToRight;
np.dist = df.dist(sx, sy, rx, ry);
np.dim = 0;
for (int d = 1; d < currMipMap.getRangeTupleSize(); d++) {
double dist2 = df.dist(sx, sy, rx,
rangeToScreenY(tupleRight, datasetIndex, d));
if (dist2 < np.dist) {
np.dist = dist2;
np.dim = d;
}
}
} else {
int closestPtToLeft = closestPtToRight - 1;
Tuple2D tupleLeft = currMipMap.getTuple(closestPtToLeft);
double lx = domainToScreenX(tupleLeft.getDomain(), datasetIndex);
double ly = rangeToScreenY(tupleLeft, datasetIndex, 0);
double lDist = df.dist(sx, sy, lx, ly);
double rDist = df.dist(sx, sy, rx, ry);
np.dim = 0;
if (lDist <= rDist) {
nearestHoverPt = closestPtToLeft;
np.dist = lDist;
} else {
nearestHoverPt = closestPtToRight;
np.dist = rDist;
}
for (int d = 1; d < currMipMap.getRangeTupleSize(); d++) {
lDist = df.dist(sx, sy, lx,
rangeToScreenY(tupleLeft, datasetIndex, d));
rDist = df.dist(sx, sy, rx,
rangeToScreenY(tupleRight, datasetIndex, d));
if (lDist <= rDist && lDist <= np.dist) {