Now allows multi coloured HTML output
authoramwaterhouse <Andrew Waterhouse>
Fri, 10 Dec 2004 14:39:22 +0000 (14:39 +0000)
committeramwaterhouse <Andrew Waterhouse>
Fri, 10 Dec 2004 14:39:22 +0000 (14:39 +0000)
src/jalview/io/HTMLOutput.java

index 14a6ccb..b238383 100755 (executable)
@@ -13,7 +13,7 @@ public class HTMLOutput
 {\r
   SequenceRenderer sr = new SequenceRenderer(null);\r
 \r
-  public HTMLOutput(AlignmentI alignment, ColourSchemeI cs)\r
+  public HTMLOutput(AlignViewport av)\r
   {\r
     Color color;\r
     JFileChooser chooser = new JFileChooser(jalview.bin.Cache.LAST_DIRECTORY);\r
@@ -29,8 +29,7 @@ public class HTMLOutput
         out.println("<HTML>");\r
         out.println("<style type=\"text/css\">");\r
         out.println("<!--");\r
-        out.println("td {font-family: \"Courier New\", Courier, mono; font-size: medium;");\r
-        out.println("  font-size: medium; text-align: center; }");\r
+        out.println("td {font-family: \"Courier New\", Courier, mono;; font-size: medium; text-align: center; }");\r
         out.println("-->");\r
         out.println("</style>");\r
         out.println("<BODY>");\r
@@ -39,21 +38,37 @@ public class HTMLOutput
 \r
 \r
         //////////////\r
+        SequenceGroup group;\r
+        SequenceI seq;\r
+        ColourSchemeI cs;\r
+        AlignmentI alignment = av.getAlignment();\r
+        String r,g,b;\r
         for (int i = 0; i < alignment.getHeight(); i++)\r
         {\r
-          SequenceI seq = alignment.getSequenceAt(i);\r
+          seq = alignment.getSequenceAt(i);\r
+          group = alignment.findGroup( seq );\r
           out.println("<tr><td>"+seq.getName()+"&nbsp;&nbsp;</td>");\r
           for (int res = 0; res < seq.getLength(); res++)\r
           {\r
+            if(group!=null && group.getStartRes()<=res && group.getEndRes()>=res)\r
+              cs = group.cs;\r
+            else\r
+              cs = av.getGlobalColourScheme();\r
+\r
             color = sr.getResidueBoxColour(cs, seq, res);\r
 \r
             if(color.getRGB()<-1)\r
             {\r
-              out.println("<td bgcolor=\"#"\r
-                        + Integer.toHexString(color.getRed())\r
-                        + Integer.toHexString(color.getGreen())\r
-                        + Integer.toHexString(color.getBlue())\r
-                        + "\">"+seq.getCharAt(res)+"</td>");\r
+              r = Integer.toHexString(color.getRed());\r
+              if(r.length()<2)\r
+                r = "0"+r;\r
+              g = Integer.toHexString(color.getGreen());\r
+              if(g.length()<2)\r
+                g = "0"+g;\r
+              b = Integer.toHexString(color.getBlue());\r
+              if(b.length()<2)\r
+                b = "0"+b;\r
+              out.println("<td bgcolor=\"#"+ r + g + b + "\">"+seq.getCharAt(res)+"</td>");\r
             }\r
             else\r
               out.println("<td>"+seq.getCharAt(res)+"</td>");\r