Program: 69620
Project: 69620
Buggy source:
private final void showLeftValue(IPrimitiveRenderer renderer,Location location,Label label,int labelPosition,boolean bShadow){
  IDeviceRenderer idr=(IDeviceRenderer)renderer;
  IChartComputation cComp=idr.getChartComputation();
  Graphics2D g2d=(Graphics2D)idr.getGraphicsContext();
  FontDefinition fontDef=label.getCaption().getFont();
  double dAngleInDegrees=fontDef.getRotation();
  if (bShadow) {
    bShadow=label.getShadowColor() != null;
  }
  Color clrText=(Color)_sxs.getColor(label.getCaption().getColor());
  Color clrBackground=null;
  if (label.getBackground() != null) {
    clrBackground=(Color)_sxs.getColor((ColorDefinition)label.getBackground());
  }
  final double dAngleInRadians=((-dAngleInDegrees * Math.PI) / 180.0);
  final double dSineTheta=(Math.sin(dAngleInRadians));
  final double dCosTheta=(Math.cos(dAngleInRadians));
  final ITextMetrics textMetrics=cComp.getTextMetrics(_sxs,label,0);
  AffineTransform afTransform=new AffineTransform(g2d.getTransform());
  location=adjustTextPosition(labelPosition,location,textMetrics,dAngleInDegrees);
  double dX=location.getX(), dY=location.getY();
  try {
    final double dFullWidth=textMetrics.getFullWidth();
    final double dHeight=textMetrics.getHeight();
    final double dDescent=textMetrics.getDescent();
    final double dFullHeight=textMetrics.getFullHeight();
    double dXOffset=0, dWidth=0;
    final int lineCount=textMetrics.getLineCount();
    final Insets insets=label.getInsets().scaledInstance(_sxs.getDpiResolution() / 72d);
    final double shadowness=3 * _sxs.getDpiResolution() / 72d;
    final boolean bEmptyText="String_Node_Str".equals(label.getCaption().getValue());
    ChartTextLayout textLayout;
    double dYDiff=dY - dFullHeight;
    final HorizontalAlignment hAlign=label.getCaption().getFont().getAlignment().getHorizontalAlignment();
    final boolean bRightAligned=hAlign.getValue() == HorizontalAlignment.RIGHT;
    final boolean bCenterAligned=hAlign.getValue() == HorizontalAlignment.CENTER;
    double dRotateX=(dX - dFullWidth);
    double dRotateY=(dY + dHeight / 2);
    dX-=dFullWidth;
    dY+=dHeight / 2;
    if (dAngleInDegrees == 0) {
      double dYHalfOffset=(dFullHeight + dHeight) / 2d;
      if (bShadow) {
        g2d.setPaint(new GradientPaint(new Point2D.Double(dX + shadowness,(dY - dYHalfOffset) + shadowness),(Color)_sxs.getColor(label.getShadowColor()),new Point2D.Double(dX + shadowness + dFullWidth,(dY - dYHalfOffset) + shadowness + dFullHeight),(Color)_sxs.getColor(label.getShadowColor().translucent())));
        fillShadow(g2d,new Rectangle2D.Double(dX + shadowness,(dY - dYHalfOffset) + shadowness,dFullWidth,dFullHeight));
      }
 else {
        final Rectangle2D.Double r2d=new Rectangle2D.Double(dX,dY - dYHalfOffset,dFullWidth,dFullHeight);
        if (clrBackground != null) {
          g2d.setColor(clrBackground);
          g2d.fill(r2d);
        }
        if (!bEmptyText) {
          g2d.setColor(clrText);
          for (int i=0; i < lineCount; i++) {
            textLayout=((ChartTextMetrics)textMetrics).getLayout(i);
            if (bRightAligned) {
              dWidth=textLayout.getBounds().getWidth();
              dXOffset=-insets.getLeft() + dFullWidth - dWidth - insets.getRight();
            }
 else             if (bCenterAligned) {
              dWidth=textLayout.getBounds().getWidth();
              dXOffset=-insets.getLeft() + (dFullWidth - dWidth) / 2;
            }
            textLayout.draw(g2d,(float)(dX + dXOffset + insets.getLeft()),(float)(dY - dYHalfOffset + insets.getTop() + dHeight * (i + 1) - dDescent));
          }
        }
        renderOutline(renderer,label.getOutline(),r2d);
      }
    }
 else     if (dAngleInDegrees > 0 && dAngleInDegrees < 90) {
      double dDeltaX=dFullWidth - dFullWidth * dCosTheta;
      double dDeltaY=dFullWidth * dSineTheta + dHeight / 2;
      dX+=dDeltaX;
      dY-=dDeltaY;
      g2d.rotate(dAngleInRadians,dRotateX + dDeltaX,dRotateY - dDeltaY);
      if (bShadow) {
        g2d.setPaint(new GradientPaint(new Point2D.Double(dX + shadowness,(dYDiff) + shadowness),(Color)_sxs.getColor(label.getShadowColor()),new Point2D.Double(dX + shadowness + dFullWidth,(dYDiff) + shadowness + dFullHeight),(Color)_sxs.getColor(label.getShadowColor().translucent())));
        fillShadow(g2d,new Rectangle2D.Double(dX + shadowness,(dYDiff) + shadowness,dFullWidth,dFullHeight));
      }
 else {
        final Rectangle2D.Double r2d=new Rectangle2D.Double(dX,dYDiff,dFullWidth,dFullHeight);
        if (clrBackground != null) {
          g2d.setColor(clrBackground);
          g2d.fill(r2d);
        }
        if (!bEmptyText) {
          g2d.setColor(clrText);
          for (int i=0; i < textMetrics.getLineCount(); i++) {
            textLayout=((ChartTextMetrics)textMetrics).getLayout(lineCount - i - 1);
            if (bRightAligned) {
              dWidth=textLayout.getBounds().getWidth();
              dXOffset=-insets.getLeft() + dFullWidth - dWidth - insets.getRight();
            }
 else             if (bCenterAligned) {
              dWidth=textLayout.getBounds().getWidth();
              dXOffset=-insets.getLeft() + (dFullWidth - dWidth) / 2;
            }
            textLayout.draw(g2d,(float)(dX + dXOffset + insets.getLeft()),(float)(((dY - dDescent) - (dHeight * i)) - insets.getBottom()));
          }
        }
        renderOutline(renderer,label.getOutline(),r2d);
      }
    }
 else     if (dAngleInDegrees < 0 && dAngleInDegrees > -90) {
      double dDeltaX=dFullWidth - dFullWidth * dCosTheta - dHeight * dSineTheta;
      double dDeltaY=dFullWidth * dSineTheta + dHeight / 2 - dHeight * dCosTheta;
      dX+=dDeltaX;
      dY-=dDeltaY;
      g2d.rotate(dAngleInRadians,dRotateX + dDeltaX,dRotateY - dDeltaY);
      if (bShadow) {
        g2d.setPaint(new GradientPaint(new Point2D.Double(dX + shadowness,(dY - dHeight) + shadowness),(Color)_sxs.getColor(label.getShadowColor()),new Point2D.Double(dX + shadowness + dFullWidth,(dY - dHeight) + shadowness + dFullHeight),(Color)_sxs.getColor(label.getShadowColor().translucent())));
        fillShadow(g2d,new Rectangle2D.Double(dX + shadowness,(dY - dHeight) + shadowness,dFullWidth,dFullHeight));
      }
 else {
        final Rectangle2D.Double r2d=new Rectangle2D.Double(dX,dY - dHeight,dFullWidth,dFullHeight);
        if (clrBackground != null) {
          g2d.setColor(clrBackground);
          g2d.fill(r2d);
        }
        if (!bEmptyText) {
          g2d.setColor(clrText);
          for (int i=0; i < lineCount; i++) {
            textLayout=((ChartTextMetrics)textMetrics).getLayout(i);
            if (bRightAligned) {
              dWidth=textLayout.getBounds().getWidth();
              dXOffset=-insets.getLeft() + dFullWidth - dWidth - insets.getRight();
            }
 else             if (bCenterAligned) {
              dWidth=textLayout.getBounds().getWidth();
              dXOffset=-insets.getLeft() + (dFullWidth - dWidth) / 2;
            }
            textLayout.draw(g2d,(float)(dX + dXOffset + insets.getLeft()),(float)(((dY - dDescent) + (dHeight * i)) + insets.getTop()));
          }
        }
        renderOutline(renderer,label.getOutline(),r2d);
      }
    }
 else     if (dAngleInDegrees == 90) {
      double dDeltaX=dFullWidth;
      double dDeltaY=(dFullWidth - dHeight) / 2;
      dX+=dDeltaX;
      dY+=dDeltaY;
      g2d.rotate(dAngleInRadians,dX,dY);
      if (bShadow) {
        g2d.setPaint(new GradientPaint(new Point2D.Double(dX + shadowness,(dYDiff) + shadowness),(Color)_sxs.getColor(label.getShadowColor()),new Point2D.Double(dX + shadowness + dFullWidth,(dYDiff) + shadowness + dFullHeight),(Color)_sxs.getColor(label.getShadowColor().translucent())));
        fillShadow(g2d,new Rectangle2D.Double(dX + shadowness,(dYDiff) + shadowness,dFullWidth,dFullHeight));
      }
 else {
        final Rectangle2D.Double r2d=new Rectangle2D.Double(dX,dYDiff,dFullWidth,dFullHeight);
        if (clrBackground != null) {
          g2d.setColor(clrBackground);
          g2d.fill(r2d);
        }
        if (!bEmptyText) {
          g2d.setColor(clrText);
          for (int i=0; i < lineCount; i++) {
            textLayout=((ChartTextMetrics)textMetrics).getLayout(i);
            if (bRightAligned) {
              dWidth=textLayout.getBounds().getWidth();
              dXOffset=-insets.getLeft() + dFullWidth - dWidth - insets.getRight();
            }
 else             if (bCenterAligned) {
              dWidth=textLayout.getBounds().getWidth();
              dXOffset=-insets.getLeft() + (dFullWidth - dWidth) / 2;
            }
            textLayout.draw(g2d,(float)(dX + dXOffset + insets.getLeft()),(float)(((dY - dDescent) - (dHeight * (lineCount - i - 1))) + insets.getTop()));
          }
        }
        renderOutline(renderer,label.getOutline(),r2d);
      }
    }
 else     if (dAngleInDegrees == -90) {
      double dDeltaX=dFullWidth - dHeight;
      double dDeltaY=(dFullWidth + dHeight) / 2;
      dX+=dDeltaX;
      dY-=dDeltaY;
      g2d.rotate(dAngleInRadians,dX,dY);
      if (bShadow) {
        g2d.setPaint(new GradientPaint(new Point2D.Double(dX + shadowness,(dYDiff) + shadowness),(Color)_sxs.getColor(label.getShadowColor()),new Point2D.Double(dX + shadowness + dFullWidth,(dYDiff) + shadowness + dFullHeight),(Color)_sxs.getColor(label.getShadowColor().translucent())));
        fillShadow(g2d,new Rectangle2D.Double(dX + shadowness,(dYDiff) + shadowness,dFullWidth,dFullHeight));
      }
 else {
        final Rectangle2D.Double r2d=new Rectangle2D.Double(dX,dY - dHeight,dFullWidth,dFullHeight);
        if (clrBackground != null) {
          g2d.setColor(clrBackground);
          g2d.fill(r2d);
        }
        if (!bEmptyText) {
          g2d.setColor(clrText);
          for (int i=0; i < lineCount; i++) {
            textLayout=((ChartTextMetrics)textMetrics).getLayout(i);
            if (bRightAligned) {
              dWidth=textLayout.getBounds().getWidth();
              dXOffset=-insets.getLeft() + dFullWidth - dWidth - insets.getRight();
            }
 else             if (bCenterAligned) {
              dWidth=textLayout.getBounds().getWidth();
              dXOffset=-insets.getLeft() + (dFullWidth - dWidth) / 2;
            }
            textLayout.draw(g2d,(float)(dX + dXOffset + insets.getLeft()),(float)(((dY - dDescent) + (dHeight * i)) + insets.getTop()));
          }
        }
        renderOutline(renderer,label.getOutline(),r2d);
      }
    }
  }
  finally {
    g2d.setTransform(afTransform);
    cComp.recycleTextMetrics(textMetrics);
  }
}

