X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignViewport.java;h=aedfe12c0e7aac5e49f4fa4cf2ba72ffb4a6a9e7;hb=43d326c3a7616aedecfce6f7980b3831ec25243a;hp=9ed953f48863bae80e8a476157f8a5ff2a23c370;hpb=06e3a52df5af8243cdb67c023c8ddd834711ad36;p=jalview.git diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 9ed953f..aedfe12 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -45,7 +45,6 @@ import jalview.api.AlignViewportI; import jalview.api.ViewStyleI; import jalview.bin.Cache; import jalview.commands.CommandI; -import jalview.datamodel.AlignedCodonFrame; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; import jalview.datamodel.ColumnSelection; @@ -71,7 +70,6 @@ import java.awt.Rectangle; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; -import java.util.Set; import java.util.Vector; import javax.swing.JInternalFrame; @@ -416,16 +414,43 @@ public class AlignViewport extends AlignmentViewport implements */ public void setAlignment(AlignmentI align) { - if (alignment != null && alignment.getCodonFrames() != null) + replaceMappings(align); + this.alignment = align; + } + + /** + * Replace any codon mappings for this viewport with those for the given + * viewport + * + * @param align + */ + public void replaceMappings(AlignmentI align) + { + StructureSelectionManager ssm = StructureSelectionManager + .getStructureSelectionManager(Desktop.instance); + + /* + * Deregister current mappings (if any) + */ + if (alignment != null) { - StructureSelectionManager.getStructureSelectionManager( - Desktop.instance).removeMappings(alignment.getCodonFrames()); + ssm.removeMappings(alignment.getCodonFrames()); } - this.alignment = align; - if (alignment != null && alignment.getCodonFrames() != null) + + /* + * Register new mappings (if any) + */ + if (align != null) { - StructureSelectionManager.getStructureSelectionManager( - Desktop.instance).addMappings(alignment.getCodonFrames()); + ssm.addMappings(align.getCodonFrames()); + } + + /* + * replace mappings on our alignment + */ + if (alignment != null && align != null) + { + alignment.setCodonFrames(align.getCodonFrames()); } } @@ -884,9 +909,8 @@ public class AlignViewport extends AlignmentViewport implements AlignmentUtils.mapProteinToCdna(protein, cdna); /* - * Create the AlignFrame for the added alignment. Note this will include the - * cDNA consensus annotation if it is protein (because the alignment holds - * mappings to nucleotide) + * Create the AlignFrame for the added alignment. If it is protein, mappings + * are registered with StructureSelectionManager as a side-effect. */ AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); @@ -921,18 +945,9 @@ public class AlignViewport extends AlignmentViewport implements if (openSplitPane) { al.alignAs(thisAlignment); - protein = openSplitFrame(newAlignFrame, thisAlignment, - protein.getCodonFrames()); + protein = openSplitFrame(newAlignFrame, thisAlignment); } - /* - * Register the mappings (held on the protein alignment) with the - * StructureSelectionManager (for mouseover linking). - */ - final StructureSelectionManager ssm = StructureSelectionManager - .getStructureSelectionManager(Desktop.instance); - ssm.addMappings(protein.getCodonFrames()); - return true; } @@ -944,16 +959,14 @@ public class AlignViewport extends AlignmentViewport implements * containing a new alignment to be shown * @param complement * cdna/protein complement alignment to show in the other split half - * @param mappings * @return the protein alignment in the split frame */ protected AlignmentI openSplitFrame(AlignFrame newAlignFrame, - AlignmentI complement, Set mappings) + AlignmentI complement) { /* * Make a new frame with a copy of the alignment we are adding to. If this - * is protein, the new frame will have a cDNA consensus annotation row - * added. + * is protein, the mappings to cDNA will be registered with StructureSelectionManager as a side-effect. */ AlignFrame copyMe = new AlignFrame(complement, AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); @@ -964,9 +977,6 @@ public class AlignViewport extends AlignmentViewport implements : newAlignFrame; final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame : copyMe; - AlignmentI protein = proteinFrame.viewport.getAlignment(); - protein.setCodonFrames(mappings); - cdnaFrame.setVisible(true); proteinFrame.setVisible(true); String linkedTitle = MessageManager @@ -978,7 +988,7 @@ public class AlignViewport extends AlignmentViewport implements JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame); Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1); - return protein; + return proteinFrame.viewport.getAlignment(); } public AnnotationColumnChooser getAnnotationColumnSelectionState()