nus-yam/ex-repair huggingface dataset:
Program: 111148
Project: 111148
Buggy source:
@Override public void onPageScrolled(int position,float positionOffset,int positionOffsetPixels){
  Log.d("String_Node_Str","String_Node_Str" + position);
}

Fixed version (ground truth):
@Override public void onPageScrolled(int position,float positionOffset,int positionOffsetPixels){
}
Program: 111149
Project: 111149
Buggy source:
@Override public void onPageSelected(int position){
  Log.d("String_Node_Str","String_Node_Str" + position);
  for (int i=0; i < mTabsLinearLayout.getChildCount(); i++) {
    TextView tv=(TextView)mTabsLinearLayout.getChildAt(i);
    if (i == position) {
      tv.setTextColor(getResources().getColor(R.color.steel_blue));
    }
 else {
      tv.setTextColor(getResources().getColor(android.R.color.darker_gray));
    }
  }
}

Fixed version (ground truth):
@Override public void onPageSelected(int position){
  for (int i=0; i < mTabsLinearLayout.getChildCount(); i++) {
    TextView tv=(TextView)mTabsLinearLayout.getChildAt(i);
    if (i == position) {
      tv.setTextColor(getResources().getColor(R.color.steel_blue));
    }
 else {
      tv.setTextColor(getResources().getColor(android.R.color.darker_gray));
    }
  }
}
Program: 111150
Project: 111150
Buggy source:
@Override public void onPageScrolled(int position,float positionOffset,int positionOffsetPixels){
  Log.d("String_Node_Str","String_Node_Str" + position);
}

Fixed version (ground truth):
@Override public void onPageScrolled(int position,float positionOffset,int positionOffsetPixels){
}
Program: 111151
Project: 111151
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_quick_return_twitter);
  bindUIElements();
  mSectionsPagerAdapter=new SectionsPagerAdapter(getFragmentManager());
  mViewPager.setAdapter(mSectionsPagerAdapter);
  mTabs.setAllCaps(false);
  mTabs.setShouldExpand(true);
  mTabs.setTextSize(QuickReturnUtils.dp2px(this,16));
  mTabs.setTabBackground(R.drawable.selector_bg_tab);
  mTabs.setIndicatorColorResource(R.color.steel_blue);
  mTabs.setOnPageChangeListener(mTabsOnPageChangeListener);
  mTabs.setViewPager(mViewPager);
  mTabsLinearLayout=((LinearLayout)mTabs.getChildAt(0));
  TextView tv=(TextView)mTabsLinearLayout.getChildAt(0);
  tv.setTextColor(getResources().getColor(R.color.steel_blue));
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_quick_return_twitter);
  bindUIElements();
  mSectionsPagerAdapter=new SectionsPagerAdapter(getFragmentManager());
  mViewPager.setAdapter(mSectionsPagerAdapter);
  mTabs.setAllCaps(false);
  mTabs.setShouldExpand(true);
  mTabs.setTextSize(QuickReturnUtils.dp2px(this,16));
  mTabs.setTabBackground(R.drawable.selector_bg_tab);
  mTabs.setIndicatorColorResource(R.color.steel_blue);
  mTabs.setIndicatorHeight(QuickReturnUtils.dp2px(this,5));
  mTabs.setOnPageChangeListener(mTabsOnPageChangeListener);
  mTabs.setViewPager(mViewPager);
  mTabsLinearLayout=((LinearLayout)mTabs.getChildAt(0));
  TextView tv=(TextView)mTabsLinearLayout.getChildAt(0);
  tv.setTextColor(getResources().getColor(R.color.steel_blue));
}
Program: 111152
Project: 111152
Buggy source:
@Override public void onPageSelected(int position){
  Log.d("String_Node_Str","String_Node_Str" + position);
  for (int i=0; i < mTabsLinearLayout.getChildCount(); i++) {
    TextView tv=(TextView)mTabsLinearLayout.getChildAt(i);
    if (i == position) {
      tv.setTextColor(getResources().getColor(R.color.steel_blue));
    }
 else {
      tv.setTextColor(getResources().getColor(android.R.color.darker_gray));
    }
  }
}

Fixed version (ground truth):
@Override public void onPageSelected(int position){
  for (int i=0; i < mTabsLinearLayout.getChildCount(); i++) {
    TextView tv=(TextView)mTabsLinearLayout.getChildAt(i);
    if (i == position) {
      tv.setTextColor(getResources().getColor(R.color.steel_blue));
    }
 else {
      tv.setTextColor(getResources().getColor(android.R.color.darker_gray));
    }
  }
}
Program: 111153
Project: 111153
Buggy source:
@Override public void onPageScrolled(int position,float positionOffset,int positionOffsetPixels){
  Log.d("String_Node_Str","String_Node_Str" + position);
}

Fixed version (ground truth):
@Override public void onPageScrolled(int position,float positionOffset,int positionOffsetPixels){
}
Program: 111154
Project: 111154
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mHeaderHeight=getResources().getDimensionPixelSize(R.dimen.header_height);
  mMinHeaderTranslation=-(mHeaderHeight * 2) + getActionBarHeight();
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mHeaderHeight=getResources().getDimensionPixelSize(R.dimen.header_height);
  mMinHeaderTranslation=-(mHeaderHeight * 2) + QuickReturnUtils.getActionBarHeight(getActivity());
}
Program: 111155
Project: 111155
Buggy source:
@SuppressLint("String_Node_Str") @Override public void onScroll(AbsListView view,int firstVisibleItem,int visibleItemCount,int totalItemCount){
  int scrollY=getScrollY();
  int diff=mPrevScrollY - scrollY;
  if (diff <= 0) {
    mDiffTotal=Math.max(mDiffTotal + diff,mMinHeaderTranslation);
  }
 else {
    mDiffTotal=Math.min(Math.max(mDiffTotal + diff,mMinHeaderTranslation),0);
  }
  if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
    mFooterAnim=new TranslateAnimation(0,0,-mDiffTotal,-mDiffTotal);
    mFooterAnim.setFillAfter(true);
    mFooterAnim.setDuration(0);
    mQuickReturnFooterLinearLayout.startAnimation(mFooterAnim);
    mHeaderAnim=new TranslateAnimation(0,0,mDiffTotal,mDiffTotal);
    mHeaderAnim.setFillAfter(true);
    mHeaderAnim.setDuration(0);
    mQuickReturnHeaderTextView.startAnimation(mHeaderAnim);
  }
 else {
    mQuickReturnFooterLinearLayout.setTranslationY(-mDiffTotal);
    mQuickReturnHeaderTextView.setTranslationY(mDiffTotal);
  }
  mPrevScrollY=scrollY;
}

