nus-yam/ex-repair huggingface dataset:
Program: 51764
Project: 51764
Buggy source:
/** 
 * Create a mail message and send it.
 * @param customerInfo  Customer information.
 * @param orderKey
 * @throws MailerAppException
 */
public void createAndSendMail(CustomerInfo customerInfo,String orderKey) throws MailerAppException {
  try {
    EMailMessage eMessage=new EMailMessage(createSubjectLine(orderKey),createMessage(orderKey),customerInfo.getCustomerID());
    Util.debug("String_Node_Str" + "String_Node_Str" + eMessage.getEmailReceiver() + "String_Node_Str"+ eMessage.getSubject()+ "String_Node_Str"+ eMessage.getHtmlContents());
    MimeMessage msg=new MimeMessage(mailSession);
    msg.setFrom();
    msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(eMessage.getEmailReceiver(),false));
    msg.setSubject(eMessage.getSubject());
    MimeBodyPart mbp=new MimeBodyPart();
    mbp.setText(eMessage.getHtmlContents(),"String_Node_Str");
    msg.setHeader("String_Node_Str","String_Node_Str");
    Multipart mp=new MimeMultipart();
    mp.addBodyPart(mbp);
    msg.setContent(mp);
    msg.setSentDate(new Date());
    Transport.send(msg);
    Util.debug("String_Node_Str");
  }
 catch (  Exception e) {
    Util.debug("String_Node_Str");
    Util.debug("String_Node_Str" + e);
    e.printStackTrace();
    throw new MailerAppException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Create a mail message and send it.
 * @param customerInfo  Customer information.
 * @param orderKey
 * @throws MailerAppException
 */
public void createAndSendMail(CustomerInfo customerInfo,long orderKey) throws MailerAppException {
  try {
    EMailMessage eMessage=new EMailMessage(createSubjectLine(orderKey),createMessage(orderKey),customerInfo.getCustomerID());
    Util.debug("String_Node_Str" + "String_Node_Str" + eMessage.getEmailReceiver() + "String_Node_Str"+ eMessage.getSubject()+ "String_Node_Str"+ eMessage.getHtmlContents());
    MimeMessage msg=new MimeMessage(mailSession);
    msg.setFrom();
    msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(eMessage.getEmailReceiver(),false));
    msg.setSubject(eMessage.getSubject());
    MimeBodyPart mbp=new MimeBodyPart();
    mbp.setText(eMessage.getHtmlContents(),"String_Node_Str");
    msg.setHeader("String_Node_Str","String_Node_Str");
    Multipart mp=new MimeMultipart();
    mp.addBodyPart(mbp);
    msg.setContent(mp);
    msg.setSentDate(new Date());
    Transport.send(msg);
    Util.debug("String_Node_Str");
  }
 catch (  Exception e) {
    Util.debug("String_Node_Str");
    Util.debug("String_Node_Str" + e);
    e.printStackTrace();
    throw new MailerAppException("String_Node_Str");
  }
}
Program: 51765
Project: 51765
Buggy source:
/** 
 * Create the email message.
 * @param orderKey The order number.
 * @return The email message.
 */
private String createMessage(String orderKey){
  Util.debug("String_Node_Str" + orderKey);
  StringBuffer msg=new StringBuffer();
  EntityManager em=entityManagerFactory.createEntityManager();
  Order order=em.find(Order.class,orderKey);
  msg.append("String_Node_Str" + orderKey + "String_Node_Str");
  msg.append("String_Node_Str" + order.getShipName() + "String_Node_Str");
  msg.append("String_Node_Str" + order.getShipAddr1() + "String_Node_Str"+ order.getShipAddr2()+ "String_Node_Str");
  msg.append("String_Node_Str" + order.getShipCity() + "String_Node_Str"+ order.getShipState()+ "String_Node_Str"+ order.getShipZip()+ "String_Node_Str");
  msg.append("String_Node_Str");
  return msg.toString();
}

Fixed version (ground truth):
/** 
 * Create the email message.
 * @param orderKey The order number.
 * @return The email message.
 */
private String createMessage(long orderKey){
  Util.debug("String_Node_Str" + orderKey);
  StringBuffer msg=new StringBuffer();
  EntityManager em=entityManagerFactory.createEntityManager();
  Order order=em.find(Order.class,orderKey);
  msg.append("String_Node_Str" + orderKey + "String_Node_Str");
  msg.append("String_Node_Str" + order.getShipName() + "String_Node_Str");
  msg.append("String_Node_Str" + order.getShipAddr1() + "String_Node_Str"+ order.getShipAddr2()+ "String_Node_Str");
  msg.append("String_Node_Str" + order.getShipCity() + "String_Node_Str"+ order.getShipState()+ "String_Node_Str"+ order.getShipZip()+ "String_Node_Str");
  msg.append("String_Node_Str");
  return msg.toString();
}
Program: 51767
Project: 51767
Buggy source:
/** 
 * This method sends an email message.
 * @param customerInfo  Customer information.
 * @param orderKey
 * @throws MailerAppException
 */
public void createAndSendMail(CustomerInfo customerInfo,String orderKey) throws MailerAppException ;

Fixed version (ground truth):
/** 
 * This method sends an email message.
 * @param customerInfo  Customer information.
 * @param orderKey
 * @throws MailerAppException
 */
public void createAndSendMail(CustomerInfo customerInfo,long orderKey) throws MailerAppException ;
Program: 51768
Project: 51768
Buggy source:
/** 
 * Send the email order confirmation message. 
 * @param customerInfo The customer information.
 * @param orderKey The order number.
 */
public final void sendConfirmationMessage(CustomerInfo customerInfo,String orderKey){
  try {
    System.out.println("String_Node_Str" + mailer);
    mailer.createAndSendMail(customerInfo,orderKey);
  }
 catch (  MailerAppException e) {
    Util.debug("String_Node_Str" + e);
  }
}

Fixed version (ground truth):
/** 
 * Send the email order confirmation message. 
 * @param customerInfo The customer information.
 * @param orderKey The order number.
 */
public final void sendConfirmationMessage(CustomerInfo customerInfo,long orderKey){
  try {
    System.out.println("String_Node_Str" + mailer);
    mailer.createAndSendMail(customerInfo,orderKey);
  }
 catch (  MailerAppException e) {
    Util.debug("String_Node_Str" + e);
  }
}
Program: 51770
Project: 51770
Buggy source:
private Map<Integer,Integer> parseHeader(String[] header){
  Map<Integer,Integer> map=new HashMap<Integer,Integer>(4);
  for (int i=0; i < HEADERS.length; i++) {
    for (int j=0; j < header.length; j++) {
      if (CsvProvider.isSimilarString(header[j],HEADERS[i],1)) {
        map.put(i,j);
      }
    }
  }
  return map;
}

