JAL-1452 distinct colour preferences for nucleotide and protein
[jalview.git] / src / jalview / jbgui / GAlignFrame.java
index 6f963a5..d9c87cb 100755 (executable)
@@ -21,6 +21,7 @@
 package jalview.jbgui;
 
 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
+import jalview.api.SplitContainerI;
 import jalview.bin.Cache;
 import jalview.gui.JvSwingUtils;
 import jalview.gui.Preferences;
@@ -218,6 +219,8 @@ public class GAlignFrame extends JInternalFrame
 
   JMenuItem createPNG = new JMenuItem();
 
+  JMenuItem createBioJS = new JMenuItem();
+
   JMenuItem createSVG = new JMenuItem();
 
   protected JMenuItem font = new JMenuItem();
@@ -258,8 +261,6 @@ public class GAlignFrame extends JInternalFrame
 
   protected JMenuItem showTranslation = new JMenuItem();
 
-  protected JMenu cdna = new JMenu();
-
   protected JMenuItem extractScores = new JMenuItem();
 
   protected JMenuItem expandAlignment = new JMenuItem();
@@ -272,6 +273,8 @@ public class GAlignFrame extends JInternalFrame
 
   JMenuItem annotationColour = new JMenuItem();
 
+  JMenuItem annotationColumn = new JMenuItem();
+
   protected JMenuItem rnahelicesColour = new JMenuItem();
 
   JMenuItem associatedData = new JMenuItem();
@@ -298,7 +301,7 @@ public class GAlignFrame extends JInternalFrame
 
   GridLayout gridLayout1 = new GridLayout();
 
-  JMenu jMenu3 = new JMenu();
+  JMenu showMenu = new JMenu();
 
   JMenuItem showAllSeqs = new JMenuItem();
 
@@ -324,6 +327,8 @@ public class GAlignFrame extends JInternalFrame
 
   protected JMenuItem hideAllAlAnnotations = new JMenuItem();
 
+  protected JCheckBoxMenuItem showComplementMenuItem = new JCheckBoxMenuItem();
+
   protected JCheckBoxMenuItem sortAnnBySequence = new JCheckBoxMenuItem();
 
   protected JCheckBoxMenuItem sortAnnByLabel = new JCheckBoxMenuItem();
@@ -342,7 +347,7 @@ public class GAlignFrame extends JInternalFrame
 
   JMenuItem textColour = new JMenuItem();
 
-  JMenu formatMenu = new JMenu();
+  protected JMenu formatMenu = new JMenu();
 
   JMenu selectMenu = new JMenu();
 
@@ -390,7 +395,9 @@ public class GAlignFrame extends JInternalFrame
 
   private boolean showAutoCalculatedAbove = false;
 
-  private Map<KeyStroke, ActionListener> accelerators = new HashMap<KeyStroke, ActionListener>();
+  private Map<KeyStroke, JMenuItem> accelerators = new HashMap<KeyStroke, JMenuItem>();
+
+  private SplitContainerI splitFrame;
 
   public GAlignFrame()
   {
@@ -509,9 +516,8 @@ public class GAlignFrame extends JInternalFrame
     // colours.add(covariationColour);
     colours.add(tcoffeeColour);
     colours.add(RNAInteractionColour);
-    setColourSelected(jalview.bin.Cache
-            .getDefault("DEFAULT_COLOUR", "None"));
-
+    setColourSelected(jalview.bin.Cache.getDefault(
+            Preferences.DEFAULT_COLOUR, "None"));
   }
 
   public void setColourSelected(String defaultColour)
@@ -1196,6 +1202,19 @@ public class GAlignFrame extends JInternalFrame
         htmlMenuItem_actionPerformed(e);
       }
     });
+
+    // TODO uncomment when supported by MassageManager
+    // createBioJS.setText(MessageManager.getString("label.biojs_html_export"));
+    createBioJS.setText("BioJS");
+    createBioJS.addActionListener(new java.awt.event.ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        bioJSMenuItem_actionPerformed(e);
+      }
+    });
+
     overviewMenuItem.setText(MessageManager
             .getString("label.overview_window"));
     overviewMenuItem.addActionListener(new ActionListener()
@@ -1614,7 +1633,6 @@ public class GAlignFrame extends JInternalFrame
         font_actionPerformed(e);
       }
     });
