X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignViewport.java;h=184944775754cbf8d3cdf53d0de187c00ec02c1e;hb=564c47bdd60cf84046269e45d2f85f39408e4441;hp=140f77e2da23cede327038af2b8e092200808370;hpb=b93f8af382bb2fbdb0c974558bcef57750d1bdd6;p=jalview.git diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 140f77e..1849447 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -73,6 +73,14 @@ import javax.swing.JInternalFrame; public class AlignViewport extends AlignmentViewport implements SelectionSource { + + public final static int NO_SPLIT = 0; + + public final static int SPLIT_FRAME = 1; + + public final static int NEW_WINDOW = 2; + + Font font; boolean cursorMode = false; @@ -162,7 +170,7 @@ public class AlignViewport extends AlignmentViewport * @param hiddenColumns * @param seqsetid * (may be null) - */ +f */ public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns, String seqsetid) { @@ -773,47 +781,54 @@ public class AlignViewport extends AlignmentViewport * in reverse order) */ JvOptionPane dialog = JvOptionPane.newOptionDialog(Desktop.desktop) - .setResponseHandler(0, new Runnable() + .setResponseHandler(NO_SPLIT, new Runnable() { @Override public void run() { addDataToAlignment(al); } - }).setResponseHandler(1, new Runnable() + }).setResponseHandler(SPLIT_FRAME, new Runnable() { @Override public void run() { - us.openLinkedAlignmentAs(al, title, true); + openLinkedAlignmentAs(getAlignPanel().alignFrame, + new Alignment(getAlignment()), al, title, + SPLIT_FRAME); +// us.openLinkedAlignmentAs(al, title, true); } - }).setResponseHandler(2, new Runnable() + }).setResponseHandler(NEW_WINDOW, new Runnable() { @Override public void run() { - us.openLinkedAlignmentAs(al, title, false); + openLinkedAlignmentAs(null, getAlignment(), al, title, + NEW_WINDOW); } }); - dialog.showDialog(question, + dialog.showDialog(question, MessageManager.getString("label.open_split_window"), JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null, options, options[0]); } - - protected void openLinkedAlignmentAs(AlignmentI al, String title, - boolean newWindowOrSplitPane) - { + /** + * Open a split frame or a new window + * + * @param al + * @param title + * @param mode + * SPLIT_FRAME or NEW_WINDOW + */ + public static void openLinkedAlignmentAs(AlignFrame thisFrame, + AlignmentI thisAlignment, AlignmentI al, String title, int mode) + { /* * Identify protein and dna alignments. Make a copy of this one if opening * in a new split pane. */ - AlignmentI thisAlignment = newWindowOrSplitPane - ? new Alignment(getAlignment()) - : getAlignment(); AlignmentI protein = al.isNucleotide() ? thisAlignment : al; - final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment; - + AlignmentI cdna = al.isNucleotide() ? al : thisAlignment; /* * Map sequences. At least one should get mapped as we have already passed * the test for 'mappability'. Any mappings made will be added to the @@ -841,7 +856,7 @@ public class AlignViewport extends AlignmentViewport // alignFrame.setFileName(file, format); // } - if (!newWindowOrSplitPane) + if (mode == NEW_WINDOW) { Desktop.addInternalFrame(newAlignFrame, title, AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); @@ -855,10 +870,10 @@ public class AlignViewport extends AlignmentViewport { } - if (newWindowOrSplitPane) + if (mode == SPLIT_FRAME) { al.alignAs(thisAlignment); - protein = openSplitFrame(newAlignFrame, thisAlignment); + openSplitFrame(thisFrame, newAlignFrame, thisAlignment); } } @@ -872,8 +887,8 @@ public class AlignViewport extends AlignmentViewport * cdna/protein complement alignment to show in the other split half * @return the protein alignment in the split frame */ - protected AlignmentI openSplitFrame(AlignFrame newAlignFrame, - AlignmentI complement) + static protected AlignmentI openSplitFrame(AlignFrame thisFrame, + AlignFrame newAlignFrame, AlignmentI complement) { /* * Make a new frame with a copy of the alignment we are adding to. If this @@ -882,7 +897,8 @@ public class AlignViewport extends AlignmentViewport */ AlignFrame copyMe = new AlignFrame(complement, AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); - copyMe.setTitle(getAlignPanel().alignFrame.getTitle()); + copyMe.setTitle(thisFrame.getTitle()); + AlignmentI al = newAlignFrame.viewport.getAlignment(); final AlignFrame proteinFrame = al.isNucleotide() ? copyMe