Fixed version (ground truth):
private Map<Integer,Integer> parseHeader(String[] header) throws IOException {
  Map<Integer,Integer> map=new HashMap<Integer,Integer>(4);
  for (int i=0; i < HEADERS.length; i++) {
    for (int j=0; j < header.length; j++) {
      if (CsvProvider.isSimilarString(header[j],HEADERS[i],1)) {
        map.put(i,j);
      }
    }
  }
  if (map.get(HEADER_GROUP) == null) {
    throw new IOException("String_Node_Str");
  }
  if (map.get(HEADER_USERNAME) == null && map.get(HEADER_STUDENTID) == null) {
    throw new IOException("String_Node_Str");
  }
  return map;
}
Program: 51773
Project: 51773
Buggy source:
/** 
 * Because the multiple search is done by combining individual searches, each UserWrapper initially can only knows of at least 1 search field. We have to tell each wrapper about the other fields. 
 * @param existing
 * @param newer
 * @throws PersistenceException 
 * @throws KeyNotFoundException 
 */
private void createSearchFields(LinkedHashSet<UserWrapper> wrappers,ArrayList<SearchCriteria> criterias) throws KeyNotFoundException, PersistenceException {
  ScoreDbLoader scoreLoader=ScoreDbLoader.Default.getInstance();
  LineitemDbLoader lineitemLoader=LineitemDbLoader.Default.getInstance();
  for (  SearchCriteria criteria : criterias) {
    for (    UserWrapper wrap : wrappers) {
      Lineitem item=lineitemLoader.loadById(Id.generateId(Lineitem.LINEITEM_DATA_TYPE,criteria.getField()));
      Score score=scoreLoader.loadByCourseMembershipIdAndLineitemId(wrap.getMember().getId(),item.getId());
      wrap.addSearchFields(item.getName(),score.getGrade());
    }
  }
}

Fixed version (ground truth):
/** 
 * Because the multiple search is done by combining individual searches, each UserWrapper initially can only knows of at least 1 search field. We have to tell each wrapper about the other fields. 
 * @param existing
 * @param newer
 * @throws PersistenceException 
 * @throws KeyNotFoundException 
 */
private void createSearchFields(LinkedHashSet<UserWrapper> wrappers,ArrayList<SearchCriteria> criterias) throws PersistenceException {
  ScoreDbLoader scoreLoader=ScoreDbLoader.Default.getInstance();
  LineitemDbLoader lineitemLoader=LineitemDbLoader.Default.getInstance();
  debug+="String_Node_Str" + criterias.size() + "String_Node_Str";
  for (  SearchCriteria criteria : criterias) {
    if (criteria.isUserInfoField()) {
      debug+="String_Node_Str" + criteria.getField();
      continue;
    }
    for (    UserWrapper wrap : wrappers) {
      debug+="String_Node_Str" + criteria.getField();
      Lineitem item=lineitemLoader.loadById(Id.generateId(Lineitem.LINEITEM_DATA_TYPE,criteria.getField()));
      Score score;
      try {
        score=scoreLoader.loadByCourseMembershipIdAndLineitemId(wrap.getMember().getId(),item.getId());
        debug+="String_Node_Str" + item.getName() + "String_Node_Str"+ score.getGrade()+ "String_Node_Str";
        wrap.addSearchFields(item.getName(),score.getGrade());
      }
 catch (      KeyNotFoundException e) {
        debug+="String_Node_Str";
        wrap.addSearchFields(item.getName(),"String_Node_Str");
      }
    }
  }
}
Program: 51775
Project: 51775
Buggy source:
/** 
 * Does the search, but only on a single criteria.
 * @param criteria
 * @return
 * @throws PersistenceException
 * @throws ConnectionNotAvailableException
 */
private LinkedHashSet<UserWrapper> searchSingleCriteria(SearchCriteria criteria) throws PersistenceException, ConnectionNotAvailableException {
  String fieldId=criteria.getField();
  String op=criteria.getOp();
  String term=criteria.getTerm();
  GradeCenterUtil gc=new GradeCenterUtil(ctx);
  debug+="String_Node_Str" + fieldId + "String_Node_Str";
  if (gc.getUserinfoColumns().containsKey(fieldId)) {
    debug+="String_Node_Str";
    return searchSingleCriteriaUserinfo(fieldId,op,term);
  }
  return searchSingleCriteriaLineitems(fieldId,op,term);
}

Fixed version (ground truth):
/** 
 * Does the search, but only on a single criteria.
 * @param criteria
 * @return
 * @throws PersistenceException
 * @throws ConnectionNotAvailableException
 */
private LinkedHashSet<UserWrapper> searchSingleCriteria(SearchCriteria criteria) throws PersistenceException, ConnectionNotAvailableException {
  String fieldId=criteria.getField();
  String op=criteria.getOp();
  String term=criteria.getTerm();
  debug+="String_Node_Str" + fieldId + "String_Node_Str";
  if (GradeCenterUtil.getUserinfoColumns().containsKey(fieldId)) {
    debug+="String_Node_Str";
    criteria.setUserInfoField(true);
    return searchSingleCriteriaUserinfo(fieldId,op,term);
  }
  return searchSingleCriteriaLineitems(fieldId,op,term);
}
Program: 51776
Project: 51776
Buggy source:
public Tuple exec(Tuple input) throws IOException {
  List<Tuple> bagtuples=new ArrayList<Tuple>();
  ;
  Tuple result=TupleFactory.getInstance().newTuple(bagtuples);
  String[] paramColumns=getParamColumns();
  try {
    if (DataChecker.isValid(input,1)) {
      String json="String_Node_Str";
      if (input.get(0) != null) {
        json=input.get(0).toString();
      }
      JSONObject jsonObject=JSONObject.fromObject(json);
      for (      String column : paramColumns) {
        String data=(String)jsonObject.get(column);
        if (data == null) {
          data="String_Node_Str";
        }
        result.append(data);
      }
    }
  }
 catch (  ExecException e) {
    e.printStackTrace();
  }
catch (  JSONException e) {
    for (    String column : paramColumns) {
      result.append(column + "String_Node_Str");
    }
  }
  return result;
}

