JAL_793 implemented embeding source data in exported html
[jalview.git] / src / jalview / io / HtmlFile.java
1 package jalview.io;
2
3 import jalview.gui.AlignFrame;
4 import jalview.schemes.ColourSchemeI;
5
6 import java.io.IOException;
7
8 import org.jsoup.Jsoup;
9 import org.jsoup.nodes.Document;
10 import org.jsoup.nodes.Element;
11
12 public class HtmlFile extends AlignFile
13 {
14   public static final String FILE_EXT = "html";
15
16   public static final String FILE_DESC = "HTML";
17
18   private ColourSchemeI cs;
19
20   public HtmlFile()
21   {
22     super();
23   }
24
25   public HtmlFile(FileParse source) throws IOException
26   {
27     super(source);
28   }
29
30   public HtmlFile(String inFile, String type) throws IOException
31   {
32     super(inFile, type);
33   }
34
35   @Override
36   public void parse() throws IOException
37   {
38     try
39     {
40       StringBuilder htmlData = new StringBuilder();
41       String currentLine;
42       while ((currentLine = nextLine()) != null)
43       {
44         htmlData.append(currentLine);
45       }
46
47       Document doc = Jsoup.parse(htmlData.toString());
48       Element content = doc.getElementById("seqData");
49       String alignmentJsonString = content.val();
50
51       JSONFile jsonFile = new JSONFile().parse(alignmentJsonString);
52       seqs = jsonFile.seqs;
53       seqGroups = jsonFile.seqGroups;
54       annotations = jsonFile.annotations;
55     } catch (Exception e)
56     {
57       e.printStackTrace();
58     }
59   }
60
61   public void LoadAlignmentFeatures(AlignFrame af)
62   {
63     af.setShowSeqFeatures(JSONFile.isSeqFeaturesEnabled());
64     af.changeColour(JSONFile.getColourScheme());
65     af.setMenusForViewport();
66   }
67
68
69   @Override
70   public String print()
71   {
72     throw new UnsupportedOperationException(
73             "Print method of HtmlFile not yet supported!");
74   }
75
76 }