Fixed version (ground truth):
@SuppressLint("String_Node_Str") @Override public void onScroll(AbsListView view,int firstVisibleItem,int visibleItemCount,int totalItemCount){
  int scrollY=QuickReturnUtils.getScrollY(mListView);
  int diff=mPrevScrollY - scrollY;
  if (diff <= 0) {
    mDiffTotal=Math.max(mDiffTotal + diff,mMinHeaderTranslation);
  }
 else {
    mDiffTotal=Math.min(Math.max(mDiffTotal + diff,mMinHeaderTranslation),0);
  }
  if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
    mFooterAnim=new TranslateAnimation(0,0,-mDiffTotal,-mDiffTotal);
    mFooterAnim.setFillAfter(true);
    mFooterAnim.setDuration(0);
    mQuickReturnFooterLinearLayout.startAnimation(mFooterAnim);
    mHeaderAnim=new TranslateAnimation(0,0,mDiffTotal,mDiffTotal);
    mHeaderAnim.setFillAfter(true);
    mHeaderAnim.setDuration(0);
    mQuickReturnHeaderTextView.startAnimation(mHeaderAnim);
  }
 else {
    mQuickReturnFooterLinearLayout.setTranslationY(-mDiffTotal);
    mQuickReturnHeaderTextView.setTranslationY(mDiffTotal);
  }
  mPrevScrollY=scrollY;
}
Program: 111156
Project: 111156
Buggy source:
@SuppressLint("String_Node_Str") @Override public void onScroll(AbsListView view,int firstVisibleItem,int visibleItemCount,int totalItemCount){
  int scrollY=getScrollY();
  int diff=mPrevScrollY - scrollY;
  if (diff <= 0) {
    mDiffTotal=Math.max(mDiffTotal + diff,-mMinFooterTranslation);
  }
 else {
    mDiffTotal=Math.min(Math.max(mDiffTotal + diff,-mMinFooterTranslation),0);
  }
  if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
    mAnim=new TranslateAnimation(0,0,-mDiffTotal,-mDiffTotal);
    mAnim.setFillAfter(true);
    mAnim.setDuration(0);
    mQuickReturnTextView.startAnimation(mAnim);
  }
 else {
    mQuickReturnTextView.setTranslationY(-mDiffTotal);
  }
  mPrevScrollY=scrollY;
}

Fixed version (ground truth):
@SuppressLint("String_Node_Str") @Override public void onScroll(AbsListView view,int firstVisibleItem,int visibleItemCount,int totalItemCount){
  int scrollY=QuickReturnUtils.getScrollY(mListView);
  int diff=mPrevScrollY - scrollY;
  if (diff <= 0) {
    mDiffTotal=Math.max(mDiffTotal + diff,-mMinFooterTranslation);
  }
 else {
    mDiffTotal=Math.min(Math.max(mDiffTotal + diff,-mMinFooterTranslation),0);
  }
  if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
    mAnim=new TranslateAnimation(0,0,-mDiffTotal,-mDiffTotal);
    mAnim.setFillAfter(true);
    mAnim.setDuration(0);
    mQuickReturnTextView.startAnimation(mAnim);
  }
 else {
    mQuickReturnTextView.setTranslationY(-mDiffTotal);
  }
  mPrevScrollY=scrollY;
}
Program: 111157
Project: 111157
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mHeaderHeight=getResources().getDimensionPixelSize(R.dimen.header_height2);
  mMinHeaderTranslation=-(mHeaderHeight) + getActionBarHeight();
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mHeaderHeight=getResources().getDimensionPixelSize(R.dimen.header_height2);
  mMinHeaderTranslation=-(mHeaderHeight) + QuickReturnUtils.getActionBarHeight(getActivity());
}
Program: 111158
Project: 111158
Buggy source:
@SuppressLint("String_Node_Str") @Override public void onScroll(AbsListView view,int firstVisibleItem,int visibleItemCount,int totalItemCount){
  int scrollY=getScrollY();
  int diff=mPrevScrollY - scrollY;
  if (diff <= 0) {
    mDiffTotal=Math.max(mDiffTotal + diff,mMinHeaderTranslation);
  }
 else {
    mDiffTotal=Math.min(Math.max(mDiffTotal + diff,mMinHeaderTranslation),0);
  }
  if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
    mAnim=new TranslateAnimation(0,0,mDiffTotal,mDiffTotal);
    mAnim.setFillAfter(true);
    mAnim.setDuration(0);
    mQuickReturnTextView.startAnimation(mAnim);
  }
 else {
    mQuickReturnTextView.setTranslationY(mDiffTotal);
  }
  mPrevScrollY=scrollY;
}

Fixed version (ground truth):
@SuppressLint("String_Node_Str") @Override public void onScroll(AbsListView view,int firstVisibleItem,int visibleItemCount,int totalItemCount){
  int scrollY=QuickReturnUtils.getScrollY(mListView);
  int diff=mPrevScrollY - scrollY;
  if (diff <= 0) {
    mDiffTotal=Math.max(mDiffTotal + diff,mMinHeaderTranslation);
  }
 else {
    mDiffTotal=Math.min(Math.max(mDiffTotal + diff,mMinHeaderTranslation),0);
  }
  if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
    mAnim=new TranslateAnimation(0,0,mDiffTotal,mDiffTotal);
    mAnim.setFillAfter(true);
    mAnim.setDuration(0);
    mQuickReturnTextView.startAnimation(mAnim);
  }
 else {
    mQuickReturnTextView.setTranslationY(mDiffTotal);
  }
  mPrevScrollY=scrollY;
}
Program: 111159
Project: 111159
Buggy source:
@Override protected void onDestroy(){
  super.onDestroy();
  Crouton.cancelAllCroutons();
}

Fixed version (ground truth):
@Override protected void onDestroy(){
  super.onDestroy();
  if (mService != null) {
    unbindService(mServiceConn);
  }
  Crouton.cancelAllCroutons();
}
Program: 111160
Project: 111160
Buggy source:
@Override public void onViewCreated(View view,Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  bindUIElements(view);
  mValues=getResources().getStringArray(R.array.languages);
  ArrayAdapter<String> adapter=new ArrayAdapter<String>(getActivity(),R.layout.list_item,R.id.item_tv,mValues);
  mQuickReturnListView.setAdapter(adapter);
  mQuickReturnListView.getViewTreeObserver().addOnGlobalLayoutListener(mQuickReturnListViewOnGlobalLayoutListener);
  mQuickReturnListView.setOnScrollListener(mQuickReturnListViewOnScrollListener);
}

Fixed version (ground truth):
@Override public void onViewCreated(View view,Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  bindUIElements(view);
  mValues=getResources().getStringArray(R.array.countries);
  ArrayAdapter<String> adapter=new ArrayAdapter<String>(getActivity(),R.layout.list_item,R.id.item_tv,mValues);
  mQuickReturnListView.setAdapter(adapter);
  mQuickReturnListView.getViewTreeObserver().addOnGlobalLayoutListener(mQuickReturnListViewOnGlobalLayoutListener);
  mQuickReturnListView.setOnScrollListener(mQuickReturnListViewOnScrollListener);
}
Program: 111161
Project: 111161
Buggy source:
@Override public void onViewCreated(View view,Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  bindUIElements(view);
  mValues=getResources().getStringArray(R.array.languages);
  ArrayAdapter<String> adapter=new ArrayAdapter<String>(getActivity(),R.layout.list_item,R.id.item_tv,mValues);
  mQuickReturnListView.setAdapter(adapter);
  mQuickReturnListView.getViewTreeObserver().addOnGlobalLayoutListener(mQuickReturnListViewOnGlobalLayoutListener);
  mQuickReturnListView.setOnScrollListener(mQuickReturnListViewOnScrollListener);
}

