Use idCanvas highlight system
authoramwaterhouse <Andrew Waterhouse>
Mon, 7 Aug 2006 15:14:13 +0000 (15:14 +0000)
committeramwaterhouse <Andrew Waterhouse>
Mon, 7 Aug 2006 15:14:13 +0000 (15:14 +0000)
src/jalview/appletgui/RedundancyPanel.java
src/jalview/gui/RedundancyPanel.java

index 7608cb9..98b907e 100755 (executable)
@@ -35,13 +35,14 @@ public class RedundancyPanel extends SliderPanel implements Runnable, WindowList
   Stack historyList = new Stack(); // simpler than synching with alignFrame.\r
   float [] redundancy;\r
   SequenceI [] originalSequences;\r
-  Hashtable originalColours;\r
   Frame frame;\r
+  Vector redundantSeqs;\r
 \r
   public RedundancyPanel(AlignmentPanel ap)\r
   {\r
     super(ap, 0, false, null);\r
 \r
+    redundantSeqs = new Vector();\r
     this.ap = ap;\r
     undoButton.setVisible(true);\r
     applyButton.setVisible(true);\r
@@ -99,7 +100,6 @@ public class RedundancyPanel extends SliderPanel implements Runnable, WindowList
       SequenceGroup sg = ap.av.getSelectionGroup();\r
       int height;\r
 \r
-      originalColours = new Hashtable();\r
       int start, end;\r
 \r
       if ( (sg != null) && (sg.getSize(false) >= 1))\r
@@ -135,9 +135,6 @@ public class RedundancyPanel extends SliderPanel implements Runnable, WindowList
       String seqi, seqj;\r
       for (int i = 0; i < height; i++)\r
       {\r
-          originalColours.put(originalSequences[i],\r
-                             originalSequences[i].getColor());\r
-\r
           for (int j = 0; j < i; j++)\r
           {\r
             if(i==j)\r
@@ -184,11 +181,13 @@ public class RedundancyPanel extends SliderPanel implements Runnable, WindowList
     for(int i=0; i<redundancy.length; i++)\r
     {\r
       if (value > redundancy[i])\r
-         originalSequences[i].setColor(java.awt.Color.white);\r
-      else\r
-         originalSequences[i].setColor(java.awt.Color.red);\r
+         redundantSeqs.removeElement(originalSequences[i]);\r
+      else if(!redundantSeqs.contains(originalSequences[i]))\r
+         redundantSeqs.addElement(originalSequences[i]);\r
     }\r
 \r
+    ap.idPanel.idCanvas.setHighlighted(redundantSeqs);\r
+\r
     PaintRefresher.Refresh(null,ap.av.alignment);\r
 \r
     }\r
@@ -273,13 +272,7 @@ public class RedundancyPanel extends SliderPanel implements Runnable, WindowList
 \r
   public void windowClosing(WindowEvent evt)\r
   {\r
-    for(int i=0; i<originalSequences.length; i++)\r
-    {\r
-      SequenceI seq = originalSequences[i];\r
-      seq.setColor( (java.awt.Color)originalColours.get(seq));\r
-    }\r
 \r
-    PaintRefresher.Refresh(ap.av.alignment);\r
   }\r
 \r
   public void windowClosed(WindowEvent evt)\r
index 3d1bfb7..5423dc9 100755 (executable)
@@ -44,8 +44,8 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
     Stack historyList = new Stack(); // simpler than synching with alignFrame.\r
     float [] redundancy;\r
     SequenceI [] originalSequences;\r
-    Hashtable originalColours;\r
     JInternalFrame frame;\r
+    Vector redundantSeqs;\r
 \r
     /**\r
      * Creates a new RedundancyPanel object.\r
@@ -53,10 +53,11 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
      * @param ap DOCUMENT ME!\r
      * @param af DOCUMENT ME!\r
      */\r
-    public RedundancyPanel(AlignmentPanel ap, AlignFrame af)\r
+    public RedundancyPanel(final AlignmentPanel ap, AlignFrame af)\r
     {\r
         this.ap = ap;\r
         this.af = af;\r
+        redundantSeqs = new Vector();\r
 \r
         slider.addChangeListener(new ChangeListener()\r
             {\r
@@ -69,7 +70,7 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
 \r
         applyButton.setText("Remove");\r
         allGroupsCheck.setVisible(false);\r
-        slider.setMinimum(60);\r
+        slider.setMinimum(0);\r
         slider.setMaximum(100);\r
         slider.setValue(100);\r
 \r
@@ -84,7 +85,7 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
             {\r
               public void internalFrameClosing(InternalFrameEvent evt)\r
               {\r
-                resetColours();\r
+               ap.idPanel.idCanvas.setHighlighted(null);\r
               }\r
             }\r
             );\r
@@ -121,7 +122,6 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
         SequenceGroup sg = ap.av.getSelectionGroup();\r
         int height;\r
 \r
-        originalColours = new Hashtable();\r
         int start, end;\r
 \r
         if ( (sg != null) && (sg.getSize(false) >= 1))\r
@@ -157,8 +157,6 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
         String seqi, seqj;\r
         for (int i = 0; i < height; i++)\r
         {\r
-            originalColours.put(originalSequences[i],\r
-                               originalSequences[i].getColor());\r
 \r
             for (int j = 0; j < i; j++)\r
             {\r
@@ -209,13 +207,13 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
       for(int i=0; i<redundancy.length; i++)\r
       {\r
         if (value > redundancy[i])\r
-           originalSequences[i].setColor(java.awt.Color.white);\r
-        else\r
-          originalSequences[i].setColor(java.awt.Color.red);\r
-      }\r
+          redundantSeqs.remove(originalSequences[i]);\r
+        else if(!redundantSeqs.contains(originalSequences[i]))\r
+          redundantSeqs.add(originalSequences[i]);\r
 \r
-      PaintRefresher.Refresh(null,ap.av.alignment);\r
+      }\r
 \r
+      ap.idPanel.idCanvas.setHighlighted(redundantSeqs);\r
     }\r
 \r
     /**\r
@@ -272,16 +270,6 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
         af.updateEditMenuBar();\r
     }\r
 \r
-    void resetColours()\r
-    {\r
-      for(int i=0; i<originalSequences.length; i++)\r
-      {\r
-        SequenceI seq = originalSequences[i];\r
-        seq.setColor( (java.awt.Color)originalColours.get(seq));\r
-      }\r
-\r
-      PaintRefresher.Refresh(ap.av.alignment);\r
-    }\r
 \r
     /**\r
      * DOCUMENT ME!\r