Fixed version (ground truth):
private final void showLeftValue(IPrimitiveRenderer renderer,Location location,Label label,int labelPosition,boolean bShadow){
  IDeviceRenderer idr=(IDeviceRenderer)renderer;
  IChartComputation cComp=idr.getChartComputation();
  Graphics2D g2d=(Graphics2D)idr.getGraphicsContext();
  FontDefinition fontDef=label.getCaption().getFont();
  double dAngleInDegrees=fontDef.getRotation();
  if (bShadow) {
    bShadow=label.getShadowColor() != null;
  }
  Color clrText=(Color)_sxs.getColor(label.getCaption().getColor());
  Color clrBackground=null;
  if (label.getBackground() != null) {
    clrBackground=(Color)_sxs.getColor((ColorDefinition)label.getBackground());
  }
  final double dAngleInRadians=((-dAngleInDegrees * Math.PI) / 180.0);
  final double dSineTheta=(Math.sin(dAngleInRadians));
  final double dCosTheta=(Math.cos(dAngleInRadians));
  final ITextMetrics textMetrics=cComp.getTextMetrics(_sxs,label,0);
  AffineTransform afTransform=new AffineTransform(g2d.getTransform());
  location=adjustTextPosition(labelPosition,location,textMetrics,dAngleInDegrees);
  double dX=location.getX(), dY=location.getY();
  try {
    final double dFullWidth=textMetrics.getFullWidth();
    final double dHeight=textMetrics.getHeight();
    final double dDescent=textMetrics.getDescent();
    final double dFullHeight=textMetrics.getFullHeight();
    double dXOffset=0, dWidth=0;
    final int lineCount=textMetrics.getLineCount();
    final Insets insets=label.getInsets().scaledInstance(_sxs.getDpiResolution() / 72d);
    final double shadowness=3 * _sxs.getDpiResolution() / 72d;
    final boolean bEmptyText="String_Node_Str".equals(label.getCaption().getValue());
    ChartTextLayout textLayout;
    double dYDiff;
    final HorizontalAlignment hAlign=label.getCaption().getFont().getAlignment().getHorizontalAlignment();
    final boolean bRightAligned=hAlign.getValue() == HorizontalAlignment.RIGHT;
    final boolean bCenterAligned=hAlign.getValue() == HorizontalAlignment.CENTER;
    double dRotateX=(dX - dFullWidth);
    double dRotateY=(dY + dHeight / 2);
    dX-=dFullWidth;
    dY+=dHeight / 2;
    if (dAngleInDegrees == 0) {
      double dYHalfOffset=(dFullHeight + dHeight) / 2d;
      if (bShadow) {
        g2d.setPaint(new GradientPaint(new Point2D.Double(dX + shadowness,(dY - dYHalfOffset) + shadowness),(Color)_sxs.getColor(label.getShadowColor()),new Point2D.Double(dX + shadowness + dFullWidth,(dY - dYHalfOffset) + shadowness + dFullHeight),(Color)_sxs.getColor(label.getShadowColor().translucent())));
        fillShadow(g2d,new Rectangle2D.Double(dX + shadowness,(dY - dYHalfOffset) + shadowness,dFullWidth,dFullHeight));
      }
 else {
        final Rectangle2D.Double r2d=new Rectangle2D.Double(dX,dY - dYHalfOffset,dFullWidth,dFullHeight);
        if (clrBackground != null) {
          g2d.setColor(clrBackground);
          g2d.fill(r2d);
        }
        if (!bEmptyText) {
          g2d.setColor(clrText);
          for (int i=0; i < lineCount; i++) {
            textLayout=((ChartTextMetrics)textMetrics).getLayout(i);
            if (bRightAligned) {
              dWidth=textLayout.getBounds().getWidth();
              dXOffset=-insets.getLeft() + dFullWidth - dWidth - insets.getRight();
            }
 else             if (bCenterAligned) {
              dWidth=textLayout.getBounds().getWidth();
              dXOffset=-insets.getLeft() + (dFullWidth - dWidth) / 2;
            }
            textLayout.draw(g2d,(float)(dX + dXOffset + insets.getLeft()),(float)(dY - dYHalfOffset + insets.getTop() + dHeight * (i + 1) - dDescent));
          }
        }
        renderOutline(renderer,label.getOutline(),r2d);
      }
    }
 else     if (dAngleInDegrees > 0 && dAngleInDegrees < 90) {
      double dDeltaX=dFullWidth - dFullWidth * dCosTheta;
      double dDeltaY=dFullWidth * dSineTheta + dHeight / 2;
      dX+=dDeltaX;
      dY-=dDeltaY;
      g2d.rotate(dAngleInRadians,dRotateX + dDeltaX,dRotateY - dDeltaY);
      dYDiff=dY - dFullHeight;
      if (bShadow) {
        g2d.setPaint(new GradientPaint(new Point2D.Double(dX + shadowness,dYDiff + shadowness),(Color)_sxs.getColor(label.getShadowColor()),new Point2D.Double(dX + shadowness + dFullWidth,dY + shadowness),(Color)_sxs.getColor(label.getShadowColor().translucent())));
        fillShadow(g2d,new Rectangle2D.Double(dX + shadowness,dYDiff + shadowness,dFullWidth,dFullHeight));
      }
 else {
        final Rectangle2D.Double r2d=new Rectangle2D.Double(dX,dYDiff,dFullWidth,dFullHeight);
        if (clrBackground != null) {
          g2d.setColor(clrBackground);
          g2d.fill(r2d);
        }
        if (!bEmptyText) {
          g2d.setColor(clrText);
          for (int i=0; i < textMetrics.getLineCount(); i++) {
            textLayout=((ChartTextMetrics)textMetrics).getLayout(lineCount - i - 1);
            if (bRightAligned) {
              dWidth=textLayout.getBounds().getWidth();
              dXOffset=-insets.getLeft() + dFullWidth - dWidth - insets.getRight();
            }
 else             if (bCenterAligned) {
              dWidth=textLayout.getBounds().getWidth();
              dXOffset=-insets.getLeft() + (dFullWidth - dWidth) / 2;
            }
            textLayout.draw(g2d,(float)(dX + dXOffset + insets.getLeft()),(float)(((dY - dDescent) - (dHeight * i)) - insets.getBottom()));
          }
        }
        renderOutline(renderer,label.getOutline(),r2d);
      }
    }
 else     if (dAngleInDegrees < 0 && dAngleInDegrees > -90) {
      double dDeltaX=dFullWidth - dFullWidth * dCosTheta - dHeight * dSineTheta;
      double dDeltaY=dFullWidth * dSineTheta + dHeight / 2 - dHeight * dCosTheta;
      dX+=dDeltaX;
      dY-=dDeltaY;
      g2d.rotate(dAngleInRadians,dRotateX + dDeltaX,dRotateY - dDeltaY);
      dYDiff=dY - dFullHeight;
      if (bShadow) {
        g2d.setPaint(new GradientPaint(new Point2D.Double(dX + shadowness,dYDiff + shadowness),(Color)_sxs.getColor(label.getShadowColor()),new Point2D.Double(dX + shadowness + dFullWidth,dY + shadowness),(Color)_sxs.getColor(label.getShadowColor().translucent())));
        fillShadow(g2d,new Rectangle2D.Double(dX + shadowness,dYDiff + shadowness,dFullWidth,dFullHeight));
      }
 else {
        final Rectangle2D.Double r2d=new Rectangle2D.Double(dX,dYDiff,dFullWidth,dFullHeight);
        if (clrBackground != null) {
          g2d.setColor(clrBackground);
          g2d.fill(r2d);
        }
        if (!bEmptyText) {
          g2d.setColor(clrText);
          for (int i=0; i < lineCount; i++) {
            textLayout=((ChartTextMetrics)textMetrics).getLayout(i);
            if (bRightAligned) {
              dWidth=textLayout.getBounds().getWidth();
              dXOffset=-insets.getLeft() + dFullWidth - dWidth - insets.getRight();
            }
 else             if (bCenterAligned) {
              dWidth=textLayout.getBounds().getWidth();
              dXOffset=-insets.getLeft() + (dFullWidth - dWidth) / 2;
            }
            textLayout.draw(g2d,(float)(dX + dXOffset + insets.getLeft()),(float)(((dY - dDescent) + (dHeight * i)) + insets.getTop()));
          }
        }
        renderOutline(renderer,label.getOutline(),r2d);
      }
    }
 else     if (dAngleInDegrees == 90) {
      double dDeltaX=dFullWidth;
      double dDeltaY=(dFullWidth - dHeight) / 2;
      dX+=dDeltaX;
      dY+=dDeltaY;
      g2d.rotate(dAngleInRadians,dX,dY);
      dYDiff=dY - dFullHeight;
      if (bShadow) {
        g2d.setPaint(new GradientPaint(new Point2D.Double(dX + shadowness,dYDiff + shadowness),(Color)_sxs.getColor(label.getShadowColor()),new Point2D.Double(dX + shadowness + dFullWidth,dY + shadowness),(Color)_sxs.getColor(label.getShadowColor().translucent())));
        fillShadow(g2d,new Rectangle2D.Double(dX + shadowness,dYDiff + shadowness,dFullWidth,dFullHeight));
      }
 else {
        final Rectangle2D.Double r2d=new Rectangle2D.Double(dX,dYDiff,dFullWidth,dFullHeight);
        if (clrBackground != null) {
          g2d.setColor(clrBackground);
          g2d.fill(r2d);
        }
        if (!bEmptyText) {
          g2d.setColor(clrText);
          for (int i=0; i < lineCount; i++) {
            textLayout=((ChartTextMetrics)textMetrics).getLayout(i);
            if (bRightAligned) {
              dWidth=textLayout.getBounds().getWidth();
              dXOffset=-insets.getLeft() + dFullWidth - dWidth - insets.getRight();
            }
 else             if (bCenterAligned) {
              dWidth=textLayout.getBounds().getWidth();
              dXOffset=-insets.getLeft() + (dFullWidth - dWidth) / 2;
            }
            textLayout.draw(g2d,(float)(dX + dXOffset + insets.getLeft()),(float)(((dY - dDescent) - (dHeight * (lineCount - i - 1))) + insets.getTop()));
          }
        }
        renderOutline(renderer,label.getOutline(),r2d);
      }
    }
 else     if (dAngleInDegrees == -90) {
      double dDeltaX=dFullWidth - dHeight;
      double dDeltaY=(dFullWidth + dHeight) / 2;
      dX+=dDeltaX;
      dY-=dDeltaY;
      g2d.rotate(dAngleInRadians,dX,dY);
      dYDiff=dY - dFullHeight;
      if (bShadow) {
        g2d.setPaint(new GradientPaint(new Point2D.Double(dX + shadowness,dYDiff + shadowness),(Color)_sxs.getColor(label.getShadowColor()),new Point2D.Double(dX + shadowness + dFullWidth,dY + shadowness),(Color)_sxs.getColor(label.getShadowColor().translucent())));
        fillShadow(g2d,new Rectangle2D.Double(dX + shadowness,dYDiff + shadowness,dFullWidth,dFullHeight));
      }
 else {
        final Rectangle2D.Double r2d=new Rectangle2D.Double(dX,dYDiff,dFullWidth,dFullHeight);
        if (clrBackground != null) {
          g2d.setColor(clrBackground);
          g2d.fill(r2d);
        }
        if (!bEmptyText) {
          g2d.setColor(clrText);
          for (int i=0; i < lineCount; i++) {
            textLayout=((ChartTextMetrics)textMetrics).getLayout(i);
            if (bRightAligned) {
              dWidth=textLayout.getBounds().getWidth();
              dXOffset=-insets.getLeft() + dFullWidth - dWidth - insets.getRight();
            }
 else             if (bCenterAligned) {
              dWidth=textLayout.getBounds().getWidth();
              dXOffset=-insets.getLeft() + (dFullWidth - dWidth) / 2;
            }
            textLayout.draw(g2d,(float)(dX + dXOffset + insets.getLeft()),(float)(((dY - dDescent) + (dHeight * i)) + insets.getTop()));
          }
        }
        renderOutline(renderer,label.getOutline(),r2d);
      }
    }
  }
  finally {
    g2d.setTransform(afTransform);
    cComp.recycleTextMetrics(textMetrics);
  }
}