JAL-1517 fix copyright for 2.8.2
[jalview.git] / src / MCview / PDBViewer.java
index c70bc6f..b802708 100755 (executable)
@@ -1,83 +1,92 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer
- * Copyright (C) 2007 AM Waterhouse, J Procter, 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
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
+ * Copyright (C) 2014 The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * 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.
- *
- * 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 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
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
 package MCview;
 
 import java.io.*;
 
-import java.awt.*;
 import java.awt.event.*;
 import javax.swing.*;
-import java.util.BitSet;
 
 import jalview.datamodel.*;
 import jalview.gui.*;
 import jalview.io.*;
 import jalview.schemes.*;
+import jalview.util.MessageManager;
+import jalview.ws.ebi.EBIFetchClient;
 
-import org.jmol.api.*;
-import org.jmol.adapter.smarter.SmarterJmolAdapter;
-import org.jmol.util.Logger;
-import org.jmol.popup.*;
-
-public class PDBViewer
-    extends JInternalFrame implements Runnable
+public class PDBViewer extends JInternalFrame implements Runnable
 {
-  PDBEntry pdb;
+
   /**
    * The associated sequence in an alignment
    */
-  Sequence sequence;
   PDBCanvas pdbcanvas;
+
+  PDBEntry pdbentry;
+
+  SequenceI[] seq;
+
+  String[] chains;
+
+  AlignmentPanel ap;
+
+  String protocol;
+
   String tmpPDBFile;
 
-  public PDBViewer(PDBEntry entry,
-                   Sequence seq,
-                   SeqCanvas seqcanvas)
+  public PDBViewer(PDBEntry pdbentry, SequenceI[] seq, String[] chains,
+          AlignmentPanel ap, String protocol)
   {
-   /* try
+    this.pdbentry = pdbentry;
+    this.seq = seq;
+    this.chains = chains;
+    this.ap = ap;
+    this.protocol = protocol;
+
+    try
     {
       jbInit();
-    }
-    catch (Exception ex)
+    } catch (Exception ex)
     {
       ex.printStackTrace();
     }
 
-    if (entry == null)
-    {
-      return;
-    }
-    pdb = entry;
-    sequence = seq;
-    pdbcanvas = new PDBCanvas(seqcanvas, sequence);
+    StringBuffer title = new StringBuffer(seq[0].getName() + ":"
+            + pdbentry.getFile());
+
+    pdbcanvas = new PDBCanvas();
 
-    if (pdb.getFile() != null)
+    setContentPane(pdbcanvas);
+
+    if (pdbentry.getFile() != null)
     {
       try
       {
-        tmpPDBFile = pdb.getFile();
+        tmpPDBFile = pdbentry.getFile();
         PDBfile pdbfile = new PDBfile(tmpPDBFile,
-                                      jalview.io.AppletFormatAdapter.FILE);
-        pdbcanvas.setPDBFile(pdbfile);
+                jalview.io.AppletFormatAdapter.FILE);
 
-      }
-      catch (java.io.IOException ex)
+        pdbcanvas.init(pdbentry, seq, chains, ap, protocol);
+
+      } catch (java.io.IOException ex)
       {
         ex.printStackTrace();
       }
@@ -88,282 +97,41 @@ public class PDBViewer
       worker.start();
     }
 
-      public void run()
-      {
-        try
-        {
-          EBIFetchClient ebi = new EBIFetchClient();
-          String query = "pdb:" + pdb.getId();
-          tmpPDBFile = ebi.fetchDataAsFile(query, "default", "raw").getAbsolutePath();
-          if (tmpPDBFile != null)
-          {
-            PDBfile pdbfile = new PDBfile(tmpPDBFile,
-                                          jalview.io.AppletFormatAdapter.FILE);
-            pdbcanvas.setPDBFile(pdbfile);
-          }
-          else
-          {
-            throw new Exception("Empty result for WSDbFetch Query: " + query);
-          }
-        }
-        catch (Exception ex)
-        {
-          ex.printStackTrace();
-          showErrorMessage("Failed to retrieve PDB structure.");
-//      this.dispose();
-        }
-      }
-
-
-    setContentPane(pdbcanvas);
-    StringBuffer title = new StringBuffer(sequence.getName() + ":" + pdb.getId());
-    if (pdb.getProperty() != null)
+    if (pdbentry.getProperty() != null)
     {
-      if (pdb.getProperty().get("method") != null)
+      if (pdbentry.getProperty().get("method") != null)
       {
         title.append(" Method: ");
-        title.append(pdb.getProperty().get("method"));
+        title.append(pdbentry.getProperty().get("method"));
       }
-      if (pdb.getProperty().get("chains") != null)
+      if (pdbentry.getProperty().get("chains") != null)
       {
         title.append(" Chain:");
-        title.append(pdb.getProperty().get("chains"));
-      }
-    }
-    */
-
-     Container contentPane = getContentPane();
-     JmolPanel jmolPanel = new JmolPanel();
-     contentPane.add(jmolPanel);
-
-     JmolViewer viewer = jmolPanel.viewer;
-
-
-     System.out.println(entry.getFile()+" "+entry.getId());
-     viewer.openFile(entry.getFile());
-
-
-     StringBuffer string = new StringBuffer();
-
-     for(int i=0; i<seq.getLength(); i++)
-     {
-       Color col = seqcanvas.getSequenceRenderer().getResidueBoxColour(seq, i);
-
-       string.append("select " + i + "B; color [" +
-                     col.getRed()+","
-                     +col.getGreen()+","
-                     +col.getBlue()+"]; ");
-     }
-    System.out.println(string);
-
-    viewer.evalString(string.toString());
-
-
-     String strError = viewer.getOpenFileError();
-     if (strError != null)
-       Logger.error(strError);
-
-
-  //   Desktop.addInternalFrame(this,
-   //                           seq.getName() + ":1GAQ"
-   //                           , 400, 400);
-
-  }
-
-
-
-
-  static class JmolPanel
-      extends JPanel implements JmolSelectionListener
-  {
-    JmolViewer viewer;
-    JmolAdapter adapter;
-    JmolPanel()
-    {
-      adapter = new SmarterJmolAdapter(null);
-      viewer = org.jmol.viewer.Viewer.allocateViewer(this, adapter);
-      viewer.addSelectionListener(this);
-
-      MyStatusListener myStatusListener;
-      myStatusListener = new MyStatusListener();
-      viewer.setJmolStatusListener(myStatusListener);
-
-      JFrame frame = new JFrame("script window");
-     // scriptWindow = new ScriptWindow(viewer, frame);
-
-      myStatusListener.jmolpopup = JmolPopup.newJmolPopup(viewer);
-    }
-     public ScriptWindow scriptWindow;
- class MyStatusListener implements JmolStatusListener
- {
-
-   JmolPopup jmolpopup ;
-
-
-   public String eval(String strEval) {
-     return "# 'eval' is implemented only for the applet.";
-   }
-
-   public void createImage(String file, String type, int quality) {
-   System.out.println("CREATE IMAGE");
-     // ImageCreator c = new ImageCreator(viewer, status);
-   //  c.createImage(file, type, quality);
-   }
-
-   public void setCallbackFunction(String callbackType, String callbackFunction) {
-     // applet only?
-   }
-
-   public void notifyFileLoaded(String fullPathName, String fileName,
-                                String modelName, Object clientFile,
-                                String errorMsg) {
-
-   }
-
-   public void notifyFrameChanged(int frameNo) {
-     // Note: twos-complement. To get actual frame number, use
-     // Math.max(frameNo, -2 - frameNo)
-     // -1 means all frames are now displayed
-
-     boolean isAnimationRunning = (frameNo <= -2);
-
-   }
-
-   public void notifyScriptStart(String statusMessage, String additionalInfo) {
-     //System.out.println("notifyScriptStart:" + statusMessage + (additionalInfo == "" ? "" : additionalInfo));
-   }
-
-   public void sendConsoleEcho(String strEcho) {
-     if (scriptWindow != null)
-       scriptWindow.sendConsoleEcho(strEcho);
-   }
-
-   public void sendConsoleMessage(String strStatus) {
-     if (scriptWindow != null)
-       scriptWindow.sendConsoleMessage(strStatus);
-   }
-
-   public void notifyScriptTermination(String strStatus, int msWalltime) {
-     if (scriptWindow != null)
-       scriptWindow.notifyScriptTermination(strStatus, msWalltime);
-   }
-
-   public void handlePopupMenu(int x, int y) {
-     jmolpopup.show(x, y);
-   }
-
-   public void notifyNewPickingModeMeasurement(int iatom, String strMeasure) {
-     notifyAtomPicked(iatom, strMeasure);
-   }
-
-   public void notifyNewDefaultModeMeasurement(int count, String strInfo) {
-   //  measurementTable.updateTables();
-   }
-
-   public void notifyAtomPicked(int atomIndex, String strInfo) {
-
-     System.out.println("ATOM PICKED "+atomIndex+" "+strInfo);
-     if (scriptWindow != null) {
-       scriptWindow.sendConsoleMessage(strInfo);
-       scriptWindow.sendConsoleMessage("\n");
-     }
-   }
-
-   public void notifyAtomHovered(int atomIndex, String strInfo) {
-System.out.println("HOVER "+atomIndex+" "+strInfo);
-   }
-
-   public void sendSyncScript(String script, String appletName) {
-   }
-
-   public void showUrl(String url) {
-   }
-
-   public void showConsole(boolean showConsole) {
-     System.out.println("SHOW CONSOLE" +(scriptWindow==null));
-     if (scriptWindow == null)
-       return;
-     if (showConsole)
-       scriptWindow.show();
-     else
-       scriptWindow.hide();
-   }
-
-   public float functionXY(String functionName, int x, int y) {
-     return 0;  // for user-defined isosurface functions (testing only -- bob hanson)
-   }
-
-    }
-
-
-    class ScriptWindowAction extends AbstractAction {
-
-      public ScriptWindowAction() {
-        super("BLAH");
-      }
-
-      public void actionPerformed(ActionEvent e) {
-        if (scriptWindow != null)
-        scriptWindow.show();
+        title.append(pdbentry.getProperty().get("chains"));
       }
     }
-
-    /**
-     * Called when the selected atoms change
-     * @param selection bit set giving selection of atom indexes
-     */
-    public void selectionChanged(BitSet selection)
-    {
-  System.out.println("SELECTION: "+selection);
-    }
-
-
-    public JmolSimpleViewer getViewer()
-    {
-      return viewer;
-    }
-
-    final Dimension currentSize = new Dimension();
-    final Rectangle rectClip = new Rectangle();
-
-    public void paint(Graphics g)
-    {
-
-      getSize(currentSize);
-      g.getClipBounds(rectClip);
-      viewer.renderScreenImage(g, currentSize, rectClip);
-    }
+    Desktop.addInternalFrame(this, title.toString(), 400, 400);
   }
 
-
   public void run()
   {
     try
     {
       EBIFetchClient ebi = new EBIFetchClient();
-      String query = "pdb:" + pdb.getId();
-      tmpPDBFile = ebi.fetchDataAsFile(query, "default", "raw").getAbsolutePath();
-      if (tmpPDBFile != null)
-      {
-        PDBfile pdbfile = new PDBfile(tmpPDBFile,
-                                      jalview.io.AppletFormatAdapter.FILE);
-        pdbcanvas.setPDBFile(pdbfile);
-      }
-      else
-      {
-        throw new Exception("Empty result for WSDbFetch Query: " + query);
-      }
-    }
-    catch (Exception ex)
+      String query = "pdb:" + pdbentry.getId();
+      pdbentry.setFile(ebi.fetchDataAsFile(query, "default", "raw")
+              .getAbsolutePath());
+
+      if (pdbentry.getFile() != null)
+        pdbcanvas.init(pdbentry, seq, chains, ap, protocol);
+    } catch (Exception ex)
     {
+      pdbcanvas.errorMessage = "Error retrieving file: " + pdbentry.getId();
       ex.printStackTrace();
-      showErrorMessage("Failed to retrieve PDB structure.");
-//      this.dispose();
     }
   }
 
