X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FSplitFrame.java;h=5bff407860c8fc9bb1738639503bb6e9c5da4d30;hb=bd894ca9f2aae448653d7431ab8a170e1105e85c;hp=aa658ce2df592e2b588f65a0b477a1bac57e325d;hpb=c59d5663482450a2eb646e64b33b1967fa749ce3;p=jalview.git
diff --git a/src/jalview/gui/SplitFrame.java b/src/jalview/gui/SplitFrame.java
index aa658ce..5bff407 100644
--- a/src/jalview/gui/SplitFrame.java
+++ b/src/jalview/gui/SplitFrame.java
@@ -1,11 +1,31 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see
+ * Once laid out, the user may choose to customise as they wish, so this
+ * method is not called again after the initial layout.
+ */
+ protected void adjustInitialLayout()
+ {
+ AlignFrame topFrame = (AlignFrame) getTopFrame();
+ AlignFrame bottomFrame = (AlignFrame) getBottomFrame();
+
+ /*
+ * recompute layout of top and bottom panels to reflect their
+ * actual (rather than requested) height
+ */
+ topFrame.alignPanel.adjustAnnotationHeight();
+ bottomFrame.alignPanel.adjustAnnotationHeight();
+
+ final AlignViewport topViewport = topFrame.viewport;
+ final AlignViewport bottomViewport = bottomFrame.viewport;
+ final AlignmentI topAlignment = topViewport.getAlignment();
+ final AlignmentI bottomAlignment = bottomViewport.getAlignment();
+ boolean topAnnotations = topViewport.isShowAnnotation();
+ boolean bottomAnnotations = bottomViewport.isShowAnnotation();
+ // TODO need number of visible sequences here, not #sequences - how?
+ int topCount = topAlignment.getHeight();
+ int bottomCount = bottomAlignment.getHeight();
+ int topCharHeight = topViewport.getViewStyle().getCharHeight();
+ int bottomCharHeight = bottomViewport.getViewStyle().getCharHeight();
+
+ /*
+ * calculate the minimum ratio that leaves at least the height
+ * of two sequences (after rounding) visible in the top panel
+ */
+ int topPanelHeight = topFrame.getHeight();
+ int bottomPanelHeight = bottomFrame.getHeight();
+ int topSequencesHeight = topFrame.alignPanel.getSeqPanel().seqCanvas
+ .getHeight();
+ int topPanelMinHeight = topPanelHeight
+ - Math.max(0, topSequencesHeight - 3 * topCharHeight);
+ double totalHeight = (double) topPanelHeight + bottomPanelHeight;
+ double minRatio = topPanelMinHeight / totalHeight;
+
+ /*
+ * calculate the maximum ratio that leaves at least the height
+ * of two sequences (after rounding) visible in the bottom panel
+ */
+ int bottomSequencesHeight = bottomFrame.alignPanel.getSeqPanel().seqCanvas
+ .getHeight();
+ int bottomPanelMinHeight = bottomPanelHeight
+ - Math.max(0, bottomSequencesHeight - 3 * bottomCharHeight);
+ double maxRatio = (totalHeight - bottomPanelMinHeight) / totalHeight;
+
+ /*
+ * estimate ratio of (topFrameContent / bottomFrameContent)
+ */
+ int insets = Platform.isAMac() ? MAC_INSETS_HEIGHT
+ : WINDOWS_INSETS_HEIGHT;
+ // allow 3 'rows' for scale, scrollbar, status bar
+ int topHeight = insets + (3 + topCount) * topCharHeight
+ + (topAnnotations ? topViewport.calcPanelHeight() : 0);
+ int bottomHeight = insets + (3 + bottomCount) * bottomCharHeight
+ + (bottomAnnotations ? bottomViewport.calcPanelHeight() : 0);
+ double ratio = ((double) topHeight)
+ / (double) (topHeight + bottomHeight);
+
+ /*
+ * limit ratio to avoid concealing all sequences
+ */
+ ratio = Math.min(ratio, maxRatio);
+ ratio = Math.max(ratio, minRatio);
+ setRelativeDividerLocation(ratio);
+ }
+
+ /**
* Add a listener to tidy up when the frame is closed.
*/
protected void addCloseFrameListener()
@@ -155,7 +292,8 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI
*/
protected void addKeyListener()
{
- addKeyListener(new KeyAdapter() {
+ addKeyListener(new KeyAdapter()
+ {
@Override
public void keyPressed(KeyEvent e)
@@ -189,7 +327,7 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI
}
}
}
-
+
});
}
@@ -235,6 +373,7 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI
actioned = true;
e.consume();
}
+ break;
default:
}
return actioned;
@@ -272,8 +411,8 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI
/*
* Ctrl-W / Cmd-W - close view or window
*/
- KeyStroke key_cmdW = KeyStroke.getKeyStroke(KeyEvent.VK_W, Toolkit
- .getDefaultToolkit().getMenuShortcutKeyMask(), false);
+ KeyStroke key_cmdW = KeyStroke.getKeyStroke(KeyEvent.VK_W,
+ Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false);
action = new AbstractAction()
{
@Override
@@ -293,8 +432,8 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI
/*
* Ctrl-T / Cmd-T open new view
*/
- KeyStroke key_cmdT = KeyStroke.getKeyStroke(KeyEvent.VK_T, Toolkit
- .getDefaultToolkit().getMenuShortcutKeyMask(), false);
+ KeyStroke key_cmdT = KeyStroke.getKeyStroke(KeyEvent.VK_T,
+ Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false);
AbstractAction action = new AbstractAction()
{
@Override
@@ -347,8 +486,8 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI
Component c = getFrameAtMouse();
if (c != null && c instanceof AlignFrame)
{
- for (ActionListener a : ((AlignFrame) c).getAccelerators()
- .get(ks).getActionListeners())
+ for (ActionListener a : ((AlignFrame) c).getAccelerators().get(ks)
+ .getActionListeners())
{
a.actionPerformed(null);
}
@@ -611,6 +750,19 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI
}
/**
+ * return the AlignFrames held by this container
+ *
+ * @return { Top alignFrame (Usually CDS), Bottom AlignFrame (Usually
+ * Protein)}
+ */
+ public List