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(Preferences.ANTI_ALIAS, false);
211 viewStyle.setShowJVSuffix(
212 Cache.getDefault(Preferences.SHOW_JVSUFFIX, true));
213 setShowAnnotation(Cache.getDefault(Preferences.SHOW_ANNOTATIONS, true));
215 setRightAlignIds(Cache.getDefault(Preferences.RIGHT_ALIGN_IDS, false));
216 setCentreColumnLabels(Cache.getDefault(Preferences.CENTRE_COLUMN_LABELS, false));
217 autoCalculateConsensusAndConservation = Cache.getDefault(Preferences.AUTO_CALC_CONSENSUS, true);
219 setPadGaps(Cache.getDefault(Preferences.PAD_GAPS, true));
220 setShowNPFeats(Cache.getDefault(Preferences.SHOW_NPFEATS_TOOLTIP, true));
221 setShowDBRefs(Cache.getDefault(Preferences.SHOW_DBREFS_TOOLTIP, true));
222 viewStyle.setSeqNameItalics(Cache.getDefault(Preferences.ID_ITALICS, true));
223 viewStyle.setWrapAlignment(
224 Cache.getDefault(Preferences.WRAP_ALIGNMENT, false));
225 viewStyle.setShowUnconserved(
226 Cache.getDefault(Preferences.SHOW_UNCONSERVED, false));
227 sortByTree = Cache.getDefault(Preferences.SORT_BY_TREE, false);
228 followSelection = Cache.getDefault(Preferences.FOLLOW_SELECTIONS, true);
229 sortAnnotationsBy = SequenceAnnotationOrder
230 .valueOf(Cache.getDefault(Preferences.SORT_ANNOTATIONS,
231 SequenceAnnotationOrder.NONE.name()));
232 showAutocalculatedAbove = Cache
233 .getDefault(Preferences.SHOW_AUTOCALC_ABOVE, false);
234 viewStyle.setScaleProteinAsCdna(
235 Cache.getDefault(Preferences.SCALE_PROTEIN_TO_CDNA, true));
240 applyViewProperties();
242 String fontName = Cache.getDefault(Preferences.FONT_NAME, "SansSerif");
243 String fontStyle = Cache.getDefault(Preferences.FONT_STYLE,
245 String fontSize = Cache.getDefault(Preferences.FONT_SIZE, "10");
249 if (fontStyle.equals("bold"))
253 else if (fontStyle.equals("italic"))
258 setFont(new Font(fontName, style, Integer.parseInt(fontSize)), true);
261 .setGapCharacter(Cache.getDefault(Preferences.GAP_SYMBOL, "-")
264 // We must set conservation and consensus before setting colour,
265 // as Blosum and Clustal require this to be done
266 if (hconsensus == null && !isDataset)
268 if (!alignment.isNucleotide())
270 showConservation = Cache.getDefault(Preferences.SHOW_CONSERVATION,
272 showQuality = Cache.getDefault(Preferences.SHOW_QUALITY, true);
273 showGroupConservation = Cache
274 .getDefault(Preferences.SHOW_GROUP_CONSERVATION, false);
276 showConsensusHistogram = Cache
277 .getDefault(Preferences.SHOW_CONSENSUS_HISTOGRAM, true);
278 showSequenceLogo = Cache.getDefault(Preferences.SHOW_CONSENSUS_LOGO,
281 normaliseSequenceLogo = Cache
282 .getDefault(Preferences.NORMALISE_CONSENSUS_LOGO, false);
283 showGroupConsensus = Cache
284 .getDefault(Preferences.SHOW_GROUP_CONSENSUS, false);
285 showConsensus = Cache.getDefault(Preferences.SHOW_IDENTITY, true);
287 showOccupancy = Cache.getDefault(Preferences.SHOW_OCCUPANCY, true);
289 initAutoAnnotation();
290 String colourProperty = alignment.isNucleotide()
291 ? Preferences.DEFAULT_COLOUR_NUC
292 : Preferences.DEFAULT_COLOUR_PROT;
293 String schemeName = Cache.getProperty(colourProperty);
294 if (schemeName == null)
296 // only DEFAULT_COLOUR available in Jalview before 2.9
297 schemeName = Cache.getDefault(Preferences.DEFAULT_COLOUR,
298 ResidueColourScheme.NONE);
300 ColourSchemeI colourScheme = ColourSchemeProperty.getColourScheme(this,
301 alignment, schemeName);
302 residueShading = new ResidueShader(colourScheme);
304 if (colourScheme instanceof UserColourScheme)
306 residueShading = new ResidueShader(
307 UserDefinedColours.loadDefaultColours());
308 residueShading.setThreshold(0, isIgnoreGapsConsensus());
311 if (residueShading != null)
313 residueShading.setConsensus(hconsensus);
315 setColourAppliesToAllGroups(true);
318 boolean validCharWidth;
324 public void setFont(Font f, boolean setGrid)
328 Container c = new Container();
332 FontMetrics fm = c.getFontMetrics(font);
333 int ww = fm.charWidth('M');
334 setCharHeight(fm.getHeight());
337 viewStyle.setFontName(font.getName());
338 viewStyle.setFontStyle(font.getStyle());
339 viewStyle.setFontSize(font.getSize());
341 validCharWidth = true;
345 public void setViewStyle(ViewStyleI settingsForView)
347 super.setViewStyle(settingsForView);
348 setFont(new Font(viewStyle.getFontName(), viewStyle.getFontStyle(),
349 viewStyle.getFontSize()), false);
355 * @return DOCUMENT ME!
357 public Font getFont()
369 public void setAlignment(AlignmentI align)
371 replaceMappings(align);
372 super.setAlignment(align);
376 * Replace any codon mappings for this viewport with those for the given
381 public void replaceMappings(AlignmentI align)
385 * Deregister current mappings (if any)
387 deregisterMappings();
390 * Register new mappings (if any)
394 getStructureSelectionManager()
395 .registerMappings(align.getCodonFrames());
399 * replace mappings on our alignment
401 if (alignment != null && align != null)
403 alignment.setCodonFrames(align.getCodonFrames());
407 protected void deregisterMappings()
409 AlignmentI al = getAlignment();
412 List<AlignedCodonFrame> mappings = al.getCodonFrames();
413 if (mappings != null && Desktop.getInstance() != null)
415 // StructureSelectionManager ssm = Desktop.getInstance()
416 // .getStructureSelectionManager();
418 // BH 2019.08.27 allows for null Desktop instance
419 StructureSelectionManager ssm = getStructureSelectionManager();
420 for (AlignedCodonFrame acf : mappings)
422 if (noReferencesTo(acf))
424 ssm.deregisterMapping(acf);
434 * @return DOCUMENT ME!
437 public char getGapCharacter()
439 return getAlignment().getGapCharacter();
448 public void setGapCharacter(char gap)
450 if (getAlignment() != null)
452 getAlignment().setGapCharacter(gap);
457 * returns the visible column regions of the alignment
459 * @param selectedRegionOnly
460 * true to just return the contigs intersecting with the selected
464 public Iterator<int[]> getViewAsVisibleContigs(boolean selectedRegionOnly)
468 if (selectedRegionOnly && selectionGroup != null)
470 start = selectionGroup.getStartRes();
471 end = selectionGroup.getEndRes() + 1;
475 end = alignment.getWidth();
477 return (alignment.getHiddenColumns().getVisContigsIterator(start, end,
482 * get hash of undo and redo list for the alignment
484 * @return long[] { historyList.hashCode, redoList.hashCode };
486 public long[] getUndoRedoHash()
489 if (historyList == null || redoList == null)
491 return new long[] { -1, -1 };
493 return new long[] { historyList.hashCode(), this.redoList.hashCode() };
497 * test if a particular set of hashcodes are different to the hashcodes for
498 * the undo and redo list.
501 * the stored set of hashcodes as returned by getUndoRedoHash
502 * @return true if the hashcodes differ (ie the alignment has been edited) or
503 * the stored hashcode array differs in size
505 public boolean isUndoRedoHashModified(long[] undoredo)
507 if (undoredo == null)
511 long[] cstate = getUndoRedoHash();
512 if (cstate.length != undoredo.length)
517 for (int i = 0; i < cstate.length; i++)
519 if (cstate[i] != undoredo[i])
527 public boolean followSelection = true;
530 * @return true if view selection should always follow the selections
531 * broadcast by other selection sources
533 public boolean getFollowSelection()
535 return followSelection;
539 * Send the current selection to be broadcast to any selection listeners.
542 public void sendSelection()
544 getStructureSelectionManager().sendSelection(
545 new SequenceGroup(getSelectionGroup()),
546 new ColumnSelection(getColumnSelection()),
547 new HiddenColumns(getAlignment().getHiddenColumns()), this);
551 * return the alignPanel containing the given viewport. Use this to get the
552 * components currently handling the given viewport.
555 * @return null or an alignPanel guaranteed to have non-null alignFrame
558 public AlignmentPanel getAlignPanel()
560 AlignmentPanel[] aps = PaintRefresher
561 .getAssociatedPanels(this.getSequenceSetId());
562 for (int p = 0; aps != null && p < aps.length; p++)
564 if (aps[p].av == this)
572 public boolean getSortByTree()
577 public void setSortByTree(boolean sort)
583 * Returns the (Desktop) instance of the StructureSelectionManager
586 public StructureSelectionManager getStructureSelectionManager()
588 // BH allows for null Desktop instance
589 return StructureSelectionManager
590 .getStructureSelectionManager(Desktop.getInstance());
594 public boolean isNormaliseSequenceLogo()
596 return normaliseSequenceLogo;
599 public void setNormaliseSequenceLogo(boolean state)
601 normaliseSequenceLogo = state;
606 * @return true if alignment characters should be displayed
609 public boolean isValidCharWidth()
611 return validCharWidth;
614 private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<>();
616 public AutoCalcSetting getCalcIdSettingsFor(String calcId)
618 return calcIdParams.get(calcId);
621 public void setCalcIdSettingsFor(String calcId, AutoCalcSetting settings,
624 calcIdParams.put(calcId, settings);
625 // TODO: create a restart list to trigger any calculations that need to be
626 // restarted after load
627 // calculator.getRegisteredWorkersOfClass(settings.getWorkerClass())
630 Cache.log.debug("trigger update for " + calcId);
635 * Method called when another alignment's edit (or possibly other) command is
638 * To allow for sequence mappings (e.g. protein to cDNA), we have to first
639 * 'unwind' the command on the source sequences (in simulation, not in fact),
640 * and then for each edit in turn:
642 * <li>compute the equivalent edit on the mapped sequences</li>
643 * <li>apply the mapped edit</li>
644 * <li>'apply' the source edit to the working copy of the source
653 public void mirrorCommand(CommandI command, boolean undo,
654 StructureSelectionManager ssm, VamsasSource source)
657 * Do nothing unless we are a 'complement' of the source. May replace this
658 * with direct calls not via SSM.
660 if (source instanceof AlignViewportI
661 && ((AlignViewportI) source).getCodingComplement() == this)
670 CommandI mappedCommand = ssm.mapCommand(command, undo, getAlignment(),
672 if (mappedCommand != null)
674 AlignmentI[] views = getAlignPanel().alignFrame.getViewAlignments();
675 mappedCommand.doCommand(views);
676 getAlignPanel().alignmentChanged();
681 * Add the sequences from the given alignment to this viewport. Optionally,
682 * may give the user the option to open a new frame, or split panel, with cDNA
683 * and protein linked.
688 public void addAlignment(AlignmentI toAdd, String title)
690 // TODO: promote to AlignViewportI? applet CutAndPasteTransfer is different
692 // JBPComment: title is a largely redundant parameter at the moment
693 // JBPComment: this really should be an 'insert/pre/append' controller
694 // JBPComment: but the DNA/Protein check makes it a bit more complex
696 // refactored from FileLoader / CutAndPasteTransfer / SequenceFetcher with
698 // TODO: create undo object for this JAL-1101
701 * Ensure datasets are created for the new alignment as
702 * mappings operate on dataset sequences
704 toAdd.setDataset(null);
707 * Check if any added sequence could be the object of a mapping or
708 * cross-reference; if so, make the mapping explicit
710 getAlignment().realiseMappings(toAdd.getSequences());
713 * If any cDNA/protein mappings exist or can be made between the alignments,
714 * offer to open a split frame with linked alignments
716 if (Cache.getDefault(Preferences.ENABLE_SPLIT_FRAME, true))
718 if (AlignmentUtils.isMappable(toAdd, getAlignment()))
720 openLinkedAlignment(toAdd, title);
724 addDataToAlignment(toAdd);
728 * adds sequences to this alignment
732 void addDataToAlignment(AlignmentI toAdd)
734 // TODO: JAL-407 regardless of above - identical sequences (based on ID and
735 // provenance) should share the same dataset sequence
737 AlignmentI al = getAlignment();
738 String gap = String.valueOf(al.getGapCharacter());
739 for (int i = 0; i < toAdd.getHeight(); i++)
741 SequenceI seq = toAdd.getSequenceAt(i);
744 * - 'align' any mapped sequences as per existing
745 * e.g. cdna to genome, domain hit to protein sequence
746 * very experimental! (need a separate menu option for this)
747 * - only add mapped sequences ('select targets from a dataset')
749 if (true /*AlignmentUtils.alignSequenceAs(seq, al, gap, true, true)*/)
755 ranges.setEndSeq(getAlignment().getHeight() - 1); // BH 2019.04.18
756 firePropertyChange("alignment", null, getAlignment().getSequences());
759 public final static int NO_SPLIT = 0;
761 public final static int SPLIT_FRAME = 1;
763 public final static int NEW_WINDOW = 2;
766 * Show a dialog with the option to open and link (cDNA <-> protein) as a new
767 * alignment, either as a standalone alignment or in a split frame. Returns
768 * true if the new alignment was opened, false if not, because the user
769 * declined the offer.
774 protected void openLinkedAlignment(AlignmentI al, String title)
776 String[] options = new String[] { MessageManager.getString("action.no"),
777 MessageManager.getString("label.split_window"),
778 MessageManager.getString("label.new_window"), };
779 final String question = JvSwingUtils.wrapTooltip(true,
780 MessageManager.getString("label.open_split_window?"));
783 * options No, Split Window, New Window correspond to
784 * dialog responses 0, 1, 2 (even though JOptionPane shows them
787 JvOptionPane dialog = JvOptionPane
788 .newOptionDialog(Desktop.getDesktopPane())
789 .setResponseHandler(NO_SPLIT, new Runnable()
794 addDataToAlignment(al);
796 }).setResponseHandler(SPLIT_FRAME, new Runnable()
801 openLinkedAlignmentAs(getAlignPanel().alignFrame,
802 new Alignment(getAlignment()), al, title,
805 }).setResponseHandler(NEW_WINDOW, new Runnable()
810 openLinkedAlignmentAs(null, getAlignment(), al, title,
814 dialog.showDialog(question,
815 MessageManager.getString("label.open_split_window"),
816 JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null,
817 options, options[0]);
821 * Open a split frame or a new window
826 * SPLIT_FRAME or NEW_WINDOW
828 public static void openLinkedAlignmentAs(AlignFrame thisFrame,
829 AlignmentI thisAlignment, AlignmentI al, String title, int mode)
832 * Identify protein and dna alignments. Make a copy of this one if opening
833 * in a new split pane.
835 AlignmentI protein = al.isNucleotide() ? thisAlignment : al;
836 AlignmentI cdna = al.isNucleotide() ? al : thisAlignment;
839 * Map sequences. At least one should get mapped as we have already passed
840 * the test for 'mappability'. Any mappings made will be added to the
841 * protein alignment. Note creating dataset sequences on the new alignment
842 * is a pre-requisite for building mappings.
845 AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna);
848 * Create the AlignFrame for the added alignment. If it is protein, mappings
849 * are registered with StructureSelectionManager as a side-effect.
851 AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
852 AlignFrame.DEFAULT_HEIGHT);
853 newAlignFrame.setTitle(title);
854 newAlignFrame.setStatus(MessageManager
855 .formatMessage("label.successfully_loaded_file", new Object[]
858 // TODO if we want this (e.g. to enable reload of the alignment from file),
859 // we will need to add parameters to the stack.
860 // if (!protocol.equals(DataSourceType.PASTE))
862 // alignFrame.setFileName(file, format);
865 if (mode == NEW_WINDOW)
867 Desktop.addInternalFrame(newAlignFrame, title,
868 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
873 newAlignFrame.setMaximum(jalview.bin.Cache
874 .getDefault(Preferences.SHOW_FULLSCREEN, false));
875 } catch (java.beans.PropertyVetoException ex)
879 if (mode == SPLIT_FRAME)
881 al.alignAs(thisAlignment);
882 openSplitFrame(thisFrame, newAlignFrame, thisAlignment);
887 * Helper method to open a new SplitFrame holding linked dna and protein
890 * @param newAlignFrame
891 * containing a new alignment to be shown
893 * cdna/protein complement alignment to show in the other split half
894 * @return the protein alignment in the split frame
896 static protected AlignmentI openSplitFrame(AlignFrame thisFrame,
897 AlignFrame newAlignFrame, AlignmentI complement)
900 * Make a new frame with a copy of the alignment we are adding to. If this
901 * is protein, the mappings to cDNA will be registered with
902 * StructureSelectionManager as a side-effect.
904 AlignFrame copyMe = new AlignFrame(complement, AlignFrame.DEFAULT_WIDTH,
905 AlignFrame.DEFAULT_HEIGHT);
906 copyMe.setTitle(thisFrame.getTitle());
908 AlignmentI al = newAlignFrame.viewport.getAlignment();
909 final AlignFrame proteinFrame = al.isNucleotide() ? copyMe
911 final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame : copyMe;
912 cdnaFrame.setVisible(true);
913 proteinFrame.setVisible(true);
914 String linkedTitle = MessageManager
915 .getString("label.linked_view_title");
918 * Open in split pane. DNA sequence above, protein below.
920 JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame);
921 Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1);
923 return proteinFrame.viewport.getAlignment();
926 public AnnotationColumnChooser getAnnotationColumnSelectionState()
928 return annotationColumnSelectionState;
931 public void setAnnotationColumnSelectionState(
932 AnnotationColumnChooser currentAnnotationColumnSelectionState)
934 this.annotationColumnSelectionState = currentAnnotationColumnSelectionState;
938 public void setIdWidth(int i)
941 AlignmentPanel ap = getAlignPanel();
944 // modify GUI elements to reflect geometry change
945 Dimension idw = getAlignPanel().getIdPanel().getIdCanvas()
948 getAlignPanel().getIdPanel().getIdCanvas().setPreferredSize(idw);
952 public Rectangle getExplodedGeometry()
954 return explodedGeometry;
957 public void setExplodedGeometry(Rectangle explodedPosition)
959 this.explodedGeometry = explodedPosition;
962 public boolean isGatherViewsHere()
964 return gatherViewsHere;
967 public void setGatherViewsHere(boolean gatherViewsHere)
969 this.gatherViewsHere = gatherViewsHere;
973 * If this viewport has a (Protein/cDNA) complement, then scroll the
974 * complementary alignment to match this one.
976 public void scrollComplementaryAlignment()
979 * Populate a SearchResults object with the mapped location to scroll to. If
980 * there is no complement, or it is not following highlights, or no mapping
981 * is found, the result will be empty.
983 SearchResultsI sr = new SearchResults();
984 int verticalOffset = findComplementScrollTarget(sr);
987 // TODO would like next line without cast but needs more refactoring...
988 final AlignmentPanel complementPanel = ((AlignViewport) getCodingComplement())
990 complementPanel.setToScrollComplementPanel(false);
991 complementPanel.scrollToCentre(sr, verticalOffset);
992 complementPanel.setToScrollComplementPanel(true);
997 * Answers true if no alignment holds a reference to the given mapping
1002 protected boolean noReferencesTo(AlignedCodonFrame acf)
1004 AlignFrame[] frames = Desktop.getAlignFrames();
1009 for (AlignFrame af : frames)
1013 for (AlignmentViewPanel ap : af.getAlignPanels())
1015 AlignmentI al = ap.getAlignment();
1016 if (al != null && al.getCodonFrames().contains(acf))
1027 * Applies the supplied feature settings descriptor to currently known
1028 * features. This supports an 'initial configuration' of feature colouring
1029 * based on a preset or user favourite. This may then be modified in the usual
1030 * way using the Feature Settings dialogue.
1032 * @param featureSettings
1035 public void applyFeaturesStyle(FeatureSettingsModelI featureSettings)
1037 if (featureSettings == null)
1042 FeatureRenderer fr = getAlignPanel().getSeqPanel().seqCanvas
1043 .getFeatureRenderer();
1044 fr.findAllFeatures(true);
1045 List<String> renderOrder = fr.getRenderOrder();
1046 FeaturesDisplayedI displayed = fr.getFeaturesDisplayed();
1048 // TODO this clears displayed.featuresRegistered - do we care?
1051 * set feature colour if specified by feature settings
1052 * set visibility of all features
1054 for (String type : renderOrder)
1056 FeatureColourI preferredColour = featureSettings
1057 .getFeatureColour(type);
1058 if (preferredColour != null)
1060 fr.setColour(type, preferredColour);
1062 if (featureSettings.isFeatureDisplayed(type))
1064 displayed.setVisible(type);
1069 * set visibility of feature groups
1071 for (String group : fr.getFeatureGroups())
1073 fr.setGroupVisibility(group, featureSettings.isGroupDisplayed(group));
1077 * order the features
1079 if (featureSettings.optimiseOrder())
1081 // TODO not supported (yet?)
1085 fr.orderFeatures(featureSettings);
1087 fr.setTransparency(featureSettings.getTransparency());
1090 public String getViewName()
1095 public void setViewName(String viewName)
1097 this.viewName = viewName;