Program: 75385
Project: 75385
Buggy source:
/** 
 * Construct a frame associated with the specified Ptolemy II model. After constructing this, it is necessary to call setVisible(true) to make the frame appear. This is typically done by calling show() on the controlling tableau. This constructor results in a graph frame that obtains its library either from the model (if it has one), or the <i>defaultLibrary</i> argument (if it is non-null), or the default library defined in the configuration.
 * @see Tableau#show()
 * @param entity The model to put in this frame.
 * @param tableau The tableau responsible for this frame.
 * @param defaultLibrary An attribute specifying the default libraryto use if the model does not have a library.
 */
public BasicGraphFrame(CompositeEntity entity,Tableau tableau,LibraryAttribute defaultLibrary){
  super(entity,tableau);
  entity.addChangeListener(this);
  getContentPane().setLayout(new BorderLayout());
  GraphPane pane=_createGraphPane();
  pane.getForegroundLayer().setPickHalo(2);
  _jgraph=new JGraph(pane);
  new EditorDropTarget(_jgraph);
  ActionListener deletionListener=new ActionListener(){
    /** 
 * Delete any nodes or edges from the graph that are currently selected.  In addition, delete any edges that are connected to any deleted nodes.
 */
    public void actionPerformed(    ActionEvent e){
      delete();
    }
  }
;
  _jgraph.registerKeyboardAction(deletionListener,"String_Node_Str",KeyStroke.getKeyStroke(KeyEvent.VK_DELETE,0),JComponent.WHEN_IN_FOCUSED_WINDOW);
  _jgraph.setRequestFocusEnabled(true);
  _jgraph.addMouseListener(new FocusMouseListener());
  _jgraph.setAlignmentX(1);
  _jgraph.setAlignmentY(1);
  _jgraph.setBackground(BACKGROUND_COLOR);
  try {
    SizeAttribute size=(SizeAttribute)getModel().getAttribute("String_Node_Str",SizeAttribute.class);
    if (size != null) {
      size.setSize(_jgraph);
    }
 else {
      _jgraph.setMinimumSize(new Dimension(200,200));
      _jgraph.setPreferredSize(new Dimension(600,400));
      _jgraph.setSize(600,400);
    }
  }
 catch (  Exception ex) {
  }
  _graphPanner=new JCanvasPanner(_jgraph);
  _graphPanner.setPreferredSize(new Dimension(200,150));
  _graphPanner.setMaximumSize(new Dimension(200,150));
  _graphPanner.setSize(200,150);
  boolean gotLibrary=false;
  try {
    LibraryAttribute libraryAttribute=(LibraryAttribute)entity.getAttribute("String_Node_Str",LibraryAttribute.class);
    if (libraryAttribute != null) {
      _topLibrary=libraryAttribute.getLibrary();
      gotLibrary=true;
    }
  }
 catch (  Exception ex) {
    try {
      MessageHandler.warning("String_Node_Str",ex);
    }
 catch (    CancelException e) {
    }
  }
  if (!gotLibrary) {
    try {
      if (defaultLibrary != null) {
        _topLibrary=defaultLibrary.getLibrary();
        gotLibrary=true;
      }
    }
 catch (    Exception ex) {
      try {
        MessageHandler.warning("String_Node_Str",ex);
      }
 catch (      CancelException e) {
      }
    }
  }
  if (!gotLibrary) {
    Configuration configuration=getConfiguration();
    if (configuration != null) {
      _topLibrary=(CompositeEntity)configuration.getEntity("String_Node_Str");
      if (_topLibrary == null) {
        Workspace workspace=entity.workspace();
        _topLibrary=new CompositeEntity(workspace);
        try {
          _topLibrary.setName("String_Node_Str");
          new Attribute(_topLibrary,"String_Node_Str");
        }
 catch (        Exception ex) {
          throw new InternalErrorException("String_Node_Str" + ex);
        }
      }
    }
  }
  _libraryModel=new VisibleTreeModel(_topLibrary);
  _library=new PTree(_libraryModel);
  _library.setRootVisible(false);
  _library.setBackground(BACKGROUND_COLOR);
  _libraryScrollPane=new JScrollPane(_library);
  _libraryScrollPane.setMinimumSize(new Dimension(200,200));
  _libraryScrollPane.setPreferredSize(new Dimension(200,200));
  _palettePane=new JPanel();
  _palettePane.setBorder(null);
  _palettePane.setLayout(new BoxLayout(_palettePane,BoxLayout.Y_AXIS));
  _palettePane.add(_libraryScrollPane,BorderLayout.CENTER);
  _palettePane.add(_graphPanner,BorderLayout.SOUTH);
  _splitPane=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true);
  _splitPane.setLeftComponent(_palettePane);
  _splitPane.setRightComponent(_jgraph);
  getContentPane().add(_splitPane,BorderLayout.CENTER);
  _toolbar=new JToolBar();
  getContentPane().add(_toolbar,BorderLayout.NORTH);
  GUIUtilities.addToolBarButton(_toolbar,_zoomInAction);
  GUIUtilities.addToolBarButton(_toolbar,_zoomResetAction);
  GUIUtilities.addToolBarButton(_toolbar,_zoomFitAction);
  GUIUtilities.addToolBarButton(_toolbar,_zoomOutAction);
  _cutAction=new CutAction();
  _copyAction=new CopyAction();
  _pasteAction=new PasteAction();
  _createHierarchyAction=new CreateHierarchyAction();
  _layoutAction=new LayoutAction();
  _saveInLibraryAction=new SaveInLibraryAction();
  _importLibraryAction=new ImportLibraryAction();
  _instantiateEntityAction=new InstantiateEntityAction();
}

