Move drawing out of repaint method
authoramwaterhouse <Andrew Waterhouse>
Thu, 4 Nov 2004 18:00:13 +0000 (18:00 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 4 Nov 2004 18:00:13 +0000 (18:00 +0000)
src/jalview/gui/ScorePanel.java

index d2b472c..b4bb3c9 100755 (executable)
@@ -43,11 +43,18 @@ public class ScorePanel extends JPanel
        this.setToolTipText(null);\r
   }\r
 \r
+\r
+\r
   public void paintComponent(Graphics g)\r
   {\r
-    setPreferredSize(new Dimension( this.getWidth(), 80));\r
+   setPreferredSize(new Dimension( this.getWidth(), 80));\r
+   drawScorePanel(g, getWidth(), av.getStartRes(),  av.getChunkWidth());\r
+  }\r
+\r
+  public void drawScorePanel(Graphics g, int width, int startRes, int length)\r
+  {\r
    g.setColor(Color.white);\r
-   g.fillRect(0, 0, this.getWidth(), 80);\r
+   g.fillRect(0, 0,width, 80);\r
    g.setColor(Color.blue);\r
    g.setFont(av.getFont());\r
 \r
@@ -58,7 +65,7 @@ public class ScorePanel extends JPanel
    char character;\r
 \r
 \r
-   int i=0, iSize = av.getChunkWidth();\r
+   int i=0, iSize = length;\r
    if(iSize > freq.size())\r
      iSize=freq.size();\r
 \r
@@ -66,7 +73,7 @@ public class ScorePanel extends JPanel
    {\r
      g.setColor(Color.blue);\r
 \r
-     Hashtable hash = (Hashtable) freq.elementAt(i+av.getStartRes());\r
+     Hashtable hash = (Hashtable) freq.elementAt(i+startRes);\r
      if(hash.containsKey("maxResidue"))\r
             characters = hash.get("maxResidue").toString();\r
      else\r