nus-yam/ex-repair huggingface dataset:
Program: 76067
Project: 76067
Buggy source:
/** 
 * Initialize the applet.
 */
public void init(){
  super.init();
  getContentPane().setLayout(new BorderLayout(5,5));
  getContentPane().add(_createRunControls(3),BorderLayout.NORTH);
  constructPtolemyModel();
  _divaPanel=new JPanel(new BorderLayout());
  _divaPanel.setBorder(new TitledBorder(new LineBorder(Color.black),"String_Node_Str"));
  _divaPanel.setBackground(getBackground());
  _divaPanel.setSize(new Dimension(600,350));
  _divaPanel.setBackground(getBackground());
  getContentPane().add(_divaPanel,BorderLayout.CENTER);
  _graph=constructDivaGraph();
  final MutableGraphModel finalGraphModel=_graph;
  final GraphController gc=new BusContentionGraphController();
  final GraphPane gp=new GraphPane(gc,_graph);
  _jgraph=new JGraph(gp);
  _divaPanel.add(_jgraph,BorderLayout.NORTH);
  _jgraph.setPreferredSize(new Dimension(600,400));
  try {
    SwingUtilities.invokeAndWait(new Runnable(){
      public void run(){
        doLayout(finalGraphModel,gp);
      }
    }
);
  }
 catch (  Exception ex) {
    ex.printStackTrace();
    System.exit(0);
  }
  _jgraph.setBackground(getBackground());
  StateListener listener=new StateListener((GraphPane)_jgraph.getCanvasPane());
  _processActor1.addListeners(listener);
  _processActor2.addListeners(listener);
  _processActor3.addListeners(listener);
}

Fixed version (ground truth):
/** 
 * Initialize the applet.
 */
public void init(){
  super.init();
  getContentPane().setLayout(new BorderLayout(5,5));
  getContentPane().add(_createRunControls(2),BorderLayout.NORTH);
  constructPtolemyModel();
  _divaPanel=new JPanel(new BorderLayout());
  _divaPanel.setBorder(new TitledBorder(new LineBorder(Color.black),"String_Node_Str"));
  _divaPanel.setBackground(getBackground());
  _divaPanel.setPreferredSize(new Dimension(500,450));
  _divaPanel.setBackground(getBackground());
  getContentPane().add(_divaPanel,BorderLayout.SOUTH);
  _graph=constructGraph();
  final BasicGraphModel finalGraphModel=_graph;
  final GraphController gc=new BusContentionGraphController();
  final GraphPane gp=new GraphPane(gc,_graph);
  _jgraph=new JGraph(gp);
  _jgraph.repaint();
  _divaPanel.add(_jgraph,BorderLayout.CENTER);
  _jgraph.setBackground(getBackground());
  StateListener listener=new StateListener((GraphPane)_jgraph.getCanvasPane());
  _processActor1.addListeners(listener);
  _processActor2.addListeners(listener);
  _processActor3.addListeners(listener);
}
Program: 76068
Project: 76068
Buggy source:
/** 
 * Override the baseclass start method so that the model does not immediately begin executing as soon as the the applet page is displayed. Execution begins once the "Go" button is depressed.
 */
public void start(){
}

Fixed version (ground truth):
/** 
 * Override the baseclass start method so that the model does not immediately begin executing as soon as the the applet page is displayed. Execution begins once the "Go" button is depressed. Layout the graph visualization, since this can't be done in the init method, because the graph hasn't yet been displayed.
 */
public void start(){
  doLayout(_graph,_jgraph.getGraphPane());
}
Program: 76069
Project: 76069
Buggy source:
/** 
 * Layout the graph again.
 */
public void doLayout(GraphModel graph,GraphPane gp){
  try {
    final GraphModel layoutGraph=graph;
    final GraphController gc=gp.getGraphController();
    final GraphPane pane=gp;
    SwingUtilities.invokeLater(new Runnable(){
      public void run(){
        LevelLayout staticLayout=new LevelLayout();
        staticLayout.setOrientation(LevelLayout.HORIZONTAL);
        LayoutTarget target=new BasicLayoutTarget(gc);
        staticLayout.layout(target,layoutGraph.getRoot());
        pane.repaint();
      }
    }
);
  }
 catch (  Exception e) {
    System.out.println(e);
  }
}

Fixed version (ground truth):
/** 
 * Layout the graph again.
 */
public void doLayout(GraphModel graph,GraphPane gp){
  try {
    final GraphModel layoutGraph=graph;
    final GraphController gc=gp.getGraphController();
    final GraphPane pane=gp;
    SwingUtilities.invokeLater(new Runnable(){
      public void run(){
        LayoutTarget target=new BasicLayoutTarget(gc);
        LevelLayout staticLayout=new LevelLayout(target);
        staticLayout.setOrientation(LevelLayout.HORIZONTAL);
        staticLayout.layout(layoutGraph.getRoot());
        pane.repaint();
      }
    }
);
  }
 catch (  Exception e) {
    System.out.println(e);
  }
}
Program: 76071
Project: 76071
Buggy source:
/** 
 * Override the baseclass start method so that the model does not immediately begin executing as soon as the the applet page is displayed. Execution begins once the "Go" button is depressed.
 */
public void start(){
}

Fixed version (ground truth):
/** 
 * Override the baseclass start method so that the model does not immediately begin executing as soon as the the applet page is displayed. Execution begins once the "Go" button is depressed. Layout the graph visualization, since this can't be done in the init method, because the graph hasn't yet been displayed.
 */
public void start(){
  doLayout(_graph,_jgraph.getGraphPane());
}
Program: 76072
Project: 76072
Buggy source:
/** 
 * Layout the graph again.
 */
