2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
24 import java.io.IOException;
26 import org.jsoup.Jsoup;
27 import org.jsoup.nodes.Document;
28 import org.jsoup.nodes.Element;
30 import jalview.api.ComplexAlignFile;
31 import jalview.datamodel.ColumnSelection;
32 import jalview.datamodel.SequenceI;
33 import jalview.schemes.ColourSchemeI;
35 public class HtmlFile extends AlignFile implements ComplexAlignFile
37 public static final String FILE_EXT = "html";
39 public static final String FILE_DESC = "HTML";
41 private ColourSchemeI colourScheme;
43 private boolean showSeqFeatures;
45 private ColumnSelection columnSelection;
47 private SequenceI[] hiddenSequences;
54 public HtmlFile(FileParse source) throws IOException
59 public HtmlFile(String inFile, String type) throws IOException
65 public void parse() throws IOException
69 StringBuilder htmlData = new StringBuilder();
71 while ((currentLine = nextLine()) != null)
73 htmlData.append(currentLine);
76 Document doc = Jsoup.parse(htmlData.toString());
77 Element content = doc.getElementById("seqData");
78 String alignmentJsonString = content.val();
80 JSONFile jsonFile = new JSONFile().parse(alignmentJsonString);
81 this.seqs = jsonFile.getSeqs();
82 this.seqGroups = jsonFile.getSeqGroups();
83 this.annotations = jsonFile.getAnnotations();
84 this.showSeqFeatures = jsonFile.isShowSeqFeatures();
85 this.colourScheme = jsonFile.getColourScheme();
86 this.hiddenSequences = jsonFile.getHiddenSequences();
87 this.columnSelection = jsonFile.getColumnSelection();
98 throw new UnsupportedOperationException(
99 "Print method of HtmlFile is not supported!");
102 public boolean isShowSeqFeatures()
104 return showSeqFeatures;
107 public void setShowSeqFeatures(boolean showSeqFeatures)
109 this.showSeqFeatures = showSeqFeatures;
112 public ColourSchemeI getColourScheme()
117 public void setColourScheme(ColourSchemeI colourScheme)
119 this.colourScheme = colourScheme;
122 public ColumnSelection getColumnSelection()
124 return columnSelection;
127 public void setColumnSelection(ColumnSelection columnSelection)
129 this.columnSelection = columnSelection;
132 public SequenceI[] getHiddenSequences()
134 return hiddenSequences;
137 public void setHiddenSequences(SequenceI[] hiddenSequences)
139 this.hiddenSequences = hiddenSequences;