3 import jalview.gui.*;
\r
4 import jalview.datamodel.*;
\r
5 import jalview.schemes.*;
\r
7 import javax.swing.*;
\r
12 public class HTMLOutput
\r
16 public HTMLOutput(AlignViewport av)
\r
18 SequenceRenderer sr = new SequenceRenderer(av);
\r
20 JFileChooser chooser = new JFileChooser(jalview.bin.Cache.LAST_DIRECTORY);
\r
21 chooser.setDialogTitle("Save as HTML");
\r
22 chooser.setToolTipText("Save");
\r
23 int value = chooser.showSaveDialog(null);
\r
24 if(value == JFileChooser.APPROVE_OPTION)
\r
26 String choice = chooser.getSelectedFile().getPath();
\r
27 jalview.bin.Cache.LAST_DIRECTORY = choice;
\r
29 PrintWriter out = new java.io.PrintWriter(new java.io.FileWriter(choice));
\r
30 out.println("<HTML>");
\r
31 out.println("<style type=\"text/css\">");
\r
32 out.println("<!--");
\r
33 out.print("td {font-family: \""+av.getFont().getFamily()+"\", \""+av.getFont().getName()+ "\", mono; "
\r
34 +"font-size: "+av.getFont().getSize()+"px; ");
\r
37 if (av.getFont().getStyle() == Font.BOLD)
\r
38 out.print("font-weight: BOLD; ");
\r
40 if (av.getFont().getStyle() == Font.ITALIC)
\r
41 out.print("font-style: italic; ");
\r
43 out.println("text-align: center; }");
\r
46 out.println("</style>");
\r
47 out.println("<BODY>");
\r
48 out.println("<table border=\"1\"><tr><td>\n");
\r
49 out.println("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n");
\r
53 SequenceGroup group;
\r
56 AlignmentI alignment = av.getAlignment();
\r
58 for (int i = 0; i < alignment.getHeight(); i++)
\r
60 seq = alignment.getSequenceAt(i);
\r
61 group = alignment.findGroup( seq );
\r
62 out.println("<tr><td nowrap>"+seq.getDisplayId()+" </td>");
\r
63 for (int res = 0; res < seq.getLength(); res++)
\r
65 if(group!=null && group.getStartRes()<=res && group.getEndRes()>=res)
\r
68 cs = av.getGlobalColourScheme();
\r
71 color = sr.getResidueBoxColour(cs, seq, res);
\r
73 if(color.getRGB()<-1)
\r
75 r = Integer.toHexString(color.getRed());
\r
78 g = Integer.toHexString(color.getGreen());
\r
81 b = Integer.toHexString(color.getBlue());
\r
84 out.println("<td bgcolor=\"#"+ r + g + b + "\">"+seq.getCharAt(res)+"</td>");
\r
87 out.println("<td>"+seq.getCharAt(res)+"</td>");
\r
91 out.println("</tr>");
\r
94 out.println("</table>");
\r
95 out.println("</td></tr></table>\n</body>\n</html>");
\r
99 jalview.util.BrowserLauncher.openURL( "file:///"+choice );
\r
101 catch(Exception ex){ex.printStackTrace();}
\r