--- /dev/null
+package jalview.datamodel;
+
+import jalview.gui.AlignExportSettings;
+
+public class AlignmentExportData
+{
+ private AlignmentI alignment;
+
+ private String[] omitHidden;
+
+ private int[] startEnd;
+
+ private AlignExportSettings settings;
+
+ public AlignmentExportData(AlignmentI align, String[] ommit,
+ int[] startEnd, AlignExportSettings settings)
+ {
+ this.alignment = align;
+ this.omitHidden = ommit;
+ this.startEnd = startEnd;
+ this.settings = settings;
+ }
+
+ public AlignmentI getAlignment()
+ {
+ return alignment;
+ }
+
+ public void setAlignment(AlignmentI alignment)
+ {
+ this.alignment = alignment;
+ }
+
+ public String[] getOmitHidden()
+ {
+ return omitHidden;
+ }
+
+ public void setOmitHidden(String[] omitHidden)
+ {
+ this.omitHidden = omitHidden;
+ }
+
+ public int[] getStartEndPostions()
+ {
+ return startEnd;
+ }
+
+ public void setStartEndPostions(int[] startEnd)
+ {
+ this.startEnd = startEnd;
+ }
+
+ public AlignExportSettings getSettings()
+ {
+ return settings;
+ }
+
+ public void setSettings(AlignExportSettings settings)
+ {
+ this.settings = settings;
+ }
+}
import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentExportData;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentOrder;
import jalview.datamodel.AlignmentView;
return false;
}
- ExportData exportData = getAlignmentForExport(format);
- FormatAdapter f = new FormatAdapter(alignPanel);
+ AlignmentExportData exportData = getAlignmentForExport(format, viewport);
+ if (exportData.getSettings().isCancelled())
+ {
+ return false;
+ }
+ FormatAdapter f = new FormatAdapter(alignPanel,
+ exportData.getSettings());
String output = f.formatSequences(format,
exportData.getAlignment(), // class cast exceptions will
// occur in the distant future
protected void outputText_actionPerformed(ActionEvent e)
{
- ExportData exportData = getAlignmentForExport(e.getActionCommand());
+ AlignmentExportData exportData = getAlignmentForExport(
+ e.getActionCommand(), viewport);
if (exportData.getSettings().isCancelled())
{
return;
}
- public ExportData getAlignmentForExport(String exportFomat)
+ public static AlignmentExportData getAlignmentForExport(String exportFomat,
+ AlignViewportI viewport)
{
AlignmentI alignmentToExport = null;
String[] omitHidden = null;
alignmentStartEnd = getStartEnd(alignmentStartEnd, viewport
.getColumnSelection().getHiddenColumns());
}
- return new ExportData(alignmentToExport, omitHidden, alignmentStartEnd,
+ AlignmentExportData ed = new AlignmentExportData(alignmentToExport, omitHidden, alignmentStartEnd,
settings);
+ return ed;
}
private static int[] getStartEnd(int[] aligmentStartEnd,
}
}
- public class ExportData
- {
- private AlignmentI alignment;
-
- private String[] omitHidden;
-
- private int[] startEnd;
-
- private AlignExportSettings settings;
-
- public ExportData(AlignmentI align, String[] ommit, int[] startEnd,
- AlignExportSettings settings)
- {
- this.alignment = align;
- this.omitHidden = ommit;
- this.startEnd = startEnd;
- this.settings = settings;
- }
-
- public AlignmentI getAlignment()
- {
- return alignment;
- }
-
- public void setAlignment(AlignmentI alignment)
- {
- this.alignment = alignment;
- }
-
- public String[] getOmitHidden()
- {
- return omitHidden;
- }
-
- public void setOmitHidden(String[] omitHidden)
- {
- this.omitHidden = omitHidden;
- }
-
- public int[] getStartEndPostions()
- {
- return startEnd;
- }
-
- public void setStartEndPostions(int[] startEnd)
- {
- this.startEnd = startEnd;
- }
-
- public AlignExportSettings getSettings()
- {
- return settings;
- }
-
- public void setSettings(AlignExportSettings settings)
- {
- this.settings = settings;
- }
- }
-
}
class PrintThread extends Thread
private AlignmentI buildAlignmentFrom(AlignFile alignFile2)
{
// Standard boilerplate for creating alignment from parser
- alignFile.configureForView(viewpanel);
+ // alignFile.configureForView(viewpanel);
AlignmentI al = new Alignment(alignFile.getSeqsAsArray());
{
throw new Exception(MessageManager.getString("error.implementation_error_unknown_file_format_string"));
}
+
afile.setNewlineString(newline);
afile.addJVSuffix(jvsuffix);
package jalview.io;
import jalview.api.AlignmentViewPanel;
+import jalview.datamodel.AlignmentExportData;
import jalview.exceptions.NoFileSelectedException;
import jalview.json.binding.v1.BioJSReleasePojo;
import jalview.json.binding.v1.BioJSRepositoryPojo;
try
{
String outputFile = getOutputFile();
- String jalviewAlignmentJson = JSONFile.getJSONData(ap);
+ // String jalviewAlignmentJson = JSONFile.getJSONData(ap);
+ AlignmentExportData exportData = jalview.gui.AlignFrame
+ .getAlignmentForExport(
+ JSONFile.FILE_DESC, ap.getAlignViewport());
+ if (exportData.getSettings().isCancelled())
+ {
+ return;
+ }
+ String jalviewAlignmentJson = new FormatAdapter(ap,
+ exportData.getSettings()).formatSequences(JSONFile.FILE_DESC,
+ exportData.getAlignment(), exportData.getOmitHidden(),
+ exportData.getStartEndPostions(), ap.getAlignViewport()
+ .getColumnSelection());
+
String bioJSTemplateString = getBioJsTemplateAsString();
String generatedBioJsWithJalviewAlignmentAsJson = bioJSTemplateString
.replaceAll(
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
-import jalview.gui.AlignmentPanel;
/**
* Additional formatting methods used by the application in a number of places.
init();
}
- public FormatAdapter(AlignmentPanel alignPanel,
+ public FormatAdapter(AlignmentViewPanel alignPanel,
AlignExportSettingI settings)
{
super(alignPanel, settings);
package jalview.io;
import jalview.api.FeatureRenderer;
+import jalview.datamodel.AlignmentExportData;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignViewport;
import jalview.gui.AlignmentPanel;
}
printUnwrapped(aDimension.getWidth(), aDimension.getHeight(), 0, g1,
g2);
- FileOutputStream out = new FileOutputStream(file);
String titleSvgData = g1.getSVGDocument();
String alignSvgData = g2.getSVGDocument();
- String jsonData = JSONFile.getJSONData(ap);
+
+ AlignmentExportData exportData = ap.alignFrame.getAlignmentForExport(
+ JSONFile.FILE_DESC, av);
+ if (exportData.getSettings().isCancelled())
+ {
+ return;
+ }
+ String jsonData = new FormatAdapter(ap, exportData.getSettings())
+ .formatSequences(JSONFile.FILE_DESC, exportData
+ .getAlignment(), exportData.getOmitHidden(),
+ exportData.getStartEndPostions(), ap
+ .getAlignViewport().getColumnSelection());
+
+ // String jsonData = JSONFile.getJSONData(ap);
String htmlData = getHtml(titleSvgData, alignSvgData, jsonData);
+ FileOutputStream out = new FileOutputStream(file);
out.write(htmlData.getBytes());
out.flush();
out.close();
public void configureForView(AlignmentViewPanel avpanel)
{
super.configureForView(avpanel);
- if (isExporting())
- {
- setViewport(avpanel.getAlignViewport());
- seqGroups = avpanel.getAlignment().getGroups();
- setDisplayedFeatures(getViewport().getFeaturesDisplayed());
- fr = avpanel.cloneFeatureRenderer();
- for (SequenceI seq : getViewport().getAlignment().getSequences())
- {
- seqs.add(seq);
- }
+ seqGroups = avpanel.getAlignment().getGroups();
+ setDisplayedFeatures(getViewport().getFeaturesDisplayed());
+ fr = avpanel.cloneFeatureRenderer();
- // Add non auto calculated annotation to AlignFile
- for (AlignmentAnnotation annot : getViewport().getAlignment()
- .getAlignmentAnnotation())
+ // Add non auto calculated annotation to AlignFile
+ for (AlignmentAnnotation annot : getViewport().getAlignment()
+ .getAlignmentAnnotation())
+ {
+ if (annot != null && !annot.autoCalculated)
{
- if (annot != null && !annot.autoCalculated)
+ if (!annot.visible)
{
- if (annot.label.equals("PDB.CATempFactor"))
- {
- continue;
- }
- annotations.add(annot);
+ continue;
}
+ annotations.add(annot);
}
-
- globalColorScheme = ColourSchemeProperty.getColourName(getViewport()
- .getGlobalColourScheme());
- setDisplayedFeatures(getViewport().getFeaturesDisplayed());
- showSeqFeatures = getViewport().isShowSequenceFeatures();
}
- }
+ globalColorScheme = ColourSchemeProperty.getColourName(getViewport()
+ .getGlobalColourScheme());
+ setDisplayedFeatures(getViewport().getFeaturesDisplayed());
+ showSeqFeatures = getViewport().isShowSequenceFeatures();
-
- public static String getJSONData(AlignmentViewPanel av)
- {
- JSONFile jsonFile = new JSONFile();
- jsonFile.configureForView(av);
- String jsonString = jsonFile.print();
- return jsonString;
}
public boolean isShowSeqFeatures()