X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignViewport.java;h=e4593a305d4c981edae71967a0a8d2cf25ea1326;hb=466c5639624028f92e214121672dc409ad10514b;hp=4ba2113bc6d50fee66a4acc550752b5f2399d887;hpb=c94c1390298db2e80abc04b371d3e7767f5e5968;p=jalview.git diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 4ba2113..e4593a3 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) - * Copyright (C) 2014 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * @@ -38,14 +38,26 @@ */ package jalview.gui; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.Set; +import java.util.Vector; + +import javax.swing.JInternalFrame; +import javax.swing.JOptionPane; + import jalview.analysis.AlignmentUtils; -import jalview.analysis.AlignmentUtils.MappingResult; import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; import jalview.analysis.NJTree; 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; @@ -63,18 +75,6 @@ import jalview.util.MessageManager; import jalview.viewmodel.AlignmentViewport; import jalview.ws.params.AutoCalcSetting; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.Set; -import java.util.Vector; - -import javax.swing.JInternalFrame; -import javax.swing.JOptionPane; - /** * DOCUMENT ME! * @@ -92,9 +92,6 @@ public class AlignViewport extends AlignmentViewport implements int endSeq; - - SequenceAnnotationOrder sortAnnotationsBy = null; - Font font; NJTree currentTree = null; @@ -300,10 +297,18 @@ public class AlignViewport extends AlignmentViewport implements showConsensus = Cache.getDefault("SHOW_IDENTITY", true); } initAutoAnnotation(); - if (jalview.bin.Cache.getProperty("DEFAULT_COLOUR") != null) + String colourProperty = alignment.isNucleotide() ? Preferences.DEFAULT_COLOUR_NUC + : Preferences.DEFAULT_COLOUR_PROT; + String propertyValue = Cache.getProperty(colourProperty); + if (propertyValue == null) + { + // fall back on this property for backwards compatibility + propertyValue = Cache.getProperty(Preferences.DEFAULT_COLOUR); + } + if (propertyValue != null) { globalColourScheme = ColourSchemeProperty.getColour(alignment, - jalview.bin.Cache.getProperty("DEFAULT_COLOUR")); + propertyValue); if (globalColourScheme instanceof UserColourScheme) { @@ -833,8 +838,6 @@ public class AlignViewport extends AlignmentViewport implements private Hashtable calcIdParams = new Hashtable(); - private boolean showAutocalculatedAbove; - public AutoCalcSetting getCalcIdSettingsFor(String calcId) { return calcIdParams.get(calcId); @@ -853,26 +856,6 @@ public class AlignViewport extends AlignmentViewport implements } } - protected SequenceAnnotationOrder getSortAnnotationsBy() - { - return sortAnnotationsBy; - } - - protected void setSortAnnotationsBy(SequenceAnnotationOrder sortAnnotationsBy) - { - this.sortAnnotationsBy = sortAnnotationsBy; - } - - protected boolean isShowAutocalculatedAbove() - { - return showAutocalculatedAbove; - } - - protected void setShowAutocalculatedAbove(boolean showAutocalculatedAbove) - { - this.showAutocalculatedAbove = showAutocalculatedAbove; - } - /** * Method called when another alignment's edit (or possibly other) command is * broadcast to here. @@ -942,17 +925,11 @@ public class AlignViewport extends AlignmentViewport implements * If one alignment is protein and one nucleotide, with at least one * sequence name in common, offer to open a linked alignment. */ - if (getAlignment().isNucleotide() != al.isNucleotide()) + if (AlignmentUtils.isMappable(al, getAlignment())) { - // TODO: JAL-845 try a bit harder to link up imported sequences - final Set sequenceNames = getAlignment().getSequenceNames(); - sequenceNames.retainAll(al.getSequenceNames()); - if (!sequenceNames.isEmpty()) // at least one sequence name in both + if (openLinkedAlignment(al, title)) { - if (openLinkedAlignment(al, title)) - { - return; - } + return; } } // TODO: JAL-407 regardless of above - identical sequences (based on ID and @@ -1033,21 +1010,11 @@ public class AlignViewport extends AlignmentViewport implements } /* - * Try to find mappings for at least one sequence. Any mappings made will be - * added to the protein alignment. + * 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 + * protein alignment. */ - MappingResult mapped = AlignmentUtils.mapProteinToCdna(protein, cdna); - if (mapped != MappingResult.Mapped) - { - /* - * No mapping possible - warn the user, but leave window open. - */ - final String msg = JvSwingUtils.wrapTooltip(true, - MessageManager.getString("label.mapping_failed")); - JOptionPane.showInternalMessageDialog(Desktop.desktop, msg, - MessageManager.getString("label.no_mappings"), - JOptionPane.WARNING_MESSAGE); - } + AlignmentUtils.mapProteinToCdna(protein, cdna); try { @@ -1060,7 +1027,8 @@ public class AlignViewport extends AlignmentViewport implements if (openSplitPane) { - protein = openSplitFrame(newAlignFrame, thisAlignment); + protein = openSplitFrame(newAlignFrame, thisAlignment, + protein.getCodonFrames()); } /* @@ -1080,18 +1048,18 @@ public class AlignViewport extends AlignmentViewport implements * * @param newAlignFrame * containing a new alignment to be shown - * @param existingAlignment - * an existing alignment to be copied for display in the split frame + * @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 existingAlignment) + AlignmentI complement, Set mappings) { - // TODO: move this to a factory/controller method ? /* * Open in split pane. DNA sequence above, protein below. */ - AlignFrame copyMe = new AlignFrame(existingAlignment, + AlignFrame copyMe = new AlignFrame(complement, AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); copyMe.setTitle(getAlignPanel().alignFrame.getTitle()); @@ -1101,6 +1069,7 @@ public class AlignViewport extends AlignmentViewport implements final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame : copyMe; AlignmentI protein = proteinFrame.viewport.getAlignment(); + protein.setCodonFrames(mappings); cdnaFrame.setVisible(true); proteinFrame.setVisible(true); @@ -1109,20 +1078,6 @@ public class AlignViewport extends AlignmentViewport implements JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame); Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1); - /* - * Set the frames to listen for each other's edit and sort commands. - */ - final StructureSelectionManager ssm = StructureSelectionManager - .getStructureSelectionManager(Desktop.instance); - ssm.addCommandListener(cdnaFrame.getViewport()); - ssm.addCommandListener(proteinFrame.getViewport()); - - /* - * 'Coding complement' (dna/protein) views will mirror each others' edits, - * selections, sorting etc as decided from time to time by the relevant - * authorities. - */ - proteinFrame.getViewport().setCodingComplement(cdnaFrame.getViewport()); return protein; }