protected OMDist<T> findClosestTest(OMDist<T> current,int index,OMGeometry graphic,double x,double y,float limit,boolean resetSelect){
  if (current == null) {
    current=createDist();
  }
  OMList<? extends OMGeometry> omgl;
  float currentDistance=Float.MAX_VALUE;
  if (!shouldProcess(graphic)) {
    return current;
  }
  if (graphic instanceof OMList<?>) {
    omgl=(OMList<T>)graphic;
    OMDist<T> dist=(OMDist<T>)omgl.findClosest(x,y,limit,resetSelect);
    if (dist.omg != null) {
      currentDistance=dist.d;
      graphic=dist.omg;
    }
  }
 else {
    if (resetSelect)     graphic.deselect();
    currentDistance=graphic.distance(x,y);
  }
  if (currentDistance < limit && currentDistance < current.d) {
    if (!isVague()) {
      current.omg=(T)graphic;
    }
 else {
      current.omg=(T)this;
    }
    current.index=index;
    current.d=currentDistance;
  }
  return current;
}

protected OMDist < T > findClosestTest ( OMDist < T > current , int index , OMGeometry graphic , double x , double y , float limit , boolean resetSelect ) { if ( current == null ) { current = createDist ( ) ; } OMList < ? extends OMGeometry > omgl ; float currentDistance = Float . MAX_VALUE ; if ( ! shouldProcess ( graphic ) ) { return current ; } if ( graphic instanceof OMList < ? > ) { omgl = ( OMList < T > ) graphic ; OMDist < T > dist = ( OMDist < T > ) omgl . findClosest ( x , y , limit , resetSelect ) ; if ( dist . omg != null ) { currentDistance = dist . d ; graphic = dist . omg ; } } else { if ( resetSelect ) graphic . deselect ( ) ; currentDistance = graphic . distance ( x , y ) ; } if ( currentDistance < limit && currentDistance < current . d ) { if ( ! isVague ( ) ) { current . omg = ( T ) graphic ; } else { current . omg = ( T ) this ; } current . index = index ; current . d = currentDistance ; } return current ; }
test the graphic distance away from the x , y point , and compare it to the current omdist passed in . if the graphic is the new closest , return the same omdist object filled in with the new value . otherwise , return null .
