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;
75 import java.util.Vector;
77 import javax.swing.JInternalFrame;
78 import javax.swing.JOptionPane;
84 * @version $Revision: 1.141 $
86 public class AlignViewport extends AlignmentViewport implements
87 SelectionSource, CommandListener
91 NJTree currentTree = null;
93 boolean cursorMode = false;
95 boolean antiAlias = false;
97 private Rectangle explodedGeometry;
102 * Flag set true on the view that should 'gather' multiple views of the same
103 * sequence set id when a project is reloaded. Set false on all views when
104 * they are 'exploded' into separate windows. Set true on the current view
105 * when 'Gather' is performed, and also on the first tab when the first new
108 private boolean gatherViewsHere = false;
110 private AnnotationColumnChooser annotationColumnSelectionState;
113 * Creates a new AlignViewport object.
118 public AlignViewport(AlignmentI al)
125 * Create a new AlignViewport object with a specific sequence set ID
129 * (may be null - but potential for ambiguous constructor exception)
131 public AlignViewport(AlignmentI al, String seqsetid)
133 this(al, seqsetid, null);
136 public AlignViewport(AlignmentI al, String seqsetid, String viewid)
138 sequenceSetID = seqsetid;
140 // TODO remove these once 2.4.VAMSAS release finished
141 if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null)
143 Cache.log.debug("Setting viewport's sequence set id : "
146 if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null)
148 Cache.log.debug("Setting viewport's view id : " + viewId);
155 * Create a new AlignViewport with hidden regions
159 * @param hiddenColumns
162 public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns)
165 if (hiddenColumns != null)
167 colSel = hiddenColumns;
173 * New viewport with hidden columns and an existing sequence set id
176 * @param hiddenColumns
180 public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns,
183 this(al, hiddenColumns, seqsetid, null);
187 * New viewport with hidden columns and an existing sequence set id and viewid
190 * @param hiddenColumns
196 public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns,
197 String seqsetid, String viewid)
199 sequenceSetID = seqsetid;
201 // TODO remove these once 2.4.VAMSAS release finished
202 if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null)
204 Cache.log.debug("Setting viewport's sequence set id : "
207 if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null)
209 Cache.log.debug("Setting viewport's view id : " + viewId);
212 if (hiddenColumns != null)
214 colSel = hiddenColumns;
220 * Apply any settings saved in user preferences
222 private void applyViewProperties()
224 antiAlias = Cache.getDefault("ANTI_ALIAS", false);
226 viewStyle.setShowJVSuffix(Cache.getDefault("SHOW_JVSUFFIX", true));
227 setShowAnnotation(Cache.getDefault("SHOW_ANNOTATIONS", true));
229 setRightAlignIds(Cache.getDefault("RIGHT_ALIGN_IDS", false));
230 setCentreColumnLabels(Cache.getDefault("CENTRE_COLUMN_LABELS", false));
231 autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
233 setPadGaps(Cache.getDefault("PAD_GAPS", true));
234 setShowNPFeats(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
235 setShowDBRefs(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
236 viewStyle.setSeqNameItalics(Cache.getDefault("ID_ITALICS", true));
237 viewStyle.setWrapAlignment(Cache.getDefault("WRAP_ALIGNMENT", false));
238 viewStyle.setShowUnconserved(Cache
239 .getDefault("SHOW_UNCONSERVED", false));
240 sortByTree = Cache.getDefault("SORT_BY_TREE", false);
241 followSelection = Cache.getDefault("FOLLOW_SELECTIONS", true);
242 sortAnnotationsBy = SequenceAnnotationOrder.valueOf(Cache.getDefault(
243 Preferences.SORT_ANNOTATIONS,
244 SequenceAnnotationOrder.NONE.name()));
245 showAutocalculatedAbove = Cache.getDefault(
246 Preferences.SHOW_AUTOCALC_ABOVE, false);
247 viewStyle.setScaleProteinAsCdna(Cache.getDefault(
248 Preferences.SCALE_PROTEIN_TO_CDNA, true));
254 this.endRes = alignment.getWidth() - 1;
256 this.endSeq = alignment.getHeight() - 1;
257 applyViewProperties();
259 String fontName = Cache.getDefault("FONT_NAME", "SansSerif");
260 String fontStyle = Cache.getDefault("FONT_STYLE", Font.PLAIN + "");
261 String fontSize = Cache.getDefault("FONT_SIZE", "10");
265 if (fontStyle.equals("bold"))
269 else if (fontStyle.equals("italic"))
274 setFont(new Font(fontName, style, Integer.parseInt(fontSize)), true);
277 .setGapCharacter(Cache.getDefault("GAP_SYMBOL", "-").charAt(0));
279 // We must set conservation and consensus before setting colour,
280 // as Blosum and Clustal require this to be done
281 if (hconsensus == null && !isDataset)
283 if (!alignment.isNucleotide())
285 showConservation = Cache.getDefault("SHOW_CONSERVATION", true);
286 showQuality = Cache.getDefault("SHOW_QUALITY", true);
287 showGroupConservation = Cache.getDefault("SHOW_GROUP_CONSERVATION",
290 showConsensusHistogram = Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM",
292 showSequenceLogo = Cache.getDefault("SHOW_CONSENSUS_LOGO", false);
293 normaliseSequenceLogo = Cache.getDefault("NORMALISE_CONSENSUS_LOGO",
295 showGroupConsensus = Cache.getDefault("SHOW_GROUP_CONSENSUS", false);
296 showConsensus = Cache.getDefault("SHOW_IDENTITY", true);
298 initAutoAnnotation();
299 String colourProperty = alignment.isNucleotide() ? Preferences.DEFAULT_COLOUR_NUC
300 : Preferences.DEFAULT_COLOUR_PROT;
301 String propertyValue = Cache.getProperty(colourProperty);
302 if (propertyValue == null)
304 // fall back on this property for backwards compatibility
305 propertyValue = Cache.getProperty(Preferences.DEFAULT_COLOUR);
307 if (propertyValue != null)
309 globalColourScheme = ColourSchemeProperty.getColour(alignment,
312 if (globalColourScheme instanceof UserColourScheme)
314 globalColourScheme = UserDefinedColours.loadDefaultColours();
315 ((UserColourScheme) globalColourScheme).setThreshold(0,
316 isIgnoreGapsConsensus());
319 if (globalColourScheme != null)
321 globalColourScheme.setConsensus(hconsensus);
327 * get the consensus sequence as displayed under the PID consensus annotation
330 * @return consensus sequence as a new sequence object
332 public SequenceI getConsensusSeq()
334 if (consensus == null)
336 updateConsensus(null);
338 if (consensus == null)
342 StringBuffer seqs = new StringBuffer();
343 for (int i = 0; i < consensus.annotations.length; i++)
345 if (consensus.annotations[i] != null)
347 if (consensus.annotations[i].description.charAt(0) == '[')
349 seqs.append(consensus.annotations[i].description.charAt(1));
353 seqs.append(consensus.annotations[i].displayCharacter);
358 SequenceI sq = new Sequence("Consensus", seqs.toString());
359 sq.setDescription("Percentage Identity Consensus "
360 + ((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
364 boolean validCharWidth;
367 * update view settings with the given font. You may need to call
368 * alignPanel.fontChanged to update the layout geometry
371 * when true, charWidth/height is set according to font mentrics
373 public void setFont(Font f, boolean setGrid)
377 Container c = new Container();
379 java.awt.FontMetrics fm = c.getFontMetrics(font);
380 int w = viewStyle.getCharWidth(), ww = fm.charWidth('M'), h = viewStyle
384 setCharHeight(fm.getHeight());
387 viewStyle.setFontName(font.getName());
388 viewStyle.setFontStyle(font.getStyle());
389 viewStyle.setFontSize(font.getSize());
391 validCharWidth = true;
395 public void setViewStyle(ViewStyleI settingsForView)
397 super.setViewStyle(settingsForView);
398 setFont(new Font(viewStyle.getFontName(), viewStyle.getFontStyle(),
399 viewStyle.getFontSize()), false);
406 * @return DOCUMENT ME!
408 public Font getFont()
419 public void setAlignment(AlignmentI align)
421 replaceMappings(align);
422 this.alignment = align;
426 * Replace any codon mappings for this viewport with those for the given
431 public void replaceMappings(AlignmentI align)
435 * Deregister current mappings (if any)
437 deregisterMappings();
440 * Register new mappings (if any)
444 StructureSelectionManager ssm = StructureSelectionManager
445 .getStructureSelectionManager(Desktop.instance);
446 ssm.registerMappings(align.getCodonFrames());
450 * replace mappings on our alignment
452 if (alignment != null && align != null)
454 alignment.setCodonFrames(align.getCodonFrames());
458 protected void deregisterMappings()
460 AlignmentI al = getAlignment();
463 List<AlignedCodonFrame> mappings = al.getCodonFrames();
464 if (mappings != null)
466 StructureSelectionManager ssm = StructureSelectionManager
467 .getStructureSelectionManager(Desktop.instance);
468 for (AlignedCodonFrame acf : mappings)
470 if (noReferencesTo(acf))
472 ssm.deregisterMapping(acf);
482 * @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!
510 public ColumnSelection getColumnSelection()
521 public void setCurrentTree(NJTree tree)
529 * @return DOCUMENT ME!
531 public NJTree getCurrentTree()
537 * returns the visible column regions of the alignment
539 * @param selectedRegionOnly
540 * true to just return the contigs intersecting with the selected
544 public int[] getViewAsVisibleContigs(boolean selectedRegionOnly)
546 int[] viscontigs = null;
547 int start = 0, end = 0;
548 if (selectedRegionOnly && selectionGroup != null)
550 start = selectionGroup.getStartRes();
551 end = selectionGroup.getEndRes() + 1;
555 end = alignment.getWidth();
557 viscontigs = colSel.getVisibleContigs(start, end);
562 * get hash of undo and redo list for the alignment
564 * @return long[] { historyList.hashCode, redoList.hashCode };
566 public long[] getUndoRedoHash()
569 if (historyList == null || redoList == null)
571 return new long[] { -1, -1 };
573 return new long[] { historyList.hashCode(), this.redoList.hashCode() };
577 * test if a particular set of hashcodes are different to the hashcodes for
578 * the undo and redo list.
581 * the stored set of hashcodes as returned by getUndoRedoHash
582 * @return true if the hashcodes differ (ie the alignment has been edited) or
583 * the stored hashcode array differs in size
585 public boolean isUndoRedoHashModified(long[] undoredo)
587 if (undoredo == null)
591 long[] cstate = getUndoRedoHash();
592 if (cstate.length != undoredo.length)
597 for (int i = 0; i < cstate.length; i++)
599 if (cstate[i] != undoredo[i])
607 public boolean followSelection = true;
610 * @return true if view selection should always follow the selections
611 * broadcast by other selection sources
613 public boolean getFollowSelection()
615 return followSelection;
619 * Send the current selection to be broadcast to any selection listeners.
622 public void sendSelection()
624 jalview.structure.StructureSelectionManager
625 .getStructureSelectionManager(Desktop.instance).sendSelection(
626 new SequenceGroup(getSelectionGroup()),
627 new ColumnSelection(getColumnSelection()), this);
631 * return the alignPanel containing the given viewport. Use this to get the
632 * components currently handling the given viewport.
635 * @return null or an alignPanel guaranteed to have non-null alignFrame
638 public AlignmentPanel getAlignPanel()
640 AlignmentPanel[] aps = PaintRefresher.getAssociatedPanels(this
641 .getSequenceSetId());
642 for (int p = 0; aps != null && p < aps.length; p++)
644 if (aps[p].av == this)
652 public boolean getSortByTree()
657 public void setSortByTree(boolean sort)
663 * synthesize a column selection if none exists so it covers the given
664 * selection group. if wholewidth is false, no column selection is made if the
665 * selection group covers the whole alignment width.
670 public void expandColSelection(SequenceGroup sg, boolean wholewidth)
674 && (sgs = sg.getStartRes()) >= 0
675 && sg.getStartRes() <= (sge = sg.getEndRes())
676 && (colSel == null || colSel.getSelected() == null || colSel
677 .getSelected().size() == 0))
679 if (!wholewidth && alignment.getWidth() == (1 + sge - sgs))
686 colSel = new ColumnSelection();
688 for (int cspos = sg.getStartRes(); cspos <= sg.getEndRes(); cspos++)
690 colSel.addElement(cspos);
696 * Returns the (Desktop) instance of the StructureSelectionManager
699 public StructureSelectionManager getStructureSelectionManager()
701 return StructureSelectionManager
702 .getStructureSelectionManager(Desktop.instance);
708 * @return an array of SequenceI arrays, one for each PDBEntry, listing which
709 * sequences in the alignment hold a reference to it
711 public SequenceI[][] collateForPDB(PDBEntry[] pdbEntries)
713 List<SequenceI[]> seqvectors = new ArrayList<SequenceI[]>();
714 for (PDBEntry pdb : pdbEntries)
716 List<SequenceI> seqs = new ArrayList<SequenceI>();
717 for (SequenceI sq : alignment.getSequences())
719 Vector<PDBEntry> pdbs = sq.getDatasetSequence().getAllPDBEntries();
724 for (PDBEntry p1 : pdbs)
726 if (p1.getId().equals(pdb.getId()))
728 if (!seqs.contains(sq))
736 seqvectors.add(seqs.toArray(new SequenceI[seqs.size()]));
738 return seqvectors.toArray(new SequenceI[seqvectors.size()][]);
742 public boolean isNormaliseSequenceLogo()
744 return normaliseSequenceLogo;
747 public void setNormaliseSequenceLogo(boolean state)
749 normaliseSequenceLogo = state;
754 * @return true if alignment characters should be displayed
757 public boolean isValidCharWidth()
759 return validCharWidth;
762 private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<String, AutoCalcSetting>();
764 public AutoCalcSetting getCalcIdSettingsFor(String calcId)
766 return calcIdParams.get(calcId);
769 public void setCalcIdSettingsFor(String calcId, AutoCalcSetting settings,
772 calcIdParams.put(calcId, settings);
773 // TODO: create a restart list to trigger any calculations that need to be
774 // restarted after load
775 // calculator.getRegisteredWorkersOfClass(settings.getWorkerClass())
778 Cache.log.debug("trigger update for " + calcId);
783 * Method called when another alignment's edit (or possibly other) command is
786 * To allow for sequence mappings (e.g. protein to cDNA), we have to first
787 * 'unwind' the command on the source sequences (in simulation, not in fact),
788 * and then for each edit in turn:
790 * <li>compute the equivalent edit on the mapped sequences</li>
791 * <li>apply the mapped edit</li>
792 * <li>'apply' the source edit to the working copy of the source sequences</li>
800 public void mirrorCommand(CommandI command, boolean undo,
801 StructureSelectionManager ssm, VamsasSource source)
804 * Do nothing unless we are a 'complement' of the source. May replace this
805 * with direct calls not via SSM.
807 if (source instanceof AlignViewportI
808 && ((AlignViewportI) source).getCodingComplement() == this)
817 CommandI mappedCommand = ssm.mapCommand(command, undo, getAlignment(),
819 if (mappedCommand != null)
821 AlignmentI[] views = getAlignPanel().alignFrame.getViewAlignments();
822 mappedCommand.doCommand(views);
823 getAlignPanel().alignmentChanged();
828 * Add the sequences from the given alignment to this viewport. Optionally,
829 * may give the user the option to open a new frame, or split panel, with cDNA
830 * and protein linked.
835 public void addAlignment(AlignmentI toAdd, String title)
837 // TODO: promote to AlignViewportI? applet CutAndPasteTransfer is different
839 // JBPComment: title is a largely redundant parameter at the moment
840 // JBPComment: this really should be an 'insert/pre/append' controller
841 // JBPComment: but the DNA/Protein check makes it a bit more complex
843 // refactored from FileLoader / CutAndPasteTransfer / SequenceFetcher with
845 // TODO: create undo object for this JAL-1101
848 * Ensure datasets are created for the new alignment as
849 * mappings operate on dataset sequences
851 toAdd.setDataset(null);
854 * Check if any added sequence could be the object of a mapping or
855 * cross-reference; if so, make the mapping explicit
857 getAlignment().realiseMappings(toAdd.getSequences());
860 * If any cDNA/protein mappings exist or can be made between the alignments,
861 * offer to open a split frame with linked alignments
863 if (Cache.getDefault(Preferences.ENABLE_SPLIT_FRAME, true))
865 if (AlignmentUtils.isMappable(toAdd, getAlignment()))
867 if (openLinkedAlignment(toAdd, title))
875 * No mappings, or offer declined - add sequences to this alignment
877 // TODO: JAL-407 regardless of above - identical sequences (based on ID and
878 // provenance) should share the same dataset sequence
880 AlignmentI al = getAlignment();
881 String gap = String.valueOf(al.getGapCharacter());
882 for (int i = 0; i < toAdd.getHeight(); i++)
884 SequenceI seq = toAdd.getSequenceAt(i);
887 * - 'align' any mapped sequences as per existing
888 * e.g. cdna to genome, domain hit to protein sequence
889 * very experimental! (need a separate menu option for this)
890 * - only add mapped sequences ('select targets from a dataset')
892 if (true /*AlignmentUtils.alignSequenceAs(seq, al, gap, true, true)*/)
898 setEndSeq(getAlignment().getHeight());
899 firePropertyChange("alignment", null, getAlignment().getSequences());
903 * Show a dialog with the option to open and link (cDNA <-> protein) as a new
904 * alignment, either as a standalone alignment or in a split frame. Returns
905 * true if the new alignment was opened, false if not, because the user
906 * declined the offer.
911 protected boolean openLinkedAlignment(AlignmentI al, String title)
913 String[] options = new String[] {
914 MessageManager.getString("action.no"),
915 MessageManager.getString("label.split_window"),
916 MessageManager.getString("label.new_window"), };
917 final String question = JvSwingUtils.wrapTooltip(true,
918 MessageManager.getString("label.open_split_window?"));
919 int response = JOptionPane.showOptionDialog(Desktop.desktop, question,
920 MessageManager.getString("label.open_split_window"),
921 JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null,
922 options, options[0]);
924 if (response != 1 && response != 2)
928 final boolean openSplitPane = (response == 1);
929 final boolean openInNewWindow = (response == 2);
932 * Identify protein and dna alignments. Make a copy of this one if opening
933 * in a new split pane.
935 AlignmentI thisAlignment = openSplitPane ? new Alignment(getAlignment())
937 AlignmentI protein = al.isNucleotide() ? thisAlignment : al;
938 final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment;
941 * Map sequences. At least one should get mapped as we have already passed
942 * the test for 'mappability'. Any mappings made will be added to the
943 * protein alignment. Note creating dataset sequences on the new alignment
944 * is a pre-requisite for building mappings.
947 AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna);
950 * Create the AlignFrame for the added alignment. If it is protein, mappings
951 * are registered with StructureSelectionManager as a side-effect.
953 AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
954 AlignFrame.DEFAULT_HEIGHT);
955 newAlignFrame.setTitle(title);
956 newAlignFrame.statusBar.setText(MessageManager.formatMessage(
957 "label.successfully_loaded_file", new Object[] { title }));
959 // TODO if we want this (e.g. to enable reload of the alignment from file),
960 // we will need to add parameters to the stack.
961 // if (!protocol.equals(AppletFormatAdapter.PASTE))
963 // alignFrame.setFileName(file, format);
968 Desktop.addInternalFrame(newAlignFrame, title,
969 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
974 newAlignFrame.setMaximum(jalview.bin.Cache.getDefault(
975 "SHOW_FULLSCREEN", false));
976 } catch (java.beans.PropertyVetoException ex)
982 al.alignAs(thisAlignment);
983 protein = openSplitFrame(newAlignFrame, thisAlignment);
990 * Helper method to open a new SplitFrame holding linked dna and protein
993 * @param newAlignFrame
994 * containing a new alignment to be shown
996 * cdna/protein complement alignment to show in the other split half
997 * @return the protein alignment in the split frame
999 protected AlignmentI openSplitFrame(AlignFrame newAlignFrame,
1000 AlignmentI complement)
1003 * Make a new frame with a copy of the alignment we are adding to. If this
1004 * is protein, the mappings to cDNA will be registered with
1005 * StructureSelectionManager as a side-effect.
1007 AlignFrame copyMe = new AlignFrame(complement,
1008 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
1009 copyMe.setTitle(getAlignPanel().alignFrame.getTitle());
1011 AlignmentI al = newAlignFrame.viewport.getAlignment();
1012 final AlignFrame proteinFrame = al.isNucleotide() ? copyMe
1014 final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame : copyMe;
1015 cdnaFrame.setVisible(true);
1016 proteinFrame.setVisible(true);
1017 String linkedTitle = MessageManager
1018 .getString("label.linked_view_title");
1021 * Open in split pane. DNA sequence above, protein below.
1023 JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame);
1024 Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1);
1026 return proteinFrame.viewport.getAlignment();
1029 public AnnotationColumnChooser getAnnotationColumnSelectionState()
1031 return annotationColumnSelectionState;
1034 public void setAnnotationColumnSelectionState(
1035 AnnotationColumnChooser currentAnnotationColumnSelectionState)
1037 this.annotationColumnSelectionState = currentAnnotationColumnSelectionState;
1041 public void setIdWidth(int i)
1043 super.setIdWidth(i);
1044 AlignmentPanel ap = getAlignPanel();
1047 // modify GUI elements to reflect geometry change
1048 Dimension idw = getAlignPanel().getIdPanel().getIdCanvas()
1049 .getPreferredSize();
1051 getAlignPanel().getIdPanel().getIdCanvas().setPreferredSize(idw);
1055 public Rectangle getExplodedGeometry()
1057 return explodedGeometry;
1060 public void setExplodedGeometry(Rectangle explodedPosition)
1062 this.explodedGeometry = explodedPosition;
1065 public boolean isGatherViewsHere()
1067 return gatherViewsHere;
1070 public void setGatherViewsHere(boolean gatherViewsHere)
1072 this.gatherViewsHere = gatherViewsHere;
1076 * If this viewport has a (Protein/cDNA) complement, then scroll the
1077 * complementary alignment to match this one.
1079 public void scrollComplementaryAlignment()
1082 * Populate a SearchResults object with the mapped location to scroll to. If
1083 * there is no complement, or it is not following highlights, or no mapping
1084 * is found, the result will be empty.
1086 SearchResults sr = new SearchResults();
1087 int verticalOffset = findComplementScrollTarget(sr);
1090 // TODO would like next line without cast but needs more refactoring...
1091 final AlignmentPanel complementPanel = ((AlignViewport) getCodingComplement())
1093 complementPanel.setDontScrollComplement(true);
1094 complementPanel.scrollToCentre(sr, verticalOffset);
1099 * Answers true if no alignment holds a reference to the given mapping
1104 protected boolean noReferencesTo(AlignedCodonFrame acf)
1106 AlignFrame[] frames = Desktop.getAlignFrames();
1111 for (AlignFrame af : frames)
1115 for (AlignmentViewPanel ap : af.getAlignPanels())
1117 AlignmentI al = ap.getAlignment();
1118 if (al != null && al.getCodonFrames().contains(acf))