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(Preferences.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(
223 Cache.getDefault(Preferences.WRAP_ALIGNMENT, false));
224 viewStyle.setShowUnconserved(
225 Cache.getDefault(Preferences.SHOW_UNCONSERVED, false));
226 sortByTree = Cache.getDefault(Preferences.SORT_BY_TREE, false);
227 followSelection = Cache.getDefault("FOLLOW_SELECTIONS", true);
228 sortAnnotationsBy = SequenceAnnotationOrder
229 .valueOf(Cache.getDefault(Preferences.SORT_ANNOTATIONS,
230 SequenceAnnotationOrder.NONE.name()));
231 showAutocalculatedAbove = Cache
232 .getDefault(Preferences.SHOW_AUTOCALC_ABOVE, false);
233 viewStyle.setScaleProteinAsCdna(
234 Cache.getDefault(Preferences.SCALE_PROTEIN_TO_CDNA, true));
239 applyViewProperties();
241 String fontName = Cache.getDefault("FONT_NAME", "SansSerif");
242 String fontStyle = Cache.getDefault("FONT_STYLE", Font.PLAIN + "");
243 String fontSize = Cache.getDefault("FONT_SIZE", "10");
247 if (fontStyle.equals("bold"))
251 else if (fontStyle.equals("italic"))
256 setFont(new Font(fontName, style, Integer.parseInt(fontSize)), true);
259 .setGapCharacter(Cache.getDefault("GAP_SYMBOL", "-").charAt(0));
261 // We must set conservation and consensus before setting colour,
262 // as Blosum and Clustal require this to be done
263 if (hconsensus == null && !isDataset)
265 if (!alignment.isNucleotide())
267 showConservation = Cache.getDefault(Preferences.SHOW_CONSERVATION, true);
268 showQuality = Cache.getDefault(Preferences.SHOW_QUALITY, true);
269 showGroupConservation = Cache.getDefault("SHOW_GROUP_CONSERVATION",
272 showConsensusHistogram = Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM",
274 showSequenceLogo = Cache.getDefault(Preferences.SHOW_CONSENSUS_LOGO, false);
276 normaliseSequenceLogo = Cache.getDefault(
277 Preferences.NORMALISE_CONSENSUS_LOGO,
279 showGroupConsensus = Cache
280 .getDefault(Preferences.SHOW_GROUP_CONSENSUS, false);
281 showConsensus = Cache.getDefault("SHOW_IDENTITY", true);
283 showOccupancy = Cache.getDefault(Preferences.SHOW_OCCUPANCY, true);
285 initAutoAnnotation();
286 String colourProperty = alignment.isNucleotide()
287 ? Preferences.DEFAULT_COLOUR_NUC
288 : Preferences.DEFAULT_COLOUR_PROT;
289 String schemeName = Cache.getProperty(colourProperty);
290 if (schemeName == null)
292 // only DEFAULT_COLOUR available in Jalview before 2.9
293 schemeName = Cache.getDefault(Preferences.DEFAULT_COLOUR,
294 ResidueColourScheme.NONE);
296 ColourSchemeI colourScheme = ColourSchemeProperty
297 .getColourScheme(this, alignment, schemeName);
298 residueShading = new ResidueShader(colourScheme);
300 if (colourScheme instanceof UserColourScheme)
302 residueShading = new ResidueShader(
303 UserDefinedColours.loadDefaultColours());
304 residueShading.setThreshold(0, isIgnoreGapsConsensus());
307 if (residueShading != null)
309 residueShading.setConsensus(hconsensus);
311 setColourAppliesToAllGroups(true);
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 Desktop.getInstance().getStructureSelectionManager()
391 .registerMappings(align.getCodonFrames());
395 * replace mappings on our alignment
397 if (alignment != null && align != null)
399 alignment.setCodonFrames(align.getCodonFrames());
403 protected void deregisterMappings()
405 AlignmentI al = getAlignment();
408 List<AlignedCodonFrame> mappings = al.getCodonFrames();
409 if (mappings != null)
411 StructureSelectionManager ssm = Desktop.getInstance()
412 .getStructureSelectionManager();
413 for (AlignedCodonFrame acf : mappings)
415 if (noReferencesTo(acf))
417 ssm.deregisterMapping(acf);
427 * @return DOCUMENT ME!
430 public char getGapCharacter()
432 return getAlignment().getGapCharacter();
441 public void setGapCharacter(char gap)
443 if (getAlignment() != null)
445 getAlignment().setGapCharacter(gap);
450 * returns the visible column regions of the alignment
452 * @param selectedRegionOnly
453 * true to just return the contigs intersecting with the selected
457 public Iterator<int[]> getViewAsVisibleContigs(boolean selectedRegionOnly)
461 if (selectedRegionOnly && selectionGroup != null)
463 start = selectionGroup.getStartRes();
464 end = selectionGroup.getEndRes() + 1;
468 end = alignment.getWidth();
470 return (alignment.getHiddenColumns().getVisContigsIterator(start, end,
475 * get hash of undo and redo list for the alignment
477 * @return long[] { historyList.hashCode, redoList.hashCode };
479 public long[] getUndoRedoHash()
482 if (historyList == null || redoList == null)
484 return new long[] { -1, -1 };
486 return new long[] { historyList.hashCode(), this.redoList.hashCode() };
490 * test if a particular set of hashcodes are different to the hashcodes for
491 * the undo and redo list.
494 * the stored set of hashcodes as returned by getUndoRedoHash
495 * @return true if the hashcodes differ (ie the alignment has been edited) or
496 * the stored hashcode array differs in size
498 public boolean isUndoRedoHashModified(long[] undoredo)
500 if (undoredo == null)
504 long[] cstate = getUndoRedoHash();
505 if (cstate.length != undoredo.length)
510 for (int i = 0; i < cstate.length; i++)
512 if (cstate[i] != undoredo[i])
520 public boolean followSelection = true;
523 * @return true if view selection should always follow the selections
524 * broadcast by other selection sources
526 public boolean getFollowSelection()
528 return followSelection;
532 * Send the current selection to be broadcast to any selection listeners.
535 public void sendSelection()
537 Desktop.getInstance().getStructureSelectionManager().sendSelection(
538 new SequenceGroup(getSelectionGroup()),
539 new ColumnSelection(getColumnSelection()),
540 new HiddenColumns(getAlignment().getHiddenColumns()), this);
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 Desktop.getInstance().getStructureSelectionManager();
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 openLinkedAlignment(toAdd, title);
715 addDataToAlignment(toAdd);
719 * adds sequences to this alignment
723 void addDataToAlignment(AlignmentI toAdd)
725 // TODO: JAL-407 regardless of above - identical sequences (based on ID and
726 // provenance) should share the same dataset sequence
728 AlignmentI al = getAlignment();
729 String gap = String.valueOf(al.getGapCharacter());
730 for (int i = 0; i < toAdd.getHeight(); i++)
732 SequenceI seq = toAdd.getSequenceAt(i);
735 * - 'align' any mapped sequences as per existing
736 * e.g. cdna to genome, domain hit to protein sequence
737 * very experimental! (need a separate menu option for this)
738 * - only add mapped sequences ('select targets from a dataset')
740 if (true /*AlignmentUtils.alignSequenceAs(seq, al, gap, true, true)*/)
746 ranges.setEndSeq(getAlignment().getHeight() - 1); // BH 2019.04.18
747 firePropertyChange("alignment", null, getAlignment().getSequences());
750 public final static int NO_SPLIT = 0;
752 public final static int SPLIT_FRAME = 1;
754 public final static int NEW_WINDOW = 2;
757 * Show a dialog with the option to open and link (cDNA <-> protein) as a new
758 * alignment, either as a standalone alignment or in a split frame. Returns
759 * true if the new alignment was opened, false if not, because the user
760 * declined the offer.
765 protected void openLinkedAlignment(AlignmentI al, String title)
767 String[] options = new String[] { MessageManager.getString("action.no"),
768 MessageManager.getString("label.split_window"),
769 MessageManager.getString("label.new_window"), };
770 final String question = JvSwingUtils.wrapTooltip(true,
771 MessageManager.getString("label.open_split_window?"));
775 * options No, Split Window, New Window correspond to
776 * dialog responses 0, 1, 2 (even though JOptionPane shows them
779 JvOptionPane dialog = JvOptionPane.newOptionDialog(Desktop.getDesktopPane())
780 .setResponseHandler(NO_SPLIT, new Runnable()
785 addDataToAlignment(al);
787 }).setResponseHandler(SPLIT_FRAME, new Runnable()
792 openLinkedAlignmentAs(getAlignPanel().alignFrame,
793 new Alignment(getAlignment()), al,
796 }).setResponseHandler(NEW_WINDOW, new Runnable()
801 openLinkedAlignmentAs(null, getAlignment(), al, title,
805 dialog.showDialog(question,
806 MessageManager.getString("label.open_split_window"),
807 JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null,
808 options, options[0]);
812 * Open a split frame or a new window
817 * SPLIT_FRAME or NEW_WINDOW
819 public static void openLinkedAlignmentAs(AlignFrame thisFrame, AlignmentI thisAlignment,
820 AlignmentI al, String title,
824 * Identify protein and dna alignments. Make a copy of this one if opening
825 * in a new split pane.
827 AlignmentI protein = al.isNucleotide() ? thisAlignment : al;
828 AlignmentI cdna = al.isNucleotide() ? al : thisAlignment;
831 * Map sequences. At least one should get mapped as we have already passed
832 * the test for 'mappability'. Any mappings made will be added to the
833 * protein alignment. Note creating dataset sequences on the new alignment
834 * is a pre-requisite for building mappings.
837 AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna);
840 * Create the AlignFrame for the added alignment. If it is protein, mappings
841 * are registered with StructureSelectionManager as a side-effect.
843 AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
844 AlignFrame.DEFAULT_HEIGHT);
845 newAlignFrame.setTitle(title);
846 newAlignFrame.setStatus(MessageManager
847 .formatMessage("label.successfully_loaded_file", new Object[]
850 // TODO if we want this (e.g. to enable reload of the alignment from file),
851 // we will need to add parameters to the stack.
852 // if (!protocol.equals(DataSourceType.PASTE))
854 // alignFrame.setFileName(file, format);
857 if (mode == NEW_WINDOW)
859 Desktop.addInternalFrame(newAlignFrame, title,
860 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
865 newAlignFrame.setMaximum(
866 jalview.bin.Cache.getDefault("SHOW_FULLSCREEN", false));
867 } catch (java.beans.PropertyVetoException ex)
871 if (mode == SPLIT_FRAME)
873 al.alignAs(thisAlignment);
874 openSplitFrame(thisFrame, newAlignFrame, thisAlignment);
879 * Helper method to open a new SplitFrame holding linked dna and protein
882 * @param newAlignFrame
883 * containing a new alignment to be shown
885 * cdna/protein complement alignment to show in the other split half
886 * @return the protein alignment in the split frame
888 static protected AlignmentI openSplitFrame(AlignFrame thisFrame,
889 AlignFrame newAlignFrame,
890 AlignmentI complement)
893 * Make a new frame with a copy of the alignment we are adding to. If this
894 * is protein, the mappings to cDNA will be registered with
895 * StructureSelectionManager as a side-effect.
897 AlignFrame copyMe = new AlignFrame(complement, AlignFrame.DEFAULT_WIDTH,
898 AlignFrame.DEFAULT_HEIGHT);
899 copyMe.setTitle(thisFrame.getTitle());
901 AlignmentI al = newAlignFrame.viewport.getAlignment();
902 final AlignFrame proteinFrame = al.isNucleotide() ? copyMe
904 final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame : copyMe;
905 cdnaFrame.setVisible(true);
906 proteinFrame.setVisible(true);
907 String linkedTitle = MessageManager
908 .getString("label.linked_view_title");
911 * Open in split pane. DNA sequence above, protein below.
913 JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame);
914 Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1);
916 return proteinFrame.viewport.getAlignment();
919 public AnnotationColumnChooser getAnnotationColumnSelectionState()
921 return annotationColumnSelectionState;
924 public void setAnnotationColumnSelectionState(
925 AnnotationColumnChooser currentAnnotationColumnSelectionState)
927 this.annotationColumnSelectionState = currentAnnotationColumnSelectionState;
931 public void setIdWidth(int i)
934 AlignmentPanel ap = getAlignPanel();
937 // modify GUI elements to reflect geometry change
938 Dimension idw = getAlignPanel().getIdPanel().getIdCanvas()
941 getAlignPanel().getIdPanel().getIdCanvas().setPreferredSize(idw);
945 public Rectangle getExplodedGeometry()
947 return explodedGeometry;
950 public void setExplodedGeometry(Rectangle explodedPosition)
952 this.explodedGeometry = explodedPosition;
955 public boolean isGatherViewsHere()
957 return gatherViewsHere;
960 public void setGatherViewsHere(boolean gatherViewsHere)
962 this.gatherViewsHere = gatherViewsHere;
966 * If this viewport has a (Protein/cDNA) complement, then scroll the
967 * complementary alignment to match this one.
969 public void scrollComplementaryAlignment()
972 * Populate a SearchResults object with the mapped location to scroll to. If
973 * there is no complement, or it is not following highlights, or no mapping
974 * is found, the result will be empty.
976 SearchResultsI sr = new SearchResults();
977 int verticalOffset = findComplementScrollTarget(sr);
980 // TODO would like next line without cast but needs more refactoring...
981 final AlignmentPanel complementPanel = ((AlignViewport) getCodingComplement())
983 complementPanel.setToScrollComplementPanel(false);
984 complementPanel.scrollToCentre(sr, verticalOffset);
985 complementPanel.setToScrollComplementPanel(true);
990 * Answers true if no alignment holds a reference to the given mapping
995 protected boolean noReferencesTo(AlignedCodonFrame acf)
997 AlignFrame[] frames = Desktop.getAlignFrames();
1002 for (AlignFrame af : frames)
1006 for (AlignmentViewPanel ap : af.getAlignPanels())
1008 AlignmentI al = ap.getAlignment();
1009 if (al != null && al.getCodonFrames().contains(acf))
1020 * Applies the supplied feature settings descriptor to currently known
1021 * features. This supports an 'initial configuration' of feature colouring
1022 * based on a preset or user favourite. This may then be modified in the usual
1023 * way using the Feature Settings dialogue.
1025 * @param featureSettings
1028 public void applyFeaturesStyle(FeatureSettingsModelI featureSettings)
1030 if (featureSettings == null)
1035 FeatureRenderer fr = getAlignPanel().getSeqPanel().seqCanvas
1036 .getFeatureRenderer();
1037 fr.findAllFeatures(true);
1038 List<String> renderOrder = fr.getRenderOrder();
1039 FeaturesDisplayedI displayed = fr.getFeaturesDisplayed();
1041 // TODO this clears displayed.featuresRegistered - do we care?
1044 * set feature colour if specified by feature settings
1045 * set visibility of all features
1047 for (String type : renderOrder)
1049 FeatureColourI preferredColour = featureSettings
1050 .getFeatureColour(type);
1051 if (preferredColour != null)
1053 fr.setColour(type, preferredColour);
1055 if (featureSettings.isFeatureDisplayed(type))
1057 displayed.setVisible(type);
1062 * set visibility of feature groups
1064 for (String group : fr.getFeatureGroups())
1066 fr.setGroupVisibility(group, featureSettings.isGroupDisplayed(group));
1070 * order the features
1072 if (featureSettings.optimiseOrder())
1074 // TODO not supported (yet?)
1078 fr.orderFeatures(featureSettings);
1080 fr.setTransparency(featureSettings.getTransparency());
1083 public String getViewName()
1088 public void setViewName(String viewName)
1090 this.viewName = viewName;