Program: 73147
Project: 73147
Buggy source:
/** 
 * Offset the locations of top level objects that are created by the change request. If a BasicGraphFrame can be found, then the position of the mouse is used to determine the offsite.  Otherwise, a small offset is  used.
 * @param parser The parser
 */
protected void _postParse(MoMLParser parser){
  double[] minimumLocation=new double[]{Double.MAX_VALUE,Double.MAX_VALUE};
  Iterator topObjects=parser.topObjectsCreated().iterator();
  while (topObjects.hasNext()) {
    NamedObj topObject=(NamedObj)topObjects.next();
    Iterator locations=topObject.attributeList(Locatable.class).iterator();
    while (locations.hasNext()) {
      Locatable location=(Locatable)locations.next();
      double[] locationValue=location.getLocation();
      for (int i=0; i < locationValue.length && i < minimumLocation.length; i++) {
        if (locationValue[i] < minimumLocation[i]) {
          minimumLocation[i]=locationValue[i];
        }
      }
    }
  }
  double xOffset=_PASTE_OFFSET;
  double yOffset=_PASTE_OFFSET;
  double scale=1.0;
  GraphController controller=null;
  SelectionModel selectionModel=null;
  BasicGraphFrame basicGraphFrame=BasicGraphFrame.getBasicGraphFrame(_context);
  if (basicGraphFrame != null) {
    controller=basicGraphFrame.getJGraph().getGraphPane().getGraphController();
    Point componentLocation=basicGraphFrame.getJGraph().getGraphPane().getCanvas().getLocationOnScreen();
    AffineTransform current=basicGraphFrame.getJGraph().getCanvasPane().getTransformContext().getTransform();
    scale=current.getScaleX();
    Rectangle2D visibleCanvas=basicGraphFrame.getVisibleCanvasRectangle();
    Point mouseLocation=MouseInfo.getPointerInfo().getLocation();
    xOffset=mouseLocation.x - componentLocation.x + visibleCanvas.getX() - minimumLocation[0];
    yOffset=mouseLocation.y - componentLocation.y + visibleCanvas.getY() - minimumLocation[1];
  }
  NamedObj container=null;
  final Set _topObjects=new HashSet<NamedObj>();
  topObjects=parser.topObjectsCreated().iterator();
  while (topObjects.hasNext()) {
    NamedObj topObject=(NamedObj)topObjects.next();
    _topObjects.add(topObject);
    if (container == null) {
      container=topObject.getContainer();
    }
    try {
      Iterator locations=topObject.attributeList(Locatable.class).iterator();
      while (locations.hasNext()) {
        Locatable location=(Locatable)locations.next();
        double[] locationValue=location.getLocation();
        for (int i=0; i < locationValue.length; i++) {
          if (i == 0) {
            locationValue[i]+=xOffset;
          }
 else           if (i == 1) {
            locationValue[i]+=yOffset;
          }
 else {
            locationValue[i]+=_PASTE_OFFSET;
          }
          location.setLocation(locationValue);
        }
      }
    }
 catch (    IllegalActionException e) {
      MessageHandler.error("String_Node_Str",e);
    }
  }
  if (controller != null) {
    final GraphController controllerFinal=controller;
    final NamedObj containerFinal=container;
    Runnable doHelloWorld=new Runnable(){
      public void run(){
        Interactor interactor=null;
        try {
          interactor=controllerFinal.getEdgeController(new Object()).getEdgeInteractor();
        }
 catch (        Exception ex) {
          interactor=controllerFinal.getNodeController(null).getNodeInteractor();
        }
        SelectionInteractor selectionInteractor=(SelectionInteractor)interactor;
        SelectionRenderer defaultSelectionRenderer=selectionInteractor.getSelectionRenderer();
        SelectionModel selectionModel=controllerFinal.getSelectionModel();
        selectionModel.clearSelection();
        AbstractBasicGraphModel graphModel=(AbstractBasicGraphModel)controllerFinal.getGraphModel();
        Iterator nodes=graphModel.nodes(containerFinal);
        while (nodes.hasNext()) {
          Location node=(Location)nodes.next();
          NamedObj entity=(NamedObj)graphModel.getSemanticObject(node);
          if (_topObjects.contains(entity)) {
            Figure figure=controllerFinal.getFigure(node);
            selectionModel.addSelection(figure);
          }
        }
      }
    }
;
    SwingUtilities.invokeLater(doHelloWorld);
  }
  parser.clearTopObjectsList();
}

