PaintRefresh changed
authoramwaterhouse <Andrew Waterhouse>
Mon, 13 Jun 2005 11:34:15 +0000 (11:34 +0000)
committeramwaterhouse <Andrew Waterhouse>
Mon, 13 Jun 2005 11:34:15 +0000 (11:34 +0000)
17 files changed:
src/jalview/appletgui/AlignFrame.java
src/jalview/appletgui/IdCanvas.java
src/jalview/appletgui/IdPanel.java
src/jalview/appletgui/PaintRefresher.java
src/jalview/appletgui/RotatableCanvas.java
src/jalview/appletgui/SeqCanvas.java
src/jalview/appletgui/SeqPanel.java
src/jalview/appletgui/TreeCanvas.java
src/jalview/gui/AlignmentPanel.java
src/jalview/gui/IdCanvas.java
src/jalview/gui/IdPanel.java
src/jalview/gui/PaintRefresher.java
src/jalview/gui/PopupMenu.java
src/jalview/gui/RotatableCanvas.java
src/jalview/gui/SeqCanvas.java
src/jalview/gui/SeqPanel.java
src/jalview/gui/TreeCanvas.java

index 25b74b6..b314854 100755 (executable)
@@ -749,10 +749,6 @@ public class AlignFrame
       {\r
         ( (ResidueColourScheme) cs).setThreshold(threshold);\r
       }\r
-      else if (cs instanceof ScoreColourScheme)\r
-      {\r
-        ( (ScoreColourScheme) cs).setThreshold(threshold);\r
-      }\r
 \r
       viewport.setGlobalColourScheme(cs);\r
     }\r
@@ -760,10 +756,6 @@ public class AlignFrame
     {\r
       ( (ResidueColourScheme) cs).setThreshold(0);\r
     }\r
-    else if (cs instanceof ScoreColourScheme)\r
-    {\r
-      ( (ScoreColourScheme) cs).setThreshold(0);\r
-    }\r
 \r
     if (viewport.getConservationSelected())\r
     {\r
@@ -804,9 +796,16 @@ public class AlignFrame
       {\r
         SequenceGroup sg = (SequenceGroup) groups.elementAt(i);\r
 \r
+        if(cs==null)\r
+        {\r
+          sg.cs = null;\r
+          continue;\r
+        }\r
         if (cs instanceof ClustalxColourScheme)\r
         {\r
-          sg.cs = new ClustalxColourScheme(sg.sequences, sg.getWidth());\r
+          ClustalxColourScheme cxs = (ClustalxColourScheme) cs;\r
+          cxs.resetClustalX(viewport.alignment.getSequences(), viewport.alignment.getWidth());\r
+          sg.cs = cxs;\r
         }\r
         else\r
         {\r
@@ -827,10 +826,6 @@ public class AlignFrame
           {\r
             ( (ResidueColourScheme) sg.cs).setThreshold(threshold);\r
           }\r
-          else if (sg.cs instanceof ScoreColourScheme)\r
-          {\r
-            ( (ScoreColourScheme) sg.cs).setThreshold(threshold);\r
-          }\r
 \r
           sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, sg.getWidth()));\r
         }\r
index 3c3c52c..8b6939e 100755 (executable)
@@ -44,7 +44,7 @@ public class IdCanvas
   {\r
     setLayout(null);\r
     this.av = av;\r
-    PaintRefresher.Register(this);\r
+    PaintRefresher.Register(this, av.alignment);\r
   }\r
 \r
   public void drawIdString(Graphics gg, SequenceI s, int i, int starty,\r
index 33463d4..d548936 100755 (executable)
@@ -238,7 +238,7 @@ public class IdPanel
       av.getSelectionGroup().recalcConservation();\r
 \r
     mouseDragging = false;\r
-    PaintRefresher.Refresh(this);\r
+    PaintRefresher.Refresh(this, av.alignment);\r
   }\r
 \r
   public void highlightSearchResults(java.util.Vector found)\r
index 670af70..2da1db6 100755 (executable)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
  */\r
 \r
-package jalview.appletgui;\r
 \r
-import java.util.*;\r
+\r
+package jalview.appletgui;\r
 \r
 import java.awt.*;\r
