Program: 87451
Project: 87451
Buggy source:
/** 
 * Lay out the StandaloneViewer windows in a  
 */
private void positionViewers(){
  int borderWidth=10;
  int layerWidth=30;
  int start_cursor_x=(int)windowDimension.getWidth() + borderWidth;
  int start_cursor_y=0;
  frame.setLocation(0,0);
  int screenWidth=java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().width;
  int screenHeight=java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().height;
  int cursor_x=start_cursor_x;
  int cursor_y=start_cursor_y;
  for (  String key : simulation.getDvHM().keySet()) {
    if (simulation.getDvHM().get(key) instanceof StandaloneViewer) {
      StandaloneViewer sViewer=((StandaloneViewer)simulation.getDvHM().get(key));
      if (viewerRects.containsKey(key)) {
        sViewer.setViewerRectangle(viewerRects.get(key));
        sViewer.show();
        continue;
      }
      sViewer.setViewerRectangle(new Rectangle(cursor_x,cursor_y,(int)sViewer.getDimensions().getWidth(),(int)sViewer.getDimensions().getHeight()));
      sViewer.show();
      cursor_y+=sViewer.getDimensions().getHeight() + borderWidth;
      if ((cursor_y + sViewer.getDimensions().getHeight()) > screenHeight - start_cursor_y) {
        cursor_y=start_cursor_y;
        if ((cursor_x + sViewer.getDimensions().getWidth()) > screenWidth - start_cursor_x) {
          start_cursor_y+=layerWidth;
          start_cursor_x+=layerWidth;
          cursor_y=start_cursor_y;
          cursor_x=start_cursor_x;
        }
 else {
          cursor_x+=sViewer.getDimensions().getWidth() + borderWidth;
        }
      }
    }
  }
  frame.setVisible(true);
}

Fixed version (ground truth):
/** 
 * Lay out the StandaloneViewer windows in a  
 */
protected void positionViewers(){
  int borderWidth=10;
  int layerWidth=30;
  int start_cursor_x=(int)windowDimension.getWidth() + borderWidth;
  int start_cursor_y=0;
  frame.setLocation(0,0);
  int screenWidth=java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().width;
  int screenHeight=java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().height;
  int cursor_x=start_cursor_x;
  int cursor_y=start_cursor_y;
  for (  String key : simulation.getDvHM().keySet()) {
    if (simulation.getDvHM().get(key) instanceof StandaloneViewer) {
      StandaloneViewer sViewer=((StandaloneViewer)simulation.getDvHM().get(key));
      if (viewerRects.containsKey(key)) {
        sViewer.setViewerRectangle(viewerRects.get(key));
        sViewer.showWithoutPack();
        continue;
      }
      sViewer.setViewerRectangle(new Rectangle(cursor_x,cursor_y,(int)sViewer.getDimensions().getWidth(),(int)sViewer.getDimensions().getHeight()));
      sViewer.show();
      cursor_y+=sViewer.getDimensions().getHeight() + borderWidth;
      if ((cursor_y + sViewer.getDimensions().getHeight()) > screenHeight - start_cursor_y) {
        cursor_y=start_cursor_y;
        if ((cursor_x + sViewer.getDimensions().getWidth()) > screenWidth - start_cursor_x) {
          start_cursor_y+=layerWidth;
          start_cursor_x+=layerWidth;
          cursor_y=start_cursor_y;
          cursor_x=start_cursor_x;
        }
 else {
          cursor_x+=sViewer.getDimensions().getWidth() + borderWidth;
        }
      }
    }
  }
  frame.setVisible(true);
}