JAL-3446 differences.txt now delivered with SwingJS-site.zip
[jalview.git] / src / jalview / bin / JalviewJSApi.java
index 7c9dee8..0512841 100644 (file)
@@ -2,7 +2,6 @@ package jalview.bin;
 
 import java.io.IOException;
 import java.net.URL;
-import java.util.Hashtable;
 
 import jalview.api.AlignViewportI;
 import jalview.datamodel.ColumnSelection;
@@ -12,7 +11,6 @@ import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
 import jalview.gui.AlignFrame;
 import jalview.io.DataSourceType;
-import jalview.io.NewickFile;
 import jalview.structure.SelectionSource;
 import jalview.structure.VamsasSource;
 
@@ -35,27 +33,22 @@ public interface JalviewJSApi
    *          - null or specific AlignFrame. This specifies the dataset that
    *          will be searched for a seuqence called sequenceId
    * @param sequenceId
-   *          - sequenceId within the dataset.
-   * @param pdbEntryString
-   *          - the short name for the PDB file
+   *          - sequenceId within the dataset or null
+   * @param pdbId
+   *          - the four-character PDB ID
    * @param pdbFile
-   *          - pdb file - either a URL or a valid PDB file.
-   * @return true if binding was as success TODO: consider making an exception
-   *         structure for indicating when PDB parsing or sequenceId location
-   *         fails.
+   *          - pdb file - either a URL or a valid PDB file or null.
+   * @return true if binding was success
    */
-  public abstract boolean addPdbFile(AlignFrame alFrame, String sequenceId,
-          String pdbEntryString, String pdbFile);
-
-  public String arrayToSeparatorList(String[] array);
+  public boolean addPdbFile(AlignFrame alFrame, String sequenceId,
+          String pdbId, String pdbFile);
 
   /**
    * 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>
+   * <em>TODO: introduce interface for jalview.appletgui.AlignFrame</em><br>
    * 
    * Most function arguments are strings, which contain serialised versions of
    * lists. Lists of things are separated by a separator character - either the
@@ -80,7 +73,7 @@ public interface JalviewJSApi
    * @return
    */
 
-  public abstract String getAlignment(String format);
+  public String getAlignment(String format);
 
   /**
    * get alignment as format with jalview start-end sequence suffix appended
@@ -90,7 +83,7 @@ public interface JalviewJSApi
    * @return
    */
 
-  public abstract String getAlignment(String format, String suffix);
+  public String getAlignment(String format, String suffix);
 
   /**
    * get alignment displayed in alf as format
@@ -99,7 +92,7 @@ public interface JalviewJSApi
    * @param format
    * @return
    */
-  public abstract String getAlignmentFrom(AlignFrame alf, String format);
+  public String getAlignmentFrom(AlignFrame alf, String format);
 
   /**
    * get alignment displayed in alf as format with or without the jalview
@@ -110,7 +103,7 @@ public interface JalviewJSApi
    * @param suffix
    * @return
    */
