Highlight from alignment
[jalview.git] / src / jalview / gui / SequenceRenderer.java
index b961b2c..7070e5d 100755 (executable)
@@ -23,6 +23,7 @@ import jalview.datamodel.*;
 import jalview.schemes.*;\r
 \r
 import java.awt.*;\r
+import java.awt.image.BufferedImage;\r
 \r
 \r
 /**\r
@@ -77,6 +78,23 @@ public class SequenceRenderer
         return resBoxColour;\r
     }\r
 \r
+    BufferedImage bi;\r
+    public Color findSequenceColour(Color initialCol, SequenceI seq, int i)\r
+    {\r
+      if (bi == null)\r
+        bi = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);\r
+\r
+      bi.getGraphics().setColor(initialCol);\r
+      bi.getGraphics().fillRect(0, 0, 1, 1);\r
+      allGroups = av.alignment.findAllGroups(seq);\r
+      graphics = bi.getGraphics();\r
+\r
+      drawBoxes(seq, i,i, 0, 0, 1,1);\r
+\r
+      return new Color(bi.getRGB(0, 0));\r
+    }\r
+\r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -136,72 +154,59 @@ public class SequenceRenderer
     public void drawBoxes(SequenceI seq, int start, int end, int x1, int y1,\r
         int width, int height)\r
     {\r
-        int i = start;\r
-        int length = seq.getLength();\r
+      int i = start;\r
+      int length = seq.getLength();\r
 \r
-        int curStart = -1;\r
-        int curWidth = width;\r
+      int curStart = -1;\r
+      int curWidth = width;\r
 \r
-        Color tempColour = null;\r
+      Color tempColour = null;\r
 \r
-        while (i <= end)\r
-        {\r
-          resBoxColour = Color.white;\r
+      while (i <= end)\r
+      {\r
+        resBoxColour = Color.white;\r
 \r
-          if (i < length)\r
+        if (i < length)\r
+        {\r
+          if (inCurrentSequenceGroup(i))\r
           {\r
-            if (inCurrentSequenceGroup(i))\r
+            if (currentSequenceGroup.getDisplayBoxes())\r
             {\r
-              if (currentSequenceGroup.getDisplayBoxes())\r
-              {\r
-                getBoxColour(currentSequenceGroup.cs, seq, i);\r
-              }\r
+              getBoxColour(currentSequenceGroup.cs, seq, i);\r
             }\r
-            else if (av.getShowBoxes())\r
-            {\r
-              getBoxColour(av.getGlobalColourScheme(), seq, i);\r
-            }\r
-\r
+          }\r
+          else if (av.getShowBoxes())\r
+          {\r
+            getBoxColour(av.getGlobalColourScheme(), seq, i);\r
           }\r
 \r
-            if (resBoxColour != tempColour)\r
-            {\r
-                if (tempColour != null)\r
-                {\r
-                  int xxx = x1 + (int) (av.charWidth * (curStart - start));\r
-                  if (width != av.charWidth)\r
-                  {\r
-                    xxx = x1 + (int) (av.charWidth * (curStart - start)) / 3;\r
-                  }\r
-\r
-\r
-                    graphics.fillRect(xxx, y1,\r
-                        curWidth, height);\r
-                }\r
+        }\r
 \r
-                graphics.setColor(resBoxColour);\r
+          if (resBoxColour != tempColour)\r
+          {\r
+              if (tempColour != null)\r
+              {\r
+                  graphics.fillRect(x1 + (width * (curStart - start)), y1,\r
+                      curWidth, height);\r
+              }\r
 \r
-                curStart = i;\r
-                curWidth = width;\r
-                tempColour = resBoxColour;\r
-            }\r
-            else\r
-            {\r
-                curWidth += width;\r
-            }\r
+              graphics.setColor(resBoxColour);\r
 \r
-            i++;\r
-        }\r
+              curStart = i;\r
+              curWidth = width;\r
+              tempColour = resBoxColour;\r
+          }\r
+          else\r
+          {\r
+              curWidth += width;\r
+          }\r
 \r
-        int xxx = x1 + (int) (av.charWidth * (curStart - start));\r
-        if (width != av.charWidth)\r
-        {\r
-          xxx = x1 + (int) (av.charWidth * (curStart - start)) / 3;\r
-        }\r
+          i++;\r
+      }\r
 \r
+      graphics.fillRect(x1 + (width * (curStart - start)), y1, curWidth,\r
+          height);\r
 \r
-        graphics.fillRect(xxx, y1, curWidth,\r
-            height);\r
     }\r
 \r
     /**\r
@@ -276,14 +281,9 @@ public class SequenceRenderer
             }\r
 \r
             charOffset = (width - fm.charWidth(s)) / 2;\r
+            graphics.drawString(String.valueOf(s),\r
+                charOffset + x1 + (int)(width * (i - start)), (y1 + height) - pady);\r
 \r
-            int xxx = charOffset + x1 + (int)(av.charWidth * (i - start));\r
-            if(width != av.charWidth)\r
-            {\r
-              xxx = charOffset + x1 + (int)(av.charWidth * (i - start))/3;\r
-            }\r
-\r
-            graphics.drawString(String.valueOf(s),xxx, (y1 + height) - pady);\r
         }\r
     }\r
 \r