Jalview 2.6 source licence
[jalview.git] / src / jalview / jbgui / GAlignFrame.java
index a12a74f..af7766a 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.6)
+ * Copyright (C) 2010 J Procter, AM Waterhouse, 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.
  * 
- * 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
+ * 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/>.
  */
 package jalview.jbgui;
 
@@ -68,6 +67,8 @@ public class GAlignFrame extends JInternalFrame
 
   protected JMenuItem sortIDMenuItem = new JMenuItem();
 
+  protected JMenuItem sortLengthMenuItem = new JMenuItem();
+
   protected JMenuItem sortGroupMenuItem = new JMenuItem();
 
   protected JMenu sortByAnnotScore = new JMenu();
@@ -120,6 +121,8 @@ public class GAlignFrame extends JInternalFrame
 
   public JCheckBoxMenuItem colourTextMenuItem = new JCheckBoxMenuItem();
 
+  public JCheckBoxMenuItem showNonconservedMenuItem = new JCheckBoxMenuItem();
+
   JMenuItem htmlMenuItem = new JMenuItem();
 
   JMenuItem overviewMenuItem = new JMenuItem();
@@ -144,6 +147,8 @@ public class GAlignFrame extends JInternalFrame
 
   public JCheckBoxMenuItem showSeqFeatures = new JCheckBoxMenuItem();
 
+  public JCheckBoxMenuItem showSeqFeaturesHeight = new JCheckBoxMenuItem();
+
   protected JRadioButtonMenuItem nucleotideColour = new JRadioButtonMenuItem();
 
   JMenuItem deleteGroups = new JMenuItem();
@@ -186,12 +191,16 @@ public class GAlignFrame extends JInternalFrame
 
   protected JMenu sort = new JMenu();
 
-  JMenu calculate = new JMenu();
+  protected JMenu calculateTree = new JMenu();
 
   JMenu jMenu2 = new JMenu();
 
   protected JCheckBoxMenuItem padGapsMenuitem = new JCheckBoxMenuItem();
 
+  protected JCheckBoxMenuItem showNpFeatsMenuitem = new JCheckBoxMenuItem();
+
+  protected JCheckBoxMenuItem showDbRefsMenuitem = new JCheckBoxMenuItem();
+
   protected ButtonGroup colours = new ButtonGroup();
 
   JMenuItem vamsasStore = new JMenuItem();
@@ -240,6 +249,12 @@ public class GAlignFrame extends JInternalFrame
 
   JMenuItem hideSelColumns = new JMenuItem();
 
+  JMenuItem hideAllButSelection = new JMenuItem();
+
+  JMenuItem hideAllSelection = new JMenuItem();
+
+  JMenuItem showAllhidden = new JMenuItem();
+
   protected JCheckBoxMenuItem hiddenMarkers = new JCheckBoxMenuItem();
 
   JMenuItem invertColSel = new JMenuItem();
@@ -262,6 +277,8 @@ public class GAlignFrame extends JInternalFrame
 
   protected JCheckBoxMenuItem centreColumnLabelsMenuItem = new JCheckBoxMenuItem();
 
+  protected JCheckBoxMenuItem followHighlightMenuItem = new JCheckBoxMenuItem();
+
   protected JMenuItem gatherViews = new JMenuItem();
 
   protected JMenuItem expandViews = new JMenuItem();
@@ -270,6 +287,26 @@ public class GAlignFrame extends JInternalFrame
 
   JMenuItem alignmentProperties = new JMenuItem();
 
