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.analysis.TreeModel;
26 import jalview.api.AlignViewportI;
27 import jalview.api.AlignmentViewPanel;
28 import jalview.api.FeatureColourI;
29 import jalview.api.FeatureSettingsModelI;
30 import jalview.api.FeaturesDisplayedI;
31 import jalview.api.ViewStyleI;
32 import jalview.bin.Cache;
33 import jalview.commands.CommandI;
34 import jalview.datamodel.AlignedCodonFrame;
35 import jalview.datamodel.Alignment;
36 import jalview.datamodel.AlignmentI;
37 import jalview.datamodel.ColumnSelection;
38 import jalview.datamodel.HiddenColumns;
39 import jalview.datamodel.PDBEntry;
40 import jalview.datamodel.SearchResults;
41 import jalview.datamodel.SearchResultsI;
42 import jalview.datamodel.SequenceGroup;
43 import jalview.datamodel.SequenceI;
44 import jalview.renderer.ResidueShader;
45 import jalview.schemes.ColourSchemeI;
46 import jalview.schemes.ColourSchemeProperty;
47 import jalview.schemes.ResidueColourScheme;
48 import jalview.schemes.UserColourScheme;
49 import jalview.structure.SelectionSource;
50 import jalview.structure.StructureSelectionManager;
51 import jalview.structure.VamsasSource;
52 import jalview.util.MessageManager;
53 import jalview.viewmodel.AlignmentViewport;
54 import jalview.ws.params.AutoCalcSetting;
56 import java.awt.Container;
57 import java.awt.Dimension;
59 import java.awt.FontMetrics;
60 import java.awt.Rectangle;
61 import java.util.ArrayList;
62 import java.util.Hashtable;
63 import java.util.List;
64 import java.util.Vector;
66 import javax.swing.JInternalFrame;
72 * @version $Revision: 1.141 $
74 public class AlignViewport extends AlignmentViewport
75 implements SelectionSource
79 TreeModel currentTree = null;
81 boolean cursorMode = false;
83 boolean antiAlias = false;
85 private Rectangle explodedGeometry;
90 * Flag set true on the view that should 'gather' multiple views of the same
91 * sequence set id when a project is reloaded. Set false on all views when
92 * they are 'exploded' into separate windows. Set true on the current view
93 * when 'Gather' is performed, and also on the first tab when the first new
96 private boolean gatherViewsHere = false;
98 private AnnotationColumnChooser annotationColumnSelectionState;
101 * Creates a new AlignViewport object.
106 public AlignViewport(AlignmentI al)
113 * Create a new AlignViewport object with a specific sequence set ID
117 * (may be null - but potential for ambiguous constructor exception)
119 public AlignViewport(AlignmentI al, String seqsetid)
121 this(al, seqsetid, null);
124 public AlignViewport(AlignmentI al, String seqsetid, String viewid)
127 sequenceSetID = seqsetid;
129 // TODO remove these once 2.4.VAMSAS release finished
130 if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null)
133 "Setting viewport's sequence set id : " + sequenceSetID);
135 if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null)
137 Cache.log.debug("Setting viewport's view id : " + viewId);
144 * Create a new AlignViewport with hidden regions
148 * @param hiddenColumns
151 public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns)
154 if (hiddenColumns != null)
156 al.setHiddenColumns(hiddenColumns);
162 * New viewport with hidden columns and an existing sequence set id
165 * @param hiddenColumns
169 public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns,
172 this(al, hiddenColumns, seqsetid, null);
176 * New viewport with hidden columns and an existing sequence set id and viewid
179 * @param hiddenColumns
185 public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns,
186 String seqsetid, String viewid)
189 sequenceSetID = seqsetid;
191 // TODO remove these once 2.4.VAMSAS release finished
192 if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null)
195 "Setting viewport's sequence set id : " + sequenceSetID);
197 if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null)
199 Cache.log.debug("Setting viewport's view id : " + viewId);
202 if (hiddenColumns != null)
204 al.setHiddenColumns(hiddenColumns);
210 * Apply any settings saved in user preferences
212 private void applyViewProperties()
214 antiAlias = Cache.getDefault("ANTI_ALIAS", false);
216 viewStyle.setShowJVSuffix(Cache.getDefault("SHOW_JVSUFFIX", true));
217 setShowAnnotation(Cache.getDefault("SHOW_ANNOTATIONS", true));
219 setRightAlignIds(Cache.getDefault("RIGHT_ALIGN_IDS", false));
220 setCentreColumnLabels(Cache.getDefault("CENTRE_COLUMN_LABELS", false));
221 autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
223 setPadGaps(Cache.getDefault("PAD_GAPS", true));
224 setShowNPFeats(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
225 setShowDBRefs(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
226 viewStyle.setSeqNameItalics(Cache.getDefault("ID_ITALICS", true));
227 viewStyle.setWrapAlignment(Cache.getDefault("WRAP_ALIGNMENT", false));
228 viewStyle.setShowUnconserved(
229 Cache.getDefault("SHOW_UNCONSERVED", false));
230 sortByTree = Cache.getDefault("SORT_BY_TREE", false);
231 followSelection = Cache.getDefault("FOLLOW_SELECTIONS", true);
232 sortAnnotationsBy = SequenceAnnotationOrder
233 .valueOf(Cache.getDefault(Preferences.SORT_ANNOTATIONS,
234 SequenceAnnotationOrder.NONE.name()));
235 showAutocalculatedAbove = Cache
236 .getDefault(Preferences.SHOW_AUTOCALC_ABOVE, false);
237 viewStyle.setScaleProteinAsCdna(
238 Cache.getDefault(Preferences.SCALE_PROTEIN_TO_CDNA, true));
243 applyViewProperties();
245 String fontName = Cache.getDefault("FONT_NAME", "SansSerif");
246 String fontStyle = Cache.getDefault("FONT_STYLE", Font.PLAIN + "");
247 String fontSize = Cache.getDefault("FONT_SIZE", "10");
251 if (fontStyle.equals("bold"))
255 else if (fontStyle.equals("italic"))
260 setFont(new Font(fontName, style, Integer.parseInt(fontSize)), true);
263 .setGapCharacter(Cache.getDefault("GAP_SYMBOL", "-").charAt(0));
265 // We must set conservation and consensus before setting colour,
266 // as Blosum and Clustal require this to be done
267 if (hconsensus == null && !isDataset)
269 if (!alignment.isNucleotide())
271 showConservation = Cache.getDefault("SHOW_CONSERVATION", true);
272 showQuality = Cache.getDefault("SHOW_QUALITY", true);
273 showGroupConservation = Cache.getDefault("SHOW_GROUP_CONSERVATION",
276 showConsensusHistogram = Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM",
278 showSequenceLogo = Cache.getDefault("SHOW_CONSENSUS_LOGO", false);
279 normaliseSequenceLogo = Cache.getDefault("NORMALISE_CONSENSUS_LOGO",
281 showGroupConsensus = Cache.getDefault("SHOW_GROUP_CONSENSUS", false);
282 showConsensus = Cache.getDefault("SHOW_IDENTITY", true);
284 showOccupancy = Cache.getDefault(Preferences.SHOW_OCCUPANCY, true);
286 initAutoAnnotation();
287 String colourProperty = alignment.isNucleotide()
288 ? Preferences.DEFAULT_COLOUR_NUC
289 : Preferences.DEFAULT_COLOUR_PROT;
290 String schemeName = Cache.getProperty(colourProperty);
291 if (schemeName == null)
293 // only DEFAULT_COLOUR available in Jalview before 2.9
294 schemeName = Cache.getDefault(Preferences.DEFAULT_COLOUR,
295 ResidueColourScheme.NONE);
297 ColourSchemeI colourScheme = ColourSchemeProperty
298 .getColourScheme(alignment, schemeName);
299 residueShading = new ResidueShader(colourScheme);
301 if (colourScheme instanceof UserColourScheme)
303 residueShading = new ResidueShader(
304 UserDefinedColours.loadDefaultColours());
305 residueShading.setThreshold(0, isIgnoreGapsConsensus());
308 if (residueShading != null)
310 residueShading.setConsensus(hconsensus);
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 StructureSelectionManager ssm = StructureSelectionManager
391 .getStructureSelectionManager(Desktop.instance);
392 ssm.registerMappings(align.getCodonFrames());
396 * replace mappings on our alignment
398 if (alignment != null && align != null)
400 alignment.setCodonFrames(align.getCodonFrames());
404 protected void deregisterMappings()
406 AlignmentI al = getAlignment();
409 List<AlignedCodonFrame> mappings = al.getCodonFrames();
410 if (mappings != null)
412 StructureSelectionManager ssm = StructureSelectionManager
413 .getStructureSelectionManager(Desktop.instance);
414 for (AlignedCodonFrame acf : mappings)
416 if (noReferencesTo(acf))
418 ssm.deregisterMapping(acf);
428 * @return DOCUMENT ME!
431 public char getGapCharacter()
433 return getAlignment().getGapCharacter();
442 public void setGapCharacter(char gap)
444 if (getAlignment() != null)
446 getAlignment().setGapCharacter(gap);
456 public void setCurrentTree(TreeModel tree)
464 * @return DOCUMENT ME!
466 public TreeModel getCurrentTree()
472 * returns the visible column regions of the alignment
474 * @param selectedRegionOnly
475 * true to just return the contigs intersecting with the selected
479 public int[] getViewAsVisibleContigs(boolean selectedRegionOnly)
481 int[] viscontigs = null;
482 int start = 0, end = 0;
483 if (selectedRegionOnly && selectionGroup != null)
485 start = selectionGroup.getStartRes();
486 end = selectionGroup.getEndRes() + 1;
490 end = alignment.getWidth();
492 viscontigs = alignment.getHiddenColumns().getVisibleContigs(start, end);
497 * get hash of undo and redo list for the alignment
499 * @return long[] { historyList.hashCode, redoList.hashCode };
501 public long[] getUndoRedoHash()
504 if (historyList == null || redoList == null)
506 return new long[] { -1, -1 };
508 return new long[] { historyList.hashCode(), this.redoList.hashCode() };
512 * test if a particular set of hashcodes are different to the hashcodes for
513 * the undo and redo list.
516 * the stored set of hashcodes as returned by getUndoRedoHash
517 * @return true if the hashcodes differ (ie the alignment has been edited) or
518 * the stored hashcode array differs in size
520 public boolean isUndoRedoHashModified(long[] undoredo)
522 if (undoredo == null)
526 long[] cstate = getUndoRedoHash();
527 if (cstate.length != undoredo.length)
532 for (int i = 0; i < cstate.length; i++)
534 if (cstate[i] != undoredo[i])
542 public boolean followSelection = true;
545 * @return true if view selection should always follow the selections
546 * broadcast by other selection sources
548 public boolean getFollowSelection()
550 return followSelection;
554 * Send the current selection to be broadcast to any selection listeners.
557 public void sendSelection()
559 jalview.structure.StructureSelectionManager
560 .getStructureSelectionManager(Desktop.instance)
561 .sendSelection(new SequenceGroup(getSelectionGroup()),
562 new ColumnSelection(getColumnSelection()),
563 new HiddenColumns(getAlignment().getHiddenColumns()),
568 * return the alignPanel containing the given viewport. Use this to get the
569 * components currently handling the given viewport.
572 * @return null or an alignPanel guaranteed to have non-null alignFrame
575 public AlignmentPanel getAlignPanel()
577 AlignmentPanel[] aps = PaintRefresher
578 .getAssociatedPanels(this.getSequenceSetId());
579 for (int p = 0; aps != null && p < aps.length; p++)
581 if (aps[p].av == this)
589 public boolean getSortByTree()
594 public void setSortByTree(boolean sort)
600 * Returns the (Desktop) instance of the StructureSelectionManager
603 public StructureSelectionManager getStructureSelectionManager()
605 return StructureSelectionManager
606 .getStructureSelectionManager(Desktop.instance);
612 * @return an array of SequenceI arrays, one for each PDBEntry, listing which
613 * sequences in the alignment hold a reference to it
615 public SequenceI[][] collateForPDB(PDBEntry[] pdbEntries)
617 List<SequenceI[]> seqvectors = new ArrayList<SequenceI[]>();
618 for (PDBEntry pdb : pdbEntries)
620 List<SequenceI> choosenSeqs = new ArrayList<SequenceI>();
621 for (SequenceI sq : alignment.getSequences())
623 Vector<PDBEntry> pdbRefEntries = sq.getDatasetSequence()
625 if (pdbRefEntries == null)
629 for (PDBEntry pdbRefEntry : pdbRefEntries)
631 if (pdbRefEntry.getId().equals(pdb.getId()))
633 if (pdbRefEntry.getChainCode() != null
634 && pdb.getChainCode() != null)
636 if (pdbRefEntry.getChainCode().equalsIgnoreCase(
637 pdb.getChainCode()) && !choosenSeqs.contains(sq))
645 if (!choosenSeqs.contains(sq))
656 .add(choosenSeqs.toArray(new SequenceI[choosenSeqs.size()]));
658 return seqvectors.toArray(new SequenceI[seqvectors.size()][]);
662 public boolean isNormaliseSequenceLogo()
664 return normaliseSequenceLogo;
667 public void setNormaliseSequenceLogo(boolean state)
669 normaliseSequenceLogo = state;
674 * @return true if alignment characters should be displayed
677 public boolean isValidCharWidth()
679 return validCharWidth;
682 private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<String, AutoCalcSetting>();
684 public AutoCalcSetting getCalcIdSettingsFor(String calcId)
686 return calcIdParams.get(calcId);
689 public void setCalcIdSettingsFor(String calcId, AutoCalcSetting settings,
692 calcIdParams.put(calcId, settings);
693 // TODO: create a restart list to trigger any calculations that need to be
694 // restarted after load
695 // calculator.getRegisteredWorkersOfClass(settings.getWorkerClass())
698 Cache.log.debug("trigger update for " + calcId);
703 * Method called when another alignment's edit (or possibly other) command is
706 * To allow for sequence mappings (e.g. protein to cDNA), we have to first
707 * 'unwind' the command on the source sequences (in simulation, not in fact),
708 * and then for each edit in turn:
710 * <li>compute the equivalent edit on the mapped sequences</li>
711 * <li>apply the mapped edit</li>
712 * <li>'apply' the source edit to the working copy of the source
721 public void mirrorCommand(CommandI command, boolean undo,
722 StructureSelectionManager ssm, VamsasSource source)
725 * Do nothing unless we are a 'complement' of the source. May replace this
726 * with direct calls not via SSM.
728 if (source instanceof AlignViewportI
729 && ((AlignViewportI) source).getCodingComplement() == this)
738 CommandI mappedCommand = ssm.mapCommand(command, undo, getAlignment(),
740 if (mappedCommand != null)
742 AlignmentI[] views = getAlignPanel().alignFrame.getViewAlignments();
743 mappedCommand.doCommand(views);
744 getAlignPanel().alignmentChanged();
749 * Add the sequences from the given alignment to this viewport. Optionally,
750 * may give the user the option to open a new frame, or split panel, with cDNA
751 * and protein linked.
756 public void addAlignment(AlignmentI toAdd, String title)
758 // TODO: promote to AlignViewportI? applet CutAndPasteTransfer is different
760 // JBPComment: title is a largely redundant parameter at the moment
761 // JBPComment: this really should be an 'insert/pre/append' controller
762 // JBPComment: but the DNA/Protein check makes it a bit more complex
764 // refactored from FileLoader / CutAndPasteTransfer / SequenceFetcher with
766 // TODO: create undo object for this JAL-1101
769 * Ensure datasets are created for the new alignment as
770 * mappings operate on dataset sequences
772 toAdd.setDataset(null);
775 * Check if any added sequence could be the object of a mapping or
776 * cross-reference; if so, make the mapping explicit
778 getAlignment().realiseMappings(toAdd.getSequences());
781 * If any cDNA/protein mappings exist or can be made between the alignments,
782 * offer to open a split frame with linked alignments
784 if (Cache.getDefault(Preferences.ENABLE_SPLIT_FRAME, true))
786 if (AlignmentUtils.isMappable(toAdd, getAlignment()))
788 if (openLinkedAlignment(toAdd, title))
796 * No mappings, or offer declined - add sequences to this alignment
798 // TODO: JAL-407 regardless of above - identical sequences (based on ID and
799 // provenance) should share the same dataset sequence
801 AlignmentI al = getAlignment();
802 String gap = String.valueOf(al.getGapCharacter());
803 for (int i = 0; i < toAdd.getHeight(); i++)
805 SequenceI seq = toAdd.getSequenceAt(i);
808 * - 'align' any mapped sequences as per existing
809 * e.g. cdna to genome, domain hit to protein sequence
810 * very experimental! (need a separate menu option for this)
811 * - only add mapped sequences ('select targets from a dataset')
813 if (true /*AlignmentUtils.alignSequenceAs(seq, al, gap, true, true)*/)
819 ranges.setEndSeq(getAlignment().getHeight());
820 firePropertyChange("alignment", null, getAlignment().getSequences());
824 * Show a dialog with the option to open and link (cDNA <-> protein) as a new
825 * alignment, either as a standalone alignment or in a split frame. Returns
826 * true if the new alignment was opened, false if not, because the user
827 * declined the offer.
832 protected boolean openLinkedAlignment(AlignmentI al, String title)
834 String[] options = new String[] { MessageManager.getString("action.no"),
835 MessageManager.getString("label.split_window"),
836 MessageManager.getString("label.new_window"), };
837 final String question = JvSwingUtils.wrapTooltip(true,
838 MessageManager.getString("label.open_split_window?"));
839 int response = JvOptionPane.showOptionDialog(Desktop.desktop, question,
840 MessageManager.getString("label.open_split_window"),
841 JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null,
842 options, options[0]);
844 if (response != 1 && response != 2)
848 final boolean openSplitPane = (response == 1);
849 final boolean openInNewWindow = (response == 2);
852 * Identify protein and dna alignments. Make a copy of this one if opening
853 * in a new split pane.
855 AlignmentI thisAlignment = openSplitPane ? new Alignment(getAlignment())
857 AlignmentI protein = al.isNucleotide() ? thisAlignment : al;
858 final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment;
861 * Map sequences. At least one should get mapped as we have already passed
862 * the test for 'mappability'. Any mappings made will be added to the
863 * protein alignment. Note creating dataset sequences on the new alignment
864 * is a pre-requisite for building mappings.
867 AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna);
870 * Create the AlignFrame for the added alignment. If it is protein, mappings
871 * are registered with StructureSelectionManager as a side-effect.
873 AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
874 AlignFrame.DEFAULT_HEIGHT);
875 newAlignFrame.setTitle(title);
876 newAlignFrame.statusBar.setText(MessageManager
877 .formatMessage("label.successfully_loaded_file", new Object[]
880 // TODO if we want this (e.g. to enable reload of the alignment from file),
881 // we will need to add parameters to the stack.
882 // if (!protocol.equals(DataSourceType.PASTE))
884 // alignFrame.setFileName(file, format);
889 Desktop.addInternalFrame(newAlignFrame, title,
890 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
895 newAlignFrame.setMaximum(
896 jalview.bin.Cache.getDefault("SHOW_FULLSCREEN", false));
897 } catch (java.beans.PropertyVetoException ex)
903 al.alignAs(thisAlignment);
904 protein = openSplitFrame(newAlignFrame, thisAlignment);
911 * Helper method to open a new SplitFrame holding linked dna and protein
914 * @param newAlignFrame
915 * containing a new alignment to be shown
917 * cdna/protein complement alignment to show in the other split half
918 * @return the protein alignment in the split frame
920 protected AlignmentI openSplitFrame(AlignFrame newAlignFrame,
921 AlignmentI complement)
924 * Make a new frame with a copy of the alignment we are adding to. If this
925 * is protein, the mappings to cDNA will be registered with
926 * StructureSelectionManager as a side-effect.
928 AlignFrame copyMe = new AlignFrame(complement, AlignFrame.DEFAULT_WIDTH,
929 AlignFrame.DEFAULT_HEIGHT);
930 copyMe.setTitle(getAlignPanel().alignFrame.getTitle());
932 AlignmentI al = newAlignFrame.viewport.getAlignment();
933 final AlignFrame proteinFrame = al.isNucleotide() ? copyMe
935 final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame : copyMe;
936 cdnaFrame.setVisible(true);
937 proteinFrame.setVisible(true);
938 String linkedTitle = MessageManager
939 .getString("label.linked_view_title");
942 * Open in split pane. DNA sequence above, protein below.
944 JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame);
945 Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1);
947 return proteinFrame.viewport.getAlignment();
950 public AnnotationColumnChooser getAnnotationColumnSelectionState()
952 return annotationColumnSelectionState;
955 public void setAnnotationColumnSelectionState(
956 AnnotationColumnChooser currentAnnotationColumnSelectionState)
958 this.annotationColumnSelectionState = currentAnnotationColumnSelectionState;
962 public void setIdWidth(int i)
965 AlignmentPanel ap = getAlignPanel();
968 // modify GUI elements to reflect geometry change
969 Dimension idw = getAlignPanel().getIdPanel().getIdCanvas()
972 getAlignPanel().getIdPanel().getIdCanvas().setPreferredSize(idw);
976 public Rectangle getExplodedGeometry()
978 return explodedGeometry;
981 public void setExplodedGeometry(Rectangle explodedPosition)
983 this.explodedGeometry = explodedPosition;
986 public boolean isGatherViewsHere()
988 return gatherViewsHere;
991 public void setGatherViewsHere(boolean gatherViewsHere)
993 this.gatherViewsHere = gatherViewsHere;
997 * If this viewport has a (Protein/cDNA) complement, then scroll the
998 * complementary alignment to match this one.
1000 public void scrollComplementaryAlignment()
1003 * Populate a SearchResults object with the mapped location to scroll to. If
1004 * there is no complement, or it is not following highlights, or no mapping
1005 * is found, the result will be empty.
1007 SearchResultsI sr = new SearchResults();
1008 int verticalOffset = findComplementScrollTarget(sr);
1011 // TODO would like next line without cast but needs more refactoring...
1012 final AlignmentPanel complementPanel = ((AlignViewport) getCodingComplement())
1014 complementPanel.setToScrollComplementPanel(false);
1015 complementPanel.scrollToCentre(sr, verticalOffset);
1016 complementPanel.setToScrollComplementPanel(true);
1021 * Answers true if no alignment holds a reference to the given mapping
1026 protected boolean noReferencesTo(AlignedCodonFrame acf)
1028 AlignFrame[] frames = Desktop.getAlignFrames();
1033 for (AlignFrame af : frames)
1037 for (AlignmentViewPanel ap : af.getAlignPanels())
1039 AlignmentI al = ap.getAlignment();
1040 if (al != null && al.getCodonFrames().contains(acf))
1051 * Applies the supplied feature settings descriptor to currently known
1052 * features. This supports an 'initial configuration' of feature colouring
1053 * based on a preset or user favourite. This may then be modified in the usual
1054 * way using the Feature Settings dialogue.
1056 * @param featureSettings
1059 public void applyFeaturesStyle(FeatureSettingsModelI featureSettings)
1061 if (featureSettings == null)
1066 FeatureRenderer fr = getAlignPanel().getSeqPanel().seqCanvas
1067 .getFeatureRenderer();
1068 fr.findAllFeatures(true);
1069 List<String> renderOrder = fr.getRenderOrder();
1070 FeaturesDisplayedI displayed = fr.getFeaturesDisplayed();
1072 // TODO this clears displayed.featuresRegistered - do we care?
1075 * set feature colour if specified by feature settings
1076 * set visibility of all features
1078 for (String type : renderOrder)
1080 FeatureColourI preferredColour = featureSettings
1081 .getFeatureColour(type);
1082 if (preferredColour != null)
1084 fr.setColour(type, preferredColour);
1086 if (featureSettings.isFeatureDisplayed(type))
1088 displayed.setVisible(type);
1093 * set visibility of feature groups
1095 for (String group : fr.getFeatureGroups())
1097 fr.setGroupVisibility(group, featureSettings.isGroupDisplayed(group));
1101 * order the features
1103 if (featureSettings.optimiseOrder())
1105 // TODO not supported (yet?)
1109 fr.orderFeatures(featureSettings);
1111 fr.setTransparency(featureSettings.getTransparency());