JAL-845 SplitFrame for "show product" and after aligning from SplitFrame
[jalview.git] / src / jalview / jbgui / GSplitFrame.java
index b2ecaeb..062fe9f 100644 (file)
@@ -1,5 +1,6 @@
 package jalview.jbgui;
 
+import jalview.api.SplitContainerI;
 import jalview.util.Platform;
 
 import java.awt.Component;
@@ -11,7 +12,7 @@ import javax.swing.JInternalFrame;
 import javax.swing.JSplitPane;
 import javax.swing.plaf.basic.BasicInternalFrameUI;
 
-public class GSplitFrame extends JInternalFrame
+public class GSplitFrame extends JInternalFrame implements SplitContainerI
 {
   private static final long serialVersionUID = 1L;
 
@@ -106,9 +107,36 @@ public class GSplitFrame extends JInternalFrame
 
   private boolean isIn(Point loc, Component comp)
   {
+    if (!comp.isVisible())
+    {
+      return false;
+    }
     Point p = comp.getLocationOnScreen();
     Rectangle r = new Rectangle(p.x, p.y, comp.getWidth(), comp.getHeight());
     return r.contains(loc);
   }
 
+  /**
+   * Make the complement of the specified split component visible or hidden,
+   * adjusting the position of the split divide.
+   */
+  @Override
+  public void setComplementVisible(Object alignFrame, boolean show)
+  {
+    if (alignFrame == this.topFrame)
+    {
+      this.bottomFrame.setVisible(show);
+    }
+    else if (alignFrame == this.bottomFrame)
+    {
+      this.topFrame.setVisible(show);
+    }
+    if (show)
+    {
+      // SplitPane needs nudging to restore 50-50 split
+      splitPane.setDividerLocation(0.5d);
+    }
+    validate();
+  }
+
 }