Program: 85863
Project: 85863
Buggy source:
/** 
 * Draws the pie.
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param info  chart rendering info.
 */
protected void drawPie(Graphics2D g2,Rectangle2D plotArea,PlotRenderingInfo info){
  PiePlotState state=initialise(g2,plotArea,this,null,info);
  double labelReserve=0.0;
  if (this.labelGenerator != null && !this.simpleLabels) {
    labelReserve=this.labelGap + this.maximumLabelWidth;
  }
  double gapHorizontal=plotArea.getWidth() * (this.interiorGap + labelReserve) * 2.0;
  double gapVertical=plotArea.getHeight() * this.interiorGap * 2.0;
  if (DEBUG_DRAW_INTERIOR) {
    double hGap=plotArea.getWidth() * this.interiorGap;
    double vGap=plotArea.getHeight() * this.interiorGap;
    double igx1=plotArea.getX() + hGap;
    double igx2=plotArea.getMaxX() - hGap;
    double igy1=plotArea.getY() + vGap;
    double igy2=plotArea.getMaxY() - vGap;
    g2.setPaint(Color.GRAY);
    g2.draw(new Rectangle2D.Double(igx1,igy1,igx2 - igx1,igy2 - igy1));
  }
  double linkX=plotArea.getX() + gapHorizontal / 2;
  double linkY=plotArea.getY() + gapVertical / 2;
  double linkW=plotArea.getWidth() - gapHorizontal;
  double linkH=plotArea.getHeight() - gapVertical;
  if (this.circular) {
    double min=Math.min(linkW,linkH) / 2;
    linkX=(linkX + linkX + linkW) / 2 - min;
    linkY=(linkY + linkY + linkH) / 2 - min;
    linkW=2 * min;
    linkH=2 * min;
  }
  Rectangle2D linkArea=new Rectangle2D.Double(linkX,linkY,linkW,linkH);
  state.setLinkArea(linkArea);
  if (DEBUG_DRAW_LINK_AREA) {
    g2.setPaint(Color.BLUE);
    g2.draw(linkArea);
    g2.setPaint(Color.YELLOW);
    g2.draw(new Ellipse2D.Double(linkArea.getX(),linkArea.getY(),linkArea.getWidth(),linkArea.getHeight()));
  }
  double lm=0.0;
  if (!this.simpleLabels) {
    lm=this.labelLinkMargin;
  }
  double hh=linkArea.getWidth() * lm * 2.0;
  double vv=linkArea.getHeight() * lm * 2.0;
  Rectangle2D explodeArea=new Rectangle2D.Double(linkX + hh / 2.0,linkY + vv / 2.0,linkW - hh,linkH - vv);
  state.setExplodedPieArea(explodeArea);
  double maximumExplodePercent=getMaximumExplodePercent();
  double percent=maximumExplodePercent / (1.0 + maximumExplodePercent);
  double h1=explodeArea.getWidth() * percent;
  double v1=explodeArea.getHeight() * percent;
  Rectangle2D pieArea=new Rectangle2D.Double(explodeArea.getX() + h1 / 2.0,explodeArea.getY() + v1 / 2.0,explodeArea.getWidth() - h1,explodeArea.getHeight() - v1);
  if (DEBUG_DRAW_PIE_AREA) {
    g2.setPaint(Color.GREEN);
    g2.draw(pieArea);
  }
  state.setPieArea(pieArea);
  state.setPieCenterX(pieArea.getCenterX());
  state.setPieCenterY(pieArea.getCenterY());
  state.setPieWRadius(pieArea.getWidth() / 2.0);
  state.setPieHRadius(pieArea.getHeight() / 2.0);
  if ((this.dataset != null) && (this.dataset.getKeys().size() > 0)) {
    List keys=this.dataset.getKeys();
    double totalValue=DatasetUtilities.calculatePieDatasetTotal(this.dataset);
    int passesRequired=state.getPassesRequired();
    for (int pass=0; pass < passesRequired; pass++) {
      double runningTotal=0.0;
      for (int section=0; section < keys.size(); section++) {
        Number n=this.dataset.getValue(section);
        if (n != null) {
          double value=n.doubleValue();
          if (value > 0.0) {
            runningTotal+=value;
            drawItem(g2,section,explodeArea,state,pass);
          }
        }
      }
    }
    if (this.simpleLabels) {
      drawSimpleLabels(g2,keys,totalValue,plotArea,linkArea,state);
    }
 else {
      drawLabels(g2,keys,totalValue,plotArea,linkArea,state);
    }
  }
 else {
    drawNoDataMessage(g2,plotArea);
  }
}