-  private void jbInit()
-      throws Exception
+  private void jbInit() throws Exception
   {
     this.addKeyListener(new KeyAdapter()
     {
@@ -374,10 +142,10 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
     });
 
     this.setJMenuBar(jMenuBar1);
-    fileMenu.setText("File");
-    coloursMenu.setText("Colours");
-    saveMenu.setActionCommand("Save Image");
-    saveMenu.setText("Save As");
+    fileMenu.setText(MessageManager.getString("action.file"));
+    coloursMenu.setText(MessageManager.getString("label.colours"));
+    saveMenu.setActionCommand(MessageManager.getString("action.save_image"));
+    saveMenu.setText(MessageManager.getString("action.save_as"));
     png.setText("PNG");
     png.addActionListener(new ActionListener()
     {
@@ -394,7 +162,7 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
         eps_actionPerformed(e);
       }
     });
-    mapping.setText("View Mapping");
+    mapping.setText(MessageManager.getString("label.view_mapping"));
     mapping.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -402,7 +170,7 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
         mapping_actionPerformed(e);
       }
     });
-    wire.setText("Wireframe");
+    wire.setText(MessageManager.getString("label.wireframe"));
     wire.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -411,7 +179,7 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
       }
     });
     depth.setSelected(true);
-    depth.setText("Depthcue");
+    depth.setText(MessageManager.getString("label.depthcue"));
     depth.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -420,7 +188,7 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
       }
     });
     zbuffer.setSelected(true);