public void doLayout(GraphModel graph,GraphPane gp){
  try {
    final GraphModel layoutGraph=graph;
    final GraphController gc=gp.getGraphController();
    final GraphPane pane=gp;
    SwingUtilities.invokeLater(new Runnable(){
      public void run(){
        LevelLayout staticLayout=new LevelLayout();
        staticLayout.setOrientation(LevelLayout.HORIZONTAL);
        LayoutTarget target=new BasicLayoutTarget(gc);
        staticLayout.layout(target,layoutGraph.getRoot());
        pane.repaint();
      }
    }
);
  }
 catch (  Exception e) {
    System.out.println(e);
  }
}

Fixed version (ground truth):
/** 
 * Layout the graph again.
 */
public void doLayout(GraphModel graph,GraphPane gp){
  try {
    final GraphModel layoutGraph=graph;
    final GraphController gc=gp.getGraphController();
    final GraphPane pane=gp;
    SwingUtilities.invokeLater(new Runnable(){
      public void run(){
        LayoutTarget target=new BasicLayoutTarget(gc);
        LevelLayout staticLayout=new LevelLayout(target);
        staticLayout.setOrientation(LevelLayout.HORIZONTAL);
        staticLayout.layout(layoutGraph.getRoot());
        pane.repaint();
      }
    }
);
  }
 catch (  Exception e) {
    System.out.println(e);
  }
}
Program: 76074
Project: 76074
Buggy source:
/** 
 * Invoke a specified number of iterations of this actor. An iteration has the effect of invoking prefire(), fire(), and  postfire(), in that order. If prefire() returns true, then fire() will be called once, followed by postfire(). Otherwise, fire() and postfire() are not invoked, and this method will return a value of false. This method will return true if  the actor was successfully iterated the specified number of  times. Otherwise, a value of false will be returned. <p> This base class method actually invokes prefire(), fire(),  and postfire(), as described above. 
 * @param count The number of iterations to perform.
 * @return True if the actor was successfully iterated thespecified number of times. Otherwise, return false.
 * @exception IllegalActionException If one of the Executablemethods throws it.
 */
public boolean iterate(int count) throws IllegalActionException {
  int n=0;
  while (n < count) {
    if (prefire()) {
      fire();
      postfire();
    }
 else     break;
    count++;
  }
  if (count == n) {
    return (true);
  }
 else {
    return (false);
  }
}

Fixed version (ground truth):
/** 
 * Invoke a specified number of iterations of this actor. An iteration has the effect of invoking prefire(), fire(), and  postfire(), in that order. In an iteration, if prefire()  returns true, then fire() will be called once, followed by  an invocation of postfire(). Otherwise, if prefire() returns  false, fire() and postfire() are not invoked, and an exception  will be thrown. This method will return the value returned by the  last invocation postfire().  <p> This base class method actually invokes prefire(), fire(),  and postfire(), as described above. 
 * @param count The number of iterations to perform.
 * @return True if the actor was successfully iterated thespecified number of times. Otherwise, return false.
 * @exception IllegalActionException If one of the Executablemethods throws it, or if prefire() returns false.
 */
public boolean iterate(int count) throws IllegalActionException {
  int n=0;
  boolean returnVal=false;
  while (n < count) {
    if (prefire()) {
      fire();
      returnVal=postfire();
    }
 else {
      throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + count + "String_Node_Str");
    }
    n++;
  }
  return returnVal;
}
Program: 76075
Project: 76075
Buggy source:
/** 
 * Increment the count of actors waiting for the queued topology changes to be processed. Check for a resultant deadlock or pausing of the execution. If either of them is detected, then notify the directing thread of the same. This method is normally called by processes or actors that queue requests for changes to the topology and do not wish to continue their execution until their requests are processed. This method is not used by the base director and is provided for use by the deriveed classes.
 */
protected synchronized void _informOfMutationBlock(){
  _mutationBlockCount++;
  if (_areActorsDeadlocked()) {
    notifyAll();
  }
  return;
}

Fixed version (ground truth):
/** 
 * Increment the count of actors waiting for the queued topology changes to be processed. Check for a resultant deadlock or pausing of the execution. If either of them is detected, then notify the directing thread of the same. This method is normally called by processes or actors that queue requests for changes to the topology and do not wish to continue their execution until their requests are processed. This method is not used by the base director and is provided for use by the deriveed classes.
 */
protected synchronized void _informOfMutationBlock(){
  _mutationBlockCount++;
  notifyAll();
}
Program: 76076
Project: 76076
Buggy source:
/** 
 * Return true if the containing composite actor contains active processes and the composite actor has input ports. Return false otherwise. This method should normally be called only after detecting a real deadlock. True is returned to indicate that the composite actor can start its execution again if it receives data on any of its input ports.
 * @return true to indicate that the composite actor can continueexecuting on receiving additional input on its input ports.
 * @exception IllegalActionException Not thrown in this base class. May bethrown by derived classes.
 */
