Program: 73134
Project: 73134
Buggy source:
/** 
 * Route the given connector, returning a Polyline2D. This method is the same as route(), except that the return type is tighter.
 */
public Polyline2D routeManhattan(ManhattanConnector c){
  TransformContext currentContext=c.getTransformContext();
  Site headSite=c.getHeadSite();
  Site tailSite=c.getTailSite();
  Point2D headPt;
  Point2D tailPt;
  if (currentContext == null) {
    return new Polyline2D.Double();
  }
  tailPt=tailSite.getPoint(currentContext);
  headPt=headSite.getPoint(currentContext);
  double radAngle=Math.atan2(tailPt.getY() - headPt.getY(),headPt.getX() - tailPt.getX());
  double distance=tailPt.distance(headPt);
  int headDir=_getManhattanDirection(radAngle,distance,true,headSite.hasNormal() ? CanvasUtilities.getDirection(headSite.getNormal()) : -1);
  headSite.setNormal(CanvasUtilities.getNormal(headDir));
  headPt=headSite.getPoint(currentContext);
  int tailDir=_getManhattanDirection(radAngle,distance,false,tailSite.hasNormal() ? CanvasUtilities.getDirection(tailSite.getNormal()) : -1);
  tailSite.setNormal(CanvasUtilities.getNormal(tailDir));
  tailPt=tailSite.getPoint(currentContext);
  headDir=CanvasUtilities.getDirection(headSite.getNormal());
  tailDir=CanvasUtilities.getDirection(tailSite.getNormal());
  double headAngle=CanvasUtilities.getNormal(headDir);
  double tailAngle=CanvasUtilities.getNormal(tailDir);
  if (c.getHeadEnd() != null) {
    c.getHeadEnd().setNormal(headAngle);
    c.getHeadEnd().setOrigin(headPt.getX(),headPt.getY());
    c.getHeadEnd().getConnection(headPt);
  }
  if (c.getTailEnd() != null) {
    c.getTailEnd().setNormal(tailAngle);
    c.getTailEnd().setOrigin(tailPt.getX(),tailPt.getY());
    c.getTailEnd().getConnection(tailPt);
  }
  Polyline2D route=_route(headPt,headDir,tailPt,tailDir);
  return route;
}

Fixed version (ground truth):
/** 
 * Route the given connector, returning a Polyline2D. This method is the same as route(), except that the return type is tighter.
 */
public Polyline2D routeManhattan(ManhattanConnector c){
  TransformContext currentContext=c.getTransformContext();
  Site headSite=c.getHeadSite();
  Site tailSite=c.getTailSite();
  Point2D headPt;
  Point2D tailPt;
  if (currentContext == null) {
    tailPt=tailSite.getPoint();
    headPt=headSite.getPoint();
    Polyline2D.Double polyline=new Polyline2D.Double();
    polyline.moveTo(tailPt.getX(),tailPt.getY());
    polyline.lineTo(headPt.getX(),headPt.getY());
    return polyline;
  }
 else {
    tailPt=tailSite.getPoint(currentContext);
    headPt=headSite.getPoint(currentContext);
  }
  double radAngle=Math.atan2(tailPt.getY() - headPt.getY(),headPt.getX() - tailPt.getX());
  double distance=tailPt.distance(headPt);
  int headDir=_getManhattanDirection(radAngle,distance,true,headSite.hasNormal() ? CanvasUtilities.getDirection(headSite.getNormal()) : -1);
  headSite.setNormal(CanvasUtilities.getNormal(headDir));
  headPt=headSite.getPoint(currentContext);
  int tailDir=_getManhattanDirection(radAngle,distance,false,tailSite.hasNormal() ? CanvasUtilities.getDirection(tailSite.getNormal()) : -1);
  tailSite.setNormal(CanvasUtilities.getNormal(tailDir));
  tailPt=tailSite.getPoint(currentContext);
  headDir=CanvasUtilities.getDirection(headSite.getNormal());
  tailDir=CanvasUtilities.getDirection(tailSite.getNormal());
  double headAngle=CanvasUtilities.getNormal(headDir);
  double tailAngle=CanvasUtilities.getNormal(tailDir);
  if (c.getHeadEnd() != null) {
    c.getHeadEnd().setNormal(headAngle);
    c.getHeadEnd().setOrigin(headPt.getX(),headPt.getY());
    c.getHeadEnd().getConnection(headPt);
  }
  if (c.getTailEnd() != null) {
    c.getTailEnd().setNormal(tailAngle);
    c.getTailEnd().setOrigin(tailPt.getX(),tailPt.getY());
    c.getTailEnd().getConnection(tailPt);
  }
  Polyline2D route=_route(headPt,headDir,tailPt,tailDir);
  return route;
}