Merge branch 'develop' into features/JAL-4219_extended_fasta_rna_ss
[jalview.git] / src / jalview / jbgui / GAlignFrame.java
index c0cdfee..2a79908 100755 (executable)
@@ -23,6 +23,7 @@ package jalview.jbgui;
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.GridLayout;
+import java.awt.Menu;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.FocusAdapter;
@@ -31,6 +32,7 @@ import java.awt.event.KeyEvent;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import javax.swing.BorderFactory;
@@ -54,11 +56,13 @@ import jalview.analysis.GeneticCodeI;
 import jalview.analysis.GeneticCodes;
 import jalview.api.SplitContainerI;
 import jalview.bin.Cache;
+import jalview.bin.Console;
 import jalview.gui.JvSwingUtils;
 import jalview.gui.Preferences;
 import jalview.io.FileFormats;
-import jalview.io.exceptions.ImageOutputException;
+import jalview.log.JLoggerLog4j;
 import jalview.schemes.ResidueColourScheme;
+import jalview.util.Log4j;
 import jalview.util.MessageManager;
 import jalview.util.Platform;
 
@@ -194,12 +198,18 @@ public class GAlignFrame extends JInternalFrame
   protected JMenuItem gatherViews = new JMenuItem();
 
   protected JMenuItem expandViews = new JMenuItem();
+  
+  protected JCheckBoxMenuItem threeDStructure = new JCheckBoxMenuItem();
+
+  protected JCheckBoxMenuItem jPred = new JCheckBoxMenuItem();
 
   protected JCheckBoxMenuItem showGroupConsensus = new JCheckBoxMenuItem();
 
   protected JCheckBoxMenuItem showGroupConservation = new JCheckBoxMenuItem();
 
-  protected JCheckBoxMenuItem showConsensusHistogram = new JCheckBoxMenuItem();
+  protected JCheckBoxMenuItem showConsensusHistogram = new JCheckBoxMenuItem();  
+
+  protected JCheckBoxMenuItem showSSConsensusHistogram = new JCheckBoxMenuItem();
 
   protected JCheckBoxMenuItem showSequenceLogo = new JCheckBoxMenuItem();
 
@@ -221,6 +231,7 @@ public class GAlignFrame extends JInternalFrame
   {
     try
     {
+      setFrameIcon(null);
 
       // for Web-page embedding using id=align-frame-div
       setName("jalview-alignment");
@@ -246,7 +257,7 @@ public class GAlignFrame extends JInternalFrame
       }
     } catch (Exception e)
     {
-      System.err.println(e.toString());
+      jalview.bin.Console.errPrintln(e.toString());
     }
 
     if (Platform.allowMnemonics()) // was "not mac and not JS"
@@ -441,7 +452,9 @@ public class GAlignFrame extends JInternalFrame
     addMenuActionAndAccelerator(keyStroke, removeAllGapsMenuItem, al);
 
     JMenuItem justifyLeftMenuItem = new JMenuItem(
-            MessageManager.getString("action.left_justify_alignment"));
+            MessageManager.getString("action.left_justify"));
+    justifyLeftMenuItem.setToolTipText(
+            MessageManager.getString("tooltip.left_justify"));
     justifyLeftMenuItem.addActionListener(new ActionListener()
     {
       @Override
@@ -451,7 +464,10 @@ public class GAlignFrame extends JInternalFrame
       }
     });
     JMenuItem justifyRightMenuItem = new JMenuItem(
-            MessageManager.getString("action.right_justify_alignment"));
+            MessageManager.getString("action.right_justify"));
+    justifyRightMenuItem.setToolTipText(
+            MessageManager.getString("action.left_justify"));
+
     justifyRightMenuItem.addActionListener(new ActionListener()
     {
       @Override
@@ -873,6 +889,18 @@ public class GAlignFrame extends JInternalFrame
         showConsensusHistogram_actionPerformed(e);
       }
 
+    });    
+    showSSConsensusHistogram.setText(
+            MessageManager.getString("label.show_ssconsensus_histogram"));
+    showSSConsensusHistogram.addActionListener(new ActionListener()
+    {
+
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        showConsensusHistogram_actionPerformed(e);
+      }
+
     });
     showSequenceLogo
             .setText(MessageManager.getString("label.show_consensus_logo"));
@@ -1779,12 +1807,61 @@ public class GAlignFrame extends JInternalFrame
     };
     addMenuActionAndAccelerator(keyStroke, copyHighlighted, al);
     copyHighlighted.addActionListener(al);