+import java.util.*;\r
+import jalview.datamodel.*;\r
 \r
 public class PaintRefresher\r
 {\r
-  static Vector components = new Vector();\r
+  static Hashtable components = new Hashtable();\r
 \r
-  public static void Register(Component c)\r
+  public static void Register(Component comp, AlignmentI al)\r
   {\r
-    if (!components.contains(c))\r
+    if(components.containsKey(al))\r
     {\r
-      components.addElement(c);\r
+      Vector comps = (Vector)components.get(al);\r
+      comps.addElement(comp);\r
     }\r
     else\r
     {\r
-      components.removeElement(c);\r
+      Vector vcoms = new Vector();\r
+      vcoms.addElement(comp);\r
+      components.put(al, vcoms);\r
     }\r
   }\r
 \r
-  public static void Refresh(Component c)\r
+  public static void Refresh(AlignmentI al)\r
+  {\r
+    Refresh(null, al);\r
+  }\r
+\r
+  public static void Refresh(Component c, AlignmentI al)\r
   {\r
     Component temp;\r
-    Enumeration e = components.elements();\r
-    while (e.hasMoreElements())\r
+    Vector coms = (Vector)components.get(al);\r
+    Enumeration e = coms.elements();\r
+    while( e.hasMoreElements() )\r
     {\r
-      temp = (Component) e.nextElement();\r
+      temp = (Component)e.nextElement();\r
 \r
-      if (!temp.isValid())\r
-      {\r
-        components.removeElement(temp);\r
-      }\r
-      else if (temp == c)\r
-      {\r
+      if(!temp.isValid())\r
+        coms.removeElement( temp );\r
+      else if( temp == c )\r
         continue;\r
-      }\r
 \r
       temp.repaint();\r
     }\r
@@ -62,3 +69,4 @@ public class PaintRefresher
   }\r
 \r
 }\r
+\r
index 8d22f37..88b6251 100755 (executable)
@@ -91,7 +91,7 @@ public class RotatableCanvas
     this.points = points;\r
     this.npoint = npoint;\r
     this.av = av;\r
-    PaintRefresher.Register(this);\r
+    PaintRefresher.Register(this, av.alignment);\r
 //\r
     prefsize = getPreferredSize();\r
     orig = new float[npoint][3];\r
@@ -471,7 +471,7 @@ public class RotatableCanvas
       if (av.getSelectionGroup() != null)\r
       {\r
         av.getSelectionGroup().addOrRemove(found, true);\r
-        PaintRefresher.Refresh(this);\r
+        PaintRefresher.Refresh(this, av.alignment);\r
       }\r
       else\r
       {\r
index 438d7ad..5aa5d66 100755 (executable)
@@ -50,7 +50,7 @@ public class SeqCanvas
     this.av = av;\r
     fr = new FeatureRenderer(av);\r
     sr = new SequenceRenderer(av);\r
-    PaintRefresher.Register(this);\r
+    PaintRefresher.Register(this, av.alignment);\r
 \r
   }\r
 \r
index 9d14b26..6e2a544 100755 (executable)
@@ -593,28 +593,23 @@ public class SeqPanel
 \r
   public void doMouseReleasedDefineMode(MouseEvent evt)\r
   {\r
-    mouseDragging = false;\r
+    if(mouseDragging)\r
+     {\r
+       stretchGroup.recalcConservation();\r
+       mouseDragging = false;\r
+     }\r
 \r
     if (stretchGroup == null)\r
     {\r
       return;\r
     }\r
 \r
-    stretchGroup.recalcConservation();\r
-\r
-    if (stretchGroup.cs instanceof ClustalxColourScheme)\r
-    {\r
-      stretchGroup.cs = new ClustalxColourScheme(stretchGroup.sequences,\r
-                                                 av.alignment.getWidth());\r
-    }\r
-\r
-    else if (stretchGroup.cs instanceof ConservationColourScheme)\r
+    if (stretchGroup.cs instanceof ConservationColourScheme)\r
     {\r
       ConservationColourScheme ccs = (ConservationColourScheme) stretchGroup.cs;\r
       stretchGroup.cs = ccs;\r
       SliderPanel.setConservationSlider(ap, stretchGroup.cs,\r
                                         stretchGroup.getName());\r
-\r
     }\r
     else\r
     {\r
index b00d6cc..136be52 100755 (executable)
@@ -70,7 +70,7 @@ public class TreeCanvas
     longestName = label;\r
     setLayout(null);\r
 \r
-    PaintRefresher.Register(this);\r
+    PaintRefresher.Register(this, av.alignment);\r
   }\r
 \r
   public void TreeSelectionChanged(Sequence sequence)\r
@@ -85,7 +85,8 @@ public class TreeCanvas
     selected.setEndRes(av.alignment.getWidth());\r
     selected.addOrRemove(sequence, true);\r
 \r
-    PaintRefresher.Refresh(this);\r
+System.out.println("called here");\r
+    PaintRefresher.Refresh(this, av.alignment);\r
     repaint();\r
   }\r
 \r
