Fire alignment changed if seqs hidden / revealed
authoramwaterhouse <Andrew Waterhouse>
Wed, 16 Aug 2006 08:05:35 +0000 (08:05 +0000)
committeramwaterhouse <Andrew Waterhouse>
Wed, 16 Aug 2006 08:05:35 +0000 (08:05 +0000)
src/jalview/appletgui/APopupMenu.java
src/jalview/appletgui/AlignFrame.java
src/jalview/appletgui/AlignViewport.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignViewport.java
src/jalview/gui/AlignmentPanel.java
src/jalview/gui/PopupMenu.java

index 449b83a..afa6c7e 100755 (executable)
@@ -226,7 +226,6 @@ public class APopupMenu
     else if(source == revealAll)\r
     {\r
         ap.av.showAllHiddenSeqs();\r
-        ap.repaint();\r
     }\r
 \r
     else if(source==copy)\r
@@ -619,8 +618,6 @@ public class APopupMenu
       }\r
 \r
       ap.av.setSelectionGroup(null);\r
-      ap.repaint();\r
-      refresh();\r
     }\r
 \r
 }\r
index 08cbb9a..64423b0 100755 (executable)
@@ -332,21 +332,20 @@ public class AlignFrame extends Frame implements ActionListener,
       case KeyEvent.VK_H:\r
       {\r
         SequenceGroup sg = viewport.getSelectionGroup();\r
+        boolean hide = false;\r
         if (sg != null && sg.getSize(false) != viewport.alignment.getHeight())\r
         {\r
-          hideSelectedSeqs();\r
+          hide = true;\r
+          viewport.hideAllSelectedSeqs();\r
         }\r
-        else\r
+        else if (viewport.colSel.getSelected().size() < 1)\r
           viewport.showAllHiddenSeqs();\r
 \r
         if (viewport.colSel.getSelected().size() > 0)\r
-        {\r
           viewport.hideSelectedColumns();\r
-        }\r
-        else\r
-         {\r
-           viewport.showAllHiddenColumns();\r
-         }\r
+        else if (!hide)\r
+          viewport.showAllHiddenColumns();\r
+\r
         alignPanel.repaint();\r
         break;\r
       }\r
@@ -458,7 +457,7 @@ public void itemStateChanged(ItemEvent evt)
     }\r
     else if(source==showSeqs)\r
     {\r
-      viewport.showAllHiddenSeqs(); alignPanel.repaint();\r
+      viewport.showAllHiddenSeqs();\r
     }\r
     else if(source == hideColumns)\r
     {\r
@@ -466,7 +465,7 @@ public void itemStateChanged(ItemEvent evt)
     }\r
     else if(source == hideSequences && viewport.getSelectionGroup()!=null)\r
     {\r
-      hideSelectedSeqs();\r
+      viewport.hideAllSelectedSeqs();\r
     }\r
     else if(source==featureSettings)\r
             featureSettings_actionPerformed();\r
@@ -1272,19 +1271,6 @@ public void itemStateChanged(ItemEvent evt)
     alignPanel.repaint();\r
   }\r
 \r
-  void hideSelectedSeqs()\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
 \r
   protected void scaleAbove_actionPerformed()\r
   {\r
index 7c46cd9..3944b89 100755 (executable)
@@ -770,29 +770,24 @@ public class AlignViewport
     {\r
       alignment.getHiddenSequences().hideSequence(seq);\r
       hasHiddenRows = true;\r
+      firePropertyChange("alignment", null, alignment.getSequences());\r
     }\r
   }\r
 \r
-  public void showSequence(int index)\r
+  public void hideAllSelectedSeqs()\r
   {\r
-    Vector tmp = alignment.getHiddenSequences().showSequence(index);\r
-    if (tmp.size() > 0)\r
-    {\r
-      if (selectionGroup == null)\r
-      {\r
-        selectionGroup = new SequenceGroup();\r
-        selectionGroup.setEndRes(alignment.getWidth() - 1);\r
-      }\r
+    if (selectionGroup == null)\r
+      return;\r
 \r
-      for (int t = 0; t < tmp.size(); t++)\r
-      {\r
-        selectionGroup.addSequence(\r
-            (SequenceI) tmp.elementAt(t), false\r
-            );\r
-      }\r
+    SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);\r
+\r
+    for (int i = 0; i < seqs.length; i++)\r
+    {\r
+      alignment.getHiddenSequences().hideSequence(seqs[i]);\r
     }\r
-    if (alignment.getHiddenSequences().getSize() < 1)\r
-      hasHiddenRows = false;\r
+    firePropertyChange("alignment", null, alignment.getSequences());\r
+    hasHiddenRows = true;\r
+    setSelectionGroup(null);\r
   }\r
 \r
   public void showColumn(int col)\r
@@ -824,8 +819,9 @@ public class AlignViewport
             (SequenceI)tmp.elementAt(t), false\r
             );\r
       }\r
+      firePropertyChange("alignment", null, alignment.getSequences());\r
       hasHiddenRows = false;\r
-      }\r
+    }\r
   }\r
 \r
   public int adjustForHiddenSeqs(int alignmentIndex)\r
