Program: 66248
Project: 66248
Buggy source:
/** 
 * Render triangle.
 * @param ipr A handle to the primitive rendering device
 * @param oSource The object wrapped in the polygon rendering event
 * @param loaFront The co-ordinates of the front face polygon
 * @param f The fill color for the front face
 * @param lia The edge color for the polygon
 * @param dSeriesThickness The thickness or the extrusion level (for 2.5D or 3D)
 * @throws ChartException
 */
private void renderRiserTriangle2D(IPrimitiveRenderer ipr,Object oSource,Location[] loaFront,Fill f,LineAttributes lia,ChartDimension cd,double dTopThickness,double dBottomThickness,boolean bDeferred,int zorder_hint) throws ChartException {
  PolygonRenderEvent pre;
  if (cd.getValue() == ChartDimension.TWO_DIMENSIONAL) {
    pre=((EventObjectCache)ipr).getEventObject(oSource,PolygonRenderEvent.class);
    pre.setPoints(loaFront);
    pre.setBackground(f);
    pre.setOutline(lia);
    if (bDeferred) {
      dc.addPlane(pre,PrimitiveRenderEvent.FILL | PrimitiveRenderEvent.DRAW);
    }
 else {
      ipr.fillPolygon(pre);
      ipr.drawPolygon(pre);
    }
    return;
  }
  final boolean bSolidColor=f instanceof ColorDefinition;
  Fill fDarker=null, fBrighter=null;
  if (cd.getValue() == ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH) {
    fDarker=FillUtil.getDarkerFill(f);
    fBrighter=FillUtil.getBrighterFill(f);
  }
  if (isDimension3D()) {
    fBrighter=FillUtil.changeBrightness(f,0.89);
    fDarker=FillUtil.changeBrightness(f,0.65);
    f=FillUtil.changeBrightness(f,0.89);
  }
  final int nSides=loaFront.length;
  final Location[][] loaa=new Location[nSides + 1][];
  Location[] loa;
  double dY, dSmallestY=0;
  for (int j, i=0; i < nSides; i++) {
    j=i + 1;
    if (j >= loaFront.length)     j=0;
    double[] correctThicknesses=computeCorrectThicknessesWithTriangle2D(nSides,i,dTopThickness,dBottomThickness);
    loa=new Location[4];
    loa[0]=goFactory.createLocation(loaFront[i].getX(),loaFront[i].getY());
    loa[1]=goFactory.createLocation(loaFront[j].getX(),loaFront[j].getY());
    loa[2]=goFactory.createLocation(loaFront[j].getX() + correctThicknesses[0],loaFront[j].getY() - correctThicknesses[0]);
    loa[3]=goFactory.createLocation(loaFront[i].getX() + correctThicknesses[1],loaFront[i].getY() - correctThicknesses[1]);
    loaa[i]=loa;
  }
  loaa[nSides]=loaFront;
  double dI, dJ;
  Location[] loaI, loaJ;
  for (int i=0; i < nSides - 1; i++) {
    loaI=loaa[i];
    for (int j=i + 1; j < nSides; j++) {
      loaJ=loaa[j];
      dI=getY(loaI,IConstants.AVERAGE);
      dJ=getY(loaJ,IConstants.AVERAGE);
      if (ChartUtil.mathGT(dJ,dI)) {
        loaa[i]=loaJ;
        loaa[j]=loaI;
        loaI=loaJ;
      }
 else       if (ChartUtil.mathEqual(dJ,dI)) {
        dI=getX(loaI,IConstants.AVERAGE);
        dJ=getX(loaJ,IConstants.AVERAGE);
        if (ChartUtil.mathGT(dI,dJ)) {
          loaa[i]=loaJ;
          loaa[j]=loaI;
          loaI=loaJ;
        }
      }
    }
  }
  int iSmallestYIndex=0;
  for (int i=0; i < nSides; i++) {
    dY=getY(loaa[i],IConstants.AVERAGE);
    if (i == 0) {
      dSmallestY=dY;
    }
 else     if (ChartUtil.mathGT(dSmallestY,dY)) {
      dSmallestY=dY;
      iSmallestYIndex=i;
    }
  }
  ArrayList alModel=new ArrayList(nSides + 1);
  Fill fP;
  for (int i=0; i < (nSides + 1); i++) {
    pre=((EventObjectCache)ipr).getEventObject(oSource,PolygonRenderEvent.class);
    pre.setOutline(lia);
    pre.setPoints(loaa[i]);
    if (i == nSides) {
      fP=f;
    }
 else     if (i == iSmallestYIndex) {
      fP=fBrighter;
    }
 else {
      fP=fDarker;
    }
    pre.setBackground(fP);
    if (i == nSides) {
      if (bDeferred) {
        alModel.add(pre.copy());
      }
 else {
        ipr.fillPolygon(pre);
      }
    }
 else     if (i == iSmallestYIndex) {
      if (!bSolidColor) {
        pre.setBackground(LIGHT_GLASS);
      }
      if (bDeferred) {
        alModel.add(pre.copy());
      }
 else {
        ipr.fillPolygon(pre);
      }
    }
 else {
      if (!bSolidColor) {
        pre.setBackground(DARK_GLASS);
      }
      if (bDeferred) {
        alModel.add(pre.copy());
      }
 else {
        ipr.fillPolygon(pre);
      }
    }
    if (!bDeferred) {
      ipr.drawPolygon(pre);
    }
  }
  if (!alModel.isEmpty()) {
    dc.addModel(new WrappedInstruction(getDeferredCache(),alModel,PrimitiveRenderEvent.FILL,zorder_hint));
  }
}

