remember to close input file!
[jalview.git] / src / MCview / PDBViewer.java
index dda04a8..8bfd7b5 100755 (executable)
@@ -1,20 +1,19 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
- * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
+ * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
  * 
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This file is part of Jalview.
  * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
  * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
  */
 package MCview;
 
@@ -29,8 +28,6 @@ import jalview.io.*;
 import jalview.schemes.*;
 import jalview.ws.ebi.EBIFetchClient;
 
-import java.awt.BorderLayout;
-
 public class PDBViewer extends JInternalFrame implements Runnable
 {
 
@@ -361,8 +358,7 @@ public class PDBViewer extends JInternalFrame implements Runnable
             if (evt.isControlDown()
                     || SwingUtilities.isRightMouseButton(evt))
             {
-              radioItem
-                      .removeActionListener(radioItem.getActionListeners()[0]);
+              radioItem.removeActionListener(radioItem.getActionListeners()[0]);
 
               int option = JOptionPane.showInternalConfirmDialog(
                       jalview.gui.Desktop.desktop,
@@ -460,7 +456,7 @@ public class PDBViewer extends JInternalFrame implements Runnable
    * DOCUMENT ME!
    * 
    * @param e
-   *                DOCUMENT ME!
+   *          DOCUMENT ME!
    */
   public void eps_actionPerformed(ActionEvent e)
   {
@@ -471,7 +467,7 @@ public class PDBViewer extends JInternalFrame implements Runnable
    * DOCUMENT ME!
    * 
    * @param e
-   *                DOCUMENT ME!
+   *          DOCUMENT ME!
    */
   public void png_actionPerformed(ActionEvent e)
   {
@@ -493,8 +489,8 @@ public class PDBViewer extends JInternalFrame implements Runnable
     else
     {
       im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.EPS,
-              "Make EPS file from view", width, height, null, this
-                      .getTitle());
+              "Make EPS file from view", width, height, null,
+              this.getTitle());
     }
 
     if (im.getGraphics() != null)
@@ -565,8 +561,15 @@ public class PDBViewer extends JInternalFrame implements Runnable
   public void mapping_actionPerformed(ActionEvent e)
   {
     jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
-    Desktop.addInternalFrame(cap, "PDB - Sequence Mapping", 550, 600);
-    cap.setText(pdbcanvas.mappingDetails.toString());
+    try
+    {
+      cap.setText(pdbcanvas.mappingDetails.toString());
+      Desktop.addInternalFrame(cap, "PDB - Sequence Mapping", 550, 600);
+    } catch (OutOfMemoryError oom)
+    {
+      new OOMWarning("Opening sequence to structure mapping report", oom);
+      cap.dispose();
+    }
   }
 
   public void allchains_itemStateChanged(ItemEvent e)
@@ -654,8 +657,8 @@ public class PDBViewer extends JInternalFrame implements Runnable
 
   public void savePDB_actionPerformed(ActionEvent e)
   {
-    JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache
-            .getProperty("LAST_DIRECTORY"));
+    JalviewFileChooser chooser = new JalviewFileChooser(
+            jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
 
     chooser.setFileView(new JalviewFileView());
     chooser.setDialogTitle("Save PDB File");
@@ -680,6 +683,7 @@ public class PDBViewer extends JInternalFrame implements Runnable
           }
         }
         out.close();
+        in.close();
       } catch (Exception ex)
       {
         ex.printStackTrace();