+  JMenu tooltipSettingsMenu = new JMenu();
+
+  private JMenuItem justifyLeftMenuItem = new JMenuItem();
+
+  private JMenuItem justifyRightMenuItem = new JMenuItem();
+
+  JMenu autoAnnMenu = new JMenu();
+
+  protected JCheckBoxMenuItem showGroupConsensus = new JCheckBoxMenuItem();
+
+  protected JCheckBoxMenuItem showGroupConservation = new JCheckBoxMenuItem();
+
+  protected JCheckBoxMenuItem showConsensusHistogram = new JCheckBoxMenuItem();
+
+  protected JCheckBoxMenuItem showSequenceLogo = new JCheckBoxMenuItem();
+
+  protected JCheckBoxMenuItem applyAutoAnnotationSettings = new JCheckBoxMenuItem();
+
+  private JMenuItem grpsFromSelection = new JMenuItem();
+
   public GAlignFrame()
   {
     try
@@ -393,9 +430,6 @@ public class GAlignFrame extends JInternalFrame
 
       switch (index)
       {
-      case ColourSchemeProperty.NONE:
-        noColourmenuItem.setSelected(true);
-        break;
       case ColourSchemeProperty.CLUSTAL:
         clustalColour.setSelected(true);
 
@@ -454,6 +488,11 @@ public class GAlignFrame extends JInternalFrame
         userDefinedColour.setSelected(true);
 
         break;
+      case ColourSchemeProperty.NONE:
+      default:
+        noColourmenuItem.setSelected(true);
+        break;
+        
       }
     }
 
@@ -525,6 +564,15 @@ public class GAlignFrame extends JInternalFrame
                 invertSequenceMenuItem_actionPerformed(e);
               }
             });
+    grpsFromSelection.setText("Make Groups for selection");
+    grpsFromSelection.addActionListener(new java.awt.event.ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        makeGrpsFromSelection_actionPerformed(e);
+      }
+    });
+
     remove2LeftMenuItem.setText("Remove Left");
     remove2LeftMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
             java.awt.event.KeyEvent.VK_L, Toolkit.getDefaultToolkit()
@@ -574,6 +622,24 @@ public class GAlignFrame extends JInternalFrame
                 removeAllGapsMenuItem_actionPerformed(e);
               }
             });
+    justifyLeftMenuItem.setText("Left Justify Alignment");
+    justifyLeftMenuItem
+            .addActionListener(new java.awt.event.ActionListener()
+            {
+              public void actionPerformed(ActionEvent e)
+              {
+                justifyLeftMenuItem_actionPerformed(e);
+              }
+            });
+    justifyRightMenuItem.setText("Right Justify Alignment");
+    justifyRightMenuItem
+            .addActionListener(new java.awt.event.ActionListener()
+            {
+              public void actionPerformed(ActionEvent e)
+              {
+                justifyRightMenuItem_actionPerformed(e);
+              }
+            });
     viewBoxesMenuItem.setText("Boxes");
     viewBoxesMenuItem.setState(true);
     viewBoxesMenuItem.addActionListener(new java.awt.event.ActionListener()
@@ -592,6 +658,16 @@ public class GAlignFrame extends JInternalFrame
         viewTextMenuItem_actionPerformed(e);
       }
     });
+    showNonconservedMenuItem.setText("Show nonconserved");
+    showNonconservedMenuItem.setState(false);
+    showNonconservedMenuItem
+            .addActionListener(new java.awt.event.ActionListener()
+            {
+              public void actionPerformed(ActionEvent e)
+              {
+                showUnconservedMenuItem_actionPerformed(e);
+              }
+            });
     sortPairwiseMenuItem.setText("by Pairwise Identity");
     sortPairwiseMenuItem
             .addActionListener(new java.awt.event.ActionListener()
@@ -609,6 +685,15 @@ public class GAlignFrame extends JInternalFrame
         sortIDMenuItem_actionPerformed(e);
       }
     });
+    sortLengthMenuItem.setText("By Length");
+    sortLengthMenuItem
+            .addActionListener(new java.awt.event.ActionListener()
+            {
+              public void actionPerformed(ActionEvent e)
+              {
+                sortLengthMenuItem_actionPerformed(e);
+              }
+            });
     sortGroupMenuItem.setText("by Group");
     sortGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
     {
@@ -914,6 +999,86 @@ public class GAlignFrame extends JInternalFrame
         showSeqFeatures_actionPerformed(actionEvent);
       }
     });
