JAL-1466 new calculation menu option to recover the full width sequences either side...
[jalview.git] / src / jalview / gui / AlignFrame.java
index a305479..f7e95b7 100644 (file)
@@ -20,6 +20,7 @@ package jalview.gui;
 
 import jalview.analysis.AAFrequency;
 import jalview.analysis.AlignmentSorter;
+import jalview.analysis.AlignmentUtils;
 import jalview.analysis.Conservation;
 import jalview.analysis.CrossRef;
 import jalview.analysis.NJTree;
@@ -2061,7 +2062,59 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     }
 
   }
+  @Override
+  protected void expand_newalign(ActionEvent e)
+  {
+    try {
+    AlignmentI alignment = AlignmentUtils.expandContext(getViewport().getAlignment(), -1);
+    AlignFrame af = new AlignFrame(alignment, DEFAULT_WIDTH,
+            DEFAULT_HEIGHT);
+    String newtitle = new String("Flanking alignment");
+
+    if (Desktop.jalviewClipboard != null
+            && Desktop.jalviewClipboard[2] != null)
+    {
+      Vector hc = (Vector) Desktop.jalviewClipboard[2];
+      for (int i = 0; i < hc.size(); i++)
+      {
+        int[] region = (int[]) hc.elementAt(i);
+        af.viewport.hideColumns(region[0], region[1]);
+      }
+    }
+
+    // >>>This is a fix for the moment, until a better solution is
+    // found!!<<<
+    af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer()
+            .transferSettings(
+                    alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
+
+    // TODO: maintain provenance of an alignment, rather than just make the
+    // title a concatenation of operations.
+    {
+      if (title.startsWith("Copied sequences"))
+      {
+        newtitle = title;
+      }
+      else
+      {
+        newtitle = newtitle.concat("- from " + title);
+      }
+    }
+
+    Desktop.addInternalFrame(af, newtitle, DEFAULT_WIDTH,
+            DEFAULT_HEIGHT);
 
+    } catch (Exception ex)
+    {
+      ex.printStackTrace();
+      System.out.println("Exception whilst pasting: " + ex);
+      // could be anything being pasted in here
+    }
+    catch (OutOfMemoryError oom)
+    {
+      new OOMWarning("Viewing flanking region of alignment", oom);
+    }
+  }
   /**
    * DOCUMENT ME!
    *