Program: 170639
Project: 170639
Buggy source:
private void drawDataSet(Canvas canvas,CandlestickDataSet candlestickDataSet,float lMax,float lMin,float rMax,float rMin){
  float min, max;
switch (candlestickDataSet.getAxisDependency()) {
case AxisY.DEPENDENCY_RIGHT:
    min=rMin;
  max=rMax;
break;
case AxisY.DEPENDENCY_BOTH:
case AxisY.DEPENDENCY_LEFT:
default :
min=lMin;
max=lMax;
break;
}
mRenderPaint.setStrokeWidth(candlestickDataSet.getStrokeThickness());
mRenderPaint.setColor(candlestickDataSet.getColor());
int valueCount=candlestickDataSet.getEntryCount();
Path path=new Path();
path.reset();
for (int i=0; i < valueCount; i++) {
final CandlestickValue candlestick=candlestickDataSet.getEntryForIndex(i);
float candleWidth=candlestickDataSet.getCandleWidth();
if (candlestickDataSet.isAutoWidth()) {
candleWidth=mContentRect.width() / candlestickDataSet.getVisibleValueCount(mViewport);
}
float xPosition=getDrawX(i / (valueCount + 0f));
float highY=(max - candlestick.getHigh()) / (max - min) * mContentRect.height();
float lowY=(max - candlestick.getLow()) / (max - min) * mContentRect.height();
float openY=(max - candlestick.getOpen()) / (max - min) * mContentRect.height();
float closeY=(max - candlestick.getClose()) / (max - min) * mContentRect.height();
float widthPercent=0.8f;
mBodyBuffers[0]=xPosition + (1 - widthPercent) * 0.5f * candleWidth;
mBodyBuffers[1]=closeY;
mBodyBuffers[2]=mBodyBuffers[0] + candleWidth * widthPercent;
mBodyBuffers[3]=openY;
final float candlestickCenterX=xPosition + candleWidth * 0.5f;
mUpperShadowBuffers[0]=candlestickCenterX;
mUpperShadowBuffers[2]=candlestickCenterX;
mLowerShadowBuffers[0]=candlestickCenterX;
mLowerShadowBuffers[2]=candlestickCenterX;
candlestick.setX(candlestickCenterX);
candlestick.setY(closeY);
if (Float.compare(candlestick.getOpen(),candlestick.getClose()) > 0) {
mUpperShadowBuffers[1]=highY;
mUpperShadowBuffers[3]=openY;
mLowerShadowBuffers[1]=lowY;
mLowerShadowBuffers[3]=closeY;
if (candlestick.getColor() == CandlestickValue.COLOR_NONE) {
mRenderPaint.setColor(candlestickDataSet.getDecreasingColor());
}
 else {
mRenderPaint.setColor(candlestick.getColor());
}
if (candlestick.getPaintStyle() != null) {
mRenderPaint.setStyle(candlestick.getPaintStyle());
}
 else {
mRenderPaint.setStyle(candlestickDataSet.getDecreasingPaintStyle());
}
}
 else if (Float.compare(candlestick.getOpen(),candlestick.getClose()) < 0) {
mUpperShadowBuffers[1]=highY;
mUpperShadowBuffers[3]=closeY;
mLowerShadowBuffers[1]=lowY;
mLowerShadowBuffers[3]=openY;
if (candlestick.getColor() == CandlestickValue.COLOR_NONE) {
mRenderPaint.setColor(candlestickDataSet.getIncreasingColor());
}
 else {
mRenderPaint.setColor(candlestick.getColor());
}
if (candlestick.getPaintStyle() != null) {
mRenderPaint.setStyle(candlestick.getPaintStyle());
}
 else {
mRenderPaint.setStyle(candlestickDataSet.getIncreasingPaintStyle());
}
}
 else {
mUpperShadowBuffers[1]=highY;
mUpperShadowBuffers[3]=openY;
mLowerShadowBuffers[1]=lowY;
mLowerShadowBuffers[3]=mUpperShadowBuffers[3];
if (candlestick.getColor() == CandlestickValue.COLOR_NONE) {
mRenderPaint.setColor(candlestickDataSet.getNeutralColor());
}
 else {
mRenderPaint.setColor(candlestick.getColor());
}
}
if (candlestickDataSet.getLimitUpColor() != Color.TRANSPARENT && i > 0) {
final CandlestickValue previousValue=candlestickDataSet.getEntryForIndex(i - 1);
boolean isLimitUp=Float.compare((candlestick.getClose() - previousValue.getClose()) / previousValue.getClose(),0.095f) > 0;
if (isLimitUp) {
mRenderPaint.setColor(candlestickDataSet.getLimitUpColor());
}
}
canvas.drawRect(mBodyBuffers[0],mBodyBuffers[1],mBodyBuffers[2],mBodyBuffers[3],mRenderPaint);
canvas.drawLines(mUpperShadowBuffers,mRenderPaint);
canvas.drawLines(mLowerShadowBuffers,mRenderPaint);
}
}

