Program: 11469
Project: 11469
Buggy source:
@Override protected void paintTo(GlimpseContext context,GlimpseBounds bounds,Axis2D axis){
  if (axis == null && !drawInPixelCoords) {
    throw new AxisNotSetException(this,context);
  }
  double x=drawInPixelCoords ? this.x : axis.getAxisX().valueToScreenPixelUnits(this.x);
  double y=drawInPixelCoords ? this.y : axis.getAxisY().valueToScreenPixelUnits(this.y);
  if (icons == null) {
    loadIcons();
  }
  if (newFont != null) {
    updateTextRenderer();
  }
  if (text != null && textLayout == null && textRenderer != null) {
    updateTextLayout();
  }
  GL2 gl=context.getGL().getGL2();
  int width=bounds.getWidth();
  int height=bounds.getHeight();
  gl.glMatrixMode(GL2.GL_PROJECTION);
  gl.glLoadIdentity();
  gl.glOrtho(-0.5,width - 1 + 0.5,-0.5,height - 1 + 0.5,-1,1);
  gl.glMatrixMode(GL2.GL_MODELVIEW);
  gl.glLoadIdentity();
  gl.glBlendFunc(GL2.GL_SRC_ALPHA,GL2.GL_ONE_MINUS_SRC_ALPHA);
  gl.glEnable(GL2.GL_BLEND);
  double iconHeight=0;
  if (icons != null)   iconHeight=iconSize * icons.size() + iconSpacing * (icons.size() - 1);
  double textHeight=0;
  if (lines != null)   textHeight=(textLayout.getAscent()) * lines.size() + lineSpacing * (lines.size() - 1);
  int boundingHeight=(int)(borderSize * 2 + Math.max(iconHeight,textHeight));
  float textLength=0;
  if (lines != null)   for (int k=0; k < lines.size(); k++)   textLength=Math.max(textLength,lines.get(0).width);
  int boundingWidth=(int)(borderSize * 2 + iconSize + textLength);
  if (iconIds != null && !iconIds.isEmpty() && lines != null)   boundingWidth+=textIconSpacing;
  double clampX=offsetX, clampY=offsetY;
  if (clampToScreenEdges) {
    if (x + boundingWidth + offsetX > bounds.getWidth())     clampX=bounds.getWidth() - boundingWidth - x;
    if (x + offsetX < 0)     clampX=-x;
    if (y + offsetY > bounds.getHeight())     clampY=bounds.getHeight() - y;
    if (boundingHeight > y + offsetY)     clampY=boundingHeight - y;
  }
  if (this.paintBackground || this.paintBorder) {
    if (this.paintBackground) {
      gl.glColor4fv(backgroundColor,0);
      gl.glBegin(GL2.GL_QUADS);
      try {
        borderVertices(gl,boundingHeight,boundingWidth,x + clampX,y + clampY);
      }
  finally {
        gl.glEnd();
      }
    }
    if (this.paintBorder) {
      gl.glColor4fv(borderColor,0);
      gl.glEnable(GL2.GL_LINE_SMOOTH);
      gl.glBegin(GL2.GL_LINE_LOOP);
      try {
        borderVertices(gl,boundingHeight,boundingWidth,x + clampX,y + clampY);
      }
  finally {
        gl.glEnd();
      }
    }
  }
  gl.glDisable(GL2.GL_BLEND);
  if (lines != null && textRenderer != null) {
    GlimpseColor.setColor(textRenderer,textColor);
    textRenderer.beginRendering(width,height);
    try {
      double posX=x + iconSize + borderSize;
      if (iconIds != null && !iconIds.isEmpty())       posX+=textIconSpacing;
      double posY=y - borderSize - textLayout.getAscent();
      double iconPosY=Float.NEGATIVE_INFINITY;
      if (wrapTextAroundIcon && icons != null)       iconPosY=y - (iconSize * icons.size() + iconSpacing * (icons.size() - 1) + borderSize);
      for (int i=0; i < lines.size(); i++) {
        if (posY + textLayout.getAscent() < iconPosY)         posX=x + borderSize;
        textRenderer.draw(lines.get(i).text,(int)(posX + clampX),(int)(posY + clampY));
        posY=posY - lineSpacing - (textLayout.getAscent());
      }
    }
  finally {
      textRenderer.endRendering();
    }
  }
  if (iconIds != null && !iconIds.isEmpty()) {
    atlas.beginRendering();
    try {
      double posY=y - borderSize - iconSize;
      for (int i=0; i < iconIds.size(); i++) {
        Object iconId=iconIds.get(i);
        ImageData iconData=icons.get(i);
        if (iconId != null && iconData != null) {
          double iconScale=iconSize / (double)iconData.getWidth();
          float[] color=defaultIconColor;
          if (iconColors != null && i < iconColors.size()) {
            float[] iconColor=iconColors.get(i);
            if (iconColor != null)             color=iconColor;
          }
          GlimpseColor.glColor(gl,color);
          atlas.drawImage(gl,iconId,(int)(x + borderSize + clampX),(int)(posY + clampY),iconScale,iconScale,0,iconData.getHeight());
          posY=posY - iconSize - iconSpacing;
        }
      }
    }
  finally {
      atlas.endRendering();
    }
  }
}

