Program: 73142
Project: 73142
Buggy source:
/** 
 * Update the size, zoom and position of the window. This method is typically called when closing the window or writing the moml file out.
 * @exception IllegalActionException If there is a problemgetting a parameter.
 * @exception NameDuplicationException If there is a problemcreating a parameter.
 */
private void _updateWindowAttributes() throws IllegalActionException, NameDuplicationException {
  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);
  boolean updateValue=false;
  if (zoom == null) {
    zoom=new ExpertParameter(getModel(),"String_Node_Str");
    updateValue=true;
  }
 else {
    double oldZoom=((DoubleToken)zoom.getToken()).doubleValue();
    if (oldZoom != scale) {
      updateValue=true;
    }
  }
  boolean toplevelHasEntities=false;
  if (updateValue) {
    if (((CompositeEntity)getModel().toplevel()).getEntities().hasMoreElements()) {
      toplevelHasEntities=true;
      String moml="String_Node_Str" + "String_Node_Str" + scale + "String_Node_Str";
      MoMLChangeRequest request=new MoMLChangeRequest(this,getModel(),moml);
      request.setUndoable(true);
      getModel().requestChange(request);
      zoom.setVisibility(Settable.EXPERT);
    }
  }
  Point2D center=getCenter();
  Parameter pan=(Parameter)getModel().getAttribute("String_Node_Str",Parameter.class);
  updateValue=false;
  if (pan == null) {
    pan=new ExpertParameter(getModel(),"String_Node_Str");
    updateValue=true;
  }
 else {
    Token[] oldCenter=((ArrayToken)pan.getToken()).arrayValue();
    double oldCenterX=((DoubleToken)oldCenter[0]).doubleValue();
    double oldCenterY=((DoubleToken)oldCenter[1]).doubleValue();
    if (center.getX() != oldCenterX || center.getY() != oldCenterY) {
      updateValue=true;
    }
  }
  if (updateValue && toplevelHasEntities) {
    String moml="String_Node_Str" + "String_Node_Str" + center.getX() + "String_Node_Str"+ center.getY()+ "String_Node_Str";
    MoMLChangeRequest request=new MoMLChangeRequest(this,getModel(),moml);
    request.setUndoable(true);
    getModel().requestChange(request);
    pan.setVisibility(Settable.EXPERT);
  }
}

Fixed version (ground truth):
/** 
 * Update the size, zoom and position of the window. This method is typically called when closing the window or writing the moml file out.
 * @exception IllegalActionException If there is a problemgetting a parameter.
 * @exception NameDuplicationException If there is a problemcreating a parameter.
 */
private void _updateWindowAttributes() throws IllegalActionException, NameDuplicationException {
  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);
  boolean updateValue=false;
  if (zoom == null || zoom.getToken() == null) {
    zoom=new ExpertParameter(getModel(),"String_Node_Str");
    zoom.setToken("String_Node_Str");
    updateValue=true;
  }
 else {
    double oldZoom=((DoubleToken)zoom.getToken()).doubleValue();
    if (oldZoom != scale) {
      updateValue=true;
    }
  }
  boolean toplevelHasEntities=false;
  if (updateValue) {
    if (((CompositeEntity)getModel().toplevel()).getEntities().hasMoreElements()) {
      toplevelHasEntities=true;
      String moml="String_Node_Str" + "String_Node_Str" + scale + "String_Node_Str";
      MoMLChangeRequest request=new MoMLChangeRequest(this,getModel(),moml);
      request.setUndoable(true);
      getModel().requestChange(request);
      zoom.setVisibility(Settable.EXPERT);
    }
  }
  Point2D center=getCenter();
  Parameter pan=(Parameter)getModel().getAttribute("String_Node_Str",Parameter.class);
  updateValue=false;
  if (pan == null || pan.getToken() == null) {
    pan=new ExpertParameter(getModel(),"String_Node_Str");
    pan.setToken("String_Node_Str" + center.getX() + "String_Node_Str"+ center.getY()+ "String_Node_Str");
    updateValue=true;
  }
 else {
    Token[] oldCenter=((ArrayToken)pan.getToken()).arrayValue();
    double oldCenterX=((DoubleToken)oldCenter[0]).doubleValue();
    double oldCenterY=((DoubleToken)oldCenter[1]).doubleValue();
    if (center.getX() != oldCenterX || center.getY() != oldCenterY) {
      updateValue=true;
    }
  }
  if (updateValue && toplevelHasEntities) {
    String moml="String_Node_Str" + "String_Node_Str" + center.getX() + "String_Node_Str"+ center.getY()+ "String_Node_Str";
    MoMLChangeRequest request=new MoMLChangeRequest(this,getModel(),moml);
    request.setUndoable(true);
    getModel().requestChange(request);
    pan.setVisibility(Settable.EXPERT);
  }
}