/** * compare method, is this new plottable nearest than the current one. * * @param newPl the item we're looking at */ private final void compare(final Plottable newPl) { // is it even visible? if (!newPl.getVisible()) return; // calculate the range final double range = newPl.rangeFrom(location); // did it produce a valid range? if (range == Plottable.INVALID_RANGE) { return; } // so, we have a valid range. is it our first? if (distance == Plottable.INVALID_RANGE) { object = newPl; distance = range; } else { if (range < distance) { distance = range; object = newPl; } } }