2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ 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.AnnotationSorter.SequenceAnnotationOrder;
43 import jalview.analysis.NJTree;
44 import jalview.api.AlignViewportI;
45 import jalview.api.AlignmentViewPanel;
46 import jalview.api.ViewStyleI;
47 import jalview.bin.Cache;
48 import jalview.commands.CommandI;
49 import jalview.datamodel.AlignedCodonFrame;
50 import jalview.datamodel.Alignment;
51 import jalview.datamodel.AlignmentI;
52 import jalview.datamodel.ColumnSelection;
53 import jalview.datamodel.PDBEntry;
54 import jalview.datamodel.SearchResults;
55 import jalview.datamodel.Sequence;
56 import jalview.datamodel.SequenceGroup;
57 import jalview.datamodel.SequenceI;
58 import jalview.schemes.ColourSchemeProperty;
59 import jalview.schemes.UserColourScheme;
60 import jalview.structure.CommandListener;
61 import jalview.structure.SelectionSource;
62 import jalview.structure.StructureSelectionManager;
63 import jalview.structure.VamsasSource;
64 import jalview.util.MessageManager;
65 import jalview.viewmodel.AlignmentViewport;
66 import jalview.ws.params.AutoCalcSetting;
68 import java.awt.Container;
69 import java.awt.Dimension;
71 import java.awt.Rectangle;
72 import java.util.ArrayList;
73 import java.util.Hashtable;
74 import java.util.List;
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, CommandListener
92 NJTree currentTree = null;
94 boolean cursorMode = false;
96 boolean antiAlias = false;
98 private Rectangle explodedGeometry;
103 * Flag set true on the view that should 'gather' multiple views of the same
104 * sequence set id when a project is reloaded. Set false on all views when
105 * they are 'exploded' into separate windows. Set true on the current view
106 * when 'Gather' is performed, and also on the first tab when the first new
109 private boolean gatherViewsHere = false;
111 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;
221 * Apply any settings saved in user preferences
223 private void applyViewProperties()
225 antiAlias = Cache.getDefault("ANTI_ALIAS", false);
227 viewStyle.setShowJVSuffix(Cache.getDefault("SHOW_JVSUFFIX", true));
228 setShowAnnotation(Cache.getDefault("SHOW_ANNOTATIONS", true));
230 setRightAlignIds(Cache.getDefault("RIGHT_ALIGN_IDS", false));
231 setCentreColumnLabels(Cache.getDefault("CENTRE_COLUMN_LABELS", false));
232 autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
234 setPadGaps(Cache.getDefault("PAD_GAPS", true));
235 setShowNPFeats(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
236 setShowDBRefs(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
237 viewStyle.setSeqNameItalics(Cache.getDefault("ID_ITALICS", true));
238 viewStyle.setWrapAlignment(Cache.getDefault("WRAP_ALIGNMENT", false));
239 viewStyle.setShowUnconserved(Cache
240 .getDefault("SHOW_UNCONSERVED", false));
241 sortByTree = Cache.getDefault("SORT_BY_TREE", false);
242 followSelection = Cache.getDefault("FOLLOW_SELECTIONS", true);
243 sortAnnotationsBy = SequenceAnnotationOrder.valueOf(Cache.getDefault(
244 Preferences.SORT_ANNOTATIONS,
245 SequenceAnnotationOrder.NONE.name()));
246 showAutocalculatedAbove = Cache.getDefault(
247 Preferences.SHOW_AUTOCALC_ABOVE, false);
248 viewStyle.setScaleProteinAsCdna(Cache.getDefault(
249 Preferences.SCALE_PROTEIN_TO_CDNA, true));
255 this.endRes = alignment.getWidth() - 1;
257 this.endSeq = alignment.getHeight() - 1;
258 applyViewProperties();
260 String fontName = Cache.getDefault("FONT_NAME", "SansSerif");
261 String fontStyle = Cache.getDefault("FONT_STYLE", Font.PLAIN + "");
262 String fontSize = Cache.getDefault("FONT_SIZE", "10");
266 if (fontStyle.equals("bold"))
270 else if (fontStyle.equals("italic"))
275 setFont(new Font(fontName, style, Integer.parseInt(fontSize)), true);
278 .setGapCharacter(Cache.getDefault("GAP_SYMBOL", "-").charAt(0));
280 // We must set conservation and consensus before setting colour,
281 // as Blosum and Clustal require this to be done
282 if (hconsensus == null && !isDataset)
284 if (!alignment.isNucleotide())
286 showConservation = Cache.getDefault("SHOW_CONSERVATION", true);
287 showQuality = Cache.getDefault("SHOW_QUALITY", true);
288 showGroupConservation = Cache.getDefault("SHOW_GROUP_CONSERVATION",
291 showConsensusHistogram = Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM",
293 showSequenceLogo = Cache.getDefault("SHOW_CONSENSUS_LOGO", false);
294 normaliseSequenceLogo = Cache.getDefault("NORMALISE_CONSENSUS_LOGO",
296 showGroupConsensus = Cache.getDefault("SHOW_GROUP_CONSENSUS", false);
297 showConsensus = Cache.getDefault("SHOW_IDENTITY", true);
299 initAutoAnnotation();
300 String colourProperty = alignment.isNucleotide() ? Preferences.DEFAULT_COLOUR_NUC
301 : Preferences.DEFAULT_COLOUR_PROT;
302 String propertyValue = Cache.getProperty(colourProperty);
303 if (propertyValue == null)
305 // fall back on this property for backwards compatibility
306 propertyValue = Cache.getProperty(Preferences.DEFAULT_COLOUR);
308 if (propertyValue != null)
310 globalColourScheme = ColourSchemeProperty.getColour(alignment,
313 if (globalColourScheme instanceof UserColourScheme)
315 globalColourScheme = UserDefinedColours.loadDefaultColours();
316 ((UserColourScheme) globalColourScheme).setThreshold(0,
317 isIgnoreGapsConsensus());
320 if (globalColourScheme != null)
322 globalColourScheme.setConsensus(hconsensus);
328 * get the consensus sequence as displayed under the PID consensus annotation
331 * @return consensus sequence as a new sequence object
333 public SequenceI getConsensusSeq()
335 if (consensus == null)
337 updateConsensus(null);
339 if (consensus == null)
343 StringBuffer seqs = new StringBuffer();
344 for (int i = 0; i < consensus.annotations.length; i++)
346 if (consensus.annotations[i] != null)
348 if (consensus.annotations[i].description.charAt(0) == '[')
350 seqs.append(consensus.annotations[i].description.charAt(1));
354 seqs.append(consensus.annotations[i].displayCharacter);
359 SequenceI sq = new Sequence("Consensus", seqs.toString());
360 sq.setDescription("Percentage Identity Consensus "
361 + ((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
365 boolean validCharWidth;
368 * update view settings with the given font. You may need to call
369 * alignPanel.fontChanged to update the layout geometry
372 * when true, charWidth/height is set according to font mentrics
374 public void setFont(Font f, boolean setGrid)
378 Container c = new Container();
380 java.awt.FontMetrics fm = c.getFontMetrics(font);
381 int w = viewStyle.getCharWidth(), ww = fm.charWidth('M'), h = viewStyle
385 setCharHeight(fm.getHeight());
388 viewStyle.setFontName(font.getName());
389 viewStyle.setFontStyle(font.getStyle());
390 viewStyle.setFontSize(font.getSize());
392 validCharWidth = true;
396 public void setViewStyle(ViewStyleI settingsForView)
398 super.setViewStyle(settingsForView);
399 setFont(new Font(viewStyle.getFontName(), viewStyle.getFontStyle(),
400 viewStyle.getFontSize()), false);
407 * @return DOCUMENT ME!
409 public Font getFont()
420 public void setAlignment(AlignmentI align)
422 replaceMappings(align);
423 this.alignment = align;
427 * Replace any codon mappings for this viewport with those for the given
432 public void replaceMappings(AlignmentI align)
436 * Deregister current mappings (if any)
438 deregisterMappings();
441 * Register new mappings (if any)
445 StructureSelectionManager ssm = StructureSelectionManager
446 .getStructureSelectionManager(Desktop.instance);
447 ssm.registerMappings(align.getCodonFrames());
451 * replace mappings on our alignment
453 if (alignment != null && align != null)
455 alignment.setCodonFrames(align.getCodonFrames());
459 protected void deregisterMappings()
461 AlignmentI al = getAlignment();
464 Set<AlignedCodonFrame> mappings = al.getCodonFrames();
465 if (mappings != null)
467 StructureSelectionManager ssm = StructureSelectionManager
468 .getStructureSelectionManager(Desktop.instance);
469 for (AlignedCodonFrame acf : mappings)
471 if (noReferencesTo(acf))
473 ssm.deregisterMapping(acf);
483 * @return DOCUMENT ME!
485 public char getGapCharacter()
487 return getAlignment().getGapCharacter();
496 public void setGapCharacter(char gap)
498 if (getAlignment() != null)
500 getAlignment().setGapCharacter(gap);
507 * @return DOCUMENT ME!
509 public ColumnSelection getColumnSelection()
520 public void setCurrentTree(NJTree tree)
528 * @return DOCUMENT ME!
530 public NJTree getCurrentTree()
536 * returns the visible column regions of the alignment
538 * @param selectedRegionOnly
539 * true to just return the contigs intersecting with the selected
543 public int[] getViewAsVisibleContigs(boolean selectedRegionOnly)
545 int[] viscontigs = null;
546 int start = 0, end = 0;
547 if (selectedRegionOnly && selectionGroup != null)
549 start = selectionGroup.getStartRes();
550 end = selectionGroup.getEndRes() + 1;
554 end = alignment.getWidth();
556 viscontigs = colSel.getVisibleContigs(start, end);
561 * get hash of undo and redo list for the alignment
563 * @return long[] { historyList.hashCode, redoList.hashCode };
565 public long[] getUndoRedoHash()
568 if (historyList == null || redoList == null)
570 return new long[] { -1, -1 };
572 return new long[] { historyList.hashCode(), this.redoList.hashCode() };
576 * test if a particular set of hashcodes are different to the hashcodes for
577 * the undo and redo list.
580 * the stored set of hashcodes as returned by getUndoRedoHash
581 * @return true if the hashcodes differ (ie the alignment has been edited) or
582 * the stored hashcode array differs in size
584 public boolean isUndoRedoHashModified(long[] undoredo)
586 if (undoredo == null)
590 long[] cstate = getUndoRedoHash();
591 if (cstate.length != undoredo.length)
596 for (int i = 0; i < cstate.length; i++)
598 if (cstate[i] != undoredo[i])
606 public boolean followSelection = true;
609 * @return true if view selection should always follow the selections
610 * broadcast by other selection sources
612 public boolean getFollowSelection()
614 return followSelection;
618 * Send the current selection to be broadcast to any selection listeners.
620 public void sendSelection()
622 jalview.structure.StructureSelectionManager
623 .getStructureSelectionManager(Desktop.instance).sendSelection(
624 new SequenceGroup(getSelectionGroup()),
625 new ColumnSelection(getColumnSelection()), this);
629 * return the alignPanel containing the given viewport. Use this to get the
630 * components currently handling the given viewport.
633 * @return null or an alignPanel guaranteed to have non-null alignFrame
636 public AlignmentPanel getAlignPanel()
638 AlignmentPanel[] aps = PaintRefresher.getAssociatedPanels(this
639 .getSequenceSetId());
640 for (int p = 0; aps != null && p < aps.length; p++)
642 if (aps[p].av == this)
650 public boolean getSortByTree()
655 public void setSortByTree(boolean sort)
661 * synthesize a column selection if none exists so it covers the given
662 * selection group. if wholewidth is false, no column selection is made if the
663 * selection group covers the whole alignment width.
668 public void expandColSelection(SequenceGroup sg, boolean wholewidth)
672 && (sgs = sg.getStartRes()) >= 0
673 && sg.getStartRes() <= (sge = sg.getEndRes())
674 && (colSel == null || colSel.getSelected() == null || colSel
675 .getSelected().size() == 0))
677 if (!wholewidth && alignment.getWidth() == (1 + sge - sgs))
684 colSel = new ColumnSelection();
686 for (int cspos = sg.getStartRes(); cspos <= sg.getEndRes(); cspos++)
688 colSel.addElement(cspos);
694 * Returns the (Desktop) instance of the StructureSelectionManager
697 public StructureSelectionManager getStructureSelectionManager()
699 return StructureSelectionManager
700 .getStructureSelectionManager(Desktop.instance);
706 * @return an array of SequenceI arrays, one for each PDBEntry, listing which
707 * sequences in the alignment hold a reference to it
709 public SequenceI[][] collateForPDB(PDBEntry[] pdbEntries)
711 List<SequenceI[]> seqvectors = new ArrayList<SequenceI[]>();
712 for (PDBEntry pdb : pdbEntries)
714 List<SequenceI> seqs = new ArrayList<SequenceI>();
715 for (SequenceI sq : alignment.getSequences())
717 Vector<PDBEntry> pdbs = sq.getDatasetSequence().getAllPDBEntries();
722 for (PDBEntry p1 : pdbs)
724 if (p1.getId().equals(pdb.getId()))
726 if (!seqs.contains(sq))
734 seqvectors.add(seqs.toArray(new SequenceI[seqs.size()]));
736 return seqvectors.toArray(new SequenceI[seqvectors.size()][]);
739 public boolean isNormaliseSequenceLogo()
741 return normaliseSequenceLogo;
744 public void setNormaliseSequenceLogo(boolean state)
746 normaliseSequenceLogo = state;
751 * @return true if alignment characters should be displayed
753 public boolean isValidCharWidth()
755 return validCharWidth;
758 private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<String, AutoCalcSetting>();
760 public AutoCalcSetting getCalcIdSettingsFor(String calcId)
762 return calcIdParams.get(calcId);
765 public void setCalcIdSettingsFor(String calcId, AutoCalcSetting settings,
768 calcIdParams.put(calcId, settings);
769 // TODO: create a restart list to trigger any calculations that need to be
770 // restarted after load
771 // calculator.getRegisteredWorkersOfClass(settings.getWorkerClass())
774 Cache.log.debug("trigger update for " + calcId);
779 * Method called when another alignment's edit (or possibly other) command is
782 * To allow for sequence mappings (e.g. protein to cDNA), we have to first
783 * 'unwind' the command on the source sequences (in simulation, not in fact),
784 * and then for each edit in turn:
786 * <li>compute the equivalent edit on the mapped sequences</li>
787 * <li>apply the mapped edit</li>
788 * <li>'apply' the source edit to the working copy of the source sequences</li>
796 public void mirrorCommand(CommandI command, boolean undo,
797 StructureSelectionManager ssm, VamsasSource source)
800 * Do nothing unless we are a 'complement' of the source. May replace this
801 * with direct calls not via SSM.
803 if (source instanceof AlignViewportI
804 && ((AlignViewportI) source).getCodingComplement() == this)
813 CommandI mappedCommand = ssm.mapCommand(command, undo, getAlignment(),
815 if (mappedCommand != null)
817 AlignmentI[] views = getAlignPanel().alignFrame.getViewAlignments();
818 mappedCommand.doCommand(views);
819 getAlignPanel().alignmentChanged();
824 * Add the sequences from the given alignment to this viewport. Optionally,
825 * may give the user the option to open a new frame, or split panel, with cDNA
826 * and protein linked.
831 public void addAlignment(AlignmentI al, String title)
833 // TODO: promote to AlignViewportI? applet CutAndPasteTransfer is different
835 // JBPComment: title is a largely redundant parameter at the moment
836 // JBPComment: this really should be an 'insert/pre/append' controller
837 // JBPComment: but the DNA/Protein check makes it a bit more complex
839 // refactored from FileLoader / CutAndPasteTransfer / SequenceFetcher with
841 // TODO: create undo object for this JAL-1101
844 * If any cDNA/protein mappings can be made between the alignments, offer to
845 * open a linked alignment with split frame option.
847 if (Cache.getDefault(Preferences.ENABLE_SPLIT_FRAME, true))
849 if (al.getDataset() == null)
851 // need to create ds seqs
852 for (SequenceI sq : al.getSequences())
854 if (sq.getDatasetSequence() == null)
856 sq.createDatasetSequence();
860 if (AlignmentUtils.isMappable(al, getAlignment()))
862 if (openLinkedAlignment(al, title))
870 * No mappings, or offer declined - add sequences to this alignment
872 // TODO: JAL-407 regardless of above - identical sequences (based on ID and
873 // provenance) should share the same dataset sequence
875 for (int i = 0; i < al.getHeight(); i++)
877 getAlignment().addSequence(al.getSequenceAt(i));
880 setEndSeq(getAlignment().getHeight());
881 firePropertyChange("alignment", null, getAlignment().getSequences());
885 * Show a dialog with the option to open and link (cDNA <-> protein) as a new
886 * alignment, either as a standalone alignment or in a split frame. Returns
887 * true if the new alignment was opened, false if not, because the user
888 * declined the offer.
893 protected boolean openLinkedAlignment(AlignmentI al, String title)
895 String[] options = new String[] {
896 MessageManager.getString("action.no"),
897 MessageManager.getString("label.split_window"),
898 MessageManager.getString("label.new_window"), };
899 final String question = JvSwingUtils.wrapTooltip(true,
900 MessageManager.getString("label.open_split_window?"));
901 int response = JOptionPane.showOptionDialog(Desktop.desktop, question,
902 MessageManager.getString("label.open_split_window"),
903 JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null,
904 options, options[0]);
906 if (response != 1 && response != 2)
910 final boolean openSplitPane = (response == 1);
911 final boolean openInNewWindow = (response == 2);
914 * Identify protein and dna alignments. Make a copy of this one if opening
915 * in a new split pane.
917 AlignmentI thisAlignment = openSplitPane ? new Alignment(getAlignment())
919 AlignmentI protein = al.isNucleotide() ? thisAlignment : al;
920 final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment;
923 * Map sequences. At least one should get mapped as we have already passed
924 * the test for 'mappability'. Any mappings made will be added to the
925 * protein alignment. Note creating dataset sequences on the new alignment
926 * is a pre-requisite for building mappings.
929 AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna);
932 * Create the AlignFrame for the added alignment. If it is protein, mappings
933 * are registered with StructureSelectionManager as a side-effect.
935 AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
936 AlignFrame.DEFAULT_HEIGHT);
937 newAlignFrame.setTitle(title);
938 newAlignFrame.statusBar.setText(MessageManager.formatMessage(
939 "label.successfully_loaded_file", new Object[] { title }));
941 // TODO if we want this (e.g. to enable reload of the alignment from file),
942 // we will need to add parameters to the stack.
943 // if (!protocol.equals(AppletFormatAdapter.PASTE))
945 // alignFrame.setFileName(file, format);
950 Desktop.addInternalFrame(newAlignFrame, title,
951 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
956 newAlignFrame.setMaximum(jalview.bin.Cache.getDefault(
957 "SHOW_FULLSCREEN", false));
958 } catch (java.beans.PropertyVetoException ex)
964 al.alignAs(thisAlignment);
965 protein = openSplitFrame(newAlignFrame, thisAlignment);
972 * Helper method to open a new SplitFrame holding linked dna and protein
975 * @param newAlignFrame
976 * containing a new alignment to be shown
978 * cdna/protein complement alignment to show in the other split half
979 * @return the protein alignment in the split frame
981 protected AlignmentI openSplitFrame(AlignFrame newAlignFrame,
982 AlignmentI complement)
985 * Make a new frame with a copy of the alignment we are adding to. If this
986 * is protein, the mappings to cDNA will be registered with
987 * StructureSelectionManager as a side-effect.
989 AlignFrame copyMe = new AlignFrame(complement,
990 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
991 copyMe.setTitle(getAlignPanel().alignFrame.getTitle());
993 AlignmentI al = newAlignFrame.viewport.getAlignment();
994 final AlignFrame proteinFrame = al.isNucleotide() ? copyMe
996 final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame : copyMe;
997 cdnaFrame.setVisible(true);
998 proteinFrame.setVisible(true);
999 String linkedTitle = MessageManager
1000 .getString("label.linked_view_title");
1003 * Open in split pane. DNA sequence above, protein below.
1005 JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame);
1006 Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1);
1008 return proteinFrame.viewport.getAlignment();
1011 public AnnotationColumnChooser getAnnotationColumnSelectionState()
1013 return annotationColumnSelectionState;
1016 public void setAnnotationColumnSelectionState(
1017 AnnotationColumnChooser currentAnnotationColumnSelectionState)
1019 this.annotationColumnSelectionState = currentAnnotationColumnSelectionState;
1023 public void setIdWidth(int i)
1025 super.setIdWidth(i);
1026 AlignmentPanel ap = getAlignPanel();
1029 // modify GUI elements to reflect geometry change
1030 Dimension idw = getAlignPanel().getIdPanel().getIdCanvas()
1031 .getPreferredSize();
1033 getAlignPanel().getIdPanel().getIdCanvas().setPreferredSize(idw);
1037 public Rectangle getExplodedGeometry()
1039 return explodedGeometry;
1042 public void setExplodedGeometry(Rectangle explodedPosition)
1044 this.explodedGeometry = explodedPosition;
1047 public boolean isGatherViewsHere()
1049 return gatherViewsHere;
1052 public void setGatherViewsHere(boolean gatherViewsHere)
1054 this.gatherViewsHere = gatherViewsHere;
1058 * If this viewport has a (Protein/cDNA) complement, then scroll the
1059 * complementary alignment to match this one.
1061 public void scrollComplementaryAlignment()
1064 * Populate a SearchResults object with the mapped location to scroll to. If
1065 * there is no complement, or it is not following highlights, or no mapping
1066 * is found, the result will be empty.
1068 SearchResults sr = new SearchResults();
1069 int verticalOffset = findComplementScrollTarget(sr);
1072 // TODO would like next line without cast but needs more refactoring...
1073 final AlignmentPanel complementPanel = ((AlignViewport) getCodingComplement())
1075 complementPanel.setFollowingComplementScroll(true);
1076 complementPanel.scrollToCentre(sr, verticalOffset);
1081 * Answers true if no alignment holds a reference to the given mapping
1086 protected boolean noReferencesTo(AlignedCodonFrame acf)
1088 AlignFrame[] frames = Desktop.getAlignFrames();
1093 for (AlignFrame af : frames)
1097 for (AlignmentViewPanel ap : af.getAlignPanels())
1099 AlignmentI al = ap.getAlignment();
1100 if (al != null && al.getCodonFrames().contains(acf))