Fixed version (ground truth):
/** 
 * Construct a frame associated with the specified Ptolemy II model. After constructing this, it is necessary to call setVisible(true) to make the frame appear. This is typically done by calling show() on the controlling tableau. This constructor results in a graph frame that obtains its library either from the model (if it has one), or the <i>defaultLibrary</i> argument (if it is non-null), or the default library defined in the configuration.
 * @see Tableau#show()
 * @param entity The model to put in this frame.
 * @param tableau The tableau responsible for this frame.
 * @param defaultLibrary An attribute specifying the default libraryto use if the model does not have a library.
 */
public BasicGraphFrame(CompositeEntity entity,Tableau tableau,LibraryAttribute defaultLibrary){
  super(entity,tableau);
  entity.addChangeListener(this);
  getContentPane().setLayout(new BorderLayout());
  GraphPane pane=_createGraphPane();
  pane.getForegroundLayer().setPickHalo(2);
  _jgraph=new JGraph(pane);
  new EditorDropTarget(_jgraph);
  ActionListener deletionListener=new ActionListener(){
    /** 
 * Delete any nodes or edges from the graph that are currently selected.  In addition, delete any edges that are connected to any deleted nodes.
 */
    public void actionPerformed(    ActionEvent e){
      delete();
    }
  }
;
  _jgraph.registerKeyboardAction(deletionListener,"String_Node_Str",KeyStroke.getKeyStroke(KeyEvent.VK_DELETE,0),JComponent.WHEN_IN_FOCUSED_WINDOW);
  _jgraph.setRequestFocusEnabled(true);
  _jgraph.addMouseListener(new FocusMouseListener());
  _jgraph.setAlignmentX(1);
  _jgraph.setAlignmentY(1);
  _jgraph.setBackground(BACKGROUND_COLOR);
  try {
    SizeAttribute size=(SizeAttribute)getModel().getAttribute("String_Node_Str",SizeAttribute.class);
    if (size != null) {
      size.setSize(_jgraph);
    }
 else {
      _jgraph.setMinimumSize(new Dimension(200,200));
      _jgraph.setPreferredSize(new Dimension(600,400));
      _jgraph.setSize(600,400);
    }
    Parameter zoom=(Parameter)getModel().getAttribute("String_Node_Str",Parameter.class);
    if (zoom != null) {
      zoom(((DoubleToken)zoom.getToken()).doubleValue());
    }
    Parameter pan=(Parameter)getModel().getAttribute("String_Node_Str",Parameter.class);
    if (pan != null) {
      ArrayToken panToken=(ArrayToken)pan.getToken();
      Point2D center=new Point2D.Double(((DoubleToken)panToken.getElement(0)).doubleValue(),((DoubleToken)panToken.getElement(1)).doubleValue());
      setCenter(center);
    }
  }
 catch (  Exception ex) {
  }
  _graphPanner=new JCanvasPanner(_jgraph);
  _graphPanner.setPreferredSize(new Dimension(200,150));
  _graphPanner.setMaximumSize(new Dimension(200,150));
  _graphPanner.setSize(200,150);
  boolean gotLibrary=false;
  try {
    LibraryAttribute libraryAttribute=(LibraryAttribute)entity.getAttribute("String_Node_Str",LibraryAttribute.class);
    if (libraryAttribute != null) {
      _topLibrary=libraryAttribute.getLibrary();
      gotLibrary=true;
    }
  }
 catch (  Exception ex) {
    try {
      MessageHandler.warning("String_Node_Str",ex);
    }
 catch (    CancelException e) {
    }
  }
  if (!gotLibrary) {
    try {
      if (defaultLibrary != null) {
        _topLibrary=defaultLibrary.getLibrary();
        gotLibrary=true;
      }
    }
 catch (    Exception ex) {
      try {
        MessageHandler.warning("String_Node_Str",ex);
      }
 catch (      CancelException e) {
      }
    }
  }
  if (!gotLibrary) {
    Configuration configuration=getConfiguration();
    if (configuration != null) {
      _topLibrary=(CompositeEntity)configuration.getEntity("String_Node_Str");
      if (_topLibrary == null) {
        Workspace workspace=entity.workspace();
        _topLibrary=new CompositeEntity(workspace);
        try {
          _topLibrary.setName("String_Node_Str");
          new Attribute(_topLibrary,"String_Node_Str");
        }
 catch (        Exception ex) {
          throw new InternalErrorException("String_Node_Str" + ex);
        }
      }
    }
  }
  _libraryModel=new VisibleTreeModel(_topLibrary);
  _library=new PTree(_libraryModel);
  _library.setRootVisible(false);
  _library.setBackground(BACKGROUND_COLOR);
  _libraryScrollPane=new JScrollPane(_library);
  _libraryScrollPane.setMinimumSize(new Dimension(200,200));
  _libraryScrollPane.setPreferredSize(new Dimension(200,200));
  _palettePane=new JPanel();
  _palettePane.setBorder(null);
  _palettePane.setLayout(new BoxLayout(_palettePane,BoxLayout.Y_AXIS));
  _palettePane.add(_libraryScrollPane,BorderLayout.CENTER);
  _palettePane.add(_graphPanner,BorderLayout.SOUTH);
  _splitPane=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true);
  _splitPane.setLeftComponent(_palettePane);
  _splitPane.setRightComponent(_jgraph);
  getContentPane().add(_splitPane,BorderLayout.CENTER);
  _toolbar=new JToolBar();
  getContentPane().add(_toolbar,BorderLayout.NORTH);
  GUIUtilities.addToolBarButton(_toolbar,_zoomInAction);
  GUIUtilities.addToolBarButton(_toolbar,_zoomResetAction);
  GUIUtilities.addToolBarButton(_toolbar,_zoomFitAction);
  GUIUtilities.addToolBarButton(_toolbar,_zoomOutAction);
  _cutAction=new CutAction();
  _copyAction=new CopyAction();
  _pasteAction=new PasteAction();
  _createHierarchyAction=new CreateHierarchyAction();
  _layoutAction=new LayoutAction();
  _saveInLibraryAction=new SaveInLibraryAction();
  _importLibraryAction=new ImportLibraryAction();
  _instantiateEntityAction=new InstantiateEntityAction();
}