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;
25 import java.util.List;
27 import org.jsoup.Jsoup;
28 import org.jsoup.nodes.Document;
29 import org.jsoup.nodes.Element;
31 import jalview.api.AlignViewControllerGuiI;
32 import jalview.schemes.ColourSchemeI;
34 public class HtmlFile extends AlignFile
36 public static final String FILE_EXT = "html";
38 public static final String FILE_DESC = "HTML";
40 private ColourSchemeI colourScheme;
42 private boolean showSeqFeatures;
44 private List<int[]> hiddenColumns;
51 public HtmlFile(FileParse source) throws IOException
56 public HtmlFile(String inFile, String type) throws IOException
62 public void parse() throws IOException
66 StringBuilder htmlData = new StringBuilder();
68 while ((currentLine = nextLine()) != null)
70 htmlData.append(currentLine);
73 Document doc = Jsoup.parse(htmlData.toString());
74 Element content = doc.getElementById("seqData");
75 String alignmentJsonString = content.val();
77 JSONFile jsonFile = new JSONFile().parse(alignmentJsonString);
78 this.seqs = jsonFile.getSeqs();
79 this.seqGroups = jsonFile.getSeqGroups();
80 this.annotations = jsonFile.getAnnotations();
81 this.showSeqFeatures = jsonFile.isShowSeqFeatures();
82 this.colourScheme = jsonFile.getColourScheme();
83 this.hiddenColumns = jsonFile.getHiddenColumns();
90 public void applySettingsToAlignmentView(AlignViewControllerGuiI avc)
92 avc.setShowSeqFeatures(isShowSeqFeatures());
93 avc.changeColour(getColourScheme());
94 avc.setMenusForViewport();
95 avc.hideColumns(hiddenColumns);
96 avc.syncHiddenSequences();
100 public String print()
102 throw new UnsupportedOperationException(
103 "Print method of HtmlFile is not supported!");
106 public boolean isShowSeqFeatures()
108 return showSeqFeatures;
111 public void setShowSeqFeatures(boolean showSeqFeatures)
113 this.showSeqFeatures = showSeqFeatures;
116 public ColourSchemeI getColourScheme()
121 public void setColourScheme(ColourSchemeI colourScheme)
123 this.colourScheme = colourScheme;