JAL-1807
[jalview.git] / src / jalview / appletgui / AlignFrame.java
index 3e919f6..5d3f33c 100644 (file)
  */
 package jalview.appletgui;
 
-import java.awt.BorderLayout;
-import java.awt.Canvas;
-import java.awt.CheckboxMenuItem;
-import java.awt.Color;
-import java.awt.Font;
-import java.awt.FontMetrics;
-import java.awt.Frame;
-import java.awt.Graphics;
-import java.awt.Label;
-import java.awt.Menu;
-import java.awt.MenuBar;
-import java.awt.MenuItem;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLEncoder;
-import java.util.Arrays;
-import java.util.Deque;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
 import jalview.analysis.AlignmentSorter;
 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
 import jalview.api.AlignViewControllerGuiI;
 import jalview.api.AlignViewControllerI;
 import jalview.api.AlignViewportI;
 import jalview.api.FeatureRenderer;
+import jalview.api.FeatureSettingsControllerI;
 import jalview.api.SequenceStructureBinding;
 import jalview.bin.JalviewLite;
 import jalview.commands.CommandI;
@@ -70,6 +37,7 @@ import jalview.commands.RemoveGapColCommand;
 import jalview.commands.RemoveGapsCommand;
 import jalview.commands.SlideSequencesCommand;
 import jalview.commands.TrimRegionCommand;
+import jalview.controller.AlignViewController;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
@@ -79,10 +47,14 @@ import jalview.datamodel.PDBEntry;
 import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
+import jalview.io.AlignmentProperties;
 import jalview.io.AnnotationFile;
 import jalview.io.AppletFormatAdapter;
 import jalview.io.FeaturesFile;
+import jalview.io.NewickFile;
+import jalview.io.AlignFile;
 import jalview.io.TCoffeeScoreFile;
+import jalview.jsdev.GenericFileAdapter;
 import jalview.schemes.Blosum62ColourScheme;
 import jalview.schemes.BuriedColourScheme;
 import jalview.schemes.ClustalxColourScheme;
@@ -101,8 +73,47 @@ import jalview.schemes.TurnColourScheme;
 import jalview.schemes.ZappoColourScheme;
 import jalview.structure.StructureSelectionManager;
 import jalview.structures.models.AAStructureBindingModel;
+import jalview.util.Comparison;
 import jalview.util.MappingUtils;
 import jalview.util.MessageManager;
+import jalview.viewmodel.AlignmentViewport;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.util.Arrays;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import awt2swing.Canvas;
+import awt2swing.CheckboxMenuItem;
+import awt2swing.Frame;
+import awt2swing.Label;
+import awt2swing.Menu;
+import awt2swing.MenuBar;
+import awt2swing.MenuItem;
+
+//import org.jmol.viewer.Viewer;
 
 public class AlignFrame extends EmbmenuFrame implements ActionListener,
         ItemListener, KeyListener, AlignViewControllerGuiI
@@ -113,9 +124,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 
   public AlignViewport viewport;
 
-  int DEFAULT_WIDTH = 700;
+  // width and height may be overridden by applet parameters
+  int frameWidth = 700;
 
-  int DEFAULT_HEIGHT = 500;
+  int frameHeight = 500;
 
   String jalviewServletURL;
 
@@ -154,6 +166,20 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
   public AlignFrame(AlignmentI al, JalviewLite applet,
           String title, boolean embedded, boolean addToDisplay)
   {
+    this(al, null, null, applet, title, embedded, addToDisplay);
+  }
+
+  public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs,
+          ColumnSelection columnSelection, JalviewLite applet,
+          String title, boolean embedded)
+  {
+    this(al, hiddenSeqs, columnSelection, applet, title, embedded, true);
+  }
+
+  public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs,
+          ColumnSelection columnSelection, JalviewLite applet,
+          String title, boolean embedded, boolean addToDisplay)
+  {
     if (applet != null)
     {
       jalviewServletURL = applet.getParameter("APPLICATION_URL");
@@ -176,33 +202,44 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
         if (param != null)
         {
           int width = Integer.parseInt(param);
-          DEFAULT_WIDTH = width;
+          frameWidth = width;
         }
         param = applet.getParameter("windowHeight");
         if (param != null)
         {
           int height = Integer.parseInt(param);
-          DEFAULT_HEIGHT = height;
+          frameHeight = height;
         }
       } catch (Exception ex)
       {
       }
     }
     viewport = new AlignViewport(al, applet);