+    
+    
+
+    ButtonGroup ssButtonGroup = new ButtonGroup();
+    final JRadioButtonMenuItem showAll = new JRadioButtonMenuItem(
+            MessageManager.getString("label.show_first"));
+    final JRadioButtonMenuItem showjPred = new JRadioButtonMenuItem(
+            MessageManager.getString("label.show_last"));
+    final JRadioButtonMenuItem show3DSS = new JRadioButtonMenuItem(
+            MessageManager.getString("label.show_last"));
+    ssButtonGroup.add(showAll);
+    ssButtonGroup.add(showjPred);
+    ssButtonGroup.add(show3DSS);
+    final boolean autoFirst1 = Cache
+            .getDefault(Preferences.SHOW_AUTOCALC_ABOVE, false);
+    showAll.setSelected(autoFirst1);
+    setShowAutoCalculatedAbove(autoFirst);
+    showAutoFirst.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        setShowAutoCalculatedAbove(showAutoFirst.isSelected());
+        sortAnnotations_actionPerformed();
+      }
+    });
+    showAutoLast.setSelected(!showAutoFirst.isSelected());
+    showAutoLast.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        setShowAutoCalculatedAbove(!showAutoLast.isSelected());
+        sortAnnotations_actionPerformed();
+      }
+    });
 
     JMenu tooltipSettingsMenu = new JMenu(
             MessageManager.getString("label.sequence_id_tooltip"));
     JMenu autoAnnMenu = new JMenu(
             MessageManager.getString("label.autocalculated_annotation"));
 
+    JMenu showSS = new JMenu(
+            MessageManager.getString("label.show_secondary_structure")); 
+    
+    showSS.addMouseListener(new MouseAdapter() {
+      
+      @Override
+      public void mouseEntered(MouseEvent e) {
+
+          updateShowSSRadioButtons(showSS, ssButtonGroup); // Update radio buttons every time the menu is clicked
+         
+      }
+    });
+    
     JMenu exportImageMenu = new JMenu(
             MessageManager.getString("label.export_image"));
     JMenu fileMenu = new JMenu(MessageManager.getString("action.file"));
@@ -1840,11 +1917,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(justifyLeftMenuItem);
+    editMenu.add(justifyRightMenuItem);
+
+    editMenu.addSeparator();
     editMenu.add(padGapsMenuitem);
 
     showMenu.add(showAllColumns);
@@ -1885,11 +1962,14 @@ public class GAlignFrame extends JInternalFrame
     annotationsMenu.add(sortAnnBySequence);
     annotationsMenu.add(sortAnnByLabel);
     annotationsMenu.addSeparator();
+    annotationsMenu.add(showSS);
+    annotationsMenu.addSeparator();
     autoAnnMenu.add(showAutoFirst);
     autoAnnMenu.add(showAutoLast);
     autoAnnMenu.addSeparator();
     autoAnnMenu.add(applyAutoAnnotationSettings);
     autoAnnMenu.add(showConsensusHistogram);
+    autoAnnMenu.add(showSSConsensusHistogram);
     autoAnnMenu.add(showSequenceLogo);
     autoAnnMenu.add(normaliseSequenceLogo);
     autoAnnMenu.addSeparator();
@@ -1979,19 +2059,19 @@ public class GAlignFrame extends JInternalFrame
   protected void createPNG_actionPerformed(ActionEvent object)
   {
     // TODO Auto-generated method stub
-    
+
   }
 
   protected void createEPS_actionPerformed(ActionEvent object)
   {
     // TODO Auto-generated method stub
-    
+
   }
 
   protected void createSVG_actionPerformed(ActionEvent object)
   {
     // TODO Auto-generated method stub
-    
+
   }
 
   protected void copyHighlightedColumns_actionPerformed(
@@ -2224,6 +2304,12 @@ public class GAlignFrame extends JInternalFrame
     // TODO Auto-generated method stub
 
   }
+  
+  protected void showSSConsensusHistogram_actionPerformed(ActionEvent e)
+  {
+    // TODO Auto-generated method stub
+
+  }
 
   protected void showSequenceLogo_actionPerformed(ActionEvent e)
   {
@@ -2487,7 +2573,6 @@ public class GAlignFrame extends JInternalFrame
   {
   }
 
-
   protected void font_actionPerformed(ActionEvent e)
   {
   }
@@ -2501,7 +2586,6 @@ public class GAlignFrame extends JInternalFrame
 
   }
 
-
   protected void loadTreeMenuItem_actionPerformed(ActionEvent e)
   {
 
@@ -2787,4 +2871,22 @@ public class GAlignFrame extends JInternalFrame
   protected void showComplement_actionPerformed(boolean complement)
   {
   }
+
+  protected List<String> updateShowSSRadioButtons()
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  protected void updateShowSSRadioButtons(JMenu showSS,
+          ButtonGroup ssButtonGroup)
+  {
+    // TODO Auto-generated method stub
+  }
+
+  protected void showSS_actionPerformed(String ssSourceSelection)
+  {
+    // TODO Auto-generated method stub
+    
+  }
 }