From: gmungoc Date: Fri, 2 Oct 2015 15:18:07 +0000 (+0100) Subject: JAL-1815 restore split frame geometry including horizontal scroll X-Git-Tag: Release_2_10_0~375^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c8ae8ef3f6365ea5664930f3139fa4871eb188c2;p=jalview.git JAL-1815 restore split frame geometry including horizontal scroll correctly --- diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index a857f11..92c6355 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -1072,7 +1072,7 @@ public class AlignViewport extends AlignmentViewport implements // TODO would like next line without cast but needs more refactoring... final AlignmentPanel complementPanel = ((AlignViewport) getCodingComplement()) .getAlignPanel(); - complementPanel.setFollowingComplementScroll(true); + complementPanel.setDontScrollComplement(true); complementPanel.scrollToCentre(sr, verticalOffset); } } diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 2c7dd3e..4d49bc2 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -99,7 +99,7 @@ public class AlignmentPanel extends GAlignmentPanel implements * Flag set while scrolling to follow complementary cDNA/protein scroll. When * true, suppresses invoking the same method recursively. */ - private boolean followingComplementScroll; + private boolean dontScrollComplement; /** * Creates a new AlignmentPanel object. @@ -732,7 +732,14 @@ public class AlignmentPanel extends GAlignmentPanel implements x = 0; } + /* + * each scroll adjustment triggers adjustmentValueChanged, which resets the + * 'do not scroll complement' flag; ensure it is the same for both + * operations + */ + boolean flag = isDontScrollComplement(); hscroll.setValues(x, hextent, 0, width); + setDontScrollComplement(flag); vscroll.setValues(y, vextent, 0, height); } @@ -831,9 +838,9 @@ public class AlignmentPanel extends GAlignmentPanel implements * If there is one, scroll the (Protein/cDNA) complementary alignment to * match, unless we are ourselves doing that. */ - if (isFollowingComplementScroll()) + if (isDontScrollComplement()) { - setFollowingComplementScroll(false); + setDontScrollComplement(false); } else { @@ -880,6 +887,12 @@ public class AlignmentPanel extends GAlignmentPanel implements hscrollFillerPanel.setPreferredSize(new Dimension(d.width, 12)); validate(); + /* + * set scroll bar positions; first suppress this being 'followed' in any + * complementary split pane + */ + setDontScrollComplement(true); + if (av.getWrapAlignment()) { int maxwidth = av.getAlignment().getWidth(); @@ -1789,17 +1802,17 @@ public class AlignmentPanel extends GAlignmentPanel implements } /** - * Set a flag to say we are scrolling to follow a (cDNA/protein) complement. + * Set a flag to say do not scroll any (cDNA/protein) complement. * * @param b */ - protected void setFollowingComplementScroll(boolean b) + protected void setDontScrollComplement(boolean b) { - this.followingComplementScroll = b; + this.dontScrollComplement = b; } - protected boolean isFollowingComplementScroll() + protected boolean isDontScrollComplement() { - return this.followingComplementScroll; + return this.dontScrollComplement; } } diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 3f92334..c957444 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -2976,25 +2976,39 @@ public class Desktop extends jalview.jbgui.GDesktop implements * AlignmentPanel objects, including their AlignmentViewports, so the * cdna/protein relationships between the viewports is carried over to the * new split frames. + * + * explodedGeometry holds the (x, y) position of the previously exploded + * SplitFrame, and the (width, height) of the AlignFrame component */ AlignmentPanel topPanel = (AlignmentPanel) topPanels.get(i); AlignFrame newTopFrame = new AlignFrame(topPanel); newTopFrame.setSize(oldTopFrame.getSize()); newTopFrame.setVisible(true); + Rectangle geometry = ((AlignViewport) topPanel.getAlignViewport()) + .getExplodedGeometry(); + if (geometry != null) + { + newTopFrame.setSize(geometry.getSize()); + } + AlignmentPanel bottomPanel = (AlignmentPanel) bottomPanels.get(i); AlignFrame newBottomFrame = new AlignFrame(bottomPanel); newBottomFrame.setSize(oldBottomFrame.getSize()); newBottomFrame.setVisible(true); + geometry = ((AlignViewport) bottomPanel.getAlignViewport()) + .getExplodedGeometry(); + if (geometry != null) + { + newBottomFrame.setSize(geometry.getSize()); + } + topPanel.av.setGatherViewsHere(false); bottomPanel.av.setGatherViewsHere(false); JInternalFrame splitFrame = new SplitFrame(newTopFrame, newBottomFrame); - // either panel may hold previous exploded frame geometry - Rectangle geometry = ((AlignViewport) topPanel.getAlignViewport()) - .getExplodedGeometry(); if (geometry != null) { - splitFrame.setBounds(geometry); + splitFrame.setLocation(geometry.getLocation()); } Desktop.addInternalFrame(splitFrame, sf.getTitle(), -1, -1); } @@ -3017,10 +3031,18 @@ public class Desktop extends jalview.jbgui.GDesktop implements */ public void gatherViews(GSplitFrame source) { + /* + * special handling of explodedGeometry for a view within a SplitFrame: - it + * holds the (x, y) position of the enclosing SplitFrame, and the (width, + * height) of the AlignFrame component + */ AlignFrame myTopFrame = (AlignFrame) source.getTopFrame(); AlignFrame myBottomFrame = (AlignFrame) source.getBottomFrame(); - myTopFrame.viewport.setExplodedGeometry(source.getBounds()); - myBottomFrame.viewport.setExplodedGeometry(source.getBounds()); + myTopFrame.viewport.setExplodedGeometry(new Rectangle(source.getX(), + source.getY(), myTopFrame.getWidth(), myTopFrame.getHeight())); + myBottomFrame.viewport.setExplodedGeometry(new Rectangle(source.getX(), + source.getY(), myBottomFrame.getWidth(), myBottomFrame + .getHeight())); myTopFrame.viewport.setGatherViewsHere(true); myBottomFrame.viewport.setGatherViewsHere(true); String topViewId = myTopFrame.viewport.getSequenceSetId(); @@ -3045,10 +3067,10 @@ public class Desktop extends jalview.jbgui.GDesktop implements gatherThis = true; topPanel.av.setGatherViewsHere(false); bottomPanel.av.setGatherViewsHere(false); - // both panels refer to the same split frame geometry - Rectangle position = sf.getBounds(); - topPanel.av.setExplodedGeometry(position); - bottomPanel.av.setExplodedGeometry(position); + topPanel.av.setExplodedGeometry(new Rectangle(sf.getLocation(), + topFrame.getSize())); + bottomPanel.av.setExplodedGeometry(new Rectangle(sf + .getLocation(), bottomFrame.getSize())); myTopFrame.addAlignmentPanel(topPanel, false); myBottomFrame.addAlignmentPanel(bottomPanel, false); } diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 4ee87fc..fe05e6e 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -680,7 +680,7 @@ public class SeqPanel extends JPanel implements MouseListener, * * @see AlignmentPanel#adjustmentValueChanged */ - ap.setFollowingComplementScroll(true); + ap.setDontScrollComplement(true); if (ap.scrollToPosition(results, false)) { seqCanvas.revalidate(); diff --git a/src/jalview/gui/SplitFrame.java b/src/jalview/gui/SplitFrame.java index 9da8240..3a6d266 100644 --- a/src/jalview/gui/SplitFrame.java +++ b/src/jalview/gui/SplitFrame.java @@ -26,6 +26,7 @@ import jalview.datamodel.AlignmentI; import jalview.jbgui.GAlignFrame; import jalview.jbgui.GSplitFrame; import jalview.structure.StructureSelectionManager; +import jalview.util.Platform; import jalview.viewmodel.AlignmentViewport; import java.awt.Component; @@ -37,12 +38,15 @@ import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.beans.PropertyVetoException; import java.util.Map.Entry; +import java.util.Set; import javax.swing.AbstractAction; import javax.swing.InputMap; import javax.swing.JComponent; import javax.swing.JMenuItem; import javax.swing.KeyStroke; +import javax.swing.UIDefaults; +import javax.swing.UIManager; import javax.swing.event.InternalFrameAdapter; import javax.swing.event.InternalFrameEvent; @@ -81,10 +85,23 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI ((AlignFrame) getTopFrame()).getViewport().setCodingComplement( ((AlignFrame) getBottomFrame()).getViewport()); - int width = ((AlignFrame) getTopFrame()).getWidth(); - // about 50 pixels for the SplitFrame's title bar etc + /* + * estimate width and height of SplitFrame; this.getInsets() doesn't seem to + * give the full additional size (a few pixels short) + */ + UIDefaults defaults = UIManager.getDefaults(); + Set keySet = defaults.keySet(); + for (Object key : keySet) + { + System.out.println(key.toString() + " = " + + UIManager.get(key).toString()); + } + int widthFudge = Platform.isAMac() ? 28 : 28; // Windows tbc + int heightFudge = Platform.isAMac() ? 50 : 50; // tbc + int width = ((AlignFrame) getTopFrame()).getWidth() + widthFudge; int height = ((AlignFrame) getTopFrame()).getHeight() - + ((AlignFrame) getBottomFrame()).getHeight() + 50; + + ((AlignFrame) getBottomFrame()).getHeight() + DIVIDER_SIZE + + heightFudge; height = fitHeightToDesktop(height); setSize(width, height); diff --git a/src/jalview/jbgui/GSplitFrame.java b/src/jalview/jbgui/GSplitFrame.java index daad4fd..7c4dcf3 100644 --- a/src/jalview/jbgui/GSplitFrame.java +++ b/src/jalview/jbgui/GSplitFrame.java @@ -33,7 +33,7 @@ import javax.swing.plaf.basic.BasicInternalFrameUI; public class GSplitFrame extends JInternalFrame { - private static final int DIVIDER_SIZE = 5; + protected static final int DIVIDER_SIZE = 5; private static final long serialVersionUID = 1L;