Invert column selection
authoramwaterhouse <Andrew Waterhouse>
Thu, 10 Aug 2006 09:48:32 +0000 (09:48 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 10 Aug 2006 09:48:32 +0000 (09:48 +0000)
src/jalview/appletgui/AlignFrame.java
src/jalview/appletgui/AlignViewport.java
src/jalview/appletgui/RedundancyPanel.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignViewport.java
src/jalview/jbgui/GAlignFrame.java

index 6a8645e..6592399 100755 (executable)
@@ -372,117 +372,146 @@ public void itemStateChanged(ItemEvent evt)
   }\r
  public void actionPerformed(ActionEvent evt)\r
  {\r
-    if(evt.getSource()==inputText)\r
+    Object source = evt.getSource();\r
+\r
+    if(source==inputText)\r
       inputText_actionPerformed();\r
-    else if(evt.getSource()==loadTree)\r
+    else if(source==loadTree)\r
       loadTree_actionPerformed();\r
-    else if(evt.getSource()==loadApplication)\r
+    else if(source==loadApplication)\r
       launchFullApplication();\r
-    else if(evt.getSource()==closeMenuItem)\r
+    else if(source==closeMenuItem)\r
       closeMenuItem_actionPerformed();\r
-    else if(evt.getSource()==copy)\r
+    else if(source==copy)\r
       copy_actionPerformed();\r
-    else if(evt.getSource()==undoMenuItem)\r
+    else if(source==undoMenuItem)\r
       undoMenuItem_actionPerformed();\r
-    else if(evt.getSource()==redoMenuItem)\r
+    else if(source==redoMenuItem)\r
       redoMenuItem_actionPerformed();\r
-    else if(evt.getSource()==inputText)\r
+    else if(source==inputText)\r
             inputText_actionPerformed();\r
-    else if(evt.getSource()==closeMenuItem)\r
+    else if(source==closeMenuItem)\r
             closeMenuItem_actionPerformed();\r
-    else if(evt.getSource()==undoMenuItem)\r
+    else if(source==undoMenuItem)\r
             undoMenuItem_actionPerformed();\r
-    else if(evt.getSource()==redoMenuItem)\r
+    else if(source==redoMenuItem)\r
             redoMenuItem_actionPerformed();\r
-    else if(evt.getSource()==copy)\r
+    else if(source==copy)\r
             copy_actionPerformed();\r
-    else if(evt.getSource()==pasteNew)\r
+    else if(source==pasteNew)\r
             pasteNew_actionPerformed();\r
-    else if(evt.getSource()==pasteThis)\r
+    else if(source==pasteThis)\r
             pasteThis_actionPerformed();\r
-    else if(evt.getSource()==cut)\r
+    else if(source==cut)\r
             cut_actionPerformed();\r
-    else if(evt.getSource()==delete)\r
+    else if(source==delete)\r
             delete_actionPerformed();\r
-    else if(evt.getSource()==deleteGroups)\r
+    else if(source==deleteGroups)\r
             deleteGroups_actionPerformed();\r
-    else if(evt.getSource()==selectAllSequenceMenuItem)\r
+    else if(source==selectAllSequenceMenuItem)\r
             selectAllSequenceMenuItem_actionPerformed();\r
-    else if(evt.getSource()==deselectAllSequenceMenuItem)\r
+    else if(source==deselectAllSequenceMenuItem)\r
             deselectAllSequenceMenuItem_actionPerformed();\r
-    else if(evt.getSource()==invertSequenceMenuItem)\r
+    else if(source==invertSequenceMenuItem)\r
             invertSequenceMenuItem_actionPerformed();\r
-    else if(evt.getSource()==remove2LeftMenuItem)\r
+    else if(source==invertColSel)\r
+    { viewport.invertColumnSelection(); repaint(); }\r
+    else if(source==remove2LeftMenuItem)\r
             remove2LeftMenuItem_actionPerformed();\r
-    else if(evt.getSource()==remove2RightMenuItem)\r
+    else if(source==remove2RightMenuItem)\r
             remove2RightMenuItem_actionPerformed();\r
-    else if(evt.getSource()==removeGappedColumnMenuItem)\r
+    else if(source==removeGappedColumnMenuItem)\r
             removeGappedColumnMenuItem_actionPerformed();\r
-    else if(evt.getSource()==removeAllGapsMenuItem)\r
+    else if(source==removeAllGapsMenuItem)\r
             removeAllGapsMenuItem_actionPerformed();\r
-    else if(evt.getSource()==findMenuItem)\r
+    else if(source==findMenuItem)\r
             findMenuItem_actionPerformed();\r
-    else if(evt.getSource()==font)\r
+    else if(source==font)\r
             font_actionPerformed();\r
-    else if(evt.getSource()==featureSettings)\r
+    else if(source==showColumns)\r
+    {\r
+      viewport.showAllHiddenColumns(); repaint();\r
+    }\r
+    else if(source==showSeqs)\r
+    {\r
+      viewport.showAllHiddenSeqs(); repaint();\r
+    }\r
+    else if(source == hideColumns)\r
+    {\r
+      viewport.hideSelectedColumns(); repaint();\r
+    }\r
+    else if(source == hideSequences && viewport.getSelectionGroup()!=null)\r
+    {\r
+      SequenceI[] seqs = viewport.getSelectionGroup().getSequencesInOrder(\r
+          viewport.alignment\r
+          );\r
+\r
+      for (int i = 0; i < seqs.length; i++)\r
+      {\r
+        viewport.hideSequence(seqs[i]);\r
+      }\r
+\r
+      alignPanel.repaint();\r
+    }\r
+    else if(source==featureSettings)\r
             featureSettings_actionPerformed();\r
-    else if(evt.getSource()==overviewMenuItem)\r
+    else if(source==overviewMenuItem)\r
             overviewMenuItem_actionPerformed();\r
-    else if(evt.getSource()==noColourmenuItem)\r
+    else if(source==noColourmenuItem)\r
             noColourmenuItem_actionPerformed();\r
-    else if(evt.getSource()==clustalColour)\r
+    else if(source==clustalColour)\r
             clustalColour_actionPerformed();\r
-    else if(evt.getSource()==zappoColour)\r
+    else if(source==zappoColour)\r
             zappoColour_actionPerformed();\r
-    else if(evt.getSource()==taylorColour)\r
+    else if(source==taylorColour)\r
             taylorColour_actionPerformed();\r
-    else if(evt.getSource()==hydrophobicityColour)\r
+    else if(source==hydrophobicityColour)\r
             hydrophobicityColour_actionPerformed();\r
-    else if(evt.getSource()==helixColour)\r
+    else if(source==helixColour)\r
             helixColour_actionPerformed();\r
-    else if(evt.getSource()==strandColour)\r
+    else if(source==strandColour)\r
             strandColour_actionPerformed();\r
-    else if(evt.getSource()==turnColour)\r
+    else if(source==turnColour)\r
             turnColour_actionPerformed();\r
-    else if(evt.getSource()==buriedColour)\r
+    else if(source==buriedColour)\r
             buriedColour_actionPerformed();\r
-    else if(evt.getSource()==nucleotideColour)\r
+    else if(source==nucleotideColour)\r
             nucleotideColour_actionPerformed();\r
-    else if(evt.getSource()==modifyPID)\r
+    else if(source==modifyPID)\r
             modifyPID_actionPerformed();\r
-    else if(evt.getSource()==modifyConservation)\r
+    else if(source==modifyConservation)\r
             modifyConservation_actionPerformed();\r
-    else if(evt.getSource()==userDefinedColour)\r
+    else if(source==userDefinedColour)\r
             userDefinedColour_actionPerformed();\r
-    else if(evt.getSource()==PIDColour)\r
+    else if(source==PIDColour)\r
             PIDColour_actionPerformed();\r
-    else if(evt.getSource()==BLOSUM62Colour)\r
+    else if(source==BLOSUM62Colour)\r
             BLOSUM62Colour_actionPerformed();\r
-    else if(evt.getSource()==annotationColour)\r
+    else if(source==annotationColour)\r
            new AnnotationColourChooser(viewport, alignPanel);\r
-    else if(evt.getSource()==sortPairwiseMenuItem)\r
+    else if(source==sortPairwiseMenuItem)\r
             sortPairwiseMenuItem_actionPerformed();\r
-    else if(evt.getSource()==sortIDMenuItem)\r
+    else if(source==sortIDMenuItem)\r
             sortIDMenuItem_actionPerformed();\r
-    else if(evt.getSource()==sortGroupMenuItem)\r
+    else if(source==sortGroupMenuItem)\r
             sortGroupMenuItem_actionPerformed();\r
-    else if(evt.getSource()==removeRedundancyMenuItem)\r
+    else if(source==removeRedundancyMenuItem)\r
             removeRedundancyMenuItem_actionPerformed();\r
-    else if(evt.getSource()==pairwiseAlignmentMenuItem)\r
+    else if(source==pairwiseAlignmentMenuItem)\r
             pairwiseAlignmentMenuItem_actionPerformed();\r
-    else if(evt.getSource()==PCAMenuItem)\r
+    else if(source==PCAMenuItem)\r
             PCAMenuItem_actionPerformed();\r
-    else if(evt.getSource()==averageDistanceTreeMenuItem)\r
+    else if(source==averageDistanceTreeMenuItem)\r
             averageDistanceTreeMenuItem_actionPerformed();\r
-    else if(evt.getSource()==neighbourTreeMenuItem)\r
+    else if(source==neighbourTreeMenuItem)\r
             neighbourTreeMenuItem_actionPerformed();\r
-    else if(evt.getSource()==njTreeBlosumMenuItem)\r
+    else if(source==njTreeBlosumMenuItem)\r
             njTreeBlosumMenuItem_actionPerformed();\r
-    else if(evt.getSource()==avDistanceTreeBlosumMenuItem)\r
+    else if(source==avDistanceTreeBlosumMenuItem)\r
             avTreeBlosumMenuItem_actionPerformed();\r
-    else if(evt.getSource()==documentation)\r
+    else if(source==documentation)\r
             documentation_actionPerformed();\r
-    else if(evt.getSource()==about)\r
+    else if(source==about)\r
             about_actionPerformed();\r
 \r
  }\r