Fixed version (ground truth):
@Override public void onViewCreated(View view,Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  bindUIElements(view);
  mValues=getResources().getStringArray(R.array.countries);
  ArrayAdapter<String> adapter=new ArrayAdapter<String>(getActivity(),R.layout.list_item,R.id.item_tv,mValues);
  mQuickReturnListView.setAdapter(adapter);
  mQuickReturnListView.getViewTreeObserver().addOnGlobalLayoutListener(mQuickReturnListViewOnGlobalLayoutListener);
  mQuickReturnListView.setOnScrollListener(mQuickReturnListViewOnScrollListener);
}
Program: 111162
Project: 111162
Buggy source:
@Override public void onViewCreated(View view,Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  bindUIElements(view);
  mValues=getResources().getStringArray(R.array.languages);
  ArrayAdapter<String> adapter=new ArrayAdapter<String>(getActivity(),R.layout.list_item,R.id.item_tv,mValues);
  mQuickReturnListView.setAdapter(adapter);
  mQuickReturnListView.getViewTreeObserver().addOnGlobalLayoutListener(mQuickReturnListViewOnGlobalLayoutListener);
  mQuickReturnListView.setOnScrollListener(mQuickReturnListViewOnScrollListener);
}

Fixed version (ground truth):
@Override public void onViewCreated(View view,Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  bindUIElements(view);
  mValues=getResources().getStringArray(R.array.countries);
  ArrayAdapter<String> adapter=new ArrayAdapter<String>(getActivity(),R.layout.list_item,R.id.item_tv,mValues);
  mQuickReturnListView.setAdapter(adapter);
  mQuickReturnListView.getViewTreeObserver().addOnGlobalLayoutListener(mQuickReturnListViewOnGlobalLayoutListener);
  mQuickReturnListView.setOnScrollListener(mQuickReturnListViewOnScrollListener);
}
Program: 111163
Project: 111163
Buggy source:
@Override public void onViewCreated(View view,Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  bindUIElements(view);
  mValues=getResources().getStringArray(R.array.languages);
  ArrayAdapter<String> adapter=new ArrayAdapter<String>(getActivity(),R.layout.list_item,R.id.item_tv,mValues);
  mQuickReturnListView.setAdapter(adapter);
  mQuickReturnListView.getViewTreeObserver().addOnGlobalLayoutListener(mQuickReturnListViewOnGlobalLayoutListener);
  mQuickReturnListView.setOnScrollListener(mQuickReturnListViewOnScrollListener);
}

Fixed version (ground truth):
@Override public void onViewCreated(View view,Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  bindUIElements(view);
  mValues=getResources().getStringArray(R.array.countries);
  ArrayAdapter<String> adapter=new ArrayAdapter<String>(getActivity(),R.layout.list_item,R.id.item_tv,mValues);
  mQuickReturnListView.setAdapter(adapter);
  mQuickReturnListView.getViewTreeObserver().addOnGlobalLayoutListener(mQuickReturnListViewOnGlobalLayoutListener);
  mQuickReturnListView.setOnScrollListener(mQuickReturnListViewOnScrollListener);
}
Program: 111164
Project: 111164
Buggy source:
@SuppressLint("String_Node_Str") @Override public void onScroll(AbsListView view,int firstVisibleItem,int visibleItemCount,int totalItemCount){
  mScrollY=0;
  int translationY=0;
  if (mQuickReturnListView.scrollYIsComputed()) {
    mScrollY=mQuickReturnListView.getComputedScrollY();
  }
  int rawY=mScrollY;
switch (mState) {
case STATE_OFFSCREEN:
    if (rawY >= mMinRawY) {
      mMinRawY=rawY;
    }
 else {
      mState=STATE_RETURNING;
    }
  translationY=rawY;
break;
case STATE_ONSCREEN:
if (rawY > mQuickReturnHeight) {
mState=STATE_OFFSCREEN;
mMinRawY=rawY;
}
translationY=rawY;
break;
case STATE_RETURNING:
translationY=(rawY - mMinRawY) + mQuickReturnHeight;
System.out.println(translationY);
if (translationY < 0) {
translationY=0;
mMinRawY=rawY + mQuickReturnHeight;
}
if (rawY == 0) {
mState=STATE_ONSCREEN;
translationY=0;
}
if (translationY > mQuickReturnHeight) {
mState=STATE_OFFSCREEN;
mMinRawY=rawY;
}
break;
}
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
mAnim=new TranslateAnimation(0,0,translationY,translationY);
mAnim.setFillAfter(true);
mAnim.setDuration(0);
mQuickReturnTextView.startAnimation(mAnim);
}
 else {
mQuickReturnTextView.setTranslationY(translationY);
}
}

Fixed version (ground truth):
@SuppressLint("String_Node_Str") @Override public void onScroll(AbsListView view,int firstVisibleItem,int visibleItemCount,int totalItemCount){
  mScrollY=0;
  int translationY=0;
  if (mQuickReturnListView.scrollYIsComputed()) {
    mScrollY=mQuickReturnListView.getComputedScrollY();
  }
  int rawY=mScrollY;
switch (mState) {
case STATE_OFFSCREEN:
    if (rawY >= mMinRawY) {
      mMinRawY=rawY;
    }
 else {
      mState=STATE_RETURNING;
    }
  translationY=rawY;
break;
case STATE_ONSCREEN:
if (rawY > mQuickReturnHeight) {
mState=STATE_OFFSCREEN;
mMinRawY=rawY;
}
translationY=rawY;
break;
case STATE_RETURNING:
translationY=(rawY - mMinRawY) + mQuickReturnHeight;
if (translationY < 0) {
translationY=0;
mMinRawY=rawY + mQuickReturnHeight;
}
if (rawY == 0) {
mState=STATE_ONSCREEN;
translationY=0;
}
if (translationY > mQuickReturnHeight) {
mState=STATE_OFFSCREEN;
mMinRawY=rawY;
}
break;
}
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
mAnim=new TranslateAnimation(0,0,translationY,translationY);
mAnim.setFillAfter(true);
mAnim.setDuration(0);
mQuickReturnTextView.startAnimation(mAnim);
}
 else {
mQuickReturnTextView.setTranslationY(translationY);
}
}
Program: 111165
Project: 111165
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (getArguments() != null) {
    mQuickReturnType=QuickReturnType.valueOf(getArguments().getString("String_Node_Str"));
  }