+    /*
+     * showSeqFeaturesHeight.setText("Vary Sequence Feature Height");
+     * showSeqFeaturesHeight.addActionListener(new ActionListener() { public
+     * void actionPerformed(ActionEvent actionEvent) {
+     * showSeqFeaturesHeight_actionPerformed(actionEvent); } });
+     */
+    showDbRefsMenuitem.setText("Show Database Refs");
+    showDbRefsMenuitem.addActionListener(new ActionListener()
+    {
+
+      public void actionPerformed(ActionEvent e)
+      {
+        showDbRefs_actionPerformed(e);
+      }
+
+    });
+    showNpFeatsMenuitem.setText("Show Non-Positional Features");
+    showNpFeatsMenuitem.addActionListener(new ActionListener()
+    {
+
+      public void actionPerformed(ActionEvent e)
+      {
+        showNpFeats_actionPerformed(e);
+      }
+
+    });
+    showGroupConservation.setText("Group Conservation");
+    showGroupConservation.addActionListener(new ActionListener()
+    {
+
+      public void actionPerformed(ActionEvent e)
+      {
+        showGroupConservation_actionPerformed(e);
+      }
+
+    });
+
+    showGroupConsensus.setText("Group Consensus");
+    showGroupConsensus.addActionListener(new ActionListener()
+    {
+
+      public void actionPerformed(ActionEvent e)
+      {
+        showGroupConsensus_actionPerformed(e);
+      }
+
+    });
+    showConsensusHistogram.setText("Show Consensus Histogram");
+    showConsensusHistogram.addActionListener(new ActionListener()
+    {
+
+      public void actionPerformed(ActionEvent e)
+      {
+        showConsensusHistogram_actionPerformed(e);
+      }
+
+    });
+    showSequenceLogo.setText("Show Consensus Logo");
+    showSequenceLogo.addActionListener(new ActionListener()
+    {
+
+      public void actionPerformed(ActionEvent e)
+      {
+        showSequenceLogo_actionPerformed(e);
+      }
+
+    });
+    applyAutoAnnotationSettings.setText("Apply to all groups");
+    applyAutoAnnotationSettings.setState(false);
+    applyAutoAnnotationSettings.setVisible(true);
+    applyAutoAnnotationSettings.addActionListener(new ActionListener()
+    {
+
+      public void actionPerformed(ActionEvent e)
+      {
+        applyAutoAnnotationSettings_actionPerformed(e);
+      }
+
+    });
+
     nucleotideColour.setText("Nucleotide");
     nucleotideColour.addActionListener(new java.awt.event.ActionListener()
     {
@@ -1082,6 +1247,18 @@ public class GAlignFrame extends JInternalFrame
                 centreColumnLabels_actionPerformed(e);
               }
             });
+    followHighlightMenuItem.setVisible(true);
+    followHighlightMenuItem.setState(true);
+    followHighlightMenuItem.setText("Automatic Scrolling");
+    followHighlightMenuItem.addActionListener(new ActionListener()
+    {
+
+      public void actionPerformed(ActionEvent e)
+      {
+        followHighlight_actionPerformed();
+      }
+
+    });
 
     modifyPID.setText("Modify Identity Threshold...");
     modifyPID.addActionListener(new java.awt.event.ActionListener()
@@ -1137,7 +1314,7 @@ public class GAlignFrame extends JInternalFrame
     });
     sortByAnnotScore.setVisible(false);
 
-    calculate.setText("Calculate Tree");
+    calculateTree.setText("Calculate Tree");
 
     jMenu2.setText("Export Image");
     padGapsMenuitem.setText("Pad Gaps");
@@ -1176,7 +1353,7 @@ public class GAlignFrame extends JInternalFrame
       }
     });
     extractScores.setVisible(true); // JBPNote: TODO: make gui for regex based