@@ -2074,6 +2103,20 @@ public void itemStateChanged(ItemEvent evt)
     sequenceFeatures.setState(false);\r
     annotationColour.setLabel("by Annotation...");\r
     annotationColour.addActionListener(this);\r
+    invertSequenceMenuItem.setLabel("Invert Sequence Selection");\r
+    invertColSel.setLabel("Invert Column Selection");\r
+    menu1.setLabel("Show");\r
+    showColumns.setLabel("All Columns ");\r
+    showSeqs.setLabel("All Sequences");\r
+    menu2.setLabel("Hide");\r
+    hideColumns.setLabel("Selected Columns");\r
+    hideSequences.setLabel("Selected Sequences");\r
+    invertColSel.addActionListener(this);\r
+    showColumns.addActionListener(this);\r
+    showSeqs.addActionListener(this);\r
+    hideColumns.addActionListener(this);\r
+    hideSequences.addActionListener(this);\r
+\r
 \r
     alignFrameMenuBar.add(fileMenu);\r
         alignFrameMenuBar.add(editMenu);\r
@@ -2099,7 +2142,8 @@ public void itemStateChanged(ItemEvent evt)
         editMenu.add(selectAllSequenceMenuItem);\r
         editMenu.add(deselectAllSequenceMenuItem);\r
         editMenu.add(invertSequenceMenuItem);\r
