+
+ @Override
+ protected void snapShotWindow_actionPerformed(ActionEvent e)
+ {
+ invalidate();
+ File of;
+ ImageMaker im = new jalview.util.ImageMaker(this, ImageMaker.TYPE.EPS,
+ "View of Desktop", getWidth(), getHeight(), of = new File(
+ "Jalview_snapshot" + System.currentTimeMillis()
+ + ".eps"), "View of desktop");
+ try
+ {
+ paintAll(im.getGraphics());
+ im.writeImage();
+ } catch (Exception q)
+ {
+ Cache.log.error("Couldn't write snapshot to " + of.getAbsolutePath(),
+ q);
+ return;
+ }
+ Cache.log.info("Successfully written snapshot to file "
+ + of.getAbsolutePath());
+ }
+
+ /**
+ * Explode the views in the given frame into separate AlignFrame windows.
+ *
+ * @param sf
+ */
+ public void explodeViews(SplitFrame sf)
+ {
+ AlignFrame oldTopFrame = (AlignFrame) sf.getTopFrame();
+ AlignFrame oldBottomFrame = (AlignFrame) sf.getBottomFrame();
+ List<? extends AlignmentViewPanel> topPanels = oldTopFrame
+ .getAlignPanels();
+ List<? extends AlignmentViewPanel> bottomPanels = oldBottomFrame
+ .getAlignPanels();
+ int viewCount = topPanels.size();
+ if (viewCount < 2)
+ {
+ return;
+ }
+
+ /*
+ * Processing in reverse order works, forwards order leaves the first panels
+ * not visible. I don't know why!
+ */
+ for (int i = viewCount - 1; i >= 0; i--)
+ {
+ /*
+ * Make new top and bottom frames. These take over the respective
+ * AlignmentPanel objects, including their AlignmentViewports, so the
+ * cdna/protein relationships between the viewports is carried over to the
+ * new split frames.
+ */
+ AlignmentPanel topPanel = (AlignmentPanel) topPanels.get(i);
+ AlignFrame newTopFrame = new AlignFrame(topPanel);
+ newTopFrame.setSize(new Dimension(AlignFrame.DEFAULT_WIDTH,
+ AlignFrame.DEFAULT_HEIGHT));
+ newTopFrame.setVisible(true);
+ AlignmentPanel bottomPanel = (AlignmentPanel) bottomPanels.get(i);
+ AlignFrame newBottomFrame = new AlignFrame(bottomPanel);
+ newBottomFrame.setSize(new Dimension(AlignFrame.DEFAULT_WIDTH,
+ AlignFrame.DEFAULT_HEIGHT));
+ newBottomFrame.setVisible(true);
+ 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);
+ }
+ Desktop.addInternalFrame(splitFrame, sf.getTitle(), -1, -1);
+ }
+
+ /*
+ * Clear references to the panels (now relocated in the new SplitFrames)
+ * before closing the old SplitFrame.
+ */
+ topPanels.clear();
+ bottomPanels.clear();
+ sf.close();
+ }
+
+ /**
+ * Gather expanded split frames, sharing the same pairs of sequence set ids,
+ * back into the given SplitFrame as additional views. Note that the gathered
+ * frames may themselves have multiple views.
+ *
+ * @param source
+ */
+ public void gatherViews(GSplitFrame source)
+ {
+ AlignFrame myTopFrame = (AlignFrame) source.getTopFrame();
+ AlignFrame myBottomFrame = (AlignFrame) source.getBottomFrame();
+ myTopFrame.viewport.setExplodedGeometry(source.getBounds());
+ myBottomFrame.viewport.setExplodedGeometry(source.getBounds());
+ myTopFrame.viewport.setGatherViewsHere(true);
+ myBottomFrame.viewport.setGatherViewsHere(true);
+ String topViewId = myTopFrame.viewport.getSequenceSetId();
+ String bottomViewId = myBottomFrame.viewport.getSequenceSetId();
+
+ JInternalFrame[] frames = desktop.getAllFrames();
+ for (JInternalFrame frame : frames)
+ {
+ if (frame instanceof SplitFrame && frame != source)
+ {
+ SplitFrame sf = (SplitFrame) frame;
+ AlignFrame topFrame = (AlignFrame) sf.getTopFrame();
+ AlignFrame bottomFrame = (AlignFrame) sf.getBottomFrame();
+ boolean gatherThis = false;
+ for (int a = 0; a < topFrame.alignPanels.size(); a++)
+ {
+ AlignmentPanel topPanel = topFrame.alignPanels.get(a);
+ AlignmentPanel bottomPanel = bottomFrame.alignPanels.get(a);
+ if (topViewId.equals(topPanel.av.getSequenceSetId())
+ && bottomViewId.equals(bottomPanel.av.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);
+ myTopFrame.addAlignmentPanel(topPanel, false);
+ myBottomFrame.addAlignmentPanel(bottomPanel, false);
+ }
+ }
+
+ if (gatherThis)
+ {
+ topFrame.getAlignPanels().clear();
+ bottomFrame.getAlignPanels().clear();
+ sf.close();
+ }
+ }
+ }
+
+ /*
+ * The dust settles...give focus to the tab we did this from.
+ */
+ myTopFrame.setDisplayedView(myTopFrame.alignPanel);
+
+ }
+
+ public static AlignFrame getCurrentAlignFrame()
+ {
+ return currentAlignFrame;
+ }
+
+ public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)
+ {
+ Desktop.currentAlignFrame = currentAlignFrame;
+ }
+
+