Merge branch 'develop' into feature/JAL-3551Pymol
[jalview.git] / src / jalview / jbgui / GStructureViewer.java
index 10e0b9b..6c0beda 100644 (file)
-/*\r
- * Jalview - A Sequence Alignment Editor and Viewer\r
- * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
- *\r
- * This program is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU General Public License\r
- * as published by the Free Software Foundation; either version 2\r
- * of the License, or (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
- */\r
-\r
-package jalview.jbgui;\r
-\r
-import javax.swing.*;\r
-import java.awt.event.ActionListener;\r
-import java.awt.event.ActionEvent;\r
-\r
-public class GStructureViewer  extends JInternalFrame\r
-{\r
-  public GStructureViewer()\r
-  {\r
-    try\r
-    {\r
-      jbInit();\r
-    }\r
-    catch (Exception ex)\r
-    {\r
-      ex.printStackTrace();\r
-    }\r
-  }\r
-\r
-  private void jbInit()\r
-      throws Exception\r
-  {\r
-    this.setJMenuBar(menuBar);\r
-    fileMenu.setText("File");\r
-    savemenu.setActionCommand("Save Image");\r
-    savemenu.setText("Save As");\r
-    pdbFile.setText("PDB File");\r
-    pdbFile.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent actionEvent)\r
-      {\r
-        pdbFile_actionPerformed(actionEvent);\r
-      }\r
-    });\r
-    png.setText("PNG");\r
-    png.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent actionEvent)\r
-      {\r
-        png_actionPerformed(actionEvent);\r
-      }\r
-    });\r
-    eps.setText("EPS");\r
-    eps.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent actionEvent)\r
-      {\r
-        eps_actionPerformed(actionEvent);\r
-      }\r
-    });\r
-    viewMapping.setText("View Mapping");\r
-    viewMapping.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent actionEvent)\r
-      {\r
-        viewMapping_actionPerformed(actionEvent);\r
-      }\r
-    });\r
-    viewMenu.setText("View");\r
-    chainMenu.setText("Show Chain");\r
-    colourMenu.setText("Colours");\r
-    backGround.setText("Background Colour...");\r
-    backGround.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent actionEvent)\r
-      {\r
-        backGround_actionPerformed(actionEvent);\r
-      }\r
-    });\r
-    seqColour.setSelected(true);\r
-    seqColour.setText("By Sequence");\r
-    seqColour.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent actionEvent)\r
-      {\r
-        seqColour_actionPerformed(actionEvent);\r
-      }\r
-    });\r
-    chainColour.setText("By Chain");\r
-    chainColour.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent actionEvent)\r
-      {\r
-        chainColour_actionPerformed(actionEvent);\r
-      }\r
-    });\r
-    chargeColour.setText("Charge & Cysteine");\r
-    chargeColour.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent actionEvent)\r
-      {\r
-        chargeColour_actionPerformed(actionEvent);\r
-      }\r
-    });\r
-    zappoColour.setText("Zappo");\r
-    zappoColour.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent actionEvent)\r
-      {\r
-        zappoColour_actionPerformed(actionEvent);\r
-      }\r
-    });\r
-    taylorColour.setText("Taylor");\r
-    taylorColour.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent actionEvent)\r
-      {\r
-        taylorColour_actionPerformed(actionEvent);\r
-      }\r
-    });\r
-    hydroColour.setText("Hydro");\r
-    hydroColour.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent actionEvent)\r
-      {\r
-        hydroColour_actionPerformed(actionEvent);\r
-      }\r
-    });\r
-    strandColour.setText("Strand");\r
-    strandColour.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent actionEvent)\r
-      {\r
-        strandColour_actionPerformed(actionEvent);\r
-      }\r
-    });\r
-    helixColour.setText("Helix Propensity");\r
-    helixColour.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent actionEvent)\r
-      {\r
-        helixColour_actionPerformed(actionEvent);\r
-      }\r
-    });\r
-    turnColour.setText("Turn Propensity");\r
-    turnColour.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent actionEvent)\r
-      {\r
-        turnColour_actionPerformed(actionEvent);\r
-      }\r
-    });\r
-    buriedColour.setText("Buried Index");\r
-    buriedColour.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent actionEvent)\r
-      {\r
-        buriedColour_actionPerformed(actionEvent);\r
-      }\r
-    });\r
-    userColour.setText("User Defined ...");\r
-    userColour.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent actionEvent)\r
-      {\r
-        userColour_actionPerformed(actionEvent);\r
-      }\r
-    });\r
-    helpMenu.setText("Help");\r
-    jmolHelp.setText("Jmol Help");\r
-    jmolHelp.addActionListener(new ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent actionEvent)\r
-      {\r
-        jmolHelp_actionPerformed(actionEvent);\r
-      }\r
-    });\r
-    menuBar.add(fileMenu);\r
-    menuBar.add(viewMenu);\r
-    menuBar.add(colourMenu);\r
-    menuBar.add(helpMenu);\r
-    fileMenu.add(savemenu);\r
-    fileMenu.add(viewMapping);\r
-    savemenu.add(pdbFile);\r
-    savemenu.add(png);\r
-    savemenu.add(eps);\r
-    viewMenu.add(chainMenu);\r
-    colourMenu.add(seqColour);\r
-    colourMenu.add(chainColour);\r
-    colourMenu.add(chargeColour);\r
-    colourMenu.add(zappoColour);\r
-    colourMenu.add(taylorColour);\r
-    colourMenu.add(hydroColour);\r
-    colourMenu.add(helixColour);\r
-    colourMenu.add(strandColour);\r
-    colourMenu.add(turnColour);\r
-    colourMenu.add(buriedColour);\r
-    colourMenu.add(userColour);\r
-    colourMenu.add(backGround);\r
-    helpMenu.add(jmolHelp);\r
-  }\r
-\r
-  JMenuBar menuBar = new JMenuBar();\r
-  JMenu fileMenu = new JMenu();\r
-  JMenu savemenu = new JMenu();\r
-  JMenuItem pdbFile = new JMenuItem();\r
-  JMenuItem png = new JMenuItem();\r
-  JMenuItem eps = new JMenuItem();\r
-  JMenuItem viewMapping = new JMenuItem();\r
-  JMenu viewMenu = new JMenu();\r
-  protected JMenu chainMenu = new JMenu();\r
-  JMenu jMenu1 = new JMenu();\r
-  JMenu colourMenu = new JMenu();\r
-  JMenuItem backGround = new JMenuItem();\r
-  protected JCheckBoxMenuItem seqColour = new JCheckBoxMenuItem();\r
-  JMenuItem chainColour = new JMenuItem();\r
-  JMenuItem chargeColour = new JMenuItem();\r
-  JMenuItem zappoColour = new JMenuItem();\r
-  JMenuItem taylorColour = new JMenuItem();\r
-  JMenuItem hydroColour = new JMenuItem();\r
-  JMenuItem strandColour = new JMenuItem();\r
-  JMenuItem helixColour = new JMenuItem();\r
-  JMenuItem turnColour = new JMenuItem();\r
-  JMenuItem buriedColour = new JMenuItem();\r
-  JMenuItem userColour = new JMenuItem();\r
-  JMenu helpMenu = new JMenu();\r
-  JMenuItem jmolHelp = new JMenuItem();\r
-  public void pdbFile_actionPerformed(ActionEvent actionEvent)\r
-  {\r
-\r
-  }\r
-\r
-  public void png_actionPerformed(ActionEvent actionEvent)\r
-  {\r
-\r
-  }\r
-\r
-  public void eps_actionPerformed(ActionEvent actionEvent)\r
-  {\r
-\r
-  }\r
-\r
-  public void viewMapping_actionPerformed(ActionEvent actionEvent)\r
-  {\r
-\r
-  }\r
-\r
-  public void seqColour_actionPerformed(ActionEvent actionEvent)\r
-  {\r
-\r
-  }\r
-\r
-  public void chainColour_actionPerformed(ActionEvent actionEvent)\r
-  {\r
-\r
-  }\r
-\r
-  public void chargeColour_actionPerformed(ActionEvent actionEvent)\r
-  {\r
-\r
-  }\r
-\r
-  public void zappoColour_actionPerformed(ActionEvent actionEvent)\r
-  {\r
-\r
-  }\r
-\r
-  public void taylorColour_actionPerformed(ActionEvent actionEvent)\r
-  {\r
-\r
-  }\r
-\r
-  public void hydroColour_actionPerformed(ActionEvent actionEvent)\r
-  {\r
-\r
-  }\r
-\r
-  public void helixColour_actionPerformed(ActionEvent actionEvent)\r
-  {\r
-\r
-  }\r
-\r
-  public void strandColour_actionPerformed(ActionEvent actionEvent)\r
-  {\r
-\r
-  }\r
-\r
-  public void turnColour_actionPerformed(ActionEvent actionEvent)\r
-  {\r
-\r
-  }\r
-\r
-  public void buriedColour_actionPerformed(ActionEvent actionEvent)\r
-  {\r
-\r
-  }\r
-\r
-  public void userColour_actionPerformed(ActionEvent actionEvent)\r
-  {\r
-\r
-  }\r
-\r
-  public void backGround_actionPerformed(ActionEvent actionEvent)\r
-  {\r
-\r
-  }\r
-\r
-  public void jmolHelp_actionPerformed(ActionEvent actionEvent)\r
-  {\r
-\r
-  }\r
-}\r
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ 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.
+ *  
+ * 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 Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.jbgui;
+
+import java.awt.BorderLayout;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+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;
+
+import jalview.api.structures.JalviewStructureDisplayI;
+import jalview.gui.ColourMenuHelper.ColourChangeListener;
+import jalview.util.ImageMaker.TYPE;
+import jalview.util.MessageManager;
+
+@SuppressWarnings("serial")
+public abstract class GStructureViewer extends JInternalFrame
+        implements JalviewStructureDisplayI, ColourChangeListener
+{
+  // private AAStructureBindingModel bindingModel;
+
+  protected JMenu savemenu;
+
+  protected JMenu viewMenu;
+
+  protected JMenu colourMenu;
+
+  protected JMenu chainMenu;
+
+  protected JMenu viewerActionMenu;
+
+  protected JMenuItem alignStructs;
+
+  protected JMenuItem fitToWindow;
+
+  protected JRadioButtonMenuItem seqColour;
+
+  protected JRadioButtonMenuItem chainColour;
+
+  protected JRadioButtonMenuItem chargeColour;
+
+  protected JRadioButtonMenuItem viewerColour;
+
+  protected JMenuItem helpItem;
+
+  protected JLabel statusBar;
+
+  protected JPanel statusPanel;
+
+  /**
+   * Constructor
+   */
+  public GStructureViewer()
+  {
+    try
+    {
+      jbInit();
+    } catch (Exception ex)
+    {
+      ex.printStackTrace();
+    }
+  }
+
+  private void jbInit() throws Exception
+  {
+
+    setName("jalview-structureviewer");
+
+    JMenuBar menuBar = new JMenuBar();
+    this.setJMenuBar(menuBar);
+
+    JMenu fileMenu = new JMenu();
+    fileMenu.setText(MessageManager.getString("action.file"));
+
+    savemenu = new JMenu();
+    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()
+    {
+      @Override
+      public void actionPerformed(ActionEvent actionEvent)
+      {
+        pdbFile_actionPerformed();
+      }
+    });
+
+    JMenuItem png = new JMenuItem();
+    png.setText("PNG");
+    png.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent actionEvent)
+      {
+        makePDBImage(TYPE.PNG);
+      }
+    });
+
+    JMenuItem eps = new JMenuItem();
+    eps.setText("EPS");
+    eps.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent actionEvent)
+      {
+        makePDBImage(TYPE.EPS);
+      }
+    });
+
+    JMenuItem viewMapping = new JMenuItem();
+    viewMapping.setText(MessageManager.getString("label.view_mapping"));
+    viewMapping.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent actionEvent)
+      {
+        viewMapping_actionPerformed();
+      }
+    });
+
+    viewMenu = new JMenu();
+    viewMenu.setText(MessageManager.getString("action.view"));
+
+    chainMenu = new JMenu();
+    chainMenu.setText(MessageManager.getString("action.show_chain"));
+
+    fitToWindow = new JMenuItem();
+    fitToWindow.setText(MessageManager.getString("label.fit_to_window"));
+    fitToWindow.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent actionEvent)
+      {
+        fitToWindow_actionPerformed();
+      }
+    });
+
+    JMenu helpMenu = new JMenu();
+    helpMenu.setText(MessageManager.getString("action.help"));
+    helpItem = new JMenuItem();
+    helpItem.setText(MessageManager.getString("label.jmol_help"));
+    helpItem.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent actionEvent)
+      {
+        showHelp_actionPerformed();
+      }
+    });
+    alignStructs = new JMenuItem();
+    alignStructs.setText(
+            MessageManager.getString("label.superpose_structures"));
+    alignStructs.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent actionEvent)
+      {
+        alignStructsWithAllAlignPanels();
+      }
+    });
+
+    viewerActionMenu = new JMenu(); // text set in sub-classes
+    viewerActionMenu.setVisible(false);
+    viewerActionMenu.add(alignStructs);
+    colourMenu = new JMenu();
+    colourMenu.setText(MessageManager.getString("label.colours"));
+    fileMenu.add(savemenu);
+    fileMenu.add(viewMapping);
+    savemenu.add(pdbFile);
+    savemenu.add(png);
+    savemenu.add(eps);
+    viewMenu.add(chainMenu);
+    helpMenu.add(helpItem);
+
+    menuBar.add(fileMenu);
+    menuBar.add(viewMenu);
+    menuBar.add(colourMenu);
+    menuBar.add(viewerActionMenu);
+    menuBar.add(helpMenu);
+
+    statusPanel = new JPanel();
+    statusPanel.setLayout(new GridLayout());
+    this.getContentPane().add(statusPanel, BorderLayout.SOUTH);
+    statusBar = new JLabel();
+    statusPanel.add(statusBar, null);
+  }
+
+  protected void fitToWindow_actionPerformed()
+  {
+  }
+
+  protected void highlightSelection_actionPerformed()
+  {
+  }
+
+  protected void viewerColour_actionPerformed()
+  {
+  }
+
+  protected abstract String alignStructsWithAllAlignPanels();
+
+  public void pdbFile_actionPerformed()
+  {
+
+  }
+
+  public void makePDBImage(TYPE imageType)
+  {
+
+  }
+
+  public void viewMapping_actionPerformed()
+  {
+
+  }
+
+  public void seqColour_actionPerformed()
+  {
+
+  }
+
+  public void chainColour_actionPerformed()
+  {
+
+  }
+
+  public void chargeColour_actionPerformed()
+  {
+
+  }
+
+  public void background_actionPerformed()
+  {
+
+  }
+
+  public void showHelp_actionPerformed()
+  {
+
+  }
+}