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.api.AlignViewportI;
26 import jalview.api.AlignmentViewPanel;
27 import jalview.api.FeatureColourI;
28 import jalview.api.FeatureSettingsModelI;
29 import jalview.api.FeaturesDisplayedI;
30 import jalview.api.ViewStyleI;
31 import jalview.bin.Cache;
32 import jalview.commands.CommandI;
33 import jalview.datamodel.AlignedCodonFrame;
34 import jalview.datamodel.Alignment;
35 import jalview.datamodel.AlignmentI;
36 import jalview.datamodel.ColumnSelection;
37 import jalview.datamodel.HiddenColumns;
38 import jalview.datamodel.PDBEntry;
39 import jalview.datamodel.SearchResults;
40 import jalview.datamodel.SearchResultsI;
41 import jalview.datamodel.SequenceGroup;
42 import jalview.datamodel.SequenceI;
43 import jalview.renderer.ResidueShader;
44 import jalview.schemes.ColourSchemeI;
45 import jalview.schemes.ColourSchemeProperty;
46 import jalview.schemes.ResidueColourScheme;
47 import jalview.schemes.UserColourScheme;
48 import jalview.structure.SelectionSource;
49 import jalview.structure.StructureSelectionManager;
50 import jalview.structure.VamsasSource;
51 import jalview.util.MessageManager;
52 import jalview.viewmodel.AlignmentViewport;
53 import jalview.ws.params.AutoCalcSetting;
55 import java.awt.Container;
56 import java.awt.Dimension;
58 import java.awt.FontMetrics;
59 import java.awt.Rectangle;
60 import java.util.ArrayList;
61 import java.util.Hashtable;
62 import java.util.List;
63 import java.util.Vector;
65 import javax.swing.JInternalFrame;
71 * @version $Revision: 1.141 $
73 public class AlignViewport extends AlignmentViewport
74 implements SelectionSource
78 boolean cursorMode = false;
80 boolean antiAlias = false;
82 private Rectangle explodedGeometry;
87 * Flag set true on the view that should 'gather' multiple views of the same
88 * sequence set id when a project is reloaded. Set false on all views when
89 * they are 'exploded' into separate windows. Set true on the current view
90 * when 'Gather' is performed, and also on the first tab when the first new
93 private boolean gatherViewsHere = false;
95 private AnnotationColumnChooser annotationColumnSelectionState;
98 * Creates a new AlignViewport object.
103 public AlignViewport(AlignmentI al)
110 * Create a new AlignViewport object with a specific sequence set ID
114 * (may be null - but potential for ambiguous constructor exception)
116 public AlignViewport(AlignmentI al, String seqsetid)
118 this(al, seqsetid, null);
121 public AlignViewport(AlignmentI al, String seqsetid, String viewid)
124 sequenceSetID = seqsetid;
126 // TODO remove these once 2.4.VAMSAS release finished
127 if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null)
130 "Setting viewport's sequence set id : " + sequenceSetID);
132 if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null)
134 Cache.log.debug("Setting viewport's view id : " + viewId);
141 * Create a new AlignViewport with hidden regions
145 * @param hiddenColumns
148 public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns)
151 if (hiddenColumns != null)
153 al.setHiddenColumns(hiddenColumns);
159 * New viewport with hidden columns and an existing sequence set id
162 * @param hiddenColumns
166 public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns,
169 this(al, hiddenColumns, seqsetid, null);
173 * New viewport with hidden columns and an existing sequence set id and viewid
176 * @param hiddenColumns
182 public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns,
183 String seqsetid, String viewid)
186 sequenceSetID = seqsetid;
188 // TODO remove these once 2.4.VAMSAS release finished
189 if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null)
192 "Setting viewport's sequence set id : " + sequenceSetID);
194 if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null)
196 Cache.log.debug("Setting viewport's view id : " + viewId);
199 if (hiddenColumns != null)
201 al.setHiddenColumns(hiddenColumns);
207 * Apply any settings saved in user preferences
209 private void applyViewProperties()
211 antiAlias = Cache.getDefault("ANTI_ALIAS", false);
213 viewStyle.setShowJVSuffix(Cache.getDefault("SHOW_JVSUFFIX", true));
214 setShowAnnotation(Cache.getDefault("SHOW_ANNOTATIONS", true));
216 setRightAlignIds(Cache.getDefault("RIGHT_ALIGN_IDS", false));
217 setCentreColumnLabels(Cache.getDefault("CENTRE_COLUMN_LABELS", false));
218 autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
220 setPadGaps(Cache.getDefault("PAD_GAPS", true));
221 setShowNPFeats(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
222 setShowDBRefs(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
223 viewStyle.setSeqNameItalics(Cache.getDefault("ID_ITALICS", true));
224 viewStyle.setWrapAlignment(Cache.getDefault("WRAP_ALIGNMENT", false));
225 viewStyle.setShowUnconserved(
226 Cache.getDefault("SHOW_UNCONSERVED", false));
227 sortByTree = Cache.getDefault("SORT_BY_TREE", false);
228 followSelection = Cache.getDefault("FOLLOW_SELECTIONS", true);
229 sortAnnotationsBy = SequenceAnnotationOrder
230 .valueOf(Cache.getDefault(Preferences.SORT_ANNOTATIONS,
231 SequenceAnnotationOrder.NONE.name()));
232 showAutocalculatedAbove = Cache
233 .getDefault(Preferences.SHOW_AUTOCALC_ABOVE, false);
234 viewStyle.setScaleProteinAsCdna(
235 Cache.getDefault(Preferences.SCALE_PROTEIN_TO_CDNA, true));
240 applyViewProperties();
242 String fontName = Cache.getDefault("FONT_NAME", "SansSerif");
243 String fontStyle = Cache.getDefault("FONT_STYLE", Font.PLAIN + "");
244 String fontSize = Cache.getDefault("FONT_SIZE", "10");
248 if (fontStyle.equals("bold"))
252 else if (fontStyle.equals("italic"))
257 setFont(new Font(fontName, style, Integer.parseInt(fontSize)), true);
260 .setGapCharacter(Cache.getDefault("GAP_SYMBOL", "-").charAt(0));
262 // We must set conservation and consensus before setting colour,
263 // as Blosum and Clustal require this to be done
264 if (hconsensus == null && !isDataset)
266 if (!alignment.isNucleotide())
268 showConservation = Cache.getDefault("SHOW_CONSERVATION", true);
269 showQuality = Cache.getDefault("SHOW_QUALITY", true);
270 showGroupConservation = Cache.getDefault("SHOW_GROUP_CONSERVATION",
273 showConsensusHistogram = Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM",
275 showSequenceLogo = Cache.getDefault("SHOW_CONSENSUS_LOGO", false);
276 normaliseSequenceLogo = Cache.getDefault("NORMALISE_CONSENSUS_LOGO",
278 showGroupConsensus = Cache.getDefault("SHOW_GROUP_CONSENSUS", false);
279 showConsensus = Cache.getDefault("SHOW_IDENTITY", true);
281 showOccupancy = Cache.getDefault(Preferences.SHOW_OCCUPANCY, true);
283 initAutoAnnotation();
287 String colourProperty = alignment.isNucleotide()
288 ? Preferences.DEFAULT_COLOUR_NUC
289 : Preferences.DEFAULT_COLOUR_PROT;
290 String schemeName = Cache.getProperty(colourProperty);
291 if (schemeName == null)
293 // only DEFAULT_COLOUR available in Jalview before 2.9
294 schemeName = Cache.getDefault(Preferences.DEFAULT_COLOUR,
295 ResidueColourScheme.NONE);
297 ColourSchemeI colourScheme = ColourSchemeProperty
298 .getColourScheme(alignment, schemeName);
299 residueShading = new ResidueShader(colourScheme);
301 if (colourScheme instanceof UserColourScheme)
303 residueShading = new ResidueShader(
304 UserDefinedColours.loadDefaultColours());
305 residueShading.setThreshold(0, isIgnoreGapsConsensus());
308 if (residueShading != null)
310 residueShading.setConsensus(hconsensus);
314 boolean validCharWidth;
320 public void setFont(Font f, boolean setGrid)
324 Container c = new Container();
328 FontMetrics fm = c.getFontMetrics(font);
329 int ww = fm.charWidth('M');
330 setCharHeight(fm.getHeight());
333 viewStyle.setFontName(font.getName());
334 viewStyle.setFontStyle(font.getStyle());
335 viewStyle.setFontSize(font.getSize());
337 validCharWidth = true;
341 public void setViewStyle(ViewStyleI settingsForView)
343 super.setViewStyle(settingsForView);
344 setFont(new Font(viewStyle.getFontName(), viewStyle.getFontStyle(),
345 viewStyle.getFontSize()), false);
351 * @return DOCUMENT ME!
353 public Font getFont()
365 public void setAlignment(AlignmentI align)
367 replaceMappings(align);
368 super.setAlignment(align);
372 * Replace any codon mappings for this viewport with those for the given
377 public void replaceMappings(AlignmentI align)
381 * Deregister current mappings (if any)
383 deregisterMappings();
386 * Register new mappings (if any)
390 StructureSelectionManager ssm = StructureSelectionManager
391 .getStructureSelectionManager(Desktop.instance);
392 ssm.registerMappings(align.getCodonFrames());
396 * replace mappings on our alignment
398 if (alignment != null && align != null)
400 alignment.setCodonFrames(align.getCodonFrames());
404 protected void deregisterMappings()
406 AlignmentI al = getAlignment();
409 List<AlignedCodonFrame> mappings = al.getCodonFrames();
410 if (mappings != null)
412 StructureSelectionManager ssm = StructureSelectionManager
413 .getStructureSelectionManager(Desktop.instance);
414 for (AlignedCodonFrame acf : mappings)
416 if (noReferencesTo(acf))
418 ssm.deregisterMapping(acf);
428 * @return DOCUMENT ME!
431 public char getGapCharacter()
433 return getAlignment().getGapCharacter();
442 public void setGapCharacter(char gap)
444 if (getAlignment() != null)
446 getAlignment().setGapCharacter(gap);
451 * returns the visible column regions of the alignment
453 * @param selectedRegionOnly
454 * true to just return the contigs intersecting with the selected
458 public int[] getViewAsVisibleContigs(boolean selectedRegionOnly)
460 int[] viscontigs = null;
461 int start = 0, end = 0;
462 if (selectedRegionOnly && selectionGroup != null)
464 start = selectionGroup.getStartRes();
465 end = selectionGroup.getEndRes() + 1;
469 end = alignment.getWidth();
471 viscontigs = alignment.getHiddenColumns().getVisibleContigs(start, end);
476 * get hash of undo and redo list for the alignment
478 * @return long[] { historyList.hashCode, redoList.hashCode };
480 public long[] getUndoRedoHash()
483 if (historyList == null || redoList == null)
485 return new long[] { -1, -1 };
487 return new long[] { historyList.hashCode(), this.redoList.hashCode() };
491 * test if a particular set of hashcodes are different to the hashcodes for
492 * the undo and redo list.
495 * the stored set of hashcodes as returned by getUndoRedoHash
496 * @return true if the hashcodes differ (ie the alignment has been edited) or
497 * the stored hashcode array differs in size
499 public boolean isUndoRedoHashModified(long[] undoredo)
501 if (undoredo == null)
505 long[] cstate = getUndoRedoHash();
506 if (cstate.length != undoredo.length)
511 for (int i = 0; i < cstate.length; i++)
513 if (cstate[i] != undoredo[i])
521 public boolean followSelection = true;
524 * @return true if view selection should always follow the selections
525 * broadcast by other selection sources
527 public boolean getFollowSelection()
529 return followSelection;
533 * Send the current selection to be broadcast to any selection listeners.
536 public void sendSelection()
538 jalview.structure.StructureSelectionManager
539 .getStructureSelectionManager(Desktop.instance)
540 .sendSelection(new SequenceGroup(getSelectionGroup()),
541 new ColumnSelection(getColumnSelection()),
542 new HiddenColumns(getAlignment().getHiddenColumns()),
547 * return the alignPanel containing the given viewport. Use this to get the
548 * components currently handling the given viewport.
551 * @return null or an alignPanel guaranteed to have non-null alignFrame
554 public AlignmentPanel getAlignPanel()
556 AlignmentPanel[] aps = PaintRefresher
557 .getAssociatedPanels(this.getSequenceSetId());
558 for (int p = 0; aps != null && p < aps.length; p++)
560 if (aps[p].av == this)
568 public boolean getSortByTree()
573 public void setSortByTree(boolean sort)
579 * Returns the (Desktop) instance of the StructureSelectionManager
582 public StructureSelectionManager getStructureSelectionManager()
584 return StructureSelectionManager
585 .getStructureSelectionManager(Desktop.instance);
591 * @return an array of SequenceI arrays, one for each PDBEntry, listing which
592 * sequences in the alignment hold a reference to it
594 public SequenceI[][] collateForPDB(PDBEntry[] pdbEntries)
596 List<SequenceI[]> seqvectors = new ArrayList<>();
597 for (PDBEntry pdb : pdbEntries)
599 List<SequenceI> choosenSeqs = new ArrayList<>();
600 for (SequenceI sq : alignment.getSequences())
602 Vector<PDBEntry> pdbRefEntries = sq.getDatasetSequence()
604 if (pdbRefEntries == null)
608 for (PDBEntry pdbRefEntry : pdbRefEntries)
610 if (pdbRefEntry.getId().equals(pdb.getId()))
612 if (pdbRefEntry.getChainCode() != null
613 && pdb.getChainCode() != null)
615 if (pdbRefEntry.getChainCode().equalsIgnoreCase(
616 pdb.getChainCode()) && !choosenSeqs.contains(sq))
624 if (!choosenSeqs.contains(sq))
635 .add(choosenSeqs.toArray(new SequenceI[choosenSeqs.size()]));
637 return seqvectors.toArray(new SequenceI[seqvectors.size()][]);
641 public boolean isNormaliseSequenceLogo()
643 return normaliseSequenceLogo;
647 public void setNormaliseSequenceLogo(boolean state)
649 normaliseSequenceLogo = state;
652 public void setNormaliseHMMSequenceLogo(boolean state)
654 normaliseHMMSequenceLogo = state;
659 * @return true if alignment characters should be displayed
662 public boolean isValidCharWidth()
664 return validCharWidth;
667 private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<>();
669 public AutoCalcSetting getCalcIdSettingsFor(String calcId)
671 return calcIdParams.get(calcId);
674 public void setCalcIdSettingsFor(String calcId, AutoCalcSetting settings,
677 calcIdParams.put(calcId, settings);
678 // TODO: create a restart list to trigger any calculations that need to be
679 // restarted after load
680 // calculator.getRegisteredWorkersOfClass(settings.getWorkerClass())
683 Cache.log.debug("trigger update for " + calcId);
688 * Method called when another alignment's edit (or possibly other) command is
691 * To allow for sequence mappings (e.g. protein to cDNA), we have to first
692 * 'unwind' the command on the source sequences (in simulation, not in fact),
693 * and then for each edit in turn:
695 * <li>compute the equivalent edit on the mapped sequences</li>
696 * <li>apply the mapped edit</li>
697 * <li>'apply' the source edit to the working copy of the source
706 public void mirrorCommand(CommandI command, boolean undo,
707 StructureSelectionManager ssm, VamsasSource source)
710 * Do nothing unless we are a 'complement' of the source. May replace this
711 * with direct calls not via SSM.
713 if (source instanceof AlignViewportI
714 && ((AlignViewportI) source).getCodingComplement() == this)
723 CommandI mappedCommand = ssm.mapCommand(command, undo, getAlignment(),
725 if (mappedCommand != null)
727 AlignmentI[] views = getAlignPanel().alignFrame.getViewAlignments();
728 mappedCommand.doCommand(views);
729 getAlignPanel().alignmentChanged();
734 * Add the sequences from the given alignment to this viewport. Optionally,
735 * may give the user the option to open a new frame, or split panel, with cDNA
736 * and protein linked.
741 public void addAlignment(AlignmentI toAdd, String title)
743 // TODO: promote to AlignViewportI? applet CutAndPasteTransfer is different
745 // JBPComment: title is a largely redundant parameter at the moment
746 // JBPComment: this really should be an 'insert/pre/append' controller
747 // JBPComment: but the DNA/Protein check makes it a bit more complex
749 // refactored from FileLoader / CutAndPasteTransfer / SequenceFetcher with
751 // TODO: create undo object for this JAL-1101
754 * Ensure datasets are created for the new alignment as
755 * mappings operate on dataset sequences
757 toAdd.setDataset(null);
760 * Check if any added sequence could be the object of a mapping or
761 * cross-reference; if so, make the mapping explicit
763 getAlignment().realiseMappings(toAdd.getSequences());
766 * If any cDNA/protein mappings exist or can be made between the alignments,
767 * offer to open a split frame with linked alignments
769 if (Cache.getDefault(Preferences.ENABLE_SPLIT_FRAME, true))
771 if (AlignmentUtils.isMappable(toAdd, getAlignment()))
773 if (openLinkedAlignment(toAdd, title))
781 * No mappings, or offer declined - add sequences to this alignment
783 // TODO: JAL-407 regardless of above - identical sequences (based on ID and
784 // provenance) should share the same dataset sequence
786 AlignmentI al = getAlignment();
787 String gap = String.valueOf(al.getGapCharacter());
788 for (int i = 0; i < toAdd.getHeight(); i++)
790 SequenceI seq = toAdd.getSequenceAt(i);
793 * - 'align' any mapped sequences as per existing
794 * e.g. cdna to genome, domain hit to protein sequence
795 * very experimental! (need a separate menu option for this)
796 * - only add mapped sequences ('select targets from a dataset')
798 if (true /*AlignmentUtils.alignSequenceAs(seq, al, gap, true, true)*/)
804 ranges.setEndSeq(getAlignment().getHeight());
805 firePropertyChange("alignment", null, getAlignment().getSequences());
809 * Show a dialog with the option to open and link (cDNA <-> protein) as a new
810 * alignment, either as a standalone alignment or in a split frame. Returns
811 * true if the new alignment was opened, false if not, because the user
812 * declined the offer.
817 protected boolean openLinkedAlignment(AlignmentI al, String title)
819 String[] options = new String[] { MessageManager.getString("action.no"),
820 MessageManager.getString("label.split_window"),
821 MessageManager.getString("label.new_window"), };
822 final String question = JvSwingUtils.wrapTooltip(true,
823 MessageManager.getString("label.open_split_window?"));
824 int response = JvOptionPane.showOptionDialog(Desktop.desktop, question,
825 MessageManager.getString("label.open_split_window"),
826 JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null,
827 options, options[0]);
829 if (response != 1 && response != 2)
833 final boolean openSplitPane = (response == 1);
834 final boolean openInNewWindow = (response == 2);
837 * Identify protein and dna alignments. Make a copy of this one if opening
838 * in a new split pane.
840 AlignmentI thisAlignment = openSplitPane ? new Alignment(getAlignment())
842 AlignmentI protein = al.isNucleotide() ? thisAlignment : al;
843 final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment;
846 * Map sequences. At least one should get mapped as we have already passed
847 * the test for 'mappability'. Any mappings made will be added to the
848 * protein alignment. Note creating dataset sequences on the new alignment
849 * is a pre-requisite for building mappings.
852 AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna);
855 * Create the AlignFrame for the added alignment. If it is protein, mappings
856 * are registered with StructureSelectionManager as a side-effect.
858 AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
859 AlignFrame.DEFAULT_HEIGHT);
860 newAlignFrame.setTitle(title);
861 newAlignFrame.statusBar.setText(MessageManager
862 .formatMessage("label.successfully_loaded_file", new Object[]
865 // TODO if we want this (e.g. to enable reload of the alignment from file),
866 // we will need to add parameters to the stack.
867 // if (!protocol.equals(DataSourceType.PASTE))
869 // alignFrame.setFileName(file, format);
874 Desktop.addInternalFrame(newAlignFrame, title,
875 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
880 newAlignFrame.setMaximum(
881 jalview.bin.Cache.getDefault("SHOW_FULLSCREEN", false));
882 } catch (java.beans.PropertyVetoException ex)
888 al.alignAs(thisAlignment);
889 protein = openSplitFrame(newAlignFrame, thisAlignment);
896 * Helper method to open a new SplitFrame holding linked dna and protein
899 * @param newAlignFrame
900 * containing a new alignment to be shown
902 * cdna/protein complement alignment to show in the other split half
903 * @return the protein alignment in the split frame
905 protected AlignmentI openSplitFrame(AlignFrame newAlignFrame,
906 AlignmentI complement)
909 * Make a new frame with a copy of the alignment we are adding to. If this
910 * is protein, the mappings to cDNA will be registered with
911 * StructureSelectionManager as a side-effect.
913 AlignFrame copyMe = new AlignFrame(complement, AlignFrame.DEFAULT_WIDTH,
914 AlignFrame.DEFAULT_HEIGHT);
915 copyMe.setTitle(getAlignPanel().alignFrame.getTitle());
917 AlignmentI al = newAlignFrame.viewport.getAlignment();
918 final AlignFrame proteinFrame = al.isNucleotide() ? copyMe
920 final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame : copyMe;
921 cdnaFrame.setVisible(true);
922 proteinFrame.setVisible(true);
923 String linkedTitle = MessageManager
924 .getString("label.linked_view_title");
927 * Open in split pane. DNA sequence above, protein below.
929 JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame);
930 Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1);
932 return proteinFrame.viewport.getAlignment();
935 public AnnotationColumnChooser getAnnotationColumnSelectionState()
937 return annotationColumnSelectionState;
940 public void setAnnotationColumnSelectionState(
941 AnnotationColumnChooser currentAnnotationColumnSelectionState)
943 this.annotationColumnSelectionState = currentAnnotationColumnSelectionState;
947 public void setIdWidth(int i)
950 AlignmentPanel ap = getAlignPanel();
953 // modify GUI elements to reflect geometry change
954 Dimension idw = getAlignPanel().getIdPanel().getIdCanvas()
957 getAlignPanel().getIdPanel().getIdCanvas().setPreferredSize(idw);
961 public Rectangle getExplodedGeometry()
963 return explodedGeometry;
966 public void setExplodedGeometry(Rectangle explodedPosition)
968 this.explodedGeometry = explodedPosition;
971 public boolean isGatherViewsHere()
973 return gatherViewsHere;
976 public void setGatherViewsHere(boolean gatherViewsHere)
978 this.gatherViewsHere = gatherViewsHere;
982 * If this viewport has a (Protein/cDNA) complement, then scroll the
983 * complementary alignment to match this one.
985 public void scrollComplementaryAlignment()
988 * Populate a SearchResults object with the mapped location to scroll to. If
989 * there is no complement, or it is not following highlights, or no mapping
990 * is found, the result will be empty.
992 SearchResultsI sr = new SearchResults();
993 int verticalOffset = findComplementScrollTarget(sr);
996 // TODO would like next line without cast but needs more refactoring...
997 final AlignmentPanel complementPanel = ((AlignViewport) getCodingComplement())
999 complementPanel.setToScrollComplementPanel(false);
1000 complementPanel.scrollToCentre(sr, verticalOffset);
1001 complementPanel.setToScrollComplementPanel(true);
1006 * Answers true if no alignment holds a reference to the given mapping
1011 protected boolean noReferencesTo(AlignedCodonFrame acf)
1013 AlignFrame[] frames = Desktop.getAlignFrames();
1018 for (AlignFrame af : frames)
1022 for (AlignmentViewPanel ap : af.getAlignPanels())
1024 AlignmentI al = ap.getAlignment();
1025 if (al != null && al.getCodonFrames().contains(acf))
1036 * Applies the supplied feature settings descriptor to currently known
1037 * features. This supports an 'initial configuration' of feature colouring
1038 * based on a preset or user favourite. This may then be modified in the usual
1039 * way using the Feature Settings dialogue.
1041 * @param featureSettings
1044 public void applyFeaturesStyle(FeatureSettingsModelI featureSettings)
1046 if (featureSettings == null)
1051 FeatureRenderer fr = getAlignPanel().getSeqPanel().seqCanvas
1052 .getFeatureRenderer();
1053 fr.findAllFeatures(true);
1054 List<String> renderOrder = fr.getRenderOrder();
1055 FeaturesDisplayedI displayed = fr.getFeaturesDisplayed();
1057 // TODO this clears displayed.featuresRegistered - do we care?
1060 * set feature colour if specified by feature settings
1061 * set visibility of all features
1063 for (String type : renderOrder)
1065 FeatureColourI preferredColour = featureSettings
1066 .getFeatureColour(type);
1067 if (preferredColour != null)
1069 fr.setColour(type, preferredColour);
1071 if (featureSettings.isFeatureDisplayed(type))
1073 displayed.setVisible(type);
1078 * set visibility of feature groups
1080 for (String group : fr.getFeatureGroups())
1082 fr.setGroupVisibility(group, featureSettings.isGroupDisplayed(group));
1086 * order the features
1088 if (featureSettings.optimiseOrder())
1090 // TODO not supported (yet?)
1094 fr.orderFeatures(featureSettings);
1096 fr.setTransparency(featureSettings.getTransparency());
1100 public boolean isNormaliseHMMSequenceLogo()
1102 return normaliseHMMSequenceLogo;