JAL-1645 Version-Rel Version 2.9 Year-Rel 2015 Licensing glob
[jalview.git] / src / jalview / jbgui / GStructureViewer.java
index a03ec76..ac2202c 100644 (file)
@@ -1,29 +1,93 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
- * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9)
+ * Copyright (C) 2015 The Jalview Authors
  * 
- * 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
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
 package jalview.jbgui;
 
-import javax.swing.*;
-import java.awt.event.ActionListener;
+import jalview.api.structures.JalviewStructureDisplayI;
+import jalview.util.MessageManager;
+
+import java.awt.GridLayout;
 import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 
-public class GStructureViewer extends JInternalFrame
+import javax.swing.ButtonGroup;
+import javax.swing.JInternalFrame;
+import javax.swing.JLabel;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JRadioButtonMenuItem;
+
+public abstract class GStructureViewer extends JInternalFrame implements
+        JalviewStructureDisplayI
 {
+  // private AAStructureBindingModel bindingModel;
+
+  protected JMenu savemenu = new JMenu();
+
+  protected JMenu viewMenu = new JMenu();
+
+  protected JMenu chainMenu = new JMenu();
+
+  protected JMenu viewerActionMenu = new JMenu();
+
+  protected JMenuItem alignStructs = new JMenuItem();
+
+  protected JMenuItem fitToWindow = new JMenuItem();
+
+  protected JRadioButtonMenuItem seqColour = new JRadioButtonMenuItem();
+
+  protected JRadioButtonMenuItem chainColour = new JRadioButtonMenuItem();
+
+  protected JRadioButtonMenuItem chargeColour = new JRadioButtonMenuItem();
+
+  protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem();
+
+  protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem();
+
+  protected JRadioButtonMenuItem hydroColour = new JRadioButtonMenuItem();
+
+  protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem();
+
+  protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem();
+
+  protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem();
+
+  protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem();
+
+  protected JRadioButtonMenuItem purinePyrimidineColour = new JRadioButtonMenuItem();
+
+  protected JRadioButtonMenuItem userColour = new JRadioButtonMenuItem();
+
+  protected JRadioButtonMenuItem viewerColour = new JRadioButtonMenuItem();
+
+  protected JMenuItem helpItem = new JMenuItem();
+
+  protected JLabel statusBar = new JLabel();
+
+  protected JPanel statusPanel = new JPanel();
+
+  /**
+   * Constructor
+   */
   public GStructureViewer()
   {
     try
@@ -37,11 +101,17 @@ public class GStructureViewer extends JInternalFrame
 
   private void jbInit() throws Exception
   {
+    JMenuBar menuBar = new JMenuBar();
     this.setJMenuBar(menuBar);
-    fileMenu.setText("File");
-    savemenu.setActionCommand("Save Image");
-    savemenu.setText("Save As");
-    pdbFile.setText("PDB File");
+
+    JMenu fileMenu = new JMenu();
+    fileMenu.setText(MessageManager.getString("action.file"));
+
+    savemenu.setActionCommand(MessageManager.getString("action.save_image"));
+    savemenu.setText(MessageManager.getString("action.save_as"));
+
+    JMenuItem pdbFile = new JMenuItem();
+    pdbFile.setText(MessageManager.getString("label.pdb_file"));
     pdbFile.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent actionEvent)
@@ -49,6 +119,8 @@ public class GStructureViewer extends JInternalFrame
         pdbFile_actionPerformed(actionEvent);
       }
     });
+
+    JMenuItem png = new JMenuItem();
     png.setText("PNG");
     png.addActionListener(new ActionListener()
     {
@@ -57,6 +129,8 @@ public class GStructureViewer extends JInternalFrame
         png_actionPerformed(actionEvent);
       }
     });
+
+    JMenuItem eps = new JMenuItem();
     eps.setText("EPS");
     eps.addActionListener(new ActionListener()
     {
@@ -65,7 +139,9 @@ public class GStructureViewer extends JInternalFrame
         eps_actionPerformed(actionEvent);
       }
     });
-    viewMapping.setText("View Mapping");
+
+    JMenuItem viewMapping = new JMenuItem();
+    viewMapping.setText(MessageManager.getString("label.view_mapping"));
     viewMapping.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent actionEvent)
@@ -73,10 +149,25 @@ public class GStructureViewer extends JInternalFrame
         viewMapping_actionPerformed(actionEvent);
       }
     });
-    viewMenu.setText("View");
-    chainMenu.setText("Show Chain");
-    colourMenu.setText("Colours");
-    backGround.setText("Background Colour...");
+    viewMenu.setText(MessageManager.getString("action.view"));
+
+    chainMenu.setText(MessageManager.getString("action.show_chain"));
+
+    fitToWindow.setText(MessageManager.getString("label.fit_to_window"));
+    fitToWindow.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent actionEvent)
+      {
+        fitToWindow_actionPerformed();
+      }
+    });
+
+    JMenu colourMenu = new JMenu();
+    colourMenu.setText(MessageManager.getString("label.colours"));
+
+    JMenuItem backGround = new JMenuItem();
+    backGround
+            .setText(MessageManager.getString("action.background_colour"));
     backGround.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent actionEvent)