-  public abstract String getAlignmentFrom(AlignFrame alf, String format,
+  public String getAlignmentFrom(AlignFrame alf, String format,
           String suffix);
 
   /**
@@ -120,7 +113,7 @@ public interface JalviewJSApi
    * @return
    */
 
-  public abstract String getAlignmentOrder();
+  public String getAlignmentOrder();
 
   /**
    * get a separator separated list of sequence IDs reflecting the order of the
@@ -129,18 +122,7 @@ public interface JalviewJSApi
    * @param alf
    * @return
    */
-  public abstract String getAlignmentOrderFrom(AlignFrame alf);
-
-  /**
-   * get a sep separated list of sequence IDs reflecting the order of the
-   * alignment in alf
-   * 
-   * @param alf
-   * @param sep
-   *          - separator to use
-   * @return
-   */
-  public abstract String getAlignmentOrderFrom(AlignFrame alf, String sep);
+  public String[] getAlignmentOrderFrom(AlignFrame alf);
 
   /**
    * get current alignment's annotation as an annotation file
@@ -148,7 +130,7 @@ public interface JalviewJSApi
    * @return
    */
 
-  public abstract String getAnnotation();
+  public String getAnnotation();
 
   /**
    * get alignment view alf's annotation as an annotation file
@@ -156,7 +138,7 @@ public interface JalviewJSApi
    * @param alf
    * @return
    */
-  public abstract String getAnnotationFrom(AlignFrame alf);
+  public String getAnnotationFrom(AlignFrame alf);
 
   public Object getAppletParameter(String name, boolean asString);
 
@@ -170,7 +152,7 @@ public interface JalviewJSApi
    * @see jalview.appletgui.AlignFrame#getFeatureGroups();
    */
 
-  public abstract String getFeatureGroups();
+  public String[] getFeatureGroups();
 
   /**
    * @param visible
@@ -178,7 +160,7 @@ public interface JalviewJSApi
    * @see jalview.appletgui.AlignFrame#getFeatureGroupsOfState(boolean);
    */
 
-  public abstract String getFeatureGroupsOfState(boolean visible);
+  public String[] getFeatureGroupsOfState(boolean visible);
 
   /**
    * @param alf
@@ -187,7 +169,7 @@ public interface JalviewJSApi
    * @return
    * @see jalview.appletgui.AlignFrame#getFeatureGroupsOfState(boolean);
    */
-  public abstract String getFeatureGroupsOfStateOn(AlignFrame alf,
+  public String[] getFeatureGroupsOfStateOn(AlignFrame alf,
           boolean visible);
 
   /**
@@ -196,7 +178,7 @@ public interface JalviewJSApi
    * @return
    * @see jalview.appletgui.AlignFrame#getFeatureGroups();
    */
-  public abstract String getFeatureGroupsOn(AlignFrame alf);
+  public String[] getFeatureGroupsOn(AlignFrame alf);
 
   /**
    * get the sequence features in the given format (Jalview or GFF);
@@ -205,7 +187,7 @@ public interface JalviewJSApi
    * @return
    */
 
-  public abstract String getFeatures(String format);
+  public String getFeatures(String format);
 
   /**
    * get the sequence features in alf in the given format (Jalview or GFF);
@@ -214,29 +196,10 @@ public interface JalviewJSApi
    * @param format
    * @return
    */
-  public abstract String getFeaturesFrom(AlignFrame alf, String format);
+  public String getFeaturesFrom(AlignFrame alf, String format);
 
   public Object getFrameForSource(VamsasSource source);
 
-  public Hashtable<String, int[]> getJSHashes();
-
-  /**
-   * Retrieve fragments of a large packet of data made available by JalviewLite.
-   * 
-   * @param messageclass
-   * @param viewId
-   * @return next chunk of message
-   */
-
-  public abstract String getJsMessage(String messageclass, String viewId);
-
-  Hashtable<String, Hashtable<String, String[]>> getJSMessages();
-
-  public Object getJSObject();
-
-  public jalview.renderer.seqfeatures.FeatureRenderer getNewFeatureRenderer(
-          AlignViewportI vp);
-
   public String getParameter(String name);
 
   /**
@@ -244,7 +207,7 @@ public interface JalviewJSApi
    *         'boolean not' character (""+0x00AC); or (&#172;);
    */
 
-  public abstract String getSelectedSequences();
+  public SequenceI[] getSelectedSequences();
 
   /**
    * @param sep
@@ -253,7 +216,7 @@ public interface JalviewJSApi
    *         separator string
    */
 
-  public abstract String getSelectedSequences(String sep);
+  public SequenceI[] getSelectedSequences(String sep);
 
   /**
    * get sequences selected in current AlignFrame and return their alignment in
@@ -269,7 +232,7 @@ public interface JalviewJSApi
    *         current selection
    */
 
-  public abstract String getSelectedSequencesAsAlignment(String format,
+  public String getSelectedSequencesAsAlignment(String format,
           String suffix);
 
   /**
@@ -285,7 +248,7 @@ public interface JalviewJSApi
    * @return selected sequences as flat file or empty string if there was no
    *         current selection
    */
-  public abstract String getSelectedSequencesAsAlignmentFrom(AlignFrame alf,
+  public String getSelectedSequencesAsAlignmentFrom(AlignFrame alf,
           String format, String suffix);
 
   /**
@@ -295,7 +258,7 @@ public interface JalviewJSApi
    *         default separator sequence
    * 
    */
-  public abstract String getSelectedSequencesFrom(AlignFrame alf);
+  public SequenceI[] getSelectedSequencesFrom(AlignFrame alf);
 
   // BH incompatibility here -- JalviewLite created an AlignFrame; Jalview
   // creates an AlignmentPanel
@@ -305,7 +268,7 @@ public interface JalviewJSApi
   // * @return
   // */
   //
-  // public abstract AlignFrame newView();
+  // public AlignFrame newView();
   //
   // /**
   // * create a new view named name and return the AlignFrame instance
@@ -314,7 +277,7 @@ public interface JalviewJSApi
   // * @return
   // */
   //
-  // public abstract AlignFrame newView(String name);
+  // public AlignFrame newView(String name);
   //
   // /**
   // * create a new view on alf and return the AlignFrame instance
@@ -322,7 +285,7 @@ public interface JalviewJSApi
   // * @param alf
   // * @return
   // */
-  // public abstract AlignFrame newViewFrom(AlignFrame alf);
+  // public AlignFrame newViewFrom(AlignFrame alf);
   //
   // /**
   // * create a new view named name on alf
@@ -331,7 +294,7 @@ public interface JalviewJSApi
   // * @param name
   // * @return
   // */
-  // public abstract AlignFrame newViewFrom(AlignFrame alf, String name);
+  // public AlignFrame newViewFrom(AlignFrame alf, String name);
 
   /**
    * get list of selected sequence IDs separated by given separator
@@ -343,21 +306,12 @@ public interface JalviewJSApi
    * @return String list of selected sequence IDs, each terminated by the given
    *         separator
    */
-  public abstract String getSelectedSequencesFrom(AlignFrame alf,
-          String sep);
+  public SequenceI[] getSelectedSequencesFrom(AlignFrame alf, String sep);
 
   public Object[] getSelectionForListener(SequenceGroup seqsel,
           ColumnSelection colsel, HiddenColumns hidden,
           SelectionSource source, Object alignFrame);
 
-  /**
-   * List separator string
-   * 
-   * @return the separator
-   */
-
-  public abstract String getSeparator();
-
   public AlignViewportI getViewport();
 
   /**
@@ -371,7 +325,7 @@ public interface JalviewJSApi
    *          column or unaligned sequence position
    */
 
-  public abstract void highlight(String sequenceId, String position,
+  public void highlight(String sequenceId, String position,
           String alignedPosition);
 
   /**
@@ -384,7 +338,7 @@ public interface JalviewJSApi
    *          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 void highlightIn(AlignFrame alf, String sequenceId,
           String position, String alignedPosition);
 
   /**
@@ -396,7 +350,7 @@ public interface JalviewJSApi
    * @return null or new alignment frame
    */
 
-  public abstract AlignFrame loadAlignment(String text, String title);
+  public AlignFrame loadAlignment(String text, String title);
 
   /**
    * add the given features or annotation to the current alignment
@@ -404,7 +358,7 @@ public interface JalviewJSApi
    * @param annotation
    */
 
-  public abstract void loadAnnotation(String annotation);
+  public void loadAnnotation(String annotation);
 
   /**
    * add the given features or annotation to the given alignment view
@@ -412,8 +366,7 @@ public interface JalviewJSApi
    * @param alf
    * @param annotation
    */
-  public abstract void loadAnnotationFrom(AlignFrame alf,
-          String annotation);
+  public void loadAnnotationFrom(AlignFrame alf, String annotation);
 
   /**
    * parse the given string as a jalview feature or GFF annotation file and
@@ -426,8 +379,7 @@ public interface JalviewJSApi
    *          be parsed from the string.
    */
 
-  public abstract void loadFeatures(String features,
-          boolean autoenabledisplay);
+  public void loadFeatures(String features, boolean autoenabledisplay);
 
   /**
    * parse the given string as a jalview feature or GFF annotation file and
@@ -441,7 +393,7 @@ public interface JalviewJSApi
    *          be parsed from the string.
    * @return true if data parsed as features
    */
-  public abstract boolean loadFeaturesFrom(AlignFrame alf, String features,
+  public boolean loadFeaturesFrom(AlignFrame alf, String features,
           boolean autoenabledisplay);
 
   public boolean loadScoreFile(String sScoreFile) throws IOException;
@@ -451,74 +403,44 @@ public interface JalviewJSApi
   public void newStructureView(PDBEntry pdb, SequenceI[] seqs,
           String[] chains, DataSourceType protocol);
 
-  /**
-   * public static method for JalviewJS API to open a PCAPanel without
-   * necessarily using a dialog.
-   * 
-   * @param af
-   *          may be null
-   * @param modelName
-   * @return the PCAPanel, or the string "label.you_need_at_least_n_sequences"
-   *         if number of sequences selected is inappropriate
-   */
-  public Object openPcaPanel(AlignFrame af, String modelName);
-
-  /**
-   * Open a new Tree panel on the desktop statically. Params are standard (not
-   * set by Groovy). No dialog is opened.
-   * 
-   * @param af
-   *          may be null
-   * @param treeType
-   * @param modelName
-   * @return null, or the string "label.you_need_at_least_n_sequences" if number
-   *         of sequences selected is inappropriate
-   */
-  public Object openTreePanel(AlignFrame af, String treeType,
-          String modelName);
-
   /// in http://www.jalview.org/examples/jalviewLiteJs.html but missing here
 
   // get selected sequences as alignment as format with or without start-end
   // suffix
 
   /**
-   * re-order the given alignment using the given list of sequence IDs separated
-   * by sep
+   * re-order the given alignment using the given array of sequence IDs
    * 
    * @param alf
-   * @param order
-   *          - sep separated list
+   * @param ids
+   *          array of sequence IDs
    * @param undoName
    *          - string to use when referring to ordering action in undo buffer
-   * @param sep
    * @return 'true' if alignment was actually reordered. empty string if
    *         alignment did not contain sequences.
    */
-  public abstract String orderAlignmentBy(AlignFrame alf, String order,
-          String undoName, String sep);
+  String orderAlignmentBy(AlignFrame alf, String[] ids, String undoName);
 
   // get a string array from a list
 
   /**
    * re-order the current alignment using the given list of sequence IDs
    * 
-   * @param order
-   *          - sep separated list
+   * @param ids
+   *          array of sequence IDs
    * @param undoName
    *          - string to use when referring to ordering action in undo buffer
    * @return 'true' if alignment was actually reordered. empty string if
    *         alignment did not contain sequences.
    */
 
-  public abstract String orderBy(String order, String undoName);
+  public String orderBy(String[] ids, String undoName);
 
   /**
    * re-order the current alignment using the given list of sequence IDs
-   * separated by sep
    * 
-   * @param order
-   *          - sep separated list
+   * @param ids
+   *          array of sequence IDs
    * @param undoName
    *          - string to use when referring to ordering action in undo buffer
    * @param sep
@@ -526,15 +448,8 @@ public interface JalviewJSApi
    *         alignment did not contain sequences.
    */
 
-  public abstract String orderBy(String order, String undoName, String sep);
-
-  /**
-   * process commandline arguments after the JavaScript application has started
-   * 
-   * @param args
-   * @return
-   */
-  Object parseArguments(String[] args);
+  // public String orderBy(String[] ids, String undoName, String sep);
+  //
 
   // public boolean getDefaultParameter(String name, boolean def);
 
@@ -549,8 +464,7 @@ public interface JalviewJSApi
    * @param listener
    *          (may be null);
    */
-  public abstract void removeSelectionListener(AlignFrame af,
-          String listener);
+  public void removeSelectionListener(AlignFrame af, String listener);
 
   // public void setAlignPdbStructures(boolean defaultParameter);
 
@@ -561,8 +475,7 @@ public interface JalviewJSApi
    * @param alf
    * @param leftHandColumn
    */
-  public abstract void scrollViewToColumnIn(AlignFrame alf,
-          String leftHandColumn);
+  public void scrollViewToColumnIn(AlignFrame alf, String leftHandColumn);
 
   /**
    * adjust horizontal/vertical scroll to make the given location the top left
@@ -572,7 +485,7 @@ public interface JalviewJSApi
    * @param topRow
    * @param leftHandColumn
    */
-  public abstract void scrollViewToIn(AlignFrame alf, String topRow,
+  public void scrollViewToIn(AlignFrame alf, String topRow,
           String leftHandColumn);
 
   /**
@@ -581,7 +494,7 @@ public interface JalviewJSApi
    * @param alf
    * @param topRow
    */
-  public abstract void scrollViewToRowIn(AlignFrame alf, String topRow);
+  public void scrollViewToRowIn(AlignFrame alf, String topRow);
 
   /**
    * select regions of the currrent alignment frame
@@ -593,7 +506,7 @@ public interface JalviewJSApi
    *          string
    */
 
-  public abstract void select(String sequenceIds, String columns);
+  public void select(String sequenceIds, String columns);
 
   /**
    * select regions of the currrent alignment frame
@@ -604,8 +517,7 @@ public interface JalviewJSApi
    *          separator between toselect fields
    */
 
-  public abstract void select(String sequenceIds, String columns,
-          String sep);
+  public void select(String sequenceIds, String columns, String sep);
 
   /**
    * select regions of the given alignment frame
@@ -616,8 +528,7 @@ public interface JalviewJSApi
    * @param sep
    *          separator between toselect fields
    */
-  public abstract void selectIn(AlignFrame alf, String sequenceIds,
-          String columns);
+  public void selectIn(AlignFrame alf, String sequenceIds, String columns);
 
   /**
    * select regions of the given alignment frame
@@ -628,12 +539,10 @@ public interface JalviewJSApi
    * @param sep
    *          separator between toselect fields
    */
-  public abstract void selectIn(AlignFrame alf, String sequenceIds,
-          String columns, String sep);
-
-  public String[] separatorListToArray(String list);
+  public void selectIn(AlignFrame alf, String sequenceIds, String columns,
+          String sep);
 
-  public abstract void setFeatureGroupState(String groups, boolean state);
+  public void setFeatureGroupState(String groups, boolean state);
 
   public void setFeatureGroupState(String[] groups, boolean state);
 
@@ -648,10 +557,10 @@ public interface JalviewJSApi
    * @see jalview.appletgui.AlignFrame#setFeatureGroupState(java.lang.String[],
    *      boolean);
    */
-  public abstract void setFeatureGroupStateOn(AlignFrame alf, String groups,
+  public void setFeatureGroupStateOn(AlignFrame alf, String groups,
           boolean state);
 
-  public abstract void setSelectionListener(AlignFrame af, String listener);
+  public void setSelectionListener(AlignFrame af, String listener);
 
   /**
    * register a javascript function to handle any alignment selection events.
@@ -666,19 +575,48 @@ public interface JalviewJSApi
    *          single number or hyphenated range); that were selected);]
    */
 
-  public abstract void setSelectionListener(String listener);
+  public void setSelectionListener(String listener);
+
+  public void updateForAnnotations();
+
+  // Bob's additions:
 
   /**
-   * List separator string
+   * public static method for JalviewJS API to open a PCAPanel without
+   * necessarily using a dialog.
    * 
-   * @param separator
-   *          the separator to set. empty string will reset separator to default
+   * @param af
+   *          may be null
+   * @param modelName
+   * @return the PCAPanel, or the string "label.you_need_at_least_n_sequences"
+   *         if number of sequences selected is inappropriate
    */
+  public Object openPcaPanel(AlignFrame af, String modelName);
 
-  public abstract void setSeparator(String separator);
+  /**
+   * Open a new Tree panel on the desktop statically. Params are standard (not
+   * set by Groovy). No dialog is opened.
+   * 
+   * @param af
+   *          may be null
+   * @param treeType
+   * @param modelName
+   * @return null, or the string "label.you_need_at_least_n_sequences" if number
+   *         of sequences selected is inappropriate
+   */
+  public Object openTreePanel(AlignFrame af, String treeType,
+          String modelName);
 
-  void showOverview();
+  /**
+   * process commandline arguments after the JavaScript application has started
+   *
+   * @param args
+   * @return
+   */
+  public Object parseArguments(String[] args);
 
-  public void updateForAnnotations();
+  public void showStructure(AlignFrame af, String pdbID, String fileType);
+
+  public void showOverview();
 
 }