// 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);
}
}
* 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.
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);
}
* 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
{
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();
}
/**
- * 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;
}
}
* 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);
}
*/
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();
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);
}
*
* @see AlignmentPanel#adjustmentValueChanged
*/
- ap.setFollowingComplementScroll(true);
+ ap.setDontScrollComplement(true);
if (ap.scrollToPosition(results, false))
{
seqCanvas.revalidate();
import jalview.jbgui.GAlignFrame;
import jalview.jbgui.GSplitFrame;
import jalview.structure.StructureSelectionManager;
+import jalview.util.Platform;
import jalview.viewmodel.AlignmentViewport;
import java.awt.Component;
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;
((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<Object> 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);
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;