-                                    // score extraction
+    // score extraction
     showProducts.setText("Get Cross References");
     /*
      * showProducts.addActionListener(new ActionListener() {
@@ -1271,6 +1448,7 @@ public class GAlignFrame extends JInternalFrame
     statusPanel.setLayout(gridLayout1);
     jMenu3.setText("Show");
     showAllSeqs.setText("All Sequences");
+    showAllSeqs.setToolTipText("Shift+H toggles sequence visiblity.");
     showAllSeqs.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -1279,6 +1457,7 @@ public class GAlignFrame extends JInternalFrame
       }
     });
     showAllColumns.setText("All Columns");
+    showAllColumns.setToolTipText("Ctrl+H toggles column visiblity.");
     showAllColumns.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -1288,6 +1467,7 @@ public class GAlignFrame extends JInternalFrame
     });
     hideMenu.setText("Hide");
     hideSelSequences.setText("Selected Sequences");
+    hideSelSequences.setToolTipText("Shift+H toggles sequence visiblity.");
     hideSelSequences.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -1296,6 +1476,7 @@ public class GAlignFrame extends JInternalFrame
       }
     });
     hideSelColumns.setText("Selected Columns");
+    hideSelColumns.setToolTipText("Ctrl+H toggles column visiblity.");
     hideSelColumns.addActionListener(new ActionListener()
     {
       public void actionPerformed(ActionEvent e)
@@ -1303,6 +1484,34 @@ public class GAlignFrame extends JInternalFrame
         hideSelColumns_actionPerformed(e);
       }
     });
+    hideAllSelection.setText("Selected Region");
+    hideAllSelection.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        hideAllSelection_actionPerformed(e);
+      }
+    });
+    // TODO: should be hidden if no selection exists.
+    hideAllButSelection.setText("All but Selected Region (Shift+Ctrl+H)");
+    hideAllButSelection.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        hideAllButSelection_actionPerformed(e);
+      }
+    });
+    showAllhidden.setText("All Sequences and Columns");
+    showAllhidden
+            .setToolTipText("H toggles visibility of hidden or selected regions.");
+    showAllhidden.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        showAllhidden_actionPerformed(e);
+      }
+    });
+
     hiddenMarkers.setText("Show Hidden Markers");
     hiddenMarkers.addActionListener(new ActionListener()
     {
@@ -1435,7 +1644,8 @@ public class GAlignFrame extends JInternalFrame
         alignmentProperties();
       }
     });
-
+    tooltipSettingsMenu.setText("Sequence ID Tooltip");
+    autoAnnMenu.setText("Autocalculated Annotation");
     alignFrameMenuBar.add(fileMenu);
     alignFrameMenuBar.add(editMenu);
     alignFrameMenuBar.add(selectMenu);
@@ -1475,6 +1685,11 @@ public class GAlignFrame extends JInternalFrame
     editMenu.add(removeAllGapsMenuItem);
     editMenu.add(removeRedundancyMenuItem);
     editMenu.addSeparator();
+    // dont add these yet in the CVS build - they cannot be undone!
+    // Excluded from Jalview 2.5 release - undo needs to be implemented.
+    // editMenu.add(justifyLeftMenuItem);
+    // editMenu.add(justifyRightMenuItem);
+    // editMenu.addSeparator();
     editMenu.add(padGapsMenuitem);
     viewMenu.add(newView);
     viewMenu.add(expandViews);
@@ -1483,10 +1698,23 @@ public class GAlignFrame extends JInternalFrame
     viewMenu.add(jMenu3);
     viewMenu.add(hideMenu);
     viewMenu.addSeparator();
+    viewMenu.add(followHighlightMenuItem);
     viewMenu.add(annotationPanelMenuItem);
+    autoAnnMenu.add(applyAutoAnnotationSettings);
+    autoAnnMenu.add(showConsensusHistogram);
+    autoAnnMenu.add(showSequenceLogo);
+    autoAnnMenu.addSeparator();
+    autoAnnMenu.add(showGroupConservation);
+    autoAnnMenu.add(showGroupConsensus);
+    viewMenu.add(autoAnnMenu);
     viewMenu.addSeparator();
     viewMenu.add(showSeqFeatures);
+    // viewMenu.add(showSeqFeaturesHeight);
+
     viewMenu.add(featureSettings);
+    tooltipSettingsMenu.add(showDbRefsMenuitem);
+    tooltipSettingsMenu.add(showNpFeatsMenuitem);
+    viewMenu.add(tooltipSettingsMenu);
     viewMenu.addSeparator();
     viewMenu.add(alignmentProperties);
     viewMenu.addSeparator();
@@ -1514,7 +1742,7 @@ public class GAlignFrame extends JInternalFrame
     colourMenu.add(modifyPID);
     colourMenu.add(annotationColour);
     calculateMenu.add(sort);
-    calculateMenu.add(calculate);
+    calculateMenu.add(calculateTree);
     calculateMenu.addSeparator();
     calculateMenu.add(pairwiseAlignmentMenuItem);
     calculateMenu.add(PCAMenuItem);
@@ -1529,13 +1757,14 @@ public class GAlignFrame extends JInternalFrame
     pasteMenu.add(pasteNew);
     pasteMenu.add(pasteThis);
     sort.add(sortIDMenuItem);
+    sort.add(sortLengthMenuItem);
     sort.add(sortGroupMenuItem);
     sort.add(sortPairwiseMenuItem);
     sort.add(sortByTreeMenu);
-    calculate.add(averageDistanceTreeMenuItem);
-    calculate.add(neighbourTreeMenuItem);
-    calculate.add(avDistanceTreeBlosumMenuItem);
-    calculate.add(njTreeBlosumMenuItem);
+    calculateTree.add(averageDistanceTreeMenuItem);
+    calculateTree.add(neighbourTreeMenuItem);
+    calculateTree.add(avDistanceTreeBlosumMenuItem);
+    calculateTree.add(njTreeBlosumMenuItem);
     jMenu2.add(htmlMenuItem);
     jMenu2.add(epsFile);
     jMenu2.add(createPNG);
@@ -1547,8 +1776,12 @@ public class GAlignFrame extends JInternalFrame
     this.getContentPane().add(tabbedPane, java.awt.BorderLayout.CENTER);
     jMenu3.add(showAllColumns);
     jMenu3.add(showAllSeqs);
+    jMenu3.add(showAllhidden);
     hideMenu.add(hideSelColumns);
     hideMenu.add(hideSelSequences);
+    hideMenu.add(hideAllSelection);
+    hideMenu.add(hideAllButSelection);
+
     formatMenu.add(font);
     formatMenu.addSeparator();
     formatMenu.add(wrapMenuItem);
@@ -1563,6 +1796,7 @@ public class GAlignFrame extends JInternalFrame
     formatMenu.add(colourTextMenuItem);
     formatMenu.add(renderGapsMenuItem);
     formatMenu.add(centreColumnLabelsMenuItem);
+    formatMenu.add(showNonconservedMenuItem);
     selectMenu.add(findMenuItem);
     selectMenu.addSeparator();
     selectMenu.add(selectAllSequenceMenuItem);
@@ -1570,6 +1804,104 @@ public class GAlignFrame extends JInternalFrame
     selectMenu.add(invertSequenceMenuItem);
     selectMenu.add(invertColSel);
     selectMenu.add(deleteGroups);
+    selectMenu.add(grpsFromSelection);
+  }
+
+  protected void showAllhidden_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  protected void hideAllButSelection_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  protected void hideAllSelection_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  protected void applyAutoAnnotationSettings_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  protected void showConsensusHistogram_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  protected void showSequenceLogo_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  protected void makeGrpsFromSelection_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  protected void showGroupConsensus_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  protected void showGroupConservation_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  protected void showUnconservedMenuItem_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  protected void showSeqFeaturesHeight_actionPerformed(
+          ActionEvent actionEvent)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  protected void justifyRightMenuItem_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  protected void justifyLeftMenuItem_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  protected void followHighlight_actionPerformed()
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  protected void showNpFeats_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+
+  }
+
+  protected void showDbRefs_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+
   }
 
   protected void centreColumnLabels_actionPerformed(ActionEvent e)
@@ -1693,6 +2025,10 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
+  protected void sortLengthMenuItem_actionPerformed(ActionEvent e)
+  {
+  }
+
   protected void sortGroupMenuItem_actionPerformed(ActionEvent e)
   {
   }