Fixed version (ground truth):
/** 
 * Offset the locations of top level objects that are created by the change request. If a BasicGraphFrame can be found, then the position of the mouse is used to determine the offsite.  Otherwise, a small offset is  used.
 * @param parser The parser
 */
protected void _postParse(MoMLParser parser){
  double[] minimumLocation=new double[]{Double.MAX_VALUE,Double.MAX_VALUE};
  Iterator topObjects=parser.topObjectsCreated().iterator();
  while (topObjects.hasNext()) {
    NamedObj topObject=(NamedObj)topObjects.next();
    Iterator locations=topObject.attributeList(Locatable.class).iterator();
    while (locations.hasNext()) {
      Locatable location=(Locatable)locations.next();
      double[] locationValue=location.getLocation();
      for (int i=0; i < locationValue.length && i < minimumLocation.length; i++) {
        if (locationValue[i] < minimumLocation[i]) {
          minimumLocation[i]=locationValue[i];
        }
      }
    }
  }
  double xOffset=_PASTE_OFFSET;
  double yOffset=_PASTE_OFFSET;
  double scale=1.0;
  GraphController controller=null;
  SelectionModel selectionModel=null;
  BasicGraphFrame basicGraphFrame=BasicGraphFrame.getBasicGraphFrame(_context);
  if (basicGraphFrame != null) {
    controller=basicGraphFrame.getJGraph().getGraphPane().getGraphController();
    Point componentLocation=basicGraphFrame.getJGraph().getGraphPane().getCanvas().getLocationOnScreen();
    AffineTransform current=basicGraphFrame.getJGraph().getCanvasPane().getTransformContext().getTransform();
    scale=current.getScaleX();
    Rectangle2D visibleCanvas=basicGraphFrame.getVisibleCanvasRectangle();
    Point mouseLocation=MouseInfo.getPointerInfo().getLocation();
    xOffset=(mouseLocation.x - componentLocation.x) / scale + visibleCanvas.getX() - minimumLocation[0];
    yOffset=(mouseLocation.y - componentLocation.y) / scale + visibleCanvas.getY() - minimumLocation[1];
  }
  NamedObj container=null;
  final Set _topObjects=new HashSet<NamedObj>();
  topObjects=parser.topObjectsCreated().iterator();
  while (topObjects.hasNext()) {
    NamedObj topObject=(NamedObj)topObjects.next();
    _topObjects.add(topObject);
    if (container == null) {
      container=topObject.getContainer();
    }
    try {
      Iterator locations=topObject.attributeList(Locatable.class).iterator();
      while (locations.hasNext()) {
        Locatable location=(Locatable)locations.next();
        double[] locationValue=location.getLocation();
        for (int i=0; i < locationValue.length; i++) {
          if (i == 0) {
            locationValue[i]+=xOffset;
          }
 else           if (i == 1) {
            locationValue[i]+=yOffset;
          }
 else {
            locationValue[i]+=_PASTE_OFFSET;
          }
          location.setLocation(locationValue);
        }
      }
    }
 catch (    IllegalActionException e) {
      MessageHandler.error("String_Node_Str",e);
    }
  }
  if (controller != null) {
    final GraphController controllerFinal=controller;
    final NamedObj containerFinal=container;
    Runnable doHelloWorld=new Runnable(){
      public void run(){
        Interactor interactor=null;
        try {
          interactor=controllerFinal.getEdgeController(new Object()).getEdgeInteractor();
        }
 catch (        Exception ex) {
          interactor=controllerFinal.getNodeController(null).getNodeInteractor();
        }
        SelectionInteractor selectionInteractor=(SelectionInteractor)interactor;
        SelectionRenderer defaultSelectionRenderer=selectionInteractor.getSelectionRenderer();
        SelectionModel selectionModel=controllerFinal.getSelectionModel();
        selectionModel.clearSelection();
        AbstractBasicGraphModel graphModel=(AbstractBasicGraphModel)controllerFinal.getGraphModel();
        Iterator nodes=graphModel.nodes(containerFinal);
        while (nodes.hasNext()) {
          Location node=(Location)nodes.next();
          NamedObj entity=(NamedObj)graphModel.getSemanticObject(node);
          if (_topObjects.contains(entity)) {
            Figure figure=controllerFinal.getFigure(node);
            selectionModel.addSelection(figure);
          }
        }
      }
    }
;
    SwingUtilities.invokeLater(doHelloWorld);
  }
  parser.clearTopObjectsList();
}