Fixed version (ground truth):
@Override protected void paintTo(GlimpseContext context,GlimpseBounds bounds,Axis2D axis){
  if (axis == null && !drawInPixelCoords) {
    throw new AxisNotSetException(this,context);
  }
  double x=drawInPixelCoords ? this.x : axis.getAxisX().valueToScreenPixelUnits(this.x);
  double y=drawInPixelCoords ? this.y : axis.getAxisY().valueToScreenPixelUnits(this.y);
  if (icons == null) {
    loadIcons();
  }
  if (newFont != null) {
    updateTextRenderer();
  }
  if (text != null && textLayout == null && textRenderer != null) {
    updateTextLayout();
  }
  if (iconIds == null || iconIds.isEmpty())   iconSize=0;
  GL2 gl=context.getGL().getGL2();
  int width=bounds.getWidth();
  int height=bounds.getHeight();
  gl.glMatrixMode(GL2.GL_PROJECTION);
  gl.glLoadIdentity();
  gl.glOrtho(-0.5,width - 1 + 0.5,-0.5,height - 1 + 0.5,-1,1);
  gl.glMatrixMode(GL2.GL_MODELVIEW);
  gl.glLoadIdentity();
  gl.glBlendFunc(GL2.GL_SRC_ALPHA,GL2.GL_ONE_MINUS_SRC_ALPHA);
  gl.glEnable(GL2.GL_BLEND);
  double iconHeight=0;
  if (icons != null)   iconHeight=iconSize * icons.size() + iconSpacing * (icons.size() - 1);
  double textHeight=0;
  if (lines != null)   textHeight=(textLayout.getLineHeight()) * lines.size() + lineSpacing * (lines.size() - 1);
  int boundingHeight=(int)(borderSize * 2 + Math.max(iconHeight,textHeight));
  float textLength=0;
  if (lines != null)   for (int k=0; k < lines.size(); k++)   textLength=Math.max(textLength,lines.get(0).width);
  int boundingWidth=(int)(borderSize * 2 + iconSize + textLength);
  if (iconIds != null && !iconIds.isEmpty() && lines != null)   boundingWidth+=textIconSpacing;
  double clampX=offsetX, clampY=offsetY;
  if (clampToScreenEdges) {
    if (x + boundingWidth + offsetX > bounds.getWidth())     clampX=bounds.getWidth() - boundingWidth - x;
    if (x + offsetX < 0)     clampX=-x;
    if (y + offsetY > bounds.getHeight())     clampY=bounds.getHeight() - y;
    if (boundingHeight > y + offsetY)     clampY=boundingHeight - y;
  }
  if (this.paintBackground || this.paintBorder) {
    if (this.paintBackground) {
      gl.glColor4fv(backgroundColor,0);
      gl.glBegin(GL2.GL_QUADS);
      try {
        borderVertices(gl,boundingHeight,boundingWidth,x + clampX,y + clampY);
      }
  finally {
        gl.glEnd();
      }
    }
    if (this.paintBorder) {
      gl.glColor4fv(borderColor,0);
      gl.glEnable(GL2.GL_LINE_SMOOTH);
      gl.glBegin(GL2.GL_LINE_LOOP);
      try {
        borderVertices(gl,boundingHeight,boundingWidth,x + clampX,y + clampY);
      }
  finally {
        gl.glEnd();
      }
    }
  }
  gl.glDisable(GL2.GL_BLEND);
  if (lines != null && textRenderer != null) {
    GlimpseColor.setColor(textRenderer,textColor);
    textRenderer.beginRendering(width,height);
    try {
      double posX=x + iconSize + borderSize;
      if (iconIds != null && !iconIds.isEmpty())       posX+=textIconSpacing;
      double posY=y - borderSize - textLayout.getLineHeight();
      double iconPosY=Float.NEGATIVE_INFINITY;
      if (wrapTextAroundIcon && icons != null)       iconPosY=y - (iconSize * icons.size() + iconSpacing * (icons.size() - 1) + borderSize);
      for (int i=0; i < lines.size(); i++) {
        if (posY + textLayout.getLineHeight() < iconPosY)         posX=x + borderSize;
        textRenderer.draw(lines.get(i).text,(int)(posX + clampX),(int)(posY + clampY));
        posY=posY - lineSpacing - (textLayout.getLineHeight());
      }
    }
  finally {
      textRenderer.endRendering();
    }
  }
  if (iconIds != null && !iconIds.isEmpty()) {
    atlas.beginRendering();
    try {
      double posY=y - borderSize - iconSize;
      for (int i=0; i < iconIds.size(); i++) {
        Object iconId=iconIds.get(i);
        ImageData iconData=icons.get(i);
        if (iconId != null && iconData != null) {
          double iconScale=iconSize / (double)iconData.getWidth();
          float[] color=defaultIconColor;
          if (iconColors != null && i < iconColors.size()) {
            float[] iconColor=iconColors.get(i);
            if (iconColor != null)             color=iconColor;
          }
          GlimpseColor.glColor(gl,color);
          atlas.drawImage(gl,iconId,(int)(x + borderSize + clampX),(int)(posY + clampY),iconScale,iconScale,0,iconData.getHeight());
          posY=posY - iconSize - iconSpacing;
        }
      }
    }
  finally {
      atlas.endRendering();
    }
  }
}