@@ -424,7 +425,6 @@ public class TreeCanvas
 \r
   public void mousePressed(MouseEvent e)\r
   {\r
-\r
     av.setCurrentTree(tree);\r
 \r
     int x = e.getX();\r
@@ -472,14 +472,22 @@ public class TreeCanvas
 \r
           Vector l = tree.findLeaves( (SequenceNode) tree.getGroups().elementAt(\r
               i), new Vector());\r
-          SequenceGroup sg = new SequenceGroup("TreeGroup", av.getGlobalColourScheme(), true, true, false,\r
-                                     0, av.alignment.getWidth());\r
+\r
+          Vector sequences = new Vector();\r
           for (int j = 0; j < l.size(); j++)\r
           {\r
-            SequenceNode sn = (SequenceNode) l.elementAt(j);\r
-            sg.addSequence( (Sequence) sn.element(), false);\r
+            sequences.addElement( (Sequence) ( (SequenceNode) l.elementAt(j)).element());\r
           }\r
 \r
+          ColourSchemeI cs = ColourSchemeProperty.getColour(sequences, av.alignment.getWidth(),\r
+              ColourSchemeProperty.getColourName(av.getGlobalColourScheme()));\r
+\r
+\r
+          SequenceGroup sg = new SequenceGroup(sequences, "TreeGroup",\r
+                                               cs, true, true,\r
+                                               false, 0, av.alignment.getWidth());\r
+\r
+\r
           if (av.getGlobalColourScheme() instanceof ConservationColourScheme)\r
           {\r
             ConservationColourScheme ccs = (ConservationColourScheme) av.\r
@@ -503,7 +511,7 @@ public class TreeCanvas
       }\r
     }\r
 \r
-    PaintRefresher.Refresh(this);\r
+    PaintRefresher.Refresh(this, av.alignment);\r
     repaint();\r
 \r
   }\r
index 068d605..1a48af6 100755 (executable)
@@ -47,7 +47,7 @@ public class AlignmentPanel
   AnnotationLabels alabels;\r
 \r
   // this value is set false when selection area being dragged\r
-  boolean fastPaint = false;\r
+  boolean fastPaint = true;\r
   int hextent = 0;\r
   int vextent = 0;\r
 \r
index c14da85..b38fd21 100755 (executable)
@@ -42,7 +42,7 @@ public class IdCanvas
   {\r
     setLayout(new BorderLayout());\r
     this.av = av;\r
-    PaintRefresher.Register(this);\r
+    PaintRefresher.Register(this, av.alignment);\r
   }\r
 \r
   public void drawIdString(Graphics2D gg, SequenceI s, int i, int starty,\r
@@ -177,9 +177,6 @@ public class IdCanvas
 \r
   void drawIds(int starty, int endy)\r
   {\r
-    if(gg==null)\r
-      return;\r
-\r
 \r
     Color currentColor = Color.white;\r
     Color currentTextColor = Color.black;\r
index 00fe35f..db24821 100755 (executable)
@@ -247,7 +247,7 @@ public class IdPanel
     }\r
 \r
     mouseDragging = false;\r
-    PaintRefresher.Refresh(this);\r
+    PaintRefresher.Refresh(av.alignment);\r
   }\r
 \r
   public void highlightSearchResults(java.util.Vector found)\r
index 6bec8fd..e59ecd9 100755 (executable)
  * along with this program; if not, write to the Free Software\r
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
  */\r
-package jalview.gui;\r
-\r
-import java.util.*;\r
 \r
+package jalview.gui;\r
 import java.awt.*;\r
+import java.util.*;\r
+import jalview.datamodel.*;\r
 \r
 public class PaintRefresher\r
 {\r
-  static Vector components = new Vector();\r
+  static Hashtable components = new Hashtable();\r
 \r
-  public static void Register(Component c)\r
+  public static void Register(Component comp, AlignmentI al)\r
   {\r
-    if (!components.contains(c))\r
+    if(components.containsKey(al))\r
     {\r
-      components.add(c);\r
+      Vector comps = (Vector)components.get(al);\r
+      comps.addElement(comp);\r
     }\r
     else\r
     {\r
-      components.remove(c);\r
+      Vector vcoms = new Vector();\r
+      vcoms.addElement(comp);\r
+      components.put(al, vcoms);\r
     }\r
   }\r
 \r
-  public static void Refresh(Component c)\r
+  public static void Refresh(AlignmentI al)\r
   {\r
-    Component temp;\r
-    Enumeration e = components.elements();\r
+    Refresh(null, al);\r
+  }\r
 \r
-    while (e.hasMoreElements())\r
+  public static void Refresh(Component c, AlignmentI al)\r
+  {\r
+    Component temp;\r
+    Vector coms = (Vector)components.get(al);\r
+    Enumeration e = coms.elements();\r
+    while( e.hasMoreElements() )\r
     {\r
-      temp = (Component) e.nextElement();\r
-\r
-      if (!temp.isValid())\r
-      {\r
-        components.removeElement(temp);\r
-      }\r
-      else if (temp == c)\r
-      {\r
+      temp = (Component)e.nextElement();\r
+\r
+      if(!temp.isValid())\r
+        coms.removeElement( temp );\r
+      else if( temp == c )\r
         continue;\r
-      }\r
 \r
       temp.repaint();\r
     }\r
+\r
   }\r
+\r
 }\r