public boolean postfire() throws IllegalActionException {
  if (!((((CompositeActor)getContainer()).inputPortList()).isEmpty()) && _getActiveActorsCount() != 0) {
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Return true if the containing composite actor contains active processes and the composite actor has input ports. Return false otherwise. This method should normally be called only after detecting a real deadlock. True is returned to indicate that the composite actor can start its execution again if it receives data on any of its input ports.
 * @return true to indicate that the composite actor can continueexecuting on receiving additional input on its input ports.
 * @exception IllegalActionException Not thrown in this base class. May bethrown by derived classes.
 */
public boolean postfire() throws IllegalActionException {
  if (!((((CompositeActor)getContainer()).inputPortList()).isEmpty()) && _getActiveActorsCount() != 0) {
    System.out.println("String_Node_Str" + _notDone);
    return _notDone;
  }
 else {
    System.out.println("String_Node_Str" + _notDone + "String_Node_Str");
    return _notDone;
  }
}
Program: 76077
Project: 76077
Buggy source:
/** 
 * Decrement the count of processes waiting for the topology change requests (mutation requests) to be processed. This method is not used by the base director and is provided for use by the derived classes.
 */
protected synchronized void _informOfMutationUnblock(){
  _mutationBlockCount--;
  return;
}

Fixed version (ground truth):
/** 
 * Decrement the count of processes waiting for the topology change requests (mutation requests) to be processed. This method is not used by the base director and is provided for use by the derived classes.
 */
protected synchronized void _informOfMutationUnblock(){
  _mutationBlockCount--;
}
Program: 76078
Project: 76078
Buggy source:
/** 
 * Resolve an artificial deadlock and return true. If the deadlock is not an artificial deadlock (it is a real deadlock), then return false. If it is an artificial deadlock, select the receiver with the smallest queue capacity on which any process is blocked on a write and increment the capacity of the contained queue. If the capacity is non-negative, then increment the capacity by 1. Otherwise set the capacity to 1. Unblock the process blocked on this receiver. Notify the thread corresponding to the blocked process and return true. <pP If derived classes introduce new forms of deadlocks, they should override this method to introduce mechanisms of handling those deadlocks. This method is called from the fire() method of the director alone.
 * @return True after handling an artificial deadlock. Otherwise returnfalse.
 * @exception IllegalActionException Not thrown in this base class.This might be thrown by derived classes.
 */
protected boolean _resolveDeadlock() throws IllegalActionException {
  if (_writeBlockCount == 0) {
    return false;
  }
 else {
    _incrementLowestWriteCapacityPort();
    return true;
  }
}

Fixed version (ground truth):
/** 
 * Resolve an artificial deadlock and return true. If the deadlock is not an artificial deadlock (it is a real deadlock), then return false. If it is an artificial deadlock, select the receiver with the smallest queue capacity on which any process is blocked on a write and increment the capacity of the contained queue. If the capacity is non-negative, then increment the capacity by 1. Otherwise set the capacity to 1. Unblock the process blocked on this receiver. Notify the thread corresponding to the blocked process and return true. <pP If derived classes introduce new forms of deadlocks, they should override this method to introduce mechanisms of handling those deadlocks. This method is called from the fire() method of the director alone.
 * @return True after handling an artificial deadlock. Otherwise returnfalse.
 * @exception IllegalActionException Not thrown in this base class.This might be thrown by derived classes.
 */
protected boolean _resolveDeadlock() throws IllegalActionException {
  if (_writeBlockCount == 0 && _readBlockCount > 0) {
    return false;
  }
 else   if (_getActiveActorsCount() == 0) {
    return false;
  }
 else {
    System.out.println("String_Node_Str");
    _incrementLowestWriteCapacityPort();
    return true;
  }
}
Program: 76080
Project: 76080
Buggy source:
/** 
 * Wait until the detection of a deadlock. If the deadlock is real, then return. Else (for an artificial deadlock), handle the deadlock by incrementing the capacity of a receiver with the smallest capacity amongst the receivers on which a process is blocked on a write. The derived directors can override this method to handle other forms of deadlock that they define and perform actions accordingly. This method is synchronized on the director.
 * @exception IllegalActionException Not thrown in this base class. Maybethrown by derived classes.
 */
public void fire() throws IllegalActionException {
  Workspace workspace=workspace();
  while (_readBlockCount != _getActiveActorsCount()) {
synchronized (this) {
      while (!_areActorsDeadlocked()) {
        workspace.wait(this);
      }
      _notDone=_resolveDeadlock();
    }
  }
  return;
}

Fixed version (ground truth):
/** 
 * Wait until the detection of a deadlock. If the deadlock is real, then return. Else (for an artificial deadlock), handle the deadlock by incrementing the capacity of a receiver with the smallest capacity amongst the receivers on which a process is blocked on a write. The derived directors can override this method to handle other forms of deadlock that they define and perform actions accordingly. This method is synchronized on the director.
 * @exception IllegalActionException Not thrown in this base class. Maybethrown by derived classes.
 */
public void fire() throws IllegalActionException {
  Workspace workspace=workspace();
  System.out.println("String_Node_Str");
  while (_readBlockCount != _getActiveActorsCount()) {
    System.out.println("String_Node_Str");
synchronized (this) {
      while (!_areActorsDeadlocked()) {
        workspace.wait(this);
        System.out.println("String_Node_Str" + "String_Node_Str" + _getActiveActorsCount() + "String_Node_Str"+ _readBlockCount+ "String_Node_Str"+ _writeBlockCount);
        Iterator threads=_actorThreadList.iterator();
      }
      System.out.println("String_Node_Str");
      _notDone=_resolveDeadlock();
      System.out.println("String_Node_Str");
    }
  }
  System.out.println("String_Node_Str");
  return;
}
Program: 76081
Project: 76081
Buggy source:
/** 
 * Increment by 1 the count of processes blocked while reading from a receiver and notify all process listeners of the blocking of the process. Check for a deadlock or pausing of the execution as a result of the process blocking on a read. If either of them is detected, then notify the directing thread of the same.
 */
protected synchronized void _actorBlocked(ProcessReceiver rcvr){
  if (rcvr.isReadBlocked()) {
    _readBlockCount++;
  }
  if (rcvr.isWriteBlocked()) {
    _writeblockedQueues.add(rcvr);
    _writeBlockCount++;
  }
  if (_areActorsDeadlocked()) {
    notifyAll();
  }
  return;
}

Fixed version (ground truth):
/** 
 * Increment by 1 the count of processes blocked while reading from a receiver and notify all process listeners of the blocking of the process. Check for a deadlock or pausing of the execution as a result of the process blocking on a read. If either of them is detected, then notify the directing thread of the same.
 */
protected synchronized void _actorBlocked(ProcessReceiver rcvr){
  if (rcvr.isReadBlocked()) {
    _readBlockCount++;
  }
  if (rcvr.isWriteBlocked()) {
    _writeblockedQueues.add(rcvr);
    _writeBlockCount++;
  }
  notifyAll();
}
Program: 76083
Project: 76083
Buggy source:
/** 
 * Increment by 1 the count of actors waiting for the time to advance. Check for a resultant deadlock or pausing of the execution. If either of them is detected, then notify the directing thread of the same.
 */
protected synchronized void _informOfDelayBlock(){
  _delayBlockCount++;
  if (_areActorsDeadlocked()) {
    notifyAll();
  }
  return;
}

Fixed version (ground truth):
/** 
 * Increment by 1 the count of actors waiting for the time to advance. Check for a resultant deadlock or pausing of the execution. If either of them is detected, then notify the directing thread of the same.
 */
protected synchronized void _informOfDelayBlock(){
  _delayBlockCount++;
  notifyAll();
}
Program: 76086
Project: 76086
Buggy source:
/** 
 * Set the visibility of the Fill button. This is deprecated.  Use setButtons().
 * @deprecated
 */
protected void _setButtonsVisibility(boolean vis){
  _fillButton.setVisible(vis);
}

Fixed version (ground truth):
/** 
 * Set the visibility of the Fill button. This is deprecated.  Use setButtons().
 * @deprecated
 */
protected void _setButtonsVisibility(boolean vis){
  _fillButton.setVisible(vis);
  _formatButton.setVisible(vis);
  _resetButton.setVisible(vis);
}
Program: 76087
Project: 76087
Buggy source:
/** 
 * Construct a plot box with a default configuration. 
 */
public PlotBox(){
  setOpaque(true);
  setLayout(new FlowLayout(FlowLayout.RIGHT));
  addMouseListener(new ZoomListener());
  addKeyListener(new CommandListener());
  addMouseMotionListener(new DragListener());
  _measureFonts();
  requestFocus();
}

Fixed version (ground truth):
/** 
 * Construct a plot box with a default configuration. 
 */
public PlotBox(){
  setOpaque(true);
  setLayout(new FlowLayout(FlowLayout.RIGHT,2,2));
  addMouseListener(new ZoomListener());
  addKeyListener(new CommandListener());
  addMouseMotionListener(new DragListener());
  _measureFonts();
  requestFocus();
}
Program: 76088
Project: 76088
Buggy source:
/** 
 * Rescale so that the data that is currently plotted just fits. This is done based on the protected variables _xBottom, _xTop, _yBottom, and _yTop.  It is up to derived classes to ensure that variables are valid. This method calls repaint(), which eventually causes the display to be updated.
 */
public synchronized void fillPlot(){
  _setXRange(_xBottom,_xTop);
  _setYRange(_yBottom,_yTop);
  repaint();
  requestFocus();
}

Fixed version (ground truth):
/** 
 * Rescale so that the data that is currently plotted just fits. This is done based on the protected variables _xBottom, _xTop, _yBottom, and _yTop.  It is up to derived classes to ensure that variables are valid. This method calls repaint(), which eventually causes the display to be updated.
 */
public synchronized void fillPlot(){
  setXRange(_xBottom,_xTop);
  setYRange(_yBottom,_yTop);
  repaint();
  requestFocus();
}
Program: 76089
Project: 76089
Buggy source:
/** 
 * Control whether the X axis is wrapped. If it is, then X values that are out of range are remapped to be in range using modulo arithmetic.
 * @param wrap If true, wrapping of the X axis is enabled.
 */
public void setWrap(boolean wrap){
  _wrap=wrap;
}

Fixed version (ground truth):
/** 
 * Specify whether the X axis is wrapped. If it is, then X values that are out of range are remapped to be in range using modulo arithmetic. The X range is determined by the most recent call to setXRange() (or the most recent zoom). If the X range has not been set, then use the default X range, or if data has been plotted, then the current fill range.
 * @param wrap If true, wrapping of the X axis is enabled.
 */
public void setWrap(boolean wrap){
  _wrap=wrap;
  if (!_xRangeGiven) {
    if (_xBottom > _xTop) {
      setXRange(0,0);
    }
 else {
      setXRange(_xBottom,_xTop);
    }
  }
  _wrapLow=_xlowgiven;
  _wrapHigh=_xhighgiven;
}
Program: 76090
Project: 76090
Buggy source:
/** 
 * If the argument is true, make a fill button visible at the upper right.  This button auto-scales the plot. NOTE: The button may infringe on the title space, if the title is long.  In an application, it is preferable to provide a menu with the fill command.  This way, when printing the plot, the printed plot will not have a spurious button.  Thus, this method should be used only by applets, which normally do not have menus. This method should only be called from within the event dispatch thread, since it interacts with swing.
 */
public synchronized void setButtons(boolean visible){
  if (_fillButton == null) {
    _fillButton=new JButton("String_Node_Str");
    _fillButton.addActionListener(new FillButtonListener());
    add(_fillButton);
  }
  _fillButton.setVisible(visible);
  requestFocus();
}

Fixed version (ground truth):
/** 
 * If the argument is true, make a fill button visible at the upper right.  This button auto-scales the plot. NOTE: The button may infringe on the title space, if the title is long.  In an application, it is preferable to provide a menu with the fill command.  This way, when printing the plot, the printed plot will not have a spurious button.  Thus, this method should be used only by applets, which normally do not have menus. This method should only be called from within the event dispatch thread, since it interacts with swing.
 */
public synchronized void setButtons(boolean visible){
  if (_resetButton == null) {
    URL img=getClass().getResource("String_Node_Str");
    ImageIcon resetIcon=new ImageIcon(img);
    _resetButton=new JButton(resetIcon);
    _resetButton.setBorderPainted(false);
    _resetButton.setPreferredSize(new Dimension(20,20));
    _resetButton.setToolTipText("String_Node_Str");
    _resetButton.addActionListener(new ButtonListener());
    add(_resetButton);
  }
  _resetButton.setVisible(visible);
  if (_formatButton == null) {
    URL img=getClass().getResource("String_Node_Str");
    ImageIcon formatIcon=new ImageIcon(img);
    _formatButton=new JButton(formatIcon);
    _formatButton.setBorderPainted(false);
    _formatButton.setPreferredSize(new Dimension(20,20));
    _formatButton.setToolTipText("String_Node_Str");
    _formatButton.addActionListener(new ButtonListener());
    add(_formatButton);
  }
  _formatButton.setVisible(visible);
  if (_fillButton == null) {
    URL img=getClass().getResource("String_Node_Str");
    ImageIcon fillIcon=new ImageIcon(img);
    _fillButton=new JButton(fillIcon);
    _fillButton.setBorderPainted(false);
    _fillButton.setPreferredSize(new Dimension(20,20));
    _fillButton.setToolTipText("String_Node_Str");
    _fillButton.addActionListener(new ButtonListener());
    add(_fillButton);
  }
  _fillButton.setVisible(visible);
  requestFocus();
}
Program: 76091
Project: 76091
Buggy source:
/** 
 * Set the Y (vertical) range of the plot.  If this is not done explicitly, then the range is computed automatically from data available when the plot is drawn.  If min and max are identical, then the range is arbitrarily spread by 0.1.
 * @param min The bottom extent of the range.
 * @param max The top extent of the range.
 */
public synchronized void setYRange(double min,double max){
  _yRangeGiven=true;
  _ylowgiven=min;
  _yhighgiven=max;
  _setYRange(min,max);
}

Fixed version (ground truth):
/** 
 * Set the Y (vertical) range of the plot.  If this is not done explicitly, then the range is computed automatically from data available when the plot is drawn.  If min and max are identical, then the range is arbitrarily spread by 0.1.
 * @param min The bottom extent of the range.
 * @param max The top extent of the range.
 */
public synchronized void setYRange(double min,double max){
  _yRangeGiven=true;
  _ylowgiven=min;
  _yhighgiven=max;
  if (!_originalYRangeGiven) {
    _originalYlow=min;
    _originalYhigh=max;
    _originalYRangeGiven=true;
  }
  _setYRange(min,max);
}
Program: 76094
Project: 76094
Buggy source:
public void actionPerformed(ActionEvent event){
  fillPlot();
}

Fixed version (ground truth):
public void actionPerformed(ActionEvent event){
  if (event.getSource() == _fillButton) {
    fillPlot();
  }
 else   if (event.getSource() == _resetButton) {
    resetAxes();
  }
 else   if (event.getSource() == _formatButton) {
    PlotFormatter fmt=new PlotFormatter(PlotBox.this);
    fmt.openModal();
  }
}
Program: 76095
Project: 76095
Buggy source:
private int _drawLegend(Graphics graphics,int urx,int ury){
  if (graphics == null)   return 0;
  graphics.setFont(_labelFont);
  int spacing=_labelFontMetrics.getHeight();
  Enumeration v=_legendStrings.elements();
  Enumeration i=_legendDatasets.elements();
  int ypos=ury + spacing;
  int maxwidth=0;
  while (v.hasMoreElements()) {
    String legend=(String)v.nextElement();
    int dataset=((Integer)i.nextElement()).intValue();
    if (dataset >= 0) {
      if (_usecolor) {
        int color=dataset % _colors.length;
        graphics.setColor(_colors[color]);
      }
      _drawPoint(graphics,dataset,urx - 3,ypos - 3,false);
      graphics.setColor(_foreground);
      int width=_labelFontMetrics.stringWidth(legend);
      if (width > maxwidth)       maxwidth=width;
      graphics.drawString(legend,urx - 15 - width,ypos);
      ypos+=spacing;
    }
  }
  return 22 + maxwidth;
}

Fixed version (ground truth):
private int _drawLegend(Graphics graphics,int urx,int ury){
  if (graphics == null)   return 0;
  Font previousFont=graphics.getFont();
  graphics.setFont(_labelFont);
  int spacing=_labelFontMetrics.getHeight();
  Enumeration v=_legendStrings.elements();
  Enumeration i=_legendDatasets.elements();
  int ypos=ury + spacing;
  int maxwidth=0;
  while (v.hasMoreElements()) {
    String legend=(String)v.nextElement();
    int dataset=((Integer)i.nextElement()).intValue();
    if (dataset >= 0) {
      if (_usecolor) {
        int color=dataset % _colors.length;
        graphics.setColor(_colors[color]);
      }
      _drawPoint(graphics,dataset,urx - 3,ypos - 3,false);
      graphics.setColor(_foreground);
      int width=_labelFontMetrics.stringWidth(legend);
      if (width > maxwidth)       maxwidth=width;
      graphics.drawString(legend,urx - 15 - width,ypos);
      ypos+=spacing;
    }
  }
  graphics.setFont(previousFont);
  return 22 + maxwidth;
}
Program: 76096
Project: 76096
Buggy source:
/** 
 * Set the X (horizontal) range of the plot.  If this is not done explicitly, then the range is computed automatically from data available when the plot is drawn.  If min and max are identical, then the range is arbitrarily spread by 1.
 * @param min The left extent of the range.
 * @param max The right extent of the range.
 */
public synchronized void setXRange(double min,double max){
  _xRangeGiven=true;
  _xlowgiven=min;
  _xhighgiven=max;
  _setXRange(min,max);
}

Fixed version (ground truth):
/** 
 * Set the X (horizontal) range of the plot.  If this is not done explicitly, then the range is computed automatically from data available when the plot is drawn.  If min and max are identical, then the range is arbitrarily spread by 1.
 * @param min The left extent of the range.
 * @param max The right extent of the range.
 */
public synchronized void setXRange(double min,double max){
  _xRangeGiven=true;
  _xlowgiven=min;
  _xhighgiven=max;
  if (!_originalXRangeGiven) {
    _originalXlow=min;
    _originalXhigh=max;
    _originalXRangeGiven=true;
  }
  _setXRange(min,max);
}
Program: 76097
Project: 76097
Buggy source:
/** 
 * Clone the actor into the specified workspace. This calls the base class and then sets the <code>init</code> and <code>step</code> public members to the parameters of the new actor.
 * @param ws The workspace for the new object.
 * @return A new actor.
 * @exception CloneNotSupportedException If a derived class containsan attribute that cannot be cloned.
 */
public Object clone(Workspace ws) throws CloneNotSupportedException {
  Ramp newobj=(Ramp)super.clone(ws);
  output.setTypeEquals(BaseType.DOUBLE);
  return newobj;
}

Fixed version (ground truth):
/** 
 * Clone the actor into the specified workspace. This calls the base class and then sets the <code>init</code> and <code>step</code> public members to the parameters of the new actor.
 * @param ws The workspace for the new object.
 * @return A new actor.
 * @exception CloneNotSupportedException If a derived class containsan attribute that cannot be cloned.
 */
public Object clone(Workspace ws) throws CloneNotSupportedException {
  CurrentTime newobj=(CurrentTime)super.clone(ws);
  output.setTypeEquals(BaseType.DOUBLE);
  return newobj;
}
Program: 76098
Project: 76098
Buggy source:
/** 
 * Update the director parameters when the attributes are changed. Only the stopWhenQueueIsEmpty parameter is effective at run time.
 * @param attr The changed parameter.
 * @exception IllegalActionException If the parameter set is not valid.Not thrown in this class. May be needed by derived classes.
 */
public void attributeChanged(Attribute attr) throws IllegalActionException {
  if (_debugging)   _debug("String_Node_Str",attr.getName());
  if (attr == stopWhenQueueIsEmpty) {
    _stopWhenQueueIsEmpty=((BooleanToken)stopWhenQueueIsEmpty.getToken()).booleanValue();
  }
}

Fixed version (ground truth):
/** 
 * Update the director parameters when the attributes are changed. Only the stopWhenQueueIsEmpty parameter is effective at run time.
 * @param attr The changed parameter.
 * @exception IllegalActionException If the parameter set is not valid.Not thrown in this class. May be needed by derived classes.
 */
public void attributeChanged(Attribute attr) throws IllegalActionException {
  if (_debugging)   _debug("String_Node_Str",attr.getName());
  if (attr == stopWhenQueueIsEmpty) {
    _stopWhenQueueIsEmpty=((BooleanToken)stopWhenQueueIsEmpty.getToken()).booleanValue();
  }
  if (attr == synchronizeToRealTime) {
    _synchronizeToRealTime=((BooleanToken)synchronizeToRealTime.getToken()).booleanValue();
  }
}
Program: 76100
Project: 76100
Buggy source:
private void _initParameters(){
  try {
    stopTime=new Parameter(this,"String_Node_Str",new DoubleToken(Double.MAX_VALUE));
    stopTime.setTypeEquals(BaseType.DOUBLE);
    stopWhenQueueIsEmpty=new Parameter(this,"String_Node_Str",new BooleanToken(true));
    stopWhenQueueIsEmpty.setTypeEquals(BaseType.BOOLEAN);
    isCQAdaptive=new Parameter(this,"String_Node_Str",new BooleanToken(true));
    isCQAdaptive.setTypeEquals(BaseType.BOOLEAN);
    minBinCount=new Parameter(this,"String_Node_Str",new IntToken(2));
    minBinCount.setTypeEquals(BaseType.INT);
    binCountFactor=new Parameter(this,"String_Node_Str",new IntToken(2));
    binCountFactor.setTypeEquals(BaseType.INT);
  }
 catch (  KernelException e) {
    throw new InternalErrorException("String_Node_Str" + e.getMessage());
  }
}

Fixed version (ground truth):
private void _initParameters(){
  try {
    stopTime=new Parameter(this,"String_Node_Str",new DoubleToken(Double.MAX_VALUE));
    stopTime.setTypeEquals(BaseType.DOUBLE);
    stopWhenQueueIsEmpty=new Parameter(this,"String_Node_Str",new BooleanToken(true));
    stopWhenQueueIsEmpty.setTypeEquals(BaseType.BOOLEAN);
    synchronizeToRealTime=new Parameter(this,"String_Node_Str",new BooleanToken(false));
    synchronizeToRealTime.setTypeEquals(BaseType.BOOLEAN);
    isCQAdaptive=new Parameter(this,"String_Node_Str",new BooleanToken(true));
    isCQAdaptive.setTypeEquals(BaseType.BOOLEAN);
    minBinCount=new Parameter(this,"String_Node_Str",new IntToken(2));
    minBinCount.setTypeEquals(BaseType.INT);
    binCountFactor=new Parameter(this,"String_Node_Str",new IntToken(2));
    binCountFactor.setTypeEquals(BaseType.INT);
  }
 catch (  KernelException e) {
    throw new InternalErrorException("String_Node_Str" + e.getMessage());
  }
}
Program: 76102
Project: 76102
Buggy source:
/** 
 * Clone the director into the specified workspace. This calls the base class and then copies the parameter of this director.  The new actor will have the same parameter values as the old.
 * @param ws The workspace for the new object.
 * @return A new actor.
 * @exception CloneNotSupportedException If one of the attributescannot be cloned.
 */
public Object clone(Workspace ws) throws CloneNotSupportedException {
  DEDirector newobj=(DEDirector)(super.clone(ws));
  newobj.stopTime=(Parameter)newobj.getAttribute("String_Node_Str");
  newobj.stopWhenQueueIsEmpty=(Parameter)newobj.getAttribute("String_Node_Str");
  newobj.isCQAdaptive=(Parameter)newobj.getAttribute("String_Node_Str");
  newobj.minBinCount=(Parameter)newobj.getAttribute("String_Node_Str");
  newobj.binCountFactor=(Parameter)newobj.getAttribute("String_Node_Str");
  return newobj;
}

Fixed version (ground truth):
/** 
 * Clone the director into the specified workspace. This calls the base class and then copies the parameter of this director.  The new actor will have the same parameter values as the old.
 * @param ws The workspace for the new object.
 * @return A new actor.
 * @exception CloneNotSupportedException If one of the attributescannot be cloned.
 */
public Object clone(Workspace ws) throws CloneNotSupportedException {
  DEDirector newobj=(DEDirector)(super.clone(ws));
  newobj.stopTime=(Parameter)newobj.getAttribute("String_Node_Str");
  newobj.stopWhenQueueIsEmpty=(Parameter)newobj.getAttribute("String_Node_Str");
  newobj.synchronizeToRealTime=(Parameter)newobj.getAttribute("String_Node_Str");
  newobj.isCQAdaptive=(Parameter)newobj.getAttribute("String_Node_Str");
  newobj.minBinCount=(Parameter)newobj.getAttribute("String_Node_Str");
  newobj.binCountFactor=(Parameter)newobj.getAttribute("String_Node_Str");
  return newobj;
}
Program: 76103
Project: 76103
Buggy source:
/** 
 * Invoke the initialize() method of each deeply contained actor, and then check the event queue for any events. If there are any, and the director is embedded in an opaque composite actor, then request a firing of the outside director. This method should be invoked once per execution, after the initialization phase, but before any iteration.  Since type resolution has been completed, the initialize() method of a contained actor may produce output or schedule events. This method is <i>not</i> synchronized on the workspace, so the caller should be.
 * @exception IllegalActionException If the initialize() method ofone of the associated actors throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  if (_isEmbedded() && !_eventQueue.isEmpty()) {
    _requestFiring();
  }
}

Fixed version (ground truth):
/** 
 * Invoke the initialize() method of each deeply contained actor, and then check the event queue for any events. If there are any, and the director is embedded in an opaque composite actor, then request a firing of the outside director. This method should be invoked once per execution, after the initialization phase, but before any iteration.  Since type resolution has been completed, the initialize() method of a contained actor may produce output or schedule events. This method is <i>not</i> synchronized on the workspace, so the caller should be.
 * @exception IllegalActionException If the initialize() method ofone of the associated actors throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  if (_isEmbedded() && !_eventQueue.isEmpty()) {
    _requestFiring();
  }
  _realStartTime=System.currentTimeMillis();
}
Program: 76104
Project: 76104
Buggy source:
/** 
 * Configure the histogram with data from the specified input stream, which is assumed to be in PlotML format.  This should be called after place(), if place() is going to be called at all.
 * @param base The base relative to which references within the inputstream are found, or null if this is not known.
 * @param in InputStream
 * @exception Exception If the stream cannot be read or its syntaxis incorrect.
 */
public void configure(URL base,InputStream in) throws Exception {
  if (histogram == null) {
    place(_container);
  }
  HistogramMLParser parser=new HistogramMLParser(histogram);
  parser.parse(base,in);
}

Fixed version (ground truth):
/** 
 * Configure the histogram with data from the specified input stream, which is assumed to be in PlotML format.  If this is called before the plotter has been created (by calling place() or initialize()), then reading of the input stream is deferred until the plotter is created.
 * @param base The base relative to which references within the inputstream are found, or null if this is not known.
 * @param in InputStream
 * @exception Exception If the stream cannot be read or its syntaxis incorrect.
 */
public void configure(URL base,InputStream in) throws Exception {
  if (histogram != null) {
    HistogramMLParser parser=new HistogramMLParser(histogram);
    parser.parse(base,in);
    _configureBase=null;
    _configureIn=null;
  }
 else {
    _configureBase=base;
    _configureIn=in;
  }
}
Program: 76105
Project: 76105
Buggy source:
/** 
 * If the histogram has not already been created, create it using place().
 * @exception IllegalActionException If the parent class throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  if (histogram == null) {
    place(_container);
  }
 else {
    histogram.clear(false);
  }
  histogram.repaint();
}

Fixed version (ground truth):
/** 
 * If the histogram has not already been created, create it using place(). If configuration specified by a call to configure() has not yet been processed, process it.
 * @exception IllegalActionException If the parent class throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  if (histogram == null) {
    place(_container);
  }
 else {
    histogram.clear(false);
  }
  histogram.repaint();
}
Program: 76106
Project: 76106
Buggy source:
/** 
 * Specify the graphical container into which this histogram should be placed. This method needs to be called before the first call to initialize(). Otherwise, the histogram will be placed in its own frame. The histogram is also placed in its own frame if this method is called with the argument null. If the argument is an instance of Histogram, then plot data to that instance.  If a container has been specified but it is not an instance of Histogram, then create a new instance of Histogram and place it in that container using its add() method.
 * @param container The container into which to place the histogram.
 */
public void place(Container container){
  _container=container;
  if (_container == null) {
    histogram=new Histogram();
    PlotFrame frame=new PlotFrame(getFullName(),histogram);
  }
 else {
    if (_container instanceof Histogram) {
      histogram=(Histogram)_container;
    }
 else {
      histogram=new Histogram();
      _container.add(histogram);
      histogram.setButtons(true);
      histogram.setBackground(_container.getBackground());
    }
  }
}

Fixed version (ground truth):
/** 
 * Specify the graphical container into which this histogram should be placed. This method needs to be called before the first call to initialize(). Otherwise, the histogram will be placed in its own frame. The histogram is also placed in its own frame if this method is called with the argument null. If the argument is an instance of Histogram, then plot data to that instance.  If a container has been specified but it is not an instance of Histogram, then create a new instance of Histogram and place it in that container using its add() method. <p> If configure() has been called (prior to the plot getting created), then the configuration that it specified has been deferred. That configuration is performed at this time.
 * @param container The container into which to place the histogram.
 */
public void place(Container container){
  _container=container;
  if (_container == null) {
    histogram=new Histogram();
    PlotFrame frame=new PlotFrame(getFullName(),histogram);
  }
 else {
    if (_container instanceof Histogram) {
      histogram=(Histogram)_container;
    }
 else {
      histogram=new Histogram();
      _container.add(histogram);
      histogram.setButtons(true);
      histogram.setBackground(_container.getBackground());
    }
  }
  if (_configureIn != null) {
    try {
      configure(_configureBase,_configureIn);
    }
 catch (    Exception ex) {
      getManager().notifyListenersOfException(ex);
    }
  }
}
Program: 76107
Project: 76107
Buggy source:
/** 
 * Configure the plot with data from the specified input stream, which is assumed to be in PlotML format.  This should be called after place(), if place() is going to be called at all.
 * @param base The base relative to which references within the inputstream are found, or null if this is not known.
 * @param in InputStream
 * @exception Exception If the stream cannot be read or its syntaxis incorrect.
 */
public void configure(URL base,InputStream in) throws Exception {
  if (plot == null) {
    place(_container);
  }
  PlotMLParser parser=new PlotMLParser(plot);
  parser.parse(base,in);
}

Fixed version (ground truth):
/** 
 * Configure the plot with data from the specified input stream, which is assumed to be in PlotML format.  If this is called before the plotter has been created (by calling place() or initialize()), then reading of the input stream is deferred until the plotter is created.
 * @param base The base relative to which references within the inputstream are found, or null if this is not known.
 * @param in InputStream
 * @exception Exception If the stream cannot be read or its syntaxis incorrect.
 */
public void configure(URL base,InputStream in) throws Exception {
  if (plot != null) {
    PlotMLParser parser=new PlotMLParser(plot);
    parser.parse(base,in);
    _configureBase=null;
    _configureIn=null;
  }
 else {
    _configureBase=base;
    _configureIn=in;
  }
}
Program: 76108
Project: 76108
Buggy source:
/** 
 * If the plot has not already been created, create it.
 * @exception IllegalActionException If the parent class throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  if (plot == null) {
    place(_container);
  }
  if (_frame != null) {
    _frame.setVisible(true);
  }
  int width=plot.getNumDataSets();
  int offset=((IntToken)startingDataset.getToken()).intValue();
  for (int i=width - 1; i >= 0; i--) {
    plot.clear(i + offset);
  }
  plot.repaint();
}

Fixed version (ground truth):
/** 
 * If the plot has not already been created, create it. If configuration specified by a call to configure() has not yet been processed, process it.
 * @exception IllegalActionException If the parent class throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  if (plot == null) {
    place(_container);
  }
  if (_frame != null) {
    _frame.setVisible(true);
  }
  int width=plot.getNumDataSets();
  int offset=((IntToken)startingDataset.getToken()).intValue();
  for (int i=width - 1; i >= 0; i--) {
    plot.clear(i + offset);
  }
  plot.repaint();
}
Program: 76109
Project: 76109
Buggy source:
/** 
 * Specify the container into which this plot should be placed. This method needs to be called before the first call to initialize() or configure(). Otherwise, the plot will be placed in its own frame. The plot is also placed in its own frame if this method is called with a null argument.  The size of the plot, unfortunately, cannot be effectively determined from the size of the container because the container may not yet be laid out (its size will be zero).  Thus, you will have to explicitly set the size of the plot by calling plot.setSize(). The background of the plot is set equal to that of the container (unless it is null).
 * @param container The container into which to place the plot.
 */
public void place(Container container){
  _container=container;
  if (_container == null) {
    plot=new Plot();
    _frame=new PlotFrame(getFullName(),plot);
    _frame.setVisible(true);
  }
 else {
    if (_container instanceof Plot) {
      plot=(Plot)_container;
    }
 else {
      if (plot == null) {
        plot=new Plot();
        plot.setButtons(true);
      }
      _container.add(plot);
      plot.setBackground(_container.getBackground());
    }
  }
}

Fixed version (ground truth):
/** 
 * Specify the container into which this plot should be placed. This method needs to be called before the first call to initialize() or configure(). Otherwise, the plot will be placed in its own frame. The plot is also placed in its own frame if this method is called with a null argument.  The size of the plot, unfortunately, cannot be effectively determined from the size of the container because the container may not yet be laid out (its size will be zero).  Thus, you will have to explicitly set the size of the plot by calling plot.setSize(). The background of the plot is set equal to that of the container (unless it is null). <p> If configure() has been called (prior to the plot getting created), then the configuration that it specified has been deferred. That configuration is performed at this time.
 * @param container The container into which to place the plot.
 */
public void place(Container container){
  _container=container;
  if (_container == null) {
    plot=new Plot();
    _frame=new PlotFrame(getFullName(),plot);
    _frame.setVisible(true);
  }
 else {
    if (_container instanceof Plot) {
      plot=(Plot)_container;
    }
 else {
      if (plot == null) {
        plot=new Plot();
        plot.setButtons(true);
      }
      _container.add(plot);
      plot.setBackground(_container.getBackground());
    }
  }
  if (_configureIn != null) {
    try {
      configure(_configureBase,_configureIn);
    }
 catch (    Exception ex) {
      getManager().notifyListenersOfException(ex);
    }
  }
}