Fixed version (ground truth):
public Tuple exec(Tuple input) throws IOException {
  List<Tuple> bagtuples=new ArrayList<Tuple>();
  ;
  Tuple result=TupleFactory.getInstance().newTuple(bagtuples);
  String[] paramColumns=getParamColumns();
  String jj="String_Node_Str";
  try {
    if (DataChecker.isValid(input,1)) {
      String json="String_Node_Str";
      if (input.get(0) != null) {
        json=input.get(0).toString();
        json=json.replace("String_Node_Str","String_Node_Str");
      }
      jj=json;
      JSONObject jsonObject=JSONObject.fromObject(json);
      for (      String column : paramColumns) {
        String data=(String)jsonObject.get(column);
        if (data == null) {
          data="String_Node_Str";
        }
        result.append(data);
      }
    }
  }
 catch (  ExecException e) {
    e.printStackTrace();
  }
catch (  JSONException e) {
    result.append(jj);
    for (    String column : paramColumns) {
      result.append("String_Node_Str");
    }
  }
  return result;
}
Program: 51777
Project: 51777
Buggy source:
public void Update(boolean refresh){
  if (_isVisible) {
    _textHandler.Update();
    _textHandler.Clear();
    if (refresh) {
      StringSquisher.Clear();
      StringSquisher.Squish(title);
      HashMap<Integer,GenericItem> items=_equipment.GetItems();
      for (      Integer item : items.keySet()) {
        StringSquisher.Squish(ItemSlot.Names[item].substring(0,1),sep,items.get(item).Name,newline);
      }
      display=StringSquisher.Flush();
    }
    _textHandler.WriteDefault(display,320,30,GetHudOrigin());
  }
}

Fixed version (ground truth):
public void Update(boolean refresh){
  if (_isVisible) {
    _textHandler.Update();
    _textHandler.Clear();
    if (refresh) {
      StringSquisher.Clear();
      StringSquisher.Squish(title);
      HashMap<Integer,GenericItem> items=_equipment.GetItems();
      for (      Integer item : items.keySet()) {
        StringSquisher.Squish(ItemSlot.Names[item].substring(0,1),sep,items.get(item).Name,newline);
      }
      display=StringSquisher.Flush();
    }
    _textHandler.WriteDefault(display,20,60,GetHudOrigin());
  }
}
Program: 51778
Project: 51778
Buggy source:
protected IHud(ICreature owner,int width,int height){
  _parent=owner;
  if (_menuBase == null) {
    _menuBase=XnaManager.GetMenuBaseAsset();
  }
  _dimensions=new Point2(width,height);
  playerHudPositions.add(new Point2(GameManager.SpriteWidth / 2,XnaManager.WindowHeight - _dimensions.Y / 2));
  playerHudPositions.add(new Point2(XnaManager.WindowWidth - _dimensions.X / 2,XnaManager.WindowHeight + _dimensions.Y / 2));
  playerHudPositions.add(new Point2(0,0));
  playerHudPositions.add(new Point2(XnaManager.WindowWidth - _dimensions.X / 2,0));
}

Fixed version (ground truth):
protected IHud(ICreature owner,int width,int height){
  _parent=owner;
  if (_menuBase == null) {
    _menuBase=XnaManager.GetMenuBaseAsset();
  }
  _dimensions=new Point2(width,height);
  playerHudPositions.add(new Point2(0,XnaManager.WindowHeight - _dimensions.Y));
  playerHudPositions.add(new Point2(XnaManager.WindowWidth - _dimensions.X,XnaManager.WindowHeight + _dimensions.Y));
  playerHudPositions.add(new Point2(0,0));
  playerHudPositions.add(new Point2(XnaManager.WindowWidth - _dimensions.X,0));
}
Program: 51779
Project: 51779
Buggy source:
public void Draw(){
  if (_isVisible) {
    XnaManager.Renderer.Draw(_menuBase,GetHudOrigin(),Depth.HudBG,Color.WHITE,(int)XnaManager.GetCenter().X,(int)XnaManager.GetCenter().Y);
    _textHandler.Draw();
    _deltas.Draw();
    _equipHud.Draw();
  }
}

Fixed version (ground truth):
public void Draw(){
  if (_isVisible) {
    XnaManager.Renderer.Draw(_menuBase,GetHudOrigin(),Depth.HudBG,Color.BLACK,(int)XnaManager.GetCenter().X,(int)XnaManager.GetCenter().Y);
    _textHandler.Draw();
    _deltas.Draw();
    _equipHud.Draw();
  }
}
Program: 51780
Project: 51780
Buggy source:
public void Draw(){
  if (!_isVisible) {
    return;
  }
  XnaManager.Renderer.Draw(_menuBase,GetHudOrigin(),Depth.HudBG,Color.GREEN,GameManager.SpriteWidth,CalculateHeight(StatType.HEALTH));
  XnaManager.Renderer.Draw(_menuBase,_manaPosition,Depth.HudBG,Color.BLUE,GameManager.SpriteWidth,CalculateHeight(StatType.MANA));
  XnaManager.Renderer.Draw(_menuBase,_costPosition,Depth.HudBG,Color.YELLOW,GameManager.SpriteWidth / 2,CostOfCurrentSkill());
  _textHandler.Draw();
}

Fixed version (ground truth):
public void Draw(){
  if (!_isVisible) {
    return;
  }
  XnaManager.Renderer.Draw(_menuBase,GetHudOrigin(),Depth.HudBG,Color.GREEN,GameManager.SpriteWidth,CalculateHeight(StatType.HEALTH));
  XnaManager.Renderer.Draw(_menuBase,_manaPosition,Depth.HudBG,Color.BLUE,GameManager.SpriteWidth,CalculateHeight(StatType.MANA));
  XnaManager.Renderer.Draw(_menuBase,_manaPosition,Depth.HudBG,Color.YELLOW,GameManager.SpriteWidth / 2,CostOfCurrentSkill());
  _textHandler.Draw();
}
Program: 51781
Project: 51781
Buggy source:
public SkillHud(ICreature owner){
  super(owner,GameManager.SpriteWidth,XnaManager.WindowHeight / 4);
  _manaPosition=new Point2(GetHudOrigin().X,GetHudOrigin().Y - XnaManager.WindowHeight / 4);
  _costPosition=new Point2(GetHudOrigin().X - GameManager.SpriteWidth / 4,GetHudOrigin().Y - XnaManager.WindowHeight / 4 + _dimensions.Y / 2 - GameManager.SpriteHeight / 4);
}

Fixed version (ground truth):
public SkillHud(ICreature owner){
  super(owner,GameManager.SpriteWidth,XnaManager.WindowHeight / 4);
  _manaPosition=new Point2(GetHudOrigin().X,GetHudOrigin().Y - XnaManager.WindowHeight / 4);
}
Program: 51782
Project: 51782
Buggy source:
public void Update(){
  if (_isVisible) {
    _textHandler.Update();
    _textHandler.Clear();
    _textHandler.WriteDefault(GetSkillStrings(),GameManager.SpriteWidth,0,GetHudOrigin());
  }
}

