From: tcofoegbu Date: Fri, 26 Jun 2015 16:06:05 +0000 (+0100) Subject: JAL-1641 fixed broken functionalities after refactor X-Git-Tag: Release_2_10_0~585^2~13 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=a8aec438cd92c74061c89487b2431a52bb0c2799;p=jalview.git JAL-1641 fixed broken functionalities after refactor --- diff --git a/src/jalview/datamodel/AlignmentExportData.java b/src/jalview/datamodel/AlignmentExportData.java new file mode 100644 index 0000000..46da85d --- /dev/null +++ b/src/jalview/datamodel/AlignmentExportData.java @@ -0,0 +1,63 @@ +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; + } +} diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 764b192..01a22ed 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -48,6 +48,7 @@ import jalview.commands.TrimRegionCommand; 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; @@ -1139,8 +1140,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, 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 @@ -1212,7 +1218,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, protected void outputText_actionPerformed(ActionEvent e) { - ExportData exportData = getAlignmentForExport(e.getActionCommand()); + AlignmentExportData exportData = getAlignmentForExport( + e.getActionCommand(), viewport); if (exportData.getSettings().isCancelled()) { return; @@ -1238,7 +1245,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } - public ExportData getAlignmentForExport(String exportFomat) + public static AlignmentExportData getAlignmentForExport(String exportFomat, + AlignViewportI viewport) { AlignmentI alignmentToExport = null; String[] omitHidden = null; @@ -1272,8 +1280,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, 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, @@ -6070,66 +6079,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } } - 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 diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java index d3d4d6e..3b81e89 100755 --- a/src/jalview/io/AppletFormatAdapter.java +++ b/src/jalview/io/AppletFormatAdapter.java @@ -483,7 +483,7 @@ public class AppletFormatAdapter private AlignmentI buildAlignmentFrom(AlignFile alignFile2) { // Standard boilerplate for creating alignment from parser - alignFile.configureForView(viewpanel); + // alignFile.configureForView(viewpanel); AlignmentI al = new Alignment(alignFile.getSeqsAsArray()); @@ -597,6 +597,7 @@ public class AppletFormatAdapter { throw new Exception(MessageManager.getString("error.implementation_error_unknown_file_format_string")); } + afile.setNewlineString(newline); afile.addJVSuffix(jvsuffix); diff --git a/src/jalview/io/BioJsHTMLOutput.java b/src/jalview/io/BioJsHTMLOutput.java index 74fb147..089f50b 100644 --- a/src/jalview/io/BioJsHTMLOutput.java +++ b/src/jalview/io/BioJsHTMLOutput.java @@ -1,6 +1,7 @@ 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; @@ -51,7 +52,20 @@ public class BioJsHTMLOutput 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( diff --git a/src/jalview/io/FormatAdapter.java b/src/jalview/io/FormatAdapter.java index e795925..8a563fa 100755 --- a/src/jalview/io/FormatAdapter.java +++ b/src/jalview/io/FormatAdapter.java @@ -29,7 +29,6 @@ import jalview.datamodel.ColumnSelection; 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. @@ -51,7 +50,7 @@ public class FormatAdapter extends AppletFormatAdapter init(); } - public FormatAdapter(AlignmentPanel alignPanel, + public FormatAdapter(AlignmentViewPanel alignPanel, AlignExportSettingI settings) { super(alignPanel, settings); diff --git a/src/jalview/io/HtmlSvgOutput.java b/src/jalview/io/HtmlSvgOutput.java index 7e02118..781eace 100644 --- a/src/jalview/io/HtmlSvgOutput.java +++ b/src/jalview/io/HtmlSvgOutput.java @@ -1,6 +1,7 @@ package jalview.io; import jalview.api.FeatureRenderer; +import jalview.datamodel.AlignmentExportData; import jalview.datamodel.SequenceI; import jalview.gui.AlignViewport; import jalview.gui.AlignmentPanel; @@ -93,13 +94,26 @@ public class HtmlSvgOutput } 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(); diff --git a/src/jalview/io/JSONFile.java b/src/jalview/io/JSONFile.java index ce70ea5..25a0064 100644 --- a/src/jalview/io/JSONFile.java +++ b/src/jalview/io/JSONFile.java @@ -594,46 +594,29 @@ public class JSONFile extends AlignFile implements ComplexAlignFile 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()