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.SearchResults;
39 import jalview.datamodel.SearchResultsI;
40 import jalview.datamodel.SequenceGroup;
41 import jalview.datamodel.SequenceI;
42 import jalview.renderer.ResidueShader;
43 import jalview.schemes.ColourSchemeI;
44 import jalview.schemes.ColourSchemeProperty;
45 import jalview.schemes.ResidueColourScheme;
46 import jalview.schemes.UserColourScheme;
47 import jalview.structure.SelectionSource;
48 import jalview.structure.StructureSelectionManager;
49 import jalview.structure.VamsasSource;
50 import jalview.util.MessageManager;
51 import jalview.viewmodel.AlignmentViewport;
52 import jalview.ws.params.AutoCalcSetting;
54 import java.awt.Container;
55 import java.awt.Dimension;
57 import java.awt.FontMetrics;
58 import java.awt.Rectangle;
59 import java.util.Hashtable;
60 import java.util.Iterator;
61 import java.util.List;
63 import javax.swing.JInternalFrame;
69 * @version $Revision: 1.141 $
71 public class AlignViewport extends AlignmentViewport
72 implements SelectionSource
76 boolean cursorMode = false;
78 boolean antiAlias = false;
80 private Rectangle explodedGeometry;
85 * Flag set true on the view that should 'gather' multiple views of the same
86 * sequence set id when a project is reloaded. Set false on all views when
87 * they are 'exploded' into separate windows. Set true on the current view
88 * when 'Gather' is performed, and also on the first tab when the first new
91 private boolean gatherViewsHere = false;
93 private AnnotationColumnChooser annotationColumnSelectionState;
96 * Creates a new AlignViewport object.
101 public AlignViewport(AlignmentI al)
108 * Create a new AlignViewport object with a specific sequence set ID
112 * (may be null - but potential for ambiguous constructor exception)
114 public AlignViewport(AlignmentI al, String seqsetid)
116 this(al, seqsetid, null);
119 public AlignViewport(AlignmentI al, String seqsetid, String viewid)
122 sequenceSetID = seqsetid;
124 // TODO remove these once 2.4.VAMSAS release finished
125 if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null)
128 "Setting viewport's sequence set id : " + sequenceSetID);
130 if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null)
132 Cache.log.debug("Setting viewport's view id : " + viewId);
139 * Create a new AlignViewport with hidden regions
143 * @param hiddenColumns
146 public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns)
149 if (hiddenColumns != null)
151 al.setHiddenColumns(hiddenColumns);
157 * New viewport with hidden columns and an existing sequence set id
160 * @param hiddenColumns
164 public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns,
167 this(al, hiddenColumns, seqsetid, null);
171 * New viewport with hidden columns and an existing sequence set id and viewid
174 * @param hiddenColumns
180 public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns,
181 String seqsetid, String viewid)
184 sequenceSetID = seqsetid;
186 // TODO remove these once 2.4.VAMSAS release finished
187 if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null)
190 "Setting viewport's sequence set id : " + sequenceSetID);
192 if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null)
194 Cache.log.debug("Setting viewport's view id : " + viewId);
197 if (hiddenColumns != null)
199 al.setHiddenColumns(hiddenColumns);
205 * Apply any settings saved in user preferences
207 private void applyViewProperties()
209 antiAlias = Cache.getDefault("ANTI_ALIAS", false);
211 viewStyle.setShowJVSuffix(Cache.getDefault("SHOW_JVSUFFIX", true));
212 setShowAnnotation(Cache.getDefault("SHOW_ANNOTATIONS", true));
214 setRightAlignIds(Cache.getDefault("RIGHT_ALIGN_IDS", false));
215 setCentreColumnLabels(Cache.getDefault("CENTRE_COLUMN_LABELS", false));
216 autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
218 setPadGaps(Cache.getDefault("PAD_GAPS", true));
219 setShowNPFeats(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
220 setShowDBRefs(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
221 viewStyle.setSeqNameItalics(Cache.getDefault("ID_ITALICS", true));
222 viewStyle.setWrapAlignment(Cache.getDefault("WRAP_ALIGNMENT", false));
223 viewStyle.setShowUnconserved(
224 Cache.getDefault("SHOW_UNCONSERVED", false));
225 sortByTree = Cache.getDefault("SORT_BY_TREE", false);
226 followSelection = Cache.getDefault("FOLLOW_SELECTIONS", true);
227 sortAnnotationsBy = SequenceAnnotationOrder
228 .valueOf(Cache.getDefault(Preferences.SORT_ANNOTATIONS,
229 SequenceAnnotationOrder.NONE.name()));
230 showAutocalculatedAbove = Cache
231 .getDefault(Preferences.SHOW_AUTOCALC_ABOVE, false);
232 viewStyle.setScaleProteinAsCdna(
233 Cache.getDefault(Preferences.SCALE_PROTEIN_TO_CDNA, true));
238 applyViewProperties();
240 String fontName = Cache.getDefault("FONT_NAME", "SansSerif");
241 String fontStyle = Cache.getDefault("FONT_STYLE", Font.PLAIN + "");
242 String fontSize = Cache.getDefault("FONT_SIZE", "10");
246 if (fontStyle.equals("bold"))
250 else if (fontStyle.equals("italic"))
255 setFont(new Font(fontName, style, Integer.parseInt(fontSize)), true);
257 if (Cache.getDefault("NORMALISE_GAPS", true))
259 alignment.setGapCharacter(Cache.getDefault("GAP_SYMBOL", "-").charAt(
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();
284 String colourProperty = alignment.isNucleotide()
285 ? 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
295 .getColourScheme(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);
311 boolean validCharWidth;
317 public void setFont(Font f, boolean setGrid)
321 Container c = new Container();
325 FontMetrics fm = c.getFontMetrics(font);
326 int ww = fm.charWidth('M');
327 setCharHeight(fm.getHeight());
330 viewStyle.setFontName(font.getName());
331 viewStyle.setFontStyle(font.getStyle());
332 viewStyle.setFontSize(font.getSize());
334 validCharWidth = true;
338 public void setViewStyle(ViewStyleI settingsForView)
340 super.setViewStyle(settingsForView);
341 setFont(new Font(viewStyle.getFontName(), viewStyle.getFontStyle(),
342 viewStyle.getFontSize()), false);
348 * @return DOCUMENT ME!
350 public Font getFont()
362 public void setAlignment(AlignmentI align)
364 replaceMappings(align);
365 super.setAlignment(align);
369 * Replace any codon mappings for this viewport with those for the given
374 public void replaceMappings(AlignmentI align)
378 * Deregister current mappings (if any)
380 deregisterMappings();
383 * Register new mappings (if any)
387 StructureSelectionManager ssm = StructureSelectionManager
388 .getStructureSelectionManager(Desktop.instance);
389 ssm.registerMappings(align.getCodonFrames());
393 * replace mappings on our alignment
395 if (alignment != null && align != null)
397 alignment.setCodonFrames(align.getCodonFrames());
401 protected void deregisterMappings()
403 AlignmentI al = getAlignment();
406 List<AlignedCodonFrame> mappings = al.getCodonFrames();
407 if (mappings != null)
409 StructureSelectionManager ssm = StructureSelectionManager
410 .getStructureSelectionManager(Desktop.instance);
411 for (AlignedCodonFrame acf : mappings)
413 if (noReferencesTo(acf))
415 ssm.deregisterMapping(acf);
425 * @return DOCUMENT ME!
428 public char getGapCharacter()
430 return getAlignment().getGapCharacter();
439 public void setGapCharacter(char gap)
441 if (getAlignment() != null)
443 getAlignment().setGapCharacter(gap);
448 * returns the visible column regions of the alignment
450 * @param selectedRegionOnly
451 * true to just return the contigs intersecting with the selected
455 public Iterator<int[]> getViewAsVisibleContigs(boolean selectedRegionOnly)
459 if (selectedRegionOnly && selectionGroup != null)
461 start = selectionGroup.getStartRes();
462 end = selectionGroup.getEndRes() + 1;
466 end = alignment.getWidth();
468 return (alignment.getHiddenColumns().getVisContigsIterator(start, end,
473 * get hash of undo and redo list for the alignment
475 * @return long[] { historyList.hashCode, redoList.hashCode };
477 public long[] getUndoRedoHash()
480 if (historyList == null || redoList == null)
482 return new long[] { -1, -1 };
484 return new long[] { historyList.hashCode(), this.redoList.hashCode() };
488 * test if a particular set of hashcodes are different to the hashcodes for
489 * the undo and redo list.
492 * the stored set of hashcodes as returned by getUndoRedoHash
493 * @return true if the hashcodes differ (ie the alignment has been edited) or
494 * the stored hashcode array differs in size
496 public boolean isUndoRedoHashModified(long[] undoredo)
498 if (undoredo == null)
502 long[] cstate = getUndoRedoHash();
503 if (cstate.length != undoredo.length)
508 for (int i = 0; i < cstate.length; i++)
510 if (cstate[i] != undoredo[i])
518 public boolean followSelection = true;
521 * @return true if view selection should always follow the selections
522 * broadcast by other selection sources
524 public boolean getFollowSelection()
526 return followSelection;
530 * Send the current selection to be broadcast to any selection listeners.
533 public void sendSelection()
535 jalview.structure.StructureSelectionManager
536 .getStructureSelectionManager(Desktop.instance)
537 .sendSelection(new SequenceGroup(getSelectionGroup()),
538 new ColumnSelection(getColumnSelection()),
539 new HiddenColumns(getAlignment().getHiddenColumns()),
544 * return the alignPanel containing the given viewport. Use this to get the
545 * components currently handling the given viewport.
548 * @return null or an alignPanel guaranteed to have non-null alignFrame
551 public AlignmentPanel getAlignPanel()
553 AlignmentPanel[] aps = PaintRefresher
554 .getAssociatedPanels(this.getSequenceSetId());
555 for (int p = 0; aps != null && p < aps.length; p++)
557 if (aps[p].av == this)
565 public boolean getSortByTree()
570 public void setSortByTree(boolean sort)
576 * Returns the (Desktop) instance of the StructureSelectionManager
579 public StructureSelectionManager getStructureSelectionManager()
581 return StructureSelectionManager
582 .getStructureSelectionManager(Desktop.instance);
586 public boolean isNormaliseSequenceLogo()
588 return normaliseSequenceLogo;
591 public void setNormaliseSequenceLogo(boolean state)
593 normaliseSequenceLogo = state;
598 * @return true if alignment characters should be displayed
601 public boolean isValidCharWidth()
603 return validCharWidth;
606 private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<>();
608 public AutoCalcSetting getCalcIdSettingsFor(String calcId)
610 return calcIdParams.get(calcId);
613 public void setCalcIdSettingsFor(String calcId, AutoCalcSetting settings,
616 calcIdParams.put(calcId, settings);
617 // TODO: create a restart list to trigger any calculations that need to be
618 // restarted after load
619 // calculator.getRegisteredWorkersOfClass(settings.getWorkerClass())
622 Cache.log.debug("trigger update for " + calcId);
627 * Method called when another alignment's edit (or possibly other) command is
630 * To allow for sequence mappings (e.g. protein to cDNA), we have to first
631 * 'unwind' the command on the source sequences (in simulation, not in fact),
632 * and then for each edit in turn:
634 * <li>compute the equivalent edit on the mapped sequences</li>
635 * <li>apply the mapped edit</li>
636 * <li>'apply' the source edit to the working copy of the source
645 public void mirrorCommand(CommandI command, boolean undo,
646 StructureSelectionManager ssm, VamsasSource source)
649 * Do nothing unless we are a 'complement' of the source. May replace this
650 * with direct calls not via SSM.
652 if (source instanceof AlignViewportI
653 && ((AlignViewportI) source).getCodingComplement() == this)
662 CommandI mappedCommand = ssm.mapCommand(command, undo, getAlignment(),
664 if (mappedCommand != null)
666 AlignmentI[] views = getAlignPanel().alignFrame.getViewAlignments();
667 mappedCommand.doCommand(views);
668 getAlignPanel().alignmentChanged();
673 * Add the sequences from the given alignment to this viewport. Optionally,
674 * may give the user the option to open a new frame, or split panel, with cDNA
675 * and protein linked.
680 public void addAlignment(AlignmentI toAdd, String title)
682 // TODO: promote to AlignViewportI? applet CutAndPasteTransfer is different
684 // JBPComment: title is a largely redundant parameter at the moment
685 // JBPComment: this really should be an 'insert/pre/append' controller
686 // JBPComment: but the DNA/Protein check makes it a bit more complex
688 // refactored from FileLoader / CutAndPasteTransfer / SequenceFetcher with
690 // TODO: create undo object for this JAL-1101
693 * Ensure datasets are created for the new alignment as
694 * mappings operate on dataset sequences
696 toAdd.setDataset(null);
699 * Check if any added sequence could be the object of a mapping or
700 * cross-reference; if so, make the mapping explicit
702 getAlignment().realiseMappings(toAdd.getSequences());
705 * If any cDNA/protein mappings exist or can be made between the alignments,
706 * offer to open a split frame with linked alignments
708 if (Cache.getDefault(Preferences.ENABLE_SPLIT_FRAME, true))
710 if (AlignmentUtils.isMappable(toAdd, getAlignment()))
712 if (openLinkedAlignment(toAdd, title))
720 * No mappings, or offer declined - add sequences to this alignment
722 // TODO: JAL-407 regardless of above - identical sequences (based on ID and
723 // provenance) should share the same dataset sequence
725 AlignmentI al = getAlignment();
726 String gap = String.valueOf(al.getGapCharacter());
727 for (int i = 0; i < toAdd.getHeight(); i++)
729 SequenceI seq = toAdd.getSequenceAt(i);
732 * - 'align' any mapped sequences as per existing
733 * e.g. cdna to genome, domain hit to protein sequence
734 * very experimental! (need a separate menu option for this)
735 * - only add mapped sequences ('select targets from a dataset')
737 if (true /*AlignmentUtils.alignSequenceAs(seq, al, gap, true, true)*/)
743 ranges.setEndSeq(getAlignment().getHeight());
744 firePropertyChange("alignment", null, getAlignment().getSequences());
748 * Show a dialog with the option to open and link (cDNA <-> protein) as a new
749 * alignment, either as a standalone alignment or in a split frame. Returns
750 * true if the new alignment was opened, false if not, because the user
751 * declined the offer.
756 protected boolean openLinkedAlignment(AlignmentI al, String title)
758 String[] options = new String[] { MessageManager.getString("action.no"),
759 MessageManager.getString("label.split_window"),
760 MessageManager.getString("label.new_window"), };
761 final String question = JvSwingUtils.wrapTooltip(true,
762 MessageManager.getString("label.open_split_window?"));
763 int response = JvOptionPane.showOptionDialog(Desktop.desktop, question,
764 MessageManager.getString("label.open_split_window"),
765 JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null,
766 options, options[0]);
768 if (response != 1 && response != 2)
772 final boolean openSplitPane = (response == 1);
773 final boolean openInNewWindow = (response == 2);
776 * Identify protein and dna alignments. Make a copy of this one if opening
777 * in a new split pane.
779 AlignmentI thisAlignment = openSplitPane ? new Alignment(getAlignment())
781 AlignmentI protein = al.isNucleotide() ? thisAlignment : al;
782 final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment;
785 * Map sequences. At least one should get mapped as we have already passed
786 * the test for 'mappability'. Any mappings made will be added to the
787 * protein alignment. Note creating dataset sequences on the new alignment
788 * is a pre-requisite for building mappings.
791 AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna);
794 * Create the AlignFrame for the added alignment. If it is protein, mappings
795 * are registered with StructureSelectionManager as a side-effect.
797 AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
798 AlignFrame.DEFAULT_HEIGHT);
799 newAlignFrame.setTitle(title);
800 newAlignFrame.statusBar.setText(MessageManager
801 .formatMessage("label.successfully_loaded_file", new Object[]
804 // TODO if we want this (e.g. to enable reload of the alignment from file),
805 // we will need to add parameters to the stack.
806 // if (!protocol.equals(DataSourceType.PASTE))
808 // alignFrame.setFileName(file, format);
813 Desktop.addInternalFrame(newAlignFrame, title,
814 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
819 newAlignFrame.setMaximum(
820 jalview.bin.Cache.getDefault("SHOW_FULLSCREEN", false));
821 } catch (java.beans.PropertyVetoException ex)
827 al.alignAs(thisAlignment);
828 protein = openSplitFrame(newAlignFrame, thisAlignment);
835 * Helper method to open a new SplitFrame holding linked dna and protein
838 * @param newAlignFrame
839 * containing a new alignment to be shown
841 * cdna/protein complement alignment to show in the other split half
842 * @return the protein alignment in the split frame
844 protected AlignmentI openSplitFrame(AlignFrame newAlignFrame,
845 AlignmentI complement)
848 * Make a new frame with a copy of the alignment we are adding to. If this
849 * is protein, the mappings to cDNA will be registered with
850 * StructureSelectionManager as a side-effect.
852 AlignFrame copyMe = new AlignFrame(complement, AlignFrame.DEFAULT_WIDTH,
853 AlignFrame.DEFAULT_HEIGHT);
854 copyMe.setTitle(getAlignPanel().alignFrame.getTitle());
856 AlignmentI al = newAlignFrame.viewport.getAlignment();
857 final AlignFrame proteinFrame = al.isNucleotide() ? copyMe
859 final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame : copyMe;
860 cdnaFrame.setVisible(true);
861 proteinFrame.setVisible(true);
862 String linkedTitle = MessageManager
863 .getString("label.linked_view_title");
866 * Open in split pane. DNA sequence above, protein below.
868 JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame);
869 Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1);
871 return proteinFrame.viewport.getAlignment();
874 public AnnotationColumnChooser getAnnotationColumnSelectionState()
876 return annotationColumnSelectionState;
879 public void setAnnotationColumnSelectionState(
880 AnnotationColumnChooser currentAnnotationColumnSelectionState)
882 this.annotationColumnSelectionState = currentAnnotationColumnSelectionState;
886 public void setIdWidth(int i)
889 AlignmentPanel ap = getAlignPanel();
892 // modify GUI elements to reflect geometry change
893 Dimension idw = getAlignPanel().getIdPanel().getIdCanvas()
896 getAlignPanel().getIdPanel().getIdCanvas().setPreferredSize(idw);
900 public Rectangle getExplodedGeometry()
902 return explodedGeometry;
905 public void setExplodedGeometry(Rectangle explodedPosition)
907 this.explodedGeometry = explodedPosition;
910 public boolean isGatherViewsHere()
912 return gatherViewsHere;
915 public void setGatherViewsHere(boolean gatherViewsHere)
917 this.gatherViewsHere = gatherViewsHere;
921 * If this viewport has a (Protein/cDNA) complement, then scroll the
922 * complementary alignment to match this one.
924 public void scrollComplementaryAlignment()
927 * Populate a SearchResults object with the mapped location to scroll to. If
928 * there is no complement, or it is not following highlights, or no mapping
929 * is found, the result will be empty.
931 SearchResultsI sr = new SearchResults();
932 int verticalOffset = findComplementScrollTarget(sr);
935 // TODO would like next line without cast but needs more refactoring...
936 final AlignmentPanel complementPanel = ((AlignViewport) getCodingComplement())
938 complementPanel.setToScrollComplementPanel(false);
939 complementPanel.scrollToCentre(sr, verticalOffset);
940 complementPanel.setToScrollComplementPanel(true);
945 * Answers true if no alignment holds a reference to the given mapping
950 protected boolean noReferencesTo(AlignedCodonFrame acf)
952 AlignFrame[] frames = Desktop.getAlignFrames();
957 for (AlignFrame af : frames)
961 for (AlignmentViewPanel ap : af.getAlignPanels())
963 AlignmentI al = ap.getAlignment();
964 if (al != null && al.getCodonFrames().contains(acf))
975 * Applies the supplied feature settings descriptor to currently known
976 * features. This supports an 'initial configuration' of feature colouring
977 * based on a preset or user favourite. This may then be modified in the usual
978 * way using the Feature Settings dialogue.
980 * @param featureSettings
983 public void applyFeaturesStyle(FeatureSettingsModelI featureSettings)
985 if (featureSettings == null)
990 FeatureRenderer fr = getAlignPanel().getSeqPanel().seqCanvas
991 .getFeatureRenderer();
992 fr.findAllFeatures(true);
993 List<String> renderOrder = fr.getRenderOrder();
994 FeaturesDisplayedI displayed = fr.getFeaturesDisplayed();
996 // TODO this clears displayed.featuresRegistered - do we care?
999 * set feature colour if specified by feature settings
1000 * set visibility of all features
1002 for (String type : renderOrder)
1004 FeatureColourI preferredColour = featureSettings
1005 .getFeatureColour(type);
1006 if (preferredColour != null)
1008 fr.setColour(type, preferredColour);
1010 if (featureSettings.isFeatureDisplayed(type))
1012 displayed.setVisible(type);
1017 * set visibility of feature groups
1019 for (String group : fr.getFeatureGroups())
1021 fr.setGroupVisibility(group, featureSettings.isGroupDisplayed(group));
1025 * order the features
1027 if (featureSettings.optimiseOrder())
1029 // TODO not supported (yet?)
1033 fr.orderFeatures(featureSettings);
1035 fr.setTransparency(featureSettings.getTransparency());