2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
22 * Jalview - A Sequence Alignment Editor and Viewer
23 * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
25 * This program is free software; you can redistribute it and/or
26 * modify it under the terms of the GNU General Public License
27 * as published by the Free Software Foundation; either version 2
28 * of the License, or (at your option) any later version.
30 * This program is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU General Public License for more details.
35 * You should have received a copy of the GNU General Public License
36 * along with this program; if not, write to the Free Software
37 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
41 import jalview.analysis.AlignmentUtils;
42 import jalview.analysis.AlignmentUtils.MappingResult;
43 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
44 import jalview.analysis.NJTree;
45 import jalview.api.AlignViewportI;
46 import jalview.api.ViewStyleI;
47 import jalview.bin.Cache;
48 import jalview.commands.CommandI;
49 import jalview.datamodel.Alignment;
50 import jalview.datamodel.AlignmentI;
51 import jalview.datamodel.ColumnSelection;
52 import jalview.datamodel.PDBEntry;
53 import jalview.datamodel.Sequence;
54 import jalview.datamodel.SequenceGroup;
55 import jalview.datamodel.SequenceI;
56 import jalview.schemes.ColourSchemeProperty;
57 import jalview.schemes.UserColourScheme;
58 import jalview.structure.CommandListener;
59 import jalview.structure.SelectionSource;
60 import jalview.structure.StructureSelectionManager;
61 import jalview.structure.VamsasSource;
62 import jalview.util.MessageManager;
63 import jalview.viewmodel.AlignmentViewport;
64 import jalview.ws.params.AutoCalcSetting;
66 import java.awt.Container;
67 import java.awt.Dimension;
69 import java.awt.Rectangle;
71 import java.util.ArrayDeque;
72 import java.util.ArrayList;
73 import java.util.Deque;
74 import java.util.Hashtable;
76 import java.util.Vector;
78 import javax.swing.JInternalFrame;
79 import javax.swing.JOptionPane;
85 * @version $Revision: 1.141 $
87 public class AlignViewport extends AlignmentViewport implements
88 SelectionSource, VamsasSource, AlignViewportI, CommandListener
99 SequenceAnnotationOrder sortAnnotationsBy = null;
103 NJTree currentTree = null;
105 boolean cursorMode = false;
107 boolean antiAlias = false;
109 Rectangle explodedPosition;
113 boolean gatherViewsHere = false;
115 private Deque<CommandI> historyList = new ArrayDeque<CommandI>();
117 private Deque<CommandI> redoList = new ArrayDeque<CommandI>();
119 private AnnotationColumnChooser annotationColumnSelectionState;
121 * Creates a new AlignViewport object.
126 public AlignViewport(AlignmentI al)
133 * Create a new AlignViewport object with a specific sequence set ID
137 * (may be null - but potential for ambiguous constructor exception)
139 public AlignViewport(AlignmentI al, String seqsetid)
141 this(al, seqsetid, null);
144 public AlignViewport(AlignmentI al, String seqsetid, String viewid)
146 sequenceSetID = seqsetid;
148 // TODO remove these once 2.4.VAMSAS release finished
149 if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null)
151 Cache.log.debug("Setting viewport's sequence set id : "
154 if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null)
156 Cache.log.debug("Setting viewport's view id : " + viewId);
163 * Create a new AlignViewport with hidden regions
167 * @param hiddenColumns
170 public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns)
173 if (hiddenColumns != null)
175 colSel = hiddenColumns;
181 * New viewport with hidden columns and an existing sequence set id
184 * @param hiddenColumns
188 public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns,
191 this(al, hiddenColumns, seqsetid, null);
195 * New viewport with hidden columns and an existing sequence set id and viewid
198 * @param hiddenColumns
204 public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns,
205 String seqsetid, String viewid)
207 sequenceSetID = seqsetid;
209 // TODO remove these once 2.4.VAMSAS release finished
210 if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null)
212 Cache.log.debug("Setting viewport's sequence set id : "
215 if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null)
217 Cache.log.debug("Setting viewport's view id : " + viewId);
220 if (hiddenColumns != null)
222 colSel = hiddenColumns;
227 private void applyViewProperties()
229 antiAlias = Cache.getDefault("ANTI_ALIAS", false);
231 viewStyle.setShowJVSuffix(Cache.getDefault("SHOW_JVSUFFIX", true));
232 setShowAnnotation(Cache.getDefault("SHOW_ANNOTATIONS", true));
234 setRightAlignIds(Cache.getDefault("RIGHT_ALIGN_IDS", false));
235 setCentreColumnLabels(Cache.getDefault("CENTRE_COLUMN_LABELS", false));
236 autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
238 setPadGaps(Cache.getDefault("PAD_GAPS", true));
239 setShowNPFeats(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
240 setShowDBRefs(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
241 viewStyle.setSeqNameItalics(Cache.getDefault("ID_ITALICS", true));
242 viewStyle.setWrapAlignment(Cache.getDefault("WRAP_ALIGNMENT", false));
243 viewStyle.setShowUnconserved(Cache
244 .getDefault("SHOW_UNCONSERVED", false));
245 sortByTree = Cache.getDefault("SORT_BY_TREE", false);
246 followSelection = Cache.getDefault("FOLLOW_SELECTIONS", true);
247 sortAnnotationsBy = SequenceAnnotationOrder.valueOf(Cache.getDefault(
248 Preferences.SORT_ANNOTATIONS,
249 SequenceAnnotationOrder.NONE.name()));
250 showAutocalculatedAbove = Cache.getDefault(
251 Preferences.SHOW_AUTOCALC_ABOVE, false);
258 this.endRes = alignment.getWidth() - 1;
260 this.endSeq = alignment.getHeight() - 1;
261 applyViewProperties();
263 String fontName = Cache.getDefault("FONT_NAME", "SansSerif");
264 String fontStyle = Cache.getDefault("FONT_STYLE", Font.PLAIN + "");
265 String fontSize = Cache.getDefault("FONT_SIZE", "10");
269 if (fontStyle.equals("bold"))
273 else if (fontStyle.equals("italic"))
278 setFont(new Font(fontName, style, Integer.parseInt(fontSize)));
281 .setGapCharacter(Cache.getDefault("GAP_SYMBOL", "-").charAt(0));
283 // We must set conservation and consensus before setting colour,
284 // as Blosum and Clustal require this to be done
285 if (hconsensus == null && !isDataset)
287 if (!alignment.isNucleotide())
289 showConservation = Cache.getDefault("SHOW_CONSERVATION", true);
290 showQuality = Cache.getDefault("SHOW_QUALITY", true);
291 showGroupConservation = Cache.getDefault("SHOW_GROUP_CONSERVATION",
294 showConsensusHistogram = Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM",
296 showSequenceLogo = Cache.getDefault("SHOW_CONSENSUS_LOGO", false);
297 normaliseSequenceLogo = Cache.getDefault("NORMALISE_CONSENSUS_LOGO",
299 showGroupConsensus = Cache.getDefault("SHOW_GROUP_CONSENSUS", false);
300 showConsensus = Cache.getDefault("SHOW_IDENTITY", true);
302 initAutoAnnotation();
303 if (jalview.bin.Cache.getProperty("DEFAULT_COLOUR") != null)
305 globalColourScheme = ColourSchemeProperty.getColour(alignment,
306 jalview.bin.Cache.getProperty("DEFAULT_COLOUR"));
308 if (globalColourScheme instanceof UserColourScheme)
310 globalColourScheme = UserDefinedColours.loadDefaultColours();
311 ((UserColourScheme) globalColourScheme).setThreshold(0,
312 isIgnoreGapsConsensus());
315 if (globalColourScheme != null)
317 globalColourScheme.setConsensus(hconsensus);
323 * get the consensus sequence as displayed under the PID consensus annotation
326 * @return consensus sequence as a new sequence object
328 public SequenceI getConsensusSeq()
330 if (consensus == null)
332 updateConsensus(null);
334 if (consensus == null)
338 StringBuffer seqs = new StringBuffer();
339 for (int i = 0; i < consensus.annotations.length; i++)
341 if (consensus.annotations[i] != null)
343 if (consensus.annotations[i].description.charAt(0) == '[')
345 seqs.append(consensus.annotations[i].description.charAt(1));
349 seqs.append(consensus.annotations[i].displayCharacter);
354 SequenceI sq = new Sequence("Consensus", seqs.toString());
355 sq.setDescription("Percentage Identity Consensus "
356 + ((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
363 * @return DOCUMENT ME!
365 public int getStartRes()
373 * @return DOCUMENT ME!
375 public int getEndRes()
383 * @return DOCUMENT ME!
385 public int getStartSeq()
396 public void setStartRes(int res)
407 public void setStartSeq(int seq)
418 public void setEndRes(int res)
420 if (res > (alignment.getWidth() - 1))
422 // log.System.out.println(" Corrected res from " + res + " to maximum " +
423 // (alignment.getWidth()-1));
424 res = alignment.getWidth() - 1;
441 public void setEndSeq(int seq)
443 if (seq > alignment.getHeight())
445 seq = alignment.getHeight();
459 * @return DOCUMENT ME!
461 public int getEndSeq()
466 boolean validCharWidth;
469 * update view settings with the given font. You may need to call
470 * alignPanel.fontChanged to update the layout geometry
472 public void setFont(Font f)
476 Container c = new Container();
478 java.awt.FontMetrics fm = c.getFontMetrics(font);
479 int w = viewStyle.getCharWidth(), ww = fm.charWidth('M'), h = viewStyle
481 setCharHeight(fm.getHeight());
483 viewStyle.setFontName(font.getName());
484 viewStyle.setFontStyle(font.getStyle());
485 viewStyle.setFontSize(font.getSize());
487 validCharWidth = true;
491 public void setViewStyle(ViewStyleI settingsForView)
493 super.setViewStyle(settingsForView);
494 setFont(new Font(viewStyle.getFontName(), viewStyle.getFontStyle(),
495 viewStyle.getFontSize()));
501 * @return DOCUMENT ME!
503 public Font getFont()
514 public void setAlignment(AlignmentI align)
516 if (alignment != null && alignment.getCodonFrames() != null)
518 StructureSelectionManager.getStructureSelectionManager(
519 Desktop.instance).removeMappings(alignment.getCodonFrames());
521 this.alignment = align;
522 if (alignment != null && alignment.getCodonFrames() != null)
524 StructureSelectionManager.getStructureSelectionManager(
525 Desktop.instance).addMappings(alignment.getCodonFrames());
532 * @return DOCUMENT ME!
534 public char getGapCharacter()
536 return getAlignment().getGapCharacter();
545 public void setGapCharacter(char gap)
547 if (getAlignment() != null)
549 getAlignment().setGapCharacter(gap);
556 * @return DOCUMENT ME!
558 public ColumnSelection getColumnSelection()
569 public void setCurrentTree(NJTree tree)
577 * @return DOCUMENT ME!
579 public NJTree getCurrentTree()
585 * returns the visible column regions of the alignment
587 * @param selectedRegionOnly
588 * true to just return the contigs intersecting with the selected
592 public int[] getViewAsVisibleContigs(boolean selectedRegionOnly)
594 int[] viscontigs = null;
595 int start = 0, end = 0;
596 if (selectedRegionOnly && selectionGroup != null)
598 start = selectionGroup.getStartRes();
599 end = selectionGroup.getEndRes() + 1;
603 end = alignment.getWidth();
605 viscontigs = colSel.getVisibleContigs(start, end);
610 * get hash of undo and redo list for the alignment
612 * @return long[] { historyList.hashCode, redoList.hashCode };
614 public long[] getUndoRedoHash()
617 if (historyList == null || redoList == null)
623 { historyList.hashCode(), this.redoList.hashCode() };
627 * test if a particular set of hashcodes are different to the hashcodes for
628 * the undo and redo list.
631 * the stored set of hashcodes as returned by getUndoRedoHash
632 * @return true if the hashcodes differ (ie the alignment has been edited) or
633 * the stored hashcode array differs in size
635 public boolean isUndoRedoHashModified(long[] undoredo)
637 if (undoredo == null)
641 long[] cstate = getUndoRedoHash();
642 if (cstate.length != undoredo.length)
647 for (int i = 0; i < cstate.length; i++)
649 if (cstate[i] != undoredo[i])
658 * when set, view will scroll to show the highlighted position
660 public boolean followHighlight = true;
663 * @return true if view should scroll to show the highlighted region of a
667 public boolean getFollowHighlight()
669 return followHighlight;
672 public boolean followSelection = true;
675 * @return true if view selection should always follow the selections
676 * broadcast by other selection sources
678 public boolean getFollowSelection()
680 return followSelection;
684 * Send the current selection to be broadcast to any selection listeners.
686 public void sendSelection()
688 jalview.structure.StructureSelectionManager
689 .getStructureSelectionManager(Desktop.instance).sendSelection(
690 new SequenceGroup(getSelectionGroup()),
691 new ColumnSelection(getColumnSelection()), this);
695 * return the alignPanel containing the given viewport. Use this to get the
696 * components currently handling the given viewport.
699 * @return null or an alignPanel guaranteed to have non-null alignFrame
702 public AlignmentPanel getAlignPanel()
704 AlignmentPanel[] aps = PaintRefresher.getAssociatedPanels(this
705 .getSequenceSetId());
706 for (int p = 0; aps != null && p < aps.length; p++)
708 if (aps[p].av == this)
716 public boolean getSortByTree()
721 public void setSortByTree(boolean sort)
727 * synthesize a column selection if none exists so it covers the given
728 * selection group. if wholewidth is false, no column selection is made if the
729 * selection group covers the whole alignment width.
734 public void expandColSelection(SequenceGroup sg, boolean wholewidth)
738 && (sgs = sg.getStartRes()) >= 0
739 && sg.getStartRes() <= (sge = sg.getEndRes())
740 && (colSel == null || colSel.getSelected() == null || colSel
741 .getSelected().size() == 0))
743 if (!wholewidth && alignment.getWidth() == (1 + sge - sgs))
750 colSel = new ColumnSelection();
752 for (int cspos = sg.getStartRes(); cspos <= sg.getEndRes(); cspos++)
754 colSel.addElement(cspos);
759 public StructureSelectionManager getStructureSelectionManager()
761 return StructureSelectionManager
762 .getStructureSelectionManager(Desktop.instance);
768 * @return a series of SequenceI arrays, one for each PDBEntry, listing which
769 * sequence in the alignment holds a reference to it
771 public SequenceI[][] collateForPDB(PDBEntry[] pdbEntries)
773 ArrayList<SequenceI[]> seqvectors = new ArrayList<SequenceI[]>();
774 for (PDBEntry pdb : pdbEntries)
776 ArrayList<SequenceI> seqs = new ArrayList<SequenceI>();
777 for (int i = 0; i < alignment.getHeight(); i++)
779 Vector pdbs = alignment.getSequenceAt(i).getDatasetSequence()
786 for (int p = 0; p < pdbs.size(); p++)
788 PDBEntry p1 = (PDBEntry) pdbs.elementAt(p);
789 if (p1.getId().equals(pdb.getId()))
791 if (!seqs.contains(sq = alignment.getSequenceAt(i)))
800 seqvectors.add(seqs.toArray(new SequenceI[seqs.size()]));
802 return seqvectors.toArray(new SequenceI[seqvectors.size()][]);
805 public boolean isNormaliseSequenceLogo()
807 return normaliseSequenceLogo;
810 public void setNormaliseSequenceLogo(boolean state)
812 normaliseSequenceLogo = state;
817 * @return true if alignment characters should be displayed
819 public boolean isValidCharWidth()
821 return validCharWidth;
824 private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<String, AutoCalcSetting>();
826 private boolean showAutocalculatedAbove;
828 public AutoCalcSetting getCalcIdSettingsFor(String calcId)
830 return calcIdParams.get(calcId);
833 public void setCalcIdSettingsFor(String calcId, AutoCalcSetting settings,
836 calcIdParams.put(calcId, settings);
837 // TODO: create a restart list to trigger any calculations that need to be
838 // restarted after load
839 // calculator.getRegisteredWorkersOfClass(settings.getWorkerClass())
842 Cache.log.debug("trigger update for " + calcId);
846 protected SequenceAnnotationOrder getSortAnnotationsBy()
848 return sortAnnotationsBy;
851 protected void setSortAnnotationsBy(SequenceAnnotationOrder sortAnnotationsBy)
853 this.sortAnnotationsBy = sortAnnotationsBy;
856 protected boolean isShowAutocalculatedAbove()
858 return showAutocalculatedAbove;
861 protected void setShowAutocalculatedAbove(boolean showAutocalculatedAbove)
863 this.showAutocalculatedAbove = showAutocalculatedAbove;
867 * Method called when another alignment's edit (or possibly other) command is
870 * To allow for sequence mappings (e.g. protein to cDNA), we have to first
871 * 'unwind' the command on the source sequences (in simulation, not in fact),
872 * and then for each edit in turn:
874 * <li>compute the equivalent edit on the mapped sequences</li>
875 * <li>apply the mapped edit</li>
876 * <li>'apply' the source edit to the working copy of the source sequences</li>
884 public void mirrorCommand(CommandI command, boolean undo,
885 StructureSelectionManager ssm, VamsasSource source)
888 * ...work in progress... do nothing unless we are a 'complement' of the
889 * source May replace this with direct calls not via SSM.
891 if (source instanceof AlignViewportI
892 && ((AlignViewportI) source).getCodingComplement() == this)
901 CommandI mappedCommand = ssm.mapCommand(command, undo, getAlignment(),
903 if (mappedCommand != null)
905 AlignmentI[] views = getAlignPanel().alignFrame.getViewAlignments();
906 mappedCommand.doCommand(views);
907 getAlignPanel().alignmentChanged();
912 public VamsasSource getVamsasSource()
918 * Add one command to the command history list.
922 public void addToHistoryList(CommandI command)
924 if (this.historyList != null)
926 this.historyList.push(command);
927 broadcastCommand(command, false);
931 protected void broadcastCommand(CommandI command, boolean undo)
933 getStructureSelectionManager().commandPerformed(command, undo, getVamsasSource());
937 * Add one command to the command redo list.
941 public void addToRedoList(CommandI command)
943 if (this.redoList != null)
945 this.redoList.push(command);
947 broadcastCommand(command, true);
951 * Clear the command redo list.
953 public void clearRedoList()
955 if (this.redoList != null)
957 this.redoList.clear();
961 public void setHistoryList(Deque<CommandI> list)
963 this.historyList = list;
966 public Deque<CommandI> getHistoryList()
968 return this.historyList;
971 public void setRedoList(Deque<CommandI> list)
973 this.redoList = list;
976 public Deque<CommandI> getRedoList()
978 return this.redoList;
982 * Add the sequences from the given alignment to this viewport. Optionally,
983 * may give the user the option to open a new frame, or split panel, with cDNA
984 * and protein linked.
989 public void addAlignment(AlignmentI al, String title)
991 // TODO: promote to AlignViewportI? applet CutAndPasteTransfer is different
993 // JBPComment: title is a largely redundant parameter at the moment
994 // JBPComment: this really should be an 'insert/pre/append' controller
995 // JBPComment: but the DNA/Protein check makes it a bit more complex
997 // refactored from FileLoader / CutAndPasteTransfer / SequenceFetcher with
999 // TODO: create undo object for this JAL-1101
1002 * If one alignment is protein and one nucleotide, with at least one
1003 * sequence name in common, offer to open a linked alignment.
1005 if (getAlignment().isNucleotide() != al.isNucleotide())
1007 // TODO: JAL-845 try a bit harder to link up imported sequences
1008 final Set<String> sequenceNames = getAlignment().getSequenceNames();
1009 sequenceNames.retainAll(al.getSequenceNames());
1010 if (!sequenceNames.isEmpty()) // at least one sequence name in both
1012 if (openLinkedAlignment(al, title))
1018 // TODO: JAL-407 regardless of above - identical sequences (based on ID and
1019 // provenance) should share the same dataset sequence
1021 for (int i = 0; i < al.getHeight(); i++)
1023 getAlignment().addSequence(al.getSequenceAt(i));
1025 // TODO this call was done by SequenceFetcher but not FileLoader or
1026 // CutAndPasteTransfer. Is it needed?
1027 // JBPComment: this repositions the view to show the new sequences
1028 // JBPComment: so it is needed for UX
1029 setEndSeq(getAlignment().getHeight());
1030 firePropertyChange("alignment", null, getAlignment().getSequences());
1034 * Show a dialog with the option to open and link (cDNA <-> protein) as a new
1035 * alignment. Returns true if the new alignment was opened, false if not,
1036 * because the user declined the offer.
1040 protected boolean openLinkedAlignment(AlignmentI al, String title)
1042 String[] options = new String[]
1043 { MessageManager.getString("action.no"),
1044 MessageManager.getString("label.split_window"),
1045 MessageManager.getString("label.new_window"), };
1046 final String question = JvSwingUtils.wrapTooltip(true,
1047 MessageManager.getString("label.open_linked_alignment?"));
1048 int response = JOptionPane.showOptionDialog(Desktop.desktop, question,
1049 MessageManager.getString("label.open_linked_alignment"),
1050 JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null,
1051 options, options[0]);
1053 if (response != 1 && response != 2)
1057 final boolean openSplitPane = (response == 1);
1058 final boolean openInNewWindow = (response == 2);
1061 * Create the AlignFrame first (which creates the new alignment's datasets),
1062 * before attempting sequence mapping.
1064 AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
1065 AlignFrame.DEFAULT_HEIGHT);
1066 newAlignFrame.setTitle(title);
1069 * Identify protein and dna alignments. Make a copy of this one if opening
1070 * in a new split pane.
1072 AlignmentI thisAlignment = openSplitPane ? new Alignment(getAlignment())
1074 AlignmentI protein = al.isNucleotide() ? thisAlignment : al;
1075 final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment;
1077 newAlignFrame.statusBar.setText(MessageManager.formatMessage(
1078 "label.successfully_loaded_file", new Object[]
1081 // TODO if we want this (e.g. to enable reload of the alignment from file),
1082 // we will need to add parameters to the stack.
1083 // if (!protocol.equals(AppletFormatAdapter.PASTE))
1085 // alignFrame.setFileName(file, format);
1088 if (openInNewWindow)
1090 Desktop.addInternalFrame(newAlignFrame, title,
1091 AlignFrame.DEFAULT_WIDTH,
1092 AlignFrame.DEFAULT_HEIGHT);
1096 * Try to find mappings for at least one sequence. Any mappings made will be
1097 * added to the protein alignment.
1099 MappingResult mapped = AlignmentUtils.mapProteinToCdna(protein, cdna);
1100 final StructureSelectionManager ssm = StructureSelectionManager
1101 .getStructureSelectionManager(Desktop.instance);
1102 if (mapped != MappingResult.Mapped)
1105 * No mapping possible - warn the user, but leave window open.
1107 final String msg = JvSwingUtils.wrapTooltip(true,
1108 MessageManager.getString("label.mapping_failed"));
1109 JOptionPane.showInternalMessageDialog(Desktop.desktop, msg,
1110 MessageManager.getString("label.no_mappings"),
1111 JOptionPane.WARNING_MESSAGE);
1116 newAlignFrame.setMaximum(jalview.bin.Cache.getDefault(
1119 } catch (java.beans.PropertyVetoException ex)
1125 // TODO: move this kind of constructor stuff to a factory/controller
1128 * Open in split pane. DNA sequence above, protein below.
1130 AlignFrame copyMe = new AlignFrame(thisAlignment,
1131 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
1132 copyMe.setTitle(getAlignPanel().alignFrame.getTitle());
1133 final AlignFrame proteinFrame = al.isNucleotide() ? copyMe
1135 final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame
1137 protein = proteinFrame.viewport.getAlignment();
1139 cdnaFrame.setVisible(true);
1140 proteinFrame.setVisible(true);
1141 String sep = String.valueOf(File.separatorChar);
1142 String proteinShortName = proteinFrame.getTitle().substring(
1143 proteinFrame.getTitle().lastIndexOf(sep) + 1);
1144 String dnaShortName = cdnaFrame.getTitle().substring(
1145 cdnaFrame.getTitle().lastIndexOf(sep) + 1);
1146 String linkedTitle = MessageManager.formatMessage(
1147 "label.linked_view_title", dnaShortName, proteinShortName);
1148 JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame);
1149 Desktop.addInternalFrame(splitFrame, linkedTitle,
1150 AlignFrame.DEFAULT_WIDTH,
1151 AlignFrame.DEFAULT_HEIGHT);
1154 * Set the frames to listen for each other's edit and sort commands.
1156 ssm.addCommandListener(cdnaFrame.getViewport());
1157 ssm.addCommandListener(proteinFrame.getViewport());
1160 * 'Coding complement' (dna/protein) views will mirror each others' edits,
1161 * selections, sorting etc as decided from time to time by the relevant
1164 proteinFrame.getViewport().setCodingComplement(cdnaFrame.getViewport());
1168 * Register the mappings (held on the protein alignment) with the
1169 * StructureSelectionManager (for mouseover linking).
1171 ssm.addMappings(protein.getCodonFrames());
1176 public AnnotationColumnChooser getAnnotationColumnSelectionState()
1178 return annotationColumnSelectionState;
1181 public void setAnnotationColumnSelectionState(
1182 AnnotationColumnChooser currentAnnotationColumnSelectionState)
1184 this.annotationColumnSelectionState = currentAnnotationColumnSelectionState;
1188 public void setIdWidth(int i)
1190 super.setIdWidth(i);
1191 AlignmentPanel ap = getAlignPanel();
1194 // modify GUI elements to reflect geometry change
1195 Dimension idw = getAlignPanel().getIdPanel().getIdCanvas()
1196 .getPreferredSize();
1198 getAlignPanel().getIdPanel().getIdCanvas().setPreferredSize(idw);