Fixed version (ground truth):
/** 
 * Render triangle.
 * @param ipr A handle to the primitive rendering device
 * @param oSource The object wrapped in the polygon rendering event
 * @param loaFront The co-ordinates of the front face polygon
 * @param f The fill color for the front face
 * @param lia The edge color for the polygon
 * @param dSeriesThickness The thickness or the extrusion level (for 2.5D or 3D)
 * @param compareBounds this bounds is used to adjust the order of polygon, if this bound isn't null, chart will use this bounds instead of actual bounds of polygon for order.
 * @throws ChartException
 */
private void renderRiserTriangle2D(IPrimitiveRenderer ipr,Object oSource,Location[] loaFront,Fill f,LineAttributes lia,ChartDimension cd,double dTopThickness,double dBottomThickness,boolean bDeferred,int zorder_hint,Bounds compareBounds) throws ChartException {
  PolygonRenderEvent pre;
  if (cd.getValue() == ChartDimension.TWO_DIMENSIONAL) {
    pre=((EventObjectCache)ipr).getEventObject(oSource,PolygonRenderEvent.class);
    pre.setPoints(loaFront);
    pre.setBackground(f);
    pre.setOutline(lia);
    if (bDeferred) {
      dc.addPlane(pre,PrimitiveRenderEvent.FILL | PrimitiveRenderEvent.DRAW);
    }
 else {
      ipr.fillPolygon(pre);
      ipr.drawPolygon(pre);
    }
    return;
  }
  final boolean bSolidColor=f instanceof ColorDefinition;
  Fill fDarker=null, fBrighter=null;
  if (cd.getValue() == ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH) {
    fDarker=FillUtil.getDarkerFill(f);
    fBrighter=FillUtil.getBrighterFill(f);
  }
  if (isDimension3D()) {
    fBrighter=FillUtil.changeBrightness(f,0.89);
    fDarker=FillUtil.changeBrightness(f,0.65);
    f=FillUtil.changeBrightness(f,0.89);
  }
  final int nSides=loaFront.length;
  final Location[][] loaa=new Location[nSides + 1][];
  Location[] loa;
  double dY, dSmallestY=0;
  for (int j, i=0; i < nSides; i++) {
    j=i + 1;
    if (j >= loaFront.length)     j=0;
    double[] correctThicknesses=computeCorrectThicknessesWithTriangle2D(nSides,i,dTopThickness,dBottomThickness);
    loa=new Location[4];
    loa[0]=goFactory.createLocation(loaFront[i].getX(),loaFront[i].getY());
    loa[1]=goFactory.createLocation(loaFront[j].getX(),loaFront[j].getY());
    loa[2]=goFactory.createLocation(loaFront[j].getX() + correctThicknesses[0],loaFront[j].getY() - correctThicknesses[0]);
    loa[3]=goFactory.createLocation(loaFront[i].getX() + correctThicknesses[1],loaFront[i].getY() - correctThicknesses[1]);
    loaa[i]=loa;
  }
  loaa[nSides]=loaFront;
  double dI, dJ;
  Location[] loaI, loaJ;
  for (int i=0; i < nSides - 1; i++) {
    loaI=loaa[i];
    for (int j=i + 1; j < nSides; j++) {
      loaJ=loaa[j];
      dI=getY(loaI,IConstants.AVERAGE);
      dJ=getY(loaJ,IConstants.AVERAGE);
      if (ChartUtil.mathGT(dJ,dI)) {
        loaa[i]=loaJ;
        loaa[j]=loaI;
        loaI=loaJ;
      }
 else       if (ChartUtil.mathEqual(dJ,dI)) {
        dI=getX(loaI,IConstants.AVERAGE);
        dJ=getX(loaJ,IConstants.AVERAGE);
        if (ChartUtil.mathGT(dI,dJ)) {
          loaa[i]=loaJ;
          loaa[j]=loaI;
          loaI=loaJ;
        }
      }
    }
  }
  int iSmallestYIndex=0;
  for (int i=0; i < nSides; i++) {
    dY=getY(loaa[i],IConstants.AVERAGE);
    if (i == 0) {
      dSmallestY=dY;
    }
 else     if (ChartUtil.mathGT(dSmallestY,dY)) {
      dSmallestY=dY;
      iSmallestYIndex=i;
    }
  }
  ArrayList alModel=new ArrayList(nSides + 1);
  Fill fP;
  for (int i=0; i < (nSides + 1); i++) {
    pre=((EventObjectCache)ipr).getEventObject(oSource,PolygonRenderEvent.class);
    pre.setOutline(lia);
    pre.setPoints(loaa[i]);
    if (i == nSides) {
      fP=f;
    }
 else     if (i == iSmallestYIndex) {
      fP=fBrighter;
    }
 else {
      fP=fDarker;
    }
    pre.setBackground(fP);
    if (i == nSides) {
      if (bDeferred) {
        alModel.add(pre.copy());
      }
 else {
        ipr.fillPolygon(pre);
      }
    }
 else     if (i == iSmallestYIndex) {
      if (!bSolidColor) {
        pre.setBackground(LIGHT_GLASS);
      }
      if (bDeferred) {
        alModel.add(pre.copy());
      }
 else {
        ipr.fillPolygon(pre);
      }
    }
 else {
      if (!bSolidColor) {
        pre.setBackground(DARK_GLASS);
      }
      if (bDeferred) {
        alModel.add(pre.copy());
      }
 else {
        ipr.fillPolygon(pre);
      }
    }
    if (!bDeferred) {
      ipr.drawPolygon(pre);
    }
  }
  if (!alModel.isEmpty()) {
    WrappedInstruction wi=new WrappedInstruction(getDeferredCache(),alModel,PrimitiveRenderEvent.FILL,zorder_hint);
    wi.setCompareBounds(compareBounds);
    dc.addModel(wi);
  }
}