JAL-3187 convenience method on SplitContainerI to retrieve a complement’s alignFrame
[jalview.git] / src / jalview / gui / SplitFrame.java
index 25dedc5..396e3b3 100644 (file)
@@ -20,6 +20,7 @@
  */
 package jalview.gui;
 
+import jalview.api.AlignViewControllerGuiI;
 import jalview.api.SplitContainerI;
 import jalview.datamodel.AlignmentI;
 import jalview.jbgui.GAlignFrame;
@@ -763,6 +764,22 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI
             { (AlignFrame) getTopFrame(), (AlignFrame) getBottomFrame() });
   }
 
+  @Override
+  public AlignFrame getComplementAlignFrame(
+          AlignViewControllerGuiI alignFrame)
+  {
+    if (getTopFrame() == alignFrame)
+    {
+      return (AlignFrame) getBottomFrame();
+    }
+    if (getBottomFrame() == alignFrame)
+    {
+      return (AlignFrame) getTopFrame();
+    }
+    // we didn't know anything about this frame...
+    return null;
+  }
+
   /**
    * Replace Cmd-F Find action with our version. This is necessary because the
    * 'default' Finder searches in the first AlignFrame it finds. We need it to