Program: 170464
Project: 170464
Buggy source:
private int getIndexForSelectedSegment(final int mouseX,final int mouseY,final Point2DArray oldPoints){
  NFastStringMap<Integer> colorMap=new NFastStringMap<Integer>();
  AbstractDirectionalMultiPointShape<?> line=m_connector.getLine();
  ScratchPad scratch=line.getScratchPad();
  scratch.clear();
  PathPartList path=line.getPathPartList();
  int pointsIndex=1;
  String color=MagnetManager.m_c_rotor.next();
  colorMap.put(color,pointsIndex);
  Context2D ctx=scratch.getContext();
  double strokeWidth=line.getStrokeWidth();
  ctx.setStrokeWidth(strokeWidth);
  Point2D absolutePos=WiresUtils.getLocation(m_connector.getLine());
  double offsetX=absolutePos.getX();
  double offsetY=absolutePos.getY();
  Point2D pathStart=new Point2D(offsetX,offsetY);
  Point2D segmentStart=pathStart;
  for (int i=0; i < path.size(); i++) {
    PathPartEntryJSO entry=path.get(i);
    NFastDoubleArrayJSO points=entry.getPoints();
switch (entry.getCommand()) {
case PathPartEntryJSO.MOVETO_ABSOLUTE:
{
        double x0=points.get(0) + offsetX;
        double y0=points.get(1) + offsetY;
        Point2D m=new Point2D(x0,y0);
        if (i == 0) {
          pathStart=m;
        }
        segmentStart=m;
        break;
      }
case PathPartEntryJSO.LINETO_ABSOLUTE:
{
      points=entry.getPoints();
      double x0=points.get(0) + offsetX;
      double y0=points.get(1) + offsetY;
      Point2D end=new Point2D(x0,y0);
      if (oldPoints.get(pointsIndex).equals(segmentStart)) {
        pointsIndex++;
        color=MagnetManager.m_c_rotor.next();
        colorMap.put(color,pointsIndex);
      }
      ctx.setStrokeColor(color);
      ctx.beginPath();
      ctx.moveTo(segmentStart.getX(),segmentStart.getY());
      ctx.lineTo(x0,y0);
      ctx.stroke();
      segmentStart=end;
      break;
    }
case PathPartEntryJSO.CLOSE_PATH_PART:
{
    double x0=pathStart.getX() + offsetX;
    double y0=pathStart.getY() + offsetY;
    Point2D end=new Point2D(x0,y0);
    if (oldPoints.get(pointsIndex).equals(segmentStart)) {
      pointsIndex++;
      color=MagnetManager.m_c_rotor.next();
      colorMap.put(color,pointsIndex);
    }
    ctx.setStrokeColor(color);
    ctx.beginPath();
    ctx.moveTo(segmentStart.getX(),segmentStart.getY());
    ctx.lineTo(x0,y0);
    ctx.stroke();
    segmentStart=end;
    break;
  }
case PathPartEntryJSO.CANVAS_ARCTO_ABSOLUTE:
{
  points=entry.getPoints();
  double x0=points.get(0) + offsetX;
  double y0=points.get(1) + offsetY;
  Point2D p0=new Point2D(x0,y0);
  double x1=points.get(2) + offsetX;
  double y1=points.get(3) + offsetY;
  double r=points.get(4);
  Point2D p1=new Point2D(x1,y1);
  Point2D end=p1;
  if (p0.equals(oldPoints.get(pointsIndex))) {
    pointsIndex++;
    color=MagnetManager.m_c_rotor.next();
    colorMap.put(color,pointsIndex);
  }
  ctx.setStrokeColor(color);
  ctx.beginPath();
  ctx.moveTo(segmentStart.getX(),segmentStart.getY());
  ctx.arcTo(x0,y0,x1,y1,r);
  ctx.stroke();
  segmentStart=end;
  break;
}
}
}
BoundingBox box=m_connector.getLine().getBoundingBox();
int sx=(int)(box.getX() - strokeWidth - offsetX);
int sy=(int)(box.getY() - strokeWidth - offsetY);
ImageData backing=ctx.getImageData(sx,sy,(int)(box.getWidth() + strokeWidth + strokeWidth),(int)(box.getHeight() + strokeWidth + strokeWidth));
color=BackingColorMapUtils.findColorAtPoint(backing,mouseX - sx,mouseY - sy);
pointsIndex=colorMap.get(color);
return pointsIndex;
}