Fixed version (ground truth):
private void drawDataSet(Canvas canvas,CandlestickDataSet candlestickDataSet,float lMax,float lMin,float rMax,float rMin){
  float min, max;
switch (candlestickDataSet.getAxisDependency()) {
case AxisY.DEPENDENCY_RIGHT:
    min=rMin;
  max=rMax;
break;
case AxisY.DEPENDENCY_BOTH:
case AxisY.DEPENDENCY_LEFT:
default :
min=lMin;
max=lMax;
break;
}
mRenderPaint.setStrokeWidth(candlestickDataSet.getStrokeThickness());
mRenderPaint.setColor(candlestickDataSet.getColor());
int valueCount=candlestickDataSet.getEntryCount();
for (int i=0; i < valueCount; i++) {
final CandlestickValue candlestick=candlestickDataSet.getEntryForIndex(i);
float candleWidth=candlestickDataSet.getCandleWidth();
if (candlestickDataSet.isAutoWidth()) {
candleWidth=mContentRect.width() / candlestickDataSet.getVisibleValueCount(mViewport);
}
float xPosition=getDrawX(i / (valueCount + 0f));
float highY=(max - candlestick.getHigh()) / (max - min) * mContentRect.height();
float lowY=(max - candlestick.getLow()) / (max - min) * mContentRect.height();
float openY=(max - candlestick.getOpen()) / (max - min) * mContentRect.height();
float closeY=(max - candlestick.getClose()) / (max - min) * mContentRect.height();
float widthPercent=0.8f;
mBodyBuffers[0]=xPosition + (1 - widthPercent) * 0.5f * candleWidth;
mBodyBuffers[1]=closeY;
mBodyBuffers[2]=mBodyBuffers[0] + candleWidth * widthPercent;
mBodyBuffers[3]=openY;
final float candlestickCenterX=xPosition + candleWidth * 0.5f;
mUpperShadowBuffers[0]=candlestickCenterX;
mUpperShadowBuffers[2]=candlestickCenterX;
mLowerShadowBuffers[0]=candlestickCenterX;
mLowerShadowBuffers[2]=candlestickCenterX;
candlestick.setX(candlestickCenterX);
candlestick.setY(closeY);
if (Float.compare(candlestick.getOpen(),candlestick.getClose()) > 0) {
mUpperShadowBuffers[1]=highY;
mUpperShadowBuffers[3]=openY;
mLowerShadowBuffers[1]=lowY;
mLowerShadowBuffers[3]=closeY;
if (candlestick.getColor() == CandlestickValue.COLOR_NONE) {
mRenderPaint.setColor(candlestickDataSet.getDecreasingColor());
}
 else {
mRenderPaint.setColor(candlestick.getColor());
}
if (candlestick.getPaintStyle() != null) {
mRenderPaint.setStyle(candlestick.getPaintStyle());
}
 else {
mRenderPaint.setStyle(candlestickDataSet.getDecreasingPaintStyle());
}
}
 else if (Float.compare(candlestick.getOpen(),candlestick.getClose()) < 0) {
mUpperShadowBuffers[1]=highY;
mUpperShadowBuffers[3]=closeY;
mLowerShadowBuffers[1]=lowY;
mLowerShadowBuffers[3]=openY;
if (candlestick.getColor() == CandlestickValue.COLOR_NONE) {
mRenderPaint.setColor(candlestickDataSet.getIncreasingColor());
}
 else {
mRenderPaint.setColor(candlestick.getColor());
}
if (candlestick.getPaintStyle() != null) {
mRenderPaint.setStyle(candlestick.getPaintStyle());
}
 else {
mRenderPaint.setStyle(candlestickDataSet.getIncreasingPaintStyle());
}
}
 else {
mUpperShadowBuffers[1]=highY;
mUpperShadowBuffers[3]=openY;
mLowerShadowBuffers[1]=lowY;
mLowerShadowBuffers[3]=mUpperShadowBuffers[3];
if (candlestick.getColor() == CandlestickValue.COLOR_NONE) {
mRenderPaint.setColor(candlestickDataSet.getNeutralColor());
}
 else {
mRenderPaint.setColor(candlestick.getColor());
}
}
if (candlestickDataSet.getLimitUpColor() != Color.TRANSPARENT && i > 0) {
final CandlestickValue previousValue=candlestickDataSet.getEntryForIndex(i - 1);
boolean isLimitUp=Float.compare((candlestick.getClose() - previousValue.getClose()) / previousValue.getClose(),0.095f) > 0;
if (isLimitUp) {
mRenderPaint.setColor(candlestickDataSet.getLimitUpColor());
}
}
canvas.drawRect(mBodyBuffers[0],mBodyBuffers[1],mBodyBuffers[2],mBodyBuffers[3],mRenderPaint);
canvas.drawLines(mUpperShadowBuffers,mRenderPaint);
canvas.drawLines(mLowerShadowBuffers,mRenderPaint);
}
}