fixed stacktrace potential for pairwise alignment action.
[jalview.git] / src / jalview / gui / AlignFrame.java
index 0c0e3d7..83ee1c3 100755 (executable)
@@ -105,18 +105,14 @@ public class AlignFrame extends GAlignFrame
 
   protected void outputText_actionPerformed(ActionEvent e)
   {
-     CutAndPasteTransfer cap = new CutAndPasteTransfer(false);
-     JInternalFrame frame = new JInternalFrame();
-     cap.formatForOutput();
-     frame.setContentPane(cap);
-     Desktop.addInternalFrame(frame, "Alignment output - "+e.getActionCommand(), 600, 500);
+     CutAndPasteTransfer cap = new CutAndPasteTransfer();
+     Desktop.addInternalFrame(cap, "Alignment output - "+e.getActionCommand(), 600, 500);
      cap.setText( FormatAdapter.formatSequences(e.getActionCommand(), viewport.getAlignment().getSequences()));
   }
 
   protected void htmlMenuItem_actionPerformed(ActionEvent e)
   {
-    HTMLOutput htmlOutput = new HTMLOutput(viewport);
-    htmlOutput = null;
+    new HTMLOutput(viewport);
   }
 
   protected void createPNG_actionPerformed(ActionEvent e)
@@ -421,11 +417,12 @@ public class AlignFrame extends GAlignFrame
   protected void delete_actionPerformed(ActionEvent e)
   {
     boolean seqsdeleted=false;
-    addHistoryItem(new HistoryItem("Delete Sequences", viewport.alignment, HistoryItem.HIDE));
 
     if (viewport.getSelectionGroup() == null)
       return;
 
+    addHistoryItem(new HistoryItem("Delete Sequences", viewport.alignment, HistoryItem.HIDE));
+
      SequenceGroup sg = viewport.getSelectionGroup();
      for (int i=0;i < sg.sequences.size(); i++)
      {
@@ -737,7 +734,6 @@ public class AlignFrame extends GAlignFrame
 
   public void clustalColour_actionPerformed(ActionEvent e)
   {
-    abovePIDThreshold.setSelected(false);
     changeColour(new ClustalxColourScheme(viewport.alignment.getSequences(), viewport.alignment.getWidth()));
   }
 
@@ -834,7 +830,7 @@ public class AlignFrame extends GAlignFrame
       ccs.setConsensus( viewport.vconsensus );
       viewport.setGlobalColourScheme(ccs);
 
-      SliderPanel.setConservationSlider(alignPanel, ccs, "Background");
+      ccs.inc = SliderPanel.setConservationSlider(alignPanel, ccs, "Background");
 
     }
     else
@@ -853,16 +849,16 @@ public class AlignFrame extends GAlignFrame
       {
         SequenceGroup sg = (SequenceGroup)groups.elementAt(i);
 
-        if (cs instanceof ClustalxColourScheme)
-        {
+        if(cs==null)
+          sg.cs = null;
+        else if (cs instanceof ClustalxColourScheme)
           sg.cs = new ClustalxColourScheme(sg.sequences, sg.getWidth());
-        }
-        else if(cs!=null)
-        {
+        else if (cs instanceof UserColourScheme)
+          sg.cs = new UserColourScheme( ((UserColourScheme)cs).getColours());
+        else
           try{
             sg.cs = (ColourSchemeI) cs.getClass().newInstance();
-          }catch(Exception ex){ex.printStackTrace();}
-        }
+          }catch(Exception ex){}
 
         if(viewport.getAbovePIDThreshold())
         {
@@ -959,7 +955,7 @@ public class AlignFrame extends GAlignFrame
 
   public void userDefinedColour_actionPerformed(ActionEvent e)
   {
-    UserDefinedColours chooser = new UserDefinedColours( alignPanel, null);
+    new UserDefinedColours( alignPanel, null);
   }
 
   public void PIDColour_actionPerformed(ActionEvent e)
@@ -999,7 +995,7 @@ public class AlignFrame extends GAlignFrame
 
   public void removeRedundancyMenuItem_actionPerformed(ActionEvent e)
   {
-    RedundancyPanel sp = new RedundancyPanel(alignPanel);
+    RedundancyPanel sp = new RedundancyPanel(alignPanel,this);
     JInternalFrame frame = new JInternalFrame();
     frame.setContentPane(sp);
     Desktop.addInternalFrame(frame, "Redundancy threshold selection", 400, 100, false);
@@ -1008,7 +1004,8 @@ public class AlignFrame extends GAlignFrame
 
   public void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e)
   {
-    if(viewport.getSelectionGroup().getSize()<2)
+    if((viewport.getSelectionGroup()==null) ||
+       viewport.getSelectionGroup().getSize()<2)
       JOptionPane.showInternalMessageDialog(this, "You must select at least 2 sequences.", "Invalid Selection", JOptionPane.WARNING_MESSAGE);
     else
     {
@@ -1063,7 +1060,7 @@ public class AlignFrame extends GAlignFrame
 
   protected void avTreeBlosumMenuItem_actionPerformed(ActionEvent e)
   {
-    NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62PID");
+    NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62");
   }
 
   void NewTreePanel(String type, String pwType, String title)
@@ -1072,7 +1069,8 @@ public class AlignFrame extends GAlignFrame
     if(!viewport.alignment.isAligned())
     {
       JOptionPane.showMessageDialog(Desktop.desktop, "The sequences must be aligned before creating a tree.\n"
-                                   +"Try using the Pad function in the edit menu.",
+                                   +"Try using the Pad function in the edit menu,\n"
+                                  +"or one of the multiple sequence alignment web services.",
                                     "Sequences not aligned", JOptionPane.WARNING_MESSAGE);
       return;
     }
@@ -1239,7 +1237,7 @@ public class AlignFrame extends GAlignFrame
     if (seq!=null) {
       JPredClient ct = new JPredClient(title, seq);
     } else {
-      System.out.print("JALVIEW ERROR! - Unexpected JPred selection state!\n");
+      System.err.print("JALVIEW ERROR! - Unexpected JPred selection state!\n");
     }
   }
   protected void msaAlignMenuItem_actionPerformed(ActionEvent e)