-        editMenu.add(deleteGroups);\r
+    editMenu.add(invertColSel);\r
+    editMenu.add(deleteGroups);\r
         editMenu.addSeparator();\r
         editMenu.add(remove2LeftMenuItem);\r
         editMenu.add(remove2RightMenuItem);\r
@@ -2109,13 +2153,15 @@ public void itemStateChanged(ItemEvent evt)
         searchMenu.add(findMenuItem);\r
         viewMenu.add(font);\r
         viewMenu.addSeparator();\r
-    viewMenu.add(seqLimits);\r
-        viewMenu.addSeparator();\r
+    viewMenu.add(menu1);\r
+    viewMenu.add(menu2);\r
+    viewMenu.addSeparator();\r
     viewMenu.add(wrapMenuItem);\r
         viewMenu.add(scaleAbove);\r
         viewMenu.add(scaleLeft);\r
         viewMenu.add(scaleRight);\r
         viewMenu.addSeparator();\r
+    viewMenu.add(seqLimits);\r
     viewMenu.add(viewBoxesMenuItem);\r
         viewMenu.add(viewTextMenuItem);\r
         viewMenu.add(colourTextMenuItem);\r
@@ -2166,6 +2212,10 @@ public void itemStateChanged(ItemEvent evt)
         calculate.add(njTreeBlosumMenuItem);\r
         helpMenu.add(documentation);\r
         helpMenu.add(about);\r
+    menu1.add(showColumns);\r
+    menu1.add(showSeqs);\r
+    menu2.add(hideColumns);\r
+    menu2.add(hideSequences);\r
   }\r
 \r
   public void setEmbedded()\r
@@ -2238,6 +2288,13 @@ public void itemStateChanged(ItemEvent evt)
   MenuItem featureSettings = new MenuItem();\r
   CheckboxMenuItem sequenceFeatures = new CheckboxMenuItem();\r
   MenuItem annotationColour = new MenuItem();\r