Fixed version (ground truth):
private int getIndexForSelectedSegment(final int mouseX,final int mouseY,final Point2DArray oldPoints){
  NFastStringMap<Integer> colorMap=new NFastStringMap<Integer>();
  AbstractDirectionalMultiPointShape<?> line=m_connector.getLine();
  ScratchPad scratch=line.getScratchPad();
  scratch.clear();
  PathPartList path=line.getPathPartList();
  int pointsIndex=1;
  String color=MagnetManager.m_c_rotor.next();
  colorMap.put(color,pointsIndex);
  Context2D ctx=scratch.getContext();
  double strokeWidth=line.getStrokeWidth();
  ctx.setStrokeWidth(strokeWidth);
  Point2D absolutePos=WiresUtils.getLocation(m_connector.getLine());
  double offsetX=absolutePos.getX();
  double offsetY=absolutePos.getY();
  Point2D pathStart=new Point2D(offsetX,offsetY);
  Point2D segmentStart=pathStart;
  for (int i=0; i < path.size(); i++) {
    PathPartEntryJSO entry=path.get(i);
    NFastDoubleArrayJSO points=entry.getPoints();
switch (entry.getCommand()) {
case PathPartEntryJSO.MOVETO_ABSOLUTE:
{
        double x0=points.get(0) + offsetX;
        double y0=points.get(1) + offsetY;
        Point2D m=new Point2D(x0,y0);
        if (i == 0) {
          pathStart=m;
        }
        segmentStart=m;
        break;
      }
case PathPartEntryJSO.LINETO_ABSOLUTE:
{
      points=entry.getPoints();
      double x0=points.get(0) + offsetX;
      double y0=points.get(1) + offsetY;
      Point2D end=new Point2D(x0,y0);
      if (oldPoints.get(pointsIndex).equals(segmentStart)) {
        pointsIndex++;
        color=MagnetManager.m_c_rotor.next();
        colorMap.put(color,pointsIndex);
      }
      ctx.setStrokeColor(color);
      ctx.beginPath();
      ctx.moveTo(segmentStart.getX(),segmentStart.getY());
      ctx.lineTo(x0,y0);
      ctx.stroke();
      segmentStart=end;
      break;
    }
case PathPartEntryJSO.CLOSE_PATH_PART:
{
    double x0=pathStart.getX() + offsetX;
    double y0=pathStart.getY() + offsetY;
    Point2D end=new Point2D(x0,y0);
    if (oldPoints.get(pointsIndex).equals(segmentStart)) {
      pointsIndex++;
      color=MagnetManager.m_c_rotor.next();
      colorMap.put(color,pointsIndex);
    }
    ctx.setStrokeColor(color);
    ctx.beginPath();
    ctx.moveTo(segmentStart.getX(),segmentStart.getY());
    ctx.lineTo(x0,y0);
    ctx.stroke();
    segmentStart=end;
    break;
  }
case PathPartEntryJSO.CANVAS_ARCTO_ABSOLUTE:
{
  points=entry.getPoints();
  double x0=points.get(0) + offsetX;
  double y0=points.get(1) + offsetY;
  Point2D p0=new Point2D(x0,y0);
  double x1=points.get(2) + offsetX;
  double y1=points.get(3) + offsetY;
  double r=points.get(4);
  Point2D p1=new Point2D(x1,y1);
  Point2D end=p1;
  if (p0.equals(oldPoints.get(pointsIndex))) {
    pointsIndex++;
    color=MagnetManager.m_c_rotor.next();
    colorMap.put(color,pointsIndex);
  }
  ctx.setStrokeColor(color);
  ctx.beginPath();
  ctx.moveTo(segmentStart.getX(),segmentStart.getY());
  ctx.arcTo(x0,y0,x1,y1,r);
  ctx.stroke();
  segmentStart=end;
  break;
}
}
}
BoundingBox box=m_connector.getLine().getBoundingBox();
int sx=(int)(box.getX() - strokeWidth - offsetX);
int sy=(int)(box.getY() - strokeWidth - offsetY);
ImageData backing=ctx.getImageData(sx,sy,(int)(box.getWidth() + strokeWidth + strokeWidth),(int)(box.getHeight() + strokeWidth + strokeWidth));
color=BackingColorMapUtils.findColorAtPoint(backing,mouseX - sx,mouseY - sy);
return null != color ? colorMap.get(color) : -1;
}