From: BobHanson Date: Sun, 7 Jun 2020 18:00:11 +0000 (-0500) Subject: reorganized JalviewJSApp (accidentally put that in jalview/api) and X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=017a7e2b525a3f047d7723e59601679ca5af7b18;p=jalview.git reorganized JalviewJSApp (accidentally put that in jalview/api) and fixes for 2-applet example --- diff --git a/src/jalview/api/JalviewJSApi.java b/src/jalview/api/JalviewJSApi.java new file mode 100644 index 0000000..895fd15 --- /dev/null +++ b/src/jalview/api/JalviewJSApi.java @@ -0,0 +1,412 @@ +package jalview.api; + +import java.net.URL; + +import jalview.datamodel.SequenceI; +import jalview.gui.AlignFrame; + +/** + * JAL-3369 JalviewJS API BH 2019.07.17 + * + * @author hansonr + * + */ +public interface JalviewJSApi +{ + + /** + * bind a pdb file to a sequence in the given AlignFrame. + * + * @param sequenceId + * - 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 or null. + * @param alFrame + * - null or specific AlignFrame. This specifies the dataset that + * will be searched for a seuqence called sequenceId + * + * @return true if binding was success + */ + public boolean addPdbFile(String sequenceId, String pdbId, String pdbFile, + AlignFrame alFrame); + + /** + * Get alignment as format with or without the jalview start-end sequence + * suffix appended. + * + * @param format + * @param addSuffix + * (default false) + * @param alf + * (default current) + * + * @return + */ + public String getAlignment(String format, boolean addSuffix, + AlignFrame alf); + + /** + * Get an array of sequence IDs reflecting the order of the alignment in the + * specified alignment frame + * + * @param alf + * (default current) + * @return array of sequence IDs + */ + public String[] getAlignmentOrder(AlignFrame alf); + + /** + * Get alignment view alf's annotation as an annotation file + * + * @param alf + * (default current) + * @return annotation + */ + public String getAnnotation(AlignFrame alf); + + /** + * Get the URL for the location where the code is found; typically ending in + * "swingjs/j2s". + * + * @return web page URL + */ + public URL getCodeBase(); + + AlignFrame getCurrentAlignFrame(); + + /** + * Get the URL for the hosting web page. + * + * @return web page URL + */ + public URL getDocumentBase(); + + /** + * Get the array of feature groups for an alignment frame. + * + * @param alf + * AlignFrame to get feature groups for (default current) + * @return + */ + public String[] getFeatureGroups(AlignFrame alf); + + /** + * Get the array of feature groups for an alignment frame with a specific + * on/off state. + * + * @param visible + * (default off) + * @param alf + * align frame (default current) + * + * @return + */ + public String[] getFeatureGroupsOfState(boolean visible, AlignFrame alf); + + /** + * Get the sequence features in the alignment frame in the given format + * (Jalview or GFF). Two additional options can be added to the format, each + * starting with a semicolon: + * + * ;includeNonpositional (default) or ;positionalOnly + * + * ;includeComplement + * + * @param format + * case-insensitive "Jalview" or "GFF" (default "GFF") + * @param alf + * (default current) + * @return formatted sequence features + */ + public String getFeatures(String format, AlignFrame alf); + + /** + * Get an applet parameter as a string. + * + * @param name + * @return value or null + */ + public String getParameter(String name); + + /** + * Get an applet parameter object value. + * + * @param name + * @return value or null + */ + public Object getParameterAsObject(String name); + + /** + * @param alf + * AlignFrame containing selection + * @return String list of selected sequence IDs, each terminated by current + * default separator sequence + * + */ + public SequenceI[] getSelectedSequences(AlignFrame alf); + + // BH incompatibility here -- JalviewLite created an AlignFrame; Jalview + // creates an AlignmentPanel + // /** + // * create a new view and return the AlignFrame instance + // * + // * @return + // */ + // + // public AlignFrame newView(); + // + // /** + // * create a new view named name and return the AlignFrame instance + // * + // * @param name + // * @return + // */ + // + // public AlignFrame newView(String name); + // + // /** + // * create a new view on alf and return the AlignFrame instance + // * + // * @param alf + // * @return + // */ + // public AlignFrame newViewFrom(AlignFrame alf); + // + // /** + // * create a new view named name on alf + // * + // * @param alf + // * @param name + // * @return + // */ + // public AlignFrame newViewFrom(AlignFrame alf, String name); + // + + /** + * get sequences selected in alf and return their alignment in format 'format' + * either with or without suffix + * + * @param format + * - format of alignment file + * @param alf + * - where selection is + * @param suffix + * - true to append /start-end string to each sequence ID + * + * @return selected sequences as flat file or empty string if there was no + * current selection + */ + public String getSelectedSequencesAsAlignment(String format, + boolean addSuffix, AlignFrame alf); + + /** + * + * @param sequenceId + * id of sequence to highlight + * @param position + * integer position [ tobe implemented or range ] on sequence + * @param alignedPosition + * false, blank or something else - indicate if position is an + * alignment column or unaligned sequence position + * @param alf + * alignment frame (default current) + */ + public void highlight(String sequenceId, String position, + String alignedPosition, AlignFrame alf); + + /** + * + * @param data + * alignment data as a string + * @param title + * window title + * @param width + * desired width or 0 for default width + * @param height + * desired height or 0 for default height + * @return null or new alignment frame + */ + + public AlignFrame loadAlignment(String data, String title, int width, + int height); + + /** + * add the given features or annotation to the given alignment view + * + * @param annotation + * @param alf + * alignment frame (default current) + */ + public void loadAnnotation(String annotation, AlignFrame alf); + + /** + * Parse the given string as a jalview feature or GFF annotation file and + * optionally enable feature display on the given AlignFrame. + * + * @param features + * - gff or features file + * @param autoenabledisplay + * - when true, feature display will be enabled if any features can + * be parsed from the string. + * @param alf + * alignment frame (default current) + * + * @return true if data parsed as features + */ + public boolean loadFeatures(String features, boolean autoenabledisplay, + AlignFrame alf); + + /** + * Load a score file. + * + * @param sScoreFile + * @param alf + * alignment frame (default current) + * + * @return + */ + public boolean loadScoreFile(String sScoreFile, AlignFrame alf); + + /** + * public static method for JalviewJS API to open a PCAPanel without + * necessarily using a dialog. + * + * @param modelName + * @param alf + * may be null + * + * @return the PCAPanel, or the string "label.you_need_at_least_n_sequences" + * if number of sequences selected is inappropriate + */ + public Object openPcaPanel(String modelName, AlignFrame alf); + + /** + * Open a new Tree panel on the desktop statically. Params are standard (not + * set by Groovy). No dialog is opened. + * + * @param treeType + * @param modelName + * @param alf + * align frame (default current) + * + * @return null, or the string "label.you_need_at_least_n_sequences" if number + * of sequences selected is inappropriate + */ + public Object openTreePanel(String treeType, String modelName, + AlignFrame alf); + + /** + * re-order the given alignment using the given array of sequence IDs + * + * @param ids + * array of sequence IDs + * @param undoName + * - string to use when referring to ordering action in undo buffer + * @param alf + * alignment frame (default current) + * + * @return 'true' if alignment was actually reordered. empty string if + * alignment did not contain sequences. + */ + public boolean orderAlignment(String[] ids, String undoName, + AlignFrame alf); + + /** + * process commandline arguments after the JavaScript application has started + * + * @param args + * @return + */ + public Object parseArguments(String[] args); + + boolean parseFeaturesFile(String filename, AlignFrame alf); + + // Bob's additions: + + /** + * remove any callback using the given listener function and associated with + * the given AlignFrame (or null for all callbacks); + * + * @param listener + * (may be null); + * @param alf + * alignment frame (default current) + */ + public void removeSelectionListener(String listener, AlignFrame af); + + /** + * adjust horizontal/vertical scroll to make the given location the top left + * hand corner for the given view + * + * @param topRow + * -1 for current top row + * @param leftHandColumn + * -1 for current left-hand column + * @param alf + * alignment frame (default current) + */ + public void scrollViewTo(int topRow, int leftHandColumn, AlignFrame alf); + /** + * select regions of the given alignment frame + * + * @param alf + * alignment frame (default current) + * @param toselect + * String separated list { column range, seq1...seqn sequence ids } + * @param sep + * separator between toselect fields + */ + public void select(String[] sequenceIds, String[] columns, + AlignFrame alf); + + /** + * Set the state (visible or not) of the selected feature groups. + * + * @param groups + * @param state + * @param alf + * (default current) + */ + public void setFeatureGroupState(String[] groups, boolean state, + AlignFrame alf); + + /** + * Register a JavaScript function to handle alignment selection events. Events + * are generated when the user completes a selection event, or when the user + * deselects all selected regions. The method is called back with the + * following arguments: + * + * the appletID (such as "Jalview1") + * + * the source alignment frame + * + * the SelectionSource object (for example, an AlignViewport) + * + * the sequence set ID + * + * an array of sequence IDs + * + * an array of columns (single number or hyphenated range) + * + * @param listener + * name of JavaScript function to be called + * + * @param alf + * alignment frame (default ALL) + */ + public void setSelectionListener(String listener, AlignFrame alf); + + public void showOverview(); + + /** + * + * @param pdbID + * @param fileType + * @param alf + * align frame (default current) + */ + public void showStructure(String pdbID, String fileType, AlignFrame alf); + +} diff --git a/src/jalview/bin/AppletParams.java b/src/jalview/bin/AppletParams.java index 3abaf72..3642985 100644 --- a/src/jalview/bin/AppletParams.java +++ b/src/jalview/bin/AppletParams.java @@ -185,7 +185,7 @@ public class AppletParams extends HashMap case "scorefile": case "sequence": // setting argName to null indicates that we want - // JalviewAppLoader to take care of this. + // JalviewJSApp to take care of this using getParameter or getParameterAsObject prefName = argName = null; value = resourcePath + value; break; @@ -244,7 +244,7 @@ public class AppletParams extends HashMap // implemented; not tested: case "oninit": - prefName = null; + argName = null; break; case "annotations": value = resourcePath + value; diff --git a/src/jalview/bin/ArgsParser.java b/src/jalview/bin/ArgsParser.java index 55e760f..c5c08f6 100644 --- a/src/jalview/bin/ArgsParser.java +++ b/src/jalview/bin/ArgsParser.java @@ -118,14 +118,15 @@ public class ArgsParser { appletParams = AppletParams.getAppletParams(args, vargs); } - else if (Platform.isJS() && args.length == 0) - { - isApplet = true; - appletParams = AppletParams - .getAppletParams(Platform.getAppletInfoAsMap(), vargs); - } else { + if (Platform.isJS()) + + { + isApplet = true; + appletParams = AppletParams + .getAppletParams(Platform.getAppletInfoAsMap(), vargs); + } for (int i = 0; i < args.length; i++) { String arg = args[i].trim(); @@ -207,7 +208,7 @@ public class ArgsParser Object value; return (appletParams == null ? null : (value = appletParams.get(key.toLowerCase())) == null - ? def : asString ? value.toString() + ? def : asString ? "" + value : value); } diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 4819d7a..81193e6 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -48,7 +48,6 @@ import com.threerings.getdown.util.LaunchUtil; import groovy.lang.Binding; import groovy.util.GroovyScriptEngine; import jalview.api.AlignCalcWorkerI; -import jalview.api.JalviewJSApp; import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI; import jalview.ext.so.SequenceOntology; import jalview.gui.AlignFrame; @@ -388,8 +387,6 @@ public class Jalview implements ApplicationSingletonI System.exit(0); } - desktop = null; - if (!isJS) /** @j2sIgnore */ { @@ -450,6 +447,8 @@ public class Jalview implements ApplicationSingletonI SequenceOntologyFactory.setSequenceOntology(new SequenceOntology()); } + + desktop = null; if (!headless) { desktop = Desktop.getInstance(); @@ -581,7 +580,6 @@ public class Jalview implements ApplicationSingletonI FileLoader fileLoader = new FileLoader(!headless); FileFormatI format = null; // Finally, deal with the remaining input data. - JalviewJSApp jsApp = null; AlignFrame af = null; if (file != null) @@ -822,8 +820,7 @@ public class Jalview implements ApplicationSingletonI if (isJS) { - jsApp = new JalviewJSApp(this, aparser); - jsApp.load(af); + new JalviewJSApp(this, aparser, af); } else /** @@ -927,10 +924,6 @@ public class Jalview implements ApplicationSingletonI desktop.setInBatchMode(false); } - if (isJS && isStartup) - { - jsApp.callInitCallback(); - } } diff --git a/src/jalview/bin/JalviewJSApi.java b/src/jalview/bin/JalviewJSApi.java deleted file mode 100644 index 0512841..0000000 --- a/src/jalview/bin/JalviewJSApi.java +++ /dev/null @@ -1,622 +0,0 @@ -package jalview.bin; - -import java.io.IOException; -import java.net.URL; - -import jalview.api.AlignViewportI; -import jalview.datamodel.ColumnSelection; -import jalview.datamodel.HiddenColumns; -import jalview.datamodel.PDBEntry; -import jalview.datamodel.SequenceGroup; -import jalview.datamodel.SequenceI; -import jalview.gui.AlignFrame; -import jalview.io.DataSourceType; -import jalview.structure.SelectionSource; -import jalview.structure.VamsasSource; - -/** - * JAL-3369 JalviewJS API BH 2019.07.17 - * - * @author hansonr - * - */ -public interface JalviewJSApi -{ - - // debug flag - controls output to standard out - public static boolean debug = false; - - /** - * bind a pdb file to a sequence in the given AlignFrame. - * - * @param alFrame - * - null or specific AlignFrame. This specifies the dataset that - * will be searched for a seuqence called sequenceId - * @param sequenceId - * - 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 or null. - * @return true if binding was success - */ - 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. - * - *
- * TODO: introduce interface for jalview.appletgui.AlignFrame
- * - * 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. Ranges and positions on an alignment or - * sequence can be specified as a list, where an item containing a single - * number is a single position, and an item like 1-2 specifies columns 1 and 2 - * as a range. - */ - - // /** - // * @author jimp - // * - // */ - // public interface JalviewLiteJsApi - // { - - /** - * get alignment as format (format names FASTA, BLC, CLUSTAL, MSF, PILEUP, - * PFAM - see jalview.io.AppletFormatAdapter for full list); - * - * @param format - * @return - */ - - public String getAlignment(String format); - - /** - * get alignment as format with jalview start-end sequence suffix appended - * - * @param format - * @param suffix - * @return - */ - - public String getAlignment(String format, String suffix); - - /** - * get alignment displayed in alf as format - * - * @param alf - * @param format - * @return - */ - public String getAlignmentFrom(AlignFrame alf, String format); - - /** - * get alignment displayed in alf as format with or without the jalview - * start-end sequence suffix appended - * - * @param alf - * @param format - * @param suffix - * @return - */ - public String getAlignmentFrom(AlignFrame alf, String format, - String suffix); - - /** - * get a separator separated list of sequence IDs reflecting the order of the - * current alignment - * - * @return - */ - - public String getAlignmentOrder(); - - /** - * get a separator separated list of sequence IDs reflecting the order of the - * alignment in alf - * - * @param alf - * @return - */ - public String[] getAlignmentOrderFrom(AlignFrame alf); - - /** - * get current alignment's annotation as an annotation file - * - * @return - */ - - public String getAnnotation(); - - /** - * get alignment view alf's annotation as an annotation file - * - * @param alf - * @return - */ - public String getAnnotationFrom(AlignFrame alf); - - public Object getAppletParameter(String name, boolean asString); - - public URL getCodeBase(); - - public URL getDocumentBase(); - - /** - * - * @return - * @see jalview.appletgui.AlignFrame#getFeatureGroups(); - */ - - public String[] getFeatureGroups(); - - /** - * @param visible - * @return - * @see jalview.appletgui.AlignFrame#getFeatureGroupsOfState(boolean); - */ - - public String[] getFeatureGroupsOfState(boolean visible); - - /** - * @param alf - * align frame to get groups of state visible - * @param visible - * @return - * @see jalview.appletgui.AlignFrame#getFeatureGroupsOfState(boolean); - */ - public String[] getFeatureGroupsOfStateOn(AlignFrame alf, - boolean visible); - - /** - * @param alf - * AlignFrame to get feature groups on - * @return - * @see jalview.appletgui.AlignFrame#getFeatureGroups(); - */ - public String[] getFeatureGroupsOn(AlignFrame alf); - - /** - * get the sequence features in the given format (Jalview or GFF); - * - * @param format - * @return - */ - - public String getFeatures(String format); - - /** - * get the sequence features in alf in the given format (Jalview or GFF); - * - * @param alf - * @param format - * @return - */ - public String getFeaturesFrom(AlignFrame alf, String format); - - public Object getFrameForSource(VamsasSource source); - - public String getParameter(String name); - - /** - * @return String list of selected sequence IDs, each terminated by the - * 'boolean not' character (""+0x00AC); or (¬); - */ - - public SequenceI[] getSelectedSequences(); - - /** - * @param sep - * separator string or null for default - * @return String list of selected sequence IDs, each terminated by given - * separator string - */ - - public SequenceI[] getSelectedSequences(String sep); - - /** - * get sequences selected in current AlignFrame and return their alignment in - * format 'format' either with or without suffix - * - * @param alf - * - where selection is - * @param format - * - format of alignment file - * @param suffix - * - "true" to append /start-end string to each sequence ID - * @return selected sequences as flat file or empty string if there was no - * current selection - */ - - public String getSelectedSequencesAsAlignment(String format, - String suffix); - - /** - * get sequences selected in alf and return their alignment in format 'format' - * either with or without suffix - * - * @param alf - * - where selection is - * @param format - * - format of alignment file - * @param suffix - * - "true" to append /start-end string to each sequence ID - * @return selected sequences as flat file or empty string if there was no - * current selection - */ - public String getSelectedSequencesAsAlignmentFrom(AlignFrame alf, - String format, String suffix); - - /** - * @param alf - * AlignFrame containing selection - * @return String list of selected sequence IDs, each terminated by current - * default separator sequence - * - */ - public SequenceI[] getSelectedSequencesFrom(AlignFrame alf); - - // BH incompatibility here -- JalviewLite created an AlignFrame; Jalview - // creates an AlignmentPanel - // /** - // * create a new view and return the AlignFrame instance - // * - // * @return - // */ - // - // public AlignFrame newView(); - // - // /** - // * create a new view named name and return the AlignFrame instance - // * - // * @param name - // * @return - // */ - // - // public AlignFrame newView(String name); - // - // /** - // * create a new view on alf and return the AlignFrame instance - // * - // * @param alf - // * @return - // */ - // public AlignFrame newViewFrom(AlignFrame alf); - // - // /** - // * create a new view named name on alf - // * - // * @param alf - // * @param name - // * @return - // */ - // public AlignFrame newViewFrom(AlignFrame alf, String name); - - /** - * get list of selected sequence IDs separated by given separator - * - * @param alf - * window containing selection - * @param sep - * separator string to use - default is 'boolean not' - * @return String list of selected sequence IDs, each terminated by the given - * separator - */ - public SequenceI[] getSelectedSequencesFrom(AlignFrame alf, String sep); - - public Object[] getSelectionForListener(SequenceGroup seqsel, - ColumnSelection colsel, HiddenColumns hidden, - SelectionSource source, Object alignFrame); - - public AlignViewportI getViewport(); - - /** - * - * @param sequenceId - * id of sequence to highlight - * @param position - * integer position [ tobe implemented or range ] on sequence - * @param alignedPosition - * true/false/empty string - indicate if position is an alignment - * column or unaligned sequence position - */ - - public void highlight(String sequenceId, String position, - String alignedPosition); - - /** - * - * @param sequenceId - * id of sequence to highlight - * @param position - * integer position [ tobe implemented or range ] on sequence - * @param alignedPosition - * false, blank or something else - indicate if position is an - * alignment column or unaligned sequence position - */ - public void highlightIn(AlignFrame alf, String sequenceId, - String position, String alignedPosition); - - /** - * - * @param text - * alignment file as a string - * @param title - * window title - * @return null or new alignment frame - */ - - public AlignFrame loadAlignment(String text, String title); - - /** - * add the given features or annotation to the current alignment - * - * @param annotation - */ - - public void loadAnnotation(String annotation); - - /** - * add the given features or annotation to the given alignment view - * - * @param alf - * @param annotation - */ - public void loadAnnotationFrom(AlignFrame alf, String annotation); - - /** - * parse the given string as a jalview feature or GFF annotation file and - * optionally enable feature display on the current AlignFrame - * - * @param features - * - gff or features file - * @param autoenabledisplay - * - when true, feature display will be enabled if any features can - * be parsed from the string. - */ - - public void loadFeatures(String features, boolean autoenabledisplay); - - /** - * parse the given string as a jalview feature or GFF annotation file and - * optionally enable feature display on the given AlignFrame. - * - * @param alf - * @param features - * - gff or features file - * @param autoenabledisplay - * - when true, feature display will be enabled if any features can - * be parsed from the string. - * @return true if data parsed as features - */ - public boolean loadFeaturesFrom(AlignFrame alf, String features, - boolean autoenabledisplay); - - public boolean loadScoreFile(String sScoreFile) throws IOException; - - public void newFeatureSettings(); - - public void newStructureView(PDBEntry pdb, SequenceI[] seqs, - String[] chains, DataSourceType protocol); - - /// 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 array of sequence IDs - * - * @param alf - * @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. - */ - 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 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 String orderBy(String[] ids, String undoName); - - /** - * re-order the current alignment using the given list of sequence IDs - * - * @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 String orderBy(String[] ids, String undoName, String sep); - // - - // public boolean getDefaultParameter(String name, boolean def); - - public boolean parseFeaturesFile(String param, DataSourceType protocol); - - /** - * remove any callback using the given listener function and associated with - * the given AlignFrame (or null for all callbacks); - * - * @param af - * (may be null); - * @param listener - * (may be null); - */ - public void removeSelectionListener(AlignFrame af, String listener); - - // public void setAlignPdbStructures(boolean defaultParameter); - - /** - * adjust horizontal scroll to make the given column the left one in the given - * view - * - * @param alf - * @param leftHandColumn - */ - public void scrollViewToColumnIn(AlignFrame alf, String leftHandColumn); - - /** - * adjust horizontal/vertical scroll to make the given location the top left - * hand corner for the given view - * - * @param alf - * @param topRow - * @param leftHandColumn - */ - public void scrollViewToIn(AlignFrame alf, String topRow, - String leftHandColumn); - - /** - * adjust vertical scroll to make the given row the top one for given view - * - * @param alf - * @param topRow - */ - public void scrollViewToRowIn(AlignFrame alf, String topRow); - - /** - * select regions of the currrent alignment frame - * - * @param sequenceIds - * String separated list of sequence ids or empty string - * @param columns - * String separated list { column range or column, ..} or empty - * string - */ - - public void select(String sequenceIds, String columns); - - /** - * select regions of the currrent alignment frame - * - * @param toselect - * String separated list { column range, seq1...seqn sequence ids } - * @param sep - * separator between toselect fields - */ - - public void select(String sequenceIds, String columns, String sep); - - /** - * select regions of the given alignment frame - * - * @param alf - * @param toselect - * String separated list { column range, seq1...seqn sequence ids } - * @param sep - * separator between toselect fields - */ - public void selectIn(AlignFrame alf, String sequenceIds, String columns); - - /** - * select regions of the given alignment frame - * - * @param alf - * @param toselect - * String separated list { column range, seq1...seqn sequence ids } - * @param sep - * separator between toselect fields - */ - public void selectIn(AlignFrame alf, String sequenceIds, String columns, - String sep); - - public void setFeatureGroupState(String groups, boolean state); - - public void setFeatureGroupState(String[] groups, boolean state); - - // public StructureSelectionManagerProvider - // getStructureSelectionManagerProvider(); - - /** - * @param groups - * tab separated list of group names - * @param state - * true or false - * @see jalview.appletgui.AlignFrame#setFeatureGroupState(java.lang.String[], - * boolean); - */ - public void setFeatureGroupStateOn(AlignFrame alf, String groups, - boolean state); - - public void setSelectionListener(AlignFrame af, String listener); - - /** - * register a javascript function to handle any alignment selection events. - * Events are generated when the user completes a selection event, or when the - * user deselects all selected regions. - * - * @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);] - */ - - public void setSelectionListener(String listener); - - public void updateForAnnotations(); - - // Bob's additions: - - /** - * 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); - - /** - * process commandline arguments after the JavaScript application has started - * - * @param args - * @return - */ - public Object parseArguments(String[] args); - - public void showStructure(AlignFrame af, String pdbID, String fileType); - - public void showOverview(); - -} diff --git a/src/jalview/api/JalviewJSApp.java b/src/jalview/bin/JalviewJSApp.java similarity index 54% rename from src/jalview/api/JalviewJSApp.java rename to src/jalview/bin/JalviewJSApp.java index 5641295..1ba7273 100644 --- a/src/jalview/api/JalviewJSApp.java +++ b/src/jalview/bin/JalviewJSApp.java @@ -1,4 +1,4 @@ -package jalview.api; +package jalview.bin; import java.awt.EventQueue; //import java.applet.AppletContext; @@ -9,9 +9,8 @@ import java.util.List; import java.util.StringTokenizer; import java.util.Vector; -import jalview.bin.ArgsParser; -import jalview.bin.Jalview; -import jalview.bin.JalviewJSApi; +import jalview.api.JalviewJSApi; +import jalview.api.StructureSelectionManagerProvider; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentOrder; @@ -40,16 +39,14 @@ import jalview.io.NewickFile; import jalview.structure.SelectionListener; import jalview.structure.SelectionSource; import jalview.structure.StructureSelectionManager; -import jalview.structure.VamsasSource; import jalview.util.HttpUtils; -import jalview.util.MessageManager; import jalview.util.Platform; -//import netscape.javascript.JSObject; - /** * Basically the JalviewLite application, but without JalviewLite * + * Processing all "applet parameters" and also all "applet interface" methods. + * * @author hansonr * */ @@ -57,274 +54,121 @@ public class JalviewJSApp implements JalviewJSApi { private ArgsParser aparser; - private boolean debug; - private String[] ret = new String[1]; + // private boolean alignPDBStructures; From JalviewLite; not implemented + private String separator = "\u00AC"; // JalviewLite note: the default used to // be '|', but many sequence IDS include // pipes. /** - * We maintain a pointer to the jalview instance here, because only with that do we have a direct - * connection from the JavaScript "applet" object to the proper instance of Jalview in case there - * are multiple applets on a page. + * We maintain a pointer to the jalview instance here, because only with that + * do we have a direct connection from the JavaScript "applet" object to the + * proper instance of Jalview in case there are multiple applets on a page. */ private Jalview jalview; - - public JalviewJSApp(Jalview jalview, ArgsParser aparser) + public class JsSelectionListener + implements jalview.structure.SelectionListener { - this.jalview = jalview; - this.aparser = aparser; - Platform.setAppClass(this); - } + AlignFrame _alf; - public void load(AlignFrame af) - { - String sep = (String) getAppletParameter("separator", true); - if (sep != null) + String _listener; + + public JsSelectionListener(AlignFrame alf, String listener) { - if (sep.length() > 0) - { - separator = sep; - } - else - { - throw new Error(MessageManager - .getString("error.invalid_separator_parameter")); - } + _alf = alf; + _listener = listener; } - loadTree(af); - loadScoreFile(); - loadFeatures(af); - loadAnnotations(af); - loadJnetFile(af); - loadPdbFiles(af); - } - - // TODO BH 2019 - // - // These are methods that are in JalviewLite that various classes call - // but are not in JalviewLiteJsApi. Or, even if they are, other classes - // call - // them to JalviewLite directly. Some may not be necessary, but they have - // to - // be at least mentioned here, or the classes calling them should - // reference - // JalviewLite itself. - - // private boolean alignPDBStructures; // From JalviewLite; not implemented - // - - @Override - public String getParameter(String name) - { - return (String) getAppletParameter(name, true); - } - - @Override - public Object getAppletParameter(String name, boolean asString) - { - return aparser.getAppletValue(name, null, asString); - } - - /** - * Get the applet-like code base even though this is an application. - */ - - @Override - public URL getCodeBase() - { - return Platform.getCodeBase(); - } - - /** - * Get the applet-like document base even though this is an application. - */ - - @Override - public URL getDocumentBase() - { - return Platform.getDocumentBase(); - } + public boolean isFor(AlignFrame alf, String listener) + { + return (_alf == null || _alf == alf) && _listener.equals(listener); + } - @Override - public Object getFrameForSource(VamsasSource source) - { - if (source != null) + @Override + public void selection(SequenceGroup seqsel, ColumnSelection colsel, + HiddenColumns hidden, SelectionSource source) { - AlignFrame af; - if (source instanceof jalview.gui.AlignViewport - && source == (af = Jalview.getCurrentAlignFrame()) - .getViewport()) + // System.err.println("Testing selection event relay to + // jsfunction:"+_listener); + String setid = ""; + AlignFrame srcFrame = (_alf == null ? getCurrentAlignFrame() : _alf); + if (source != null) { - // should be valid if it just generated an event! - return af; + if (source instanceof AlignViewport + && srcFrame.getViewport() != source) + { + return; + } } - // TODO: ensure that if '_af' is specified along with a handler - // function, then only events from that alignFrame are sent to that - // function - } - return null; - } - - @Override - public Object[] getSelectionForListener(SequenceGroup seqsel, - ColumnSelection colsel, HiddenColumns hidden, - SelectionSource source, Object alignFrame) - { - return getSelectionForListener(null, seqsel, colsel, hidden, source, - alignFrame); - } - - /** - * scorefile - * - */ - - @Override - public boolean loadScoreFile(String sScoreFile) throws IOException - { - return loadScoreFile(null, sScoreFile); - } - - public boolean loadScoreFile(AlignFrame af, String sScoreFile) throws IOException - { - (af == null ? Jalview.getCurrentAlignFrame() : af).loadJalviewDataFile(sScoreFile, null, null, null); - return true; - } - - public void loadTree(AlignFrame af, NewickFile nf, String treeFile) throws IOException - { - if (af == null) - af = Jalview.getCurrentAlignFrame(); - af.getViewport() - .setCurrentTree(af.showNewickTree(nf, treeFile).getTree()); - } - - @Override - public void newFeatureSettings() - { - System.err.println( - "Jalview applet interface newFeatureSettings not implemented"); - } - - // - // - // public void setAlignPdbStructures(boolean defaultParameter) - // { - // alignPDBStructures = true; - // } - // - - @Override - public void newStructureView(PDBEntry pdb, SequenceI[] seqs, - String[] chains, DataSourceType protocol) - { - newStructureView(null, pdb, seqs, chains, protocol); - - } - - /** - * @j2sAlias showStructure - */ - @Override - public void showStructure(AlignFrame af, String pdbID, String fileType) { - if (af == null) - af = Jalview.getCurrentAlignFrame(); - PDBEntry pe = null; - SequenceI[] seqs = null; - if (pdbID == null) { - seqs = af.getViewport().getSequenceSelection(); - if (seqs.length == 0) - seqs = af.getViewport().getAlignment().getSequencesArray(); - for (int i = 0; i < seqs.length; i++) { - Vector list = seqs[i].getAllPDBEntries(); - if (list.size() > 0) { - pe = list.get(0); - break; + String[] seqs = new String[] {}; + String[] cols = new String[] {}; + int strt = 0, end = (srcFrame == null) ? -1 + : srcFrame.alignPanel.av.getAlignment().getWidth(); + if (seqsel != null && seqsel.getSize() > 0) + { + seqs = new String[seqsel.getSize()]; + for (int i = 0; i < seqs.length; i++) + { + seqs[i] = seqsel.getSequenceAt(i).getName(); + } + if (strt < seqsel.getStartRes()) + { + strt = seqsel.getStartRes(); + } + if (end == -1 || end > seqsel.getEndRes()) + { + end = seqsel.getEndRes(); } } - } - if (pe == null) { - if (pdbID == null) - return; - pe = new PDBEntry(pdbID, null, fileType); - List list = af.getViewport().getAlignment().getSequences(); - List tmp = new ArrayList(); - for (int i = 0; i < list.size(); i++) { - SequenceI seq = list.get(i); - if (seq.getPDBEntry(pdbID) != null) { - tmp.add(seq); + if (colsel != null && !colsel.isEmpty()) + { + if (end == -1) + { + end = colsel.getMax() + 1; + } + cols = new String[colsel.getSelected().size()]; + for (int i = 0; i < cols.length; i++) + { + cols[i] = "" + (1 + colsel.getSelected().get(i).intValue()); } } - seqs = tmp.toArray(new SequenceI[tmp.size()]); - af.alignPanel.selectSequences(tmp); + else + { + if (seqsel != null && seqsel.getSize() > 0) + { + // send a valid range, otherwise we send the empty selection + cols = new String[1]; + cols[0] = "" + (1 + strt) + "-" + (1 + end); + } + } + doSendCallback(_listener, + new Object[] + { Jalview.getInstance().j2sAppletID, srcFrame, source, setid, + seqs, cols }); } - StructureViewer.launchStructureViewer( - af.alignPanel, - pe, seqs); - } - - public void newStructureView(AlignFrame af, PDBEntry pdb, - SequenceI[] seqs, String[] chains, DataSourceType protocol) - { - StructureViewer.launchStructureViewer( - (af == null ? Jalview.getCurrentAlignFrame() : af).alignPanel, - pdb, seqs); - } - /** - * features - * @param af - * - */ - - @Override - public boolean parseFeaturesFile(String filename, DataSourceType protocol) - { - return parseFeaturesFile(null, filename, protocol); - } - - /** - * @j2sAlias parseFeatureFile - * - * @param af - * @param filename - * @param protocol - * @return - */ - public boolean parseFeaturesFile(AlignFrame af, String filename, DataSourceType protocol) - { - return (af == null ? Jalview.getCurrentAlignFrame() : af).parseFeaturesFile(filename, protocol); - } - - /** - * annotations, jpredfile, jnetfile - * - */ - - @Override - public void updateForAnnotations() - { - updateForAnnotations(null); } - public void updateForAnnotations(AlignFrame af) + public JalviewJSApp(Jalview jalview, ArgsParser aparser, AlignFrame alf) { - (af == null ? Jalview.getCurrentAlignFrame() : af).updateForAnnotations(); + Platform.setAppClass(this); + this.jalview = jalview; + this.aparser = aparser; + initFromParams(alf); + callInitCallback(); } @Override - public boolean addPdbFile(AlignFrame alf, String sequenceId, String pdbId, - String pdbFile) + public boolean addPdbFile(String sequenceId, String pdbId, String pdbFile, + AlignFrame alf) { if (alf == null) { - alf = Jalview.getCurrentAlignFrame(); + alf = getCurrentAlignFrame(); } SequenceI seq = alf.getViewport().getAlignment().findName(sequenceId); if (seq != null) @@ -362,91 +206,20 @@ public class JalviewJSApp implements JalviewJSApi return true; } -// @Override -// public String arrayToSeparatorList(String[] array) -// { -// return arrayToSeparatorList(array, separator); -// } - -// /** -// * concatenate the list with separator -// * -// * @param list -// * @param separator -// * @return concatenated string -// */ -// public static String arrayToSeparatorList(String[] list, String separator) -// { -// // TODO use StringUtils version -// StringBuffer v = new StringBuffer(); -// if (list != null && list.length > 0) -// { -// for (int i = 0, iSize = list.length; i < iSize; i++) -// { -// if (list[i] != null) -// { -// if (i > 0) -// { -// v.append(separator); -// } -// v.append(list[i]); -// } -// } -// // if (debug) -// // { -// // System.err -// // .println("Returning '" + separator + "' separated List:\n"); -// // System.err.println(v); -// // } -// return v.toString(); -// } -// // if (debug) -// // { -// // System.err.println( -// // "Returning empty '" + separator + "' separated List\n"); -// // } -// return "" + separator; -// } - - @Override - public String getAlignment(String format) - { - return getAlignmentFrom(null, format, null); - } - - /** - * suffix string "true"/"false" (default true) - * passed to AlnFile class controls whether /START-END is added to - * sequence names - */ - @Override - public String getAlignment(String format, String suffix) - { - return getAlignmentFrom(Jalview.getCurrentAlignFrame(), format, suffix); - } - - @Override - public String getAlignmentFrom(AlignFrame alf, String format) - { - return getAlignmentFrom(alf, format, null); - } - @Override - public String getAlignmentFrom(AlignFrame alf, String format, - String suffix) + public String getAlignment(String format, boolean addSuffix, + AlignFrame alf) { try { if (alf == null) { - alf = Jalview.getCurrentAlignFrame(); + alf = getCurrentAlignFrame(); } - boolean seqlimits = (suffix == null - || suffix.equalsIgnoreCase("true")); FileFormatI theFormat = FileFormats.getInstance().forName(format); String reply = new AppletFormatAdapter().formatSequences(theFormat, - alf.getViewport().getAlignment(), seqlimits); + alf.getViewport().getAlignment(), addSuffix); return reply; } catch (IllegalArgumentException ex) { @@ -457,17 +230,11 @@ public class JalviewJSApp implements JalviewJSApi } @Override - public String getAlignmentOrder() - { - return getAlignmentFrom(Jalview.getCurrentAlignFrame(), null); - } - - @Override - public String[] getAlignmentOrderFrom(AlignFrame alf) + public String[] getAlignmentOrder(AlignFrame alf) { if (alf == null) { - alf = Jalview.getCurrentAlignFrame(); + alf = getCurrentAlignFrame(); } AlignmentI alorder = alf.getViewport().getAlignment(); String[] order = new String[alorder.getHeight()]; @@ -475,88 +242,95 @@ public class JalviewJSApp implements JalviewJSApi { order[i] = alorder.getSequenceAt(i).getName(); } - return order;// arrayToSeparatorList(order, sep); - } - - @Override - public String getAnnotation() - { - return getAnnotationFrom(null); + return order;// arrayToSeparatorList(order, sep); } @Override - public String getAnnotationFrom(AlignFrame alf) + public String getAnnotation(AlignFrame alf) { if (alf == null) { - alf = Jalview.getCurrentAlignFrame(); + alf = getCurrentAlignFrame(); } String annotation = new AnnotationFile() .printAnnotationsForView(alf.getViewport()); return annotation; } + /** + * Get the applet-like code base even though this is an application. + */ + @Override - public String[] getFeatureGroups() + public URL getCodeBase() { - return getFeatureGroupsOn(null); + return Platform.getCodeBase(); } @Override - public String[] getFeatureGroupsOfState(boolean visible) + public AlignFrame getCurrentAlignFrame() { - return getFeatureGroupsOfStateOn(null, visible); + // if (jalview != Jalview.getInstance() || jalview.currentAlignFrame != + // Jalview.getCurrentAlignFrame()) { + // /** @j2sNative debugger */ + // } + return jalview.currentAlignFrame; } + /** + * Get the applet-like document base even though this is an application. + */ + @Override - public String[] getFeatureGroupsOfStateOn(AlignFrame alf, boolean visible) + public URL getDocumentBase() { - if (alf == null) - { - alf = Jalview.getCurrentAlignFrame(); - } - return alf.getFeatureGroupsOfState(visible); + return Platform.getDocumentBase(); } @Override - public String[] getFeatureGroupsOn(AlignFrame alf) + public String[] getFeatureGroups(AlignFrame alf) { if (alf == null) { - alf = Jalview.getCurrentAlignFrame(); + alf = getCurrentAlignFrame(); } return alf.getFeatureGroups(); } @Override - public String getFeatures(String format) + public String[] getFeatureGroupsOfState(boolean visible, AlignFrame alf) { - return getFeaturesFrom(null, format); + if (alf == null) + { + alf = getCurrentAlignFrame(); + } + return alf.getFeatureGroupsOfState(visible); } /** * JavaScript interface to print the alignment frame * - * @param alf * @param format * "jalview" or "gff" with or without ";includeComplement" or * ";includeNonpositional"; default with no ";" is * ";includeNonpositional" + * @param alf + * * @return */ @Override - public String getFeaturesFrom(AlignFrame alf, String format) + public String getFeatures(String format, AlignFrame alf) { if (alf == null) { - alf = Jalview.getCurrentAlignFrame(); + alf = getCurrentAlignFrame(); } String features; FeaturesFile formatter = new FeaturesFile(); format = format.toLowerCase(); if (format.indexOf(";") < 0) format += ";includenonpositional"; - boolean nonpos = format.indexOf(";includenonpositional") > 0; + boolean nonpos = format.indexOf(";includenonpositional") >= 0; boolean compl = format.indexOf(";includecomplement") >= 0; if (format.startsWith("jalview")) { @@ -578,7 +352,27 @@ public class JalviewJSApp implements JalviewJSApi return features; } - + + /** + * Get an applet parameter as a string. + * + */ + @Override + public String getParameter(String name) + { + return (String) aparser.getAppletValue(name, null, true); + } + + /** + * Get an applet parameter as an Object. + */ + + @Override + public Object getParameterAsObject(String name) + { + return aparser.getAppletValue(name, null, false); + } + /** * read sequence1...sequenceN as a raw alignment * @@ -590,8 +384,7 @@ public class JalviewJSApp implements JalviewJSApi StringBuffer data = new StringBuffer("PASTE"); int i = 1; String file = null; - while ((file = (String) getAppletParameter("sequence" + i, - true)) != null) + while ((file = getParameter("sequence" + i)) != null) { data.append(file.toString() + "\n"); i++; @@ -604,43 +397,56 @@ public class JalviewJSApp implements JalviewJSApi } /** + * @j2sAlias getSelectedSequences * - * @see jalview.appletgui.js.JalviewLiteJsApi#getSelectedSequences() + * @see jalview.appletgui.js.JalviewLiteJsApi#getSelectedSequencesFrom(jalview.appletgui + * .AlignFrame) */ @Override - public SequenceI[] getSelectedSequences() + public SequenceI[] getSelectedSequences(AlignFrame alf) { - return getSelectedSequencesFrom(Jalview.getCurrentAlignFrame()); - } - - /** - * - * @see jalview.appletgui.js.JalviewLiteJsApi#getSelectedSequences(java.lang.String) - */ - @Override - public SequenceI[] getSelectedSequences(String sep) - { - return getSelectedSequencesFrom(Jalview.getCurrentAlignFrame(), sep); + // return getSelectedSequencesFrom(alf, null); + // } + // + // @Override + // public SequenceI[] getSelectedSequencesFrom(AlignFrame alf, String sep) + // { + if (alf == null) + { + alf = getCurrentAlignFrame(); + } + AlignViewport v = alf.getViewport(); + if (v.getSelectionGroup() != null) + { + return v.getSelectionGroup().getSequencesInOrder(v.getAlignment()); + } + return null; } + // /** + // * + // * @see + // jalview.appletgui.js.JalviewLiteJsApi#getSelectedSequencesFrom(jalview.appletgui + // * .AlignFrame, java.lang.String) + // */ + // @Override + // public void highlight(String sequenceId, String position, + // String alignedPosition) + // { + // highlightIn(null, sequenceId, position, alignedPosition); + // } + /** + * @j2sAlias getSelectedSequencesAsAlignment + */ @Override public String getSelectedSequencesAsAlignment(String format, - String suffix) - { - return getSelectedSequencesAsAlignmentFrom(null, format, suffix); - } - - @Override - public String getSelectedSequencesAsAlignmentFrom(AlignFrame alf, - String format, String suffix) + boolean addSuffix, AlignFrame alf) { if (alf == null) { - alf = Jalview.getCurrentAlignFrame(); + alf = getCurrentAlignFrame(); } - - boolean seqlimits = (suffix == null || suffix.equalsIgnoreCase("true")); try { AlignViewport vp = alf.getViewport(); @@ -651,7 +457,7 @@ public class JalviewJSApp implements JalviewJSApi // method now returns a full copy of sequence data // TODO consider using getSequenceSelection instead here String reply = new AppletFormatAdapter().formatSequences(theFormat, - new Alignment(vp.getSelectionAsNewSequence()), seqlimits); + new Alignment(vp.getSelectionAsNewSequence()), addSuffix); return reply; } } catch (IllegalArgumentException ex) @@ -663,118 +469,13 @@ public class JalviewJSApp implements JalviewJSApi return ""; } - /** - * - * @see jalview.appletgui.js.JalviewLiteJsApi#getSelectedSequencesFrom(jalview.appletgui - * .AlignFrame) - */ - @Override - public SequenceI[] getSelectedSequencesFrom(AlignFrame alf) - { - return getSelectedSequencesFrom(alf, null); - } - - @Override - public SequenceI[] getSelectedSequencesFrom(AlignFrame alf, String sep) - { - if (alf == null) - { - alf = Jalview.getCurrentAlignFrame(); - } - AlignViewport v = alf.getViewport(); - if (v.getSelectionGroup() != null) - { - return v.getSelectionGroup() - .getSequencesInOrder(v.getAlignment()); - } - - return null; - } - - public Object[] getSelectionForListener(AlignFrame alf, - SequenceGroup seqsel, ColumnSelection colsel, - HiddenColumns hidden, SelectionSource source, Object alignFrame) - { - if (alf == null) - { - alf = Jalview.getCurrentAlignFrame(); - } - // System.err.println("Testing selection event relay to - // jsfunction:"+_listener); - String setid = ""; - AlignFrame src = (AlignFrame) alignFrame; - if (source != null) - { - if (source instanceof AlignViewport && alf.getViewport() == source) - { - // should be valid if it just generated an event! - src = alf; - - } - } - String[] seqs = new String[] {}; - String[] cols = new String[] {}; - int strt = 0, end = (src == null) ? -1 - : src.alignPanel.av.getAlignment().getWidth(); - if (seqsel != null && seqsel.getSize() > 0) - { - seqs = new String[seqsel.getSize()]; - for (int i = 0; i < seqs.length; i++) - { - seqs[i] = seqsel.getSequenceAt(i).getName(); - } - if (strt < seqsel.getStartRes()) - { - strt = seqsel.getStartRes(); - } - if (end == -1 || end > seqsel.getEndRes()) - { - end = seqsel.getEndRes(); - } - } - if (colsel != null && !colsel.isEmpty()) - { - if (end == -1) - { - end = colsel.getMax() + 1; - } - cols = new String[colsel.getSelected().size()]; - for (int i = 0; i < cols.length; i++) - { - cols[i] = "" + (1 + colsel.getSelected().get(i).intValue()); - } - } - else - { - if (seqsel != null && seqsel.getSize() > 0) - { - // send a valid range, otherwise we send the empty selection - cols = new String[2]; - cols[0] = "" + (1 + strt) + "-" + (1 + end); - } - } - return new Object[] { src, setid, seqs, cols }; - } - - /** - * - * @see jalview.appletgui.js.JalviewLiteJsApi#getSelectedSequencesFrom(jalview.appletgui - * .AlignFrame, java.lang.String) - */ @Override public void highlight(String sequenceId, String position, - String alignedPosition) - { - highlightIn(null, sequenceId, position, alignedPosition); - } - - @Override - public void highlightIn(AlignFrame alf, final String sequenceId, - final String position, final String alignedPosition) + String alignedPosition, AlignFrame alf) { if (alf == null) { - alf = Jalview.getCurrentAlignFrame(); + alf = getCurrentAlignFrame(); } // TODO: could try to highlight in all alignments if alf==null jalview.analysis.SequenceIdMatcher matcher = new jalview.analysis.SequenceIdMatcher( @@ -823,8 +524,9 @@ public class JalviewJSApp implements JalviewJSApi } } - public AlignFrame loadAlignment(String text, int width, int height, - String title) + @Override + public AlignFrame loadAlignment(String text, String title, int width, + int height) { AlignmentI al = null; @@ -836,7 +538,9 @@ public class JalviewJSApp implements JalviewJSApi format); if (al.getHeight() > 0) { - return new AlignFrame(al, width, height, title); + return new AlignFrame(al, + width > 0 ? width : AlignFrame.DEFAULT_WIDTH, + height > 0 ? height : AlignFrame.DEFAULT_HEIGHT, title); } } catch (IOException ex) { @@ -845,36 +549,12 @@ public class JalviewJSApp implements JalviewJSApi return null; } - // public void setMouseoverListener(String listener) - // { - // appLoader.setMouseoverListener(listener); - // } - // - // - // public void setMouseoverListener(AlignFrame af, String listener) - // { - // } - // - - @Override - public AlignFrame loadAlignment(String text, String title) - { - return loadAlignment(text, AlignFrame.DEFAULT_WIDTH, - AlignFrame.DEFAULT_HEIGHT, title); - } - - @Override - public void loadAnnotation(String annotation) - { - loadAnnotationFrom(null, annotation); - } - @Override - public void loadAnnotationFrom(AlignFrame alf, String annotation) + public void loadAnnotation(String annotation, AlignFrame alf) { if (alf == null) { - alf = Jalview.getCurrentAlignFrame(); + alf = getCurrentAlignFrame(); } if (new AnnotationFile().annotateAlignmentView(alf.getViewport(), annotation, DataSourceType.PASTE)) @@ -888,580 +568,263 @@ public class JalviewJSApp implements JalviewJSApi } } - /** - * Load annotations if specified by parameter. Returns true if loaded, else - * false. - * - * - * @param alignFrame - * @return - */ - protected boolean loadAnnotations(AlignFrame af) + @Override + public boolean loadFeatures(String features, boolean autoenabledisplay, + AlignFrame alf) { - boolean result = false; - String param = (String) getAppletParameter("annotations", true); - if (param != null) + if (alf == null) { - ret[0] = param; - DataSourceType protocol = resolveFileProtocol(ret); - param = ret[0]; - if (new AnnotationFile().annotateAlignmentView(af.getViewport(), param, - protocol)) - { - updateForAnnotations(); - result = true; - } - else - { - System.err - .println("Annotations were not added from annotation file '" - + param + "'"); - } + alf = getCurrentAlignFrame(); } - return result; - } - - //// JalviewJSApi - - /** - * Load features file and view settings as specified by parameters. Returns - * true if features were loaded, else false. - * @param - * - * @param alignFrame - * @return - */ - protected boolean loadFeatures(AlignFrame af) - { - boolean result = false; - // /////////////////////////// - // modify display of features - // we do this before any features have been loaded, ensuring any hidden - // groups are hidden when features first displayed - // - // hide specific groups - // - String param = (String) getAppletParameter("hidefeaturegroups", true); - if (param != null) + boolean ret = alf.parseFeaturesFile(features, DataSourceType.PASTE); + if (!ret) { - setFeatureGroupState(af, separatorListToArray(param, separator), false); - // setFeatureGroupStateOn(newAlignFrame, param, false); + return false; } - // show specific groups - param = (String) getAppletParameter("showfeaturegroups", true); - if (param != null) + if (autoenabledisplay) { - setFeatureGroupState(af, separatorListToArray(param, separator), true); - // setFeatureGroupStateOn(newAlignFrame, param, true); + alf.getViewport().setShowSequenceFeatures(true); + // this next was for a checkbox in JalviewLite + // ((AlignFrame) alf).getViewport().sequenceFeatures.setState(true); } - // and now load features - param = (String) getAppletParameter("features", true); - if (param != null) - { - ret[0] = param; - DataSourceType protocol = resolveFileProtocol(ret); + return true; + } - result = parseFeaturesFile(af, ret[0], protocol); + @Override + public boolean loadScoreFile(String fileName, AlignFrame alf) + { + try + { + (alf == null ? getCurrentAlignFrame() : alf) + .loadJalviewDataFile(fileName, null, null, null); + return true; + } catch (Throwable t) + { + return false; } + } - param = (String) getAppletParameter("showFeatureSettings", true); - if (param != null && param.equalsIgnoreCase("true")) + /** + * @j2sAlias openPcaPanel + * + * public static method for JalviewJS API to open a PCAPanel without + * necessarily using a dialog. + * @param modelName + * @param alf + * + * @return the PCAPanel, or the string "label.you_need_at_least_n_sequences" + * if number of sequences selected is inappropriate + */ + @Override + public Object openPcaPanel(String modelName, AlignFrame alf) + { + if (alf == null) { - newFeatureSettings(); + alf = getCurrentAlignFrame(); } - return result; + return CalculationChooser.openPcaPanel(alf, modelName, null); } + /** + * @j2sAlias openTreePanel + * + * Open a new Tree panel on the desktop statically. Params are + * standard (not set by Groovy). No dialog is opened. + * @param treeType + * @param modelName + * @param alf + * + * @return null, or the string "label.you_need_at_least_n_sequences" if number + * of sequences selected is inappropriate + */ @Override - public void loadFeatures(String features, boolean autoenabledisplay) + public Object openTreePanel(String treeType, String modelName, + AlignFrame alf) { - loadFeaturesFrom(null, features, autoenabledisplay); + if (alf == null) + { + alf = getCurrentAlignFrame(); + } + return CalculationChooser.openTreePanel(alf, treeType, modelName, null); } @Override - public boolean loadFeaturesFrom(AlignFrame alf, String features, - boolean autoenabledisplay) + public boolean orderAlignment(String[] ids, String undoName, + AlignFrame alf) { if (alf == null) + alf = getCurrentAlignFrame(); + SequenceI[] sqs = null; + if (ids != null && ids.length > 0) { - alf = Jalview.getCurrentAlignFrame(); + jalview.analysis.SequenceIdMatcher matcher = new jalview.analysis.SequenceIdMatcher( + alf.getViewport().getAlignment().getSequencesArray()); + int s = 0; + sqs = new SequenceI[ids.length]; + for (int i = 0; i < ids.length; i++) + { + if (ids[i].trim().length() == 0) + { + continue; + } + SequenceI sq = matcher.findIdMatch(ids[i]); + if (sq != null) + { + sqs[s++] = sq; + } + } + if (s > 0) + { + SequenceI[] sqq = new SequenceI[s]; + System.arraycopy(sqs, 0, sqq, 0, s); + sqs = sqq; + } + else + { + sqs = null; + } } - boolean ret = alf.parseFeaturesFile(features, DataSourceType.PASTE); - if (!ret) + if (sqs == null) { return false; } - if (autoenabledisplay) + ; + final AlignmentOrder aorder = new AlignmentOrder(sqs); + + if (undoName != null && undoName.trim().length() == 0) { - alf.getViewport().setShowSequenceFeatures(true); - // this next was for a checkbox in JalviewLite - // ((AlignFrame) alf).getViewport().sequenceFeatures.setState(true); + undoName = null; } - return true; + final String _undoName = undoName; + // TODO: deal with synchronization here: cannot raise any events until + // alfter + // this has returned. + return alf.sortBy(aorder, _undoName); } /** - * Load in a Jnetfile if specified by parameter. Returns true if loaded, else - * false. + * Allow an outside entity to initiate the second half of argument parsing + * (only). * - * @param alignFrame - * @return + * @param args + * @return null is good */ - protected boolean loadJnetFile(AlignFrame af) + @Override + public Object parseArguments(String[] args) { - boolean result = false; - String param = (String) getAppletParameter("jnetfile", true); - if (param == null) + + try { - // jnet became jpred around 2016 - param = (String) getAppletParameter("jpredfile", true); - } - if (param != null) + jalview.parseArguments(new ArgsParser(args), false); + return null; + } catch (Throwable t) { - try - { - ret[0] = param; - DataSourceType protocol = resolveFileProtocol(ret); - JPredFile predictions = new JPredFile(ret[0], protocol); - JnetAnnotationMaker.add_annotation(predictions, - af.getViewport().getAlignment(), 0, false); - // false == do not add sequence profile from concise output - af.getViewport().getAlignment().setupJPredAlignment(); - updateForAnnotations(); - result = true; - } catch (Exception ex) - { - ex.printStackTrace(); - } + return t; } - return result; } /** - * Load PDBFiles if any specified by parameter(s). Returns true if loaded, - * else false. + * @j2sAlias parseFeatureFile * - * @param loaderFrame + * @param filename + * @param alf * @return */ - protected boolean loadPdbFiles(AlignFrame af) - { - boolean result = false; - /* - * Undocumented for 2.6 - - * related to JAL-434 - */ - - // not supported (as for JalviewLite) - // boolean doAlign = false;//"true".equalsIgnoreCase("" + - // getAppletParameter("alignpdbfiles", false)); - // setAlignPdbStructures(doAlign); - /* - * - * - * - * - * - */ - - // Accumulate pdbs here if they are heading for the same view (if - // alignPdbStructures is true) - // ArrayList pdbs = new ArrayList<>(); - // create a lazy matcher if we're asked to - boolean relaxed = "true".equalsIgnoreCase( - "" + getAppletParameter("relaxedidmatch", false)); - jalview.analysis.SequenceIdMatcher matcher = relaxed - ? new jalview.analysis.SequenceIdMatcher( - af.getViewport().getAlignment().getSequencesArray()) - : null; - - int pdbFileCount = 0; - String param; - do - { - if (pdbFileCount > 0) - { - param = (String) getAppletParameter("PDBFILE" + pdbFileCount, true); - } - else - { - param = (String) getAppletParameter("PDBFILE", true); - } - - if (param != null) - { - PDBEntry pdb = new PDBEntry(); - - String seqstring; - SequenceI[] seqs = null; - String[] chains = null; - - StringTokenizer st = new StringTokenizer(param, " "); - - if (st.countTokens() < 2) - { - String sequence = (String) getAppletParameter("PDBSEQ", true); - if (sequence != null) - { - seqs = new SequenceI[] { matcher == null - ? (Sequence) af.getViewport().getAlignment() - .findName(sequence) - : matcher.findIdMatch(sequence) }; - } - - } - else - { - param = st.nextToken(); - List tmp = new ArrayList<>(); - List tmp2 = new ArrayList<>(); - - while (st.hasMoreTokens()) - { - seqstring = st.nextToken(); - StringTokenizer st2 = new StringTokenizer(seqstring, "="); - if (st2.countTokens() > 1) - { - // This is the chain - tmp2.add(st2.nextToken()); - seqstring = st2.nextToken(); - } - tmp.add(matcher == null - ? (Sequence) af.getViewport().getAlignment() - .findName(seqstring) - : matcher.findIdMatch(seqstring)); - } - - seqs = tmp.toArray(new SequenceI[tmp.size()]); - if (tmp2.size() == tmp.size()) - { - chains = tmp2.toArray(new String[tmp2.size()]); - } - } - pdb.setId(param); - ret[0] = param; - DataSourceType protocol = resolveFileProtocol(ret); - // TODO check JAL-357 for files in a jar (CLASSLOADER) - pdb.setFile(ret[0]); - - if (seqs != null) - { - for (int i = 0; i < seqs.length; i++) - { - if (seqs[i] != null) - { - ((Sequence) seqs[i]).addPDBId(pdb); - StructureSelectionManager - .getStructureSelectionManager( - (StructureSelectionManagerProvider) this) - .registerPDBEntry(pdb); - } - else - { - if (debug) - { - // this may not really be a problem but we give a warning - // anyway - System.err.println( - "Warning: Possible input parsing error: Null sequence for attachment of PDB (sequence " - + i + ")"); - } - } - } - - // if (doAlign) - // { - // pdbs.add(new Object[] { pdb, seqs, chains, protocol }); - // } - // else - { - newStructureView(af, pdb, seqs, chains, protocol); - } - } - } - - pdbFileCount++; - } while (param != null || pdbFileCount < 10); - // - // if (doAlign && pdbs.size() > 0) - // { - // SequenceI[][] seqs = new SequenceI[pdbs.size()][]; - // PDBEntry[] pdb = new PDBEntry[pdbs.size()]; - // String[][] chains = new String[pdbs.size()][]; - // String[] protocols = new String[pdbs.size()]; - // for (int pdbsi = 0, pdbsiSize = pdbs - // .size(); pdbsi < pdbsiSize; pdbsi++) - // { - // Object[] o = pdbs.get(pdbsi); - // pdb[pdbsi] = (PDBEntry) o[0]; - // seqs[pdbsi] = (SequenceI[]) o[1]; - // chains[pdbsi] = (String[]) o[2]; - // protocols[pdbsi] = (String) o[3]; - // } - //// alignedStructureView(pdb, seqs, chains, protocols); - // result = true; - // } - return result; - } - - /** - * Load a score file if specified by parameter. Returns true if file was - * loaded, else false. - * - * @param loaderFrame - */ - protected boolean loadScoreFile() + @Override + public boolean parseFeaturesFile(String filename, AlignFrame alf) { - boolean result = false; - String sScoreFile = (String) getAppletParameter("scoreFile", true); - if (sScoreFile != null && !"".equals(sScoreFile)) - { - try - { - if (debug) - { - System.err.println( - "Attempting to load T-COFFEE score file from the scoreFile parameter"); - } - result = loadScoreFile(sScoreFile); - if (!result) - { - System.err.println( - "Failed to parse T-COFFEE parameter as a valid score file ('" - + sScoreFile + "')"); - } - } catch (Exception e) - { - System.err.printf("Cannot read score file: '%s'. Cause: %s \n", - sScoreFile, e.getMessage()); - } - } - return result; + ret[0] = filename; + DataSourceType protocol = resolveFileProtocol(ret); + if (protocol == null) + return false; + return (alf == null ? getCurrentAlignFrame() : alf) + .parseFeaturesFile(ret[0], protocol); } - /** - * Load a tree for the alignment if specified by parameter. Returns true if a - * tree was loaded, else false. - * - * @return - */ - protected boolean loadTree(AlignFrame af) + @Override + public void removeSelectionListener(String listener, AlignFrame alf) { - boolean result = false; - String treeFile = (String) getAppletParameter("tree", true); - if (treeFile == null) - { - treeFile = (String) getAppletParameter("treefile", true); - } - if (treeFile != null) + List listeners = Desktop + .getStructureSelectionManager().getListeners(); + for (int i = listeners.size(); --i >= 0;) { - try - { - ret[0] = treeFile; - NewickFile fin = new NewickFile(treeFile, resolveFileProtocol(ret)); - fin.parse(); - - if (fin.getTree() != null) - { - loadTree(af, fin, ret[0]); - result = true; - if (debug) - { - System.out.println("Successfully imported tree."); - } - } - else - { - if (debug) - { - System.out.println( - "Tree parameter did not resolve to a valid tree."); - } - } - } catch (Exception ex) + SelectionListener l = listeners.get(i); + if (l instanceof JsSelectionListener + && ((JsSelectionListener) l).isFor(alf, listener)) { - ex.printStackTrace(); + listeners.remove(i); + break; } } - return result; - } - - /** - * @j2sAlias openPcaPanel - * - * public static method for JalviewJS API to open a PCAPanel without - * necessarily using a dialog. - * - * @param af - * @param modelName - * @return the PCAPanel, or the string "label.you_need_at_least_n_sequences" - * if number of sequences selected is inappropriate - */ - @Override - public Object openPcaPanel(AlignFrame af, String modelName) - { - if (af == null) - { - af = Jalview.getCurrentAlignFrame(); - } - return CalculationChooser.openPcaPanel(af, modelName, null); } - /** - * @j2sAlias openTreePanel - * - * Open a new Tree panel on the desktop statically. Params are standard (not - * set by Groovy). No dialog is opened. - * - * @param af - * @param treeType - * @param modelName - * @return null, or the string "label.you_need_at_least_n_sequences" if number - * of sequences selected is inappropriate - */ - @Override - public Object openTreePanel(AlignFrame af, String treeType, - String modelName) + private DataSourceType resolveFileProtocol(String[] retPath) { - if (af == null) + String path = retPath[0]; + /* + * is it paste data? + */ + if (path.startsWith("PASTE")) { - af = Jalview.getCurrentAlignFrame(); + retPath[0] = path.substring(5); + return DataSourceType.PASTE; } - return CalculationChooser.openTreePanel(af, treeType, modelName, null); - } - - - @Override - public String orderBy(String[] ids, String undoName) - { - return orderAlignmentBy(null, ids, undoName); - } - @Override - public String orderAlignmentBy(AlignFrame alf, String[] ids, - String undoName) - { - if (alf == null) - alf = Jalview.getCurrentAlignFrame(); - SequenceI[] sqs = null; - if (ids != null && ids.length > 0) - { - jalview.analysis.SequenceIdMatcher matcher = new jalview.analysis.SequenceIdMatcher( - alf.getViewport().getAlignment().getSequencesArray()); - int s = 0; - sqs = new SequenceI[ids.length]; - for (int i = 0; i < ids.length; i++) - { - if (ids[i].trim().length() == 0) - { - continue; - } - SequenceI sq = matcher.findIdMatch(ids[i]); - if (sq != null) - { - sqs[s++] = sq; - } - } - if (s > 0) - { - SequenceI[] sqq = new SequenceI[s]; - System.arraycopy(sqs, 0, sqq, 0, s); - sqs = sqq; - } - else - { - sqs = null; - } - } - if (sqs == null) + /* + * is it a URL? + */ + if (path.indexOf("://") >= 0) { - return ""; + return DataSourceType.URL; } - ; - final AlignmentOrder aorder = new AlignmentOrder(sqs); - if (undoName != null && undoName.trim().length() == 0) + /* + * try relative to document root + */ + URL documentBase = getDocumentBase(); + String withDocBase = resolveUrlForLocalOrAbsolute(path, documentBase); + if (HttpUtils.isValidUrl(withDocBase)) { - undoName = null; + // if (debug) + // { + // System.err.println("Prepended document base '" + documentBase + // + "' to make: '" + withDocBase + "'"); + // } + retPath[0] = withDocBase; + return DataSourceType.URL; } - final String _undoName = undoName; - // TODO: deal with synchronization here: cannot raise any events until after - // this has returned. - return alf.sortBy(aorder, _undoName) ? "true" : ""; - } - /** - * Allow an outside entity to initiate the second half of argument parsing - * (only). - * - * @param args - * @return null is good - */ - @Override - public Object parseArguments(String[] args) - { - - try - { - jalview.parseArguments(new ArgsParser(args), false); - return null; - } catch (Throwable t) + /* + * try relative to codebase (if different to document base) + */ + URL codeBase = getCodeBase(); + String withCodeBase = resolveUrlForLocalOrAbsolute(path, codeBase); + if (!withCodeBase.equals(withDocBase) + && HttpUtils.isValidUrl(withCodeBase)) { - return t; + // if (debug) + // { + // System.err.println("Prepended codebase '" + codeBase + // + "' to make: '" + withCodeBase + "'"); + // } + retPath[0] = withCodeBase; + return DataSourceType.URL; } - } - @Override - public void removeSelectionListener(AlignFrame af, String listener) - { - - List listeners = Desktop - .getStructureSelectionManager().getListeners(); - for (int i = listeners.size(); --i >= 0;) + /* + * try locating by classloader; try this last so files in the directory + * are resolved using document base + */ + if (inArchive(getClass(), path)) { - SelectionListener l = listeners.get(i); - if (l instanceof JsSelectionListener - && ((JsSelectionListener) l).isFor(af, listener)) - { - listeners.remove(i); - break; - } + return DataSourceType.CLASSLOADER; } + return null; } @Override - public void scrollViewToColumnIn(final AlignFrame alf, - final String leftHandColumn) - { - java.awt.EventQueue.invokeLater(new Runnable() - { - - @Override - public void run() - { - try - { - (alf == null ? Jalview.getCurrentAlignFrame() : alf) - .scrollToColumn( - Integer.valueOf(leftHandColumn).intValue()); - - } catch (Exception ex) - { - System.err.println( - "Couldn't parse integer arguments (leftHandColumn='" - + leftHandColumn + "')"); - ex.printStackTrace(); - } - } - }); - - } - - @Override - public void scrollViewToIn(final AlignFrame alf, final String topRow, - final String leftHandColumn) + public void scrollViewTo(int topRow, int leftHandColumn, AlignFrame alf) { // TODO test java.awt.EventQueue.invokeLater(new Runnable() @@ -1471,10 +834,8 @@ public class JalviewJSApp implements JalviewJSApi { try { - (alf == null ? Jalview.getCurrentAlignFrame() : alf).scrollTo( - Integer.valueOf(topRow).intValue(), - Integer.valueOf(leftHandColumn).intValue()); - + (alf == null ? getCurrentAlignFrame() : alf).scrollTo(topRow, + leftHandColumn); } catch (Exception ex) { System.err.println("Couldn't parse integer arguments (topRow='" @@ -1487,98 +848,10 @@ public class JalviewJSApp implements JalviewJSApi } @Override - public void scrollViewToRowIn(final AlignFrame alf, final String topRow) - { - // TODO test - - java.awt.EventQueue.invokeLater(new Runnable() - { - @Override - public void run() - { - try - { - (alf == null ? Jalview.getCurrentAlignFrame() : alf) - .scrollToRow(Integer.valueOf(topRow).intValue()); - - } catch (Exception ex) - { - System.err.println("Couldn't parse integer arguments (topRow='" - + topRow + "')"); - ex.printStackTrace(); - } - - } - }); - } - - @Override - public void select(String sequenceIds, String columns) - { - selectIn(Jalview.getCurrentAlignFrame(), sequenceIds, columns, null); - } - - @Override - public void select(String sequenceIds, String columns, String sep) - { - selectIn(null, sequenceIds, columns, sep); - } - - // @Override - // public AlignFrame newView() - // { - // return newViewFrom(null, null); - // } - // - // @Override - // public AlignFrame newView(String name) - // { - // return newViewFrom(null, name); - // } - // - // @Override - // public AlignFrame newViewFrom(AlignFrame alf) - // { - // return newViewFrom(alf, null); - // } - // - // @Override - // public AlignFrame newViewFrom(AlignFrame alf, String name) - // { - // if (alf == null) - // { - // alf = Jalview.getCurrentAlignFrame(); - // } - // return appLoader.newViewFrom(alf, name); - // } - - @Override - public void selectIn(AlignFrame alf, String sequenceIds, String columns) - { - selectIn(alf, sequenceIds, columns, null); - } - - @Override - public void selectIn(AlignFrame af, String sequenceIds, String columns, - String sep) + public void select(String ids[], String cols[], AlignFrame alf) { - AlignFrame alf = (af == null ? Jalview.getCurrentAlignFrame() : af); - - if (sep == null || sep.length() == 0) - { - sep = separator; - } - else - { - if (debug) - { - System.err.println("Selecting region using separator string '" - + separator + "'"); - } - } - // deparse fields - String[] ids = separatorListToArray(sequenceIds, sep); - String[] cols = separatorListToArray(columns, sep); + if (alf == null) + alf = getCurrentAlignFrame(); final SequenceGroup sel = new SequenceGroup(); final ColumnSelection csel = new ColumnSelection(); AlignmentI al = alf.getViewport().getAlignment(); @@ -1674,11 +947,6 @@ public class JalviewJSApp implements JalviewJSApi csel.addElement(r); } } - if (debug) - { - System.err.println("Range '" + cl + "' deparsed as [" + from - + "," + to + "]"); - } } else { @@ -1729,11 +997,6 @@ public class JalviewJSApp implements JalviewJSApi } } csel.addElement(r); - if (debug) - { - System.err.println("Point selection '" + cl - + "' deparsed as [" + r + "]"); - } } else { @@ -1762,78 +1025,249 @@ public class JalviewJSApp implements JalviewJSApi } sel.setStartRes(start); sel.setEndRes(end); + AlignFrame af = alf; EventQueue.invokeLater(new Runnable() { @Override public void run() { - alf.select(sel, csel, - alf.getCurrentView().getAlignment().getHiddenColumns()); + af.select(sel, csel, + af.getCurrentView().getAlignment().getHiddenColumns()); } }); } } + // + // @Override + // public void setFeatureGroupState(String[] groups, boolean state) + // { + // setFeatureGroupState(null, groups, state); + // } + // + // @Override + // public void setFeatureGroupState(String[] groups, boolean state) + // { // JalviewLite API + // setFeatureGroupStateOn(null, groups, state); + // } + // + @Override + public void setFeatureGroupState(final String[] groups, + boolean state, AlignFrame alf) + { + // setFeatureGroupState(alf, groups, state); + // java.awt.EventQueue.invokeLater(new Runnable() + // { + // @Override + // public void run() + // { + // (alf == null ? getCurrentAlignFrame() : alf) + // .setFeatureGroupState( + // separatorListToArray(groups, separator), state); + // } + // }); + // } + // + // public void setFeatureGroupState(AlignFrame alf, String[] groups, boolean + // state) { + (alf == null ? getCurrentAlignFrame() : alf) + .setFeatureGroupState(groups, state); + } + @Override - public void setFeatureGroupState(String[] groups, boolean state) + public void setSelectionListener(String listener, AlignFrame alf) { - setFeatureGroupState(null, groups, state); + Desktop.getStructureSelectionManager() + .addSelectionListener(new JsSelectionListener(alf, listener)); } @Override - public void setFeatureGroupState(String groups, boolean state) - { // JalviewLite API - setFeatureGroupStateOn(null, groups, state); + public void showOverview() + { + getCurrentAlignFrame().overviewMenuItem_actionPerformed(null); } + /** + * @j2sAlias showStructure + */ @Override - public void setFeatureGroupStateOn(final AlignFrame alf, - final String groups, boolean state) + public void showStructure(String pdbID, String fileType, AlignFrame alf) { - setFeatureGroupState(alf, separatorListToArray(groups, separator), state); -// java.awt.EventQueue.invokeLater(new Runnable() -// { -// @Override -// public void run() -// { -// (alf == null ? Jalview.getCurrentAlignFrame() : alf) -// .setFeatureGroupState( -// separatorListToArray(groups, separator), state); -// } -// }); - } - - public void setFeatureGroupState(AlignFrame af, String[] groups, boolean state) { - (af == null ? Jalview.getCurrentAlignFrame() : af).setFeatureGroupState(groups, state); + if (alf == null) + alf = getCurrentAlignFrame(); + PDBEntry pe = null; + SequenceI[] seqs = null; + if (pdbID == null) + { + seqs = alf.getViewport().getSequenceSelection(); + if (seqs.length == 0) + seqs = alf.getViewport().getAlignment().getSequencesArray(); + for (int i = 0; i < seqs.length; i++) + { + Vector list = seqs[i].getAllPDBEntries(); + if (list.size() > 0) + { + pe = list.get(0); + break; + } + } + } + if (pe == null) + { + if (pdbID == null) + return; + pe = new PDBEntry(pdbID, null, fileType); + List list = alf.getViewport().getAlignment() + .getSequences(); + List tmp = new ArrayList(); + for (int i = 0; i < list.size(); i++) + { + SequenceI seq = list.get(i); + if (seq.getPDBEntry(pdbID) != null) + { + tmp.add(seq); + } + } + seqs = tmp.toArray(new SequenceI[tmp.size()]); + alf.alignPanel.selectSequences(tmp); + } + StructureViewer.launchStructureViewer(alf.alignPanel, pe, seqs); } + // private or package-private methods - @Override - public void setSelectionListener(AlignFrame af, String listener) + /** + * form a complete URL given a path to a resource and a reference location on + * the same server + * + * @param targetPath + * - an absolute path on the same server as localref or a document + * located relative to localref + * @param localref + * - a URL on the same server as url + * @return a complete URL for the resource located by url + */ + private static String resolveUrlForLocalOrAbsolute(String targetPath, + URL localref) { - Desktop.getStructureSelectionManager() - .addSelectionListener(new JsSelectionListener(af, listener)); + String resolvedPath = ""; + if (targetPath.startsWith("/")) + { + String codebase = localref.toString(); + String localfile = localref.getFile(); + resolvedPath = codebase.substring(0, + codebase.length() - localfile.length()) + targetPath; + return resolvedPath; + } + + /* + * get URL path and strip off any trailing file e.g. + * www.jalview.org/examples/index.html#applets?a=b is trimmed to + * www.jalview.org/examples/ + */ + String urlPath = localref.toString(); + String directoryPath = urlPath; + int lastSeparator = directoryPath.lastIndexOf("/"); + if (lastSeparator > 0) + { + directoryPath = directoryPath.substring(0, lastSeparator + 1); + } + + if (targetPath.startsWith("/")) + { + /* + * construct absolute URL to a file on the server - this is not allowed? + */ + // String localfile = localref.getFile(); + // resolvedPath = urlPath.substring(0, + // urlPath.length() - localfile.length()) + // + targetPath; + resolvedPath = directoryPath + targetPath.substring(1); + } + else + { + resolvedPath = directoryPath + targetPath; + } + // if (debug) + // { + // System.err.println( + // "resolveUrlForLocalOrAbsolute returning " + resolvedPath); + // } + return resolvedPath; } - @Override - public void setSelectionListener(String listener) + /** + * parse the string into a list + * + * @param list + * @param separator + * @return elements separated by separator + */ + private static String[] separatorListToArray(String list, + String separator) { - Desktop.getStructureSelectionManager() - .addSelectionListener(new JsSelectionListener(null, listener)); + // TODO use StringUtils version (slightly different...) + int seplen = separator.length(); + if (list == null || list.equals("") || list.equals(separator)) + { + return null; + } + Vector jv = new Vector<>(); + int cp = 0, pos; + while ((pos = list.indexOf(separator, cp)) > cp) + { + jv.addElement(list.substring(cp, pos)); + cp = pos + seplen; + } + if (cp < list.length()) + { + String c = list.substring(cp); + if (!c.equals(separator)) + { + jv.addElement(c); + } + } + if (jv.size() > 0) + { + String[] v = new String[jv.size()]; + for (int i = 0; i < v.length; i++) + { + v[i] = jv.elementAt(i); + } + jv.removeAllElements(); + return v; + } + return null; } - @Override - public void showOverview() + /** + * Discovers whether the given file is in the Applet Archive + * + * @param f + * String + * @return boolean + */ + private static boolean inArchive(Class c, String f) { - Jalview.getCurrentAlignFrame().overviewMenuItem_actionPerformed(null); + // This might throw a security exception in certain browsers + // Netscape Communicator for instance. + try + { + boolean rtn = (c.getResourceAsStream("/" + f) != null); + return rtn; + } catch (Exception ex) + { + System.out.println("Exception checking resources: " + f + " " + ex); + return false; + } } /** * Allowing for a JavaScript function here. */ - public void callInitCallback() + void callInitCallback() { - Object initjscallback = getAppletParameter("oninit", false); + Object initjscallback = getParameterAsObject("oninit"); if (initjscallback != null) { try @@ -1858,7 +1292,7 @@ public class JalviewJSApp implements JalviewJSApi * @param data * @return String return from the callback method. */ - public String doSendCallback(Object callback, Object[] data) + String doSendCallback(Object callback, Object[] data) { Jalview me = jalview; @@ -1883,287 +1317,367 @@ public class JalviewJSApp implements JalviewJSApi return ""; } - private DataSourceType resolveFileProtocol(String[] retPath) + /** + * Initialize from Info.key/value pairs that match the old JalviewLite applet + * parameters. + * + * See http://www.jalview.org/old/v2_8/examples/appletParameters.html + * + * Note that some of these parameters are handled as command-line arguments, + * as determined in ArgsParser. + * + * @param alf + */ + private void initFromParams(AlignFrame alf) { - String path = retPath[0]; - /* - * is it paste data? - */ - if (path.startsWith("PASTE")) - { - retPath[0] = path.substring(5); - return DataSourceType.PASTE; - } - - /* - * is it a URL? - */ - if (path.indexOf("://") >= 0) - { - return DataSourceType.URL; - } - - /* - * try relative to document root - */ - URL documentBase = getDocumentBase(); - String withDocBase = resolveUrlForLocalOrAbsolute(path, documentBase); - if (HttpUtils.isValidUrl(withDocBase)) - { - // if (debug) - // { - // System.err.println("Prepended document base '" + documentBase - // + "' to make: '" + withDocBase + "'"); - // } - retPath[0] = withDocBase; - return DataSourceType.URL; - } - - /* - * try relative to codebase (if different to document base) - */ - URL codeBase = getCodeBase(); - String withCodeBase = resolveUrlForLocalOrAbsolute(path, codeBase); - if (!withCodeBase.equals(withDocBase) - && HttpUtils.isValidUrl(withCodeBase)) - { - // if (debug) - // { - // System.err.println("Prepended codebase '" + codeBase - // + "' to make: '" + withCodeBase + "'"); - // } - retPath[0] = withCodeBase; - return DataSourceType.URL; - } - - /* - * try locating by classloader; try this last so files in the directory - * are resolved using document base - */ - if (inArchive(getClass(), path)) + String sep = getParameter("separator"); + if (sep != null && sep.length() > 0) { - return DataSourceType.CLASSLOADER; + separator = sep; } - return null; + initTree(alf); + initScoreFile(alf); + initFeatures(alf); + initAnnotations(alf); + initJnetFile(alf); + initPdbFiles(alf); } /** - * Discovers whether the given file is in the Applet Archive + * Load annotations if specified by parameter. Returns true if loaded, else + * false. * - * @param f - * String - * @return boolean + * + * @param alignFrame + * @return */ - private static boolean inArchive(Class c, String f) + private boolean initAnnotations(AlignFrame alf) { - // This might throw a security exception in certain browsers - // Netscape Communicator for instance. - try - { - boolean rtn = (c.getResourceAsStream("/" + f) != null); - return rtn; - } catch (Exception ex) - { - System.out.println("Exception checking resources: " + f + " " + ex); + + String param = getParameter("annotations"); + if (param == null) + return false; + ret[0] = param; + DataSourceType protocol = resolveFileProtocol(ret); + param = ret[0]; + if (!new AnnotationFile().annotateAlignmentView(alf.getViewport(), + param, protocol)) + { + System.err.println("Annotations were not added from annotation file '" + + param + "'"); return false; } + updateForAnnotations(); + return true; } /** - * form a complete URL given a path to a resource and a reference location on - * the same server - * - * @param targetPath - * - an absolute path on the same server as localref or a document - * located relative to localref - * @param localref - * - a URL on the same server as url - * @return a complete URL for the resource located by url + * Load features file and view settings as specified by parameters. Returns + * true if features were loaded, else false. + * + * @param + * + * @param alignFrame + * @return */ - public static String resolveUrlForLocalOrAbsolute(String targetPath, - URL localref) + private boolean initFeatures(AlignFrame alf) { - String resolvedPath = ""; - if (targetPath.startsWith("/")) + + // /////////////////////////// + // modify display of features + // we do this before any features have been loaded, ensuring any hidden + // groups are hidden when features first displayed + // + // hide specific groups + // + String param = getParameter("hidefeaturegroups"); + if (param != null) { - String codebase = localref.toString(); - String localfile = localref.getFile(); - resolvedPath = codebase.substring(0, - codebase.length() - localfile.length()) + targetPath; - return resolvedPath; + setFeatureGroupState(separatorListToArray(param, separator), + false, alf); + // setFeatureGroupStateOn(newAlignFrame, param, false); } - - /* - * get URL path and strip off any trailing file e.g. - * www.jalview.org/examples/index.html#applets?a=b is trimmed to - * www.jalview.org/examples/ - */ - String urlPath = localref.toString(); - String directoryPath = urlPath; - int lastSeparator = directoryPath.lastIndexOf("/"); - if (lastSeparator > 0) + // show specific groups + param = getParameter("showfeaturegroups"); + if (param != null) { - directoryPath = directoryPath.substring(0, lastSeparator + 1); + setFeatureGroupState(separatorListToArray(param, separator), + true, alf); + // setFeatureGroupStateOn(newAlignFrame, param, true); } - - if (targetPath.startsWith("/")) + // and now load features + param = getParameter("features"); + if (param == null) { - /* - * construct absolute URL to a file on the server - this is not allowed? - */ - // String localfile = localref.getFile(); - // resolvedPath = urlPath.substring(0, - // urlPath.length() - localfile.length()) - // + targetPath; - resolvedPath = directoryPath + targetPath.substring(1); + return false; } - else + if (!parseFeaturesFile(param, alf)) + return false; + param = getParameter("showFeatureSettings"); + if (param != null && param.equalsIgnoreCase("true")) { - resolvedPath = directoryPath + targetPath; + alf.showFeatureSettingsUI(); } - // if (debug) - // { - // System.err.println( - // "resolveUrlForLocalOrAbsolute returning " + resolvedPath); - // } - return resolvedPath; + return true; } /** - * parse the string into a list + * Load in a Jnetfile if specified by parameter. Returns true if loaded, else + * false. * - * @param list - * @param separator - * @return elements separated by separator + * @param alignFrame + * @return */ - public static String[] separatorListToArray(String list, String separator) + private boolean initJnetFile(AlignFrame alf) { - // TODO use StringUtils version (slightly different...) - int seplen = separator.length(); - if (list == null || list.equals("") || list.equals(separator)) - { - return null; - } - Vector jv = new Vector<>(); - int cp = 0, pos; - while ((pos = list.indexOf(separator, cp)) > cp) + + String param = getParameter("jnetfile"); + if (param == null) { - jv.addElement(list.substring(cp, pos)); - cp = pos + seplen; + // jnet became jpred around 2016 + param = getParameter("jpredfile"); } - if (cp < list.length()) + if (param != null) { - String c = list.substring(cp); - if (!c.equals(separator)) + try { - jv.addElement(c); - } - } - if (jv.size() > 0) - { - String[] v = new String[jv.size()]; - for (int i = 0; i < v.length; i++) + ret[0] = param; + DataSourceType protocol = resolveFileProtocol(ret); + JPredFile predictions = new JPredFile(ret[0], protocol); + JnetAnnotationMaker.add_annotation(predictions, + alf.getViewport().getAlignment(), 0, false); + // false == do not add sequence profile from concise output + alf.getViewport().getAlignment().setupJPredAlignment(); + updateForAnnotations(); + } catch (Exception ex) { - v[i] = jv.elementAt(i); + ex.printStackTrace(); + return false; } - jv.removeAllElements(); - return v; } - return null; + return true; } - public class JsSelectionListener - implements jalview.structure.SelectionListener + /** + * Load PDBFiles if any specified by parameter(s). Returns true if loaded, + * else false. + * + * @param loaderFrame + * @return + */ + private boolean initPdbFiles(AlignFrame alf) { - AlignFrame _af; + /* + * Undocumented for 2.6 - + * related to JAL-434 + */ - String _listener; + // not supported (as for JalviewLite) + // boolean doAlign = false;//"true".equalsIgnoreCase("" + + // getAppletParameter("alignpdbfiles", false)); + // setAlignPdbStructures(doAlign); + /* + * + * + * + * + * + */ + + // Accumulate pdbs here if they are heading for the same view (if + // alignPdbStructures is true) + // ArrayList pdbs = new ArrayList<>(); + // init a lazy matcher if we're asked to + boolean relaxed = "true" + .equalsIgnoreCase(getParameter("relaxedidmatch")); + jalview.analysis.SequenceIdMatcher matcher = relaxed + ? new jalview.analysis.SequenceIdMatcher( + alf.getViewport().getAlignment().getSequencesArray()) + : null; - public JsSelectionListener(AlignFrame af, String listener) + String param = getParameter("PDBFILE"); + int plast = (param == null ? 9 : 1); + if (param == null && (param = getParameter("PDBFILE1")) == null) { - _af = af; - _listener = listener; + return false; } - - @Override - public void selection(SequenceGroup seqsel, ColumnSelection colsel, - HiddenColumns hidden, SelectionSource source) + for (int p = 1; p <= plast; p++) { - // System.err.println("Testing selection event relay to - // jsfunction:"+_listener); - String setid = ""; - AlignFrame src = _af; - if (source != null) + if (p > 1) { - if (source instanceof AlignViewport - && Jalview.getCurrentAlignFrame().getViewport() == source) - { - src = Jalview.getCurrentAlignFrame(); - if (src != _af) - return; - } + param = getParameter("PDBFILE" + p); + if (param == null) + break; } - String[] seqs = new String[] {}; - String[] cols = new String[] {}; - int strt = 0, end = (src == null) ? -1 - : src.alignPanel.av.getAlignment().getWidth(); - if (seqsel != null && seqsel.getSize() > 0) + PDBEntry pdb = new PDBEntry(); + + String seqstring; + SequenceI[] seqs = null; + String[] chains = null; + + StringTokenizer st = new StringTokenizer(param, " "); + + if (st.countTokens() < 2) { - seqs = new String[seqsel.getSize()]; - for (int i = 0; i < seqs.length; i++) + String sequence = getParameter("PDBSEQ"); + if (sequence != null) { - seqs[i] = seqsel.getSequenceAt(i).getName(); + seqs = new SequenceI[] { matcher == null + ? (Sequence) alf.getViewport().getAlignment() + .findName(sequence) + : matcher.findIdMatch(sequence) }; } - if (strt < seqsel.getStartRes()) + + } + else + { + param = st.nextToken(); + List tmp = new ArrayList<>(); + List tmp2 = new ArrayList<>(); + + while (st.hasMoreTokens()) { - strt = seqsel.getStartRes(); + seqstring = st.nextToken(); + StringTokenizer st2 = new StringTokenizer(seqstring, "="); + if (st2.countTokens() > 1) + { + // This is the chain + tmp2.add(st2.nextToken()); + seqstring = st2.nextToken(); + } + tmp.add(matcher == null + ? (Sequence) alf.getViewport().getAlignment() + .findName(seqstring) + : matcher.findIdMatch(seqstring)); } - if (end == -1 || end > seqsel.getEndRes()) + + seqs = tmp.toArray(new SequenceI[tmp.size()]); + if (tmp2.size() == tmp.size()) { - end = seqsel.getEndRes(); + chains = tmp2.toArray(new String[tmp2.size()]); } } - if (colsel != null && !colsel.isEmpty()) + pdb.setId(param); + ret[0] = param; + DataSourceType protocol = resolveFileProtocol(ret); + // TODO check JAL-357 for files in a jar (CLASSLOADER) + pdb.setFile(ret[0]); + + if (seqs != null) { - if (end == -1) + for (int i = 0; i < seqs.length; i++) { - end = colsel.getMax() + 1; + if (seqs[i] != null) + { + ((Sequence) seqs[i]).addPDBId(pdb); + StructureSelectionManager + .getStructureSelectionManager( + (StructureSelectionManagerProvider) this) + .registerPDBEntry(pdb); + } } - cols = new String[colsel.getSelected().size()]; - for (int i = 0; i < cols.length; i++) + + // if (doAlign) + // { + // pdbs.add(new Object[] { pdb, seqs, chains, protocol }); + // } + // else { - cols[i] = "" + (1 + colsel.getSelected().get(i).intValue()); + StructureViewer.launchStructureViewer( + (alf == null ? getCurrentAlignFrame() : alf).alignPanel, + pdb, seqs); } } - else + } + // + // if (doAlign && pdbs.size() > 0) + // { + // SequenceI[][] seqs = new SequenceI[pdbs.size()][]; + // PDBEntry[] pdb = new PDBEntry[pdbs.size()]; + // String[][] chains = new String[pdbs.size()][]; + // String[] protocols = new String[pdbs.size()]; + // for (int pdbsi = 0, pdbsiSize = pdbs + // .size(); pdbsi < pdbsiSize; pdbsi++) + // { + // Object[] o = pdbs.get(pdbsi); + // pdb[pdbsi] = (PDBEntry) o[0]; + // seqs[pdbsi] = (SequenceI[]) o[1]; + // chains[pdbsi] = (String[]) o[2]; + // protocols[pdbsi] = (String) o[3]; + // } + //// alignedStructureView(pdb, seqs, chains, protocols); + // result = true; + // } + return true; + } + + /** + * Load a score file if specified by parameter. Returns true if file was + * loaded, else false. + * + * @param loaderFrame + */ + private boolean initScoreFile(AlignFrame alf) + { + + String sScoreFile = getParameter("scoreFile"); + if (sScoreFile != null && !"".equals(sScoreFile)) + { + try { - if (seqsel != null && seqsel.getSize() > 0) + if (loadScoreFile(sScoreFile, alf)) { - // send a valid range, otherwise we send the empty selection - cols = new String[1]; - cols[0] = "" + (1 + strt) + "-" + (1 + end); + return true; } - ; - + System.err.println( + "Failed to parse T-COFFEE parameter as a valid score file ('" + + sScoreFile + "')"); + } catch (Exception e) + { + System.err.printf("Cannot read score file: '%s'. Cause: %s \n", + sScoreFile, e.getMessage()); } - - doSendCallback(_listener, - new Object[] - { src, setid, seqs, cols }); } + return false; + } - public boolean isFor(AlignFrame af, String listener) + /** + * Load a tree for the alignment if specified by parameter. Returns true if a + * tree was loaded, else false. + * + * @return + */ + private boolean initTree(AlignFrame alf) + { + String treeFile; + if ((treeFile = getParameter("tree")) == null + && (treeFile = getParameter("treefile")) == null) + return false; + if (alf == null) + alf = getCurrentAlignFrame(); + try { - return _af == af && _listener.contentEquals(listener); + ret[0] = treeFile; + NewickFile nf = new NewickFile(treeFile, resolveFileProtocol(ret)); + nf.parse(); + if (nf.getTree() != null) + { + treeFile = ret[0]; + alf.getViewport() + .setCurrentTree(alf.showNewickTree(nf, treeFile).getTree()); + return true; + } + } catch (Exception ex) + { + ex.printStackTrace(); } - + return false; } - @Override - public AlignViewportI getViewport() + private void updateForAnnotations() { - return Jalview.getCurrentAlignFrame().getViewport(); + getCurrentAlignFrame().updateForAnnotations(); } - } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 4e50439..f74eb32 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -167,6 +167,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, IProgressIndicator, AlignViewControllerGuiI, ColourChangeListener { + public static int frameCount; + public static final int DEFAULT_WIDTH = 700; public static final int DEFAULT_HEIGHT = 500; @@ -194,6 +196,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, File fileObject; + private int id; + /** * Creates a new AlignFrame object with specific width and height. * @@ -288,6 +292,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, public AlignFrame(AlignmentI al, HiddenColumns hiddenColumns, int width, int height, String sequenceSetId, String viewId) { + + id = (++frameCount); + setSize(width, height); if (al.getDataset() == null) @@ -5923,6 +5930,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, alignPanel.getSeqPanel().selection(sel, csel, hidden, null); } + + public int getID() + { + return id; + } + } class PrintThread extends Thread diff --git a/swingjs/SwingJS-site.zip b/swingjs/SwingJS-site.zip index 90ec5a2..90b1901 100644 Binary files a/swingjs/SwingJS-site.zip and b/swingjs/SwingJS-site.zip differ diff --git a/swingjs/timestamp b/swingjs/timestamp index 5cb9ccc..bf52be2 100644 --- a/swingjs/timestamp +++ b/swingjs/timestamp @@ -1 +1 @@ -20200606223527 +20200607125736 diff --git a/swingjs/ver/3.2.9/SwingJS-site.zip b/swingjs/ver/3.2.9/SwingJS-site.zip index 90ec5a2..90b1901 100644 Binary files a/swingjs/ver/3.2.9/SwingJS-site.zip and b/swingjs/ver/3.2.9/SwingJS-site.zip differ diff --git a/swingjs/ver/3.2.9/timestamp b/swingjs/ver/3.2.9/timestamp index 5cb9ccc..bf52be2 100644 --- a/swingjs/ver/3.2.9/timestamp +++ b/swingjs/ver/3.2.9/timestamp @@ -1 +1 @@ -20200606223527 +20200607125736 diff --git a/utils/jalviewjs/site-resources/jalview_bin_JalviewJS_core.html b/utils/jalviewjs/site-resources/_jalview_bin_JalviewJS_core.html similarity index 100% rename from utils/jalviewjs/site-resources/jalview_bin_JalviewJS_core.html rename to utils/jalviewjs/site-resources/_jalview_bin_JalviewJS_core.html diff --git a/utils/jalviewjs/site-resources/jalview_embedded_example1.html b/utils/jalviewjs/site-resources/_jalview_embedded_example1.html similarity index 100% rename from utils/jalviewjs/site-resources/jalview_embedded_example1.html rename to utils/jalviewjs/site-resources/_jalview_embedded_example1.html diff --git a/utils/jalviewjs/site-resources/_jalview_embedded_example2.html b/utils/jalviewjs/site-resources/_jalview_embedded_example2.html new file mode 100644 index 0000000..89a4f71 --- /dev/null +++ b/utils/jalviewjs/site-resources/_jalview_embedded_example2.html @@ -0,0 +1,101 @@ + + + +Embedded JalviewJS Example 2 + + + + + + + + + + + + + + + + + +
Demonstration of embedded JalviewJS components
+
+this page tests two Jalview apps on the same page. +
+
+
+
+
+
+
+
+
+This is System.out. clear it
Add ?j2snocore to URL to see full class list; ?j2sdebug to use uncompressed j2s/core files
get _j2sClassList.txt +
+ +
+ +
+ + + +