-
     seqLimits.setText(MessageManager
             .getString("label.show_sequence_limits"));
     seqLimits.setState(jalview.bin.Cache.getDefault("SHOW_JVSUFFIX", true));
@@ -1819,54 +1837,6 @@ public class GAlignFrame extends JInternalFrame
       }
     });
 
-    /*
-     * cDNA menu options
-     */
-    cdna.setText(MessageManager.getString("label.cdna"));
-    // link to available cDNA
-    JMenuItem linkCdna = new JMenuItem(
-            MessageManager.getString("label.link_cdna"));
-    linkCdna.setToolTipText(JvSwingUtils.wrapTooltip(true,
-            MessageManager.getString("label.link_cdna_tip")));
-    linkCdna.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        linkCdna_actionPerformed();
-      }
-    });
-    cdna.add(linkCdna);
-    // align linked cDNA
-    JMenuItem alignCdna = new JMenuItem(
-            MessageManager.getString("label.align_cdna"));
-    alignCdna.setToolTipText(JvSwingUtils.wrapTooltip(true,
-            MessageManager.getString("label.align_cdna_tip")));
-    alignCdna.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        alignCdna_actionPerformed();
-      }
-    });
-    cdna.add(alignCdna);
-
-    // view alignment as cDNA (when known)
-    JMenuItem viewAsCdna = new JMenuItem(
-            MessageManager.getString("label.view_as_cdna"));
-    viewAsCdna.setToolTipText(JvSwingUtils.wrapTooltip(true,
-            MessageManager.getString("label.view_as_cdna_tip")));
-    viewAsCdna.addActionListener(new ActionListener()
-    {
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        viewAsCdna_actionPerformed();
-      }
-    });
-    cdna.add(viewAsCdna);
-
     extractScores.setText(MessageManager.getString("label.extract_scores")
             + "...");
     extractScores.addActionListener(new ActionListener()
@@ -1914,6 +1884,17 @@ public class GAlignFrame extends JInternalFrame
       }
     });
 
+    annotationColumn.setText(MessageManager
+            .getString("action.select_by_annotation"));
+    annotationColumn.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        annotationColumn_actionPerformed(e);
+      }
+    });
+
     rnahelicesColour.setText(MessageManager
             .getString("action.by_rna_helixes"));
     rnahelicesColour.addActionListener(new ActionListener()
@@ -2030,7 +2011,7 @@ public class GAlignFrame extends JInternalFrame
       }
     });
     statusPanel.setLayout(gridLayout1);
-    jMenu3.setText(MessageManager.getString("action.show"));
+    showMenu.setText(MessageManager.getString("action.show"));
     showAllSeqs.setText(MessageManager.getString("label.all_sequences"));
     showAllSeqs.setToolTipText(MessageManager
             .getString("label.toggle_sequence_visibility"));
@@ -2137,6 +2118,16 @@ public class GAlignFrame extends JInternalFrame
     };
     addMenuActionAndAccelerator(keyStroke, invertColSel, al);
 
