Program: 31097
Project: 31097
Buggy source:
void draw(ComponentDrawContext context,Collection<Component> hidden){
  boolean showState=context.getShowState();
  CircuitState state=context.getCircuitState();
  Graphics g=context.getGraphics();
  g.setColor(Color.BLACK);
  GraphicsUtil.switchToWidth(g,Wire.WIDTH);
  WireSet highlighted=context.getHighlightedWires();
  BundleMap bmap=getBundleMap();
  boolean isValid=bmap.isValid();
  if (hidden == null || hidden.size() == 0) {
    for (    Wire w : wires) {
      Location s=w.e0;
      Location t=w.e1;
      WireBundle wb=bmap.getBundleAt(s);
      if (!wb.isValid()) {
        g.setColor(Value.WIDTH_ERROR_COLOR);
      }
 else       if (showState) {
        if (!isValid)         g.setColor(Value.NIL_COLOR);
 else         g.setColor(state.getValue(s).getColor());
      }
 else {
        g.setColor(Color.BLACK);
      }
      if (highlighted.containsWire(w)) {
        int width;
        if (wb.isBus())         width=Wire.HIGHLIGHTED_WIDTH_BUS;
 else         width=Wire.HIGHLIGHTED_WIDTH;
        GraphicsUtil.switchToWidth(g,width);
        g.drawLine(s.getX(),s.getY(),t.getX(),t.getY());
      }
 else {
        int width;
        if (wb.isBus())         width=Wire.WIDTH_BUS;
 else         width=Wire.WIDTH;
        GraphicsUtil.switchToWidth(g,width);
        g.drawLine(s.getX(),s.getY(),t.getX(),t.getY());
      }
    }
    for (    Location loc : points.getSplitLocations()) {
      if (points.getComponentCount(loc) > 2) {
        WireBundle wb=bmap.getBundleAt(loc);
        if (wb != null) {
          if (!wb.isValid()) {
            g.setColor(Value.WIDTH_ERROR_COLOR);
          }
 else           if (showState) {
            if (!isValid)             g.setColor(Value.NIL_COLOR);
 else             g.setColor(state.getValue(loc).getColor());
          }
 else {
            g.setColor(Color.BLACK);
          }
          int radius;
          if (highlighted.containsLocation(loc)) {
            radius=wb.isBus() ? Wire.HIGHLIGHTED_WIDTH_BUS : Wire.HIGHLIGHTED_WIDTH;
          }
 else {
            radius=wb.isBus() ? Wire.WIDTH_BUS : Wire.WIDTH;
          }
          g.fillOval(loc.getX() - radius,loc.getY() - radius,radius * 2,radius * 2);
        }
      }
    }
  }
 else {
    for (    Wire w : wires) {
      if (!hidden.contains(w)) {
        Location s=w.e0;
        Location t=w.e1;
        WireBundle wb=bmap.getBundleAt(s);
        if (!wb.isValid()) {
          g.setColor(Value.WIDTH_ERROR_COLOR);
        }
 else         if (showState) {
          if (!isValid)           g.setColor(Value.NIL_COLOR);
 else           g.setColor(state.getValue(s).getColor());
        }
 else {
          g.setColor(Color.BLACK);
        }
        if (highlighted.containsWire(w)) {
          GraphicsUtil.switchToWidth(g,Wire.WIDTH + 2);
          g.drawLine(s.getX(),s.getY(),t.getX(),t.getY());
          GraphicsUtil.switchToWidth(g,Wire.WIDTH);
        }
 else {
          if (wb.isBus())           GraphicsUtil.switchToWidth(g,Wire.WIDTH_BUS);
 else           GraphicsUtil.switchToWidth(g,Wire.WIDTH);
          g.drawLine(s.getX(),s.getY(),t.getX(),t.getY());
        }
      }
    }
    for (    Location loc : points.getSplitLocations()) {
      if (points.getComponentCount(loc) > 2) {
        int icount=0;
        for (        Component comp : points.getComponents(loc)) {
          if (!hidden.contains(comp))           ++icount;
        }
        if (icount > 2) {
          WireBundle wb=bmap.getBundleAt(loc);
          if (wb != null) {
            if (!wb.isValid()) {
              g.setColor(Value.WIDTH_ERROR_COLOR);
            }
 else             if (showState) {
              if (!isValid)               g.setColor(Value.NIL_COLOR);
 else               g.setColor(state.getValue(loc).getColor());
            }
 else {
              g.setColor(Color.BLACK);
            }
            int radius;
            if (highlighted.containsLocation(loc)) {
              radius=wb.isBus() ? Wire.HIGHLIGHTED_WIDTH_BUS : Wire.HIGHLIGHTED_WIDTH;
            }
 else {
              radius=wb.isBus() ? Wire.WIDTH_BUS : Wire.WIDTH;
            }
            g.fillOval(loc.getX() - radius,loc.getY() - radius,radius * 2,radius * 2);
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
void draw(ComponentDrawContext context,Collection<Component> hidden){
  boolean showState=context.getShowState();
  CircuitState state=context.getCircuitState();
  Graphics g=context.getGraphics();
  g.setColor(Color.BLACK);
  GraphicsUtil.switchToWidth(g,Wire.WIDTH);
  WireSet highlighted=context.getHighlightedWires();
  BundleMap bmap=getBundleMap();
  boolean isValid=bmap.isValid();
  if (hidden == null || hidden.size() == 0) {
    for (    Wire w : wires) {
      Location s=w.e0;
      Location t=w.e1;
      WireBundle wb=bmap.getBundleAt(s);
      if (!wb.isValid()) {
        g.setColor(Value.WIDTH_ERROR_COLOR);
      }
 else       if (showState) {
        if (!isValid)         g.setColor(Value.NIL_COLOR);
 else         g.setColor(state.getValue(s).getColor());
      }
 else {
        g.setColor(Color.BLACK);
      }
      if (highlighted.containsWire(w)) {
        int width;
        if (wb.isBus())         width=Wire.HIGHLIGHTED_WIDTH_BUS;
 else         width=Wire.HIGHLIGHTED_WIDTH;
        GraphicsUtil.switchToWidth(g,width);
        g.drawLine(s.getX(),s.getY(),t.getX(),t.getY());
      }
 else {
        int width;
        if (wb.isBus())         width=Wire.WIDTH_BUS;
 else         width=Wire.WIDTH;
        GraphicsUtil.switchToWidth(g,width);
        g.drawLine(s.getX(),s.getY(),t.getX(),t.getY());
      }
    }
    for (    Location loc : points.getSplitLocations()) {
      if (points.getComponentCount(loc) > 2) {
        WireBundle wb=bmap.getBundleAt(loc);
        if (wb != null) {
          if (!wb.isValid()) {
            g.setColor(Value.WIDTH_ERROR_COLOR);
          }
 else           if (showState) {
            if (!isValid)             g.setColor(Value.NIL_COLOR);
 else             g.setColor(state.getValue(loc).getColor());
          }
 else {
            g.setColor(Color.BLACK);
          }
          int radius;
          if (highlighted.containsLocation(loc)) {
            radius=wb.isBus() ? (int)(Wire.HIGHLIGHTED_WIDTH_BUS * Wire.DOT_MULTIPLY_FACTOR) : (int)(Wire.HIGHLIGHTED_WIDTH * Wire.DOT_MULTIPLY_FACTOR);
          }
 else {
            radius=wb.isBus() ? (int)(Wire.WIDTH_BUS * Wire.DOT_MULTIPLY_FACTOR) : (int)(Wire.WIDTH * Wire.DOT_MULTIPLY_FACTOR);
          }
          g.fillOval(loc.getX() - radius,loc.getY() - radius,radius * 2,radius * 2);
        }
      }
    }
  }
 else {
    for (    Wire w : wires) {
      if (!hidden.contains(w)) {
        Location s=w.e0;
        Location t=w.e1;
        WireBundle wb=bmap.getBundleAt(s);
        if (!wb.isValid()) {
          g.setColor(Value.WIDTH_ERROR_COLOR);
        }
 else         if (showState) {
          if (!isValid)           g.setColor(Value.NIL_COLOR);
 else           g.setColor(state.getValue(s).getColor());
        }
 else {
          g.setColor(Color.BLACK);
        }
        if (highlighted.containsWire(w)) {
          GraphicsUtil.switchToWidth(g,Wire.WIDTH + 2);
          g.drawLine(s.getX(),s.getY(),t.getX(),t.getY());
          GraphicsUtil.switchToWidth(g,Wire.WIDTH);
        }
 else {
          if (wb.isBus())           GraphicsUtil.switchToWidth(g,Wire.WIDTH_BUS);
 else           GraphicsUtil.switchToWidth(g,Wire.WIDTH);
          g.drawLine(s.getX(),s.getY(),t.getX(),t.getY());
        }
      }
    }
    for (    Location loc : points.getSplitLocations()) {
      if (points.getComponentCount(loc) > 2) {
        int icount=0;
        for (        Component comp : points.getComponents(loc)) {
          if (!hidden.contains(comp))           ++icount;
        }
        if (icount > 2) {
          WireBundle wb=bmap.getBundleAt(loc);
          if (wb != null) {
            if (!wb.isValid()) {
              g.setColor(Value.WIDTH_ERROR_COLOR);
            }
 else             if (showState) {
              if (!isValid)               g.setColor(Value.NIL_COLOR);
 else               g.setColor(state.getValue(loc).getColor());
            }
 else {
              g.setColor(Color.BLACK);
            }
            int radius;
            if (highlighted.containsLocation(loc)) {
              radius=wb.isBus() ? Wire.HIGHLIGHTED_WIDTH_BUS : Wire.HIGHLIGHTED_WIDTH;
            }
 else {
              radius=wb.isBus() ? Wire.WIDTH_BUS : Wire.WIDTH;
            }
            g.fillOval(loc.getX() - radius,loc.getY() - radius,radius * 2,radius * 2);
          }
        }
      }
    }
  }
}