switch (mQuickReturnType) {
case HEADER:
    mQuickReturnHeaderViewVisible=false;
  break;
case FOOTER:
mQuickReturnFooterViewVisible=true;
break;
case BOTH:
mQuickReturnHeaderViewVisible=false;
mQuickReturnFooterViewVisible=true;
break;
}
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (getArguments() != null) {
    mQuickReturnType=QuickReturnType.valueOf(getArguments().getString("String_Node_Str"));
  }
}
Program: 111166
Project: 111166
Buggy source:
@Override public void onViewCreated(View view,Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  bindUIElements(view);
  mNotifyingScrollView.setOnScrollChangedListener(mOnScrollChangedListener);
  mNotifyingScrollView.setOverScrollEnabled(false);
}

Fixed version (ground truth):
@Override public void onViewCreated(View view,Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  bindUIElements(view);
switch (mQuickReturnType) {
case HEADER:
    mQuickReturnHeaderViewVisible=false;
  break;
case FOOTER:
mQuickReturnFooterViewVisible=true;
mQuickReturnFooterTextView.setVisibility(View.VISIBLE);
break;
case BOTH:
mQuickReturnHeaderViewVisible=false;
mQuickReturnFooterViewVisible=true;
mQuickReturnFooterTextView.setVisibility(View.VISIBLE);
break;
}
mNotifyingScrollView.setOnScrollChangedListener(mOnScrollChangedListener);
mNotifyingScrollView.setOverScrollEnabled(false);
}
Program: 111167
Project: 111167
Buggy source:
/** 
 * Calculates the legend bounds for a custom list of legends.
 */
protected void onLegendDataChanged(){
  int legendCount=mLegendList.size();
  float margin=(mLegendWidth / legendCount);
  float currentOffset=0;
  for (  LegendModel model : mLegendList) {
    model.setLegendBounds(new RectF(currentOffset,0,currentOffset + margin,mLegendHeight));
    Rect textBounds=new Rect();
    mLegendPaint.getTextBounds(model.getLegendLabel(),0,model.getLegendLabel().length(),textBounds);
    model.setTextBounds(textBounds);
    currentOffset+=margin;
  }
  invalidateGlobal();
}

Fixed version (ground truth):
/** 
 * Calculates the legend bounds for a custom list of legends.
 */
protected void onLegendDataChanged(){
  int legendCount=mLegendList.size();
  float margin=(mGraphWidth / legendCount);
  float currentOffset=0;
  for (  LegendModel model : mLegendList) {
    model.setLegendBounds(new RectF(currentOffset,0,currentOffset + margin,mLegendHeight));
    currentOffset+=margin;
  }
  Utils.calculateLegendInformation(mLegendList,0,mGraphWidth,mLegendPaint);
  invalidateGlobal();
}
Program: 111168
Project: 111168
Buggy source:
@Override protected boolean onGraphOverlayTouchEvent(MotionEvent _Event){
  super.onGraphOverlayTouchEvent(_Event);
  if (!mStartedAnimation && !mSeries.isEmpty()) {
    mScaleGestureDetector.onTouchEvent(_Event);
    mGestureDetector.onTouchEvent(_Event);
    float newX=getScaledXCoordinate(_Event.getX());
    float newY=_Event.getY();
switch (_Event.getAction()) {
case MotionEvent.ACTION_UP:
      if (!mIsInteracting) {
        findNearestPoint(newX,newY);
      }
 else {
        mIsInteracting=false;
      }
    return true;
}
}
return true;
}

Fixed version (ground truth):
@Override protected boolean onGraphOverlayTouchEvent(MotionEvent _Event){
  super.onGraphOverlayTouchEvent(_Event);
  if (!mStartedAnimation && containsPoints()) {
    mScaleGestureDetector.onTouchEvent(_Event);
    mGestureDetector.onTouchEvent(_Event);
    float newX=getScaledXCoordinate(_Event.getX());
    float newY=_Event.getY();
switch (_Event.getAction()) {
case MotionEvent.ACTION_UP:
      if (!mIsInteracting) {
        findNearestPoint(newX,newY);
      }
 else {
        mIsInteracting=false;
      }
    return true;
}
}
return true;
}
Program: 111169
Project: 111169
Buggy source:
public void setUseCustomLegend(boolean _useCustomLegend){
  mUseCustomLegend=_useCustomLegend;
  invalidateGlobal();
}

