*/
package jalview.io;
-import jalview.api.AlignExportSettingI;
+import jalview.api.AlignExportSettingsI;
+import jalview.datamodel.AlignExportSettingsAdapter;
import jalview.datamodel.AlignmentExportData;
import jalview.exceptions.NoFileSelectedException;
import jalview.gui.AlignmentPanel;
protected File generatedFile;
+ String _bioJson = null;
+
+ /**
+ * Constructor given an alignment panel (which should not be null)
+ *
+ * @param ap
+ */
public HTMLOutput(AlignmentPanel ap)
{
- if (ap != null)
- {
- this.ap = ap;
- this.pIndicator = ap.alignFrame;
- }
+ this.ap = ap;
+ this.pIndicator = ap.alignFrame;
}
+ /**
+ * Gets the BioJSON data as a string, with lazy evaluation (first time called
+ * only). If the output format is configured not to embed BioJSON, returns
+ * null.
+ *
+ * @return
+ */
public String getBioJSONData()
{
- return getBioJSONData(null);
- }
-
- public String getBioJSONData(AlignExportSettingI exportSettings)
- {
if (!isEmbedData())
{
return null;
}
- if (exportSettings == null)
+ if (_bioJson == null)
{
- exportSettings = new AlignExportSettingI()
- {
- @Override
- public boolean isExportHiddenSequences()
- {
- return true;
- }
-
- @Override
- public boolean isExportHiddenColumns()
- {
- return true;
- }
-
- @Override
- public boolean isExportAnnotations()
- {
- return true;
- }
-
- @Override
- public boolean isExportFeatures()
- {
- return true;
- }
-
- @Override
- public boolean isExportGroups()
- {
- return true;
- }
-
- @Override
- public boolean isCancelled()
- {
- return false;
- }
- };
+ AlignExportSettingsI options = new AlignExportSettingsAdapter(true);
+ AlignmentExportData exportData = ap.getAlignViewport()
+ .getAlignExportData(options);
+ _bioJson = new FormatAdapter(ap, options).formatSequences(
+ FileFormat.Json, exportData.getAlignment(),
+ exportData.getOmitHidden(), exportData.getStartEndPostions(),
+ ap.getAlignViewport().getAlignment().getHiddenColumns());
}
- AlignmentExportData exportData = jalview.gui.AlignFrame
- .getAlignmentForExport(FileFormat.Json, ap.getAlignViewport(),
- exportSettings);
- String bioJSON = new FormatAdapter(ap, exportData.getSettings())
- .formatSequences(FileFormat.Json, exportData.getAlignment(),
- exportData.getOmitHidden(),
- exportData.getStartEndPostions(), ap.getAlignViewport()
- .getAlignment().getHiddenColumns());
- return bioJSON;
+
+ return _bioJson;
}
/**