+    showComplementMenuItem.setVisible(false);
+    showComplementMenuItem.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        showComplement_actionPerformed(showComplementMenuItem.getState());
+      }
+    });
+
     tabbedPane.addChangeListener(new javax.swing.event.ChangeListener()
     {
       @Override
@@ -2327,8 +2318,9 @@ public class GAlignFrame extends JInternalFrame
     viewMenu.add(expandViews);
     viewMenu.add(gatherViews);
     viewMenu.addSeparator();
-    viewMenu.add(jMenu3);
+    viewMenu.add(showMenu);
     viewMenu.add(hideMenu);
+    viewMenu.add(showComplementMenuItem);
     viewMenu.addSeparator();
     viewMenu.add(followHighlightMenuItem);
     annotationsMenu.add(annotationPanelMenuItem);
@@ -2398,7 +2390,6 @@ public class GAlignFrame extends JInternalFrame
     calculateMenu.add(PCAMenuItem);
     calculateMenu.addSeparator();
     calculateMenu.add(showTranslation);
-    calculateMenu.add(cdna);
     calculateMenu.add(showProducts);
     calculateMenu.add(autoCalculate);
     calculateMenu.add(sortByTree);
@@ -2417,6 +2408,7 @@ public class GAlignFrame extends JInternalFrame
     jMenu2.add(htmlMenuItem);
     jMenu2.add(epsFile);
     jMenu2.add(createPNG);
+    jMenu2.add(createBioJS);
     jMenu2.add(createSVG);
     addSequenceMenu.add(addFromFile);
     addSequenceMenu.add(addFromText);
@@ -2424,9 +2416,9 @@ public class GAlignFrame extends JInternalFrame
     this.getContentPane().add(statusPanel, java.awt.BorderLayout.SOUTH);
     statusPanel.add(statusBar, null);
     this.getContentPane().add(tabbedPane, java.awt.BorderLayout.CENTER);
-    jMenu3.add(showAllColumns);
-    jMenu3.add(showAllSeqs);
-    jMenu3.add(showAllhidden);
+    showMenu.add(showAllColumns);
+    showMenu.add(showAllSeqs);
+    showMenu.add(showAllhidden);
     hideMenu.add(hideSelColumns);
     hideMenu.add(hideSelSequences);
     hideMenu.add(hideAllSelection);
@@ -2457,6 +2449,7 @@ public class GAlignFrame extends JInternalFrame
     selectMenu.add(unGroup);
     selectMenu.add(grpsFromSelection);
     selectMenu.add(deleteGroups);
+    selectMenu.add(annotationColumn);
     calculateMenu.add(expandAlignment);
     // TODO - determine if the listenToViewSelections button is needed : see bug
     // JAL-574
@@ -2476,22 +2469,10 @@ public class GAlignFrame extends JInternalFrame
           JMenuItem menuItem, ActionListener actionListener)
   {
     menuItem.setAccelerator(keyStroke);
-    accelerators.put(keyStroke, actionListener);
+    accelerators.put(keyStroke, menuItem);
     menuItem.addActionListener(actionListener);
   }
 
-  protected void viewAsCdna_actionPerformed()
-  {
-  }
-
-  protected void alignCdna_actionPerformed()
-  {
-  }
-
-  protected void linkCdna_actionPerformed()
-  {
-  }
-
   /**
    * Action on clicking sort annotations by type.
    * 
@@ -2699,6 +2680,11 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
+  protected void bioJSMenuItem_actionPerformed(ActionEvent e)
+  {
+
+  }
+
   protected void closeMenuItem_actionPerformed(boolean b)
   {
   }
@@ -3054,6 +3040,11 @@ public class GAlignFrame extends JInternalFrame
 
   }
 
+  public void annotationColumn_actionPerformed(ActionEvent e)
+  {
+
+  }
+
   public void rnahelicesColour_actionPerformed(ActionEvent e)
   {
 
@@ -3210,8 +3201,49 @@ public class GAlignFrame extends JInternalFrame
     this.annotationSortOrder = annotationSortOrder;
   }
 
-  public Map<KeyStroke, ActionListener> getAccelerators()
+  public Map<KeyStroke, JMenuItem> getAccelerators()
   {
     return this.accelerators;
   }
+
+  /**
+   * Returns the selected index of the tabbed pane, or -1 if none selected
+   * (including the case where the tabbed pane has not been made visible).
+   * 
+   * @return
+   */
+  public int getTabIndex()
+  {
+    return tabbedPane.getSelectedIndex();
+  }
+
+  public JPanel getStatusPanel()
+  {
+    return statusPanel;
+  }
+
+  /**
+   * Sets a reference to the containing split frame. Also makes the 'toggle
+   * split view' menu item visible and checked.
+   * 
+   * @param sf
+   */
+  public void setSplitFrame(SplitContainerI sf)
+  {
+    this.splitFrame = sf;
+    if (sf != null)
+    {
+      this.showComplementMenuItem.setVisible(true);
+      this.showComplementMenuItem.setState(true);
+    }
+  }
+
+  public SplitContainerI getSplitViewContainer()
+  {
+    return this.splitFrame;
+  }
+
+  protected void showComplement_actionPerformed(boolean state)
+  {
+  }
 }