Fixed version (ground truth):
public void setUseCustomLegend(boolean _useCustomLegend){
  mUseCustomLegend=_useCustomLegend;
  onLegendDataChanged();
}
Program: 111170
Project: 111170
Buggy source:
@Override protected void onLegendDraw(Canvas _Canvas){
  super.onLegendDraw(_Canvas);
  mLegendPaint.setColor(mLegendColor);
  mLegendPaint.setStrokeWidth(DEF_LEGEND_STROKE);
  if (!mSeries.isEmpty()) {
    _Canvas.translate(Utils.getTranslationX(mDrawMatrixValues),0);
    if (mUseCustomLegend) {
      for (      LegendModel model : mLegendList) {
        Rect textBounds=model.getTextBounds();
        RectF bounds=model.getLegendBounds();
        _Canvas.drawText(model.getLegendLabel(),bounds.centerX() - (textBounds.width() / 2),bounds.centerY(),mLegendPaint);
        _Canvas.drawLine(bounds.centerX(),bounds.centerY() - textBounds.height() - mLegendTopPadding,bounds.centerX(),mLegendTopPadding,mLegendPaint);
      }
    }
 else {
      List<? extends BaseModel> list=mSeries.get(0).getSeries();
      for (      BaseModel model : list) {
        if (model.canShowLabel()) {
          RectF bounds=model.getLegendBounds();
          _Canvas.drawText(model.getLegendLabel(),model.getLegendLabelPosition(),bounds.bottom - mMaxFontHeight,mLegendPaint);
          _Canvas.drawLine(bounds.centerX(),bounds.bottom - mMaxFontHeight * 2 - mLegendTopPadding,bounds.centerX(),mLegendTopPadding,mLegendPaint);
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void onLegendDraw(Canvas _Canvas){
  super.onLegendDraw(_Canvas);
  mLegendPaint.setColor(mLegendColor);
  mLegendPaint.setStrokeWidth(DEF_LEGEND_STROKE);
  if (!mSeries.isEmpty()) {
    _Canvas.translate(Utils.getTranslationX(mDrawMatrixValues),0);
    if (mUseCustomLegend) {
      for (      LegendModel model : mLegendList) {
        RectF bounds=model.getLegendBounds();
        _Canvas.drawText(model.getLegendLabel(),model.getLegendLabelPosition(),bounds.bottom - mMaxFontHeight,mLegendPaint);
        _Canvas.drawLine(bounds.centerX(),bounds.bottom - mMaxFontHeight * 2 - mLegendTopPadding,bounds.centerX(),mLegendTopPadding,mLegendPaint);
      }
    }
 else {
      List<? extends BaseModel> list=mSeries.get(0).getSeries();
      for (      BaseModel model : list) {
        if (model.canShowLabel()) {
          RectF bounds=model.getLegendBounds();
          _Canvas.drawText(model.getLegendLabel(),model.getLegendLabelPosition(),bounds.bottom - mMaxFontHeight,mLegendPaint);
          _Canvas.drawLine(bounds.centerX(),bounds.bottom - mMaxFontHeight * 2 - mLegendTopPadding,bounds.centerX(),mLegendTopPadding,mLegendPaint);
        }
      }
    }
  }
}
Program: 111172
Project: 111172
Buggy source:
public void resetZoom(){
  mDrawMatrixValues=new float[]{1f,0f,0f,0f,1f,0f,0f,0f,1f};
  mDrawMatrix.setValues(mDrawMatrixValues);
  if (!mSeries.isEmpty()) {
    recalculateXCoordinates(mGraphWidth * mDrawMatrixValues[0]);
    if (calculateLegendBounds())     Utils.calculateLegendInformation(mSeries.get(0).getSeries(),0,mGraphWidth * mDrawMatrixValues[0],mLegendPaint);
    calculateValueTextHeight();
  }
  invalidateGlobal();
}

Fixed version (ground truth):
public void resetZoom(boolean _recalculate){
  mDrawMatrixValues=new float[]{1f,0f,0f,0f,1f,0f,0f,0f,1f};
  mDrawMatrix.setValues(mDrawMatrixValues);
  if (!mSeries.isEmpty() && _recalculate) {
    recalculateXCoordinates(mGraphWidth * mDrawMatrixValues[0]);
    if (calculateLegendBounds())     Utils.calculateLegendInformation(mSeries.get(0).getSeries(),0,mGraphWidth * mDrawMatrixValues[0],mLegendPaint);
    calculateValueTextHeight();
  }
  invalidateGlobal();
}
Program: 111173
Project: 111173
Buggy source:
public void setMaxZoomY(float _maxZoomY){
  mMaxZoomY=_maxZoomY;
  resetZoom();
}

Fixed version (ground truth):
public void setMaxZoomY(float _maxZoomY){
  mMaxZoomY=_maxZoomY;
  resetZoom(true);
}
Program: 111174
Project: 111174
Buggy source:
public void setMaxZoomX(float _maxZoomX){
  mMaxZoomX=_maxZoomX;
  resetZoom();
}

Fixed version (ground truth):
public void setMaxZoomX(float _maxZoomX){
  mMaxZoomX=_maxZoomX;
  resetZoom(true);
}
Program: 111175
Project: 111175
Buggy source:
@Override public void onReset(){
  mCubicValueLineChart.resetZoom();
}

Fixed version (ground truth):
@Override public void onReset(){
  mCubicValueLineChart.resetZoom(true);
}
Program: 111176
Project: 111176
Buggy source:
@Override public void onReset(){
  mValueLineChart.resetZoom();
}

Fixed version (ground truth):
@Override public void onReset(){
  mValueLineChart.resetZoom(true);
}
Program: 111177
Project: 111177
Buggy source:
/** 
 * Constructor that is called when inflating a view from XML. This is called when a view is being constructed from an XML file, supplying attributes that were specified in the XML file. This version uses a default style of 0, so the only attribute values applied are those in the Context's Theme and the given AttributeSet. <p/> <p/> The method onFinishInflate() will be called after all children have been added.
 * @param context The Context the view is running in, through which it canaccess the current theme, resources, etc.
 * @param attrs   The attributes of the XML tag that is inflating the view.
 * @see #View(android.content.Context,android.util.AttributeSet,int)
 */
public BaseChart(Context context,AttributeSet attrs){
  super(context,attrs);
  TypedArray a=context.getTheme().obtainStyledAttributes(attrs,R.styleable.BaseChart,0,0);
  try {
    mLegendHeight=a.getDimension(R.styleable.BaseChart_egLegendHeight,Utils.dpToPx(DEF_LEGEND_HEIGHT));
    mLegendTextSize=a.getDimension(R.styleable.BaseChart_egLegendTextSize,Utils.dpToPx(DEF_LEGEND_TEXT_SIZE));
    mAnimationTime=a.getInt(R.styleable.BaseChart_egAnimationTime,DEF_ANIMATION_TIME);
    mShowDecimal=a.getBoolean(R.styleable.BaseChart_egShowDecimal,DEF_SHOW_DECIMAL);
    mLegendColor=a.getColor(R.styleable.BaseChart_egLegendColor,DEF_LEGEND_COLOR);
  }
  finally {
    a.recycle();
  }
}

Fixed version (ground truth):
/** 
 * Constructor that is called when inflating a view from XML. This is called when a view is being constructed from an XML file, supplying attributes that were specified in the XML file. This version uses a default style of 0, so the only attribute values applied are those in the Context's Theme and the given AttributeSet. <p/> <p/> The method onFinishInflate() will be called after all children have been added.
 * @param context The Context the view is running in, through which it canaccess the current theme, resources, etc.
 * @param attrs   The attributes of the XML tag that is inflating the view.
 * @see #View(android.content.Context,android.util.AttributeSet,int)
 */
public BaseChart(Context context,AttributeSet attrs){
  super(context,attrs);
  TypedArray a=context.getTheme().obtainStyledAttributes(attrs,R.styleable.BaseChart,0,0);
  try {
    mLegendHeight=a.getDimension(R.styleable.BaseChart_egLegendHeight,Utils.dpToPx(DEF_LEGEND_HEIGHT));
    mLegendTextSize=a.getDimension(R.styleable.BaseChart_egLegendTextSize,Utils.dpToPx(DEF_LEGEND_TEXT_SIZE));
    mAnimationTime=a.getInt(R.styleable.BaseChart_egAnimationTime,DEF_ANIMATION_TIME);
    mShowDecimal=a.getBoolean(R.styleable.BaseChart_egShowDecimal,DEF_SHOW_DECIMAL);
    mLegendColor=a.getColor(R.styleable.BaseChart_egLegendColor,DEF_LEGEND_COLOR);
    mEmptyDataText=a.getString(R.styleable.BaseChart_egEmptyDataText);
  }
  finally {
    a.recycle();
  }
  if (mEmptyDataText == null) {
    mEmptyDataText=DEF_EMPTY_DATA_TEXT;
  }
}
Program: 111178
Project: 111178
Buggy source:
@Override protected void onGraphDraw(Canvas _Canvas){
  super.onGraphDraw(_Canvas);
  if (!mPieData.isEmpty()) {
    float innerStartAngle=0;
    float innerSweepAngle=0;
    int amountOfPieSlices=mPieData.size();
    for (int pieIndex=0; pieIndex < amountOfPieSlices; pieIndex++) {
      PieModel model=mPieData.get(pieIndex);
      mGraphPaint.setColor(model.getColor());
      float startAngle;
      float sweepAngle=(model.getEndAngle() - model.getStartAngle()) * mRevealValue;
      if (mOpenClockwise) {
        startAngle=model.getStartAngle() * mRevealValue;
      }
 else {
        startAngle=360 - model.getEndAngle() * mRevealValue;
      }
      if (pieIndex == 0) {
        innerStartAngle=startAngle + (mOpenClockwise ? 0 : (float)Math.ceil(sweepAngle));
      }
      if (mOpenClockwise)       innerSweepAngle+=sweepAngle;
 else       innerSweepAngle-=(float)Math.ceil(sweepAngle);
      _Canvas.drawArc(mGraphBounds,startAngle,sweepAngle,true,mGraphPaint);
      if (mUseInnerPadding) {
        mGraphPaint.setColor(model.getHighlightedColor());
        _Canvas.drawArc(mInnerBounds,startAngle,sweepAngle,true,mGraphPaint);
      }
    }
    if (mUseInnerPadding) {
      mGraphPaint.setColor(mInnerPaddingColor);
      _Canvas.drawArc(mInnerOutlineBounds,innerStartAngle,innerSweepAngle,true,mGraphPaint);
    }
  }
 else {
  }
}

Fixed version (ground truth):
@Override protected void onGraphDraw(Canvas _Canvas){
  super.onGraphDraw(_Canvas);
  if (!mPieData.isEmpty()) {
    float innerStartAngle=0;
    float innerSweepAngle=0;
    int amountOfPieSlices=mPieData.size();
    for (int pieIndex=0; pieIndex < amountOfPieSlices; pieIndex++) {
      PieModel model=mPieData.get(pieIndex);
      mGraphPaint.setColor(model.getColor());
      float startAngle;
      float sweepAngle=(model.getEndAngle() - model.getStartAngle()) * mRevealValue;
      if (mOpenClockwise) {
        startAngle=model.getStartAngle() * mRevealValue;
      }
 else {
        startAngle=360 - model.getEndAngle() * mRevealValue;
      }
      if (pieIndex == 0) {
        innerStartAngle=startAngle + (mOpenClockwise ? 0 : (float)Math.ceil(sweepAngle));
      }
      if (mOpenClockwise)       innerSweepAngle+=sweepAngle;
 else       innerSweepAngle-=(float)Math.ceil(sweepAngle);
      _Canvas.drawArc(mGraphBounds,startAngle,sweepAngle,true,mGraphPaint);
      if (mUseInnerPadding) {
        mGraphPaint.setColor(model.getHighlightedColor());
        _Canvas.drawArc(mInnerBounds,startAngle,sweepAngle,true,mGraphPaint);
      }
    }
    if (mUseInnerPadding) {
      mGraphPaint.setColor(mInnerPaddingColor);
      _Canvas.drawArc(mInnerOutlineBounds,innerStartAngle,innerSweepAngle,true,mGraphPaint);
    }
  }
 else {
    mGraphPaint.setColor(0xFFB6B6B6);
    _Canvas.drawArc(mGraphBounds,0,360,true,mGraphPaint);
    if (mUseInnerPadding) {
      mGraphPaint.setColor(0xFFC6C6C6);
      _Canvas.drawArc(mInnerBounds,0,360,true,mGraphPaint);
      mGraphPaint.setColor(mInnerPaddingColor);
      _Canvas.drawArc(mInnerOutlineBounds,0,360,true,mGraphPaint);
    }
  }
}
Program: 111179
Project: 111179
Buggy source:
@Override protected void onLegendDraw(Canvas _Canvas){
  super.onLegendDraw(_Canvas);
  _Canvas.drawPath(mTriangle,mLegendPaint);
  float height=mMaxFontHeight=Utils.calculateMaxTextHeight(mLegendPaint);
  if (!mPieData.isEmpty()) {
    PieModel model=mPieData.get(mCurrentItem);
    mLegendPaint.getTextBounds(model.getLegendLabel(),0,model.getLegendLabel().length(),mTextBounds);
    _Canvas.drawText(model.getLegendLabel(),(mLegendWidth / 2) - (mTextBounds.width() / 2),mIndicatorSize * 2 + mIndicatorBottomMargin + mIndicatorTopMargin + height,mLegendPaint);
  }
 else {
    String str="String_Node_Str";
    mLegendPaint.getTextBounds(str,0,str.length(),mTextBounds);
    _Canvas.drawText(str,(mLegendWidth / 2) - (mTextBounds.width() / 2),mIndicatorSize * 2 + mIndicatorBottomMargin + mIndicatorTopMargin + height,mLegendPaint);
  }
}

Fixed version (ground truth):
@Override protected void onLegendDraw(Canvas _Canvas){
  super.onLegendDraw(_Canvas);
  _Canvas.drawPath(mTriangle,mLegendPaint);
  float height=mMaxFontHeight=Utils.calculateMaxTextHeight(mLegendPaint);
  if (!mPieData.isEmpty()) {
    PieModel model=mPieData.get(mCurrentItem);
    mLegendPaint.getTextBounds(model.getLegendLabel(),0,model.getLegendLabel().length(),mTextBounds);
    _Canvas.drawText(model.getLegendLabel(),(mLegendWidth / 2) - (mTextBounds.width() / 2),mIndicatorSize * 2 + mIndicatorBottomMargin + mIndicatorTopMargin + height,mLegendPaint);
  }
 else {
    mLegendPaint.getTextBounds(mEmptyDataText,0,mEmptyDataText.length(),mTextBounds);
    _Canvas.drawText(mEmptyDataText,(mLegendWidth / 2) - (mTextBounds.width() / 2),mIndicatorSize * 2 + mIndicatorBottomMargin + mIndicatorTopMargin + height,mLegendPaint);
  }
}
Program: 111182
Project: 111182
Buggy source:
/** 
 * This is called during layout when the size of this view has changed. If you were just added to the view hierarchy, you're called with the old values of 0.
 * @param w    Current width of this view.
 * @param h    Current height of this view.
 * @param oldw Old width of this view.
 * @param oldh Old height of this view.
 */
@Override protected void onSizeChanged(int w,int h,int oldw,int oldh){
  super.onSizeChanged(w,h,oldw,oldh);
  onDataChanged();
  if (mUseCustomLegend) {
    onLegendDataChanged();
  }
}

Fixed version (ground truth):
/** 
 * This is called during layout when the size of this view has changed. If you were just added to the view hierarchy, you're called with the old values of 0.
 * @param w    Current width of this view.
 * @param h    Current height of this view.
 * @param oldw Old width of this view.
 * @param oldh Old height of this view.
 */
@Override protected void onSizeChanged(int w,int h,int oldw,int oldh){
  super.onSizeChanged(w,h,oldw,oldh);
  mUsableGraphHeight=(int)(mGraphHeight - mGraphHeightPadding);
  onDataChanged();
  if (mUseCustomLegend) {
    onLegendDataChanged();
  }
}
Program: 111183
Project: 111183
Buggy source:
public void resetZoom(){
  Log.d(LOG_TAG,"String_Node_Str" + mDrawMatrix.toShortString());
  mDrawMatrixValues=new float[]{1f,0f,0f,0f,1f,0f,0f,0f,1f};
  mDrawMatrix.setValues(mDrawMatrixValues);
  recalculateXCoordinates(mGraphWidth * mDrawMatrixValues[0]);
  if (calculateLegendBounds())   Utils.calculateLegendInformation(mSeries.get(0).getSeries(),0,mGraphWidth * mDrawMatrixValues[0],mLegendPaint);
  calculateValueTextHeight();
  invalidateGlobal();
}

Fixed version (ground truth):
public void resetZoom(){
  mDrawMatrixValues=new float[]{1f,0f,0f,0f,1f,0f,0f,0f,1f};
  mDrawMatrix.setValues(mDrawMatrixValues);
  if (!mSeries.isEmpty()) {
    recalculateXCoordinates(mGraphWidth * mDrawMatrixValues[0]);
    if (calculateLegendBounds())     Utils.calculateLegendInformation(mSeries.get(0).getSeries(),0,mGraphWidth * mDrawMatrixValues[0],mLegendPaint);
    calculateValueTextHeight();
  }
  invalidateGlobal();
}
Program: 111184
Project: 111184
Buggy source:
@Override protected boolean onGraphOverlayTouchEvent(MotionEvent _Event){
  boolean result=mGestureDetector.onTouchEvent(_Event);
switch (_Event.getAction()) {
case MotionEvent.ACTION_DOWN:
    performClick();
  result=true;
if (mListener == null) {
  BaseBarChart.this.onTouchEvent(_Event);
}
 else {
  float newX=_Event.getX() + mCurrentViewport.left;
  float newY=_Event.getY();
  int counter=0;
  for (  RectF rectF : getBarBounds()) {
    if (Utils.intersectsPointWithRectF(rectF,newX,newY)) {
      mListener.onBarClicked(counter);
      break;
    }
    counter++;
  }
}
break;
}
return result;
}

Fixed version (ground truth):
@Override protected boolean onGraphOverlayTouchEvent(MotionEvent _Event){
  boolean result=mGestureDetector.onTouchEvent(_Event);
switch (_Event.getAction()) {
case MotionEvent.ACTION_DOWN:
    result=true;
  if (mListener == null) {
    BaseBarChart.this.onTouchEvent(_Event);
  }
 else {
    float newX=_Event.getX() + mCurrentViewport.left;
    float newY=_Event.getY();
    int counter=0;
    for (    RectF rectF : getBarBounds()) {
      if (Utils.intersectsPointWithRectF(rectF,newX,newY)) {
        mListener.onBarClicked(counter);
        break;
      }
      counter++;
    }
  }
break;
}
return result;
}
Program: 111186
Project: 111186
Buggy source:
@Override public boolean onDown(MotionEvent e){
  mGraph.accelerate();
  if (isAnimationRunning()) {
    stopScrolling();
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onDown(MotionEvent e){
  if (isAnimationRunning()) {
    stopScrolling();
  }
  return true;
}
Program: 111187
Project: 111187
Buggy source:
@Override protected void onGraphDraw(Canvas _Canvas){
  super.onGraphDraw(_Canvas);
  if (!mPieData.isEmpty()) {
    for (    PieModel model : mPieData) {
      mGraphPaint.setColor(model.getColor());
      float startAngle;
      if (mOpenClockwise) {
        startAngle=model.getStartAngle() * mRevealValue;
      }
 else {
        startAngle=360 - model.getEndAngle() * mRevealValue;
      }
      float sweepAngle=(model.getEndAngle() - model.getStartAngle()) * mRevealValue;
      _Canvas.drawArc(mGraphBounds,startAngle,sweepAngle,true,mGraphPaint);
      if (mUseInnerPadding) {
        mGraphPaint.setColor(model.getHighlightedColor());
        _Canvas.drawArc(mInnerBounds,startAngle,sweepAngle,true,mGraphPaint);
      }
    }
    if (mUseInnerPadding) {
      mGraphPaint.setColor(mInnerPaddingColor);
      if (mOpenClockwise) {
        _Canvas.drawArc(mInnerOutlineBounds,0,(360 * mRevealValue),true,mGraphPaint);
      }
 else {
        _Canvas.drawArc(mInnerOutlineBounds,0,(360 * -mRevealValue),true,mGraphPaint);
      }
    }
  }
 else {
  }
}

Fixed version (ground truth):
@Override protected void onGraphDraw(Canvas _Canvas){
  super.onGraphDraw(_Canvas);
  if (!mPieData.isEmpty()) {
    float innerStartAngle=0;
    float innerSweepAngle=0;
    int amountOfPieSlices=mPieData.size();
    for (int pieIndex=0; pieIndex < amountOfPieSlices; pieIndex++) {
      PieModel model=mPieData.get(pieIndex);
      mGraphPaint.setColor(model.getColor());
      float startAngle;
      float sweepAngle=(model.getEndAngle() - model.getStartAngle()) * mRevealValue;
      if (mOpenClockwise) {
        startAngle=model.getStartAngle() * mRevealValue;
      }
 else {
        startAngle=360 - model.getEndAngle() * mRevealValue;
      }
      if (pieIndex == 0) {
        innerStartAngle=startAngle + (mOpenClockwise ? 0 : (float)Math.ceil(sweepAngle));
      }
      if (mOpenClockwise)       innerSweepAngle+=sweepAngle;
 else       innerSweepAngle-=(float)Math.ceil(sweepAngle);
      _Canvas.drawArc(mGraphBounds,startAngle,sweepAngle,true,mGraphPaint);
      if (mUseInnerPadding) {
        mGraphPaint.setColor(model.getHighlightedColor());
        _Canvas.drawArc(mInnerBounds,startAngle,sweepAngle,true,mGraphPaint);
      }
    }
    if (mUseInnerPadding) {
      mGraphPaint.setColor(mInnerPaddingColor);
      _Canvas.drawArc(mInnerOutlineBounds,innerStartAngle,innerSweepAngle,true,mGraphPaint);
    }
  }
 else {
  }
}
Program: 111188
Project: 111188
Buggy source:
/** 
 * Constructor that is called when inflating a view from XML. This is called when a view is being constructed from an XML file, supplying attributes that were specified in the XML file. This version uses a default style of 0, so the only attribute values applied are those in the Context's Theme and the given AttributeSet. <p/> <p/> The method onFinishInflate() will be called after all children have been added.
 * @param context The Context the view is running in, through which it canaccess the current theme, resources, etc.
 * @param attrs   The attributes of the XML tag that is inflating the view.
 * @see #View(android.content.Context,android.util.AttributeSet,int)
 */
public BaseChart(Context context,AttributeSet attrs){
  super(context,attrs);
  TypedArray a=context.getTheme().obtainStyledAttributes(attrs,R.styleable.BaseChart,0,0);
  try {
    mLegendHeight=a.getDimension(R.styleable.BaseChart_egLegendHeight,Utils.dpToPx(DEF_LEGEND_HEIGHT));
    mLegendTextSize=a.getDimension(R.styleable.BaseChart_egLegendTextSize,Utils.dpToPx(DEF_LEGEND_TEXT_SIZE));
    mAnimationTime=a.getInt(R.styleable.BaseChart_egAnimationTime,DEF_ANIMATION_TIME);
    mShowDecimal=a.getBoolean(R.styleable.BaseChart_egShowDecimal,DEF_SHOW_DECIMAL);
  }
  finally {
    a.recycle();
  }
}

Fixed version (ground truth):
/** 
 * Constructor that is called when inflating a view from XML. This is called when a view is being constructed from an XML file, supplying attributes that were specified in the XML file. This version uses a default style of 0, so the only attribute values applied are those in the Context's Theme and the given AttributeSet. <p/> <p/> The method onFinishInflate() will be called after all children have been added.
 * @param context The Context the view is running in, through which it canaccess the current theme, resources, etc.
 * @param attrs   The attributes of the XML tag that is inflating the view.
 * @see #View(android.content.Context,android.util.AttributeSet,int)
 */
public BaseChart(Context context,AttributeSet attrs){
  super(context,attrs);
  TypedArray a=context.getTheme().obtainStyledAttributes(attrs,R.styleable.BaseChart,0,0);
  try {
    mLegendHeight=a.getDimension(R.styleable.BaseChart_egLegendHeight,Utils.dpToPx(DEF_LEGEND_HEIGHT));
    mLegendTextSize=a.getDimension(R.styleable.BaseChart_egLegendTextSize,Utils.dpToPx(DEF_LEGEND_TEXT_SIZE));
    mAnimationTime=a.getInt(R.styleable.BaseChart_egAnimationTime,DEF_ANIMATION_TIME);
    mShowDecimal=a.getBoolean(R.styleable.BaseChart_egShowDecimal,DEF_SHOW_DECIMAL);
    mLegendColor=a.getColor(R.styleable.BaseChart_egLegendColor,DEF_LEGEND_COLOR);
  }
  finally {
    a.recycle();
  }
}
Program: 111191
Project: 111191
Buggy source:
/** 
 * Calculates the text height for the indicator value and sets its x-coordinate.
 */
private void calculateValueTextHeight(){
  Rect rect=new Rect();
  String str=Utils.getFloatString(mFocusedPoint.getValue(),mShowDecimal) + (!mIndicatorTextUnit.isEmpty() ? "String_Node_Str" + mIndicatorTextUnit : "String_Node_Str");
  mIndicatorPaint.getTextBounds(str,0,str.length(),rect);
  mValueTextHeight=rect.height();
  if (mFocusedPoint.getCoordinates().getX() + rect.width() + mIndicatorLeftPadding > mGraphWidth + mLeftPadding) {
    mGraphOverlay.mValueLabelX=(int)(mFocusedPoint.getCoordinates().getX() - (rect.width() + mIndicatorLeftPadding));
  }
 else {
    mGraphOverlay.mValueLabelX=(int)(mFocusedPoint.getCoordinates().getX() + mIndicatorLeftPadding);
  }
}

Fixed version (ground truth):
/** 
 * Calculates the text height for the indicator value and sets its x-coordinate.
 */
private void calculateValueTextHeight(){
  Rect valueRect=new Rect();
  Rect legendRect=new Rect();
  String str=Utils.getFloatString(mFocusedPoint.getValue(),mShowDecimal) + (!mIndicatorTextUnit.isEmpty() ? "String_Node_Str" + mIndicatorTextUnit : "String_Node_Str");
  mIndicatorPaint.getTextBounds(str,0,str.length(),valueRect);
  mLegendPaint.getTextBounds(mFocusedPoint.getLegendLabel(),0,mFocusedPoint.getLegendLabel().length(),legendRect);
  mValueTextHeight=valueRect.height();
  mGraphOverlay.mValueLabelY=(int)(mValueTextHeight + mIndicatorTopPadding);
  mGraphOverlay.mLegendLabelY=(int)(mValueTextHeight + mIndicatorTopPadding + legendRect.height()+ Utils.dpToPx(7.f));
  int chosenWidth=valueRect.width() > legendRect.width() ? valueRect.width() : legendRect.width();
  if (mFocusedPoint.getCoordinates().getX() + chosenWidth + mIndicatorLeftPadding > mGraphWidth + mLeftPadding) {
    mGraphOverlay.mValueLabelX=(int)(mFocusedPoint.getCoordinates().getX() - (valueRect.width() + mIndicatorLeftPadding));
    mGraphOverlay.mLegendLabelX=(int)(mFocusedPoint.getCoordinates().getX() - (legendRect.width() + mIndicatorLeftPadding));
  }
 else {
    mGraphOverlay.mValueLabelX=mGraphOverlay.mLegendLabelX=(int)(mFocusedPoint.getCoordinates().getX() + mIndicatorLeftPadding);
  }
}
Program: 111192
Project: 111192
Buggy source:
/** 
 * Implement this to do your drawing.
 * @param canvas the canvas on which the background will be drawn
 */
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  mLegendPaint.setStrokeWidth(DEF_LEGEND_STROKE);
  if (!mSeries.isEmpty()) {
    if (mUseCustomLegend) {
      for (      LegendModel model : mLegendList) {
        Rect textBounds=model.getTextBounds();
        RectF bounds=model.getLegendBounds();
        canvas.drawText(model.getLegendLabel(),bounds.centerX() - (textBounds.width() / 2),bounds.centerY(),mLegendPaint);
        canvas.drawLine(bounds.centerX(),bounds.centerY() - textBounds.height() - mLegendTopPadding,bounds.centerX(),mLegendTopPadding,mLegendPaint);
      }
    }
 else {
      List<? extends BaseModel> list=mSeries.get(0).getSeries();
      for (      BaseModel model : list) {
        if (model.canShowLabel()) {
          RectF bounds=model.getLegendBounds();
          canvas.drawText(model.getLegendLabel(),model.getLegendLabelPosition(),bounds.bottom - mMaxFontHeight,mLegendPaint);
          canvas.drawLine(bounds.centerX(),bounds.bottom - mMaxFontHeight * 2 - mLegendTopPadding,bounds.centerX(),mLegendTopPadding,mLegendPaint);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Implement this to do your drawing.
 * @param canvas the canvas on which the background will be drawn
 */
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  mLegendPaint.setColor(mLegendColor);
  mLegendPaint.setStrokeWidth(DEF_LEGEND_STROKE);
  if (!mSeries.isEmpty()) {
    if (mUseCustomLegend) {
      for (      LegendModel model : mLegendList) {
        Rect textBounds=model.getTextBounds();
        RectF bounds=model.getLegendBounds();
        canvas.drawText(model.getLegendLabel(),bounds.centerX() - (textBounds.width() / 2),bounds.centerY(),mLegendPaint);
        canvas.drawLine(bounds.centerX(),bounds.centerY() - textBounds.height() - mLegendTopPadding,bounds.centerX(),mLegendTopPadding,mLegendPaint);
      }
    }
 else {
      List<? extends BaseModel> list=mSeries.get(0).getSeries();
      for (      BaseModel model : list) {
        if (model.canShowLabel()) {
          RectF bounds=model.getLegendBounds();
          canvas.drawText(model.getLegendLabel(),model.getLegendLabelPosition(),bounds.bottom - mMaxFontHeight,mLegendPaint);
          canvas.drawLine(bounds.centerX(),bounds.bottom - mMaxFontHeight * 2 - mLegendTopPadding,bounds.centerX(),mLegendTopPadding,mLegendPaint);
        }
      }
    }
  }
}