*/
void setFollowHighlight(boolean b);
+ /**
+ * Returns a FeatureRenderer instance
+ *
+ * @return
+ */
public FeatureRenderer getFeatureRenderer();
+ /**
+ * Sets a FeatureRenderer for a viewport
+ *
+ * @param featureRenderer
+ */
public void setFeatureRenderer(FeatureRenderer featureRenderer);
- public boolean isIncludeHiddenRegion();
+ /**
+ * Returns Settings for exporting an Alignment
+ *
+ * @return
+ */
+ public AlignExportSettingI getExportSettings();
}
FeatureRenderer fr = this.alignPanel.cloneFeatureRenderer();
viewport.setFeatureRenderer(fr);
- viewport.setIncludeHiddenRegion(false);
cap.setText(new AppletFormatAdapter(viewport).formatSequences(
e.getActionCommand(), viewport.getAlignment(),
viewport.getShowJVSuffix()));
import java.awt.Font;
import jalview.analysis.NJTree;
+import jalview.api.AlignExportSettingI;
import jalview.api.AlignViewportI;
import jalview.api.FeatureRenderer;
import jalview.bin.JalviewLite;
private FeatureRenderer featureRenderer;
- private boolean includeHiddenRegion = true;
+ private AlignExportSettingI exportSettings;
public void finalize()
{
}
- public boolean isIncludeHiddenRegion()
+ public AlignExportSettingI getExportSettings()
{
- return includeHiddenRegion;
+ return exportSettings;
}
- public void setIncludeHiddenRegion(boolean includeHiddenRegion)
+ public void setExportSettings(AlignExportSettingI exportSettings)
{
- this.includeHiddenRegion = includeHiddenRegion;
+ this.exportSettings = exportSettings;
}
+
}
import jalview.analysis.Dna;
import jalview.analysis.ParseProperties;
import jalview.analysis.SequenceIdMatcher;
+import jalview.api.AlignExportSettingI;
import jalview.api.AlignViewControllerGuiI;
import jalview.api.AlignViewControllerI;
import jalview.api.AlignViewportI;
return false;
}
- ExportData exportData = getAlignmentForExport();
+ ExportData exportData = getAlignmentForExport(format);
FormatAdapter f = new FormatAdapter(viewport);
String output = f.formatSequences(format,
exportData.getAlignment(), // class cast exceptions will
protected void outputText_actionPerformed(ActionEvent e)
{
- ExportData exportData = getAlignmentForExport();
+ ExportData exportData = getAlignmentForExport(e.getActionCommand());
+ if (exportData.getSettings().isCancelled())
+ {
+ return;
+ }
CutAndPasteTransfer cap = new CutAndPasteTransfer();
cap.setForInput(null);
-
try
{
cap.setText(new FormatAdapter(viewport).formatSequences(
}
- public ExportData getAlignmentForExport()
+ public ExportData getAlignmentForExport(String exportFomat)
{
AlignmentI alignmentToExport = null;
String[] omitHidden = null;
alignmentStartEnd = new int[]
{ 0, alignmentToExport.getWidth() - 1 };
- if (viewport.hasHiddenColumns() || hiddenSeqs.getSize() > 0)
- {
- int reply = JOptionPane
- .showInternalConfirmDialog(
- Desktop.desktop,
- MessageManager
- .getString("label.alignment_contains_hidden_columns"),
- MessageManager
- .getString("action.save_omit_hidden_columns"),
- JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE);
+ boolean hasHiddenSeqs = hiddenSeqs.getSize() > 0;
+ AlignExportSettingI settings = new AlignExportSettings(hasHiddenSeqs,
+ viewport.hasHiddenColumns(), exportFomat);
+ viewport.setExportSettings(settings);
+ settings.isExportAnnotations();
- if (reply == JOptionPane.YES_OPTION)
- {
- // export only visible region
- omitHidden = viewport.getViewAsString(false);
- alignmentToExport = viewport.getAlignment();
- alignmentStartEnd = getStartEnd(alignmentStartEnd, viewport
- .getColumnSelection().getHiddenColumns());
- viewport.setIncludeHiddenRegion(false);
- }
- else
- {
- // export all region including visible
- alignmentToExport = hiddenSeqs.getFullAlignment();
- viewport.setIncludeHiddenRegion(true);
- }
+ if (viewport.hasHiddenColumns() && !settings.isExportHiddenColumns())
+ {
+ omitHidden = viewport.getViewAsString(false);
}
- return new ExportData(alignmentToExport, omitHidden, alignmentStartEnd);
+ if (hasHiddenSeqs && settings.isExportHiddenSequences())
+ {
+ alignmentToExport = hiddenSeqs.getFullAlignment();
+ }
+ else
+ {
+ alignmentToExport = viewport.getAlignment();
+ alignmentStartEnd = getStartEnd(alignmentStartEnd, viewport
+ .getColumnSelection().getHiddenColumns());
+ }
+ return new ExportData(alignmentToExport, omitHidden, alignmentStartEnd,
+ settings);
}
private static int[] getStartEnd(int[] aligmentStartEnd,
@Override
protected void htmlMenuItem_actionPerformed(ActionEvent e)
{
- // new HTMLOutput(alignPanel,
- // alignPanel.getSeqPanel().seqCanvas.getSequenceRenderer(),
- // alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer());
new HtmlSvgOutput(null, alignPanel);
}
private int[] startEnd;
- public ExportData(AlignmentI align, String[] ommit, int[] startEnd)
+ private AlignExportSettingI settings;
+
+ public ExportData(AlignmentI align, String[] ommit, int[] startEnd,
+ AlignExportSettingI settings)
{
this.alignment = align;
this.omitHidden = ommit;
this.startEnd = startEnd;
+ this.settings = settings;
}
public AlignmentI getAlignment()
{
this.startEnd = startEnd;
}
+
+ public AlignExportSettingI getSettings()
+ {
+ return settings;
+ }
+
+ public void setSettings(AlignExportSettingI settings)
+ {
+ this.settings = settings;
+ }
}
}
import jalview.analysis.AlignmentUtils;
import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
import jalview.analysis.NJTree;
+import jalview.api.AlignExportSettingI;
import jalview.api.AlignViewportI;
import jalview.api.FeatureRenderer;
import jalview.api.ViewStyleI;
private FeatureRenderer featureRenderer;
private boolean includeHiddenRegion = true;
+
+ private AlignExportSettingI exportSettings;
+
String viewName;
/*
this.featureRenderer = featureRenderer;
}
- public boolean isIncludeHiddenRegion()
+ public AlignExportSettingI getExportSettings()
{
- return includeHiddenRegion;
+ return exportSettings;
}
- public void setIncludeHiddenRegion(boolean includeHiddenRegion)
+ public void setExportSettings(AlignExportSettingI exportSettings)
{
- this.includeHiddenRegion = includeHiddenRegion;
+ this.exportSettings = exportSettings;
}
}
private FeatureRenderer fr;
- private JSONExportSettings jsonExportSettings;
-
private List<int[]> hiddenColumns;
private ColumnSelection columnSelection;
String jsonOutput = null;
try
{
- if (getJsonExportSettings() == null)
- {
- jsonExportSettings = new JSONExportSettings();
- jsonExportSettings.setExportAnnotations(true);
- jsonExportSettings.setExportGroups(true);
- jsonExportSettings.setExportJalviewSettings(true);
- jsonExportSettings.setExportSequenceFeatures(true);
- }
-
AlignmentPojo jsonAlignmentPojo = new AlignmentPojo();
if (getViewport() != null)
{
jsonAlignmentPojo.getSeqs().add(jsonSeqPojo);
}
- if (jsonExportSettings.isExportJalviewSettings())
+ jsonAlignmentPojo.setGlobalColorScheme(globalColorScheme);
+ jsonAlignmentPojo.getAppSettings().put("application", application);
+ jsonAlignmentPojo.getAppSettings().put("version", version);
+ jsonAlignmentPojo.getAppSettings().put("webStartUrl", webstartUrl);
+ jsonAlignmentPojo.getAppSettings().put("showSeqFeatures",
+ String.valueOf(showSeqFeatures));
+
+ String[] hiddenSections = getHiddenSections();
+ if (hiddenSections != null)
{
- jsonAlignmentPojo.setGlobalColorScheme(globalColorScheme);
- jsonAlignmentPojo.getAppSettings().put("application", application);
- jsonAlignmentPojo.getAppSettings().put("version", version);
- jsonAlignmentPojo.getAppSettings().put("webStartUrl", webstartUrl);
- jsonAlignmentPojo.getAppSettings().put("showSeqFeatures",
- String.valueOf(showSeqFeatures));
-
- String[] hiddenSections = exportHiddenSections();
- if (hiddenSections != null && getViewport().isIncludeHiddenRegion())
+ if (hiddenSections[0] != null
+ && getViewport().getExportSettings()
+ .isExportHiddenColumns())
{
- if (hiddenSections[0] != null)
- {
- jsonAlignmentPojo.getAppSettings().put("hiddenCols",
- String.valueOf(hiddenSections[0]));
- }
- if (hiddenSections[1] != null)
- {
- jsonAlignmentPojo.getAppSettings().put("hiddenSeqs",
- String.valueOf(hiddenSections[1]));
- }
+ jsonAlignmentPojo.getAppSettings().put("hiddenCols",
+ String.valueOf(hiddenSections[0]));
+ }
+ if (hiddenSections[1] != null
+ && getViewport().getExportSettings()
+ .isExportHiddenSequences())
+ {
+ jsonAlignmentPojo.getAppSettings().put("hiddenSeqs",
+ String.valueOf(hiddenSections[1]));
}
}
- if (jsonExportSettings.isExportAnnotations())
+ if (getViewport().getExportSettings().isExportAnnotations())
{
jsonAlignmentPojo
.setAlignAnnotation(annotationToJsonPojo(annotations));
}
- if (jsonExportSettings.isExportSequenceFeatures())
+ if (getViewport().getExportSettings().isExportFeatures())
{
jsonAlignmentPojo
.setSeqFeatures(sequenceFeatureToJsonPojo(seqs, fr));
}
- if (jsonExportSettings.isExportGroups() && seqGroups != null
+ if (getViewport().getExportSettings().isExportGroups()
+ && seqGroups != null
&& seqGroups.size() > 0)
{
for (SequenceGroup seqGrp : seqGroups)
return jsonOutput;
}
- public String[] exportHiddenSections()
+ public String[] getHiddenSections()
{
String[] hiddenSections = new String[2];
if (getViewport() == null)
this.displayedFeatures = displayedFeatures;
}
- public JSONExportSettings getJsonExportSettings()
- {
- return jsonExportSettings;
- }
-
- public void setJsonExportSettings(JSONExportSettings jsonExportSettings)
- {
- this.jsonExportSettings = jsonExportSettings;
- }
-
public static String getJSONData(AlignViewportI av)
{