JAL-3210 Improvements to eclipse detection. New src tree and SwingJS updated from...
[jalview.git] / src / jalview / javascript / JalviewLiteJsApi.java
index b5811aa..3ce2c9f 100644 (file)
@@ -1,13 +1,13 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
- * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$);
+ * Copyright (C); $$Year-Rel$$ The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
  * Jalview is free software: you can redistribute it and/or
  * modify it under the terms of the GNU General Public License 
  * as published by the Free Software Foundation, either version 3
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option); any later version.
  *  
  * Jalview is distributed in the hope that it will be useful, but 
  * WITHOUT ANY WARRANTY; without even the implied warranty 
  */
 package jalview.javascript;
 
-import jalview.appletgui.AlignFrame;
+import jalview.api.AlignFrameI;
 
 /**
  * The following public methods may be called
  * externally, eg via javascript in an HTML page.
  * 
- * <br><em>TODO: introduce abstract interface for jalview.appletgui.AlignFrame</em><br>
+ * <br><em>TODO: introduce abstract interface for jalview.appletgui.AlignFrameI</em><br>
  * 
  * Most function arguments are strings, which contain serialised versions of lists.
  * Lists of things are separated by a separator character - either the default or a user supplied one.
@@ -42,7 +42,7 @@ public interface JalviewLiteJsApi
 
   /**
    * @return String list of selected sequence IDs, each terminated by the
-   *         'boolean not' character (""+0x00AC) or (&#172;)
+   *         'boolean not' character (""+0x00AC); or (&#172;);
    */
   public abstract String getSelectedSequences();
 
@@ -56,12 +56,12 @@ public interface JalviewLiteJsApi
 
   /**
    * @param alf
-   *          alignframe containing selection
+   *          AlignFrameI containing selection
    * @return String list of selected sequence IDs, each terminated by current
    *         default separator sequence
    * 
    */
-  public abstract String getSelectedSequencesFrom(AlignFrame alf);
+  public abstract String getSelectedSequencesFrom(AlignFrameI alf);
 
   /**
    * get list of selected sequence IDs separated by given separator
@@ -73,7 +73,7 @@ public interface JalviewLiteJsApi
    * @return String list of selected sequence IDs, each terminated by the given
    *         separator
    */