Fixed version (ground truth):
public void Update(){
  if (_isVisible) {
    _textHandler.Update();
    _textHandler.Clear();
    _textHandler.WriteDefault(GetSkillStrings(),(int)GetHudOrigin().X + GameManager.SpriteWidth,GameManager.SpriteHeight,null);
  }
}
Program: 51783
Project: 51783
Buggy source:
public void Draw(){
  if (!_isVisible) {
    return;
  }
  XnaManager.Renderer.Draw(_menuBase.getScaledCopy((int)CalculateHeight(StatType.HEALTH).PosX,(int)CalculateHeight(StatType.HEALTH).PosY),GetHudOrigin(),Depth.HudBG,Color.green);
  XnaManager.Renderer.Draw(_menuBase.getScaledCopy((int)CostOfCurrentSkill().PosX,(int)CostOfCurrentSkill().PosY),_manaPosition,Depth.HudBG,Color.yellow);
  XnaManager.Renderer.Draw(_menuBase.getScaledCopy((int)CalculateHeight(StatType.MANA).PosX,(int)CalculateHeight(StatType.MANA).PosY),_manaPosition,Depth.HudBG,Color.blue);
  _textHandler.Draw();
}

Fixed version (ground truth):
public void Draw(){
  if (!_isVisible) {
    return;
  }
  XnaManager.Renderer.Draw(_menuBase.getScaledCopy((int)_dimensions.X,CalculateHeight(StatType.HEALTH)),GetHudOrigin(),Depth.HudBG,Color.green);
  XnaManager.Renderer.Draw(_menuBase.getScaledCopy((int)_dimensions.X,CalculateHeight(StatType.MANA)),_manaPosition,Depth.HudBG,Color.blue);
  XnaManager.Renderer.Draw(_menuBase.getScaledCopy((int)(_dimensions.X * .5f),CostOfCurrentSkill()),_manaPosition,Depth.HudBG,Color.yellow);
  _textHandler.Draw();
}
Program: 51784
Project: 51784
Buggy source:
private Point2 CostOfCurrentSkill(){
  return new Point2(_dimensions.X * .5f,_parent.GetCurrentSkillCost() / _parent.GetMax(StatType.MANA) * _dimensions.Y);
}

Fixed version (ground truth):
private int CostOfCurrentSkill(){
  return (int)(_parent.GetCurrentSkillCost() / _parent.GetMax(StatType.MANA) * _dimensions.Y);
}
Program: 51785
Project: 51785
Buggy source:
private Point2 CalculateHeight(String statType){
  return new Point2(_dimensions.X,(_parent.Get(statType) / _parent.GetMax(statType)) * _dimensions.Y);
}

Fixed version (ground truth):
private int CalculateHeight(String statType){
  return (int)((_parent.Get(statType) / _parent.GetMax(statType)) * _dimensions.Y);
}
Program: 51786
Project: 51786
Buggy source:
private static AbstractCreature GenerateCreature(int actorType){
switch (actorType) {
case AigilasActorType.PEON:
    return new Peon();
case AigilasActorType.ZORB:
  return new Zorb();
case AigilasActorType.WRATH:
return new Wrath();
case AigilasActorType.HAND:
return new Hand();
case AigilasActorType.PRIDE:
return new Pride();
case AigilasActorType.ENVY:
return new Envy();
case AigilasActorType.GLUTTONY:
return new Gluttony();
case AigilasActorType.LUST:
return new Lust();
case AigilasActorType.SLOTH:
return new Sloth();
case AigilasActorType.GREED:
return new Greed();
case AigilasActorType.SERPENT:
return new Serpent();
case AigilasActorType.BREAKING_WHEEL:
return new BreakingWheel();
default :
try {
throw new Exception("String_Node_Str" + actorType);
}
 catch (Exception e) {
e.printStackTrace();
}
}
}

