--- /dev/null
+package jalview.api;
+
+/**
+ * Common methods for jalview.appletgui.AlignFrame and jalview.gui.AlignFrame in
+ * relation to JalviewJS and the JalviewLiteJSApi
+ *
+ * @author hansonr
+ *
+ */
+public interface AlignFrameI
+{
+
+}
* @return displayed name for the view
*/
String getViewName();
+
+ SequenceRenderer getSequenceRenderer();
}
package jalview.api;
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.io.DataSourceType;
import jalview.io.NewickFile;
+import jalview.javascript.JSFunctionExec;
+import jalview.javascript.MouseOverStructureListener;
+import jalview.structure.SelectionSource;
+import jalview.structure.VamsasSource;
+import java.applet.AppletContext;
import java.io.IOException;
import java.net.URL;
+import java.util.Hashtable;
+import java.util.Vector;
+
+import netscape.javascript.JSObject;
public interface JalviewApp
{
public void loadTree(NewickFile fin, String treeFile) throws IOException;
+ public Vector<Runnable> getJsExecQueue(JSFunctionExec jsFunctionExec);
+
+ public AppletContext getAppletContext();
+
+ public boolean isJsfallbackEnabled();
+
+ public JSObject getJSObject();
+
+ public StructureSelectionManagerProvider getStructureSelectionManagerProvider();
+
+ public void updateColoursFromMouseOver(Object source,
+ MouseOverStructureListener mouseOverStructureListener);
+
+ public Object[] getSelectionForListener(SequenceGroup seqsel, ColumnSelection colsel,
+ HiddenColumns hidden, SelectionSource source, Object alignFrame);
+
+ public String arrayToSeparatorList(String[] array);
+
+ public Hashtable<String, int[]> getJSHashes();
+
+ Hashtable<String, Hashtable<String, String[]>> getJSMessages();
+
+ public Object getFrameForSource(VamsasSource source);
+
+ public jalview.renderer.seqfeatures.FeatureRenderer getNewFeatureRenderer(
+ AlignViewportI vp);
+
}
import jalview.analysis.TreeBuilder;
import jalview.analysis.scoremodels.PIDModel;
import jalview.analysis.scoremodels.ScoreModels;
+import jalview.api.AlignFrameI;
import jalview.api.AlignViewControllerGuiI;
import jalview.api.AlignViewControllerI;
import jalview.api.AlignViewportI;
import org.jmol.viewer.Viewer;
-public class AlignFrame extends EmbmenuFrame implements ActionListener,
+public class AlignFrame extends EmbmenuFrame implements AlignFrameI,
+ ActionListener,
ItemListener, KeyListener, AlignViewControllerGuiI
{
public AlignViewControllerI avc;
*/
package jalview.bin;
+import jalview.api.AlignFrameI;
import jalview.api.AlignViewportI;
import jalview.api.JalviewApp;
+import jalview.api.StructureSelectionManagerProvider;
import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.ext.so.SequenceOntology;
import jalview.gui.AlignFrame;
import jalview.gui.AlignViewport;
+import jalview.gui.AlignmentPanel;
import jalview.gui.Desktop;
import jalview.gui.Preferences;
import jalview.gui.PromptUserConfig;
import jalview.io.IdentifyFile;
import jalview.io.NewickFile;
import jalview.io.gff.SequenceOntologyFactory;
+import jalview.javascript.JSFunctionExec;
import jalview.javascript.JalviewLiteJsApi;
+import jalview.javascript.MouseOverStructureListener;
+import jalview.renderer.seqfeatures.FeatureRenderer;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ColourSchemeProperty;
+import jalview.structure.SelectionSource;
+import jalview.structure.VamsasSource;
import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.ws.jws2.Jws2Discoverer;
+import java.applet.AppletContext;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.security.Permissions;
import java.security.Policy;
import java.util.HashMap;
+import java.util.Hashtable;
import java.util.Map;
import java.util.Vector;
import java.util.logging.ConsoleHandler;
import groovy.lang.Binding;
import groovy.util.GroovyScriptEngine;
+import netscape.javascript.JSObject;
/**
* Main class for Jalview Application <br>
public String appletResourcePath;
+ private JalviewAppLoader appLoader;
+
+ protected JSFunctionExec jsFunctionExec;
+
public static AlignFrame getCurrentAlignFrame()
{
return getInstance().currentAlignFrame;
*/
public void quit()
{
+ if (jsFunctionExec != null)
+ {
+ jsFunctionExec.tidyUp();
+ jsFunctionExec = null;
+ }
+
if (desktop != null)
{
desktop.quit();
private boolean alignPDBStructures; // From JalviewLite; not implemented
+ private Hashtable<String, Hashtable<String, String[]>> jsmessages;
+
+ private Hashtable<String, int[]> jshashes;
+
@Override
public String getParameter(String name)
{
"Jalview applet interface newFeatureSettings not implemented");
}
+ private Vector<Runnable> jsExecQueue;
+
+ @Override
+ public Vector<Runnable> getJsExecQueue(JSFunctionExec exec)
+ {
+ jsFunctionExec = exec;
+ return (jsExecQueue == null ? (jsExecQueue = new Vector<>())
+ : jsExecQueue);
+ }
+
+ @Override
+ public AppletContext getAppletContext()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isJsfallbackEnabled()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public JSObject getJSObject()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public StructureSelectionManagerProvider getStructureSelectionManagerProvider()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void updateColoursFromMouseOver(Object source,
+ MouseOverStructureListener mouseOverStructureListener)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Object[] getSelectionForListener(SequenceGroup seqsel,
+ ColumnSelection colsel, HiddenColumns hidden,
+ SelectionSource source, Object alignFrame)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String arrayToSeparatorList(String[] array)
+ {
+ return appLoader.arrayToSeparatorList(array);
+ }
+
+ @Override
+ public Hashtable<String, int[]> getJSHashes()
+ {
+ return (jshashes == null
+ ? (jshashes = new Hashtable<>())
+ : jshashes);
+ }
+
+ @Override
+ public Hashtable<String, Hashtable<String, String[]>> getJSMessages()
+ {
+ return (jsmessages == null
+ ? (jsmessages = new Hashtable<>())
+ : jsmessages);
+ }
+
+ @Override
+ public Object getFrameForSource(VamsasSource source)
+ {
+ if (source != null)
+ {
+ AlignFrame af;
+ if (source instanceof jalview.gui.AlignViewport
+ && source == (af = getCurrentAlignFrame()).getViewport())
+ {
+ // should be valid if it just generated an event!
+ return af;
+ }
+ // 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 FeatureRenderer getNewFeatureRenderer(AlignViewportI vp)
+ {
+ return new jalview.gui.FeatureRenderer((AlignmentPanel) vp);
+ }
+
};
- new JalviewAppLoader(true).load(app);
+ appLoader = new JalviewAppLoader(true);
+ appLoader.load(app);
}
@Override
}
@Override
- public String getSelectedSequencesFrom(jalview.appletgui.AlignFrame alf)
+ public String getSelectedSequencesFrom(AlignFrameI alf)
{
// TODO Auto-generated method stub
return null;
}
@Override
- public String getSelectedSequencesFrom(jalview.appletgui.AlignFrame alf,
+ public String getSelectedSequencesFrom(AlignFrameI alf,
String sep)
{
// TODO Auto-generated method stub
}
@Override
- public void highlightIn(jalview.appletgui.AlignFrame alf,
+ public void highlightIn(AlignFrameI alf,
String sequenceId, String position, String alignedPosition)
{
// TODO Auto-generated method stub
}
@Override
- public void selectIn(jalview.appletgui.AlignFrame alf, String sequenceIds,
+ public void selectIn(AlignFrameI alf, String sequenceIds,
String columns)
{
// TODO Auto-generated method stub
}
@Override
- public void selectIn(jalview.appletgui.AlignFrame alf, String sequenceIds,
+ public void selectIn(AlignFrameI alf, String sequenceIds,
String columns, String sep)
{
// TODO Auto-generated method stub
@Override
public String getSelectedSequencesAsAlignmentFrom(
- jalview.appletgui.AlignFrame alf, String format, String suffix)
+ AlignFrameI alf, String format, String suffix)
{
// TODO Auto-generated method stub
return null;
}
@Override
- public String getAlignmentOrderFrom(jalview.appletgui.AlignFrame alf)
+ public String getAlignmentOrderFrom(AlignFrameI alf)
{
// TODO Auto-generated method stub
return null;
}
@Override
- public String getAlignmentOrderFrom(jalview.appletgui.AlignFrame alf,
+ public String getAlignmentOrderFrom(AlignFrameI alf,
String sep)
{
// TODO Auto-generated method stub
}
@Override
- public String orderAlignmentBy(jalview.appletgui.AlignFrame alf,
+ public String orderAlignmentBy(AlignFrameI alf,
String order, String undoName, String sep)
{
// TODO Auto-generated method stub
}
@Override
- public String getAlignmentFrom(jalview.appletgui.AlignFrame alf,
+ public String getAlignmentFrom(AlignFrameI alf,
String format)
{
// TODO Auto-generated method stub
}
@Override
- public String getAlignmentFrom(jalview.appletgui.AlignFrame alf,
+ public String getAlignmentFrom(AlignFrameI alf,
String format, String suffix)
{
// TODO Auto-generated method stub
}
@Override
- public void loadAnnotationFrom(jalview.appletgui.AlignFrame alf,
+ public void loadAnnotationFrom(AlignFrameI alf,
String annotation)
{
// TODO Auto-generated method stub
}
@Override
- public boolean loadFeaturesFrom(jalview.appletgui.AlignFrame alf,
+ public boolean loadFeaturesFrom(AlignFrameI alf,
String features, boolean autoenabledisplay)
{
// TODO Auto-generated method stub
}
@Override
- public String getFeaturesFrom(jalview.appletgui.AlignFrame alf,
+ public String getFeaturesFrom(AlignFrameI alf,
String format)
{
// TODO Auto-generated method stub
}
@Override
- public String getAnnotationFrom(jalview.appletgui.AlignFrame alf)
+ public String getAnnotationFrom(AlignFrameI alf)
{
// TODO Auto-generated method stub
return null;
}
@Override
- public jalview.appletgui.AlignFrame newView()
+ public AlignFrameI newView()
{
// TODO Auto-generated method stub
return null;
}
@Override
- public jalview.appletgui.AlignFrame newView(String name)
+ public AlignFrameI newView(String name)
{
// TODO Auto-generated method stub
return null;
}
@Override
- public jalview.appletgui.AlignFrame newViewFrom(
- jalview.appletgui.AlignFrame alf)
+ public AlignFrameI newViewFrom(AlignFrameI alf)
{
// TODO Auto-generated method stub
return null;
}
@Override
- public jalview.appletgui.AlignFrame newViewFrom(
- jalview.appletgui.AlignFrame alf, String name)
+ public AlignFrameI newViewFrom(AlignFrameI alf, String name)
{
// TODO Auto-generated method stub
return null;
}
@Override
- public jalview.appletgui.AlignFrame loadAlignment(String text,
+ public AlignFrameI loadAlignment(String text,
String title)
{
// TODO Auto-generated method stub
}
@Override
- public void setMouseoverListener(jalview.appletgui.AlignFrame af,
+ public void setMouseoverListener(AlignFrameI af,
String listener)
{
// TODO Auto-generated method stub
}
@Override
- public void setSelectionListener(jalview.appletgui.AlignFrame af,
+ public void setSelectionListener(AlignFrameI af,
String listener)
{
// TODO Auto-generated method stub
}
@Override
- public void removeJavascriptListener(jalview.appletgui.AlignFrame af,
+ public void removeJavascriptListener(AlignFrameI af,
String listener)
{
// TODO Auto-generated method stub
}
@Override
- public boolean addPdbFile(jalview.appletgui.AlignFrame alFrame,
+ public boolean addPdbFile(AlignFrameI alFrame,
String sequenceId, String pdbEntryString, String pdbFile)
{
// TODO Auto-generated method stub
}
@Override
- public void scrollViewToIn(jalview.appletgui.AlignFrame alf,
+ public void scrollViewToIn(AlignFrameI alf,
String topRow, String leftHandColumn)
{
// TODO Auto-generated method stub
}
@Override
- public void scrollViewToRowIn(jalview.appletgui.AlignFrame alf,
+ public void scrollViewToRowIn(AlignFrameI alf,
String topRow)
{
// TODO Auto-generated method stub
}
@Override
- public void scrollViewToColumnIn(jalview.appletgui.AlignFrame alf,
+ public void scrollViewToColumnIn(AlignFrameI alf,
String leftHandColumn)
{
// TODO Auto-generated method stub
}
@Override
- public String getFeatureGroupsOn(jalview.appletgui.AlignFrame alf)
+ public String getFeatureGroupsOn(AlignFrameI alf)
{
// TODO Auto-generated method stub
return null;
}
@Override
- public String getFeatureGroupsOfStateOn(jalview.appletgui.AlignFrame alf,
+ public String getFeatureGroupsOfStateOn(AlignFrameI alf,
boolean visible)
{
// TODO Auto-generated method stub
}
@Override
- public void setFeatureGroupStateOn(jalview.appletgui.AlignFrame alf,
+ public void setFeatureGroupStateOn(AlignFrameI alf,
String groups, boolean state)
{
// TODO Auto-generated method stub
try
{
ret[0] = param;
- DataSourceType protocol = resolveFileProtocol(app,
- ret);
+ DataSourceType protocol = resolveFileProtocol(app, ret);
JPredFile predictions = new JPredFile(ret[0], protocol);
JnetAnnotationMaker.add_annotation(predictions,
app.getViewport().getAlignment(), 0, false);
if (param != null)
{
ret[0] = param;
- DataSourceType protocol = resolveFileProtocol(app,
- ret);
+ DataSourceType protocol = resolveFileProtocol(app, ret);
param = ret[0];
if (new AnnotationFile().annotateAlignmentView(app.getViewport(),
param, protocol))
String param = app.getParameter("hidefeaturegroups");
if (param != null)
{
- app.setFeatureGroupState(
- separatorListToArray(param, separator), false);
+ app.setFeatureGroupState(separatorListToArray(param, separator),
+ false);
// app.setFeatureGroupStateOn(newAlignFrame, param, false);
}
// show specific groups
if (param != null)
{
ret[0] = param;
- DataSourceType protocol = resolveFileProtocol(app,
- ret);
+ DataSourceType protocol = resolveFileProtocol(app, ret);
result = app.parseFeaturesFile(ret[0], protocol);
}
}
String[] ret = new String[1];
+
/**
* Load a tree for the alignment if specified by parameter. Returns true if a
* tree was loaded, else false.
{
if (debug)
{
- System.out.println("Tree parameter did not resolve to a valid tree.");
+ System.out.println(
+ "Tree parameter did not resolve to a valid tree.");
}
}
} catch (Exception ex)
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
{
directoryPath = directoryPath.substring(0, lastSeparator + 1);
}
-
+
if (targetPath.startsWith("/"))
{
/*
retPath[0] = path.substring(5);
return DataSourceType.PASTE;
}
-
+
/*
* is it a URL?
*/
{
return DataSourceType.URL;
}
-
+
/*
* try relative to document root
*/
URL documentBase = app.getDocumentBase();
- String withDocBase = resolveUrlForLocalOrAbsolute(path,
- documentBase);
+ String withDocBase = resolveUrlForLocalOrAbsolute(path, documentBase);
if (HttpUtils.isValidUrl(withDocBase))
{
// if (debug)
retPath[0] = withDocBase;
return DataSourceType.URL;
}
-
+
/*
* try relative to codebase (if different to document base)
*/
URL codeBase = app.getCodeBase();
- String withCodeBase = resolveUrlForLocalOrAbsolute(path,
- codeBase);
+ String withCodeBase = resolveUrlForLocalOrAbsolute(path, codeBase);
if (!withCodeBase.equals(withDocBase)
&& HttpUtils.isValidUrl(withCodeBase))
{
* @param jalviewApp
* @return
*/
- public String getPastedSequence(JalviewApp jalviewApp) {
+ public String getPastedSequence(JalviewApp jalviewApp)
+ {
StringBuffer data = new StringBuffer("PASTE");
int i = 1;
String file = null;
}
return file;
}
-}
+
+ /**
+ * 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;
+ }
+
+ public String arrayToSeparatorList(String[] array)
+ {
+ return arrayToSeparatorList(array, separator);
+ }
+
+}
\ No newline at end of file
package jalview.bin;
import jalview.analysis.AlignmentUtils;
+import jalview.api.AlignFrameI;
import jalview.api.AlignViewportI;
import jalview.api.JalviewApp;
import jalview.api.StructureSelectionManagerProvider;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentOrder;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.javascript.JalviewLiteJsApi;
import jalview.javascript.JsCallBack;
import jalview.javascript.MouseOverStructureListener;
+import jalview.renderer.seqfeatures.FeatureRenderer;
import jalview.structure.SelectionListener;
+import jalview.structure.SelectionSource;
import jalview.structure.StructureSelectionManager;
+import jalview.structure.VamsasSource;
import jalview.util.ColorUtils;
import jalview.util.MessageManager;
+import jalview.viewmodel.AlignmentViewport;
import java.applet.Applet;
import java.awt.Button;
* @author $author$
* @version $Revision: 1.92 $
*/
+@SuppressWarnings("serial")
public class JalviewLite extends Applet
implements StructureSelectionManagerProvider, JalviewLiteJsApi,
JalviewApp
return StructureSelectionManager.getStructureSelectionManager(this);
}
+ @Override
+ public StructureSelectionManagerProvider getStructureSelectionManagerProvider()
+ {
+ return this;
+ }
+
// /////////////////////////////////////////
// The following public methods may be called
// externally, eg via javascript in HTML page
* .AlignFrame)
*/
@Override
- public String getSelectedSequencesFrom(AlignFrame alf)
+ public String getSelectedSequencesFrom(AlignFrameI alf)
{
return getSelectedSequencesFrom(alf, separator); // ""+0x00AC);
}
* .AlignFrame, java.lang.String)
*/
@Override
- public String getSelectedSequencesFrom(AlignFrame alf, String sep)
+ public String getSelectedSequencesFrom(AlignFrameI alf, String sep)
{
StringBuffer result = new StringBuffer("");
if (sep == null || sep.length() == 0)
{
sep = separator; // "+0x00AC;
}
- if (alf.viewport.getSelectionGroup() != null)
+ if (((AlignFrame) alf).viewport.getSelectionGroup() != null)
{
- SequenceI[] seqs = alf.viewport.getSelectionGroup()
- .getSequencesInOrder(alf.viewport.getAlignment());
+ SequenceI[] seqs = ((AlignFrame) alf).viewport.getSelectionGroup()
+ .getSequencesInOrder(
+ ((AlignFrame) alf).viewport.getAlignment());
for (int i = 0; i < seqs.length; i++)
{
* java.lang.String, java.lang.String, java.lang.String)
*/
@Override
- public void highlightIn(final AlignFrame alf, final String sequenceId,
+ public void highlightIn(final AlignFrameI alf, final String sequenceId,
final String position, final String alignedPosition)
{
// TODO: could try to highlight in all alignments if alf==null
jalview.analysis.SequenceIdMatcher matcher = new jalview.analysis.SequenceIdMatcher(
- alf.viewport.getAlignment().getSequencesArray());
+ ((AlignFrame) alf).viewport.getAlignment().getSequencesArray());
final SequenceI sq = matcher.findIdMatch(sequenceId);
if (sq != null)
{
* java.lang.String, java.lang.String)
*/
@Override
- public void selectIn(AlignFrame alf, String sequenceIds, String columns)
+ public void selectIn(AlignFrameI alf, String sequenceIds, String columns)
{
selectIn(alf, sequenceIds, columns, separator);
}
* java.lang.String, java.lang.String, java.lang.String)
*/
@Override
- public void selectIn(final AlignFrame alf, String sequenceIds,
+ public void selectIn(final AlignFrameI alf, String sequenceIds,
String columns, String sep)
{
if (sep == null || sep.length() == 0)
String[] cols = JalviewAppLoader.separatorListToArray(columns, sep);
final SequenceGroup sel = new SequenceGroup();
final ColumnSelection csel = new ColumnSelection();
- AlignmentI al = alf.viewport.getAlignment();
+ AlignmentI al = ((AlignFrame) alf).viewport.getAlignment();
jalview.analysis.SequenceIdMatcher matcher = new jalview.analysis.SequenceIdMatcher(
- alf.viewport.getAlignment().getSequencesArray());
+ ((AlignFrame) alf).viewport.getAlignment().getSequencesArray());
int start = 0, end = al.getWidth(), alw = al.getWidth();
boolean seqsfound = true;
if (ids != null && ids.length > 0)
@Override
public void run()
{
- alf.select(sel, csel,
- alf.getAlignViewport().getAlignment().getHiddenColumns());
+ ((AlignFrame) alf).select(sel, csel, ((AlignFrame) alf)
+ .getAlignViewport().getAlignment().getHiddenColumns());
}
});
}
* .appletgui.AlignFrame, java.lang.String, java.lang.String)
*/
@Override
- public String getSelectedSequencesAsAlignmentFrom(AlignFrame alf,
+ public String getSelectedSequencesAsAlignmentFrom(AlignFrameI alf,
String format, String suffix)
{
try
{
FileFormatI theFormat = FileFormats.getInstance().forName(format);
boolean seqlimits = suffix.equalsIgnoreCase(TRUE);
- if (alf.viewport.getSelectionGroup() != null)
+ if (((AlignFrame) alf).viewport.getSelectionGroup() != null)
{
// JBPNote: getSelectionAsNewSequence behaviour has changed - this
// method now returns a full copy of sequence data
// TODO consider using getSequenceSelection instead here
String reply = new AppletFormatAdapter().formatSequences(theFormat,
- new Alignment(alf.viewport.getSelectionAsNewSequence()),
+ new Alignment(((AlignFrame) alf).viewport
+ .getSelectionAsNewSequence()),
seqlimits);
return reply;
}
* )
*/
@Override
- public String getAlignmentOrderFrom(AlignFrame alf)
+ public String getAlignmentOrderFrom(AlignFrameI alf)
{
return getAlignmentOrderFrom(alf, separator);
}
* , java.lang.String)
*/
@Override
- public String getAlignmentOrderFrom(AlignFrame alf, String sep)
+ public String getAlignmentOrderFrom(AlignFrameI alf, String sep)
{
- AlignmentI alorder = alf.getAlignViewport().getAlignment();
+ AlignmentI alorder = ((AlignFrame) alf).getAlignViewport()
+ .getAlignment();
String[] order = new String[alorder.getHeight()];
for (int i = 0; i < order.length; i++)
{
* java.lang.String, java.lang.String, java.lang.String)
*/
@Override
- public String orderAlignmentBy(AlignFrame alf, String order,
+ public String orderAlignmentBy(AlignFrameI alf, String order,
String undoName, String sep)
{
String[] ids = JalviewAppLoader.separatorListToArray(order, sep);
if (ids != null && ids.length > 0)
{
jalview.analysis.SequenceIdMatcher matcher = new jalview.analysis.SequenceIdMatcher(
- alf.viewport.getAlignment().getSequencesArray());
+ ((AlignFrame) alf).viewport.getAlignment()
+ .getSequencesArray());
int s = 0;
sqs = new SequenceI[ids.length];
for (int i = 0; i < ids.length; i++)
final String _undoName = undoName;
// TODO: deal with synchronization here: cannot raise any events until after
// this has returned.
- return alf.sortBy(aorder, _undoName) ? TRUE : "";
+ return ((AlignFrame) alf).sortBy(aorder, _undoName) ? TRUE : "";
}
/*
* java.lang.String)
*/
@Override
- public String getAlignmentFrom(AlignFrame alf, String format)
+ public String getAlignmentFrom(AlignFrameI alf, String format)
{
return getAlignmentFrom(alf, format, TRUE);
}
* java.lang.String, java.lang.String)
*/
@Override
- public String getAlignmentFrom(AlignFrame alf, String format,
+ public String getAlignmentFrom(AlignFrameI alf, String format,
String suffix)
{
try
FileFormatI theFormat = FileFormats.getInstance().forName(format);
String reply = new AppletFormatAdapter().formatSequences(theFormat,
- alf.viewport.getAlignment(), seqlimits);
+ ((AlignFrame) alf).viewport.getAlignment(), seqlimits);
return reply;
} catch (IllegalArgumentException ex)
{
* , java.lang.String)
*/
@Override
- public void loadAnnotationFrom(AlignFrame alf, String annotation)
+ public void loadAnnotationFrom(AlignFrameI alf, String annotation)
{
- if (new AnnotationFile().annotateAlignmentView(alf.getAlignViewport(),
+ if (new AnnotationFile().annotateAlignmentView(
+ ((AlignFrame) alf).getAlignViewport(),
annotation, DataSourceType.PASTE))
{
- alf.alignPanel.fontChanged();
- alf.alignPanel.setScrollValues(0, 0);
+ ((AlignFrame) alf).alignPanel.fontChanged();
+ ((AlignFrame) alf).alignPanel.setScrollValues(0, 0);
}
else
{
- alf.parseFeaturesFile(annotation, DataSourceType.PASTE);
+ ((AlignFrame) alf).parseFeaturesFile(annotation,
+ DataSourceType.PASTE);
}
}
* , java.lang.String)
*/
@Override
- public boolean loadFeaturesFrom(AlignFrame alf, String features,
+ public boolean loadFeaturesFrom(AlignFrameI alf, String features,
boolean autoenabledisplay)
{
- return alf.parseFeaturesFile(features, DataSourceType.PASTE,
+ return ((AlignFrame) alf).parseFeaturesFile(features,
+ DataSourceType.PASTE,
autoenabledisplay);
}
* java.lang.String)
*/
@Override
- public String getFeaturesFrom(AlignFrame alf, String format)
+ public String getFeaturesFrom(AlignFrameI alf, String format)
{
- return alf.outputFeatures(false, format);
+ return ((AlignFrame) alf).outputFeatures(false, format);
}
/*
* )
*/
@Override
- public String getAnnotationFrom(AlignFrame alf)
+ public String getAnnotationFrom(AlignFrameI alf)
{
- return alf.outputAnnotations(false);
+ return ((AlignFrame) alf).outputAnnotations(false);
}
/*
* @see jalview.bin.JalviewLiteJsApi#newViewFrom(jalview.appletgui.AlignFrame)
*/
@Override
- public AlignFrame newViewFrom(AlignFrame alf)
+ public AlignFrame newViewFrom(AlignFrameI alf)
{
- return alf.newView(null);
+ return ((AlignFrame) alf).newView(null);
}
/*
* java.lang.String)
*/
@Override
- public AlignFrame newViewFrom(AlignFrame alf, String name)
+ public AlignFrame newViewFrom(AlignFrameI alf, String name)
{
- return alf.newView(name);
+ return ((AlignFrame) alf).newView(name);
}
/*
* , java.lang.String)
*/
@Override
- public void setMouseoverListener(AlignFrame af, String listener)
+ public void setMouseoverListener(AlignFrameI af, String listener)
{
if (listener != null)
{
}
}
jalview.javascript.MouseOverListener mol = new jalview.javascript.MouseOverListener(
- this, af, listener);
+ this, (AlignFrame) af, listener, debug);
javascriptListeners.addElement(mol);
StructureSelectionManager.getStructureSelectionManager(this)
.addStructureViewerListener(mol);
System.err.println("Added a mouseover listener for "
+ ((af == null) ? "All frames"
: "Just views for "
- + af.getAlignViewport().getSequenceSetId()));
+ + ((AlignFrame) af).getAlignViewport()
+ .getSequenceSetId()));
System.err.println("There are now " + javascriptListeners.size()
+ " listeners in total.");
}
* , java.lang.String)
*/
@Override
- public void setSelectionListener(AlignFrame af, String listener)
+ public void setSelectionListener(AlignFrameI af, String listener)
{
if (listener != null)
{
}
}
jalview.javascript.JsSelectionSender mol = new jalview.javascript.JsSelectionSender(
- this, af, listener);
+ this, (AlignFrame) af, listener, debug);
javascriptListeners.addElement(mol);
StructureSelectionManager.getStructureSelectionManager(this)
.addSelectionListener(mol);
System.err.println("Added a selection listener for "
+ ((af == null) ? "All frames"
: "Just views for "
- + af.getAlignViewport().getSequenceSetId()));
+ + ((AlignFrame) af).getAlignViewport()
+ .getSequenceSetId()));
System.err.println("There are now " + javascriptListeners.size()
+ " listeners in total.");
}
}
}
MouseOverStructureListener mol = new MouseOverStructureListener(this,
- listener, separatorListToArray(modelSet));
+ listener, separatorListToArray(modelSet), debug);
javascriptListeners.addElement(mol);
StructureSelectionManager.getStructureSelectionManager(this)
.addStructureViewerListener(mol);
* .AlignFrame, java.lang.String)
*/
@Override
- public void removeJavascriptListener(AlignFrame af, String listener)
+ public void removeJavascriptListener(AlignFrameI af, String listener)
{
if (listener != null)
{
}
if (jsFunctionExec != null)
{
- jsFunctionExec.stopQueue();
- jsFunctionExec.jvlite = null;
+ jsFunctionExec.tidyUp();
+ jsFunctionExec = null;
}
initialAlignFrame = null;
- jsFunctionExec = null;
javascriptListeners = null;
StructureSelectionManager.release(this);
}
* java.lang.String, java.lang.String)
*/
@Override
- public void scrollViewToIn(final AlignFrame alf, final String topRow,
+ public void scrollViewToIn(final AlignFrameI alf, final String topRow,
final String leftHandColumn)
{
java.awt.EventQueue.invokeLater(new Runnable()
{
try
{
- alf.scrollTo(new Integer(topRow).intValue(),
+ ((AlignFrame) alf).scrollTo(new Integer(topRow).intValue(),
new Integer(leftHandColumn).intValue());
} catch (Exception ex)
* .AlignFrame, java.lang.String)
*/
@Override
- public void scrollViewToRowIn(final AlignFrame alf, final String topRow)
+ public void scrollViewToRowIn(final AlignFrameI alf, final String topRow)
{
java.awt.EventQueue.invokeLater(new Runnable()
{
try
{
- alf.scrollToRow(new Integer(topRow).intValue());
+ ((AlignFrame) alf).scrollToRow(new Integer(topRow).intValue());
} catch (Exception ex)
{
* .AlignFrame, java.lang.String)
*/
@Override
- public void scrollViewToColumnIn(final AlignFrame alf,
+ public void scrollViewToColumnIn(final AlignFrameI alf,
final String leftHandColumn)
{
java.awt.EventQueue.invokeLater(new Runnable()
{
try
{
- alf.scrollToColumn(new Integer(leftHandColumn).intValue());
+ ((AlignFrame) alf)
+ .scrollToColumn(new Integer(leftHandColumn).intValue());
} catch (Exception ex)
{
boolean embedded = false;
- private boolean checkForJmol = true;
+ boolean checkForJmol = true;
- private boolean checkedForJmol = false; // ensure we don't check for jmol
+ boolean checkedForJmol = false; // ensure we don't check for jmol
// every time the app is re-inited
try
{
// do onInit with the JS executor thread
- new JSFunctionExec(this).executeJavascriptFunction(true,
+ new JSFunctionExec(this, debug).executeJavascriptFunction(true,
initjscallback, null,
"Calling oninit callback '" + initjscallback + "'.");
} catch (Exception e)
/**
* set to enable the URL based javascript execution mechanism
*/
- public boolean jsfallbackEnabled = false;
+ private boolean jsfallbackEnabled = false;
/**
* parse the string into a list
* @param list
* @return concatenated string
*/
+ @Override
public String arrayToSeparatorList(String[] list)
{
- return arrayToSeparatorList(list, 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;
+ return JalviewAppLoader.arrayToSeparatorList(list, separator);
}
/*
* )
*/
@Override
- public String getFeatureGroupsOn(AlignFrame alf)
+ public String getFeatureGroupsOn(AlignFrameI alf)
{
- String lst = arrayToSeparatorList(alf.getFeatureGroups());
+ String lst = arrayToSeparatorList(
+ ((AlignFrame) alf).getFeatureGroups());
return lst;
}
* .AlignFrame, boolean)
*/
@Override
- public String getFeatureGroupsOfStateOn(AlignFrame alf, boolean visible)
+ public String getFeatureGroupsOfStateOn(AlignFrameI alf, boolean visible)
{
- return arrayToSeparatorList(alf.getFeatureGroupsOfState(visible));
+ return arrayToSeparatorList(
+ ((AlignFrame) alf).getFeatureGroupsOfState(visible));
}
/*
* AlignFrame, java.lang.String, boolean)
*/
@Override
- public void setFeatureGroupStateOn(final AlignFrame alf,
+ public void setFeatureGroupStateOn(final AlignFrameI alf,
final String groups, boolean state)
{
final boolean st = state;// !(state==null || state.equals("") ||
@Override
public void run()
{
- alf.setFeatureGroupState(separatorListToArray(groups), st);
+ ((AlignFrame) alf)
+ .setFeatureGroupState(separatorListToArray(groups), st);
}
});
}
* java.lang.String, java.lang.String, java.lang.String)
*/
@Override
- public boolean addPdbFile(AlignFrame alFrame, String sequenceId,
+ public boolean addPdbFile(AlignFrameI alFrame, String sequenceId,
String pdbEntryString, String pdbFile)
{
- return alFrame.addPdbFile(sequenceId, pdbEntryString, pdbFile);
+ return ((AlignFrame) alFrame).addPdbFile(sequenceId, pdbEntryString,
+ pdbFile);
}
@Override
// callInitCallback();
}
- private Hashtable<String, long[]> jshashes = new Hashtable<>();
+ private Hashtable<String, int[]> jshashes = new Hashtable<>();
private Hashtable<String, Hashtable<String, String[]>> jsmessages = new Hashtable<>();
- public void setJsMessageSet(String messageclass, String viewId,
- String[] colcommands)
- {
- Hashtable<String, String[]> msgset = jsmessages.get(messageclass);
- if (msgset == null)
- {
- msgset = new Hashtable<>();
- jsmessages.put(messageclass, msgset);
- }
- msgset.put(viewId, colcommands);
- long[] l = new long[colcommands.length];
- for (int i = 0; i < colcommands.length; i++)
- {
- l[i] = colcommands[i].hashCode();
- }
- jshashes.put(messageclass + "|" + viewId, l);
- }
- /*
- * (non-Javadoc)
- *
- * @see jalview.bin.JalviewLiteJsApi#getJsMessage(java.lang.String,
- * java.lang.String)
- */
@Override
- public String getJsMessage(String messageclass, String viewId)
+ public Hashtable<String, int[]> getJSHashes()
{
- Hashtable<String, String[]> msgset = jsmessages.get(messageclass);
- if (msgset != null)
- {
- String[] msgs = msgset.get(viewId);
- if (msgs != null)
- {
- for (int i = 0; i < msgs.length; i++)
- {
- if (msgs[i] != null)
- {
- String m = msgs[i];
- msgs[i] = null;
- return m;
- }
- }
- }
- }
- return "";
+ return jshashes;
}
- public boolean isJsMessageSetChanged(String string, String string2,
- String[] colcommands)
+ @Override
+ public Hashtable<String, Hashtable<String, String[]>> getJSMessages()
{
- long[] l = jshashes.get(string + "|" + string2);
- if (l == null && colcommands != null)
- {
- return true;
- }
- for (int i = 0; i < colcommands.length; i++)
- {
- if (l[i] != colcommands[i].hashCode())
- {
- return true;
- }
- }
- return false;
+ return jsmessages;
}
- private Vector jsExecQueue = new Vector();
+ private Vector<Runnable> jsExecQueue = new Vector<>();
- public Vector getJsExecQueue()
+ @Override
+ public Vector<Runnable> getJsExecQueue(JSFunctionExec exec)
{
+ jsFunctionExec = exec;
return jsExecQueue;
}
- public void setExecutor(JSFunctionExec jsFunctionExec2)
- {
- jsFunctionExec = jsFunctionExec2;
- }
+ // public void setExecutor(JSFunctionExec jsFunctionExec2)
+ // {
+ // jsFunctionExec = jsFunctionExec2;
+ // }
/**
* return the given colour value parameter or the given default if parameter
loaderFrame.loadTree(tree, treeFile);
}
+ @Override
+ public boolean isJsfallbackEnabled()
+ {
+ return jsfallbackEnabled;
+ }
+
+ @Override
+ public JSObject getJSObject()
+ {
+ return JSObject.getWindow(this);
+ }
+
+ @Override
+ public void updateColoursFromMouseOver(Object source,
+ MouseOverStructureListener listener)
+ {
+ }
+
+ @Override
+ public Object[] getSelectionForListener(SequenceGroup seqsel, ColumnSelection colsel,
+ HiddenColumns hidden, SelectionSource source, Object alignFrame)
+ {
+ // System.err.println("Testing selection event relay to
+ // jsfunction:"+_listener);
+ String setid = "";
+ AlignFrame src = (AlignFrame) alignFrame;
+ if (source != null)
+ {
+ if (source instanceof jalview.appletgui.AlignViewport
+ && ((jalview.appletgui.AlignViewport) source).applet.currentAlignFrame.viewport == source)
+ {
+ // should be valid if it just generated an event!
+ src = ((jalview.appletgui.AlignViewport) source).applet.currentAlignFrame;
+
+ }
+ }
+ 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, arrayToSeparatorList(seqs), arrayToSeparatorList(cols) };
+ }
+
+ @Override
+ public String getJsMessage(String messageclass, String viewId)
+ {
+ return JSFunctionExec.getJsMessage(messageclass, viewId, this);
+ }
+
+ @Override
+ public Object getFrameForSource(VamsasSource source)
+ {
+ if (source != null)
+ {
+ if (source instanceof jalview.appletgui.AlignViewport
+ && ((jalview.appletgui.AlignViewport) source).applet.currentAlignFrame.viewport == source)
+ {
+ // should be valid if it just generated an event!
+ return ((jalview.appletgui.AlignViewport) source).applet.currentAlignFrame;
+
+ }
+ // 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 FeatureRenderer getNewFeatureRenderer(AlignViewportI vp)
+ {
+ return new jalview.appletgui.FeatureRenderer((AlignmentViewport) vp);
+ }
+
/**
* bind structures in a viewer to any matching sequences in an alignFrame (use
* sequenceIds to limit scope of search to specific sequences)
import jalview.analysis.ParseProperties;
import jalview.analysis.SequenceIdMatcher;
import jalview.api.AlignExportSettingsI;
+import jalview.api.AlignFrameI;
import jalview.api.AlignViewControllerGuiI;
import jalview.api.AlignViewControllerI;
import jalview.api.AlignViewportI;
* @version $Revision$
*/
@SuppressWarnings("serial")
-public class AlignFrame extends GAlignFrame implements DropTargetListener,
+public class AlignFrame extends GAlignFrame
+ implements AlignFrameI, DropTargetListener,
IProgressIndicator, AlignViewControllerGuiI, ColourChangeListener
{
import jalview.analysis.AnnotationSorter;
import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
+import jalview.api.SequenceRenderer;
import jalview.bin.Cache;
import jalview.bin.Jalview;
import jalview.datamodel.AlignmentI;
return calculationDialog;
}
+ @Override
+ public SequenceRenderer getSequenceRenderer()
+ {
+ return seqPanel.seqCanvas.getSequenceRenderer();
+ }
+
}
*/
package jalview.javascript;
-import jalview.bin.JalviewLite;
+import jalview.api.JalviewApp;
import java.net.URL;
+import java.util.Hashtable;
import java.util.Vector;
import netscape.javascript.JSObject;
public class JSFunctionExec implements Runnable
{
- public JalviewLite jvlite;
+ public JalviewApp jvlite;
- public JSFunctionExec(JalviewLite applet)
+ protected boolean debug;
+
+ public JSFunctionExec(JalviewApp applet, boolean debug)
{
jvlite = applet;
-
- jsExecQueue = jvlite.getJsExecQueue();
- jvlite.setExecutor(this);
+ this.debug = debug;
+ jsExecQueue = jvlite.getJsExecQueue(this);
}
- private Vector jsExecQueue;
+ private Vector<Runnable> jsExecQueue;
private Thread executor = null;
{
if (jsExecQueue != null)
{
- Vector<JSFunctionExec> q = null;
+ Vector<Runnable> q = null;
synchronized (jsExecQueue)
{
q = jsExecQueue;
}
if (q != null)
{
- for (JSFunctionExec jx : q)
+ for (Runnable jx : q)
{
- jx.jvlite = null;
+ ((JSFunctionExec) jx).jvlite = null;
}
q.removeAllElements();
{
if (jsExecQueue.size() > 0)
{
- Runnable r = (Runnable) jsExecQueue.elementAt(0);
+ Runnable r = jsExecQueue.elementAt(0);
jsExecQueue.removeElementAt(0);
try
{
JSObject scriptObject = null;
try
{
- scriptObject = JSObject.getWindow(jvlite);
+ scriptObject = jvlite.getJSObject();
} catch (Exception ex)
{
}
;
if (scriptObject != null)
{
- if (jvlite.debug && dbgMsg != null)
+ if (debug && dbgMsg != null)
{
System.err.println(dbgMsg);
}
// squash any malformedURLExceptions thrown by windows/safari
if (!(jex instanceof java.net.MalformedURLException))
{
- if (jvlite.debug)
+ if (debug)
{
System.err.println(jex);
}
if (jex instanceof netscape.javascript.JSException
- && jvlite.jsfallbackEnabled)
+ && jvlite.isJsfallbackEnabled())
{
jsex[0] = jex;
- if (jvlite.debug)
+ if (debug)
{
System.err.println("Falling back to javascript: url call");
}
sb.append("\"");
}
sb.append(")");
- if (jvlite.debug)
+ if (debug)
{
System.err.println(sb.toString());
}
{
if (executor == null)
{
- executor = new Thread(new JSFunctionExec(jvlite));
+ executor = new Thread(new JSFunctionExec(jvlite, debug));
executor.start();
}
synchronized (jsExecQueue)
}
}
+ public static void setJsMessageSet(String messageclass, String viewId,
+ String[] colcommands, JalviewApp app)
+ {
+ Hashtable<String, Hashtable<String, String[]>> jsmessages = app
+ .getJSMessages();
+ Hashtable<String, int[]> jshashes = app.getJSHashes();
+
+ Hashtable<String, String[]> msgset = jsmessages.get(messageclass);
+ if (msgset == null)
+ {
+ msgset = new Hashtable<>();
+ jsmessages.put(messageclass, msgset);
+ }
+ msgset.put(viewId, colcommands);
+ int[] l = new int[colcommands.length];
+ for (int i = 0; i < colcommands.length; i++)
+ {
+ l[i] = colcommands[i].hashCode();
+ }
+ jshashes.put(messageclass + "|" + viewId, l);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see jalview.bin.JalviewLiteJsApi#getJsMessage(java.lang.String,
+ * java.lang.String)
+ */
+ public static String getJsMessage(String messageclass, String viewId,
+ JalviewApp app)
+ {
+ Hashtable<String, String[]> msgset = app.getJSMessages()
+ .get(messageclass);
+ if (msgset != null)
+ {
+ String[] msgs = msgset.get(viewId);
+ if (msgs != null)
+ {
+ for (int i = 0; i < msgs.length; i++)
+ {
+ if (msgs[i] != null)
+ {
+ String m = msgs[i];
+ msgs[i] = null;
+ return m;
+ }
+ }
+ }
+ }
+ return "";
+ }
+
+ public static boolean isJsMessageSetChanged(String string, String string2,
+ String[] colcommands, JalviewApp app)
+ {
+ int[] l = app.getJSHashes().get(string + "|" + string2);
+ if (l == null && colcommands != null)
+ {
+ return true;
+ }
+ for (int i = 0; i < colcommands.length; i++)
+ {
+ if (l[i] != colcommands[i].hashCode())
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void tidyUp()
+ {
+ stopQueue();
+ jvlite = null;
+ }
+
}
*/
package jalview.javascript;
-import jalview.appletgui.AlignFrame;
+import jalview.api.AlignFrameI;
/**
* The following public methods may be called
* externally, eg via javascript in an HTML page.
*
- * <br><em>TODO: introduce abstract interface for jalview.appletgui.AlignFrame</em><br>
+ * <br><em>TODO: introduce abstract interface for jalview.appletgui.AlignFrameI</em><br>
*
* Most function arguments are strings, which contain serialised versions of lists.
* Lists of things are separated by a separator character - either the default or a user supplied one.
/**
* @param alf
- * alignframe containing selection
+ * AlignFrameI containing selection
* @return String list of selected sequence IDs, each terminated by current
* default separator sequence
*
*/
- public abstract String getSelectedSequencesFrom(AlignFrame alf);
+ public abstract String getSelectedSequencesFrom(AlignFrameI alf);
/**
* get list of selected sequence IDs separated by given separator
* @return String list of selected sequence IDs, each terminated by the given
* separator
*/
- public abstract String getSelectedSequencesFrom(AlignFrame alf,
+ public abstract String getSelectedSequencesFrom(AlignFrameI alf,
String sep);
/**
* false, blank or something else - indicate if position is an
* alignment column or unaligned sequence position
*/
- public abstract void highlightIn(AlignFrame alf, String sequenceId,
+ public abstract void highlightIn(AlignFrameI alf, String sequenceId,
String position, String alignedPosition);
/**
* @param sep
* separator between toselect fields
*/
- public abstract void selectIn(AlignFrame alf, String sequenceIds,
+ public abstract void selectIn(AlignFrameI alf, String sequenceIds,
String columns);
/**
* @param sep
* separator between toselect fields
*/
- public abstract void selectIn(AlignFrame alf, String sequenceIds,
+ public abstract void selectIn(AlignFrameI alf, String sequenceIds,
String columns, String sep);
/**
- * get sequences selected in current alignFrame and return their alignment in
+ * get sequences selected in current AlignFrameI and return their alignment in
* format 'format' either with or without suffix
*
* @param alf
* @return selected sequences as flat file or empty string if there was no
* current selection
*/
- public abstract String getSelectedSequencesAsAlignmentFrom(AlignFrame alf,
+ public abstract String getSelectedSequencesAsAlignmentFrom(
+ AlignFrameI alf,
String format, String suffix);
/**
* @param alf
* @return
*/
- public abstract String getAlignmentOrderFrom(AlignFrame alf);
+ public abstract String getAlignmentOrderFrom(AlignFrameI alf);
/**
* get a sep separated list of sequence IDs reflecting the order of the
* - separator to use
* @return
*/
- public abstract String getAlignmentOrderFrom(AlignFrame alf, String sep);
+ public abstract String getAlignmentOrderFrom(AlignFrameI alf, String sep);
/**
* re-order the current alignment using the given list of sequence IDs
* @return 'true' if alignment was actually reordered. empty string if
* alignment did not contain sequences.
*/
- public abstract String orderAlignmentBy(AlignFrame alf, String order,
+ public abstract String orderAlignmentBy(AlignFrameI alf, String order,
String undoName, String sep);
/**
* @param format
* @return
*/
- public abstract String getAlignmentFrom(AlignFrame alf, String format);
+ public abstract String getAlignmentFrom(AlignFrameI alf, String format);
/**
* get alignment as format with jalview start-end sequence suffix appended
* @param suffix
* @return
*/
- public abstract String getAlignmentFrom(AlignFrame alf, String format,
+ public abstract String getAlignmentFrom(AlignFrameI alf, String format,
String suffix);
/**
* @param alf
* @param annotation
*/
- public abstract void loadAnnotationFrom(AlignFrame alf,
+ public abstract void loadAnnotationFrom(AlignFrameI alf,
String annotation);
/**
* parse the given string as a jalview feature or GFF annotation file and
- * optionally enable feature display on the current alignFrame
+ * optionally enable feature display on the current AlignFrameI
*
* @param features
* - gff or features file
/**
* parse the given string as a jalview feature or GFF annotation file and
- * optionally enable feature display on the given alignFrame.
+ * optionally enable feature display on the given AlignFrameI.
*
* @param alf
* @param features
* be parsed from the string.
* @return true if data parsed as features
*/
- public abstract boolean loadFeaturesFrom(AlignFrame alf, String features,
+ public abstract boolean loadFeaturesFrom(AlignFrameI alf, String features,
boolean autoenabledisplay);
/**
* @param format
* @return
*/
- public abstract String getFeaturesFrom(AlignFrame alf, String format);
+ public abstract String getFeaturesFrom(AlignFrameI alf, String format);
/**
* get current alignment's annotation as an annotation file
* @param alf
* @return
*/
- public abstract String getAnnotationFrom(AlignFrame alf);
+ public abstract String getAnnotationFrom(AlignFrameI alf);
/**
- * create a new view and return the alignFrame instance
+ * create a new view and return the AlignFrameI instance
*
* @return
*/
- public abstract AlignFrame newView();
+ public abstract AlignFrameI newView();
/**
- * create a new view named name and return the alignFrame instance
+ * create a new view named name and return the AlignFrameI instance
*
* @param name
* @return
*/
- public abstract AlignFrame newView(String name);
+ public abstract AlignFrameI newView(String name);
/**
- * create a new view on alf and return the alignFrame instance
+ * create a new view on alf and return the AlignFrameI instance
*
* @param alf
* @return
*/
- public abstract AlignFrame newViewFrom(AlignFrame alf);
+ public abstract AlignFrameI newViewFrom(AlignFrameI alf);
/**
* create a new view named name on alf
* @param name
* @return
*/
- public abstract AlignFrame newViewFrom(AlignFrame alf, String name);
+ public abstract AlignFrameI newViewFrom(AlignFrameI alf, String name);
/**
*
* window title
* @return null or new alignment frame
*/
- public abstract AlignFrame loadAlignment(String text, String title);
+ public abstract AlignFrameI loadAlignment(String text, String title);
/**
* register a javascript function to handle any alignment mouseover events
*
* @param listener
* name of javascript function (called with arguments
- * [jalview.appletgui.AlignFrame,String(sequence id),String(column in
- * alignment), String(position in sequence)]
+ * [jalview.appletgui.AlignFrameI,String(sequence id),String(column
+ * in alignment), String(position in sequence)]
*/
public abstract void setMouseoverListener(String listener);
* register a javascript function to handle mouseover events
*
* @param af
- * (null or specific alignframe for which events are to be listened
+ * (null or specific AlignFrameI for which events are to be listened
* for)
* @param listener
* name of javascript function
*/
- public abstract void setMouseoverListener(AlignFrame af, String listener);
+ public abstract void setMouseoverListener(AlignFrameI af,
+ String listener);
/**
* register a javascript function to handle any alignment selection events.
*
* @param listener
* name of javascript function (called with arguments
- * [jalview.appletgui.AlignFrame, String(sequence set id),
+ * [jalview.appletgui.AlignFrameI, String(sequence set id),
* String(separator separated list of sequences which were selected),
* String(separator separated list of column ranges (i.e. single
* number or hyphenated range) that were selected)]
*/
public abstract void setSelectionListener(String listener);
- public abstract void setSelectionListener(AlignFrame af, String listener);
+ public abstract void setSelectionListener(AlignFrameI af,
+ String listener);
/**
* register a javascript function to handle events normally routed to a Jmol
/**
* remove any callback using the given listener function and associated with
- * the given alignFrame (or null for all callbacks)
+ * the given AlignFrameI (or null for all callbacks)
*
* @param af
* (may be null)
* @param listener
* (may be null)
*/
- public abstract void removeJavascriptListener(AlignFrame af,
+ public abstract void removeJavascriptListener(AlignFrameI af,
String listener);
/**
String pdbfile);
/**
- * bind a pdb file to a sequence in the given alignFrame.
+ * bind a pdb file to a sequence in the given AlignFrameI.
*
* @param alFrame
- * - null or specific alignFrame. This specifies the dataset that
+ * - null or specific AlignFrameI. This specifies the dataset that
* will be searched for a seuqence called sequenceId
* @param sequenceId
* - sequenceId within the dataset.
* structure for indicating when PDB parsing or sequenceId location
* fails.
*/
- public abstract boolean addPdbFile(AlignFrame alFrame, String sequenceId,
+ public abstract boolean addPdbFile(AlignFrameI alFrame, String sequenceId,
String pdbEntryString, String pdbFile);
/**
* @param topRow
* @param leftHandColumn
*/
- public abstract void scrollViewToIn(AlignFrame alf, String topRow,
+ public abstract void scrollViewToIn(AlignFrameI alf, String topRow,
String leftHandColumn);
/**
* @param alf
* @param topRow
*/
- public abstract void scrollViewToRowIn(AlignFrame alf, String topRow);
+ public abstract void scrollViewToRowIn(AlignFrameI alf, String topRow);
/**
* adjust horizontal scroll to make the given column the left one in the given
* @param alf
* @param leftHandColumn
*/
- public abstract void scrollViewToColumnIn(AlignFrame alf,
+ public abstract void scrollViewToColumnIn(AlignFrameI alf,
String leftHandColumn);
/**
*
* @return
- * @see jalview.appletgui.AlignFrame#getFeatureGroups()
+ * @see jalview.appletgui.AlignFrameI#getFeatureGroups()
*/
public abstract String getFeatureGroups();
/**
* @param alf
- * alignframe to get feature groups on
+ * AlignFrameI to get feature groups on
* @return
- * @see jalview.appletgui.AlignFrame#getFeatureGroups()
+ * @see jalview.appletgui.AlignFrameI#getFeatureGroups()
*/
- public abstract String getFeatureGroupsOn(AlignFrame alf);
+ public abstract String getFeatureGroupsOn(AlignFrameI alf);
/**
* @param visible
* @return
- * @see jalview.appletgui.AlignFrame#getFeatureGroupsOfState(boolean)
+ * @see jalview.appletgui.AlignFrameI#getFeatureGroupsOfState(boolean)
*/
public abstract String getFeatureGroupsOfState(boolean visible);
* align frame to get groups of state visible
* @param visible
* @return
- * @see jalview.appletgui.AlignFrame#getFeatureGroupsOfState(boolean)
+ * @see jalview.appletgui.AlignFrameI#getFeatureGroupsOfState(boolean)
*/
- public abstract String getFeatureGroupsOfStateOn(AlignFrame alf,
+ public abstract String getFeatureGroupsOfStateOn(AlignFrameI alf,
boolean visible);
/**
* tab separated list of group names
* @param state
* true or false
- * @see jalview.appletgui.AlignFrame#setFeatureGroupState(java.lang.String[],
+ * @see jalview.appletgui.AlignFrameI#setFeatureGroupState(java.lang.String[],
* boolean)
*/
- public abstract void setFeatureGroupStateOn(AlignFrame alf, String groups,
+ public abstract void setFeatureGroupStateOn(AlignFrameI alf,
+ String groups,
boolean state);
public abstract void setFeatureGroupState(String groups, boolean state);
*/
package jalview.javascript;
+import jalview.api.JalviewApp;
import jalview.appletgui.AlignFrame;
-import jalview.bin.JalviewLite;
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SequenceGroup;
String _listener;
- public JsSelectionSender(JalviewLite jvlite, AlignFrame af,
- String listener)
+ public JsSelectionSender(JalviewApp jvlite, AlignFrame af,
+ String listener, boolean debug)
{
- super(jvlite);
+ super(jvlite, debug);
_af = af;
_listener = listener;
}
public void selection(SequenceGroup seqsel, ColumnSelection colsel,
HiddenColumns hidden, SelectionSource source)
{
- // System.err.println("Testing selection event relay to
- // jsfunction:"+_listener);
+ Object[] info = jvlite.getSelectionForListener(seqsel, colsel, hidden, source, _af);
try
{
- String setid = "";
- AlignFrame src = _af;
- if (source != null)
- {
- if (source instanceof jalview.appletgui.AlignViewport
- && ((jalview.appletgui.AlignViewport) source).applet.currentAlignFrame.viewport == source)
- {
- // should be valid if it just generated an event!
- src = ((jalview.appletgui.AlignViewport) source).applet.currentAlignFrame;
- }
- }
- 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);
- }
- ;
-
- }
System.err.println("Relaying selection to jsfunction:" + _listener);
- executeJavascriptFunction(_listener,
- new Object[]
- { src, setid, jvlite.arrayToSeparatorList(seqs),
- jvlite.arrayToSeparatorList(cols) });
+ executeJavascriptFunction(_listener, info);
+
} catch (Exception ex)
{
System.err.println(
}
}
+
}
@Override
*/
package jalview.javascript;
+import jalview.api.JalviewApp;
import jalview.appletgui.AlignFrame;
-import jalview.bin.JalviewLite;
import jalview.datamodel.SequenceI;
import jalview.structure.VamsasListener;
import jalview.structure.VamsasSource;
// + seq + " at " + index);
last = seq;
i = index;
- AlignFrame src = null;
+ Object alignFrame = jvlite.getFrameForSource(source);
try
{
- if (source != null)
- {
- if (source instanceof jalview.appletgui.AlignViewport
- && ((jalview.appletgui.AlignViewport) source).applet.currentAlignFrame.viewport == source)
- {
- // should be valid if it just generated an event!
- src = ((jalview.appletgui.AlignViewport) source).applet.currentAlignFrame;
-
- }
- // TODO: ensure that if '_af' is specified along with a handler
- // function, then only events from that alignFrame are sent to that
- // function
- }
executeJavascriptFunction(_listener,
new Object[]
- { src, seq.getDisplayId(false), "" + (1 + i),
+ { alignFrame, seq.getDisplayId(false), "" + (1 + i),
"" + seq.findPosition(i) });
} catch (Exception ex)
{
}
}
- public MouseOverListener(JalviewLite applet, AlignFrame af,
- String listener)
+ public MouseOverListener(JalviewApp applet, AlignFrame af,
+ String listener, boolean debug)
{
- super(applet);
+ super(applet, debug);
_af = af;
_listener = listener;
}
*/
package jalview.javascript;
+import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
-import jalview.api.FeatureRenderer;
+import jalview.api.JalviewApp;
import jalview.api.SequenceRenderer;
import jalview.appletgui.AlignFrame;
-import jalview.bin.JalviewLite;
import jalview.datamodel.SequenceI;
import jalview.ext.jmol.JmolCommands;
import jalview.structure.AtomSpec;
String _listenerfn;
- String[] modelSet;
+ public String[] modelSet;
- public MouseOverStructureListener(JalviewLite jalviewLite,
- String listener, String[] modelList)
+ public MouseOverStructureListener(JalviewApp app, String listener,
+ String[] modelList, boolean debug)
{
- super(jalviewLite);
+ super(app, debug);
_listenerfn = listener;
modelSet = modelList;
if (modelSet != null)
}
@Override
- public synchronized void updateColours(Object srce)
+ public synchronized void updateColours(Object source)
{
- final Object source = srce;
StructureSelectionManager ssm = StructureSelectionManager
- .getStructureSelectionManager(jvlite);
+ .getStructureSelectionManager(
+ jvlite.getStructureSelectionManagerProvider());
- if (JalviewLite.debug)
+ if (debug)
{
System.err.println(
this.getClass().getName() + " modelSet[0]: " + modelSet[0]);
ssm.reportMapping();
}
- if (source instanceof jalview.api.AlignmentViewPanel)
+ if (source instanceof AlignmentViewPanel)
{
+ AlignmentViewPanel panel = (AlignmentViewPanel) source;
SequenceI[][] sequence = new SequenceI[modelSet.length][];
for (int m = 0; m < modelSet.length; m++)
{
// }
}
- SequenceRenderer sr = ((jalview.appletgui.AlignmentPanel) source)
- .getSequenceRenderer();
- FeatureRenderer fr = ((jalview.appletgui.AlignmentPanel) source).av
- .isShowSequenceFeatures()
- ? new jalview.appletgui.FeatureRenderer(
- ((jalview.appletgui.AlignmentPanel) source).av)
- : null;
+ SequenceRenderer sr = panel.getSequenceRenderer();
+ AlignViewportI vp = panel.getAlignViewport();
+ jalview.renderer.seqfeatures.FeatureRenderer fr = vp
+ .isShowSequenceFeatures() ? jvlite.getNewFeatureRenderer(vp)
+ : null;
if (fr != null)
{
- ((jalview.appletgui.FeatureRenderer) fr).transferSettings(
- ((jalview.appletgui.AlignmentPanel) source)
- .getFeatureRenderer());
+ fr.transferSettings(panel.getFeatureRenderer());
}
- ;
// Form a colour command from the given alignment panel for each distinct
// structure
- ArrayList<String[]> ccomands = new ArrayList<String[]>();
- ArrayList<String> pdbfn = new ArrayList<String>();
+ ArrayList<String[]> ccomands = new ArrayList<>();
+ ArrayList<String> pdbfn = new ArrayList<>();
StructureMappingcommandSet[] colcommands = JmolCommands
.getColourBySequenceCommand(ssm, modelSet, sequence, sr,
(AlignmentViewPanel) source);
pdbfn.add(ccset.mapping);
}
- String mclass, mhandle;
String ccomandset[] = new String[sz];
sz = 0;
for (String[] ccset : ccomands)
System.arraycopy(ccset, 0, ccomandset, sz, ccset.length);
sz += ccset.length;
}
- if (jvlite.isJsMessageSetChanged(mclass = "colourstruct",
- mhandle = ((jalview.appletgui.AlignmentPanel) source).av
- .getViewId(),
- ccomandset))
+ String mclass = "colourstruct";
+ String mhandle = vp.getViewId();
+ if (isJsMessageSetChanged(mclass, mhandle, ccomandset, jvlite))
{
- jvlite.setJsMessageSet(mclass, mhandle, ccomandset);
+ setJsMessageSet(mclass, mhandle, ccomandset, jvlite);
// and notify javascript handler
- String st[] = new String[] { "colourstruct",
- "" + ((jalview.appletgui.AlignmentPanel) source).av.getViewId(),
+ String st[] = new String[] { mclass, mhandle,
"" + ccomandset.length, jvlite.arrayToSeparatorList(
pdbfn.toArray(new String[pdbfn.size()])) };
- try
- {
- executeJavascriptFunction(true, _listenerfn, st);
- } catch (Exception ex)
- {
- System.err.println("Couldn't execute callback with " + _listenerfn
- + " using args { " + st[0] + ", " + st[1] + ", " + st[2]
- + "," + st[3] + "}"); // + ","+st[4]+"\n");
- ex.printStackTrace();
-
- }
+ executeJavascriptFunction(true, st);
}
/*
* new Thread(new Runnable() { public void run() { // and send to
*/
}
+ jvlite.updateColoursFromMouseOver(source, this);
}
@Override
return true;
}
+ public void executeJavascriptFunction(boolean b, String[] st)
+ {
+ try
+ {
+ executeJavascriptFunction(true, _listenerfn, st);
+ } catch (Exception ex)
+ {
+ System.err.println("Couldn't execute callback with " + _listenerfn
+ + " using args { " + st[0] + ", " + st[1] + ", " + st[2] + ","
+ + st[3] + "}"); // + ","+st[4]+"\n");
+ ex.printStackTrace();
+
+ }
+ }
+
}