Fixed version (ground truth):
/** 
 * Draws the pie.
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param info  chart rendering info.
 */
protected void drawPie(Graphics2D g2,Rectangle2D plotArea,PlotRenderingInfo info){
  PiePlotState state=initialise(g2,plotArea,this,null,info);
  double labelReserve=0.0;
  if (this.labelGenerator != null && !this.simpleLabels) {
    labelReserve=this.labelGap + this.maximumLabelWidth;
  }
  double gapHorizontal=plotArea.getWidth() * (this.interiorGap + labelReserve) * 2.0;
  double gapVertical=plotArea.getHeight() * this.interiorGap * 2.0;
  if (DEBUG_DRAW_INTERIOR) {
    double hGap=plotArea.getWidth() * this.interiorGap;
    double vGap=plotArea.getHeight() * this.interiorGap;
    double igx1=plotArea.getX() + hGap;
    double igx2=plotArea.getMaxX() - hGap;
    double igy1=plotArea.getY() + vGap;
    double igy2=plotArea.getMaxY() - vGap;
    g2.setPaint(Color.GRAY);
    g2.draw(new Rectangle2D.Double(igx1,igy1,igx2 - igx1,igy2 - igy1));
  }
  double linkX=plotArea.getX() + gapHorizontal / 2;
  double linkY=plotArea.getY() + gapVertical / 2;
  double linkW=plotArea.getWidth() - gapHorizontal;
  double linkH=plotArea.getHeight() - gapVertical;
  if (this.circular) {
    double min=Math.min(linkW,linkH) / 2;
    linkX=(linkX + linkX + linkW) / 2 - min;
    linkY=(linkY + linkY + linkH) / 2 - min;
    linkW=2 * min;
    linkH=2 * min;
  }
  Rectangle2D linkArea=new Rectangle2D.Double(linkX,linkY,linkW,linkH);
  state.setLinkArea(linkArea);
  if (DEBUG_DRAW_LINK_AREA) {
    g2.setPaint(Color.BLUE);
    g2.draw(linkArea);
    g2.setPaint(Color.YELLOW);
    g2.draw(new Ellipse2D.Double(linkArea.getX(),linkArea.getY(),linkArea.getWidth(),linkArea.getHeight()));
  }
  double lm=0.0;
  if (!this.simpleLabels) {
    lm=this.labelLinkMargin;
  }
  double hh=linkArea.getWidth() * lm * 2.0;
  double vv=linkArea.getHeight() * lm * 2.0;
  Rectangle2D explodeArea=new Rectangle2D.Double(linkX + hh / 2.0,linkY + vv / 2.0,linkW - hh,linkH - vv);
  state.setExplodedPieArea(explodeArea);
  double maximumExplodePercent=getMaximumExplodePercent();
  double percent=maximumExplodePercent / (1.0 + maximumExplodePercent);
  double h1=explodeArea.getWidth() * percent;
  double v1=explodeArea.getHeight() * percent;
  Rectangle2D pieArea=new Rectangle2D.Double(explodeArea.getX() + h1 / 2.0,explodeArea.getY() + v1 / 2.0,explodeArea.getWidth() - h1,explodeArea.getHeight() - v1);
  if (DEBUG_DRAW_PIE_AREA) {
    g2.setPaint(Color.GREEN);
    g2.draw(pieArea);
  }
  state.setPieArea(pieArea);
  state.setPieCenterX(pieArea.getCenterX());
  state.setPieCenterY(pieArea.getCenterY());
  state.setPieWRadius(pieArea.getWidth() / 2.0);
  state.setPieHRadius(pieArea.getHeight() / 2.0);
  if ((this.dataset != null) && (this.dataset.getKeys().size() > 0)) {
    List<Comparable> keys=this.dataset.getKeys();
    double totalValue=DatasetUtilities.calculatePieDatasetTotal(this.dataset);
    int passesRequired=state.getPassesRequired();
    for (int pass=0; pass < passesRequired; pass++) {
      double runningTotal=0.0;
      for (int section=0; section < keys.size(); section++) {
        Number n=this.dataset.getValue(section);
        if (n != null) {
          double value=n.doubleValue();
          if (value > 0.0) {
            runningTotal+=value;
            drawItem(g2,section,explodeArea,state,pass);
          }
        }
      }
    }
    if (this.simpleLabels) {
      drawSimpleLabels(g2,keys,totalValue,plotArea,linkArea,state);
    }
 else {
      drawLabels(g2,keys,totalValue,plotArea,linkArea,state);
    }
  }
 else {
    drawNoDataMessage(g2,plotArea);
  }
}