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;
70 import java.util.ArrayList;
71 import java.util.Hashtable;
73 import java.util.Vector;
75 import javax.swing.JInternalFrame;
76 import javax.swing.JOptionPane;
82 * @version $Revision: 1.141 $
84 public class AlignViewport extends AlignmentViewport implements
85 SelectionSource, AlignViewportI, CommandListener
96 SequenceAnnotationOrder sortAnnotationsBy = null;
100 NJTree currentTree = null;
102 boolean cursorMode = false;
104 boolean antiAlias = false;
106 private Rectangle explodedGeometry;
110 private boolean gatherViewsHere = false;
112 private AnnotationColumnChooser annotationColumnSelectionState;
114 * Creates a new AlignViewport object.
119 public AlignViewport(AlignmentI al)
126 * Create a new AlignViewport object with a specific sequence set ID
130 * (may be null - but potential for ambiguous constructor exception)
132 public AlignViewport(AlignmentI al, String seqsetid)
134 this(al, seqsetid, null);
137 public AlignViewport(AlignmentI al, String seqsetid, String viewid)
139 sequenceSetID = seqsetid;
141 // TODO remove these once 2.4.VAMSAS release finished
142 if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null)
144 Cache.log.debug("Setting viewport's sequence set id : "
147 if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null)
149 Cache.log.debug("Setting viewport's view id : " + viewId);
156 * Create a new AlignViewport with hidden regions
160 * @param hiddenColumns
163 public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns)
166 if (hiddenColumns != null)
168 colSel = hiddenColumns;
174 * New viewport with hidden columns and an existing sequence set id
177 * @param hiddenColumns
181 public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns,
184 this(al, hiddenColumns, seqsetid, null);
188 * New viewport with hidden columns and an existing sequence set id and viewid
191 * @param hiddenColumns
197 public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns,
198 String seqsetid, String viewid)
200 sequenceSetID = seqsetid;
202 // TODO remove these once 2.4.VAMSAS release finished
203 if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null)
205 Cache.log.debug("Setting viewport's sequence set id : "
208 if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null)
210 Cache.log.debug("Setting viewport's view id : " + viewId);
213 if (hiddenColumns != null)
215 colSel = hiddenColumns;
220 private void applyViewProperties()
222 antiAlias = Cache.getDefault("ANTI_ALIAS", false);
224 viewStyle.setShowJVSuffix(Cache.getDefault("SHOW_JVSUFFIX", true));
225 setShowAnnotation(Cache.getDefault("SHOW_ANNOTATIONS", true));
227 setRightAlignIds(Cache.getDefault("RIGHT_ALIGN_IDS", false));
228 setCentreColumnLabels(Cache.getDefault("CENTRE_COLUMN_LABELS", false));
229 autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
231 setPadGaps(Cache.getDefault("PAD_GAPS", true));
232 setShowNPFeats(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
233 setShowDBRefs(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
234 viewStyle.setSeqNameItalics(Cache.getDefault("ID_ITALICS", true));
235 viewStyle.setWrapAlignment(Cache.getDefault("WRAP_ALIGNMENT", false));
236 viewStyle.setShowUnconserved(Cache
237 .getDefault("SHOW_UNCONSERVED", false));
238 sortByTree = Cache.getDefault("SORT_BY_TREE", false);
239 followSelection = Cache.getDefault("FOLLOW_SELECTIONS", true);
240 sortAnnotationsBy = SequenceAnnotationOrder.valueOf(Cache.getDefault(
241 Preferences.SORT_ANNOTATIONS,
242 SequenceAnnotationOrder.NONE.name()));
243 showAutocalculatedAbove = Cache.getDefault(
244 Preferences.SHOW_AUTOCALC_ABOVE, false);
251 this.endRes = alignment.getWidth() - 1;
253 this.endSeq = alignment.getHeight() - 1;
254 applyViewProperties();
256 String fontName = Cache.getDefault("FONT_NAME", "SansSerif");
257 String fontStyle = Cache.getDefault("FONT_STYLE", Font.PLAIN + "");
258 String fontSize = Cache.getDefault("FONT_SIZE", "10");
262 if (fontStyle.equals("bold"))
266 else if (fontStyle.equals("italic"))
271 setFont(new Font(fontName, style, Integer.parseInt(fontSize)), true);
274 .setGapCharacter(Cache.getDefault("GAP_SYMBOL", "-").charAt(0));
276 // We must set conservation and consensus before setting colour,
277 // as Blosum and Clustal require this to be done
278 if (hconsensus == null && !isDataset)
280 if (!alignment.isNucleotide())
282 showConservation = Cache.getDefault("SHOW_CONSERVATION", true);
283 showQuality = Cache.getDefault("SHOW_QUALITY", true);
284 showGroupConservation = Cache.getDefault("SHOW_GROUP_CONSERVATION",
287 showConsensusHistogram = Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM",
289 showSequenceLogo = Cache.getDefault("SHOW_CONSENSUS_LOGO", false);
290 normaliseSequenceLogo = Cache.getDefault("NORMALISE_CONSENSUS_LOGO",
292 showGroupConsensus = Cache.getDefault("SHOW_GROUP_CONSENSUS", false);
293 showConsensus = Cache.getDefault("SHOW_IDENTITY", true);
295 initAutoAnnotation();
296 if (jalview.bin.Cache.getProperty("DEFAULT_COLOUR") != null)
298 globalColourScheme = ColourSchemeProperty.getColour(alignment,
299 jalview.bin.Cache.getProperty("DEFAULT_COLOUR"));
301 if (globalColourScheme instanceof UserColourScheme)
303 globalColourScheme = UserDefinedColours.loadDefaultColours();
304 ((UserColourScheme) globalColourScheme).setThreshold(0,
305 isIgnoreGapsConsensus());
308 if (globalColourScheme != null)
310 globalColourScheme.setConsensus(hconsensus);
316 * get the consensus sequence as displayed under the PID consensus annotation
319 * @return consensus sequence as a new sequence object
321 public SequenceI getConsensusSeq()
323 if (consensus == null)
325 updateConsensus(null);
327 if (consensus == null)
331 StringBuffer seqs = new StringBuffer();
332 for (int i = 0; i < consensus.annotations.length; i++)
334 if (consensus.annotations[i] != null)
336 if (consensus.annotations[i].description.charAt(0) == '[')
338 seqs.append(consensus.annotations[i].description.charAt(1));
342 seqs.append(consensus.annotations[i].displayCharacter);
347 SequenceI sq = new Sequence("Consensus", seqs.toString());
348 sq.setDescription("Percentage Identity Consensus "
349 + ((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
356 * @return DOCUMENT ME!
358 public int getStartRes()
366 * @return DOCUMENT ME!
368 public int getEndRes()
376 * @return DOCUMENT ME!
378 public int getStartSeq()
389 public void setStartRes(int res)
400 public void setStartSeq(int seq)
411 public void setEndRes(int res)
413 if (res > (alignment.getWidth() - 1))
415 // log.System.out.println(" Corrected res from " + res + " to maximum " +
416 // (alignment.getWidth()-1));
417 res = alignment.getWidth() - 1;
434 public void setEndSeq(int seq)
436 if (seq > alignment.getHeight())
438 seq = alignment.getHeight();
452 * @return DOCUMENT ME!
454 public int getEndSeq()
459 boolean validCharWidth;
462 * update view settings with the given font. You may need to call
463 * alignPanel.fontChanged to update the layout geometry
466 * when true, charWidth/height is set according to font mentrics
468 public void setFont(Font f, boolean setGrid)
472 Container c = new Container();
474 java.awt.FontMetrics fm = c.getFontMetrics(font);
475 int w = viewStyle.getCharWidth(), ww = fm.charWidth('M'), h = viewStyle
479 setCharHeight(fm.getHeight());
482 viewStyle.setFontName(font.getName());
483 viewStyle.setFontStyle(font.getStyle());
484 viewStyle.setFontSize(font.getSize());
486 validCharWidth = true;
490 public void setViewStyle(ViewStyleI settingsForView)
492 super.setViewStyle(settingsForView);
493 setFont(new Font(viewStyle.getFontName(), viewStyle.getFontStyle(),
494 viewStyle.getFontSize()), false);
500 * @return DOCUMENT ME!
502 public Font getFont()
513 public void setAlignment(AlignmentI align)
515 if (alignment != null && alignment.getCodonFrames() != null)
517 StructureSelectionManager.getStructureSelectionManager(
518 Desktop.instance).removeMappings(alignment.getCodonFrames());
520 this.alignment = align;
521 if (alignment != null && alignment.getCodonFrames() != null)
523 StructureSelectionManager.getStructureSelectionManager(
524 Desktop.instance).addMappings(alignment.getCodonFrames());
531 * @return DOCUMENT ME!
533 public char getGapCharacter()
535 return getAlignment().getGapCharacter();
544 public void setGapCharacter(char gap)
546 if (getAlignment() != null)
548 getAlignment().setGapCharacter(gap);
555 * @return DOCUMENT ME!
557 public ColumnSelection getColumnSelection()
568 public void setCurrentTree(NJTree tree)
576 * @return DOCUMENT ME!
578 public NJTree getCurrentTree()
584 * returns the visible column regions of the alignment
586 * @param selectedRegionOnly
587 * true to just return the contigs intersecting with the selected
591 public int[] getViewAsVisibleContigs(boolean selectedRegionOnly)
593 int[] viscontigs = null;
594 int start = 0, end = 0;
595 if (selectedRegionOnly && selectionGroup != null)
597 start = selectionGroup.getStartRes();
598 end = selectionGroup.getEndRes() + 1;
602 end = alignment.getWidth();
604 viscontigs = colSel.getVisibleContigs(start, end);
609 * get hash of undo and redo list for the alignment
611 * @return long[] { historyList.hashCode, redoList.hashCode };
613 public long[] getUndoRedoHash()
616 if (historyList == null || redoList == null)
622 { historyList.hashCode(), this.redoList.hashCode() };
626 * test if a particular set of hashcodes are different to the hashcodes for
627 * the undo and redo list.
630 * the stored set of hashcodes as returned by getUndoRedoHash
631 * @return true if the hashcodes differ (ie the alignment has been edited) or
632 * the stored hashcode array differs in size
634 public boolean isUndoRedoHashModified(long[] undoredo)
636 if (undoredo == null)
640 long[] cstate = getUndoRedoHash();
641 if (cstate.length != undoredo.length)
646 for (int i = 0; i < cstate.length; i++)
648 if (cstate[i] != undoredo[i])
657 * when set, view will scroll to show the highlighted position
659 public boolean followHighlight = true;
662 * @return true if view should scroll to show the highlighted region of a
666 public boolean getFollowHighlight()
668 return followHighlight;
671 public boolean followSelection = true;
674 * @return true if view selection should always follow the selections
675 * broadcast by other selection sources
677 public boolean getFollowSelection()
679 return followSelection;
683 * Send the current selection to be broadcast to any selection listeners.
685 public void sendSelection()
687 jalview.structure.StructureSelectionManager
688 .getStructureSelectionManager(Desktop.instance).sendSelection(
689 new SequenceGroup(getSelectionGroup()),
690 new ColumnSelection(getColumnSelection()), this);
694 * return the alignPanel containing the given viewport. Use this to get the
695 * components currently handling the given viewport.
698 * @return null or an alignPanel guaranteed to have non-null alignFrame
701 public AlignmentPanel getAlignPanel()
703 AlignmentPanel[] aps = PaintRefresher.getAssociatedPanels(this
704 .getSequenceSetId());
705 for (int p = 0; aps != null && p < aps.length; p++)
707 if (aps[p].av == this)
715 public boolean getSortByTree()
720 public void setSortByTree(boolean sort)
726 * synthesize a column selection if none exists so it covers the given
727 * selection group. if wholewidth is false, no column selection is made if the
728 * selection group covers the whole alignment width.
733 public void expandColSelection(SequenceGroup sg, boolean wholewidth)
737 && (sgs = sg.getStartRes()) >= 0
738 && sg.getStartRes() <= (sge = sg.getEndRes())
739 && (colSel == null || colSel.getSelected() == null || colSel
740 .getSelected().size() == 0))
742 if (!wholewidth && alignment.getWidth() == (1 + sge - sgs))
749 colSel = new ColumnSelection();
751 for (int cspos = sg.getStartRes(); cspos <= sg.getEndRes(); cspos++)
753 colSel.addElement(cspos);
759 * Returns the (Desktop) instance of the StructureSelectionManager
762 public StructureSelectionManager getStructureSelectionManager()
764 return StructureSelectionManager
765 .getStructureSelectionManager(Desktop.instance);
771 * @return a series of SequenceI arrays, one for each PDBEntry, listing which
772 * sequence in the alignment holds a reference to it
774 public SequenceI[][] collateForPDB(PDBEntry[] pdbEntries)
776 ArrayList<SequenceI[]> seqvectors = new ArrayList<SequenceI[]>();
777 for (PDBEntry pdb : pdbEntries)
779 ArrayList<SequenceI> seqs = new ArrayList<SequenceI>();
780 for (int i = 0; i < alignment.getHeight(); i++)
782 Vector pdbs = alignment.getSequenceAt(i).getDatasetSequence()
789 for (int p = 0; p < pdbs.size(); p++)
791 PDBEntry p1 = (PDBEntry) pdbs.elementAt(p);
792 if (p1.getId().equals(pdb.getId()))
794 if (!seqs.contains(sq = alignment.getSequenceAt(i)))
803 seqvectors.add(seqs.toArray(new SequenceI[seqs.size()]));
805 return seqvectors.toArray(new SequenceI[seqvectors.size()][]);
808 public boolean isNormaliseSequenceLogo()
810 return normaliseSequenceLogo;
813 public void setNormaliseSequenceLogo(boolean state)
815 normaliseSequenceLogo = state;
820 * @return true if alignment characters should be displayed
822 public boolean isValidCharWidth()
824 return validCharWidth;
827 private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<String, AutoCalcSetting>();
829 private boolean showAutocalculatedAbove;
831 public AutoCalcSetting getCalcIdSettingsFor(String calcId)
833 return calcIdParams.get(calcId);
836 public void setCalcIdSettingsFor(String calcId, AutoCalcSetting settings,
839 calcIdParams.put(calcId, settings);
840 // TODO: create a restart list to trigger any calculations that need to be
841 // restarted after load
842 // calculator.getRegisteredWorkersOfClass(settings.getWorkerClass())
845 Cache.log.debug("trigger update for " + calcId);
849 protected SequenceAnnotationOrder getSortAnnotationsBy()
851 return sortAnnotationsBy;
854 protected void setSortAnnotationsBy(SequenceAnnotationOrder sortAnnotationsBy)
856 this.sortAnnotationsBy = sortAnnotationsBy;
859 protected boolean isShowAutocalculatedAbove()
861 return showAutocalculatedAbove;
864 protected void setShowAutocalculatedAbove(boolean showAutocalculatedAbove)
866 this.showAutocalculatedAbove = showAutocalculatedAbove;
870 * Method called when another alignment's edit (or possibly other) command is
873 * To allow for sequence mappings (e.g. protein to cDNA), we have to first
874 * 'unwind' the command on the source sequences (in simulation, not in fact),
875 * and then for each edit in turn:
877 * <li>compute the equivalent edit on the mapped sequences</li>
878 * <li>apply the mapped edit</li>
879 * <li>'apply' the source edit to the working copy of the source sequences</li>
887 public void mirrorCommand(CommandI command, boolean undo,
888 StructureSelectionManager ssm, VamsasSource source)
891 * Do nothing unless we are a 'complement' of the source. May replace this
892 * with direct calls not via SSM.
894 if (source instanceof AlignViewportI
895 && ((AlignViewportI) source).getCodingComplement() == this)
904 CommandI mappedCommand = ssm.mapCommand(command, undo, getAlignment(),
906 if (mappedCommand != null)
908 AlignmentI[] views = getAlignPanel().alignFrame.getViewAlignments();
909 mappedCommand.doCommand(views);
910 getAlignPanel().alignmentChanged();
915 * Add the sequences from the given alignment to this viewport. Optionally,
916 * may give the user the option to open a new frame, or split panel, with cDNA
917 * and protein linked.
922 public void addAlignment(AlignmentI al, String title)
924 // TODO: promote to AlignViewportI? applet CutAndPasteTransfer is different
926 // JBPComment: title is a largely redundant parameter at the moment
927 // JBPComment: this really should be an 'insert/pre/append' controller
928 // JBPComment: but the DNA/Protein check makes it a bit more complex
930 // refactored from FileLoader / CutAndPasteTransfer / SequenceFetcher with
932 // TODO: create undo object for this JAL-1101
935 * If one alignment is protein and one nucleotide, with at least one
936 * sequence name in common, offer to open a linked alignment.
938 if (getAlignment().isNucleotide() != al.isNucleotide())
940 // TODO: JAL-845 try a bit harder to link up imported sequences
941 final Set<String> sequenceNames = getAlignment().getSequenceNames();
942 sequenceNames.retainAll(al.getSequenceNames());
943 if (!sequenceNames.isEmpty()) // at least one sequence name in both
945 if (openLinkedAlignment(al, title))
951 // TODO: JAL-407 regardless of above - identical sequences (based on ID and
952 // provenance) should share the same dataset sequence
954 for (int i = 0; i < al.getHeight(); i++)
956 getAlignment().addSequence(al.getSequenceAt(i));
958 // TODO this call was done by SequenceFetcher but not FileLoader or
959 // CutAndPasteTransfer. Is it needed?
960 // JBPComment: this repositions the view to show the new sequences
961 // JBPComment: so it is needed for UX
962 setEndSeq(getAlignment().getHeight());
963 firePropertyChange("alignment", null, getAlignment().getSequences());
967 * Show a dialog with the option to open and link (cDNA <-> protein) as a new
968 * alignment. Returns true if the new alignment was opened, false if not,
969 * because the user declined the offer.
973 protected boolean openLinkedAlignment(AlignmentI al, String title)
975 String[] options = new String[]
976 { MessageManager.getString("action.no"),
977 MessageManager.getString("label.split_window"),
978 MessageManager.getString("label.new_window"), };
979 final String question = JvSwingUtils.wrapTooltip(true,
980 MessageManager.getString("label.open_linked_alignment?"));
981 int response = JOptionPane.showOptionDialog(Desktop.desktop, question,
982 MessageManager.getString("label.open_linked_alignment"),
983 JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null,
984 options, options[0]);
986 if (response != 1 && response != 2)
990 final boolean openSplitPane = (response == 1);
991 final boolean openInNewWindow = (response == 2);
994 * Create the AlignFrame first (which creates the new alignment's datasets),
995 * before attempting sequence mapping.
997 AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
998 AlignFrame.DEFAULT_HEIGHT);
999 newAlignFrame.setTitle(title);
1002 * Identify protein and dna alignments. Make a copy of this one if opening
1003 * in a new split pane.
1005 AlignmentI thisAlignment = openSplitPane ? new Alignment(getAlignment())
1007 AlignmentI protein = al.isNucleotide() ? thisAlignment : al;
1008 final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment;
1010 newAlignFrame.statusBar.setText(MessageManager.formatMessage(
1011 "label.successfully_loaded_file", new Object[]
1014 // TODO if we want this (e.g. to enable reload of the alignment from file),
1015 // we will need to add parameters to the stack.
1016 // if (!protocol.equals(AppletFormatAdapter.PASTE))
1018 // alignFrame.setFileName(file, format);
1021 if (openInNewWindow)
1023 Desktop.addInternalFrame(newAlignFrame, title,
1024 AlignFrame.DEFAULT_WIDTH,
1025 AlignFrame.DEFAULT_HEIGHT);
1029 * Try to find mappings for at least one sequence. Any mappings made will be
1030 * added to the protein alignment.
1032 MappingResult mapped = AlignmentUtils.mapProteinToCdna(protein, cdna);
1033 if (mapped != MappingResult.Mapped)
1036 * No mapping possible - warn the user, but leave window open.
1038 final String msg = JvSwingUtils.wrapTooltip(true,
1039 MessageManager.getString("label.mapping_failed"));
1040 JOptionPane.showInternalMessageDialog(Desktop.desktop, msg,
1041 MessageManager.getString("label.no_mappings"),
1042 JOptionPane.WARNING_MESSAGE);
1047 newAlignFrame.setMaximum(jalview.bin.Cache.getDefault(
1050 } catch (java.beans.PropertyVetoException ex)
1056 protein = openSplitFrame(newAlignFrame, thisAlignment);
1060 * Register the mappings (held on the protein alignment) with the
1061 * StructureSelectionManager (for mouseover linking).
1063 final StructureSelectionManager ssm = StructureSelectionManager
1064 .getStructureSelectionManager(Desktop.instance);
1065 ssm.addMappings(protein.getCodonFrames());
1071 * Helper method to open a new SplitFrame holding linked dna and protein
1074 * @param newAlignFrame
1075 * containing a new alignment to be shown
1076 * @param existingAlignment
1077 * an existing alignment to be copied for display in the split frame
1078 * @return the protein alignment in the split frame
1080 protected AlignmentI openSplitFrame(AlignFrame newAlignFrame,
1081 AlignmentI existingAlignment)
1083 // TODO: move this to a factory/controller method ?
1085 * Open in split pane. DNA sequence above, protein below.
1087 AlignFrame copyMe = new AlignFrame(existingAlignment,
1088 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
1089 copyMe.setTitle(getAlignPanel().alignFrame.getTitle());
1091 AlignmentI al = newAlignFrame.viewport.getAlignment();
1092 final AlignFrame proteinFrame = al.isNucleotide() ? copyMe
1094 final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame
1096 AlignmentI protein = proteinFrame.viewport.getAlignment();
1098 cdnaFrame.setVisible(true);
1099 proteinFrame.setVisible(true);
1100 String linkedTitle = MessageManager
1101 .getString("label.linked_view_title");
1102 JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame);
1103 Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1);
1106 * Set the frames to listen for each other's edit and sort commands.
1108 final StructureSelectionManager ssm = StructureSelectionManager
1109 .getStructureSelectionManager(Desktop.instance);
1110 ssm.addCommandListener(cdnaFrame.getViewport());
1111 ssm.addCommandListener(proteinFrame.getViewport());
1114 * 'Coding complement' (dna/protein) views will mirror each others' edits,
1115 * selections, sorting etc as decided from time to time by the relevant
1118 proteinFrame.getViewport().setCodingComplement(cdnaFrame.getViewport());
1122 public AnnotationColumnChooser getAnnotationColumnSelectionState()
1124 return annotationColumnSelectionState;
1127 public void setAnnotationColumnSelectionState(
1128 AnnotationColumnChooser currentAnnotationColumnSelectionState)
1130 this.annotationColumnSelectionState = currentAnnotationColumnSelectionState;
1134 public void setIdWidth(int i)
1136 super.setIdWidth(i);
1137 AlignmentPanel ap = getAlignPanel();
1140 // modify GUI elements to reflect geometry change
1141 Dimension idw = getAlignPanel().getIdPanel().getIdCanvas()
1142 .getPreferredSize();
1144 getAlignPanel().getIdPanel().getIdCanvas().setPreferredSize(idw);
1148 public Rectangle getExplodedGeometry()
1150 return explodedGeometry;
1153 public void setExplodedGeometry(Rectangle explodedPosition)
1155 this.explodedGeometry = explodedPosition;
1158 public boolean isGatherViewsHere()
1160 return gatherViewsHere;
1163 public void setGatherViewsHere(boolean gatherViewsHere)
1165 this.gatherViewsHere = gatherViewsHere;