*/
package jalview.gui;
+import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
import jalview.bin.Cache;
import jalview.io.FileLoader;
import jalview.io.IdentifyFile;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
+import jalview.jbgui.GSplitFrame;
import jalview.jbgui.GStructureViewer;
import jalview.structure.StructureSelectionManager;
import jalview.util.ImageMaker;
/**
*
* @param alignmentId
+ * - if null, all sets are returned
* @return all AlignmentPanels concerning the alignmentId sequence set
*/
public static AlignmentPanel[] getAlignmentPanels(String alignmentId)
{
for (AlignmentPanel ap : af.alignPanels)
{
- if (alignmentId.equals(ap.av.getSequenceSetId()))
+ if (alignmentId==null || alignmentId.equals(ap.av.getSequenceSetId()))
{
aps.add(ap);
}
}
- // for (int a = 0; a < af.alignPanels.size(); a++)
- // {
- // if (alignmentId.equals(af.alignPanels
- // .get(a).av.getSequenceSetId()))
- // {
- // aps.add(af.alignPanels.get(a));
- // }
- // }
}
if (aps.size() == 0)
{
* get all the viewports on an alignment.
*
* @param sequenceSetId
- * unique alignment id
+ * unique alignment id (may be null - all viewports returned in that
+ * case)
* @return all viewports on the alignment bound to sequenceSetId
*/
public static AlignmentViewport[] getViewports(String sequenceSetId)
for (AlignFrame afr : frames)
{
- if (afr.getViewport().getSequenceSetId().equals(sequenceSetId))
+ if (sequenceSetId==null || afr.getViewport().getSequenceSetId().equals(sequenceSetId))
{
if (afr.alignPanels != null)
{
for (AlignmentPanel ap : afr.alignPanels)
{
- if (sequenceSetId.equals(ap.av.getSequenceSetId()))
+ if (sequenceSetId == null
+ || sequenceSetId.equals(ap.av.getSequenceSetId()))
{
viewp.add(ap.av);
}
{
AlignmentPanel ap = af.alignPanels.get(i);
AlignFrame newaf = new AlignFrame(ap);
- if (ap.av.explodedPosition != null
- && !ap.av.explodedPosition.equals(af.getBounds()))
+
+ /*
+ * Restore the view's last exploded frame geometry if known. Multiple
+ * views from one exploded frame share and restore the same (frame)
+ * position and size.
+ */
+ Rectangle geometry = ap.av.getExplodedGeometry();
+ if (geometry != null)
{
- newaf.setBounds(ap.av.explodedPosition);
+ newaf.setBounds(geometry);
}
- ap.av.gatherViewsHere = false;
+ ap.av.setGatherViewsHere(false);
addInternalFrame(newaf, af.getTitle(), AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
*/
public void gatherViews(AlignFrame source)
{
- source.viewport.gatherViewsHere = true;
- source.viewport.explodedPosition = source.getBounds();
+ source.viewport.setGatherViewsHere(true);
+ source.viewport.setExplodedGeometry(source.getBounds());
JInternalFrame[] frames = desktop.getAllFrames();
String viewId = source.viewport.getSequenceSetId();
if (viewId.equals(ap.av.getSequenceSetId()))
{
gatherThis = true;
- ap.av.gatherViewsHere = false;
- ap.av.explodedPosition = af.getBounds();
+ ap.av.setGatherViewsHere(false);
+ ap.av.setExplodedGeometry(af.getBounds());
source.addAlignmentPanel(ap, false);
}
}
/*
* Also check for a split frame containing an AlignFrame
*/
- SplitFrame sf = (SplitFrame) frames[i];
+ GSplitFrame sf = (GSplitFrame) frames[i];
if (sf.getTopFrame() instanceof AlignFrame)
{
avp.add((AlignFrame) sf.getTopFrame());
}
/**
- * This will return the first AlignFrame viewing AlignViewport av. It will
- * break if there are more than one AlignFrames viewing a particular av.
+ * This will return the first AlignFrame holding the given viewport instance. It
+ * will break if there are more than one AlignFrames viewing a particular av.
*
- * @param av
- * @return alignFrame for av
+ * @param viewport
+ * @return alignFrame for viewport
*/
- public static AlignFrame getAlignFrameFor(AlignmentViewport av)
+ public static AlignFrame getAlignFrameFor(AlignViewportI viewport)
{
if (desktop != null)
{
- AlignmentPanel[] aps = getAlignmentPanels(av.getSequenceSetId());
+ AlignmentPanel[] aps = getAlignmentPanels(viewport
+ .getSequenceSetId());
for (int panel = 0; aps != null && panel < aps.length; panel++)
{
- if (aps[panel] != null && aps[panel].av == av)
+ if (aps[panel] != null && aps[panel].av == viewport)
{
return aps[panel].alignFrame;
}
}
/**
- * Explode the views in the given frame into separate AlignFrame
+ * Explode the views in the given frame into separate AlignFrame windows.
*
* @param sf
*/
* cdna/protein relationships between the viewports is carried over to the
* new split frames.
*/
- AlignFrame newTopFrame = new AlignFrame(
- (AlignmentPanel) topPanels.get(i));
+ AlignmentPanel topPanel = (AlignmentPanel) topPanels.get(i);
+ AlignFrame newTopFrame = new AlignFrame(topPanel);
newTopFrame.setVisible(true);
- AlignFrame newBottomFrame = new AlignFrame(
- (AlignmentPanel) bottomPanels.get(i));
+ AlignmentPanel bottomPanel = (AlignmentPanel) bottomPanels.get(i);
+ AlignFrame newBottomFrame = new AlignFrame(bottomPanel);
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);
-
- // if (ap.av.explodedPosition != null
- // && !ap.av.explodedPosition.equals(af.getBounds()))
- // {
- // newaf.setBounds(ap.av.explodedPosition);
- // }
- //
- // ap.av.gatherViewsHere = false;
}
/*
*
* @param source
*/
- public void gatherViews(SplitFrame source)
+ public void gatherViews(GSplitFrame source)
{
- // source.viewport.gatherViewsHere = true;
- // source.viewport.explodedPosition = source.getBounds();
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();
&& bottomViewId.equals(bottomPanel.av.getSequenceSetId()))
{
gatherThis = true;
- topPanel.av.gatherViewsHere = false;
- bottomPanel.av.gatherViewsHere = false;
- // topPanel.av.explodedPosition = af.getBounds();
+ 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);
}