+
+    if (hiddenSeqs != null && hiddenSeqs.length > 0)
+    {
+      viewport.hideSequence(hiddenSeqs);
+    }
+    if (columnSelection != null)
+    {
+      viewport.setColumnSelection(columnSelection);
+    }
+
     alignPanel = new AlignmentPanel(this, viewport);
-    avc = new jalview.controller.AlignViewController(this, viewport,
+    avc = new AlignViewController(this, viewport,
             alignPanel);
     viewport.updateConservation(alignPanel);
     viewport.updateConsensus(alignPanel);
 
     displayNonconservedMenuItem.setState(viewport.getShowUnconserved());
-    followMouseOverFlag.setState(viewport.getFollowHighlight());
+    followMouseOverFlag.setState(viewport.isFollowHighlight());
     showGroupConsensus.setState(viewport.isShowGroupConsensus());
     showGroupConservation.setState(viewport.isShowGroupConservation());
     showConsensusHistogram.setState(viewport.isShowConsensusHistogram());
     showSequenceLogo.setState(viewport.isShowSequenceLogo());
     normSequenceLogo.setState(viewport.isNormaliseSequenceLogo());
     applyToAllGroups.setState(viewport.getColourAppliesToAllGroups());
+    annotationPanelMenuItem.setState(viewport.isShowAnnotation());
     showAlignmentAnnotations.setState(viewport.isShowAnnotation());
     showSequenceAnnotations.setState(viewport.isShowAnnotation());
 
@@ -336,7 +373,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     boolean featuresFile = false;
     try
     {
-      featuresFile = new jalview.io.FeaturesFile(file, type)
+      featuresFile = new FeaturesFile(file, type)
               .parse(viewport.getAlignment(), alignPanel.seqPanel.seqCanvas
                       .getFeatureRenderer().getFeatureColours(), featureLinks,
                       true, viewport.applet.getDefaultParameter(
@@ -367,7 +404,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
         viewport.featureSettings.refreshTable();
       }
       alignPanel.paintAlignment(true);
-      statusBar.setText(MessageManager
+      setStatus(MessageManager
               .getString("label.successfully_added_features_alignment"));
     }
     return featuresFile;
@@ -522,7 +559,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 
     case KeyEvent.VK_F2:
       viewport.cursorMode = !viewport.cursorMode;
-      statusBar.setText(MessageManager.formatMessage(
+      setStatus(MessageManager.formatMessage(
               "label.keyboard_editing_mode", new String[]
               { (viewport.cursorMode ? "on" : "off") }));
       if (viewport.cursorMode)
@@ -899,7 +936,9 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
               : showForSequences);
         aa.visible = visible;
     }
-    alignPanel.validateAnnotationDimensions(false);
+    alignPanel.validateAnnotationDimensions(true);
+    validate();
+    repaint();
   }
 
   private void setAnnotationSortOrder(SequenceAnnotationOrder order)
@@ -924,7 +963,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 
   private void mouseOverFlag_stateChanged()
   {
-    viewport.followHighlight = followMouseOverFlag.getState();
+    viewport.setFollowHighlight(followMouseOverFlag.getState());
     // TODO: could kick the scrollTo mechanism to reset view for current
     // searchresults.
   }
@@ -1139,13 +1178,13 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     }
     else if (source == alProperties)
     {
-      StringBuffer contents = new jalview.io.AlignmentProperties(
+      StringBuffer contents = new AlignmentProperties(
               viewport.getAlignment()).formatAsString();
       CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this);
       cap.setText(contents.toString());
       Frame frame = new Frame();
       frame.add(cap);
-      jalview.bin.JalviewLite.addFrame(frame, MessageManager.formatMessage(
+      JalviewLite.addFrame(frame, MessageManager.formatMessage(
               "label.alignment_properties", new String[]
               { getTitle() }), 400, 250);
     }
@@ -1298,7 +1337,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
     Frame frame = new Frame();
     frame.add(cap);
-    jalview.bin.JalviewLite.addFrame(frame,
+    JalviewLite.addFrame(frame,
             MessageManager.getString("label.input_cut_paste"), 500, 500);
   }
 
@@ -1307,10 +1346,12 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
     Frame frame = new Frame();
     frame.add(cap);
-    jalview.bin.JalviewLite.addFrame(frame, MessageManager.formatMessage(
+    JalviewLite.addFrame(frame, MessageManager.formatMessage(
             "label.alignment_output_command", new Object[]
             { e.getActionCommand() }), 600, 500);
-    cap.setText(new AppletFormatAdapter().formatSequences(
+
+    FeatureRenderer fr = this.alignPanel.cloneFeatureRenderer();
+    cap.setText(new AppletFormatAdapter(alignPanel).formatSequences(
             e.getActionCommand(), viewport.getAlignment(),
             viewport.getShowJVSuffix()));
   }
@@ -1323,7 +1364,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     cap.setAnnotationImport();
     Frame frame = new Frame();
     frame.add(cap);
-    jalview.bin.JalviewLite.addFrame(frame,
+    JalviewLite.addFrame(frame,
             MessageManager.getString("action.paste_annotations"), 400, 300);
 
   }
@@ -1338,7 +1379,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
       CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this);
       Frame frame = new Frame();
       frame.add(cap);
-      jalview.bin.JalviewLite.addFrame(frame,
+      JalviewLite.addFrame(frame,
               MessageManager.getString("label.annotations"), 600, 500);
       cap.setText(annotation);
     }
@@ -1388,7 +1429,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
       }
       Frame frame = new Frame();
       frame.add(cap);
-      jalview.bin.JalviewLite.addFrame(frame,
+      JalviewLite.addFrame(frame,
               MessageManager.getString("label.features"), 600, 500);
       cap.setText(features);
     }
@@ -1592,7 +1633,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     viewport.addToRedoList(command);
     command.undoCommand(null);
 
-    AlignViewport originalSource = getOriginatingSource(command);
+    AlignmentViewport originalSource = getOriginatingSource(command);
     // JBPNote Test
     if (originalSource != viewport)
     {
@@ -1624,7 +1665,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     viewport.addToHistoryList(command);
     command.doCommand(null);
 
-    AlignViewport originalSource = getOriginatingSource(command);
+    AlignmentViewport originalSource = getOriginatingSource(command);
     // JBPNote Test
     if (originalSource != viewport)
     {
@@ -1640,9 +1681,9 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
             .getAlignment().getSequences());
   }
 
-  AlignViewport getOriginatingSource(CommandI command)
+  AlignmentViewport getOriginatingSource(CommandI command)
   {
-    AlignViewport originalSource = null;
+    AlignmentViewport originalSource = null;
     // For sequence removal and addition, we need to fire
     // the property change event FROM the viewport where the
     // original alignment was altered
@@ -1884,7 +1925,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
       for (int j = 0; j < sg.getEndRes() + 1 && j < seq.getLength(); j++)
       {
         ch = seq.getCharAt(j);
-        if (!jalview.util.Comparison.isGap((ch)))
+        if (!Comparison.isGap((ch)))
         {
           endRes++;
         }
@@ -1964,8 +2005,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
           }
         }
 
-        jalview.bin.JalviewLite.addFrame(af, newtitle, DEFAULT_WIDTH,
-                DEFAULT_HEIGHT);
+        JalviewLite.addFrame(af, newtitle, frameWidth,
+                frameHeight);
       }
       else
       {
@@ -2240,7 +2281,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
                 viewport.getSelectionGroup());
       }
 
-      statusBar.setText(MessageManager.formatMessage(
+      setStatus(MessageManager.formatMessage(
               "label.removed_columns", new String[]
               { Integer.valueOf(trimRegion.getSize()).toString() }));
       addHistoryItem(trimRegion);
@@ -2282,7 +2323,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 
     addHistoryItem(removeGapCols);
 
-    statusBar.setText(MessageManager.formatMessage(
+    setStatus(MessageManager.formatMessage(
             "label.removed_empty_columns", new String[]
             { Integer.valueOf(removeGapCols.getSize()).toString() }));
 
@@ -2516,7 +2557,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     OverviewPanel overview = new OverviewPanel(alignPanel);
     frame.add(overview);
     // +50 must allow for applet frame window
-    jalview.bin.JalviewLite.addFrame(frame, MessageManager.formatMessage(
+    JalviewLite.addFrame(frame, MessageManager.formatMessage(
             "label.overview_params", new String[]
             { this.getTitle() }), overview.getPreferredSize().width,
             overview.getPreferredSize().height + 50);
@@ -2539,7 +2580,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 
   }
 
-  void changeColour(ColourSchemeI cs)
+  public void changeColour(ColourSchemeI cs)
   {
     int threshold = 0;
 
@@ -2569,8 +2610,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
       alignPanel.getOverviewPanel().updateOverviewImage();
     }
 
-    jalview.structure.StructureSelectionManager
-            .getStructureSelectionManager(viewport.applet)
+    StructureSelectionManager.getStructureSelectionManager(viewport.applet)
             .sequenceColoursChanged(alignPanel);
 
     alignPanel.paintAlignment(true);
@@ -2673,7 +2713,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     {
       Frame frame = new Frame();
       frame.add(new PairwiseAlignPanel(alignPanel));
-      jalview.bin.JalviewLite.addFrame(frame,
+      JalviewLite.addFrame(frame,
               MessageManager.getString("action.pairwise_alignment"), 600,
               500);
     }
@@ -2765,7 +2805,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 
       addTreeMenuItem(tp, title);
 
-      jalview.bin.JalviewLite.addFrame(tp, title, 600, 500);
+      JalviewLite.addFrame(tp, title, 600, 500);
     }
   }
 
@@ -2776,15 +2816,15 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     cap.setTreeImport();
     Frame frame = new Frame();
     frame.add(cap);
-    jalview.bin.JalviewLite.addFrame(frame,
+    JalviewLite.addFrame(frame,
             MessageManager.getString("label.paste_newick_file"), 400, 300);
   }
 
-  public void loadTree(jalview.io.NewickFile tree, String treeFile)
+  public void loadTree(NewickFile tree, String treeFile)
   {
     TreePanel tp = new TreePanel(alignPanel, treeFile,
             MessageManager.getString("label.load_tree_from_file"), tree);
-    jalview.bin.JalviewLite.addFrame(tp, treeFile, 600, 500);
+    JalviewLite.addFrame(tp, treeFile, 600, 500);
     addTreeMenuItem(tp, treeFile);
   }
 
@@ -2889,7 +2929,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
       }
 
       @Override
-      public void paint(Graphics g)
+      public void paintComponent(Graphics g)
       {
         g.setColor(Color.white);
         g.fillRect(0, 0, getSize().width, getSize().height);
@@ -2897,7 +2937,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
         FontMetrics fm = g.getFontMetrics();
         int fh = fm.getHeight();
         int y = 5, x = 7;
-        g.setColor(Color.black);
+        g.setColor(Color.black); 
         // TODO: update this text for each release or centrally store it for
         // lite and application
         g.setFont(new Font("Helvetica", Font.BOLD, 14));
@@ -2934,7 +2974,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     Frame frame = new Frame();
     frame.add(new AboutPanel(JalviewLite.getVersion(), JalviewLite
             .getBuildDate()));
-    jalview.bin.JalviewLite.addFrame(frame,
+    JalviewLite.addFrame(frame,
             MessageManager.getString("label.jalview"), 580, 220);
 
   }
@@ -3017,7 +3057,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 
   BorderLayout borderLayout1 = new BorderLayout();
 
-  public Label statusBar = new Label();
+  Label statusBar = new Label();
 
   MenuItem clustalColour = new MenuItem();
 
@@ -3164,11 +3204,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     inputText.addActionListener(this);
     Menu outputTextboxMenu = new Menu(
             MessageManager.getString("label.out_to_textbox"));
-    for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; i++)
+    for (int i = 0; i < AppletFormatAdapter.WRITEABLE_FORMATS.length; i++)
     {
 
-      MenuItem item = new MenuItem(
-              jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]);
+      MenuItem item = new MenuItem(AppletFormatAdapter.WRITEABLE_FORMATS[i]);
 
       item.addActionListener(new java.awt.event.ActionListener()
       {
@@ -3596,8 +3635,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     /*
      * Annotations menu
      */
-    // annotationsMenu.add(annotationPanelMenuItem);
-    // annotationsMenu.addSeparator();
+    annotationsMenu.add(annotationPanelMenuItem);
+    annotationsMenu.addSeparator();
     annotationsMenu.add(showAlignmentAnnotations);
     annotationsMenu.add(showSequenceAnnotations);
     annotationsMenu.add(sortAnnBySequence);
@@ -3691,11 +3730,11 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
      */
     statusBar.setBackground(Color.white);
     statusBar.setFont(new java.awt.Font("Verdana", 0, 11));
-    statusBar.setText(MessageManager.getString("label.status_bar"));
+    setStatus(MessageManager.getString("label.status_bar"));
     this.add(statusBar, BorderLayout.SOUTH);
   }
 
-  public void setStatus(String string)
+       public void setStatus(String string)
   {
     statusBar.setText(string);
   };
@@ -3738,6 +3777,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 
   private CheckboxMenuItem showAutoLast;
 
+  private SplitFrame splitFrame;
+
   /**
    * Attach the alignFrame panels after embedding menus, if necessary. This used
    * to be called setEmbedded, but is now creates the dropdown menus in a
@@ -3770,9 +3811,9 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
       add(statusBar, BorderLayout.SOUTH);
       add(alignPanel, BorderLayout.CENTER);
       // and register with the applet so it can pass external API calls to us
-      jalview.bin.JalviewLite.addFrame(this, this.getTitle(),
-              DEFAULT_WIDTH,
-              DEFAULT_HEIGHT);
+      JalviewLite.addFrame(this, this.getTitle(),
+              frameWidth,
+              frameHeight);
     }
   }
 
@@ -3822,77 +3863,77 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     theApplet.validate();
   }
 
-  /**
-   * create a new binding between structures in an existing jmol viewer instance
-   * and an alignpanel with sequences that have existing PDBFile entries. Note,
-   * this does not open a new Jmol window, or modify the display of the
-   * structures in the original jmol window. Note This method doesn't work
-   * without an additional javascript library to exchange messages between the
-   * distinct applets. See http://issues.jalview.org/browse/JAL-621
-   * 
-   * @param viewer
-   *          JmolViewer instance
-   * @param sequenceIds
-   *          - sequence Ids to search for associations
-   */
-  public SequenceStructureBinding addStructureViewInstance(
-          Object jmolviewer, String[] sequenceIds)
-  {
-    org.jmol.api.JmolViewer viewer = null;
-    try
-    {
-      viewer = (org.jmol.api.JmolViewer) jmolviewer;
-    } catch (ClassCastException ex)
-    {
-      System.err.println("Unsupported viewer object :"
-              + jmolviewer.getClass());
-    }
-    if (viewer == null)
-    {
-      System.err.println("Can't use this object as a structure viewer:"
-              + jmolviewer.getClass());
-      return null;
-    }
-    SequenceI[] seqs = null;
-    if (sequenceIds == null || sequenceIds.length == 0)
-    {
-      seqs = viewport.getAlignment().getSequencesArray();
-    }
-    else
-    {
-      Vector sqi = new Vector();
-      AlignmentI al = viewport.getAlignment();
-      for (int sid = 0; sid < sequenceIds.length; sid++)
-      {
-        SequenceI sq = al.findName(sequenceIds[sid]);
-        if (sq != null)
-        {
-          sqi.addElement(sq);
-        }
-      }
-      if (sqi.size() > 0)
-      {
-        seqs = new SequenceI[sqi.size()];
-        for (int sid = 0, sSize = sqi.size(); sid < sSize; sid++)
-        {
-          seqs[sid] = (SequenceI) sqi.elementAt(sid);
-        }
-      }
-      else
-      {
-        return null;
-      }
-    }
-    AAStructureBindingModel jmv = null;
-    // TODO: search for a jmv that involves viewer
-    if (jmv == null)
-    { // create a new viewer/jalview binding.
-      jmv = new ExtJmol(viewer, alignPanel, new SequenceI[][]
-      { seqs });
-    }
-    return jmv;
-
-  }
+       /**
+        * create a new binding between structures in an existing jmol viewer instance
+        * and an alignpanel with sequences that have existing PDBFile entries. Note,
+        * this does not open a new Jmol window, or modify the display of the
+        * structures in the original jmol window. Note This method doesn't work
+        * without an additional javascript library to exchange messages between the
+        * distinct applets. See http://issues.jalview.org/browse/JAL-621
+        * 
+        * @param viewer
+        *          JmolViewer instance
+        * @param sequenceIds
+        *          - sequence Ids to search for associations
+        */
+       public SequenceStructureBinding addStructureViewInstance(Object jmolviewer,
+                       String[] sequenceIds) {
+               return null;
+               // Viewer viewer = null;
+               // try
+               // {
+               // viewer = (Viewer) jmolviewer;
+               // } catch (ClassCastException ex)
+               // {
+               // System.err.println("Unsupported viewer object :"
+               // + jmolviewer.getClass());
+               // }
+               // if (viewer == null)
+               // {
+               // System.err.println("Can't use this object as a structure viewer:"
+               // + jmolviewer.getClass());
+               // return null;
+               // }
+               // SequenceI[] seqs = null;
+               // if (sequenceIds == null || sequenceIds.length == 0)
+               // {
+               // seqs = viewport.getAlignment().getSequencesArray();
+               // }
+               // else
+               // {
+               // Vector sqi = new Vector();
+               // AlignmentI al = viewport.getAlignment();
+               // for (int sid = 0; sid < sequenceIds.length; sid++)
+               // {
+               // SequenceI sq = al.findName(sequenceIds[sid]);
+               // if (sq != null)
+               // {
+               // sqi.addElement(sq);
+               // }
+               // }
+               // if (sqi.size() > 0)
+               // {
+               // seqs = new SequenceI[sqi.size()];
+               // for (int sid = 0, sSize = sqi.size(); sid < sSize; sid++)
+               // {
+               // seqs[sid] = (SequenceI) sqi.elementAt(sid);
+               // }
+               // }
+               // else
+               // {
+               // return null;
+               // }
+               // }
+               // AAStructureBindingModel jmv = null;
+               // // TODO: search for a jmv that involves viewer
+               // if (jmv == null)
+               // { // create a new viewer/jalview binding.
+               // jmv = new ExtJmol(viewer, alignPanel, new SequenceI[][]
+               // { seqs });
+               // }
+               // return jmv;
+               //
+       }
 
   /**
    * bind a pdb file to a sequence in the current view
@@ -3990,79 +4031,67 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 
   }
 
-  public void newStructureView(JalviewLite applet, PDBEntry pdb,
-          SequenceI[] seqs, String[] chains, String protocol)
-  {
-    // Scrub any null sequences from the array
-    Object[] sqch = cleanSeqChainArrays(seqs, chains);
-    seqs = (SequenceI[]) sqch[0];
-    chains = (String[]) sqch[1];
-    if (seqs == null || seqs.length == 0)
-    {
-      System.err
-              .println("JalviewLite.AlignFrame:newStructureView: No sequence to bind structure to.");
-    }
-    if (protocol == null || protocol.trim().length() == 0
-            || protocol.equals("null"))
-    {
-      protocol = (String) pdb.getProperty().get("protocol");
-      if (protocol == null)
-      {
-        System.err.println("Couldn't work out protocol to open structure: "
-                + pdb.getId());
-        return;
-      }
-    }
-    if (applet.useXtrnalSviewer)
-    {
-      // register the association(s) and quit, don't create any windows.
-      if (StructureSelectionManager.getStructureSelectionManager(applet)
-              .setMapping(seqs, chains, pdb.getFile(), protocol) == null)
-      {
-        System.err.println("Failed to map " + pdb.getFile() + " ("
-                + protocol + ") to any sequences");
-      }
-      return;
-    }
-    if (applet.isAlignPdbStructures() && applet.jmolAvailable)
-    {
-      // can only do alignments with Jmol
-      // find the last jmol window assigned to this alignment
-      jalview.appletgui.AppletJmol ajm = null, tajm;
-      Vector jmols = applet
-              .getAppletWindow(jalview.appletgui.AppletJmol.class);
-      for (int i = 0, iSize = jmols.size(); i < iSize; i++)
-      {
-        tajm = (jalview.appletgui.AppletJmol) jmols.elementAt(i);
-        if (tajm.ap.alignFrame == this)
-        {
-          ajm = tajm;
-          break;
-        }
-      }
-      if (ajm != null)
-      {
-        System.err
-                .println("Incremental adding and aligning structure to existing Jmol view not yet implemented.");
-        // try and add the pdb structure
-        // ajm.addS
-        ajm = null;
-      }
-    }
-    // otherwise, create a new window
-    if (applet.jmolAvailable)
-    {
-      new jalview.appletgui.AppletJmol(pdb, seqs, chains, alignPanel,
-              protocol);
-      applet.lastFrameX += 40;
-      applet.lastFrameY += 40;
-    }
-    else
-    {
-      new MCview.AppletPDBViewer(pdb, seqs, chains, alignPanel, protocol);
-    }
-
-  }
+       public void newStructureView(JalviewLite applet, PDBEntry pdb,
+                       SequenceI[] seqs, String[] chains, String protocol) {
+               // Scrub any null sequences from the array
+               Object[] sqch = cleanSeqChainArrays(seqs, chains);
+               seqs = (SequenceI[]) sqch[0];
+               chains = (String[]) sqch[1];
+               if (seqs == null || seqs.length == 0) {
+                       System.err
+                                       .println("JalviewLite.AlignFrame:newStructureView: No sequence to bind structure to.");
+               }
+               if (protocol == null || protocol.trim().length() == 0
+                               || protocol.equals("null")) {
+                       protocol = (String) pdb.getProperty().get("protocol");
+                       if (protocol == null) {
+                               System.err.println("Couldn't work out protocol to open structure: "
+                                               + pdb.getId());
+                               return;
+                       }
+               }
+               if (applet.useXtrnalSviewer) {
+                       // register the association(s) and quit, don't create any windows.
+                       if (StructureSelectionManager.getStructureSelectionManager(applet)
+                                       .setMapping(seqs, chains, pdb.getFile(), protocol) == null) {
+                               System.err.println("Failed to map " + pdb.getFile() + " (" + protocol
+                                               + ") to any sequences");
+                       }
+                       return;
+               }
+               if (applet.isAlignPdbStructures() && applet.jmolAvailable) {
+                       // can only do alignments with Jmol
+                       // find the last jmol window assigned to this alignment
+                       AppletJmol ajm = null, tajm;
+                       Vector jmols = applet.getAppletWindow(AppletJmol.class);
+                       for (int i = 0, iSize = jmols.size(); i < iSize; i++) {
+                               tajm = (AppletJmol) jmols.elementAt(i);
+                               if (tajm.ap.alignFrame == this) {
+                                       ajm = tajm;
+                                       break;
+                               }
+                       }
+                       if (ajm != null) {
+                               System.err
+                                               .println("Incremental adding and aligning structure to existing Jmol view not yet implemented.");
+                               // try and add the pdb structure
+                               // ajm.addS
+                               ajm = null;
+                       }
+               }
+               // otherwise, create a new window
+               // if (applet.jmolAvailable)
+               // {
+               new AppletJmol(pdb, seqs, chains, alignPanel, protocol);
+               applet.lastFrameX += 40;
+               applet.lastFrameY += 40;
+               // }
+               // else
+               // {
+               // new MCview.AppletPDBViewer(pdb, seqs, chains, alignPanel, protocol);
+               // }
+
+       }
 
   public void alignedStructureView(JalviewLite applet, PDBEntry[] pdb,
           SequenceI[][] seqs, String[][] chains, String[] protocols)
@@ -4111,22 +4140,22 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
   /**
    * Load the (T-Coffee) score file from the specified url
    * 
-   * @param source
+   * @param inFile
    *          File/URL/T-COFFEE score file contents
    * @throws IOException
    * @return true if alignment was annotated with data from source
    */
-  public boolean loadScoreFile(String source) throws IOException
+  public boolean loadScoreFile(String inFile) throws IOException
   {
 
-    TCoffeeScoreFile file = new TCoffeeScoreFile(source,
-            AppletFormatAdapter.checkProtocol(source));
+    TCoffeeScoreFile file = (TCoffeeScoreFile) GenericFileAdapter.getFile("TCoffeeScoreFile", inFile, 
+            AppletFormatAdapter.checkProtocol(inFile));        
     if (!file.isValid())
     {
       // TODO: raise dialog for gui
       System.err.println("Problems parsing T-Coffee scores: "
               + file.getWarningMessage());
-      System.err.println("Origin was:\n" + source);
+      System.err.println("Origin was:\n" + inFile);
       return false;
     }
 
@@ -4164,4 +4193,45 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     return false;
   }
 
+  public SplitFrame getSplitFrame()
+  {
+    return this.splitFrame;
+  }
+
+  public void setSplitFrame(SplitFrame sf)
+  {
+    this.splitFrame = sf;
+  }
+
+    // may not need this
+  @Override
+  public void setShowSeqFeatures(boolean b)
+  {
+    // showSeqFeatures.setSelected(b);
+    viewport.setShowSequenceFeatures(b);
+
+  }
+
+  @Override
+  public void setMenusForViewport()
+  {
+    // setMenusFromViewport(viewport);
+
+  }
+  @Override
+  public void refreshFeatureUI(boolean enableIfNecessary)
+  {
+    if (enableIfNecessary)
+    {
+      sequenceFeatures.setState(true);
+      alignPanel.av.setShowSequenceFeatures(true);
+    }
+  }
+
+  @Override
+  public FeatureSettingsControllerI getFeatureSettingsUI()
+  {
+    return alignPanel.av.featureSettings;
+  }
+
 }