-    zbuffer.setText("Z Buffering");
+    zbuffer.setText(MessageManager.getString("label.z_buffering"));
     zbuffer.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -428,7 +196,7 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
         zbuffer_actionPerformed(e);
       }
     });
-    charge.setText("Charge & Cysteine");
+    charge.setText(MessageManager.getString("label.charge_cysteine"));
     charge.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -436,7 +204,7 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
         charge_actionPerformed(e);
       }
     });
-    chain.setText("By Chain");
+    chain.setText(MessageManager.getString("action.by_chain"));
     chain.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -445,7 +213,7 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
       }
     });
     seqButton.setSelected(true);
-    seqButton.setText("By Sequence");
+    seqButton.setText(MessageManager.getString("action.by_sequence"));
     seqButton.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -454,7 +222,7 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
       }
     });
     allchains.setSelected(true);
-    allchains.setText("Show All Chains");
+    allchains.setText(MessageManager.getString("label.show_all_chains"));
     allchains.addItemListener(new ItemListener()
     {
       public void itemStateChanged(ItemEvent e)
@@ -462,7 +230,7 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
         allchains_itemStateChanged(e);
       }
     });
-    zappo.setText("Zappo");
+    zappo.setText(MessageManager.getString("label.zappo"));
     zappo.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -470,7 +238,7 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
         zappo_actionPerformed(e);
       }
     });
