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(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);
309 boolean validCharWidth;
315 public void setFont(Font f, boolean setGrid)
319 Container c = new Container();
323 FontMetrics fm = c.getFontMetrics(font);
324 int ww = fm.charWidth('M');
325 setCharHeight(fm.getHeight());
328 viewStyle.setFontName(font.getName());
329 viewStyle.setFontStyle(font.getStyle());
330 viewStyle.setFontSize(font.getSize());
332 validCharWidth = true;
336 public void setViewStyle(ViewStyleI settingsForView)
338 super.setViewStyle(settingsForView);
339 setFont(new Font(viewStyle.getFontName(), viewStyle.getFontStyle(),
340 viewStyle.getFontSize()), false);
346 * @return DOCUMENT ME!
348 public Font getFont()
360 public void setAlignment(AlignmentI align)
362 replaceMappings(align);
363 super.setAlignment(align);
367 * Replace any codon mappings for this viewport with those for the given
372 public void replaceMappings(AlignmentI align)
376 * Deregister current mappings (if any)
378 deregisterMappings();
381 * Register new mappings (if any)
385 StructureSelectionManager ssm = StructureSelectionManager
386 .getStructureSelectionManager(Desktop.instance);
387 ssm.registerMappings(align.getCodonFrames());
391 * replace mappings on our alignment
393 if (alignment != null && align != null)
395 alignment.setCodonFrames(align.getCodonFrames());
399 protected void deregisterMappings()
401 AlignmentI al = getAlignment();
404 List<AlignedCodonFrame> mappings = al.getCodonFrames();
405 if (mappings != null)
407 StructureSelectionManager ssm = StructureSelectionManager
408 .getStructureSelectionManager(Desktop.instance);
409 for (AlignedCodonFrame acf : mappings)
411 if (noReferencesTo(acf))
413 ssm.deregisterMapping(acf);
423 * @return DOCUMENT ME!
426 public char getGapCharacter()
428 return getAlignment().getGapCharacter();
437 public void setGapCharacter(char gap)
439 if (getAlignment() != null)
441 getAlignment().setGapCharacter(gap);
446 * returns the visible column regions of the alignment
448 * @param selectedRegionOnly
449 * true to just return the contigs intersecting with the selected
453 public Iterator<int[]> getViewAsVisibleContigs(boolean selectedRegionOnly)
457 if (selectedRegionOnly && selectionGroup != null)
459 start = selectionGroup.getStartRes();
460 end = selectionGroup.getEndRes() + 1;
464 end = alignment.getWidth();
466 return (alignment.getHiddenColumns().getVisContigsIterator(start, end,
471 * get hash of undo and redo list for the alignment
473 * @return long[] { historyList.hashCode, redoList.hashCode };
475 public long[] getUndoRedoHash()
478 if (historyList == null || redoList == null)
480 return new long[] { -1, -1 };
482 return new long[] { historyList.hashCode(), this.redoList.hashCode() };
486 * test if a particular set of hashcodes are different to the hashcodes for
487 * the undo and redo list.
490 * the stored set of hashcodes as returned by getUndoRedoHash
491 * @return true if the hashcodes differ (ie the alignment has been edited) or
492 * the stored hashcode array differs in size
494 public boolean isUndoRedoHashModified(long[] undoredo)
496 if (undoredo == null)
500 long[] cstate = getUndoRedoHash();
501 if (cstate.length != undoredo.length)
506 for (int i = 0; i < cstate.length; i++)
508 if (cstate[i] != undoredo[i])
516 public boolean followSelection = true;
519 * @return true if view selection should always follow the selections
520 * broadcast by other selection sources
522 public boolean getFollowSelection()
524 return followSelection;
528 * Send the current selection to be broadcast to any selection listeners.
531 public void sendSelection()
533 jalview.structure.StructureSelectionManager
534 .getStructureSelectionManager(Desktop.instance)
535 .sendSelection(new SequenceGroup(getSelectionGroup()),
536 new ColumnSelection(getColumnSelection()),
537 new HiddenColumns(getAlignment().getHiddenColumns()),
542 * return the alignPanel containing the given viewport. Use this to get the
543 * components currently handling the given viewport.
546 * @return null or an alignPanel guaranteed to have non-null alignFrame
549 public AlignmentPanel getAlignPanel()
551 AlignmentPanel[] aps = PaintRefresher
552 .getAssociatedPanels(this.getSequenceSetId());
553 for (int p = 0; aps != null && p < aps.length; p++)
555 if (aps[p].av == this)
563 public boolean getSortByTree()
568 public void setSortByTree(boolean sort)
574 * Returns the (Desktop) instance of the StructureSelectionManager
577 public StructureSelectionManager getStructureSelectionManager()
579 return StructureSelectionManager
580 .getStructureSelectionManager(Desktop.instance);
584 public boolean isNormaliseSequenceLogo()
586 return normaliseSequenceLogo;
589 public void setNormaliseSequenceLogo(boolean state)
591 normaliseSequenceLogo = state;
596 * @return true if alignment characters should be displayed
599 public boolean isValidCharWidth()
601 return validCharWidth;
604 private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<>();
606 public AutoCalcSetting getCalcIdSettingsFor(String calcId)
608 return calcIdParams.get(calcId);
611 public void setCalcIdSettingsFor(String calcId, AutoCalcSetting settings,
614 calcIdParams.put(calcId, settings);
615 // TODO: create a restart list to trigger any calculations that need to be
616 // restarted after load
617 // calculator.getRegisteredWorkersOfClass(settings.getWorkerClass())
620 Cache.log.debug("trigger update for " + calcId);
625 * Method called when another alignment's edit (or possibly other) command is
628 * To allow for sequence mappings (e.g. protein to cDNA), we have to first
629 * 'unwind' the command on the source sequences (in simulation, not in fact),
630 * and then for each edit in turn:
632 * <li>compute the equivalent edit on the mapped sequences</li>
633 * <li>apply the mapped edit</li>
634 * <li>'apply' the source edit to the working copy of the source
643 public void mirrorCommand(CommandI command, boolean undo,
644 StructureSelectionManager ssm, VamsasSource source)
647 * Do nothing unless we are a 'complement' of the source. May replace this
648 * with direct calls not via SSM.
650 if (source instanceof AlignViewportI
651 && ((AlignViewportI) source).getCodingComplement() == this)
660 CommandI mappedCommand = ssm.mapCommand(command, undo, getAlignment(),
662 if (mappedCommand != null)
664 AlignmentI[] views = getAlignPanel().alignFrame.getViewAlignments();
665 mappedCommand.doCommand(views);
666 getAlignPanel().alignmentChanged();
671 * Add the sequences from the given alignment to this viewport. Optionally,
672 * may give the user the option to open a new frame, or split panel, with cDNA
673 * and protein linked.
678 public void addAlignment(AlignmentI toAdd, String title)
680 // TODO: promote to AlignViewportI? applet CutAndPasteTransfer is different
682 // JBPComment: title is a largely redundant parameter at the moment
683 // JBPComment: this really should be an 'insert/pre/append' controller
684 // JBPComment: but the DNA/Protein check makes it a bit more complex
686 // refactored from FileLoader / CutAndPasteTransfer / SequenceFetcher with
688 // TODO: create undo object for this JAL-1101
691 * Ensure datasets are created for the new alignment as
692 * mappings operate on dataset sequences
694 toAdd.setDataset(null);
697 * Check if any added sequence could be the object of a mapping or
698 * cross-reference; if so, make the mapping explicit
700 getAlignment().realiseMappings(toAdd.getSequences());
703 * If any cDNA/protein mappings exist or can be made between the alignments,
704 * offer to open a split frame with linked alignments
706 if (Cache.getDefault(Preferences.ENABLE_SPLIT_FRAME, true))
708 if (AlignmentUtils.isMappable(toAdd, getAlignment()))
710 openLinkedAlignment(toAdd, title);
714 addDataToAlignment(toAdd);
718 * adds sequences to this alignment
722 void addDataToAlignment(AlignmentI toAdd)
724 // TODO: JAL-407 regardless of above - identical sequences (based on ID and
725 // provenance) should share the same dataset sequence
727 AlignmentI al = getAlignment();
728 String gap = String.valueOf(al.getGapCharacter());
729 for (int i = 0; i < toAdd.getHeight(); i++)
731 SequenceI seq = toAdd.getSequenceAt(i);
734 * - 'align' any mapped sequences as per existing
735 * e.g. cdna to genome, domain hit to protein sequence
736 * very experimental! (need a separate menu option for this)
737 * - only add mapped sequences ('select targets from a dataset')
739 if (true /*AlignmentUtils.alignSequenceAs(seq, al, gap, true, true)*/)
745 ranges.setEndSeq(getAlignment().getHeight());
746 firePropertyChange("alignment", null, getAlignment().getSequences());
750 * Show a dialog with the option to open and link (cDNA <-> protein) as a new
751 * alignment, either as a standalone alignment or in a split frame. Returns
752 * true if the new alignment was opened, false if not, because the user
753 * declined the offer.
758 protected void openLinkedAlignment(AlignmentI al, String title)
760 String[] options = new String[] { MessageManager.getString("action.no"),
761 MessageManager.getString("label.split_window"),
762 MessageManager.getString("label.new_window"), };
763 final String question = JvSwingUtils.wrapTooltip(true,
764 MessageManager.getString("label.open_split_window?"));
765 final AlignViewport us = this;
768 * options No, Split Window, New Window correspond to
769 * dialog responses 0, 1, 2 (even though JOptionPane shows them
772 JvOptionPane dialog = JvOptionPane.newOptionDialog(Desktop.desktop)
773 .setResponseHandler(0, new Runnable()
778 addDataToAlignment(al);
780 }).setResponseHandler(1, new Runnable()
785 us.openLinkedAlignmentAs(al, title, true);
787 }).setResponseHandler(2, new Runnable()
792 us.openLinkedAlignmentAs(al, title, false);
795 dialog.showDialog(question,
796 MessageManager.getString("label.open_split_window"),
797 JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null,
798 options, options[0]);
801 protected void openLinkedAlignmentAs(AlignmentI al, String title,
802 boolean newWindowOrSplitPane)
805 * Identify protein and dna alignments. Make a copy of this one if opening
806 * in a new split pane.
808 AlignmentI thisAlignment = newWindowOrSplitPane
809 ? new Alignment(getAlignment())
811 AlignmentI protein = al.isNucleotide() ? thisAlignment : al;
812 final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment;
815 * Map sequences. At least one should get mapped as we have already passed
816 * the test for 'mappability'. Any mappings made will be added to the
817 * protein alignment. Note creating dataset sequences on the new alignment
818 * is a pre-requisite for building mappings.
821 AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna);
824 * Create the AlignFrame for the added alignment. If it is protein, mappings
825 * are registered with StructureSelectionManager as a side-effect.
827 AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
828 AlignFrame.DEFAULT_HEIGHT);
829 newAlignFrame.setTitle(title);
830 newAlignFrame.setStatus(MessageManager
831 .formatMessage("label.successfully_loaded_file", new Object[]
834 // TODO if we want this (e.g. to enable reload of the alignment from file),
835 // we will need to add parameters to the stack.
836 // if (!protocol.equals(DataSourceType.PASTE))
838 // alignFrame.setFileName(file, format);
841 if (!newWindowOrSplitPane)
843 Desktop.addInternalFrame(newAlignFrame, title,
844 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
849 newAlignFrame.setMaximum(
850 jalview.bin.Cache.getDefault("SHOW_FULLSCREEN", false));
851 } catch (java.beans.PropertyVetoException ex)
855 if (newWindowOrSplitPane)
857 al.alignAs(thisAlignment);
858 protein = openSplitFrame(newAlignFrame, thisAlignment);
863 * Helper method to open a new SplitFrame holding linked dna and protein
866 * @param newAlignFrame
867 * containing a new alignment to be shown
869 * cdna/protein complement alignment to show in the other split half
870 * @return the protein alignment in the split frame
872 protected AlignmentI openSplitFrame(AlignFrame newAlignFrame,
873 AlignmentI complement)
876 * Make a new frame with a copy of the alignment we are adding to. If this
877 * is protein, the mappings to cDNA will be registered with
878 * StructureSelectionManager as a side-effect.
880 AlignFrame copyMe = new AlignFrame(complement, AlignFrame.DEFAULT_WIDTH,
881 AlignFrame.DEFAULT_HEIGHT);
882 copyMe.setTitle(getAlignPanel().alignFrame.getTitle());
884 AlignmentI al = newAlignFrame.viewport.getAlignment();
885 final AlignFrame proteinFrame = al.isNucleotide() ? copyMe
887 final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame : copyMe;
888 cdnaFrame.setVisible(true);
889 proteinFrame.setVisible(true);
890 String linkedTitle = MessageManager
891 .getString("label.linked_view_title");
894 * Open in split pane. DNA sequence above, protein below.
896 JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame);
897 Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1);
899 return proteinFrame.viewport.getAlignment();
902 public AnnotationColumnChooser getAnnotationColumnSelectionState()
904 return annotationColumnSelectionState;
907 public void setAnnotationColumnSelectionState(
908 AnnotationColumnChooser currentAnnotationColumnSelectionState)
910 this.annotationColumnSelectionState = currentAnnotationColumnSelectionState;
914 public void setIdWidth(int i)
917 AlignmentPanel ap = getAlignPanel();
920 // modify GUI elements to reflect geometry change
921 Dimension idw = getAlignPanel().getIdPanel().getIdCanvas()
924 getAlignPanel().getIdPanel().getIdCanvas().setPreferredSize(idw);
928 public Rectangle getExplodedGeometry()
930 return explodedGeometry;
933 public void setExplodedGeometry(Rectangle explodedPosition)
935 this.explodedGeometry = explodedPosition;
938 public boolean isGatherViewsHere()
940 return gatherViewsHere;
943 public void setGatherViewsHere(boolean gatherViewsHere)
945 this.gatherViewsHere = gatherViewsHere;
949 * If this viewport has a (Protein/cDNA) complement, then scroll the
950 * complementary alignment to match this one.
952 public void scrollComplementaryAlignment()
955 * Populate a SearchResults object with the mapped location to scroll to. If
956 * there is no complement, or it is not following highlights, or no mapping
957 * is found, the result will be empty.
959 SearchResultsI sr = new SearchResults();
960 int verticalOffset = findComplementScrollTarget(sr);
963 // TODO would like next line without cast but needs more refactoring...
964 final AlignmentPanel complementPanel = ((AlignViewport) getCodingComplement())
966 complementPanel.setToScrollComplementPanel(false);
967 complementPanel.scrollToCentre(sr, verticalOffset);
968 complementPanel.setToScrollComplementPanel(true);
973 * Answers true if no alignment holds a reference to the given mapping
978 protected boolean noReferencesTo(AlignedCodonFrame acf)
980 AlignFrame[] frames = Desktop.getAlignFrames();
985 for (AlignFrame af : frames)
989 for (AlignmentViewPanel ap : af.getAlignPanels())
991 AlignmentI al = ap.getAlignment();
992 if (al != null && al.getCodonFrames().contains(acf))
1003 * Applies the supplied feature settings descriptor to currently known
1004 * features. This supports an 'initial configuration' of feature colouring
1005 * based on a preset or user favourite. This may then be modified in the usual
1006 * way using the Feature Settings dialogue.
1008 * @param featureSettings
1011 public void applyFeaturesStyle(FeatureSettingsModelI featureSettings)
1013 if (featureSettings == null)
1018 FeatureRenderer fr = getAlignPanel().getSeqPanel().seqCanvas
1019 .getFeatureRenderer();
1020 fr.findAllFeatures(true);
1021 List<String> renderOrder = fr.getRenderOrder();
1022 FeaturesDisplayedI displayed = fr.getFeaturesDisplayed();
1024 // TODO this clears displayed.featuresRegistered - do we care?
1027 * set feature colour if specified by feature settings
1028 * set visibility of all features
1030 for (String type : renderOrder)
1032 FeatureColourI preferredColour = featureSettings
1033 .getFeatureColour(type);
1034 if (preferredColour != null)
1036 fr.setColour(type, preferredColour);
1038 if (featureSettings.isFeatureDisplayed(type))
1040 displayed.setVisible(type);
1045 * set visibility of feature groups
1047 for (String group : fr.getFeatureGroups())
1049 fr.setGroupVisibility(group, featureSettings.isGroupDisplayed(group));
1053 * order the features
1055 if (featureSettings.optimiseOrder())
1057 // TODO not supported (yet?)
1061 fr.orderFeatures(featureSettings);
1063 fr.setTransparency(featureSettings.getTransparency());
1066 public String getViewName()
1071 public void setViewName(String viewName)
1073 this.viewName = viewName;