Program: 74194
Project: 74194
Buggy source:
/** 
 * Write the model to the specified file.  This overrides the base class to record the current size and position of the window in the model.
 * @param file The file to write to.
 * @exception IOException If the write fails.
 */
protected void _writeFile(File file) throws IOException {
  try {
    Component component=_getRightComponent().getParent();
    Component parent=component.getParent();
    while ((parent != null) && !(parent instanceof Frame)) {
      component=parent;
      parent=component.getParent();
    }
    if (parent instanceof Frame) {
      WindowPropertiesAttribute properties=(WindowPropertiesAttribute)getModel().getAttribute("String_Node_Str",WindowPropertiesAttribute.class);
      if (properties == null) {
        properties=new WindowPropertiesAttribute(getModel(),"String_Node_Str");
      }
      properties.recordProperties((Frame)parent);
    }
    _createSizeAttribute();
    JCanvas canvas=getJGraph().getGraphPane().getCanvas();
    AffineTransform current=canvas.getCanvasPane().getTransformContext().getTransform();
    double scale=current.getScaleX();
    Parameter zoom=(Parameter)getModel().getAttribute("String_Node_Str",Parameter.class);
    if (zoom == null) {
      zoom=new ExpertParameter(getModel(),"String_Node_Str");
    }
    zoom.setToken(new DoubleToken(scale));
    zoom.setVisibility(Settable.EXPERT);
    Point2D center=getCenter();
    Parameter pan=(Parameter)getModel().getAttribute("String_Node_Str",Parameter.class);
    if (pan == null) {
      pan=new ExpertParameter(getModel(),"String_Node_Str");
    }
    Token[] centerArray=new Token[2];
    centerArray[0]=new DoubleToken(center.getX());
    centerArray[1]=new DoubleToken(center.getY());
    pan.setToken(new ArrayToken(centerArray));
    pan.setVisibility(Settable.EXPERT);
  }
 catch (  Throwable throwable) {
  }
  if (_isDesignPattern()) {
    FileWriter fileWriter=null;
    try {
      fileWriter=new FileWriter(file);
      String name=getModel().getName();
      String filename=file.getName();
      int period=filename.indexOf("String_Node_Str");
      if (period > 0) {
        name=filename.substring(0,period);
      }
 else {
        name=filename;
      }
      _exportDesignPattern(fileWriter,getModel(),name);
    }
  finally {
      if (fileWriter != null) {
        fileWriter.close();
      }
    }
  }
 else {
    super._writeFile(file);
  }
}

Fixed version (ground truth):
/** 
 * Write the model to the specified file.  This overrides the base class to record the current size and position of the window in the model.
 * @param file The file to write to.
 * @exception IOException If the write fails.
 */
protected void _writeFile(File file) throws IOException {
  try {
    Component component=_getRightComponent().getParent();
    Component parent=component.getParent();
    while ((parent != null) && !(parent instanceof Frame)) {
      component=parent;
      parent=component.getParent();
    }
    if (parent != null) {
      WindowPropertiesAttribute properties=(WindowPropertiesAttribute)getModel().getAttribute("String_Node_Str",WindowPropertiesAttribute.class);
      if (properties == null) {
        properties=new WindowPropertiesAttribute(getModel(),"String_Node_Str");
      }
      properties.recordProperties((Frame)parent);
    }
    _createSizeAttribute();
    JCanvas canvas=getJGraph().getGraphPane().getCanvas();
    AffineTransform current=canvas.getCanvasPane().getTransformContext().getTransform();
    double scale=current.getScaleX();
    Parameter zoom=(Parameter)getModel().getAttribute("String_Node_Str",Parameter.class);
    if (zoom == null) {
      zoom=new ExpertParameter(getModel(),"String_Node_Str");
    }
    zoom.setToken(new DoubleToken(scale));
    zoom.setVisibility(Settable.EXPERT);
    Point2D center=getCenter();
    Parameter pan=(Parameter)getModel().getAttribute("String_Node_Str",Parameter.class);
    if (pan == null) {
      pan=new ExpertParameter(getModel(),"String_Node_Str");
    }
    Token[] centerArray=new Token[2];
    centerArray[0]=new DoubleToken(center.getX());
    centerArray[1]=new DoubleToken(center.getY());
    pan.setToken(new ArrayToken(centerArray));
    pan.setVisibility(Settable.EXPERT);
  }
 catch (  Throwable throwable) {
  }
  if (_isDesignPattern()) {
    FileWriter fileWriter=null;
    try {
      fileWriter=new FileWriter(file);
      String name=getModel().getName();
      String filename=file.getName();
      int period=filename.indexOf("String_Node_Str");
      if (period > 0) {
        name=filename.substring(0,period);
      }
 else {
        name=filename;
      }
      _exportDesignPattern(fileWriter,getModel(),name);
    }
  finally {
      if (fileWriter != null) {
        fileWriter.close();
      }
    }
  }
 else {
    super._writeFile(file);
  }
}