+  MenuItem invertColSel = new MenuItem();\r
+  Menu menu1 = new Menu();\r
+  MenuItem showColumns = new MenuItem();\r
+  MenuItem showSeqs = new MenuItem();\r
+  Menu menu2 = new Menu();\r
+  MenuItem hideColumns = new MenuItem();\r
+  MenuItem hideSequences = new MenuItem();\r
 \r
   public void mousePressed(MouseEvent evt)\r
   {\r
index b4cac5c..99d0794 100755 (executable)
@@ -738,6 +738,21 @@ public class AlignViewport
     hasHiddenColumns = true;\r
   }\r
 \r
+  public void invertColumnSelection()\r
+  {\r
+    int column;\r
+    for (int i = 0; i < alignment.getWidth(); i++)\r
+    {\r
+      column = i;\r
+\r
+      if (colSel.contains(column))\r
+        colSel.removeElement(column);\r
+      else\r
+        colSel.addElement(column);\r
+\r
+    }\r
+  }\r
+\r
 \r
   public void hideColumns(int start, int end)\r
   {\r
index b4cd21d..efabb9b 100755 (executable)
@@ -52,7 +52,7 @@ public class RedundancyPanel extends SliderPanel implements Runnable, WindowList
     valueField.setText("100");\r
 \r
     slider.setVisibleAmount(1);\r
-    slider.setMinimum(40);\r
+    slider.setMinimum(0);\r
     slider.setMaximum(100+slider.getVisibleAmount());\r
     slider.setValue(100);\r
 \r
index 790a17a..b85d5d4 100755 (executable)
@@ -1082,6 +1082,13 @@ public class AlignFrame
     PaintRefresher.Refresh(null, viewport.alignment);\r
   }\r
 \r
+  public void invertColSel_actionPerformed(ActionEvent e)\r
+  {\r
+    viewport.invertColumnSelection();\r
+    alignPanel.repaint();\r
+  }\r
+\r
+\r
   /**\r
    * DOCUMENT ME!\r
    *\r
index fde4d90..2dd5fda 100755 (executable)
@@ -1161,6 +1161,22 @@ public class AlignViewport
       }\r
     }\r
 \r
+    public void invertColumnSelection()\r
+    {\r
+      int column;\r
+      for(int i=0; i<alignment.getWidth(); i++)\r
+      {\r
+        column = i;\r
+\r
+        if(colSel.contains(column))\r
+          colSel.removeElement(column);\r
+        else\r
+          colSel.addElement(column);\r
+\r
+      }\r
+\r
+    }\r
+\r
     public int adjustForHiddenSeqs(int alignmentIndex)\r
     {\r
       return alignment.getHiddenSequences().adjustForHiddenSeqs(alignmentIndex);\r
index 8aa5159..b7c903e 100755 (executable)
@@ -136,6 +136,7 @@ public class GAlignFrame
   JMenuItem hideSelSequences = new JMenuItem();\r
   JMenuItem hideSelColumns = new JMenuItem();\r
   protected JCheckBoxMenuItem hiddenMarkers = new JCheckBoxMenuItem();\r
+  JMenuItem invertColSel = new JMenuItem();\r
 \r
   public GAlignFrame()\r
   {\r
@@ -365,7 +366,7 @@ public class GAlignFrame
         deselectAllSequenceMenuItem_actionPerformed(e);\r
       }\r
     });\r
-    invertSequenceMenuItem.setText("Invert Selection");\r
+    invertSequenceMenuItem.setText("Invert Sequence Selection");\r
     invertSequenceMenuItem.addActionListener(new java.awt.event.ActionListener()\r
     {\r
       public void actionPerformed(ActionEvent e)\r
@@ -1077,6 +1078,14 @@ public class GAlignFrame
         hiddenMarkers_actionPerformed(e);\r
       }\r
     });\r
+    invertColSel.setText("Invert Column Selection");\r
+    invertColSel.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        invertColSel_actionPerformed(e);\r
+      }\r
+    });\r
 \r
     alignFrameMenuBar.add(fileMenu);\r
     alignFrameMenuBar.add(editMenu);\r
@@ -1110,6 +1119,7 @@ public class GAlignFrame
     editMenu.add(selectAllSequenceMenuItem);\r
     editMenu.add(deselectAllSequenceMenuItem);\r
     editMenu.add(invertSequenceMenuItem);\r
+    editMenu.add(invertColSel);\r
     editMenu.add(deleteGroups);\r
     editMenu.addSeparator();\r
     editMenu.add(remove2LeftMenuItem);\r
@@ -1582,4 +1592,9 @@ public class GAlignFrame
   {\r
 \r
   }\r
+\r
+  public void invertColSel_actionPerformed(ActionEvent e)\r
+  {\r
+\r
+  }\r
 }\r