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;
82 private String viewName;
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);
258 .setGapCharacter(Cache.getDefault("GAP_SYMBOL", "-").charAt(0));
260 // We must set conservation and consensus before setting colour,
261 // as Blosum and Clustal require this to be done
262 if (hconsensus == null && !isDataset)
264 if (!alignment.isNucleotide())
266 showConservation = Cache.getDefault("SHOW_CONSERVATION", true);
267 showQuality = Cache.getDefault("SHOW_QUALITY", true);
268 showGroupConservation = Cache.getDefault("SHOW_GROUP_CONSERVATION",
271 showConsensusHistogram = Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM",
273 showSequenceLogo = Cache.getDefault("SHOW_CONSENSUS_LOGO", false);
274 normaliseSequenceLogo = Cache.getDefault("NORMALISE_CONSENSUS_LOGO",
276 showGroupConsensus = Cache.getDefault("SHOW_GROUP_CONSENSUS", false);
277 showConsensus = Cache.getDefault("SHOW_IDENTITY", true);
279 showOccupancy = Cache.getDefault(Preferences.SHOW_OCCUPANCY, true);
281 initAutoAnnotation();
282 String colourProperty = alignment.isNucleotide()
283 ? Preferences.DEFAULT_COLOUR_NUC
284 : Preferences.DEFAULT_COLOUR_PROT;
285 String schemeName = Cache.getProperty(colourProperty);
286 if (schemeName == null)
288 // only DEFAULT_COLOUR available in Jalview before 2.9
289 schemeName = Cache.getDefault(Preferences.DEFAULT_COLOUR,
290 ResidueColourScheme.NONE);
292 ColourSchemeI colourScheme = ColourSchemeProperty
293 .getColourScheme(this, alignment, schemeName);
294 residueShading = new ResidueShader(colourScheme);
296 if (colourScheme instanceof UserColourScheme)
298 residueShading = new ResidueShader(
299 UserDefinedColours.loadDefaultColours());
300 residueShading.setThreshold(0, isIgnoreGapsConsensus());
303 if (residueShading != null)
305 residueShading.setConsensus(hconsensus);
307 setColourAppliesToAllGroups(true);
310 boolean validCharWidth;
316 public void setFont(Font f, boolean setGrid)
320 Container c = new Container();
324 FontMetrics fm = c.getFontMetrics(font);
325 int ww = fm.charWidth('M');
326 setCharHeight(fm.getHeight());
329 viewStyle.setFontName(font.getName());
330 viewStyle.setFontStyle(font.getStyle());
331 viewStyle.setFontSize(font.getSize());
333 validCharWidth = true;
337 public void setViewStyle(ViewStyleI settingsForView)
339 super.setViewStyle(settingsForView);
340 setFont(new Font(viewStyle.getFontName(), viewStyle.getFontStyle(),
341 viewStyle.getFontSize()), false);
347 * @return DOCUMENT ME!
349 public Font getFont()
361 public void setAlignment(AlignmentI align)
363 replaceMappings(align);
364 super.setAlignment(align);
368 * Replace any codon mappings for this viewport with those for the given
373 public void replaceMappings(AlignmentI align)
377 * Deregister current mappings (if any)
379 deregisterMappings();
382 * Register new mappings (if any)
386 StructureSelectionManager ssm = StructureSelectionManager
387 .getStructureSelectionManager(Desktop.instance);
388 ssm.registerMappings(align.getCodonFrames());
392 * replace mappings on our alignment
394 if (alignment != null && align != null)
396 alignment.setCodonFrames(align.getCodonFrames());
400 protected void deregisterMappings()
402 AlignmentI al = getAlignment();
405 List<AlignedCodonFrame> mappings = al.getCodonFrames();
406 if (mappings != null)
408 StructureSelectionManager ssm = StructureSelectionManager
409 .getStructureSelectionManager(Desktop.instance);
410 for (AlignedCodonFrame acf : mappings)
412 if (noReferencesTo(acf))
414 ssm.deregisterMapping(acf);
424 * @return DOCUMENT ME!
427 public char getGapCharacter()
429 return getAlignment().getGapCharacter();
438 public void setGapCharacter(char gap)
440 if (getAlignment() != null)
442 getAlignment().setGapCharacter(gap);
447 * returns the visible column regions of the alignment
449 * @param selectedRegionOnly
450 * true to just return the contigs intersecting with the selected
454 public Iterator<int[]> getViewAsVisibleContigs(boolean selectedRegionOnly)
458 if (selectedRegionOnly && selectionGroup != null)
460 start = selectionGroup.getStartRes();
461 end = selectionGroup.getEndRes() + 1;
465 end = alignment.getWidth();
467 return (alignment.getHiddenColumns().getVisContigsIterator(start, end,
472 * get hash of undo and redo list for the alignment
474 * @return long[] { historyList.hashCode, redoList.hashCode };
476 public long[] getUndoRedoHash()
479 if (historyList == null || redoList == null)
481 return new long[] { -1, -1 };
483 return new long[] { historyList.hashCode(), this.redoList.hashCode() };
487 * test if a particular set of hashcodes are different to the hashcodes for
488 * the undo and redo list.
491 * the stored set of hashcodes as returned by getUndoRedoHash
492 * @return true if the hashcodes differ (ie the alignment has been edited) or
493 * the stored hashcode array differs in size
495 public boolean isUndoRedoHashModified(long[] undoredo)
497 if (undoredo == null)
501 long[] cstate = getUndoRedoHash();
502 if (cstate.length != undoredo.length)
507 for (int i = 0; i < cstate.length; i++)
509 if (cstate[i] != undoredo[i])
517 public boolean followSelection = true;
520 * @return true if view selection should always follow the selections
521 * broadcast by other selection sources
523 public boolean getFollowSelection()
525 return followSelection;
529 * Send the current selection to be broadcast to any selection listeners.
532 public void sendSelection()
534 jalview.structure.StructureSelectionManager
535 .getStructureSelectionManager(Desktop.instance)
536 .sendSelection(new SequenceGroup(getSelectionGroup()),
537 new ColumnSelection(getColumnSelection()),
538 new HiddenColumns(getAlignment().getHiddenColumns()),
543 * return the alignPanel containing the given viewport. Use this to get the
544 * components currently handling the given viewport.
547 * @return null or an alignPanel guaranteed to have non-null alignFrame
550 public AlignmentPanel getAlignPanel()
552 AlignmentPanel[] aps = PaintRefresher
553 .getAssociatedPanels(this.getSequenceSetId());
554 for (int p = 0; aps != null && p < aps.length; p++)
556 if (aps[p].av == this)
564 public boolean getSortByTree()
569 public void setSortByTree(boolean sort)
575 * Returns the (Desktop) instance of the StructureSelectionManager
578 public StructureSelectionManager getStructureSelectionManager()
580 return StructureSelectionManager
581 .getStructureSelectionManager(Desktop.instance);
585 public boolean isNormaliseSequenceLogo()
587 return normaliseSequenceLogo;
590 public void setNormaliseSequenceLogo(boolean state)
592 normaliseSequenceLogo = state;
597 * @return true if alignment characters should be displayed
600 public boolean isValidCharWidth()
602 return validCharWidth;
605 private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<>();
607 public AutoCalcSetting getCalcIdSettingsFor(String calcId)
609 return calcIdParams.get(calcId);
612 public void setCalcIdSettingsFor(String calcId, AutoCalcSetting settings,
615 calcIdParams.put(calcId, settings);
616 // TODO: create a restart list to trigger any calculations that need to be
617 // restarted after load
618 // calculator.getRegisteredWorkersOfClass(settings.getWorkerClass())
621 Cache.log.debug("trigger update for " + calcId);
626 * Method called when another alignment's edit (or possibly other) command is
629 * To allow for sequence mappings (e.g. protein to cDNA), we have to first
630 * 'unwind' the command on the source sequences (in simulation, not in fact),
631 * and then for each edit in turn:
633 * <li>compute the equivalent edit on the mapped sequences</li>
634 * <li>apply the mapped edit</li>
635 * <li>'apply' the source edit to the working copy of the source
644 public void mirrorCommand(CommandI command, boolean undo,
645 StructureSelectionManager ssm, VamsasSource source)
648 * Do nothing unless we are a 'complement' of the source. May replace this
649 * with direct calls not via SSM.
651 if (source instanceof AlignViewportI
652 && ((AlignViewportI) source).getCodingComplement() == this)
661 CommandI mappedCommand = ssm.mapCommand(command, undo, getAlignment(),
663 if (mappedCommand != null)
665 AlignmentI[] views = getAlignPanel().alignFrame.getViewAlignments();
666 mappedCommand.doCommand(views);
667 getAlignPanel().alignmentChanged();
672 * Add the sequences from the given alignment to this viewport. Optionally,
673 * may give the user the option to open a new frame, or split panel, with cDNA
674 * and protein linked.
679 public void addAlignment(AlignmentI toAdd, String title)
681 // TODO: promote to AlignViewportI? applet CutAndPasteTransfer is different
683 // JBPComment: title is a largely redundant parameter at the moment
684 // JBPComment: this really should be an 'insert/pre/append' controller
685 // JBPComment: but the DNA/Protein check makes it a bit more complex
687 // refactored from FileLoader / CutAndPasteTransfer / SequenceFetcher with
689 // TODO: create undo object for this JAL-1101
692 * Ensure datasets are created for the new alignment as
693 * mappings operate on dataset sequences
695 toAdd.setDataset(null);
698 * Check if any added sequence could be the object of a mapping or
699 * cross-reference; if so, make the mapping explicit
701 getAlignment().realiseMappings(toAdd.getSequences());
704 * If any cDNA/protein mappings exist or can be made between the alignments,
705 * offer to open a split frame with linked alignments
707 if (Cache.getDefault(Preferences.ENABLE_SPLIT_FRAME, true))
709 if (AlignmentUtils.isMappable(toAdd, getAlignment()))
711 if (openLinkedAlignment(toAdd, title))
719 * No mappings, or offer declined - add sequences to this alignment
721 // TODO: JAL-407 regardless of above - identical sequences (based on ID and
722 // provenance) should share the same dataset sequence
724 AlignmentI al = getAlignment();
725 String gap = String.valueOf(al.getGapCharacter());
726 for (int i = 0; i < toAdd.getHeight(); i++)
728 SequenceI seq = toAdd.getSequenceAt(i);
731 * - 'align' any mapped sequences as per existing
732 * e.g. cdna to genome, domain hit to protein sequence
733 * very experimental! (need a separate menu option for this)
734 * - only add mapped sequences ('select targets from a dataset')
736 if (true /*AlignmentUtils.alignSequenceAs(seq, al, gap, true, true)*/)
742 ranges.setEndSeq(getAlignment().getHeight());
743 firePropertyChange("alignment", null, getAlignment().getSequences());
747 * Show a dialog with the option to open and link (cDNA <-> protein) as a new
748 * alignment, either as a standalone alignment or in a split frame. Returns
749 * true if the new alignment was opened, false if not, because the user
750 * declined the offer.
755 protected boolean openLinkedAlignment(AlignmentI al, String title)
757 String[] options = new String[] { MessageManager.getString("action.no"),
758 MessageManager.getString("label.split_window"),
759 MessageManager.getString("label.new_window"), };
760 final String question = JvSwingUtils.wrapTooltip(true,
761 MessageManager.getString("label.open_split_window?"));
762 int response = JvOptionPane.showOptionDialog(Desktop.desktop, question,
763 MessageManager.getString("label.open_split_window"),
764 JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null,
765 options, options[0]);
767 if (response != 1 && response != 2)
771 final boolean openSplitPane = (response == 1);
772 final boolean openInNewWindow = (response == 2);
775 * Identify protein and dna alignments. Make a copy of this one if opening
776 * in a new split pane.
778 AlignmentI thisAlignment = openSplitPane ? new Alignment(getAlignment())
780 AlignmentI protein = al.isNucleotide() ? thisAlignment : al;
781 final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment;
784 * Map sequences. At least one should get mapped as we have already passed
785 * the test for 'mappability'. Any mappings made will be added to the
786 * protein alignment. Note creating dataset sequences on the new alignment
787 * is a pre-requisite for building mappings.
790 AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna);
793 * Create the AlignFrame for the added alignment. If it is protein, mappings
794 * are registered with StructureSelectionManager as a side-effect.
796 AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
797 AlignFrame.DEFAULT_HEIGHT);
798 newAlignFrame.setTitle(title);
799 newAlignFrame.setStatus(MessageManager
800 .formatMessage("label.successfully_loaded_file", new Object[]
803 // TODO if we want this (e.g. to enable reload of the alignment from file),
804 // we will need to add parameters to the stack.
805 // if (!protocol.equals(DataSourceType.PASTE))
807 // alignFrame.setFileName(file, format);
812 Desktop.addInternalFrame(newAlignFrame, title,
813 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
818 newAlignFrame.setMaximum(
819 jalview.bin.Cache.getDefault("SHOW_FULLSCREEN", false));
820 } catch (java.beans.PropertyVetoException ex)
826 al.alignAs(thisAlignment);
827 protein = openSplitFrame(newAlignFrame, thisAlignment);
834 * Helper method to open a new SplitFrame holding linked dna and protein
837 * @param newAlignFrame
838 * containing a new alignment to be shown
840 * cdna/protein complement alignment to show in the other split half
841 * @return the protein alignment in the split frame
843 protected AlignmentI openSplitFrame(AlignFrame newAlignFrame,
844 AlignmentI complement)
847 * Make a new frame with a copy of the alignment we are adding to. If this
848 * is protein, the mappings to cDNA will be registered with
849 * StructureSelectionManager as a side-effect.
851 AlignFrame copyMe = new AlignFrame(complement, AlignFrame.DEFAULT_WIDTH,
852 AlignFrame.DEFAULT_HEIGHT);
853 copyMe.setTitle(getAlignPanel().alignFrame.getTitle());
855 AlignmentI al = newAlignFrame.viewport.getAlignment();
856 final AlignFrame proteinFrame = al.isNucleotide() ? copyMe
858 final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame : copyMe;
859 cdnaFrame.setVisible(true);
860 proteinFrame.setVisible(true);
861 String linkedTitle = MessageManager
862 .getString("label.linked_view_title");
865 * Open in split pane. DNA sequence above, protein below.
867 JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame);
868 Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1);
870 return proteinFrame.viewport.getAlignment();
873 public AnnotationColumnChooser getAnnotationColumnSelectionState()
875 return annotationColumnSelectionState;
878 public void setAnnotationColumnSelectionState(
879 AnnotationColumnChooser currentAnnotationColumnSelectionState)
881 this.annotationColumnSelectionState = currentAnnotationColumnSelectionState;
885 public void setIdWidth(int i)
888 AlignmentPanel ap = getAlignPanel();
891 // modify GUI elements to reflect geometry change
892 Dimension idw = getAlignPanel().getIdPanel().getIdCanvas()
895 getAlignPanel().getIdPanel().getIdCanvas().setPreferredSize(idw);
899 public Rectangle getExplodedGeometry()
901 return explodedGeometry;
904 public void setExplodedGeometry(Rectangle explodedPosition)
906 this.explodedGeometry = explodedPosition;
909 public boolean isGatherViewsHere()
911 return gatherViewsHere;
914 public void setGatherViewsHere(boolean gatherViewsHere)
916 this.gatherViewsHere = gatherViewsHere;
920 * If this viewport has a (Protein/cDNA) complement, then scroll the
921 * complementary alignment to match this one.
923 public void scrollComplementaryAlignment()
926 * Populate a SearchResults object with the mapped location to scroll to. If
927 * there is no complement, or it is not following highlights, or no mapping
928 * is found, the result will be empty.
930 SearchResultsI sr = new SearchResults();
931 int verticalOffset = findComplementScrollTarget(sr);
934 // TODO would like next line without cast but needs more refactoring...
935 final AlignmentPanel complementPanel = ((AlignViewport) getCodingComplement())
937 complementPanel.setToScrollComplementPanel(false);
938 complementPanel.scrollToCentre(sr, verticalOffset);
939 complementPanel.setToScrollComplementPanel(true);
944 * Answers true if no alignment holds a reference to the given mapping
949 protected boolean noReferencesTo(AlignedCodonFrame acf)
951 AlignFrame[] frames = Desktop.getAlignFrames();
956 for (AlignFrame af : frames)
960 for (AlignmentViewPanel ap : af.getAlignPanels())
962 AlignmentI al = ap.getAlignment();
963 if (al != null && al.getCodonFrames().contains(acf))
974 * Applies the supplied feature settings descriptor to currently known
975 * features. This supports an 'initial configuration' of feature colouring
976 * based on a preset or user favourite. This may then be modified in the usual
977 * way using the Feature Settings dialogue.
979 * @param featureSettings
982 public void applyFeaturesStyle(FeatureSettingsModelI featureSettings)
984 if (featureSettings == null)
989 FeatureRenderer fr = getAlignPanel().getSeqPanel().seqCanvas
990 .getFeatureRenderer();
991 fr.findAllFeatures(true);
992 List<String> renderOrder = fr.getRenderOrder();
993 FeaturesDisplayedI displayed = fr.getFeaturesDisplayed();
995 // TODO this clears displayed.featuresRegistered - do we care?
998 * set feature colour if specified by feature settings
999 * set visibility of all features
1001 for (String type : renderOrder)
1003 FeatureColourI preferredColour = featureSettings
1004 .getFeatureColour(type);
1005 if (preferredColour != null)
1007 fr.setColour(type, preferredColour);
1009 if (featureSettings.isFeatureDisplayed(type))
1011 displayed.setVisible(type);
1016 * set visibility of feature groups
1018 for (String group : fr.getFeatureGroups())
1020 fr.setGroupVisibility(group, featureSettings.isGroupDisplayed(group));
1024 * order the features
1026 if (featureSettings.optimiseOrder())
1028 // TODO not supported (yet?)
1032 fr.orderFeatures(featureSettings);
1034 fr.setTransparency(featureSettings.getTransparency());
1037 public String getViewName()
1042 public void setViewName(String viewName)
1044 this.viewName = viewName;