Program: 31067
Project: 31067
Buggy source:
/** 
 * This function will be in charge of placing the name of the pin and rotate them accordingly avoid the names being upside down
 * @param painter
 * @param edge
 * @param x
 * @param y
 * @param dx
 * @param dy
 * @param LeftSide
 * @param angle
 */
private static void placePins(InstancePainter painter,Map<Direction,List<Instance>> edge,int x,int y,int width,int height,double angle,Direction facing){
  int ldx=0;
  int ldy=0;
  int maxVert=Math.max(edge.get(Direction.EAST).size(),edge.get(Direction.WEST).size());
  List<Instance> pins_west=edge.get(Direction.WEST);
  List<Instance> pins_east=edge.get(Direction.EAST);
  Font pins_font=DrawAttr.DEFAULT_FIXED_PICH_FONT;
  for (int i=0; i < maxVert; i++) {
    if (pins_east.size() > i) {
      Instance pin_east=pins_east.get(i);
      if (pin_east.getAttributeSet().containsAttribute(StdAttr.LABEL)) {
        Graphics g1=painter.getGraphics().create();
        FontMetrics m=g1.getFontMetrics(pins_font);
        if (Direction.WEST == facing) {
          ldx=20;
          ldy=-(i * (m.getHeight() + 5) - 2);
        }
 else {
          ldx=-m.stringWidth(pin_east.getAttributeValue(StdAttr.LABEL)) - 20;
          ldy=(i * (m.getHeight() + 5) + 5);
        }
        ((Graphics2D)g1).rotate(angle);
        ((Graphics2D)g1).setFont(pins_font);
        ((Graphics2D)g1).drawString(pin_east.getAttributeValue(StdAttr.LABEL),ldx,ldy);
        g1.dispose();
      }
    }
    if (pins_west.size() > i) {
      Instance pin_west=pins_west.get(i);
      if (pin_west.getAttributeSet().containsAttribute(StdAttr.LABEL)) {
        Graphics g1=painter.getGraphics().create();
        FontMetrics m=g1.getFontMetrics(pins_font);
        ((Graphics2D)g1).setFont(pins_font);
        ((Graphics2D)g1).rotate(angle);
        if (Direction.SOUTH == facing) {
          ldx=-height + 20;
          ldy=(i * (m.getHeight() + 5) + 5);
        }
 else         if (Direction.WEST == facing) {
          ldx=width - m.stringWidth(pin_west.getAttributeValue(StdAttr.LABEL)) - 20;
          ldy=-(i * (m.getHeight() + 5) - 2);
          System.out.println("String_Node_Str" + ldx + "String_Node_Str"+ ldy);
        }
 else         if (Direction.EAST == facing) {
          ldx=-width + 20;
          ldy=(i * (m.getHeight() + 5) + 5);
        }
 else         if (Direction.NORTH == facing) {
          ldx=-height + 20;
          ldy=(i * (m.getHeight() + 5) + 5);
        }
        ((Graphics2D)g1).drawString(pin_west.getAttributeValue(StdAttr.LABEL),ldx,ldy);
        g1.dispose();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * This function will be in charge of placing the name of the pin and rotate them accordingly avoid the names being upside down
 * @param painter
 * @param edge
 * @param x
 * @param y
 * @param dx
 * @param dy
 * @param LeftSide
 * @param angle
 */
private static void placePins(InstancePainter painter,Map<Direction,List<Instance>> edge,int x,int y,int width,int height,double angle,Direction facing){
  int ldx=0;
  int ldy=0;
  int maxVert=Math.max(edge.get(Direction.EAST).size(),edge.get(Direction.WEST).size());
  List<Instance> pins_west=edge.get(Direction.WEST);
  List<Instance> pins_east=edge.get(Direction.EAST);
  Font pins_font=DrawAttr.DEFAULT_FIXED_PICH_FONT;
  for (int i=0; i < maxVert; i++) {
    if (pins_east.size() > i) {
      Instance pin_east=pins_east.get(i);
      if (pin_east.getAttributeSet().containsAttribute(StdAttr.LABEL)) {
        Graphics g1=painter.getGraphics().create();
        FontMetrics m=g1.getFontMetrics(pins_font);
        if (Direction.WEST == facing) {
          ldx=20;
          ldy=-(i * (m.getHeight() + 5) - 2);
        }
 else {
          ldx=-m.stringWidth(pin_east.getAttributeValue(StdAttr.LABEL)) - 20;
          ldy=(i * (m.getHeight() + 5) + 5);
        }
        ((Graphics2D)g1).rotate(angle);
        ((Graphics2D)g1).setFont(pins_font);
        ((Graphics2D)g1).drawString(pin_east.getAttributeValue(StdAttr.LABEL),ldx,ldy);
        g1.dispose();
      }
    }
    if (pins_west.size() > i) {
      Instance pin_west=pins_west.get(i);
      if (pin_west.getAttributeSet().containsAttribute(StdAttr.LABEL)) {
        Graphics g1=painter.getGraphics().create();
        FontMetrics m=g1.getFontMetrics(pins_font);
        ((Graphics2D)g1).setFont(pins_font);
        ((Graphics2D)g1).rotate(angle);
        if (Direction.SOUTH == facing) {
          ldx=-height + 20;
          ldy=(i * (m.getHeight() + 5) + 5);
        }
 else         if (Direction.WEST == facing) {
          ldx=width - m.stringWidth(pin_west.getAttributeValue(StdAttr.LABEL)) - 20;
          ldy=-(i * (m.getHeight() + 5) - 2);
        }
 else         if (Direction.EAST == facing) {
          ldx=-width + 20;
          ldy=(i * (m.getHeight() + 5) + 5);
        }
 else         if (Direction.NORTH == facing) {
          ldx=-height + 20;
          ldy=(i * (m.getHeight() + 5) + 5);
        }
        ((Graphics2D)g1).drawString(pin_west.getAttributeValue(StdAttr.LABEL),ldx,ldy);
        g1.dispose();
      }
    }
  }
}