Reduced arguments for speed
[jalview.git] / src / jalview / appletgui / SequenceRenderer.java
index c413588..3f87b02 100755 (executable)
@@ -33,6 +33,7 @@ public class SequenceRenderer
   SequenceGroup[] allGroups = null;\r
   Color resBoxColour;\r
   Graphics graphics;\r
+  boolean forOverview = false;\r
 \r
   public SequenceRenderer(AlignViewport av)\r
   {\r
@@ -44,11 +45,24 @@ public class SequenceRenderer
     renderGaps = b;\r
   }\r
 \r
-  public Color getResidueBoxColour(ColourSchemeI cs, SequenceI seq, int i)\r
+  public Color getResidueBoxColour(SequenceI seq, int i)\r
   {\r
-    getBoxColour(cs, seq, i);\r
+    allGroups = av.alignment.findAllGroups(seq);\r
+\r
+    if (inCurrentSequenceGroup(i))\r
+    {\r
+      if (currentSequenceGroup.getDisplayBoxes())\r
+      {\r
+        getBoxColour(currentSequenceGroup.cs, seq, i);\r
+      }\r
+    }\r
+    else if (av.getShowBoxes())\r
+    {\r
+        getBoxColour(av.globalColourScheme, seq, i);\r
+    }\r
+\r
     return resBoxColour;\r
-  }\r
+    }\r
 \r
   void getBoxColour(ColourSchemeI cs, SequenceI seq, int i)\r
   {\r
@@ -56,35 +70,45 @@ public class SequenceRenderer
     {\r
       resBoxColour = cs.findColour(seq.getSequence(i, i + 1), i);\r
     }\r
+    else if(forOverview && !jalview.util.Comparison.isGap(seq.getCharAt(i)))\r
+    {\r
+        resBoxColour = Color.lightGray;\r
+    }\r
     else\r
     {\r
       resBoxColour = Color.white;\r
     }\r
+\r
+  }\r
+\r
+  public Color findSequenceColour(SequenceI seq, int i)\r
+  {\r
+    allGroups = av.alignment.findAllGroups(seq);\r
+    drawBoxes(seq, i,i, 0);\r
+    return resBoxColour;\r
   }\r
 \r
   public void drawSequence(Graphics g, SequenceI seq, SequenceGroup[] sg,\r
-                           int start, int end, int x1, int y1, int width,\r
-                           int height)\r
+                           int start, int end,  int y1)\r
   {\r
     allGroups = sg;\r
 \r
     graphics = g;\r
 \r
-    drawBoxes(seq, start, end, x1, y1, (int) width, height);\r
+    drawBoxes(seq, start, end,  y1);\r
 \r
     fm = g.getFontMetrics();\r
-    drawText(seq, start, end, x1, y1, (int) width, height);\r
+    drawText(seq, start, end, y1);\r
 \r
   }\r
 \r
-  public void drawBoxes(SequenceI seq, int start, int end, int x1, int y1,\r
-                        int width, int height)\r
+  public void drawBoxes(SequenceI seq, int start, int end,  int y1)\r
   {\r
     int i = start;\r
     int length = seq.getLength();\r
 \r
     int curStart = -1;\r
-    int curWidth = width;\r
+    int curWidth = av.charWidth;\r
 \r
     Color tempColour = null;\r
     while (i <= end)\r
@@ -110,46 +134,45 @@ public class SequenceRenderer
       {\r
         if (tempColour != null)\r
         {\r
-          graphics.fillRect(x1 + width * (curStart - start), y1, curWidth,\r
-                            height);\r
+          graphics.fillRect(av.charWidth * (curStart - start), y1, curWidth,\r
+                            av.charHeight);\r
         }\r
         graphics.setColor(resBoxColour);\r
 \r
         curStart = i;\r
-        curWidth = width;\r
+        curWidth = av.charWidth;\r
         tempColour = resBoxColour;\r
 \r
       }\r
       else\r
       {\r
-        curWidth += width;\r
+        curWidth += av.charWidth;\r
       }\r
 \r
       i++;\r
     }\r
 \r
-    graphics.fillRect(x1 + width * (curStart - start), y1, curWidth, height);\r
+    graphics.fillRect(av.charWidth * (curStart - start), y1, curWidth, av.charHeight);\r
   }\r
 \r
-  public void drawText(SequenceI seq, int start, int end, int x1, int y1,\r
-                       int width, int height)\r
+  public void drawText(SequenceI seq, int start, int end, int y1)\r
   {\r
-    int pady = height / 5;\r
-    int charOffset = 0;\r
-    char s=' ';\r
-    // Need to find the sequence position here.\r
 \r
-    String sequence = seq.getSequence();\r
+    y1 += av.charHeight - av.charHeight / 5;  // height/5 replaces pady\r
+\r
+    int charOffset = 0;\r
 \r
+    // Need to find the sequence position here.\r
     if(end+1>=seq.getLength())\r
           end = seq.getLength()-1;\r
 \r
+    char s = ' ';\r
+\r
     for (int i = start; i <= end; i++)\r
     {\r
       graphics.setColor(Color.black);\r
 \r
-      s = sequence.charAt(i);\r
-\r
+      s = seq.getCharAt(i);\r
       if (!renderGaps && jalview.util.Comparison.isGap(s))\r
       {\r
         continue;\r
@@ -189,10 +212,10 @@ public class SequenceRenderer
         }\r
       }\r
 \r
-      charOffset = (width - fm.charWidth(s)) / 2;\r
+      charOffset = (av.charWidth - fm.charWidth(s)) / 2;\r
       graphics.drawString(String.valueOf(s),\r
-                          charOffset + x1 + width * (i - start),\r
-                          y1 + height - pady);\r
+                         charOffset + av.charWidth * (i - start),\r
+                        y1 );\r
     }\r
 \r
   }\r