index 2b15ed9..7ec1f26 100755 (executable)
@@ -1284,12 +1284,16 @@ public class AlignFrame
      viewport.updateConsensus();\r
      viewport.updateConservation();\r
    }\r
+\r
    resetAllColourSchemes();\r
    if(alignPanel.overviewPanel!=null)\r
      alignPanel.overviewPanel.updateOverviewImage();\r
 \r
    viewport.alignment.adjustSequenceAnnotations();\r
 \r
+   if(alignPanel.overviewPanel!=null)\r
+     alignPanel.overviewPanel.updateOverviewImage();\r
+\r
    alignPanel.repaint();\r
  }\r
 \r
@@ -1423,31 +1427,17 @@ public class AlignFrame
   public void showAllSeqs_actionPerformed(ActionEvent e)\r
   {\r
     viewport.showAllHiddenSeqs();\r
-    repaint();\r
   }\r
 \r
   public void showAllColumns_actionPerformed(ActionEvent e)\r
   {\r
     viewport.showAllHiddenColumns();\r
+    repaint();\r
   }\r
 \r
   public void hideSelSequences_actionPerformed(ActionEvent e)\r
   {\r
-    if(viewport.getSelectionGroup()==null)\r
-      return;\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
-    viewport.setSelectionGroup(null);\r
-\r
-    alignPanel.repaint();\r
+    viewport.hideAllSelectedSeqs();\r
   }\r
 \r
   public void hideSelColumns_actionPerformed(ActionEvent e)\r
index bca3589..f8626a7 100755 (executable)
@@ -1122,12 +1122,29 @@ public class AlignViewport
       hasHiddenColumns = true;\r
     }\r
 \r
+    public void hideAllSelectedSeqs()\r
+    {\r
+      if (selectionGroup == null)\r
+        return;\r
+\r
+      SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);\r
+\r
+      for (int i = 0; i < seqs.length; i++)\r
+      {\r
+        alignment.getHiddenSequences().hideSequence(seqs[i]);\r
+      }\r
+      firePropertyChange("alignment", null, alignment.getSequences());\r
+      hasHiddenRows = true;\r
+      setSelectionGroup(null);\r
+    }\r
+\r
     public void hideSequence(SequenceI seq)\r
     {\r
       if(seq!=null)\r
       {\r
         alignment.getHiddenSequences().hideSequence(seq);\r
         hasHiddenRows = true;\r
+        firePropertyChange("alignment", null, alignment.getSequences());\r
       }\r
     }\r
 \r
@@ -1148,7 +1165,9 @@ public class AlignViewport
               (SequenceI) tmp.elementAt(t), false\r
               );\r
         }\r
+        firePropertyChange("alignment", null, alignment.getSequences());\r
       }\r
+\r
       if(alignment.getHiddenSequences().getSize()<1)\r
         hasHiddenRows = false;\r
     }\r
@@ -1182,6 +1201,7 @@ public class AlignViewport
               (SequenceI)tmp.elementAt(t), false\r
               );\r
         }\r
+        firePropertyChange("alignment", null, alignment.getSequences());\r
         hasHiddenRows = false;\r
       }\r
     }\r
index 7446d6d..c0de33e 100755 (executable)
@@ -238,16 +238,18 @@ public class AlignmentPanel extends GAlignmentPanel
           case KeyEvent.VK_H:\r
           {\r
             SequenceGroup sg = av.getSelectionGroup();\r
+            boolean hide = false;\r
             if(sg!=null && sg.getSize(false)!=av.alignment.getHeight())\r
             {\r
+              hide = true;\r
               alignFrame.hideSelSequences_actionPerformed(null);\r
             }\r
-            else\r
+            else if(av.colSel.getSelected().size()<1)\r
               alignFrame.showAllSeqs_actionPerformed(null);\r
 \r
             if(av.colSel.getSelected().size()>0)\r
               alignFrame.hideSelColumns_actionPerformed(null);\r
-            else\r
+            else if(!hide)\r
               alignFrame.showAllColumns_actionPerformed(null);\r
 \r
             break;\r
index e89eb28..4be63e4 100755 (executable)
@@ -206,7 +206,6 @@ public class PopupMenu extends JPopupMenu
                 public void actionPerformed(ActionEvent e)\r
                 {\r
                   ap.av.showSequence(index);\r
-                  ap.repaint();\r
                   if (ap.overviewPanel != null)\r
                     ap.overviewPanel.updateOverviewImage();\r
                 }\r
@@ -220,10 +219,9 @@ public class PopupMenu extends JPopupMenu
                   public void actionPerformed(ActionEvent e)\r
                   {\r
                     ap.av.showAllHiddenSeqs();\r
-                    ap.repaint();\r
                     if (ap.overviewPanel != null)\r
                       ap.overviewPanel.updateOverviewImage();\r
-                      }\r
+                    }\r
                 });\r
 \r
             add(menuItem);\r
@@ -1148,8 +1146,6 @@ public class PopupMenu extends JPopupMenu
         }\r
 \r
         ap.av.setSelectionGroup(null);\r
-        ap.repaint();\r
-        refresh();\r
     }\r
 \r
   public void copy_actionPerformed(ActionEvent e)\r