-    taylor.setText("Taylor");
+    taylor.setText(MessageManager.getString("label.taylor"));
     taylor.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -478,7 +246,7 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
         taylor_actionPerformed(e);
       }
     });
-    hydro.setText("Hydro");
+    hydro.setText(MessageManager.getString("label.hydrophobicity"));
     hydro.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -486,7 +254,7 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
         hydro_actionPerformed(e);
       }
     });
-    helix.setText("Helix");
+    helix.setText(MessageManager.getString("label.helix_propensity"));
     helix.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -494,7 +262,7 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
         helix_actionPerformed(e);
       }
     });
-    strand.setText("Strand");
+    strand.setText(MessageManager.getString("label.strand_propensity"));
     strand.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -502,7 +270,7 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
         strand_actionPerformed(e);
       }
     });
-    turn.setText("Turn");
+    turn.setText(MessageManager.getString("label.turn_propensity"));
     turn.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -510,7 +278,7 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
         turn_actionPerformed(e);
       }
     });
-    buried.setText("Buried");
+    buried.setText(MessageManager.getString("label.buried_index"));
     buried.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -518,7 +286,7 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
         buried_actionPerformed(e);
       }
     });
-    user.setText("User Defined...");
+    user.setText(MessageManager.getString("action.user_defined"));
     user.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -526,8 +294,8 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
         user_actionPerformed(e);
       }
     });