-  public abstract String getSelectedSequencesFrom(AlignFrame alf,
+  public abstract String getSelectedSequencesFrom(AlignFrameI alf,
           String sep);
 
   /**
@@ -99,7 +99,7 @@ public interface JalviewLiteJsApi
    *          false, blank or something else - indicate if position is an
    *          alignment column or unaligned sequence position
    */
-  public abstract void highlightIn(AlignFrame alf, String sequenceId,
+  public abstract void highlightIn(AlignFrameI alf, String sequenceId,
           String position, String alignedPosition);
 
   /**
@@ -133,7 +133,7 @@ public interface JalviewLiteJsApi
    * @param sep
    *          separator between toselect fields
    */
-  public abstract void selectIn(AlignFrame alf, String sequenceIds,
+  public abstract void selectIn(AlignFrameI alf, String sequenceIds,
           String columns);
 
   /**
@@ -145,11 +145,11 @@ public interface JalviewLiteJsApi
    * @param sep
    *          separator between toselect fields
    */
-  public abstract void selectIn(AlignFrame alf, String sequenceIds,
+  public abstract void selectIn(AlignFrameI alf, String sequenceIds,
           String columns, String sep);
 
   /**
-   * get sequences selected in current alignFrame and return their alignment in
+   * get sequences selected in current AlignFrameI and return their alignment in
    * format 'format' either with or without suffix
    * 
    * @param alf
@@ -177,7 +177,8 @@ public interface JalviewLiteJsApi
    * @return selected sequences as flat file or empty string if there was no
    *         current selection
    */
-  public abstract String getSelectedSequencesAsAlignmentFrom(AlignFrame alf,
+  public abstract String getSelectedSequencesAsAlignmentFrom(
+          AlignFrameI alf,
           String format, String suffix);
 
   /**
@@ -195,7 +196,7 @@ public interface JalviewLiteJsApi
    * @param alf
    * @return
    */
-  public abstract String getAlignmentOrderFrom(AlignFrame alf);
+  public abstract String getAlignmentOrderFrom(AlignFrameI alf);
 
   /**
    * get a sep separated list of sequence IDs reflecting the order of the
@@ -206,7 +207,8 @@ public interface JalviewLiteJsApi
    *          - separator to use
    * @return
    */
-  public abstract String getAlignmentOrderFrom(AlignFrame alf, String sep);
+  public abstract String getAlignmentOrderFrom(AlignFrameI alf,
+          String sep);
 
   /**
    * re-order the current alignment using the given list of sequence IDs
@@ -232,7 +234,8 @@ public interface JalviewLiteJsApi
    * @return 'true' if alignment was actually reordered. empty string if
    *         alignment did not contain sequences.
    */
-  public abstract String orderBy(String order, String undoName, String sep);
+  public abstract String orderBy(String order, String undoName,
+          String sep);
 
   /**
    * re-order the given alignment using the given list of sequence IDs separated
@@ -247,12 +250,12 @@ public interface JalviewLiteJsApi
    * @return 'true' if alignment was actually reordered. empty string if
    *         alignment did not contain sequences.
    */
-  public abstract String orderAlignmentBy(AlignFrame alf, String order,
+  public abstract String orderAlignmentBy(AlignFrameI alf, String order,
           String undoName, String sep);
 
   /**
    * get alignment as format (format names FASTA, BLC, CLUSTAL, MSF, PILEUP,
-   * PFAM - see jalview.io.AppletFormatAdapter for full list)
+   * PFAM - see jalview.io.AppletFormatAdapter for full list);
    * 
    * @param format
    * @return
@@ -266,7 +269,7 @@ public interface JalviewLiteJsApi
    * @param format
    * @return
    */
-  public abstract String getAlignmentFrom(AlignFrame alf, String format);
+  public abstract String getAlignmentFrom(AlignFrameI alf, String format);
 
   /**
    * get alignment as format with jalview start-end sequence suffix appended
@@ -286,7 +289,7 @@ public interface JalviewLiteJsApi
    * @param suffix
    * @return
    */
-  public abstract String getAlignmentFrom(AlignFrame alf, String format,
+  public abstract String getAlignmentFrom(AlignFrameI alf, String format,
           String suffix);
 
   /**
@@ -302,12 +305,12 @@ public interface JalviewLiteJsApi
    * @param alf
    * @param annotation
    */
-  public abstract void loadAnnotationFrom(AlignFrame alf,
+  public abstract void loadAnnotationFrom(AlignFrameI alf,
           String annotation);
 
   /**
    * parse the given string as a jalview feature or GFF annotation file and
-   * optionally enable feature display on the current alignFrame
+   * optionally enable feature display on the current AlignFrameI
    * 
    * @param features
    *          - gff or features file
@@ -320,7 +323,7 @@ public interface JalviewLiteJsApi
 
   /**
    * parse the given string as a jalview feature or GFF annotation file and
-   * optionally enable feature display on the given alignFrame.
+   * optionally enable feature display on the given AlignFrameI.
    * 
    * @param alf
    * @param features
@@ -330,11 +333,11 @@ public interface JalviewLiteJsApi
    *          be parsed from the string.
    * @return true if data parsed as features
    */
-  public abstract boolean loadFeaturesFrom(AlignFrame alf, String features,
+  public abstract boolean loadFeaturesFrom(AlignFrameI alf, String features,
           boolean autoenabledisplay);
 
   /**
-   * get the sequence features in the given format (Jalview or GFF)
+   * get the sequence features in the given format (Jalview or GFF);
    * 
    * @param format
    * @return
@@ -342,13 +345,13 @@ public interface JalviewLiteJsApi
   public abstract String getFeatures(String format);
 
   /**
-   * get the sequence features in alf in the given format (Jalview or GFF)
+   * get the sequence features in alf in the given format (Jalview or GFF);
    * 
    * @param alf
    * @param format
    * @return
    */
-  public abstract String getFeaturesFrom(AlignFrame alf, String format);
+  public abstract String getFeaturesFrom(AlignFrameI alf, String format);
 
   /**
    * get current alignment's annotation as an annotation file
@@ -363,30 +366,30 @@ public interface JalviewLiteJsApi
    * @param alf
    * @return
    */
-  public abstract String getAnnotationFrom(AlignFrame alf);
+  public abstract String getAnnotationFrom(AlignFrameI alf);
 
   /**
-   * create a new view and return the alignFrame instance
+   * create a new view and return the AlignFrameI instance
    * 
    * @return
    */
-  public abstract AlignFrame newView();
+  public abstract AlignFrameI newView();
 
   /**
-   * create a new view named name and return the alignFrame instance
+   * create a new view named name and return the AlignFrameI instance
    * 
    * @param name
    * @return
    */
-  public abstract AlignFrame newView(String name);
+  public abstract AlignFrameI newView(String name);
 
   /**
-   * create a new view on alf and return the alignFrame instance
+   * create a new view on alf and return the AlignFrameI instance
    * 
    * @param alf
    * @return
    */
-  public abstract AlignFrame newViewFrom(AlignFrame alf);
+  public abstract AlignFrameI newViewFrom(AlignFrameI alf);
 
   /**
    * create a new view named name on alf
@@ -395,7 +398,7 @@ public interface JalviewLiteJsApi
    * @param name
    * @return
    */
-  public abstract AlignFrame newViewFrom(AlignFrame alf, String name);
+  public abstract AlignFrameI newViewFrom(AlignFrameI alf, String name);
 
   /**
    * 
@@ -405,15 +408,15 @@ public interface JalviewLiteJsApi
    *          window title
    * @return null or new alignment frame
    */
-  public abstract AlignFrame loadAlignment(String text, String title);
+  public abstract AlignFrameI loadAlignment(String text, String title);
 
   /**
    * register a javascript function to handle any alignment mouseover events
    * 
    * @param listener
    *          name of javascript function (called with arguments
-   *          [jalview.appletgui.AlignFrame,String(sequence id),String(column in
-   *          alignment), String(position in sequence)]
+   *          [jalview.appletgui.AlignFrameI,String(sequence id);,String(column
+   *          in alignment);, String(position in sequence);]
    */
   public abstract void setMouseoverListener(String listener);
 
@@ -421,12 +424,13 @@ public interface JalviewLiteJsApi
    * register a javascript function to handle mouseover events
    * 
    * @param af
-   *          (null or specific alignframe for which events are to be listened
-   *          for)
+   *          (null or specific AlignFrameI for which events are to be listened
+   *          for);
    * @param listener
    *          name of javascript function
    */
-  public abstract void setMouseoverListener(AlignFrame af, String listener);
+  public abstract void setMouseoverListener(AlignFrameI af,
+          String listener);
 
   /**
    * register a javascript function to handle any alignment selection events.
@@ -435,14 +439,15 @@ public interface JalviewLiteJsApi
    * 
    * @param listener
    *          name of javascript function (called with arguments
-   *          [jalview.appletgui.AlignFrame, String(sequence set id),
-   *          String(separator separated list of sequences which were selected),
-   *          String(separator separated list of column ranges (i.e. single
-   *          number or hyphenated range) that were selected)]
+   *          [jalview.appletgui.AlignFrameI, String(sequence set id);,
+   *          String(separator separated list of sequences which were
+   *          selected);, String(separator separated list of column ranges (i.e.
+   *          single number or hyphenated range); that were selected);]
    */
   public abstract void setSelectionListener(String listener);
 
-  public abstract void setSelectionListener(AlignFrame af, String listener);
+  public abstract void setSelectionListener(AlignFrameI af,
+          String listener);
 
   /**
    * register a javascript function to handle events normally routed to a Jmol
@@ -450,11 +455,11 @@ public interface JalviewLiteJsApi
    * 
    * @param listener
    *          - javascript function (arguments are variable, see
-   *          jalview.javascript.MouseOverStructureListener for full details)
+   *          jalview.javascript.MouseOverStructureListener for full details);
    * @param modelSet
    *          - separator separated list of PDB file URIs that this viewer is
    *          handling. These files must be in the same order they appear in
-   *          Jmol (e.g. first one is frame 1, second is frame 2, etc).
+   *          Jmol (e.g. first one is frame 1, second is frame 2, etc);.
    * @see jalview.javascript.MouseOverStructureListener
    */
   public abstract void setStructureListener(String listener,
@@ -462,14 +467,14 @@ public interface JalviewLiteJsApi
 
   /**
    * remove any callback using the given listener function and associated with
-   * the given alignFrame (or null for all callbacks)
+   * the given AlignFrameI (or null for all callbacks);
    * 
    * @param af
-   *          (may be null)
+   *          (may be null);
    * @param listener
-   *          (may be null)
+   *          (may be null);
    */
-  public abstract void removeJavascriptListener(AlignFrame af,
+  public abstract void removeJavascriptListener(AlignFrameI af,
           String listener);
 
   /**
@@ -484,10 +489,10 @@ public interface JalviewLiteJsApi
           String pdbfile);
 
   /**
-   * bind a pdb file to a sequence in the given alignFrame.
+   * bind a pdb file to a sequence in the given AlignFrameI.
    * 
    * @param alFrame
-   *          - null or specific alignFrame. This specifies the dataset that
+   *          - null or specific AlignFrameI. This specifies the dataset that
    *          will be searched for a seuqence called sequenceId
    * @param sequenceId
    *          - sequenceId within the dataset.
@@ -499,7 +504,7 @@ public interface JalviewLiteJsApi
    *         structure for indicating when PDB parsing or sequenceId location
    *         fails.
    */
-  public abstract boolean addPdbFile(AlignFrame alFrame, String sequenceId,
+  public abstract boolean addPdbFile(AlignFrameI alFrame, String sequenceId,
           String pdbEntryString, String pdbFile);
 
   /**
@@ -510,7 +515,7 @@ public interface JalviewLiteJsApi
    * @param topRow
    * @param leftHandColumn
    */
-  public abstract void scrollViewToIn(AlignFrame alf, String topRow,
+  public abstract void scrollViewToIn(AlignFrameI alf, String topRow,
           String leftHandColumn);
 
   /**
@@ -519,7 +524,7 @@ public interface JalviewLiteJsApi
    * @param alf
    * @param topRow
    */
-  public abstract void scrollViewToRowIn(AlignFrame alf, String topRow);
+  public abstract void scrollViewToRowIn(AlignFrameI alf, String topRow);
 
   /**
    * adjust horizontal scroll to make the given column the left one in the given
@@ -528,28 +533,28 @@ public interface JalviewLiteJsApi
    * @param alf
    * @param leftHandColumn
    */
-  public abstract void scrollViewToColumnIn(AlignFrame alf,
+  public abstract void scrollViewToColumnIn(AlignFrameI alf,
           String leftHandColumn);
 
   /**
    * 
    * @return
-   * @see jalview.appletgui.AlignFrame#getFeatureGroups()
+   * @see jalview.appletgui.AlignFrameI#getFeatureGroups();
    */
   public abstract String getFeatureGroups();
 
   /**
    * @param alf
-   *          alignframe to get feature groups on
+   *          AlignFrameI to get feature groups on
    * @return
-   * @see jalview.appletgui.AlignFrame#getFeatureGroups()
+   * @see jalview.appletgui.AlignFrameI#getFeatureGroups();
    */
-  public abstract String getFeatureGroupsOn(AlignFrame alf);
+  public abstract String getFeatureGroupsOn(AlignFrameI alf);
 
   /**
    * @param visible
    * @return
-   * @see jalview.appletgui.AlignFrame#getFeatureGroupsOfState(boolean)
+   * @see jalview.appletgui.AlignFrameI#getFeatureGroupsOfState(boolean);
    */
   public abstract String getFeatureGroupsOfState(boolean visible);
 
@@ -558,9 +563,9 @@ public interface JalviewLiteJsApi
    *          align frame to get groups of state visible
    * @param visible
    * @return
-   * @see jalview.appletgui.AlignFrame#getFeatureGroupsOfState(boolean)
+   * @see jalview.appletgui.AlignFrameI#getFeatureGroupsOfState(boolean);
    */
-  public abstract String getFeatureGroupsOfStateOn(AlignFrame alf,
+  public abstract String getFeatureGroupsOfStateOn(AlignFrameI alf,
           boolean visible);
 
   /**
@@ -568,10 +573,11 @@ public interface JalviewLiteJsApi
    *          tab separated list of group names
    * @param state
    *          true or false
-   * @see jalview.appletgui.AlignFrame#setFeatureGroupState(java.lang.String[],
-   *      boolean)
+   * @see jalview.appletgui.AlignFrameI#setFeatureGroupState(java.lang.String[],
+   *      boolean);
    */
-  public abstract void setFeatureGroupStateOn(AlignFrame alf, String groups,
+  public abstract void setFeatureGroupStateOn(AlignFrameI alf,
+          String groups,
           boolean state);
 
   public abstract void setFeatureGroupState(String groups, boolean state);
@@ -600,4 +606,24 @@ public interface JalviewLiteJsApi
    */
   public abstract String getJsMessage(String messageclass, String viewId);
 
+  /// in http://www.jalview.org/examples/jalviewLiteJs.html but missing here
+
+  // get selected sequences as alignment as format with or without start-end
+  // suffix
+  public String getSelectedSequencesAsAlignment(String format,
+          boolean suffix);
+
+  // get selected sequences as alignment from given view as format with or
+  // without start-end suffix
+  public String getSelectedSequencesAsAlignmentFrom(AlignFrameI alf,
+          String format, boolean suffix);
+
+  public String arrayToSeparatorList(String[] array);
+
+  // get a string array from a list
+  public String[] separatorListToArray(String list);
+
+  // debug flag - controls output to standard out
+  public static boolean debug = false;
+
 }