*/
public String getSelectedSequences()
{
- return getSelectedSequencesFrom(currentAlignFrame);
+ return getSelectedSequencesFrom(getDefaultTargetFrame());
}
public String getSelectedSequencesFrom(AlignFrame alf)
{
public String getAlignment(String format)
{
- return getAlignmentFrom(currentAlignFrame, format, "true");
+ return getAlignmentFrom(getDefaultTargetFrame(), format, "true");
}
public String getAlignmentFrom(AlignFrame alf, String format)
{
}
public String getAlignment(String format, String suffix)
{
- return getAlignmentFrom(currentAlignFrame, format, suffix);
+ return getAlignmentFrom(getDefaultTargetFrame(), format, suffix);
}
public String getAlignmentFrom(AlignFrame alf, String format, String suffix)
{
public void loadAnnotation(String annotation)
{
- loadAnnotationFrom(currentAlignFrame, annotation);
+ loadAnnotationFrom(getDefaultTargetFrame(), annotation);
}
public void loadAnnotationFrom(AlignFrame alf, String annotation)
{
public String getFeatures(String format)
{
- return getFeaturesFrom(currentAlignFrame, format);
+ return getFeaturesFrom(getDefaultTargetFrame(), format);
}
public String getFeaturesFrom(AlignFrame alf, String format)
{
}
public String getAnnotation()
{
- return getAnnotationFrom(currentAlignFrame);
+ return getAnnotationFrom(getDefaultTargetFrame());
}
public String getAnnotationFrom(AlignFrame alf)
{
}
public AlignFrame newView()
{
- return newViewFrom(currentAlignFrame);
+ return newViewFrom(getDefaultTargetFrame());
}
public AlignFrame newView(String name)
{
- return newViewFrom(currentAlignFrame, name);
+ return newViewFrom(getDefaultTargetFrame(), name);
}
public AlignFrame newViewFrom(AlignFrame alf)
String file = "No file";
Button launcher = new Button("Start Jalview");
- //The currentAlignFrame is static, it will change
- //if and when the user selects a new window
+ /**
+ * The currentAlignFrame is static, it will change
+ * if and when the user selects a new window.
+ * Note that it will *never* point back to the embedded AlignFrame
+ * if the applet is started as embedded on the page and then afterwards a new view is created.
+ */
public static AlignFrame currentAlignFrame;
- //This is the first frame to be displayed, and does not change
+ /**
+ * This is the first frame to be displayed, and does not change.
+ * API calls will default to this instance if currentAlignFrame is null.
+ */
AlignFrame initialAlignFrame;
boolean embedded = false;
frame.setMenuBar(null);
frame.dispose();
}
-
+
public void windowActivated(WindowEvent e)
{
if (frame instanceof AlignFrame)
System.err.println("Activated window "+frame);
}
}
+ // be good.
+ super.windowActivated(e);
}
-
+ /* Probably not necessary to do this - see TODO above.
+ * (non-Javadoc)
+ * @see java.awt.event.WindowAdapter#windowDeactivated(java.awt.event.WindowEvent)
+ *
+ public void windowDeactivated(WindowEvent e)
+ {
+ if (currentAlignFrame == frame)
+ {
+ currentAlignFrame = null;
+ if (debug)
+ {
+ System.err.println("Deactivated window "+frame);
+ }
+ }
+ super.windowDeactivated(e);
+ }
+ */
});
frame.setVisible(true);
}
}
if ( (al != null) && (al.getHeight() > 0))
{
- currentAlignFrame = new AlignFrame(al,
+ initialAlignFrame = new AlignFrame(al,
applet,
file,
embedded);
+ // update the focus.
+ currentAlignFrame = initialAlignFrame;
if (protocol == jalview.io.AppletFormatAdapter.PASTE)
{
currentAlignFrame.setTitle("Sequences from " + getDocumentBase());
}
- initialAlignFrame = currentAlignFrame;
-
currentAlignFrame.statusBar.setText("Successfully loaded file " + file);
String treeFile = applet.getParameter("tree");
}
}
/**
+ * @return the default alignFrame acted on by the public applet methods.
+ * May return null with an error message on System.err indicating the fact.
+ */
+ protected AlignFrame getDefaultTargetFrame()
+ {
+ if (currentAlignFrame!=null)
+ {
+ return currentAlignFrame;
+ }
+ if (initialAlignFrame!=null)
+ {
+ return initialAlignFrame;
+ }
+ System.err.println("Implementation error: Jalview Applet API cannot work out which AlignFrame to use.");
+ return null;
+ }
+ /**
* separator used for separatorList
*/
protected String separator = "|"; // this is a safe(ish) separator - tabs don't work for firefox
*/
public String getFeatureGroups()
{
- String lst = arrayToSeparatorList(currentAlignFrame.getFeatureGroups());
+ String lst = arrayToSeparatorList(getDefaultTargetFrame().getFeatureGroups());
return lst;
}
/**
*/
public String getFeatureGroupsOfState(boolean visible)
{
- return arrayToSeparatorList(currentAlignFrame.getFeatureGroupsOfState(visible));
+ return arrayToSeparatorList(getDefaultTargetFrame().getFeatureGroupsOfState(visible));
}
/**
* @param alf align frame to get groups of state visible
}
public void setFeatureGroupState(String groups, boolean state)
{
- setFeatureGroupStateOn(currentAlignFrame, groups, state);
+ setFeatureGroupStateOn(getDefaultTargetFrame(), groups, state);
}
/**
* List separator string