Program: 70263
Project: 70263
Buggy source:
/** 
 * Draws background image in a rectangle area with specified repeat pattern. <br> <br> The repeat mode can be: <table border="solid"> <tr> <td align="center"><B>Name</td> <td align="center"><B>What for</td> </tr> <tr> <td>no-repeat</td> <td>Don't repeat.</td> </tr> <tr> <td>repeat-x</td> <td>Only repeat on x orientation.</td> </tr> <tr> <td>repeat-y</td> <td>Only repeat on y orientation.</td> </tr> <tr> <td>repeat</td> <td>Repeat on x and y orientation.</td> </tr> </table>
 * @param imageURI the uri of the background image.
 * @param x the x coordinate of the rectangle area.
 * @param y the y coordinate of the rectangle area.
 * @param width the width of the rectangle area.
 * @param height the height of the rectangle area.
 * @param positionX the initial x position of the background image.
 * @param positionY the initial y position of the background image.
 * @param repeat the repeat mode.
 * @throws Exception 
 */
public void drawBackgroundImage(String imageURI,float x,float y,float width,float height,float positionX,float positionY,int repeat) throws IOException {
  URL url=new URL(imageURI);
  InputStream imageStream=null;
  try {
    imageStream=url.openStream();
    Image image=ImageIO.read(imageStream);
    ImageIcon imageIcon=new ImageIcon(image);
    Position imageSize=new Position(imageIcon.getIconWidth(),imageIcon.getIconHeight());
    Position areaPosition=new Position(x,y);
    Position areaSize=new Position(width,height);
    Position imagePosition=new Position(x + positionX,y + positionY);
    BackgroundImageLayout layout=new BackgroundImageLayout(areaPosition,areaSize,imagePosition,imageSize);
    Collection positions=layout.getImagePositions(repeat);
    gSave();
    setColor(Color.WHITE);
    out.println("String_Node_Str");
    drawRawRect(x,y,width,height);
    out.println("String_Node_Str");
    Iterator iterator=positions.iterator();
    while (iterator.hasNext()) {
      Position position=(Position)iterator.next();
      drawImage(imageURI,image,position.getX(),position.getY(),imageSize.getX(),imageSize.getY());
    }
    gRestore();
  }
  finally {
    if (imageStream != null) {
      imageStream.close();
      imageStream=null;
    }
  }
}

Fixed version (ground truth):
/** 
 * Draws background image in a rectangle area with specified repeat pattern. <br> <br> The repeat mode can be: <table border="solid"> <tr> <td align="center"><B>Name</td> <td align="center"><B>What for</td> </tr> <tr> <td>no-repeat</td> <td>Don't repeat.</td> </tr> <tr> <td>repeat-x</td> <td>Only repeat on x orientation.</td> </tr> <tr> <td>repeat-y</td> <td>Only repeat on y orientation.</td> </tr> <tr> <td>repeat</td> <td>Repeat on x and y orientation.</td> </tr> </table>
 * @param imageURI the uri of the background image.
 * @param x the x coordinate of the rectangle area.
 * @param y the y coordinate of the rectangle area.
 * @param width the width of the rectangle area.
 * @param height the height of the rectangle area.
 * @param positionX the initial x position of the background image.
 * @param positionY the initial y position of the background image.
 * @param repeat the repeat mode.
 * @throws Exception 
 */
public void drawBackgroundImage(String imageURI,float x,float y,float width,float height,float imageWidth,float imageHeight,float positionX,float positionY,int repeat) throws IOException {
  URL url=new URL(imageURI);
  InputStream imageStream=null;
  try {
    imageStream=url.openStream();
    Image image=ImageIO.read(imageStream);
    Position imageSize=null;
    ImageIcon imageIcon=new ImageIcon(image);
    if (imageHeight == 0 || imageWidth == 0) {
      imageSize=new Position(imageIcon.getIconWidth(),imageIcon.getIconHeight());
    }
 else {
      imageSize=new Position(imageWidth,imageHeight);
    }
    Position areaPosition=new Position(x,y);
    Position areaSize=new Position(width,height);
    Position imagePosition=new Position(x + positionX,y + positionY);
    BackgroundImageLayout layout=new BackgroundImageLayout(areaPosition,areaSize,imagePosition,imageSize);
    Collection positions=layout.getImagePositions(repeat);
    gSave();
    setColor(Color.WHITE);
    out.println("String_Node_Str");
    drawRawRect(x,y,width,height);
    out.println("String_Node_Str");
    Iterator iterator=positions.iterator();
    while (iterator.hasNext()) {
      Position position=(Position)iterator.next();
      drawImage(imageURI,image,position.getX(),position.getY(),imageSize.getX(),imageSize.getY());
    }
    gRestore();
  }
  finally {
    if (imageStream != null) {
      imageStream.close();
      imageStream=null;
    }
  }
}