index 7576173..d563e09 100755 (executable)
@@ -634,7 +634,7 @@ public class PopupMenu
     SequenceGroup sg = ap.av.getSelectionGroup();\r
     ap.av.alignment.deleteGroup(sg);\r
     ap.av.setSelectionGroup(null);\r
-    ap.repaint();\r
+    refresh();\r
   }\r
 \r
   void pdbMenuItem_actionPerformed(ActionEvent e)\r
@@ -676,7 +676,7 @@ public class PopupMenu
       sg.setOutlineColour(col);\r
     }\r
 \r
-    ap.repaint();\r
+    refresh();\r
   }\r
 \r
   public void showBoxes_actionPerformed(ActionEvent e)\r
index c89cd59..6ae66a2 100755 (executable)
@@ -75,7 +75,7 @@ public class RotatableCanvas
     this.npoint = npoint;\r
     this.av = av;\r
     ToolTipManager.sharedInstance().registerComponent(this);\r
-    PaintRefresher.Register(this);\r
+    PaintRefresher.Register(this, av.alignment);\r
 \r
     //\r
     prefsize = getPreferredSize();\r
@@ -475,7 +475,7 @@ public class RotatableCanvas
       if (av.getSelectionGroup() != null)\r
       {\r
         av.getSelectionGroup().addOrRemove(found, true);\r
-        PaintRefresher.Refresh(this);\r
+        PaintRefresher.Refresh(this, av.alignment);\r
       }\r
       else\r
       {\r
index 1194d08..789fb3f 100755 (executable)
@@ -44,13 +44,15 @@ public class SeqCanvas
   int LABEL_WEST;\r
   int LABEL_EAST;\r
 \r
+\r
   public SeqCanvas(AlignViewport av)\r
   {\r
     this.av = av;\r
     fr = new FeatureRenderer(av);\r
     sr = new SequenceRenderer(av);\r
     setLayout(new BorderLayout());\r
-    PaintRefresher.Register(this);\r
+    PaintRefresher.Register(this, av.alignment);\r
+    setBackground(Color.white);\r
   }\r
 \r
   void drawNorthScale(Graphics g, int startx, int endx, int ypos)\r
@@ -212,16 +214,16 @@ public class SeqCanvas
    * NOTE 1: The av limits are set in setFont in this class and\r
    * in the adjustment listener in SeqPanel when the scrollbars move.\r
    */\r
+\r
+\r
+  // Set this to false to force a full panel paint\r
   public void paintComponent(Graphics g)\r
   {\r
-    g.setColor(Color.white);\r
-    g.fillRect(0, 0, getWidth(), getHeight());\r
-\r
-    if (fastPaint)\r
+    if (fastPaint  ||  getWidth() !=  g.getClipBounds().width\r
+                   ||  getHeight() != g.getClipBounds().height)\r
     {\r
       g.drawImage(img, 0, 0, this);\r
       fastPaint = false;\r
-\r
       return;\r
     }\r
 \r
index 52d137b..a643ab8 100755 (executable)
@@ -60,6 +60,7 @@ public class SeqPanel
   public SeqPanel(AlignViewport avp, AlignmentPanel p)\r
   {\r
     this.av = avp;\r
+    setBackground(Color.white);\r
 \r
     seqCanvas = new SeqCanvas(avp);\r
     setLayout(new BorderLayout());\r
@@ -160,9 +161,9 @@ public class SeqPanel
         doMouseEnteredDefineMode(evt);\r
       }\r
     });\r
-    repaint();\r
   }\r
 \r
+\r
   public void doMouseReleased(MouseEvent evt)\r
   {\r
     if (seqEditOccurred > -1)\r
@@ -176,7 +177,7 @@ public class SeqPanel
     editingSeqs = false;\r
     groupEditing = false;\r
 \r
-    ap.repaint();\r
+    seqCanvas.repaint();\r
   }\r
 \r
   public void doMousePressed(MouseEvent evt)\r