Fixed version (ground truth):
private static AbstractCreature GenerateCreature(int actorType){
switch (actorType) {
case AigilasActorType.PEON:
    return new Peon();
case AigilasActorType.ZORB:
  return new Zorb();
case AigilasActorType.WRATH:
return new Wrath();
case AigilasActorType.HAND:
return new Hand();
case AigilasActorType.PRIDE:
return new Pride();
case AigilasActorType.ENVY:
return new Envy();
case AigilasActorType.GLUTTONY:
return new Gluttony();
case AigilasActorType.LUST:
return new Lust();
case AigilasActorType.SLOTH:
return new Sloth();
case AigilasActorType.GREED:
return new Greed();
case AigilasActorType.SERPENT:
return new Serpent();
case AigilasActorType.BREAKING_WHEEL:
return new BreakingWheel();
default :
try {
throw new Exception("String_Node_Str" + actorType);
}
 catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
Program: 51787
Project: 51787
Buggy source:
public void React(String skillId){
}

Fixed version (ground truth):
public void React(String skillId){
  if (_actorType == AigilasActorType.PLAYER && skillId != SkillId.FORGET_SKILL && _god.NameText == GodId.Names[GodId.GLUTTONY]) {
    if (_skills.Count() < _currentLevel) {
      _skills.Add(skillId);
    }
  }
}
Program: 51788
Project: 51788
Buggy source:
public ComboMarker(ICreature source,int elementId,int index){
}

Fixed version (ground truth):
public ComboMarker(ICreature source,int elementId,int index){
  Initialize(source.GetLocation(),SpriteType.COMBO_MARKER,com.aigilas.EntityType.COMBO_MARKER,com.aigilas.Depth.ComboMarker);
  _graphic.SetColor(Elements.Colors[elementId]);
  _graphic.SetAlpha(0);
  ParticleEngine.Emit(com.spx.particles.behaviors.RotateBehavior.GetInstance(),this,_graphic.GetColor());
  _parent=source;
  _index=index;
}
Program: 51789
Project: 51789
Buggy source:
/** 
 * <p>setStatus</p>
 * @param status a int.
 * @param description a {@link java.lang.String} object.
 */
public void setStatus(int status,String description){
switch (status) {
case ERROR:
    m_errorIcon.setTitle(description);
  m_panel.setWidget(m_errorIcon);
break;
case LOADING:
m_progressIcon.setTitle(description);
m_panel.setWidget(m_progressIcon);
break;
case COMPLETE:
if (m_panel.getContentWidget() != null) {
m_panel.remove(m_panel.getContentWidget());
}
break;
}
}

Fixed version (ground truth):
/** 
 * <p>setStatus</p>
 * @param status a int.
 * @param description a {@link java.lang.String} object.
 */
public void setStatus(int status,String description){
switch (status) {
case ERROR:
    m_errorIcon.setTitle(description);
  m_panel.setWidget(m_errorIcon);
break;
case LOADING:
m_progressIcon.setTitle(description);
m_panel.setWidget(m_progressIcon);
break;
case COMPLETE:
if (m_panel.getWidget() != null) {
m_panel.remove(m_panel.getWidget());
}
break;
}
}
Program: 51790
Project: 51790
Buggy source:
private Map<Long,Double> getPowerData(CostFunctionCapability powerCost,boolean isInstantaneous){
  currentMap.clear();
  capacityMap.clear();
  initCurrentAndCapacity(powerCost);
  if (isInstantaneous) {
    for (    Long t : currentMap.keySet()) {
      System.out.println(t + "String_Node_Str" + currentMap.get(t));
    }
    System.out.println();
  }
  return isInstantaneous ? currentMap : capacityMap;
}

Fixed version (ground truth):
private Map<Long,Double> getPowerData(CostFunctionCapability powerCost,boolean isInstantaneous){
  currentMap.clear();
  capacityMap.clear();
  initCurrentAndCapacity(powerCost);
  return isInstantaneous ? currentMap : capacityMap;
}
Program: 51791
Project: 51791
Buggy source:
private Map<Long,Double> getCommData(CostFunctionCapability commCost,boolean isInstantaneous){
  Collection<Long> changeTimes=getChangeTimes(CostType.COMM);
  Map<Long,Double> data=new TreeMap<Long,Double>();
  if (isInstantaneous) {
    for (    Long t : changeTimes) {
      data.put(t,commCost.getValue(t));
    }
  }
 else {
    Long[] timeType=new Long[]{};
    Long[] time=changeTimes.toArray(timeType);
    int size=changeTimes.size();
    double currentValue=0;
    for (int i=0; i < size; i++) {
      long t=time[i];
      data.put(t,currentValue);
      double commValue=commCost.getValue(t);
      double increase=((i < size - 1) ? commValue * (time[i + 1] - t) / SECOND_TO_MILLIS : 0.0);
      currentValue+=increase;
    }
  }
  return data;
}

Fixed version (ground truth):
private Map<Long,Double> getCommData(CostFunctionCapability commCost,boolean isInstantaneous){
  Collection<Long> changeTimes=getChangeTimes(CostType.COMM);
  Map<Long,Double> data=new TreeMap<Long,Double>();
  if (isInstantaneous) {
    for (    Long t : changeTimes) {
      data.put(t,commCost.getValue(t));
    }
  }
 else {
    Long[] timeType=new Long[]{};
    Long[] time=changeTimes.toArray(timeType);
    int size=changeTimes.size();
    double currentValue=0;
    for (int i=0; i < size; i++) {
      long t=time[i];
      data.put(t,currentValue);
      double commValue=commCost.getValue(t);
      double increase=((i < size - 1) ? commValue * (time[i + 1] - t) / SECOND_TO_MILLIS : 0.0);
      currentValue+=increase;
    }
    if (getStart() != time[0])     data.put(getStart(),0.0);
    if (getEnd() != time[changeTimes.size() - 1])     data.put(getEnd(),currentValue);
  }
  return data;
}
Program: 51792
Project: 51792
Buggy source:
private void initCurrentAndCapacity(CostFunctionCapability powerCost){
  Battery battery=new Battery(getModel());
  double initialStateOfCharge=battery.getInitialStateOfCharge();
  double stateOfCharge=initialStateOfCharge;
  double voltage, current, power;
  Collection<Long> changeTimes=getChangeTimes(CostType.POWER);
  for (  Long t : changeTimes) {
    capacityMap.put(t,stateOfCharge);
    power=powerCost.getValue(t);
    if ((battery.getStateOfCharge() < 100.0) || ((battery.getStateOfCharge() == initialStateOfCharge) && (power > 0.0))) {
      voltage=battery.getVoltage();
      current=power / voltage;
      stateOfCharge=battery.setStateOfCharge(power,(double)TIME_INTERVAL);
    }
 else {
      stateOfCharge=initialStateOfCharge;
      current=0.0;
    }
    currentMap.put(t,current);
  }
}

Fixed version (ground truth):
private void initCurrentAndCapacity(CostFunctionCapability powerCost){
  Battery battery=new Battery(getModel());
  double initialStateOfCharge=battery.getInitialStateOfCharge();
  double stateOfCharge=initialStateOfCharge;
  double voltage, current=0.0, power;
  Collection<Long> changeTimes=getChangeTimes(CostType.POWER);
  Long previousTime=-1l;
  capacityMap.put(getStart(),initialStateOfCharge);
  currentMap.put(getStart(),0.0);
  for (  Long t : changeTimes) {
    power=powerCost.getValue(t);
    if ((battery.getStateOfCharge() < 100.0) || ((battery.getStateOfCharge() >= 100.0) && (power > 0.0))) {
      if (!capacityMap.containsKey(previousTime)) {
        capacityMap.put(t,stateOfCharge);
      }
 else {
        if (stateOfCharge != capacityMap.get(previousTime)) {
          capacityMap.put(t,stateOfCharge);
        }
      }
      voltage=battery.getVoltage();
      current=BatteryVoltageTable.getNearestState(power / voltage);
      if (!currentMap.containsKey(previousTime)) {
        currentMap.put(t,current);
      }
 else {
        if (current != currentMap.get(previousTime)) {
          currentMap.put(t,current);
        }
      }
      stateOfCharge=battery.setStateOfCharge(power,(double)TIME_INTERVAL);
    }
 else {
      currentMap.put(t,0.0);
    }
    previousTime=t;
  }
  capacityMap.put(getEnd(),stateOfCharge);
  currentMap.put(getEnd(),0.0);
}
Program: 51793
Project: 51793
Buggy source:
public double setStateOfCharge(double power,double duration){
  duration=getMinuteToHour(duration);
  if (power != 0) {
    double change=power * duration / capacity;
    stateOfCharge-=change * 100.0;
  }
  return stateOfCharge;
}

Fixed version (ground truth):
public double setStateOfCharge(double power,double duration){
  duration=getMinuteToHour(duration);
  if (power != 0) {
    double change=power * duration / capacity;
    stateOfCharge-=change * 100.0;
  }
  stateOfCharge=(stateOfCharge > 100.0) ? 100.0 : stateOfCharge;
  return round(stateOfCharge);
}
Program: 51794
Project: 51794
Buggy source:
private double getNearestState(double realState){
  double upper=Math.ceil(realState / INTERVAL) * INTERVAL;
  double lower=Math.floor(realState / INTERVAL) * INTERVAL;
  double state=((upper - realState) - (realState - lower) >= 0) ? lower : upper;
  return state;
}

Fixed version (ground truth):
public static double getNearestState(double realState){
  double upper=Math.ceil(realState / INTERVAL) * INTERVAL;
  double lower=Math.floor(realState / INTERVAL) * INTERVAL;
  double state=((upper - realState) - (realState - lower) >= 0) ? lower : upper;
  return state;
}
Program: 51795
Project: 51795
Buggy source:
protected void updateGraph(){
  Collection<Long> timeCollection=new TreeSet<Long>();
  Collection<Double> dataCollection=new ArrayList<Double>();
  Map<Long,Double> values=graphData.getData(type,isInstantaneous);
  if (values != null) {
    if (!values.containsKey(getStart()))     values.put(getStart(),0.0);
    if (!values.containsKey(getEnd()))     values.put(getEnd(),0.0);
    dataCollection=values.values();
    timeCollection=values.keySet();
  }
  int size=timeCollection.size();
  if (size > 1) {
    Double[] dataType=new Double[]{};
    dataPoints=dataCollection.toArray(dataType);
    Long[] timeType=new Long[]{};
    time=timeCollection.toArray(timeType);
    setMinAndMax(dataPoints);
    int[] x=new int[size];
    int[] y=new int[size];
    for (int j=0; j < size; j++) {
      x[j]=toX(time[j]);
      y[j]=toY(dataPoints[j],minData,maxData);
    }
    this.x=x;
    this.y=y;
  }
}

Fixed version (ground truth):
protected void updateGraph(){
  Collection<Long> timeCollection=new TreeSet<Long>();
  Collection<Double> dataCollection=new ArrayList<Double>();
  Map<Long,Double> values=graphData.getData(type,isInstantaneous);
  if (values != null) {
    dataCollection=values.values();
    timeCollection=values.keySet();
  }
  int size=timeCollection.size();
  if (size > 1) {
    Double[] dataType=new Double[]{};
    dataPoints=dataCollection.toArray(dataType);
    Long[] timeType=new Long[]{};
    time=timeCollection.toArray(timeType);
    setMinAndMax(dataPoints);
    int[] x=new int[size];
    int[] y=new int[size];
    for (int j=0; j < size; j++) {
      x[j]=toX(time[j]);
      y[j]=toY(dataPoints[j],minData,maxData);
    }
    this.x=x;
    this.y=y;
  }
}
Program: 51796
Project: 51796
Buggy source:
public RepositoryMoveDialog(final SwingWorker worker){
  super(null,Dialog.ModalityType.APPLICATION_MODAL);
  final JPanel panel=new JPanel();
  final JLabel label=new JLabel("String_Node_Str");
  final JProgressBar progress=new JProgressBar(0,100);
  final JButton button=new JButton("String_Node_Str");
  button.addActionListener(new ActionListener(){
    @Override public void actionPerformed(    ActionEvent e){
      RepositoryMoveDialog.this.dispose();
    }
  }
);
  worker.addPropertyChangeListener(new PropertyChangeListener(){
    @Override public void propertyChange(    PropertyChangeEvent event){
      progress.setValue(worker.getProgress());
    }
  }
);
  panel.setLayout(new BoxLayout(panel,BoxLayout.PAGE_AXIS));
  panel.add(label);
  panel.add(progress);
  panel.add(button);
  add(panel);
  pack();
}

Fixed version (ground truth):
public RepositoryMoveDialog(final SwingWorker<?,?> worker){
  super(null,Dialog.ModalityType.APPLICATION_MODAL);
  final JPanel panel=new JPanel();
  final JLabel label=new JLabel("String_Node_Str");
  final JProgressBar progress=new JProgressBar(0,100);
  final JButton button=new JButton("String_Node_Str");
  button.addActionListener(new ActionListener(){
    @Override public void actionPerformed(    ActionEvent e){
      RepositoryMoveDialog.this.dispose();
    }
  }
);
  worker.addPropertyChangeListener(new PropertyChangeListener(){
    @Override public void propertyChange(    PropertyChangeEvent event){
      progress.setValue(worker.getProgress());
    }
  }
);
  panel.setLayout(new BoxLayout(panel,BoxLayout.PAGE_AXIS));
  panel.add(label);
  panel.add(progress);
  panel.add(button);
  add(panel);
  pack();
}
Program: 51797
Project: 51797
Buggy source:
@Override protected Void doInBackground() throws Exception {
  Map<AbstractComponent,Set<AbstractComponent>> otherRepositories=new HashMap<AbstractComponent,Set<AbstractComponent>>();
  int i=0, j=0;
  int childCount=addedComponents.size();
  for (  AbstractComponent child : addedComponents) {
    Collection<AbstractComponent> parents=child.getReferencingComponents();
    int parentCount=parents.size();
    for (    AbstractComponent parent : parents) {
      RepositoryCapability parentRepo=parent.getCapability(RepositoryCapability.class);
      if (parentRepo != null && parentRepo.getCapabilityClass().isAssignableFrom(repositoryComponent.getCapabilityClass())) {
        if (!(repositoryComponent.getComponentId().equals(parent.getComponentId()))) {
          if (!otherRepositories.containsKey(parent)) {
            otherRepositories.put(parent,new HashSet<AbstractComponent>());
          }
          otherRepositories.get(parent).add(child);
        }
      }
      setProgress((100 * i + (j * i / parentCount)) / childCount);
    }
    i++;
    setProgress(100 * i / childCount);
  }
  for (  Entry<AbstractComponent,Set<AbstractComponent>> otherRepo : otherRepositories.entrySet()) {
    otherRepo.getKey().removeDelegateComponents(otherRepo.getValue());
  }
  PlatformAccess.getPlatform().getPersistenceProvider().persist(otherRepositories.keySet());
  return null;
}

Fixed version (ground truth):
@Override protected Void doInBackground() throws Exception {
  Map<String,Set<AbstractComponent>> toRemove=new HashMap<String,Set<AbstractComponent>>();
  Map<String,AbstractComponent> parentRepos=new HashMap<String,AbstractComponent>();
  int childIndex=0;
  int childCount=addedComponents.size();
  for (  AbstractComponent child : addedComponents) {
    Collection<AbstractComponent> parents=child.getReferencingComponents();
    int parentIndex=0;
    int parentCount=parents.size();
    for (    AbstractComponent parent : parents) {
      RepositoryCapability parentRepo=parent.getCapability(RepositoryCapability.class);
      if (parentRepo != null && parentRepo.getCapabilityClass().isAssignableFrom(repositoryComponent.getCapabilityClass())) {
        String parentId=parent.getComponentId();
        if (!(repositoryComponent.getComponentId().equals(parentId))) {
          parentRepos.put(parentId,parent);
          if (!toRemove.containsKey(parentId)) {
            toRemove.put(parentId,new HashSet<AbstractComponent>());
          }
          toRemove.get(parentId).add(child);
        }
      }
      parentIndex++;
      setProgress((100 * childIndex + (parentIndex * childIndex / parentCount)) / childCount);
    }
    childIndex++;
    setProgress(100 * childIndex / childCount);
  }
  for (  String id : parentRepos.keySet()) {
    parentRepos.get(id).removeDelegateComponents(toRemove.get(id));
  }
  PlatformAccess.getPlatform().getPersistenceProvider().persist(parentRepos.values());
  return null;
}
Program: 51799
Project: 51799
Buggy source:
@Override protected <T>List<T> handleGetCapabilities(Class<T> capability){
  if (capability.isAssignableFrom(TagCapability.class)) {
    List<T> tagCapabilities=null;
    for (    AbstractComponent child : getComponents()) {
      if (!(child instanceof ActivityComponent)) {
        List<T> childTags=child.getCapabilities(capability);
        if (childTags != null && !childTags.isEmpty()) {
          if (tagCapabilities == null) {
            tagCapabilities=new ArrayList<T>();
            tagCapabilities.addAll(childTags);
          }
        }
      }
    }
    if (tagCapabilities != null) {
      return tagCapabilities;
    }
  }
  return super.handleGetCapabilities(capability);
}

Fixed version (ground truth):
@Override protected <T>List<T> handleGetCapabilities(Class<T> capability){
  if (capability.isAssignableFrom(TagCapability.class)) {
    List<T> tagCapabilities=null;
    for (    AbstractComponent child : getComponents()) {
      if (!(child instanceof ActivityComponent)) {
        List<T> childTags=child.getCapabilities(capability);
        if (childTags != null && !childTags.isEmpty()) {
          if (tagCapabilities == null) {
            tagCapabilities=new ArrayList<T>();
          }
          tagCapabilities.addAll(childTags);
        }
      }
    }
    if (tagCapabilities != null) {
      return tagCapabilities;
    }
  }
  return super.handleGetCapabilities(capability);
}
Program: 51800
Project: 51800
Buggy source:
@Override public void viewPersisted(){
  if (!getInfo().getViewType().equals(ViewType.EMBEDDED)) {
    setManifestedComponent(PlatformAccess.getPlatform().getPersistenceProvider().getComponent(getManifestedComponent().getComponentId()));
    getManifestedComponent().addViewManifestation(this);
  }
  Collection<View> selected=getSelectionProvider().getSelectedManifestations();
  String selectedId=null;
  if (!selected.isEmpty()) {
    selectedId=selected.iterator().next().getManifestedComponent().getComponentId();
    select(null);
  }
  for (  AbstractComponent child : getManifestedComponent().getComponents()) {
    searchAndReplace(upperPanel,child);
  }
  if (costGraph != null) {
    costGraph.setManifestedComponent(getManifestedComponent());
    costGraph.viewPersisted();
  }
  if (selectedId != null) {
    selectComponent(selectedId);
  }
}

Fixed version (ground truth):
@Override public void viewPersisted(){
  if (!getInfo().getViewType().equals(ViewType.EMBEDDED)) {
    setManifestedComponent(PlatformAccess.getPlatform().getPersistenceProvider().getComponent(getManifestedComponent().getComponentId()));
    getManifestedComponent().addViewManifestation(this);
  }
  Collection<View> selected=getSelectionProvider().getSelectedManifestations();
  String selectedId=null;
  if (!selected.isEmpty()) {
    selectedId=selected.iterator().next().getManifestedComponent().getComponentId();
    select(null);
  }
  for (  AbstractComponent child : getManifestedComponent().getComponents()) {
    child.getCapability(ComponentInitializer.class).setWorkUnitDelegate(getManifestedComponent());
    searchAndReplace(upperPanel,child);
  }
  if (costGraph != null) {
    costGraph.setManifestedComponent(getManifestedComponent());
    costGraph.viewPersisted();
  }
  if (selectedId != null) {
    selectComponent(selectedId);
  }
}
Program: 51801
Project: 51801
Buggy source:
private void buildUpperPanel(){
  AbstractComponent ac=getManifestedComponent();
  if (!getInfo().getViewType().equals(ViewType.EMBEDDED)) {
    ac.addViewManifestation(this);
  }
  for (  AbstractComponent child : ac.getComponents()) {
    if (child instanceof TimelineComponent) {
      upperPanel.add(createTimeline((TimelineComponent)child));
    }
  }
  List<CostFunctionCapability> costs=ac.getCapabilities(CostFunctionCapability.class);
  if (costs != null && !costs.isEmpty()) {
    upperPanel.add(new CollapsibleContainer(costGraph=GraphView.VIEW_INFO.createView(getManifestedComponent())));
  }
}

Fixed version (ground truth):
private void buildUpperPanel(){
  AbstractComponent ac=getManifestedComponent();
  if (!getInfo().getViewType().equals(ViewType.EMBEDDED)) {
    ac.addViewManifestation(this);
  }
  for (  AbstractComponent child : ac.getComponents()) {
    if (child instanceof TimelineComponent) {
      child.getCapability(ComponentInitializer.class).setWorkUnitDelegate(getManifestedComponent());
      upperPanel.add(createTimeline((TimelineComponent)child));
    }
  }
  List<CostFunctionCapability> costs=ac.getCapabilities(CostFunctionCapability.class);
  if (costs != null && !costs.isEmpty()) {
    upperPanel.add(new CollapsibleContainer(costGraph=GraphView.VIEW_INFO.createView(getManifestedComponent())));
  }
}
Program: 51802
Project: 51802
Buggy source:
@Override public void propertyChange(java.beans.PropertyChangeEvent evt){
  Object src=evt.getSource();
  if ((Boolean)evt.getNewValue() && src instanceof View && ((View)src).getManifestedComponent().isStale()) {
    if (!used && getManifestedComponent().getComponentId() != null) {
      AbstractComponent committedComponent=PlatformAccess.getPlatform().getPersistenceProvider().getComponent(getManifestedComponent().getComponentId());
      ObjectManager objectManager=getManifestedComponent().getCapability(ObjectManager.class);
      boolean updated=objectManager != null && new TimelineMergeHandler(objectManager).update(committedComponent);
      setManifestedComponent(committedComponent);
      rebuildUpperPanel();
      updateMasterDuration();
      used=true;
      if (updated) {
        save();
      }
    }
  }
}

Fixed version (ground truth):
@Override public void propertyChange(java.beans.PropertyChangeEvent evt){
  Object src=evt.getSource();
  if ((Boolean)evt.getNewValue() && src instanceof View && ((View)src).getManifestedComponent().isStale()) {
    if (!used && getManifestedComponent().getComponentId() != null) {
      AbstractComponent committedComponent=PlatformAccess.getPlatform().getPersistenceProvider().getComponent(getManifestedComponent().getComponentId());
      AbstractComponent workUnitDelegate=getManifestedComponent().getWorkUnitDelegate();
      ObjectManager objectManager=(workUnitDelegate == null ? getManifestedComponent() : workUnitDelegate).getCapability(ObjectManager.class);
      if (workUnitDelegate != null) {
        committedComponent.getCapability(ComponentInitializer.class).setWorkUnitDelegate(workUnitDelegate);
      }
      boolean updated=objectManager != null && new TimelineMergeHandler(objectManager).update(committedComponent);
      setManifestedComponent(committedComponent);
      rebuildUpperPanel();
      updateMasterDuration();
      used=true;
      if (updated) {
        save();
      }
    }
  }
}
Program: 51803
Project: 51803
Buggy source:
private boolean canContain(AbstractComponent parent,AbstractComponent child){
  if (parent instanceof ScenarioComponent) {
    return child instanceof TimelineComponent || child instanceof ActivityComponent;
  }
  if (parent instanceof TimelineComponent) {
    return !(child instanceof DecisionComponent || child instanceof ScenarioComponent) && (child.getCapability(DurationCapability.class) != null || child.getCapability(FeedProvider.class) != null || child.getComponentTypeID().contains("String_Node_Str"));
  }
  if (parent instanceof ActivityComponent) {
    return child instanceof ActivityComponent || child instanceof DecisionComponent;
  }
  if (child instanceof DecisionComponent) {
    return parent instanceof ActivityComponent;
  }
  return true;
}

Fixed version (ground truth):
private boolean canContain(AbstractComponent parent,AbstractComponent child){
  if (parent instanceof ScenarioComponent) {
    return child instanceof TimelineComponent || child instanceof ActivityComponent;
  }
  if (parent instanceof TimelineComponent) {
    return !(child instanceof DecisionComponent || child instanceof TimelineComponent || child instanceof ScenarioComponent) && (child.getCapability(DurationCapability.class) != null || child.getCapability(FeedProvider.class) != null || child.getComponentTypeID().contains("String_Node_Str"));
  }
  if (parent instanceof ActivityComponent) {
    return child instanceof ActivityComponent || child instanceof DecisionComponent;
  }
  if (child instanceof DecisionComponent) {
    return parent instanceof ActivityComponent;
  }
  return true;
}
Program: 51804
Project: 51804
Buggy source:
public ScenarioView(AbstractComponent ac,ViewInfo vi){
  super(ac,vi);
  setOpaque(false);
  JPanel upperPanel=new JPanel();
  upperPanel.setLayout(new BoxLayout(upperPanel,BoxLayout.Y_AXIS));
  upperPanel.setOpaque(false);
  getContentPane().setLayout(new BorderLayout());
  getContentPane().add(upperPanel,BorderLayout.NORTH);
  for (  AbstractComponent child : ac.getComponents()) {
    if (child instanceof TimelineComponent) {
      View view=TimelineView.VIEW_INFO.createView(child);
      upperPanel.add(new CollapsibleContainer(view));
    }
  }
}

Fixed version (ground truth):
public ScenarioView(AbstractComponent ac,ViewInfo vi){
  super(ac,vi);
  setOpaque(false);
  JPanel upperPanel=new JPanel();
  upperPanel.setLayout(new BoxLayout(upperPanel,BoxLayout.Y_AXIS));
  upperPanel.setOpaque(false);
  getContentPane().setLayout(new BorderLayout());
  getContentPane().add(upperPanel,BorderLayout.NORTH);
  for (  AbstractComponent child : ac.getComponents()) {
    if (child instanceof TimelineComponent) {
      View view=TimelineView.VIEW_INFO.createView(child);
      upperPanel.add(new CollapsibleContainer(view));
    }
  }
  upperPanel.add(GraphView.VIEW_INFO.createView(getManifestedComponent()));
}
Program: 51805
Project: 51805
Buggy source:
public void paintComponent(Graphics g){
  if (isActive) {
    g.setColor(OVERLAY_COLOR);
    g.fillRect(x + getLeftPadding(),0,1,getHeight());
    long time=(long)(x / getPixelScale()) + getTimeOffset();
    FontMetrics metrics=g.getFontMetrics(g.getFont());
    for (    Component c : costComponents) {
      if (c instanceof CostOverlay) {
        int compX=getXRelativeToContentPane(c);
        if (compX <= x + getLeftPadding() && compX + c.getWidth() >= x + getLeftPadding()) {
          List<CostFunctionCapability> costs=((CostOverlay)c).getCostFunctions();
          String costString="String_Node_Str";
          for (          CostFunctionCapability cost : costs) {
            costString+=cost.getValue(time) + "String_Node_Str" + cost.getUnits()+ "String_Node_Str";
          }
          if (!costString.isEmpty()) {
            int leftX=x + getLeftPadding();
            int centerY=getYRelativeToContentPane(c) + c.getHeight() / 2;
            int width=metrics.stringWidth(costString);
            int height=metrics.getHeight() * 3 / 2;
            g.setColor(OVERLAY_COLOR);
            g.fillRect(leftX,centerY - height / 2,width + 4,height);
            g.setColor(OVERLAY_TEXT_COLOR);
            g.drawString(costString,leftX + 2,centerY + metrics.getAscent() / 2 - 1);
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
public void paintComponent(Graphics g){
  if (isActive) {
    g.setColor(OVERLAY_COLOR);
    g.fillRect(x + getLeftPadding(),0,1,getHeight());
    long time=(long)(x / getPixelScale()) + getTimeOffset();
    FontMetrics metrics=g.getFontMetrics(g.getFont());
    for (    Component c : costComponents) {
      if (c instanceof CostOverlay && c.isShowing()) {
        int compX=getXRelativeToContentPane(c);
        if (compX <= x + getLeftPadding() && compX + c.getWidth() >= x + getLeftPadding()) {
          List<CostFunctionCapability> costs=((CostOverlay)c).getCostFunctions();
          String costString="String_Node_Str";
          for (          CostFunctionCapability cost : costs) {
            costString+=cost.getValue(time) + "String_Node_Str" + cost.getUnits()+ "String_Node_Str";
          }
          if (!costString.isEmpty()) {
            int leftX=x + getLeftPadding();
            int centerY=getYRelativeToContentPane(c) + c.getHeight() / 2;
            int width=metrics.stringWidth(costString);
            int height=metrics.getHeight() * 3 / 2;
            g.setColor(OVERLAY_COLOR);
            g.fillRect(leftX,centerY - height / 2,width + 4,height);
            g.setColor(OVERLAY_TEXT_COLOR);
            g.drawString(costString,leftX + 2,centerY + metrics.getAscent() / 2 - 1);
          }
        }
      }
    }
  }
}