y2 += epsilon;
y2 -= epsilon;
  private int evaluateCrossings(double x, double y, boolean neg,                                boolean useYaxis, double distance)  {    float cx = 0.0f;    float cy = 0.0f;    float firstx = 0.0f;    float firsty = 0.0f;    int negative = (neg) ? -1 : 1;    double x0;    double x1;    double x2;    double x3;    double y0;    double y1;    double y2;    double y3;    double[] r = new double[4];    int nRoots;    double epsilon = 0.0;    int pos = 0;    int windingNumber = 0;    boolean pathStarted = false;    if (index == 0)      return (0);    if (useYaxis)      {	float[] swap1;	swap1 = ypoints;	ypoints = xpoints;	xpoints = swap1;	double swap2;	swap2 = y;	y = x;	x = swap2;      }    /* Get a value which is hopefully small but not insignificant relative     the path. */    epsilon = ypoints[0] * 1E-9;    pos = 0;    while (pos < index)      {	switch (types[pos])	  {	  case PathIterator.SEG_MOVETO:	    if (pathStarted) // close old path	      {		x0 = cx;		y0 = cy;		x1 = firstx;		y1 = firsty;		if (y0 == 0.0)		  y0 += epsilon;		if (y1 == 0.0)		  y1 += epsilon;		if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance,		                          0.0))		  windingNumber += (y1 < y0) ? 1 : negative;		cx = firstx;		cy = firsty;	      }	    cx = firstx = xpoints[pos] - (float) x;	    cy = firsty = ypoints[pos++] - (float) y;	    pathStarted = true;	    break;	  case PathIterator.SEG_CLOSE:	    x0 = cx;	    y0 = cy;	    x1 = firstx;	    y1 = firsty;	    if (y0 == 0.0)	      y0 += epsilon;	    if (y1 == 0.0)	      y1 += epsilon;	    if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0))	      windingNumber += (y1 < y0) ? 1 : negative;	    cx = firstx;	    cy = firsty;	    pos++;	    pathStarted = false;	    break;	  case PathIterator.SEG_LINETO:	    x0 = cx;	    y0 = cy;	    x1 = xpoints[pos] - (float) x;	    y1 = ypoints[pos++] - (float) y;	    if (y0 == 0.0)	      y0 += epsilon;	    if (y1 == 0.0)	      y1 += epsilon;	    if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0))	      windingNumber += (y1 < y0) ? 1 : negative;	    cx = xpoints[pos - 1] - (float) x;	    cy = ypoints[pos - 1] - (float) y;	    break;	  case PathIterator.SEG_QUADTO:	    x0 = cx;	    y0 = cy;	    x1 = xpoints[pos] - x;	    y1 = ypoints[pos++] - y;	    x2 = xpoints[pos] - x;	    y2 = ypoints[pos++] - y;	    /* check if curve may intersect X+ axis. */	    if ((x0 > 0.0 || x1 > 0.0 || x2 > 0.0)	        && (y0 * y1 <= 0 || y1 * y2 <= 0))	      {		if (y0 == 0.0)		  y0 += epsilon;		if (y2 == 0.0)		  y2 += epsilon;		r[0] = y0;		r[1] = 2 * (y1 - y0);		r[2] = (y2 - 2 * y1 + y0);		/* degenerate roots (=tangent points) do not		   contribute to the winding number. */		if ((nRoots = QuadCurve2D.solveQuadratic(r)) == 2)		  for (int i = 0; i < nRoots; i++)		    {		      float t = (float) r[i];		      if (t > 0.0f && t < 1.0f)		        {			  double crossing = t * t * (x2 - 2 * x1 + x0)			                    + 2 * t * (x1 - x0) + x0;			  if (crossing >= 0.0 && crossing <= distance)			    windingNumber += (2 * t * (y2 - 2 * y1 + y0)			                   + 2 * (y1 - y0) < 0) ? 1 : negative;		        }		    }	      }	    cx = xpoints[pos - 1] - (float) x;	    cy = ypoints[pos - 1] - (float) y;	    break;	  case PathIterator.SEG_CUBICTO:	    x0 = cx;	    y0 = cy;	    x1 = xpoints[pos] - x;	    y1 = ypoints[pos++] - y;	    x2 = xpoints[pos] - x;	    y2 = ypoints[pos++] - y;	    x3 = xpoints[pos] - x;	    y3 = ypoints[pos++] - y;	    /* check if curve may intersect X+ axis. */	    if ((x0 > 0.0 || x1 > 0.0 || x2 > 0.0 || x3 > 0.0)	        && (y0 * y1 <= 0 || y1 * y2 <= 0 || y2 * y3 <= 0))	      {		if (y0 == 0.0)		  y0 += epsilon;		if (y3 == 0.0)		  y3 += epsilon;		r[0] = y0;		r[1] = 3 * (y1 - y0);		r[2] = 3 * (y2 + y0 - 2 * y1);		r[3] = y3 - 3 * y2 + 3 * y1 - y0;		if ((nRoots = CubicCurve2D.solveCubic(r)) != 0)		  for (int i = 0; i < nRoots; i++)		    {		      float t = (float) r[i];		      if (t > 0.0 && t < 1.0)		        {			  double crossing = -(t * t * t) * (x0 - 3 * x1			                    + 3 * x2 - x3)			                    + 3 * t * t * (x0 - 2 * x1 + x2)			                    + 3 * t * (x1 - x0) + x0;			  if (crossing >= 0 && crossing <= distance)			    windingNumber += (3 * t * t * (y3 + 3 * y1			                     - 3 * y2 - y0)			                     + 6 * t * (y0 - 2 * y1 + y2)			                   + 3 * (y1 - y0) < 0) ? 1 : negative;		        }		    }	      }	    cx = xpoints[pos - 1] - (float) x;	    cy = ypoints[pos - 1] - (float) y;	    break;	  }      }    // swap coordinates back    if (useYaxis)      {	float[] swap;	swap = ypoints;	ypoints = xpoints;	xpoints = swap;      }    return (windingNumber);	}