X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FDesktop.java;h=d3b8afc948f58c4a1f190e22c7a31525f3218618;hb=d616b0e1ac213a82591cece50ea25c5bfbfa865f;hp=3f923348bedf78f5b6e31cc2d018ee82a4cfd132;hpb=5e3ef593f6032b49eb41b962badf1ee36403184e;p=jalview.git diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 3f92334..d3b8afc 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -23,6 +23,7 @@ package jalview.gui; import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; import jalview.bin.Cache; +import jalview.bin.Jalview; import jalview.io.FileLoader; import jalview.io.FormatAdapter; import jalview.io.IdentifyFile; @@ -2381,6 +2382,12 @@ public class Desktop extends jalview.jbgui.GDesktop implements */ public static AlignFrame[] getAlignFrames() { + if (Jalview.isHeadlessMode()) + { + // Desktop.desktop is null in headless mode + return new AlignFrame[] { currentAlignFrame }; + } + JInternalFrame[] frames = Desktop.desktop.getAllFrames(); if (frames == null) @@ -2976,25 +2983,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 +3038,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 +3074,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); }