Merge commit 'ab43013b7e357b84b4abade0dba949668dfb2a0e' into develop
[jalview.git] / src / jalview / jbgui / GAlignFrame.java
index dba77dd..afd1f60 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2b1)
  * Copyright (C) 2014 The Jalview Authors
  * 
  * This file is part of Jalview.
@@ -23,6 +23,7 @@ package jalview.jbgui;
 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
 import jalview.bin.Cache;
 import jalview.gui.JvSwingUtils;
+import jalview.gui.Preferences;
 import jalview.schemes.ColourSchemeProperty;
 import jalview.util.MessageManager;
 
@@ -213,6 +214,10 @@ public class GAlignFrame extends JInternalFrame
 
   JMenuItem createPNG = new JMenuItem();
 
+  JMenuItem createBioJS = new JMenuItem();
+
+  JMenuItem createSVG = new JMenuItem();
+
   protected JMenuItem font = new JMenuItem();
 
   public JCheckBoxMenuItem seqLimits = new JCheckBoxMenuItem();
@@ -263,6 +268,8 @@ public class GAlignFrame extends JInternalFrame
 
   JMenuItem annotationColour = new JMenuItem();
 
+  JMenuItem annotationColumn = new JMenuItem();
+
   protected JMenuItem rnahelicesColour = new JMenuItem();
 
   JMenuItem associatedData = new JMenuItem();
@@ -371,9 +378,9 @@ public class GAlignFrame extends JInternalFrame
 
   protected JCheckBoxMenuItem applyAutoAnnotationSettings = new JCheckBoxMenuItem();
 
-  protected JCheckBoxMenuItem showAutoFirst = new JCheckBoxMenuItem();
+  protected JRadioButtonMenuItem showAutoFirst = new JRadioButtonMenuItem();
 
-  protected JCheckBoxMenuItem showAutoLast = new JCheckBoxMenuItem();
+  protected JRadioButtonMenuItem showAutoLast = new JRadioButtonMenuItem();
 
   private JMenuItem grpsFromSelection = new JMenuItem();
 
@@ -1139,15 +1146,20 @@ public class GAlignFrame extends JInternalFrame
         hideAllAnnotations_actionPerformed(true, false);
       }
     });
+    SequenceAnnotationOrder sortAnnotationsBy = SequenceAnnotationOrder
+            .valueOf(Cache.getDefault(Preferences.SORT_ANNOTATIONS,
+                    SequenceAnnotationOrder.NONE.name()));
     sortAnnBySequence.setText(MessageManager
             .getString("label.sort_annotations_by_sequence"));
+    sortAnnBySequence
+            .setSelected(sortAnnotationsBy == SequenceAnnotationOrder.SEQUENCE_AND_LABEL);
     sortAnnBySequence.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
       {
         boolean newState = sortAnnBySequence.getState();
-        sortAnnByLabel.setState(false);
+        sortAnnByLabel.setSelected(false);
         setAnnotationSortOrder(newState ? SequenceAnnotationOrder.SEQUENCE_AND_LABEL
                 : SequenceAnnotationOrder.NONE);
         sortAnnotations_actionPerformed();
@@ -1155,13 +1167,15 @@ public class GAlignFrame extends JInternalFrame
     });
     sortAnnByLabel.setText(MessageManager
             .getString("label.sort_annotations_by_label"));
+    sortAnnByLabel
+            .setSelected(sortAnnotationsBy == SequenceAnnotationOrder.LABEL_AND_SEQUENCE);
     sortAnnByLabel.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
       {
         boolean newState = sortAnnByLabel.getState();
-        sortAnnBySequence.setState(false);
+        sortAnnBySequence.setSelected(false);
         setAnnotationSortOrder(newState ? SequenceAnnotationOrder.LABEL_AND_SEQUENCE
                 : SequenceAnnotationOrder.NONE);
         sortAnnotations_actionPerformed();
@@ -1187,6 +1201,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 java.awt.event.ActionListener()
@@ -1414,29 +1441,30 @@ public class GAlignFrame extends JInternalFrame
       }
     });
 
+    ButtonGroup buttonGroup = new ButtonGroup();
+    buttonGroup.add(showAutoFirst);
+    buttonGroup.add(showAutoLast);
     showAutoFirst.setText(MessageManager.getString("label.show_first"));
-    showAutoFirst.setState(Cache.getDefault("SHOW_AUTOCALC_ABOVE", false));
+    showAutoFirst.setSelected(Cache.getDefault(
+            Preferences.SHOW_AUTOCALC_ABOVE,
+            false));
     showAutoFirst.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        boolean sortFirst = showAutoFirst.getState();
-        setShowAutoCalculatedAbove(sortFirst);
-        showAutoLast.setState(!sortFirst);
+        setShowAutoCalculatedAbove(showAutoFirst.isSelected());
         sortAnnotations_actionPerformed();
       }
     });
     showAutoLast.setText(MessageManager.getString("label.show_last"));
-    showAutoLast.setState(!showAutoFirst.getState());
+    showAutoLast.setSelected(!showAutoFirst.isSelected());
     showAutoLast.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
       {
-        boolean sortLast = showAutoLast.getState();
-        setShowAutoCalculatedAbove(!sortLast);
-        showAutoFirst.setState(!sortLast);
+        setShowAutoCalculatedAbove(!showAutoLast.isSelected());
         sortAnnotations_actionPerformed();
       }
     });
@@ -1582,6 +1610,7 @@ public class GAlignFrame extends JInternalFrame
     createPNG.setActionCommand(MessageManager
             .getString("label.save_png_image"));
     createPNG.setText("PNG");
+
     font.setText(MessageManager.getString("action.font"));
     font.addActionListener(new java.awt.event.ActionListener()
     {
@@ -1591,7 +1620,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));
@@ -1612,6 +1640,17 @@ public class GAlignFrame extends JInternalFrame
         createEPS(null);
       }
     });
+
+    createSVG.setText("SVG");
+    createSVG.addActionListener(new java.awt.event.ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        createSVG(null);
+      }
+    });
+
     LoadtreeMenuItem.setActionCommand(MessageManager
             .getString("label.load_tree_for_sequence_set"));
     LoadtreeMenuItem.setText(MessageManager
@@ -1730,7 +1769,7 @@ public class GAlignFrame extends JInternalFrame
     sortByAnnotScore.setText(MessageManager
             .getString("label.sort_by_score"));
     sort.add(sortByAnnotScore);
-    sortByAnnotScore.addMenuListener(new javax.swing.event.MenuListener()
+    sort.addMenuListener(new javax.swing.event.MenuListener()
     {
 
       @Override
@@ -1837,6 +1876,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()
@@ -2330,6 +2380,8 @@ 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);
     addSequenceMenu.add(addFromURL);
@@ -2369,6 +2421,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
@@ -2587,6 +2640,11 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
+  protected void bioJSMenuItem_actionPerformed(ActionEvent e)
+  {
+
+  }
+
   protected void closeMenuItem_actionPerformed(boolean b)
   {
   }
@@ -2840,6 +2898,10 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
+  public void createSVG(java.io.File f)
+  {
+
+  }
   protected void LoadtreeMenuItem_actionPerformed(ActionEvent e)
   {
 
@@ -2938,6 +3000,11 @@ public class GAlignFrame extends JInternalFrame
 
   }
 
+  public void annotationColumn_actionPerformed(ActionEvent e)
+  {
+
+  }
+
   public void rnahelicesColour_actionPerformed(ActionEvent e)
   {