@@ -84,8 +175,8 @@ public class GStructureViewer extends JInternalFrame
         backGround_actionPerformed(actionEvent);
       }
     });
-    seqColour.setSelected(true);
-    seqColour.setText("By Sequence");
+    seqColour.setSelected(false);
+    seqColour.setText(MessageManager.getString("action.by_sequence"));
     seqColour.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent actionEvent)
@@ -93,7 +184,7 @@ public class GStructureViewer extends JInternalFrame
         seqColour_actionPerformed(actionEvent);
       }
     });
-    chainColour.setText("By Chain");
+    chainColour.setText(MessageManager.getString("action.by_chain"));
     chainColour.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent actionEvent)
@@ -101,7 +192,7 @@ public class GStructureViewer extends JInternalFrame
         chainColour_actionPerformed(actionEvent);
       }
     });
-    chargeColour.setText("Charge & Cysteine");
+    chargeColour.setText(MessageManager.getString("label.charge_cysteine"));
     chargeColour.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent actionEvent)
@@ -109,7 +200,7 @@ public class GStructureViewer extends JInternalFrame
         chargeColour_actionPerformed(actionEvent);
       }
     });
-    zappoColour.setText("Zappo");
+    zappoColour.setText(MessageManager.getString("label.zappo"));
     zappoColour.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent actionEvent)
@@ -117,7 +208,7 @@ public class GStructureViewer extends JInternalFrame
         zappoColour_actionPerformed(actionEvent);
       }
     });
-    taylorColour.setText("Taylor");
+    taylorColour.setText(MessageManager.getString("label.taylor"));
     taylorColour.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent actionEvent)
@@ -125,7 +216,7 @@ public class GStructureViewer extends JInternalFrame
         taylorColour_actionPerformed(actionEvent);
       }
     });
-    hydroColour.setText("Hydro");
+    hydroColour.setText(MessageManager.getString("label.hydrophobicity"));
     hydroColour.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent actionEvent)
@@ -133,7 +224,8 @@ public class GStructureViewer extends JInternalFrame
         hydroColour_actionPerformed(actionEvent);
       }
     });
-    strandColour.setText("Strand");
+    strandColour.setText(MessageManager
+            .getString("label.strand_propensity"));
     strandColour.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent actionEvent)
@@ -141,7 +233,7 @@ public class GStructureViewer extends JInternalFrame
         strandColour_actionPerformed(actionEvent);
       }
     });
-    helixColour.setText("Helix Propensity");
+    helixColour.setText(MessageManager.getString("label.helix_propensity"));
     helixColour.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent actionEvent)
@@ -149,7 +241,7 @@ public class GStructureViewer extends JInternalFrame
         helixColour_actionPerformed(actionEvent);
       }
     });
-    turnColour.setText("Turn Propensity");
+    turnColour.setText(MessageManager.getString("label.turn_propensity"));
     turnColour.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent actionEvent)
@@ -157,7 +249,7 @@ public class GStructureViewer extends JInternalFrame
         turnColour_actionPerformed(actionEvent);
       }
     });
-    buriedColour.setText("Buried Index");
+    buriedColour.setText(MessageManager.getString("label.buried_index"));
     buriedColour.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent actionEvent)
@@ -165,7 +257,17 @@ public class GStructureViewer extends JInternalFrame
         buriedColour_actionPerformed(actionEvent);
       }
     });
-    userColour.setText("User Defined ...");
+    purinePyrimidineColour.setText(MessageManager
+            .getString("label.purine_pyrimidine"));
+    purinePyrimidineColour.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent actionEvent)
+      {
+        purinePyrimidineColour_actionPerformed(actionEvent);
+      }
+    });
+
+    userColour.setText(MessageManager.getString("action.user_defined"));
     userColour.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent actionEvent)
@@ -173,18 +275,44 @@ public class GStructureViewer extends JInternalFrame
         userColour_actionPerformed(actionEvent);
       }
     });
-    helpMenu.setText("Help");
-    jmolHelp.setText("Jmol Help");
-    jmolHelp.addActionListener(new ActionListener()
+    viewerColour.setSelected(false);
+    viewerColour
+            .setText(MessageManager.getString("label.colour_with_jmol"));
+    viewerColour.setToolTipText(MessageManager
+            .getString("label.let_jmol_manage_structure_colours"));
+    viewerColour.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent actionEvent)
       {
-        jmolHelp_actionPerformed(actionEvent);
+        viewerColour_actionPerformed(actionEvent);
       }
     });