-    viewMenu.setText("View");
-    background.setText("Background Colour...");
+    viewMenu.setText(MessageManager.getString("action.view"));
+    background.setText(MessageManager.getString("label.background_colour") + "...");
     background.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -535,7 +303,7 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
         background_actionPerformed(e);
       }
     });
-    savePDB.setText("PDB File");
+    savePDB.setText(MessageManager.getString("label.pdb_file"));
     savePDB.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -578,32 +346,32 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
 
     if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
     {
-      java.util.Enumeration userColours = jalview.gui.UserDefinedColours.
-          getUserColourSchemes().keys();
+      java.util.Enumeration userColours = jalview.gui.UserDefinedColours
+              .getUserColourSchemes().keys();
 
       while (userColours.hasMoreElements())
       {
         final JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(
-            userColours.
-            nextElement().toString());
+                userColours.nextElement().toString());
         radioItem.setName("USER_DEFINED");
         radioItem.addMouseListener(new MouseAdapter()
         {
           public void mousePressed(MouseEvent evt)
           {
-            if (evt.isControlDown() || SwingUtilities.isRightMouseButton(evt))
+            if (evt.isControlDown()
+                    || SwingUtilities.isRightMouseButton(evt))
             {
               radioItem.removeActionListener(radioItem.getActionListeners()[0]);
 
-              int option = JOptionPane.showInternalConfirmDialog(jalview.gui.
-                  Desktop.desktop,
-                  "Remove from default list?",
-                  "Remove user defined colour",
-                  JOptionPane.YES_NO_OPTION);
+              int option = JOptionPane.showInternalConfirmDialog(
+                      jalview.gui.Desktop.desktop,
+                      MessageManager.getString("label.remove_from_default_list"),
+                      MessageManager.getString("label.remove_user_defined_colour"),
+                      JOptionPane.YES_NO_OPTION);
               if (option == JOptionPane.YES_OPTION)
               {
-                jalview.gui.UserDefinedColours.removeColourFromDefaults(
-                    radioItem.getText());
+                jalview.gui.UserDefinedColours
+                        .removeColourFromDefaults(radioItem.getText());
                 coloursMenu.remove(radioItem);
               }
               else
@@ -638,36 +406,60 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
   }
 
   JMenuBar jMenuBar1 = new JMenuBar();
+
   JMenu fileMenu = new JMenu();
+
   JMenu coloursMenu = new JMenu();
+
   JMenu saveMenu = new JMenu();
+
   JMenuItem png = new JMenuItem();
+
   JMenuItem eps = new JMenuItem();
+
   JMenuItem mapping = new JMenuItem();
+
   JCheckBoxMenuItem wire = new JCheckBoxMenuItem();
+
   JCheckBoxMenuItem depth = new JCheckBoxMenuItem();
+
   JCheckBoxMenuItem zbuffer = new JCheckBoxMenuItem();
+
   JCheckBoxMenuItem allchains = new JCheckBoxMenuItem();
 
   JRadioButtonMenuItem charge = new JRadioButtonMenuItem();
+
   JRadioButtonMenuItem chain = new JRadioButtonMenuItem();
+
   JRadioButtonMenuItem seqButton = new JRadioButtonMenuItem();
+
   JRadioButtonMenuItem hydro = new JRadioButtonMenuItem();
+
   JRadioButtonMenuItem taylor = new JRadioButtonMenuItem();
+
   JRadioButtonMenuItem zappo = new JRadioButtonMenuItem();
+
   JRadioButtonMenuItem user = new JRadioButtonMenuItem();
+
   JRadioButtonMenuItem buried = new JRadioButtonMenuItem();
+
   JRadioButtonMenuItem turn = new JRadioButtonMenuItem();
+
   JRadioButtonMenuItem strand = new JRadioButtonMenuItem();
+
   JRadioButtonMenuItem helix = new JRadioButtonMenuItem();
+
   JMenu viewMenu = new JMenu();
+
   JMenuItem background = new JMenuItem();
+
   JMenuItem savePDB = new JMenuItem();
 
   /**
    * DOCUMENT ME!
-   *
-   * @param e DOCUMENT ME!
+   * 
+   * @param e
+   *          DOCUMENT ME!
    */
   public void eps_actionPerformed(ActionEvent e)
   {
@@ -676,8 +468,9 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
 
   /**
    * DOCUMENT ME!
-   *
-   * @param e DOCUMENT ME!
+   * 
+   * @param e
+   *          DOCUMENT ME!
    */
   public void png_actionPerformed(ActionEvent e)
   {
@@ -693,19 +486,14 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
 
     if (type == jalview.util.ImageMaker.PNG)
     {
-      im = new jalview.util.ImageMaker(this,
-                                       jalview.util.ImageMaker.PNG,
-                                       "Make PNG image from view",
-                                       width, height,
-                                       null, null);
+      im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.PNG,
+              "Make PNG image from view", width, height, null, null);
     }
     else
     {
-      im = new jalview.util.ImageMaker(this,
-                                       jalview.util.ImageMaker.EPS,
-                                       "Make EPS file from view",
-                                       width, height,
-                                       null, this.getTitle());
+      im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.EPS,
+              "Make EPS file from view", width, height, null,
+              this.getTitle());
     }
 
     if (im.getGraphics() != null)
@@ -776,8 +564,15 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
   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, MessageManager.getString("label.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)
@@ -785,13 +580,6 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
     pdbcanvas.setAllchainsVisible(allchains.getState());
   }
 
-  void showErrorMessage(String error)
-  {
-  //  JOptionPane.showInternalMessageDialog(Desktop.desktop,
-  //                                        error, "PDB Viewer Error",
-  //                                        JOptionPane.WARNING_MESSAGE);
-  }
-
   public void zappo_actionPerformed(ActionEvent e)
   {
     pdbcanvas.bysequence = false;
@@ -842,14 +630,14 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
 
   public void user_actionPerformed(ActionEvent e)
   {
-    if (e.getActionCommand().equals("User Defined..."))
+    if (e.getActionCommand().equals(MessageManager.getString("action.user_defined")))
     {
-      new UserDefinedColours(pdbcanvas, null);
+      // new UserDefinedColours(pdbcanvas, null);
     }
     else
     {
-      UserColourScheme udc = (UserColourScheme) UserDefinedColours.
-          getUserColourSchemes().get(e.getActionCommand());
+      UserColourScheme udc = (UserColourScheme) UserDefinedColours
+              .getUserColourSchemes().get(e.getActionCommand());
 
       pdbcanvas.pdb.setColours(udc);
       pdbcanvas.redrawneeded = true;
@@ -860,8 +648,7 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
   public void background_actionPerformed(ActionEvent e)
   {
     java.awt.Color col = JColorChooser.showDialog(this,
-                                                  "Select Background Colour",
-                                                  pdbcanvas.backgroundColour);
+            MessageManager.getString("label.select_backgroud_colour"), pdbcanvas.backgroundColour);
 
     if (col != null)
     {
@@ -874,12 +661,11 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
   public void savePDB_actionPerformed(ActionEvent e)
   {
     JalviewFileChooser chooser = new JalviewFileChooser(
-        jalview.bin.Cache.getProperty(
-            "LAST_DIRECTORY"));
+            jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
 
     chooser.setFileView(new JalviewFileView());
     chooser.setDialogTitle("Save PDB File");
-    chooser.setToolTipText("Save");
+    chooser.setToolTipText(MessageManager.getString("action.save"));
 
     int value = chooser.showSaveDialog(this);
 
@@ -892,18 +678,16 @@ System.out.println("HOVER "+atomIndex+" "+strInfo);
 
         PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
         String data;
-        while ( (data = in.readLine()) != null)
+        while ((data = in.readLine()) != null)
         {
-          if (
-              ! (data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1)
-              )
+          if (!(data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1))
           {
             out.println(data);
           }
         }
         out.close();
-      }
-      catch (Exception ex)
+        in.close();
+      } catch (Exception ex)
       {
         ex.printStackTrace();
       }