public float distance(double x,double y){
  Shape shape=getShape();
  if (shape != null) {
    return super.distance(x,y);
  }
  float temp, distance=Float.POSITIVE_INFINITY;
  if (getNeedToRegenerate()) {
    return distance;
  }
  float[][] xpts=xpoints;
  float[][] ypts=ypoints;
  float[] _x, _y;
  int len=xpts.length;
  for (int i=0; i < len; i++) {
    _x=xpts[i];
    _y=ypts[i];
    if (isPolygon() && DrawUtil.inside_polygon(_x,_y,x,y))     return 0f;
    temp=DrawUtil.closestPolyDistance(_x,_y,x,y,false);
    if (temp < distance)     distance=temp;
  }
  return normalizeDistanceForLineWidth(distance);
}

public float distance ( double x , double y ) { Shape shape = getShape ( ) ; if ( shape != null ) { return super . distance ( x , y ) ; } float temp , distance = Float . POSITIVE_INFINITY ; if ( getNeedToRegenerate ( ) ) { return distance ; } float [ ] [ ] xpts = xpoints ; float [ ] [ ] ypts = ypoints ; float [ ] _x , _y ; int len = xpts . length ; for ( int i = 0 ; i < len ; i ++ ) { _x = xpts [ i ] ; _y = ypts [ i ] ; if ( isPolygon ( ) && DrawUtil . inside_polygon ( _x , _y , x , y ) ) return 0f ; temp = DrawUtil . closestPolyDistance ( _x , _y , x , y , false ) ; if ( temp < distance ) distance = temp ; } return normalizeDistanceForLineWidth ( distance ) ; }
return the shortest distance from the graphic to an xy - point . this works if generate ( ) has been successful .