+
+    JMenu helpMenu = new JMenu();
+    helpMenu.setText(MessageManager.getString("action.help"));
+    helpItem.setText(MessageManager.getString("label.jmol_help"));
+    helpItem.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent actionEvent)
+      {
+        showHelp_actionPerformed(actionEvent);
+      }
+    });
+    alignStructs
+            .setText(MessageManager.getString("label.align_structures"));
+    alignStructs.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent actionEvent)
+      {
+        alignStructs_actionPerformed(actionEvent);
+      }
+    });
+    viewerActionMenu.setText(MessageManager.getString("label.jmol"));
     menuBar.add(fileMenu);
     menuBar.add(viewMenu);
     menuBar.add(colourMenu);
+    menuBar.add(viewerActionMenu);
+    viewerActionMenu.setVisible(false);
     menuBar.add(helpMenu);
     fileMenu.add(savemenu);
     fileMenu.add(viewMapping);
@@ -192,6 +320,7 @@ public class GStructureViewer extends JInternalFrame
     savemenu.add(png);
     savemenu.add(eps);
     viewMenu.add(chainMenu);
+
     colourMenu.add(seqColour);
     colourMenu.add(chainColour);
     colourMenu.add(chargeColour);
@@ -202,60 +331,46 @@ public class GStructureViewer extends JInternalFrame
     colourMenu.add(strandColour);
     colourMenu.add(turnColour);
     colourMenu.add(buriedColour);
+    colourMenu.add(purinePyrimidineColour);
     colourMenu.add(userColour);
+    colourMenu.add(viewerColour);
     colourMenu.add(backGround);
-    helpMenu.add(jmolHelp);
-  }
-
-  JMenuBar menuBar = new JMenuBar();
-
-  JMenu fileMenu = new JMenu();
-
-  JMenu savemenu = new JMenu();
-
-  JMenuItem pdbFile = new JMenuItem();
-
-  JMenuItem png = new JMenuItem();
-
-  JMenuItem eps = new JMenuItem();
-
-  JMenuItem viewMapping = new JMenuItem();
-
-  JMenu viewMenu = new JMenu();
-
-  protected JMenu chainMenu = new JMenu();
-
-  JMenu jMenu1 = new JMenu();
-
-  JMenu colourMenu = new JMenu();
 
-  JMenuItem backGround = new JMenuItem();
-
-  protected JCheckBoxMenuItem seqColour = new JCheckBoxMenuItem();
-
-  JMenuItem chainColour = new JMenuItem();
-
-  JMenuItem chargeColour = new JMenuItem();
-
-  JMenuItem zappoColour = new JMenuItem();
-
-  JMenuItem taylorColour = new JMenuItem();
-
-  JMenuItem hydroColour = new JMenuItem();
-
-  JMenuItem strandColour = new JMenuItem();
-
-  JMenuItem helixColour = new JMenuItem();
-
-  JMenuItem turnColour = new JMenuItem();
-
-  JMenuItem buriedColour = new JMenuItem();
+    ButtonGroup colourButtons = new ButtonGroup();
+
+    colourButtons.add(seqColour);
+    colourButtons.add(chainColour);
+    colourButtons.add(chargeColour);
+    colourButtons.add(zappoColour);
+    colourButtons.add(taylorColour);
+    colourButtons.add(hydroColour);
+    colourButtons.add(helixColour);
+    colourButtons.add(strandColour);
+    colourButtons.add(turnColour);
+    colourButtons.add(buriedColour);
+    colourButtons.add(purinePyrimidineColour);
+    colourButtons.add(userColour);
+    colourButtons.add(viewerColour);
+
+    helpMenu.add(helpItem);
+    viewerActionMenu.add(alignStructs);
+
+    statusPanel.setLayout(new GridLayout());
+    this.getContentPane().add(statusPanel, java.awt.BorderLayout.SOUTH);
+    statusPanel.add(statusBar, null);
+  }
 
-  JMenuItem userColour = new JMenuItem();
+  protected void fitToWindow_actionPerformed()
+  {
+  }
 
-  JMenu helpMenu = new JMenu();
+  protected void viewerColour_actionPerformed(ActionEvent actionEvent)
+  {
+  }
 
-  JMenuItem jmolHelp = new JMenuItem();
+  protected void alignStructs_actionPerformed(ActionEvent actionEvent)
+  {
+  }
 
   public void pdbFile_actionPerformed(ActionEvent actionEvent)
   {
@@ -327,6 +442,11 @@ public class GStructureViewer extends JInternalFrame
 
   }
 
+  public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
+  {
+
+  }
+
   public void userColour_actionPerformed(ActionEvent actionEvent)
   {
 
@@ -337,8 +457,18 @@ public class GStructureViewer extends JInternalFrame
 
   }
 
-  public void jmolHelp_actionPerformed(ActionEvent actionEvent)
+  public void showHelp_actionPerformed(ActionEvent actionEvent)
   {
 
   }
+
+  // {
+  // return bindingModel;
+  // }
+
+  // public void setBindingModel(AAStructureBindingModel bindingModel)
+  // {
+  // this.bindingModel = bindingModel;
+  // }
+
 }