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.
23 import jalview.analysis.AlignmentUtils;
24 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
25 import jalview.analysis.NJTree;
26 import jalview.api.AlignViewportI;
27 import jalview.api.AlignmentViewPanel;
28 import jalview.api.FeatureColourI;
29 import jalview.api.FeatureSettingsModelI;
30 import jalview.api.FeaturesDisplayedI;
31 import jalview.api.ViewStyleI;
32 import jalview.bin.Cache;
33 import jalview.commands.CommandI;
34 import jalview.datamodel.AlignedCodonFrame;
35 import jalview.datamodel.Alignment;
36 import jalview.datamodel.AlignmentI;
37 import jalview.datamodel.ColumnSelection;
38 import jalview.datamodel.HiddenColumns;
39 import jalview.datamodel.PDBEntry;
40 import jalview.datamodel.SearchResults;
41 import jalview.datamodel.SearchResultsI;
42 import jalview.datamodel.Sequence;
43 import jalview.datamodel.SequenceGroup;
44 import jalview.datamodel.SequenceI;
45 import jalview.renderer.ResidueShader;
46 import jalview.schemes.ColourSchemeI;
47 import jalview.schemes.ColourSchemeProperty;
48 import jalview.schemes.ResidueColourScheme;
49 import jalview.schemes.UserColourScheme;
50 import jalview.structure.SelectionSource;
51 import jalview.structure.StructureSelectionManager;
52 import jalview.structure.VamsasSource;
53 import jalview.util.MessageManager;
54 import jalview.viewmodel.AlignmentViewport;
55 import jalview.viewmodel.ViewportRanges;
56 import jalview.ws.params.AutoCalcSetting;
58 import java.awt.Container;
59 import java.awt.Dimension;
61 import java.awt.Rectangle;
62 import java.util.ArrayList;
63 import java.util.Hashtable;
64 import java.util.List;
65 import java.util.Vector;
67 import javax.swing.JInternalFrame;
73 * @version $Revision: 1.141 $
75 public class AlignViewport extends AlignmentViewport implements
80 NJTree currentTree = null;
82 boolean cursorMode = false;
84 boolean antiAlias = false;
86 private Rectangle explodedGeometry;
91 * Flag set true on the view that should 'gather' multiple views of the same
92 * sequence set id when a project is reloaded. Set false on all views when
93 * they are 'exploded' into separate windows. Set true on the current view
94 * when 'Gather' is performed, and also on the first tab when the first new
97 private boolean gatherViewsHere = false;
99 private AnnotationColumnChooser annotationColumnSelectionState;
102 * Creates a new AlignViewport object.
107 public AlignViewport(AlignmentI al)
114 * Create a new AlignViewport object with a specific sequence set ID
118 * (may be null - but potential for ambiguous constructor exception)
120 public AlignViewport(AlignmentI al, String seqsetid)
122 this(al, seqsetid, null);
125 public AlignViewport(AlignmentI al, String seqsetid, String viewid)
127 sequenceSetID = seqsetid;
129 // TODO remove these once 2.4.VAMSAS release finished
130 if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null)
132 Cache.log.debug("Setting viewport's sequence set id : "
135 if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null)
137 Cache.log.debug("Setting viewport's view id : " + viewId);
144 * Create a new AlignViewport with hidden regions
148 * @param hiddenColumns
151 public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns)
154 if (hiddenColumns != null)
156 al.setHiddenColumns(hiddenColumns);
162 * New viewport with hidden columns and an existing sequence set id
165 * @param hiddenColumns
169 public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns,
172 this(al, hiddenColumns, seqsetid, null);
176 * New viewport with hidden columns and an existing sequence set id and viewid
179 * @param hiddenColumns
185 public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns,
186 String seqsetid, String viewid)
188 sequenceSetID = seqsetid;
190 // TODO remove these once 2.4.VAMSAS release finished
191 if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null)
193 Cache.log.debug("Setting viewport's sequence set id : "
196 if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null)
198 Cache.log.debug("Setting viewport's view id : " + viewId);
201 if (hiddenColumns != null)
203 al.setHiddenColumns(hiddenColumns);
209 * Apply any settings saved in user preferences
211 private void applyViewProperties()
213 antiAlias = Cache.getDefault("ANTI_ALIAS", false);
215 viewStyle.setShowJVSuffix(Cache.getDefault("SHOW_JVSUFFIX", true));
216 setShowAnnotation(Cache.getDefault("SHOW_ANNOTATIONS", true));
218 setRightAlignIds(Cache.getDefault("RIGHT_ALIGN_IDS", false));
219 setCentreColumnLabels(Cache.getDefault("CENTRE_COLUMN_LABELS", false));
220 autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
222 setPadGaps(Cache.getDefault("PAD_GAPS", true));
223 setShowNPFeats(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
224 setShowDBRefs(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
225 viewStyle.setSeqNameItalics(Cache.getDefault("ID_ITALICS", true));
226 viewStyle.setWrapAlignment(Cache.getDefault("WRAP_ALIGNMENT", false));
227 viewStyle.setShowUnconserved(Cache
228 .getDefault("SHOW_UNCONSERVED", false));
229 sortByTree = Cache.getDefault("SORT_BY_TREE", false);
230 followSelection = Cache.getDefault("FOLLOW_SELECTIONS", true);
231 sortAnnotationsBy = SequenceAnnotationOrder.valueOf(Cache.getDefault(
232 Preferences.SORT_ANNOTATIONS,
233 SequenceAnnotationOrder.NONE.name()));
234 showAutocalculatedAbove = Cache.getDefault(
235 Preferences.SHOW_AUTOCALC_ABOVE, false);
236 viewStyle.setScaleProteinAsCdna(Cache.getDefault(
237 Preferences.SCALE_PROTEIN_TO_CDNA, true));
242 ranges = new ViewportRanges(this.alignment);
243 applyViewProperties();
245 String fontName = Cache.getDefault("FONT_NAME", "SansSerif");
246 String fontStyle = Cache.getDefault("FONT_STYLE", Font.PLAIN + "");
247 String fontSize = Cache.getDefault("FONT_SIZE", "10");
251 if (fontStyle.equals("bold"))
255 else if (fontStyle.equals("italic"))
260 setFont(new Font(fontName, style, Integer.parseInt(fontSize)), true);
263 .setGapCharacter(Cache.getDefault("GAP_SYMBOL", "-").charAt(0));
265 // We must set conservation and consensus before setting colour,
266 // as Blosum and Clustal require this to be done
267 if (hconsensus == null && !isDataset)
269 if (!alignment.isNucleotide())
271 showConservation = Cache.getDefault("SHOW_CONSERVATION", true);
272 showQuality = Cache.getDefault("SHOW_QUALITY", true);
273 showGroupConservation = Cache.getDefault("SHOW_GROUP_CONSERVATION",
276 showConsensusHistogram = Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM",
278 showSequenceLogo = Cache.getDefault("SHOW_CONSENSUS_LOGO", false);
279 normaliseSequenceLogo = Cache.getDefault("NORMALISE_CONSENSUS_LOGO",
281 showGroupConsensus = Cache.getDefault("SHOW_GROUP_CONSENSUS", false);
282 showConsensus = Cache.getDefault("SHOW_IDENTITY", true);
284 initAutoAnnotation();
285 String colourProperty = alignment.isNucleotide() ? Preferences.DEFAULT_COLOUR_NUC
286 : Preferences.DEFAULT_COLOUR_PROT;
287 String schemeName = Cache.getProperty(colourProperty);
288 if (schemeName == null)
290 // only DEFAULT_COLOUR available in Jalview before 2.9
291 schemeName = Cache.getDefault(Preferences.DEFAULT_COLOUR,
292 ResidueColourScheme.NONE);
294 ColourSchemeI colourScheme = ColourSchemeProperty.getColourScheme(
295 alignment, schemeName);
296 residueShading = new ResidueShader(colourScheme);
298 if (colourScheme instanceof UserColourScheme)
300 residueShading = new ResidueShader(
301 UserDefinedColours.loadDefaultColours());
302 residueShading.setThreshold(0, isIgnoreGapsConsensus());
305 if (residueShading != null)
307 residueShading.setConsensus(hconsensus);
312 * get the consensus sequence as displayed under the PID consensus annotation
315 * @return consensus sequence as a new sequence object
317 public SequenceI getConsensusSeq()
319 if (consensus == null)
321 updateConsensus(null);
323 if (consensus == null)
327 StringBuffer seqs = new StringBuffer();
328 for (int i = 0; i < consensus.annotations.length; i++)
330 if (consensus.annotations[i] != null)
332 if (consensus.annotations[i].description.charAt(0) == '[')
334 seqs.append(consensus.annotations[i].description.charAt(1));
338 seqs.append(consensus.annotations[i].displayCharacter);
343 SequenceI sq = new Sequence("Consensus", seqs.toString());
344 sq.setDescription("Percentage Identity Consensus "
345 + ((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
349 boolean validCharWidth;
352 * update view settings with the given font. You may need to call
353 * alignPanel.fontChanged to update the layout geometry
356 * when true, charWidth/height is set according to font mentrics
358 public void setFont(Font f, boolean setGrid)
362 Container c = new Container();
364 java.awt.FontMetrics fm = c.getFontMetrics(font);
365 int w = viewStyle.getCharWidth(), ww = fm.charWidth('M'), h = viewStyle
369 setCharHeight(fm.getHeight());
372 viewStyle.setFontName(font.getName());
373 viewStyle.setFontStyle(font.getStyle());
374 viewStyle.setFontSize(font.getSize());
376 validCharWidth = true;
380 public void setViewStyle(ViewStyleI settingsForView)
382 super.setViewStyle(settingsForView);
383 setFont(new Font(viewStyle.getFontName(), viewStyle.getFontStyle(),
384 viewStyle.getFontSize()), false);
390 * @return DOCUMENT ME!
392 public Font getFont()
404 public void setAlignment(AlignmentI align)
406 replaceMappings(align);
407 super.setAlignment(align);
411 * Replace any codon mappings for this viewport with those for the given
416 public void replaceMappings(AlignmentI align)
420 * Deregister current mappings (if any)
422 deregisterMappings();
425 * Register new mappings (if any)
429 StructureSelectionManager ssm = StructureSelectionManager
430 .getStructureSelectionManager(Desktop.instance);
431 ssm.registerMappings(align.getCodonFrames());
435 * replace mappings on our alignment
437 if (alignment != null && align != null)
439 alignment.setCodonFrames(align.getCodonFrames());
443 protected void deregisterMappings()
445 AlignmentI al = getAlignment();
448 List<AlignedCodonFrame> mappings = al.getCodonFrames();
449 if (mappings != null)
451 StructureSelectionManager ssm = StructureSelectionManager
452 .getStructureSelectionManager(Desktop.instance);
453 for (AlignedCodonFrame acf : mappings)
455 if (noReferencesTo(acf))
457 ssm.deregisterMapping(acf);
467 * @return DOCUMENT ME!
470 public char getGapCharacter()
472 return getAlignment().getGapCharacter();
481 public void setGapCharacter(char gap)
483 if (getAlignment() != null)
485 getAlignment().setGapCharacter(gap);
495 public void setCurrentTree(NJTree tree)
503 * @return DOCUMENT ME!
505 public NJTree getCurrentTree()
511 * returns the visible column regions of the alignment
513 * @param selectedRegionOnly
514 * true to just return the contigs intersecting with the selected
518 public int[] getViewAsVisibleContigs(boolean selectedRegionOnly)
520 int[] viscontigs = null;
521 int start = 0, end = 0;
522 if (selectedRegionOnly && selectionGroup != null)
524 start = selectionGroup.getStartRes();
525 end = selectionGroup.getEndRes() + 1;
529 end = alignment.getWidth();
531 viscontigs = alignment.getHiddenColumns().getVisibleContigs(start, end);
536 * get hash of undo and redo list for the alignment
538 * @return long[] { historyList.hashCode, redoList.hashCode };
540 public long[] getUndoRedoHash()
543 if (historyList == null || redoList == null)
545 return new long[] { -1, -1 };
547 return new long[] { historyList.hashCode(), this.redoList.hashCode() };
551 * test if a particular set of hashcodes are different to the hashcodes for
552 * the undo and redo list.
555 * the stored set of hashcodes as returned by getUndoRedoHash
556 * @return true if the hashcodes differ (ie the alignment has been edited) or
557 * the stored hashcode array differs in size
559 public boolean isUndoRedoHashModified(long[] undoredo)
561 if (undoredo == null)
565 long[] cstate = getUndoRedoHash();
566 if (cstate.length != undoredo.length)
571 for (int i = 0; i < cstate.length; i++)
573 if (cstate[i] != undoredo[i])
581 public boolean followSelection = true;
584 * @return true if view selection should always follow the selections
585 * broadcast by other selection sources
587 public boolean getFollowSelection()
589 return followSelection;
593 * Send the current selection to be broadcast to any selection listeners.
596 public void sendSelection()
598 jalview.structure.StructureSelectionManager
599 .getStructureSelectionManager(Desktop.instance).sendSelection(
600 new SequenceGroup(getSelectionGroup()),
601 new ColumnSelection(getColumnSelection()),
602 new HiddenColumns(getAlignment().getHiddenColumns()),
607 * return the alignPanel containing the given viewport. Use this to get the
608 * components currently handling the given viewport.
611 * @return null or an alignPanel guaranteed to have non-null alignFrame
614 public AlignmentPanel getAlignPanel()
616 AlignmentPanel[] aps = PaintRefresher.getAssociatedPanels(this
617 .getSequenceSetId());
618 for (int p = 0; aps != null && p < aps.length; p++)
620 if (aps[p].av == this)
628 public boolean getSortByTree()
633 public void setSortByTree(boolean sort)
639 * Returns the (Desktop) instance of the StructureSelectionManager
642 public StructureSelectionManager getStructureSelectionManager()
644 return StructureSelectionManager
645 .getStructureSelectionManager(Desktop.instance);
651 * @return an array of SequenceI arrays, one for each PDBEntry, listing which
652 * sequences in the alignment hold a reference to it
654 public SequenceI[][] collateForPDB(PDBEntry[] pdbEntries)
656 List<SequenceI[]> seqvectors = new ArrayList<SequenceI[]>();
657 for (PDBEntry pdb : pdbEntries)
659 List<SequenceI> choosenSeqs = new ArrayList<SequenceI>();
660 for (SequenceI sq : alignment.getSequences())
662 Vector<PDBEntry> pdbRefEntries = sq.getDatasetSequence()
664 if (pdbRefEntries == null)
668 for (PDBEntry pdbRefEntry : pdbRefEntries)
670 if (pdbRefEntry.getId().equals(pdb.getId()))
672 if (pdbRefEntry.getChainCode() != null
673 && pdb.getChainCode() != null)
675 if (pdbRefEntry.getChainCode().equalsIgnoreCase(
677 && !choosenSeqs.contains(sq))
685 if (!choosenSeqs.contains(sq))
696 .add(choosenSeqs.toArray(new SequenceI[choosenSeqs.size()]));
698 return seqvectors.toArray(new SequenceI[seqvectors.size()][]);
702 public boolean isNormaliseSequenceLogo()
704 return normaliseSequenceLogo;
707 public void setNormaliseSequenceLogo(boolean state)
709 normaliseSequenceLogo = state;
714 * @return true if alignment characters should be displayed
717 public boolean isValidCharWidth()
719 return validCharWidth;
722 private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<String, AutoCalcSetting>();
724 public AutoCalcSetting getCalcIdSettingsFor(String calcId)
726 return calcIdParams.get(calcId);
729 public void setCalcIdSettingsFor(String calcId, AutoCalcSetting settings,
732 calcIdParams.put(calcId, settings);
733 // TODO: create a restart list to trigger any calculations that need to be
734 // restarted after load
735 // calculator.getRegisteredWorkersOfClass(settings.getWorkerClass())
738 Cache.log.debug("trigger update for " + calcId);
743 * Method called when another alignment's edit (or possibly other) command is
746 * To allow for sequence mappings (e.g. protein to cDNA), we have to first
747 * 'unwind' the command on the source sequences (in simulation, not in fact),
748 * and then for each edit in turn:
750 * <li>compute the equivalent edit on the mapped sequences</li>
751 * <li>apply the mapped edit</li>
752 * <li>'apply' the source edit to the working copy of the source sequences</li>
760 public void mirrorCommand(CommandI command, boolean undo,
761 StructureSelectionManager ssm, VamsasSource source)
764 * Do nothing unless we are a 'complement' of the source. May replace this
765 * with direct calls not via SSM.
767 if (source instanceof AlignViewportI
768 && ((AlignViewportI) source).getCodingComplement() == this)
777 CommandI mappedCommand = ssm.mapCommand(command, undo, getAlignment(),
779 if (mappedCommand != null)
781 AlignmentI[] views = getAlignPanel().alignFrame.getViewAlignments();
782 mappedCommand.doCommand(views);
783 getAlignPanel().alignmentChanged();
788 * Add the sequences from the given alignment to this viewport. Optionally,
789 * may give the user the option to open a new frame, or split panel, with cDNA
790 * and protein linked.
795 public void addAlignment(AlignmentI toAdd, String title)
797 // TODO: promote to AlignViewportI? applet CutAndPasteTransfer is different
799 // JBPComment: title is a largely redundant parameter at the moment
800 // JBPComment: this really should be an 'insert/pre/append' controller
801 // JBPComment: but the DNA/Protein check makes it a bit more complex
803 // refactored from FileLoader / CutAndPasteTransfer / SequenceFetcher with
805 // TODO: create undo object for this JAL-1101
808 * Ensure datasets are created for the new alignment as
809 * mappings operate on dataset sequences
811 toAdd.setDataset(null);
814 * Check if any added sequence could be the object of a mapping or
815 * cross-reference; if so, make the mapping explicit
817 getAlignment().realiseMappings(toAdd.getSequences());
820 * If any cDNA/protein mappings exist or can be made between the alignments,
821 * offer to open a split frame with linked alignments
823 if (Cache.getDefault(Preferences.ENABLE_SPLIT_FRAME, true))
825 if (AlignmentUtils.isMappable(toAdd, getAlignment()))
827 if (openLinkedAlignment(toAdd, title))
835 * No mappings, or offer declined - add sequences to this alignment
837 // TODO: JAL-407 regardless of above - identical sequences (based on ID and
838 // provenance) should share the same dataset sequence
840 AlignmentI al = getAlignment();
841 String gap = String.valueOf(al.getGapCharacter());
842 for (int i = 0; i < toAdd.getHeight(); i++)
844 SequenceI seq = toAdd.getSequenceAt(i);
847 * - 'align' any mapped sequences as per existing
848 * e.g. cdna to genome, domain hit to protein sequence
849 * very experimental! (need a separate menu option for this)
850 * - only add mapped sequences ('select targets from a dataset')
852 if (true /*AlignmentUtils.alignSequenceAs(seq, al, gap, true, true)*/)
858 ranges.setEndSeq(getAlignment().getHeight());
859 firePropertyChange("alignment", null, getAlignment().getSequences());
863 * Show a dialog with the option to open and link (cDNA <-> protein) as a new
864 * alignment, either as a standalone alignment or in a split frame. Returns
865 * true if the new alignment was opened, false if not, because the user
866 * declined the offer.
871 protected boolean openLinkedAlignment(AlignmentI al, String title)
873 String[] options = new String[] {
874 MessageManager.getString("action.no"),
875 MessageManager.getString("label.split_window"),
876 MessageManager.getString("label.new_window"), };
877 final String question = JvSwingUtils.wrapTooltip(true,
878 MessageManager.getString("label.open_split_window?"));
879 int response = JvOptionPane.showOptionDialog(Desktop.desktop, question,
880 MessageManager.getString("label.open_split_window"),
881 JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null,
882 options, options[0]);
884 if (response != 1 && response != 2)
888 final boolean openSplitPane = (response == 1);
889 final boolean openInNewWindow = (response == 2);
892 * Identify protein and dna alignments. Make a copy of this one if opening
893 * in a new split pane.
895 AlignmentI thisAlignment = openSplitPane ? new Alignment(getAlignment())
897 AlignmentI protein = al.isNucleotide() ? thisAlignment : al;
898 final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment;
901 * Map sequences. At least one should get mapped as we have already passed
902 * the test for 'mappability'. Any mappings made will be added to the
903 * protein alignment. Note creating dataset sequences on the new alignment
904 * is a pre-requisite for building mappings.
907 AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna);
910 * Create the AlignFrame for the added alignment. If it is protein, mappings
911 * are registered with StructureSelectionManager as a side-effect.
913 AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
914 AlignFrame.DEFAULT_HEIGHT);
915 newAlignFrame.setTitle(title);
916 newAlignFrame.statusBar.setText(MessageManager.formatMessage(
917 "label.successfully_loaded_file", new Object[] { title }));
919 // TODO if we want this (e.g. to enable reload of the alignment from file),
920 // we will need to add parameters to the stack.
921 // if (!protocol.equals(DataSourceType.PASTE))
923 // alignFrame.setFileName(file, format);
928 Desktop.addInternalFrame(newAlignFrame, title,
929 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
934 newAlignFrame.setMaximum(jalview.bin.Cache.getDefault(
935 "SHOW_FULLSCREEN", false));
936 } catch (java.beans.PropertyVetoException ex)
942 al.alignAs(thisAlignment);
943 protein = openSplitFrame(newAlignFrame, thisAlignment);
950 * Helper method to open a new SplitFrame holding linked dna and protein
953 * @param newAlignFrame
954 * containing a new alignment to be shown
956 * cdna/protein complement alignment to show in the other split half
957 * @return the protein alignment in the split frame
959 protected AlignmentI openSplitFrame(AlignFrame newAlignFrame,
960 AlignmentI complement)
963 * Make a new frame with a copy of the alignment we are adding to. If this
964 * is protein, the mappings to cDNA will be registered with
965 * StructureSelectionManager as a side-effect.
967 AlignFrame copyMe = new AlignFrame(complement,
968 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
969 copyMe.setTitle(getAlignPanel().alignFrame.getTitle());
971 AlignmentI al = newAlignFrame.viewport.getAlignment();
972 final AlignFrame proteinFrame = al.isNucleotide() ? copyMe
974 final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame : copyMe;
975 cdnaFrame.setVisible(true);
976 proteinFrame.setVisible(true);
977 String linkedTitle = MessageManager
978 .getString("label.linked_view_title");
981 * Open in split pane. DNA sequence above, protein below.
983 JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame);
984 Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1);
986 return proteinFrame.viewport.getAlignment();
989 public AnnotationColumnChooser getAnnotationColumnSelectionState()
991 return annotationColumnSelectionState;
994 public void setAnnotationColumnSelectionState(
995 AnnotationColumnChooser currentAnnotationColumnSelectionState)
997 this.annotationColumnSelectionState = currentAnnotationColumnSelectionState;
1001 public void setIdWidth(int i)
1003 super.setIdWidth(i);
1004 AlignmentPanel ap = getAlignPanel();
1007 // modify GUI elements to reflect geometry change
1008 Dimension idw = getAlignPanel().getIdPanel().getIdCanvas()
1009 .getPreferredSize();
1011 getAlignPanel().getIdPanel().getIdCanvas().setPreferredSize(idw);
1015 public Rectangle getExplodedGeometry()
1017 return explodedGeometry;
1020 public void setExplodedGeometry(Rectangle explodedPosition)
1022 this.explodedGeometry = explodedPosition;
1025 public boolean isGatherViewsHere()
1027 return gatherViewsHere;
1030 public void setGatherViewsHere(boolean gatherViewsHere)
1032 this.gatherViewsHere = gatherViewsHere;
1036 * If this viewport has a (Protein/cDNA) complement, then scroll the
1037 * complementary alignment to match this one.
1039 public void scrollComplementaryAlignment()
1042 * Populate a SearchResults object with the mapped location to scroll to. If
1043 * there is no complement, or it is not following highlights, or no mapping
1044 * is found, the result will be empty.
1046 SearchResultsI sr = new SearchResults();
1047 int verticalOffset = findComplementScrollTarget(sr);
1050 // TODO would like next line without cast but needs more refactoring...
1051 final AlignmentPanel complementPanel = ((AlignViewport) getCodingComplement())
1053 complementPanel.setDontScrollComplement(true);
1054 complementPanel.scrollToCentre(sr, verticalOffset);
1059 * Answers true if no alignment holds a reference to the given mapping
1064 protected boolean noReferencesTo(AlignedCodonFrame acf)
1066 AlignFrame[] frames = Desktop.getAlignFrames();
1071 for (AlignFrame af : frames)
1075 for (AlignmentViewPanel ap : af.getAlignPanels())
1077 AlignmentI al = ap.getAlignment();
1078 if (al != null && al.getCodonFrames().contains(acf))
1089 * Applies the supplied feature settings descriptor to currently known
1090 * features. This supports an 'initial configuration' of feature colouring
1091 * based on a preset or user favourite. This may then be modified in the usual
1092 * way using the Feature Settings dialogue.
1094 * @param featureSettings
1097 public void applyFeaturesStyle(FeatureSettingsModelI featureSettings)
1099 if (featureSettings == null)
1104 FeatureRenderer fr = getAlignPanel().getSeqPanel().seqCanvas
1105 .getFeatureRenderer();
1106 fr.findAllFeatures(true);
1107 List<String> renderOrder = fr.getRenderOrder();
1108 FeaturesDisplayedI displayed = fr.getFeaturesDisplayed();
1110 // TODO this clears displayed.featuresRegistered - do we care?
1113 * set feature colour if specified by feature settings
1114 * set visibility of all features
1116 for (String type : renderOrder)
1118 FeatureColourI preferredColour = featureSettings
1119 .getFeatureColour(type);
1120 if (preferredColour != null)
1122 fr.setColour(type, preferredColour);
1124 if (featureSettings.isFeatureDisplayed(type))
1126 displayed.setVisible(type);
1131 * set visibility of feature groups
1133 for (String group : fr.getFeatureGroups())
1135 fr.setGroupVisibility(group, featureSettings.isGroupDisplayed(group));
1139 * order the features
1141 if (featureSettings.optimiseOrder())
1143 // TODO not supported (yet?)
1147 fr.orderFeatures(featureSettings);
1149 fr.setTransparency(featureSettings.getTransparency());