@@ -443,14 +444,14 @@ public class SeqPanel
 \r
     endEdit = res;\r
     lastres = res;\r
-    repaint();\r
+    seqCanvas.repaint();\r
   }\r
 \r
   public void drawChars(int seqstart, int seqend, int start)\r
   {\r
     seqCanvas.drawPanel(seqCanvas.gg, start, av.getEndRes(), seqstart,\r
                         seqend, av.getStartRes(), av.getStartSeq(), 0);\r
-    repaint();\r
+    seqCanvas.repaint();\r
   }\r
 \r
   public void insertChar(int j, int seq)\r
@@ -465,7 +466,7 @@ public class SeqPanel
     seqEditOccurred = seq;\r
 \r
     av.alignment.getWidth();\r
-    repaint();\r
+    seqCanvas.repaint();\r
   }\r
 \r
   void editOccurred(int i)\r
@@ -608,24 +609,26 @@ public class SeqPanel
 \r
     stretchGroup.getWidth();\r
 \r
-    repaint();\r
+    seqCanvas.repaint();\r
   }\r
 \r
   public void doMouseReleasedDefineMode(MouseEvent evt)\r
   {\r
-    mouseDragging = false;\r
+    if(mouseDragging)\r
+    {\r
+      stretchGroup.recalcConservation();\r
+      mouseDragging = false;\r
+    }\r
 \r
     if (stretchGroup == null)\r
     {\r
       return;\r
     }\r
 \r
-    stretchGroup.recalcConservation();\r
-\r
     if (stretchGroup.cs instanceof ClustalxColourScheme)\r
     {\r
-      stretchGroup.cs = new ClustalxColourScheme(stretchGroup.sequences,\r
-                                                 av.alignment.getWidth());\r
+      ( (ClustalxColourScheme) stretchGroup.cs).resetClustalX(stretchGroup.sequences,\r
+                                                     stretchGroup.getWidth());\r
     }\r
     else if (stretchGroup.cs instanceof ConservationColourScheme)\r
     {\r
@@ -644,7 +647,7 @@ public class SeqPanel
     changeEndRes = false;\r
     changeStartRes = false;\r
     stretchGroup = null;\r
-    repaint();\r
+    seqCanvas.repaint();\r
     ap.idPanel.repaint();\r
   }\r
 \r
@@ -743,7 +746,7 @@ public class SeqPanel
       scrollThread.setEvent(evt);\r
     }\r
 \r
-    repaint();\r
+    seqCanvas.repaint();\r
   }\r
 \r
   public void doMouseEnteredDefineMode(MouseEvent e)\r
index 0f74faf..2864eb4 100755 (executable)
@@ -65,7 +65,7 @@ public class TreeCanvas
     tree.findHeight(tree.getTopNode());\r
     longestName = label;\r
 \r
-    PaintRefresher.Register(this);\r
+    PaintRefresher.Register(this, av.alignment);\r
   }\r
 \r
   public void TreeSelectionChanged(Sequence sequence)\r
@@ -81,7 +81,7 @@ public class TreeCanvas
     selected.setEndRes(av.alignment.getWidth());\r
     selected.addOrRemove(sequence, true);\r
 \r
-    PaintRefresher.Refresh(this);\r
+    PaintRefresher.Refresh(this, av.alignment);\r
     repaint();\r
   }\r
 \r
@@ -568,11 +568,19 @@ public class TreeCanvas
             sequences.add( (Sequence)((SequenceNode) l.elementAt(j)).element());\r
           }\r
 \r
+          ColourSchemeI cs = ColourSchemeProperty.getColour(sequences, av.alignment.getWidth(),\r
+              ColourSchemeProperty.getColourName(av.getGlobalColourScheme()));\r
+\r
           SequenceGroup sg = new SequenceGroup(sequences, "TreeGroup",\r
-                           av.getGlobalColourScheme(), true, true,\r
+                           cs, true, true,\r
                            false, 0, av.alignment.getWidth());\r
 \r
 \r
+           ( (ResidueColourScheme) sg.cs).setThreshold(25);\r
+\r
+\r
+\r
+\r
           if (av.getGlobalColourScheme() instanceof ConservationColourScheme)\r
           {\r
             ConservationColourScheme ccs = (ConservationColourScheme) av.\r
@@ -594,7 +602,7 @@ public class TreeCanvas
       }\r
     }\r
 \r
-    PaintRefresher.Refresh(this);\r
+    PaintRefresher.Refresh(this, av.alignment);\r
     repaint();\r
   }\r
 \r