Merge branch 'develop' into features/JAL-892varnaToProject
[jalview.git] / src / jalview / io / FileParse.java
index f9c717d..9228257 100755 (executable)
@@ -20,7 +20,9 @@
  */
 package jalview.io;
 
+import jalview.api.AlignExportSettingI;
 import jalview.api.AlignViewportI;
+import jalview.api.AlignmentViewPanel;
 import jalview.util.MessageManager;
 
 import java.io.BufferedReader;
@@ -49,12 +51,26 @@ public class FileParse
 
   public File inFile = null;
 
+  /**
+   * a viewport associated with the current file operation. May be null. May
+   * move to different object.
+   */
   private AlignViewportI viewport;
 
-  public int index = 1; // sequence counter for FileParse object created from
+  /**
+   * specific settings for exporting data from the current context
+   */
+  private AlignExportSettingI exportSettings;
 
-  // same data source
+  /**
+   * sequence counter for FileParse object created from same data source
+   */
+  public int index = 1;
 
+  /**
+   * separator for extracting specific 'frame' of a datasource for formats that
+   * support multiple records (e.g. BLC, Stockholm, etc)
+   */
   protected char suffixSeparator = '#';
 
   /**
@@ -395,6 +411,19 @@ public class FileParse
     throw new IOException(MessageManager.formatMessage("exception.invalid_source_stream", new String[]{errormessage}));
   }
 
+  /**
+   * 
+   * @return true if this FileParse is configured for Export only
+   */
+  public boolean isExporting()
+  {
+    return !error && dataIn == null;
+  }
+
+  /**
+   * 
+   * @return true if the data source is valid
+   */
   public boolean isValid()
   {
     return !error;
@@ -501,4 +530,37 @@ public class FileParse
   {
     this.viewport = viewport;
   }
+
+  /**
+   * @return the currently configured exportSettings for writing data.
+   */
+  public AlignExportSettingI getExportSettings()
+  {
+    return exportSettings;
+  }
+
+  /**
+   * Set configuration for export of data.
+   * 
+   * @param exportSettings
+   *          the exportSettings to set
+   */
+  public void setExportSettings(AlignExportSettingI exportSettings)
+  {
+    this.exportSettings = exportSettings;
+  }
+
+  /**
+   * method overridden by complex file exporter/importers which support
+   * exporting visualisation and layout settings for a view
+   * 
+   * @param avpanel
+   */
+  public void configureForView(AlignmentViewPanel avpanel)
+  {
+    if (avpanel!=null) {
+      setViewport(avpanel.getAlignViewport());
+    }
+    // could also set export/import settings
+  }
 }