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.Sequence;
43 import jalview.datamodel.SequenceGroup;
44 import jalview.datamodel.SequenceI;
45 import jalview.renderer.ResidueShader;
46 import jalview.schemes.ColourSchemeI;
47 import jalview.schemes.ColourSchemeProperty;
48 import jalview.schemes.ResidueColourScheme;
49 import jalview.schemes.UserColourScheme;
50 import jalview.structure.SelectionSource;
51 import jalview.structure.StructureSelectionManager;
52 import jalview.structure.VamsasSource;
53 import jalview.util.MessageManager;
54 import jalview.viewmodel.AlignmentViewport;
55 import jalview.ws.params.AutoCalcSetting;
57 import java.awt.Container;
58 import java.awt.Dimension;
60 import java.awt.FontMetrics;
61 import java.awt.Rectangle;
62 import java.util.ArrayList;
63 import java.util.Hashtable;
64 import java.util.List;
65 import java.util.Vector;
67 import javax.swing.JInternalFrame;
73 * @version $Revision: 1.141 $
75 public class AlignViewport extends AlignmentViewport implements
80 TreeModel currentTree = null;
82 boolean cursorMode = false;
84 boolean antiAlias = false;
86 private Rectangle explodedGeometry;
91 * Flag set true on the view that should 'gather' multiple views of the same
92 * sequence set id when a project is reloaded. Set false on all views when
93 * they are 'exploded' into separate windows. Set true on the current view
94 * when 'Gather' is performed, and also on the first tab when the first new
97 private boolean gatherViewsHere = false;
99 private AnnotationColumnChooser annotationColumnSelectionState;
102 * Creates a new AlignViewport object.
107 public AlignViewport(AlignmentI al)
114 * Create a new AlignViewport object with a specific sequence set ID
118 * (may be null - but potential for ambiguous constructor exception)
120 public AlignViewport(AlignmentI al, String seqsetid)
122 this(al, seqsetid, null);
125 public AlignViewport(AlignmentI al, String seqsetid, String viewid)
128 sequenceSetID = seqsetid;
130 // TODO remove these once 2.4.VAMSAS release finished
131 if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null)
133 Cache.log.debug("Setting viewport's sequence set id : "
136 if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null)
138 Cache.log.debug("Setting viewport's view id : " + viewId);
145 * Create a new AlignViewport with hidden regions
149 * @param hiddenColumns
152 public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns)
155 if (hiddenColumns != null)
157 al.setHiddenColumns(hiddenColumns);
163 * New viewport with hidden columns and an existing sequence set id
166 * @param hiddenColumns
170 public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns,
173 this(al, hiddenColumns, seqsetid, null);
177 * New viewport with hidden columns and an existing sequence set id and viewid
180 * @param hiddenColumns
186 public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns,
187 String seqsetid, String viewid)
190 sequenceSetID = seqsetid;
192 // TODO remove these once 2.4.VAMSAS release finished
193 if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null)
195 Cache.log.debug("Setting viewport's sequence set id : "
198 if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null)
200 Cache.log.debug("Setting viewport's view id : " + viewId);
203 if (hiddenColumns != null)
205 al.setHiddenColumns(hiddenColumns);
211 * Apply any settings saved in user preferences
213 private void applyViewProperties()
215 antiAlias = Cache.getDefault("ANTI_ALIAS", false);
217 viewStyle.setShowJVSuffix(Cache.getDefault("SHOW_JVSUFFIX", true));
218 setShowAnnotation(Cache.getDefault("SHOW_ANNOTATIONS", true));
220 setRightAlignIds(Cache.getDefault("RIGHT_ALIGN_IDS", false));
221 setCentreColumnLabels(Cache.getDefault("CENTRE_COLUMN_LABELS", false));
222 autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
224 setPadGaps(Cache.getDefault("PAD_GAPS", true));
225 setShowNPFeats(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
226 setShowDBRefs(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
227 viewStyle.setSeqNameItalics(Cache.getDefault("ID_ITALICS", true));
228 viewStyle.setWrapAlignment(Cache.getDefault("WRAP_ALIGNMENT", false));
229 viewStyle.setShowUnconserved(Cache
230 .getDefault("SHOW_UNCONSERVED", false));
231 sortByTree = Cache.getDefault("SORT_BY_TREE", false);
232 followSelection = Cache.getDefault("FOLLOW_SELECTIONS", true);
233 sortAnnotationsBy = SequenceAnnotationOrder.valueOf(Cache.getDefault(
234 Preferences.SORT_ANNOTATIONS,
235 SequenceAnnotationOrder.NONE.name()));
236 showAutocalculatedAbove = Cache.getDefault(
237 Preferences.SHOW_AUTOCALC_ABOVE, false);
238 viewStyle.setScaleProteinAsCdna(Cache.getDefault(
239 Preferences.SCALE_PROTEIN_TO_CDNA, true));
244 applyViewProperties();
246 String fontName = Cache.getDefault("FONT_NAME", "SansSerif");
247 String fontStyle = Cache.getDefault("FONT_STYLE", Font.PLAIN + "");
248 String fontSize = Cache.getDefault("FONT_SIZE", "10");
252 if (fontStyle.equals("bold"))
256 else if (fontStyle.equals("italic"))
261 setFont(new Font(fontName, style, Integer.parseInt(fontSize)), true);
264 .setGapCharacter(Cache.getDefault("GAP_SYMBOL", "-").charAt(0));
266 // We must set conservation and consensus before setting colour,
267 // as Blosum and Clustal require this to be done
268 if (hconsensus == null && !isDataset)
270 if (!alignment.isNucleotide())
272 showConservation = Cache.getDefault("SHOW_CONSERVATION", true);
273 showQuality = Cache.getDefault("SHOW_QUALITY", true);
274 showGroupConservation = Cache.getDefault("SHOW_GROUP_CONSERVATION",
277 showConsensusHistogram = Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM",
279 showSequenceLogo = Cache.getDefault("SHOW_CONSENSUS_LOGO", false);
280 normaliseSequenceLogo = Cache.getDefault("NORMALISE_CONSENSUS_LOGO",
282 showGroupConsensus = Cache.getDefault("SHOW_GROUP_CONSENSUS", false);
283 showConsensus = Cache.getDefault("SHOW_IDENTITY", true);
285 showOccupancy = Cache.getDefault(Preferences.SHOW_OCCUPANCY, true);
287 initAutoAnnotation();
288 String colourProperty = alignment.isNucleotide() ? 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.getColourScheme(
298 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);
315 * get the consensus sequence as displayed under the PID consensus annotation
318 * @return consensus sequence as a new sequence object
320 public SequenceI getConsensusSeq()
322 if (consensus == null)
324 updateConsensus(null);
326 if (consensus == null)
330 StringBuffer seqs = new StringBuffer();
331 for (int i = 0; i < consensus.annotations.length; i++)
333 if (consensus.annotations[i] != null)
335 if (consensus.annotations[i].description.charAt(0) == '[')
337 seqs.append(consensus.annotations[i].description.charAt(1));
341 seqs.append(consensus.annotations[i].displayCharacter);
346 SequenceI sq = new Sequence("Consensus", seqs.toString());
347 sq.setDescription("Percentage Identity Consensus "
348 + ((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
352 boolean validCharWidth;
358 public void setFont(Font f, boolean setGrid)
362 Container c = new Container();
366 FontMetrics fm = c.getFontMetrics(font);
367 int ww = fm.charWidth('M');
368 setCharHeight(fm.getHeight());
371 viewStyle.setFontName(font.getName());
372 viewStyle.setFontStyle(font.getStyle());
373 viewStyle.setFontSize(font.getSize());
375 validCharWidth = true;
379 public void setViewStyle(ViewStyleI settingsForView)
381 super.setViewStyle(settingsForView);
382 setFont(new Font(viewStyle.getFontName(), viewStyle.getFontStyle(),
383 viewStyle.getFontSize()), false);
389 * @return DOCUMENT ME!
391 public Font getFont()
403 public void setAlignment(AlignmentI align)
405 replaceMappings(align);
406 super.setAlignment(align);
410 * Replace any codon mappings for this viewport with those for the given
415 public void replaceMappings(AlignmentI align)
419 * Deregister current mappings (if any)
421 deregisterMappings();
424 * Register new mappings (if any)
428 StructureSelectionManager ssm = StructureSelectionManager
429 .getStructureSelectionManager(Desktop.instance);
430 ssm.registerMappings(align.getCodonFrames());
434 * replace mappings on our alignment
436 if (alignment != null && align != null)
438 alignment.setCodonFrames(align.getCodonFrames());
442 protected void deregisterMappings()
444 AlignmentI al = getAlignment();
447 List<AlignedCodonFrame> mappings = al.getCodonFrames();
448 if (mappings != null)
450 StructureSelectionManager ssm = StructureSelectionManager
451 .getStructureSelectionManager(Desktop.instance);
452 for (AlignedCodonFrame acf : mappings)
454 if (noReferencesTo(acf))
456 ssm.deregisterMapping(acf);
466 * @return DOCUMENT ME!
469 public char getGapCharacter()
471 return getAlignment().getGapCharacter();
480 public void setGapCharacter(char gap)
482 if (getAlignment() != null)
484 getAlignment().setGapCharacter(gap);
494 public void setCurrentTree(TreeModel tree)
502 * @return DOCUMENT ME!
504 public TreeModel getCurrentTree()
510 * returns the visible column regions of the alignment
512 * @param selectedRegionOnly
513 * true to just return the contigs intersecting with the selected
517 public int[] getViewAsVisibleContigs(boolean selectedRegionOnly)
519 int[] viscontigs = null;
520 int start = 0, end = 0;
521 if (selectedRegionOnly && selectionGroup != null)
523 start = selectionGroup.getStartRes();
524 end = selectionGroup.getEndRes() + 1;
528 end = alignment.getWidth();
530 viscontigs = alignment.getHiddenColumns().getVisibleContigs(start, end);
535 * get hash of undo and redo list for the alignment
537 * @return long[] { historyList.hashCode, redoList.hashCode };
539 public long[] getUndoRedoHash()
542 if (historyList == null || redoList == null)
544 return new long[] { -1, -1 };
546 return new long[] { historyList.hashCode(), this.redoList.hashCode() };
550 * test if a particular set of hashcodes are different to the hashcodes for
551 * the undo and redo list.
554 * the stored set of hashcodes as returned by getUndoRedoHash
555 * @return true if the hashcodes differ (ie the alignment has been edited) or
556 * the stored hashcode array differs in size
558 public boolean isUndoRedoHashModified(long[] undoredo)
560 if (undoredo == null)
564 long[] cstate = getUndoRedoHash();
565 if (cstate.length != undoredo.length)
570 for (int i = 0; i < cstate.length; i++)
572 if (cstate[i] != undoredo[i])
580 public boolean followSelection = true;
583 * @return true if view selection should always follow the selections
584 * broadcast by other selection sources
586 public boolean getFollowSelection()
588 return followSelection;
592 * Send the current selection to be broadcast to any selection listeners.
595 public void sendSelection()
597 jalview.structure.StructureSelectionManager
598 .getStructureSelectionManager(Desktop.instance).sendSelection(
599 new SequenceGroup(getSelectionGroup()),
600 new ColumnSelection(getColumnSelection()),
601 new HiddenColumns(getAlignment().getHiddenColumns()),
606 * return the alignPanel containing the given viewport. Use this to get the
607 * components currently handling the given viewport.
610 * @return null or an alignPanel guaranteed to have non-null alignFrame
613 public AlignmentPanel getAlignPanel()
615 AlignmentPanel[] aps = PaintRefresher.getAssociatedPanels(this
616 .getSequenceSetId());
617 for (int p = 0; aps != null && p < aps.length; p++)
619 if (aps[p].av == this)
627 public boolean getSortByTree()
632 public void setSortByTree(boolean sort)
638 * Returns the (Desktop) instance of the StructureSelectionManager
641 public StructureSelectionManager getStructureSelectionManager()
643 return StructureSelectionManager
644 .getStructureSelectionManager(Desktop.instance);
650 * @return an array of SequenceI arrays, one for each PDBEntry, listing which
651 * sequences in the alignment hold a reference to it
653 public SequenceI[][] collateForPDB(PDBEntry[] pdbEntries)
655 List<SequenceI[]> seqvectors = new ArrayList<>();
656 for (PDBEntry pdb : pdbEntries)
658 List<SequenceI> choosenSeqs = new ArrayList<>();
659 for (SequenceI sq : alignment.getSequences())
661 Vector<PDBEntry> pdbRefEntries = sq.getDatasetSequence()
663 if (pdbRefEntries == null)
667 for (PDBEntry pdbRefEntry : pdbRefEntries)
669 if (pdbRefEntry.getId().equals(pdb.getId()))
671 if (pdbRefEntry.getChainCode() != null
672 && pdb.getChainCode() != null)
674 if (pdbRefEntry.getChainCode().equalsIgnoreCase(
676 && !choosenSeqs.contains(sq))
684 if (!choosenSeqs.contains(sq))
695 .add(choosenSeqs.toArray(new SequenceI[choosenSeqs.size()]));
697 return seqvectors.toArray(new SequenceI[seqvectors.size()][]);
701 public boolean isNormaliseSequenceLogo()
703 return normaliseSequenceLogo;
707 public void setNormaliseSequenceLogo(boolean state)
709 normaliseSequenceLogo = state;
712 public void setNormaliseHMMSequenceLogo(boolean state)
714 normaliseHMMSequenceLogo = state;
719 * @return true if alignment characters should be displayed
722 public boolean isValidCharWidth()
724 return validCharWidth;
727 private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<>();
729 public AutoCalcSetting getCalcIdSettingsFor(String calcId)
731 return calcIdParams.get(calcId);
734 public void setCalcIdSettingsFor(String calcId, AutoCalcSetting settings,
737 calcIdParams.put(calcId, settings);
738 // TODO: create a restart list to trigger any calculations that need to be
739 // restarted after load
740 // calculator.getRegisteredWorkersOfClass(settings.getWorkerClass())
743 Cache.log.debug("trigger update for " + calcId);
748 * Method called when another alignment's edit (or possibly other) command is
751 * To allow for sequence mappings (e.g. protein to cDNA), we have to first
752 * 'unwind' the command on the source sequences (in simulation, not in fact),
753 * and then for each edit in turn:
755 * <li>compute the equivalent edit on the mapped sequences</li>
756 * <li>apply the mapped edit</li>
757 * <li>'apply' the source edit to the working copy of the source sequences</li>
765 public void mirrorCommand(CommandI command, boolean undo,
766 StructureSelectionManager ssm, VamsasSource source)
769 * Do nothing unless we are a 'complement' of the source. May replace this
770 * with direct calls not via SSM.
772 if (source instanceof AlignViewportI
773 && ((AlignViewportI) source).getCodingComplement() == this)
782 CommandI mappedCommand = ssm.mapCommand(command, undo, getAlignment(),
784 if (mappedCommand != null)
786 AlignmentI[] views = getAlignPanel().alignFrame.getViewAlignments();
787 mappedCommand.doCommand(views);
788 getAlignPanel().alignmentChanged();
793 * Add the sequences from the given alignment to this viewport. Optionally,
794 * may give the user the option to open a new frame, or split panel, with cDNA
795 * and protein linked.
800 public void addAlignment(AlignmentI toAdd, String title)
802 // TODO: promote to AlignViewportI? applet CutAndPasteTransfer is different
804 // JBPComment: title is a largely redundant parameter at the moment
805 // JBPComment: this really should be an 'insert/pre/append' controller
806 // JBPComment: but the DNA/Protein check makes it a bit more complex
808 // refactored from FileLoader / CutAndPasteTransfer / SequenceFetcher with
810 // TODO: create undo object for this JAL-1101
813 * Ensure datasets are created for the new alignment as
814 * mappings operate on dataset sequences
816 toAdd.setDataset(null);
819 * Check if any added sequence could be the object of a mapping or
820 * cross-reference; if so, make the mapping explicit
822 getAlignment().realiseMappings(toAdd.getSequences());
825 * If any cDNA/protein mappings exist or can be made between the alignments,
826 * offer to open a split frame with linked alignments
828 if (Cache.getDefault(Preferences.ENABLE_SPLIT_FRAME, true))
830 if (AlignmentUtils.isMappable(toAdd, getAlignment()))
832 if (openLinkedAlignment(toAdd, title))
840 * No mappings, or offer declined - add sequences to this alignment
842 // TODO: JAL-407 regardless of above - identical sequences (based on ID and
843 // provenance) should share the same dataset sequence
845 AlignmentI al = getAlignment();
846 String gap = String.valueOf(al.getGapCharacter());
847 for (int i = 0; i < toAdd.getHeight(); i++)
849 SequenceI seq = toAdd.getSequenceAt(i);
852 * - 'align' any mapped sequences as per existing
853 * e.g. cdna to genome, domain hit to protein sequence
854 * very experimental! (need a separate menu option for this)
855 * - only add mapped sequences ('select targets from a dataset')
857 if (true /*AlignmentUtils.alignSequenceAs(seq, al, gap, true, true)*/)
863 ranges.setEndSeq(getAlignment().getHeight());
864 firePropertyChange("alignment", null, getAlignment().getSequences());
868 * Show a dialog with the option to open and link (cDNA <-> protein) as a new
869 * alignment, either as a standalone alignment or in a split frame. Returns
870 * true if the new alignment was opened, false if not, because the user
871 * declined the offer.
876 protected boolean openLinkedAlignment(AlignmentI al, String title)
878 String[] options = new String[] {
879 MessageManager.getString("action.no"),
880 MessageManager.getString("label.split_window"),
881 MessageManager.getString("label.new_window"), };
882 final String question = JvSwingUtils.wrapTooltip(true,
883 MessageManager.getString("label.open_split_window?"));
884 int response = JvOptionPane.showOptionDialog(Desktop.desktop, question,
885 MessageManager.getString("label.open_split_window"),
886 JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null,
887 options, options[0]);
889 if (response != 1 && response != 2)
893 final boolean openSplitPane = (response == 1);
894 final boolean openInNewWindow = (response == 2);
897 * Identify protein and dna alignments. Make a copy of this one if opening
898 * in a new split pane.
900 AlignmentI thisAlignment = openSplitPane ? new Alignment(getAlignment())
902 AlignmentI protein = al.isNucleotide() ? thisAlignment : al;
903 final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment;
906 * Map sequences. At least one should get mapped as we have already passed
907 * the test for 'mappability'. Any mappings made will be added to the
908 * protein alignment. Note creating dataset sequences on the new alignment
909 * is a pre-requisite for building mappings.
912 AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna);
915 * Create the AlignFrame for the added alignment. If it is protein, mappings
916 * are registered with StructureSelectionManager as a side-effect.
918 AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
919 AlignFrame.DEFAULT_HEIGHT);
920 newAlignFrame.setTitle(title);
921 newAlignFrame.statusBar.setText(MessageManager.formatMessage(
922 "label.successfully_loaded_file", new Object[] { title }));
924 // TODO if we want this (e.g. to enable reload of the alignment from file),
925 // we will need to add parameters to the stack.
926 // if (!protocol.equals(DataSourceType.PASTE))
928 // alignFrame.setFileName(file, format);
933 Desktop.addInternalFrame(newAlignFrame, title,
934 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
939 newAlignFrame.setMaximum(jalview.bin.Cache.getDefault(
940 "SHOW_FULLSCREEN", false));
941 } catch (java.beans.PropertyVetoException ex)
947 al.alignAs(thisAlignment);
948 protein = openSplitFrame(newAlignFrame, thisAlignment);
955 * Helper method to open a new SplitFrame holding linked dna and protein
958 * @param newAlignFrame
959 * containing a new alignment to be shown
961 * cdna/protein complement alignment to show in the other split half
962 * @return the protein alignment in the split frame
964 protected AlignmentI openSplitFrame(AlignFrame newAlignFrame,
965 AlignmentI complement)
968 * Make a new frame with a copy of the alignment we are adding to. If this
969 * is protein, the mappings to cDNA will be registered with
970 * StructureSelectionManager as a side-effect.
972 AlignFrame copyMe = new AlignFrame(complement,
973 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
974 copyMe.setTitle(getAlignPanel().alignFrame.getTitle());
976 AlignmentI al = newAlignFrame.viewport.getAlignment();
977 final AlignFrame proteinFrame = al.isNucleotide() ? copyMe
979 final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame : copyMe;
980 cdnaFrame.setVisible(true);
981 proteinFrame.setVisible(true);
982 String linkedTitle = MessageManager
983 .getString("label.linked_view_title");
986 * Open in split pane. DNA sequence above, protein below.
988 JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame);
989 Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1);
991 return proteinFrame.viewport.getAlignment();
994 public AnnotationColumnChooser getAnnotationColumnSelectionState()
996 return annotationColumnSelectionState;
999 public void setAnnotationColumnSelectionState(
1000 AnnotationColumnChooser currentAnnotationColumnSelectionState)
1002 this.annotationColumnSelectionState = currentAnnotationColumnSelectionState;
1006 public void setIdWidth(int i)
1008 super.setIdWidth(i);
1009 AlignmentPanel ap = getAlignPanel();
1012 // modify GUI elements to reflect geometry change
1013 Dimension idw = getAlignPanel().getIdPanel().getIdCanvas()
1014 .getPreferredSize();
1016 getAlignPanel().getIdPanel().getIdCanvas().setPreferredSize(idw);
1020 public Rectangle getExplodedGeometry()
1022 return explodedGeometry;
1025 public void setExplodedGeometry(Rectangle explodedPosition)
1027 this.explodedGeometry = explodedPosition;
1030 public boolean isGatherViewsHere()
1032 return gatherViewsHere;
1035 public void setGatherViewsHere(boolean gatherViewsHere)
1037 this.gatherViewsHere = gatherViewsHere;
1041 * If this viewport has a (Protein/cDNA) complement, then scroll the
1042 * complementary alignment to match this one.
1044 public void scrollComplementaryAlignment()
1047 * Populate a SearchResults object with the mapped location to scroll to. If
1048 * there is no complement, or it is not following highlights, or no mapping
1049 * is found, the result will be empty.
1051 SearchResultsI sr = new SearchResults();
1052 int verticalOffset = findComplementScrollTarget(sr);
1055 // TODO would like next line without cast but needs more refactoring...
1056 final AlignmentPanel complementPanel = ((AlignViewport) getCodingComplement())
1058 complementPanel.setToScrollComplementPanel(false);
1059 complementPanel.scrollToCentre(sr, verticalOffset);
1060 complementPanel.setToScrollComplementPanel(true);
1065 * Answers true if no alignment holds a reference to the given mapping
1070 protected boolean noReferencesTo(AlignedCodonFrame acf)
1072 AlignFrame[] frames = Desktop.getAlignFrames();
1077 for (AlignFrame af : frames)
1081 for (AlignmentViewPanel ap : af.getAlignPanels())
1083 AlignmentI al = ap.getAlignment();
1084 if (al != null && al.getCodonFrames().contains(acf))
1095 * Applies the supplied feature settings descriptor to currently known
1096 * features. This supports an 'initial configuration' of feature colouring
1097 * based on a preset or user favourite. This may then be modified in the usual
1098 * way using the Feature Settings dialogue.
1100 * @param featureSettings
1103 public void applyFeaturesStyle(FeatureSettingsModelI featureSettings)
1105 if (featureSettings == null)
1110 FeatureRenderer fr = getAlignPanel().getSeqPanel().seqCanvas
1111 .getFeatureRenderer();
1112 fr.findAllFeatures(true);
1113 List<String> renderOrder = fr.getRenderOrder();
1114 FeaturesDisplayedI displayed = fr.getFeaturesDisplayed();
1116 // TODO this clears displayed.featuresRegistered - do we care?
1119 * set feature colour if specified by feature settings
1120 * set visibility of all features
1122 for (String type : renderOrder)
1124 FeatureColourI preferredColour = featureSettings
1125 .getFeatureColour(type);
1126 if (preferredColour != null)
1128 fr.setColour(type, preferredColour);
1130 if (featureSettings.isFeatureDisplayed(type))
1132 displayed.setVisible(type);
1137 * set visibility of feature groups
1139 for (String group : fr.getFeatureGroups())
1141 fr.setGroupVisibility(group, featureSettings.isGroupDisplayed(group));
1145 * order the features
1147 if (featureSettings.optimiseOrder())
1149 // TODO not supported (yet?)
1153 fr.orderFeatures(featureSettings);
1155 fr.setTransparency(featureSettings.getTransparency());
1159 public boolean isNormaliseHMMSequenceLogo()
1161 return normaliseHMMSequenceLogo;