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 jalview.api.ComplexAlignFile;
25 import jalview.api.FeaturesDisplayedI;
26 import jalview.datamodel.ColumnSelection;
27 import jalview.datamodel.SequenceI;
28 import jalview.schemes.ColourSchemeI;
30 import java.io.IOException;
31 import java.io.StringReader;
33 import org.jsoup.Jsoup;
34 import org.jsoup.nodes.Document;
35 import org.jsoup.nodes.Element;
37 public class HtmlFile extends AlignFile implements ComplexAlignFile
39 public static final String FILE_EXT = "html";
41 public static final String FILE_DESC = "HTML";
43 private ColourSchemeI colourScheme;
45 private boolean showSeqFeatures;
47 private ColumnSelection columnSelection;
49 private SequenceI[] hiddenSequences;
51 private FeaturesDisplayedI displayedFeatures;
58 public HtmlFile(FileParse source) throws IOException
63 public HtmlFile(String inFile, String type) throws IOException
69 public void parse() throws IOException
71 Element content = null;
75 StringBuilder htmlData = new StringBuilder();
77 while ((currentLine = nextLine()) != null)
79 htmlData.append(currentLine);
81 doc = Jsoup.parse(htmlData.toString());
82 } catch (OutOfMemoryError oom)
84 errormessage = "Not enough memory to process HTML document";
85 throw new IOException(errormessage);
90 content = doc.getElementById("seqData");
93 errormessage = "The html document is not embedded with BioJSON data";
94 throw new IOException(errormessage);
96 JSONFile jsonFile = new JSONFile().parse(new StringReader(content
98 this.seqs = jsonFile.getSeqs();
99 this.seqGroups = jsonFile.getSeqGroups();
100 this.annotations = jsonFile.getAnnotations();
101 this.showSeqFeatures = jsonFile.isShowSeqFeatures();
102 this.colourScheme = jsonFile.getColourScheme();
103 this.hiddenSequences = jsonFile.getHiddenSequences();
104 this.columnSelection = jsonFile.getColumnSelection();
105 this.displayedFeatures = jsonFile.getDisplayedFeatures();
106 } catch (Exception e)
114 public String print()
116 throw new UnsupportedOperationException(
117 "Print method of HtmlFile is not supported!");
120 public boolean isShowSeqFeatures()
122 return showSeqFeatures;
125 public void setShowSeqFeatures(boolean showSeqFeatures)
127 this.showSeqFeatures = showSeqFeatures;
130 public ColourSchemeI getColourScheme()
135 public void setColourScheme(ColourSchemeI colourScheme)
137 this.colourScheme = colourScheme;
140 public ColumnSelection getColumnSelection()
142 return columnSelection;
145 public void setColumnSelection(ColumnSelection columnSelection)
147 this.columnSelection = columnSelection;
150 public SequenceI[] getHiddenSequences()
152 return hiddenSequences;
155 public void setHiddenSequences(SequenceI[] hiddenSequences)
157 this.hiddenSequences = hiddenSequences;
161 public FeaturesDisplayedI getDisplayedFeatures()
163 return displayedFeatures;