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.Annotation;
38 import jalview.datamodel.ColumnSelection;
39 import jalview.datamodel.HiddenColumns;
40 import jalview.datamodel.PDBEntry;
41 import jalview.datamodel.SearchResults;
42 import jalview.datamodel.SearchResultsI;
43 import jalview.datamodel.Sequence;
44 import jalview.datamodel.SequenceGroup;
45 import jalview.datamodel.SequenceI;
46 import jalview.renderer.ResidueShader;
47 import jalview.schemes.ColourSchemeI;
48 import jalview.schemes.ColourSchemeProperty;
49 import jalview.schemes.ResidueColourScheme;
50 import jalview.schemes.UserColourScheme;
51 import jalview.structure.SelectionSource;
52 import jalview.structure.StructureSelectionManager;
53 import jalview.structure.VamsasSource;
54 import jalview.util.MessageManager;
55 import jalview.viewmodel.AlignmentViewport;
56 import jalview.ws.params.AutoCalcSetting;
58 import java.awt.Container;
59 import java.awt.Dimension;
61 import java.awt.FontMetrics;
62 import java.awt.Rectangle;
63 import java.util.ArrayList;
64 import java.util.Hashtable;
65 import java.util.List;
66 import java.util.Vector;
68 import javax.swing.JInternalFrame;
74 * @version $Revision: 1.141 $
76 public class AlignViewport extends AlignmentViewport implements
81 TreeModel currentTree = null;
83 boolean cursorMode = false;
85 boolean antiAlias = false;
87 private Rectangle explodedGeometry;
92 * Flag set true on the view that should 'gather' multiple views of the same
93 * sequence set id when a project is reloaded. Set false on all views when
94 * they are 'exploded' into separate windows. Set true on the current view
95 * when 'Gather' is performed, and also on the first tab when the first new
98 private boolean gatherViewsHere = false;
100 private AnnotationColumnChooser annotationColumnSelectionState;
103 * Creates a new AlignViewport object.
108 public AlignViewport(AlignmentI al)
115 * Create a new AlignViewport object with a specific sequence set ID
119 * (may be null - but potential for ambiguous constructor exception)
121 public AlignViewport(AlignmentI al, String seqsetid)
123 this(al, seqsetid, null);
126 public AlignViewport(AlignmentI al, String seqsetid, String viewid)
129 sequenceSetID = seqsetid;
131 // TODO remove these once 2.4.VAMSAS release finished
132 if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null)
134 Cache.log.debug("Setting viewport's sequence set id : "
137 if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null)
139 Cache.log.debug("Setting viewport's view id : " + viewId);
146 * Create a new AlignViewport with hidden regions
150 * @param hiddenColumns
153 public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns)
156 if (hiddenColumns != null)
158 al.setHiddenColumns(hiddenColumns);
164 * New viewport with hidden columns and an existing sequence set id
167 * @param hiddenColumns
171 public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns,
174 this(al, hiddenColumns, seqsetid, null);
178 * New viewport with hidden columns and an existing sequence set id and viewid
181 * @param hiddenColumns
187 public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns,
188 String seqsetid, String viewid)
191 sequenceSetID = seqsetid;
193 // TODO remove these once 2.4.VAMSAS release finished
194 if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null)
196 Cache.log.debug("Setting viewport's sequence set id : "
199 if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null)
201 Cache.log.debug("Setting viewport's view id : " + viewId);
204 if (hiddenColumns != null)
206 al.setHiddenColumns(hiddenColumns);
212 * Apply any settings saved in user preferences
214 private void applyViewProperties()
216 antiAlias = Cache.getDefault("ANTI_ALIAS", false);
218 viewStyle.setShowJVSuffix(Cache.getDefault("SHOW_JVSUFFIX", true));
219 setShowAnnotation(Cache.getDefault("SHOW_ANNOTATIONS", true));
221 setRightAlignIds(Cache.getDefault("RIGHT_ALIGN_IDS", false));
222 setCentreColumnLabels(Cache.getDefault("CENTRE_COLUMN_LABELS", false));
223 autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
225 setPadGaps(Cache.getDefault("PAD_GAPS", true));
226 setShowNPFeats(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
227 setShowDBRefs(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
228 viewStyle.setSeqNameItalics(Cache.getDefault("ID_ITALICS", true));
229 viewStyle.setWrapAlignment(Cache.getDefault("WRAP_ALIGNMENT", false));
230 viewStyle.setShowUnconserved(Cache
231 .getDefault("SHOW_UNCONSERVED", false));
232 sortByTree = Cache.getDefault("SORT_BY_TREE", false);
233 followSelection = Cache.getDefault("FOLLOW_SELECTIONS", true);
234 sortAnnotationsBy = SequenceAnnotationOrder.valueOf(Cache.getDefault(
235 Preferences.SORT_ANNOTATIONS,
236 SequenceAnnotationOrder.NONE.name()));
237 showAutocalculatedAbove = Cache.getDefault(
238 Preferences.SHOW_AUTOCALC_ABOVE, false);
239 viewStyle.setScaleProteinAsCdna(Cache.getDefault(
240 Preferences.SCALE_PROTEIN_TO_CDNA, true));
245 applyViewProperties();
247 String fontName = Cache.getDefault("FONT_NAME", "SansSerif");
248 String fontStyle = Cache.getDefault("FONT_STYLE", Font.PLAIN + "");
249 String fontSize = Cache.getDefault("FONT_SIZE", "10");
253 if (fontStyle.equals("bold"))
257 else if (fontStyle.equals("italic"))
262 setFont(new Font(fontName, style, Integer.parseInt(fontSize)), true);
265 .setGapCharacter(Cache.getDefault("GAP_SYMBOL", "-").charAt(0));
267 // We must set conservation and consensus before setting colour,
268 // as Blosum and Clustal require this to be done
269 if (hconsensus == null && !isDataset)
271 if (!alignment.isNucleotide())
273 showConservation = Cache.getDefault("SHOW_CONSERVATION", true);
274 showQuality = Cache.getDefault("SHOW_QUALITY", true);
275 showGroupConservation = Cache.getDefault("SHOW_GROUP_CONSERVATION",
278 showConsensusHistogram = Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM",
280 showSequenceLogo = Cache.getDefault("SHOW_CONSENSUS_LOGO", false);
281 normaliseSequenceLogo = Cache.getDefault("NORMALISE_CONSENSUS_LOGO",
283 showGroupConsensus = Cache.getDefault("SHOW_GROUP_CONSENSUS", false);
284 showConsensus = Cache.getDefault("SHOW_IDENTITY", true);
286 showOccupancy = Cache.getDefault(Preferences.SHOW_OCCUPANCY, true);
288 initAutoAnnotation();
289 String colourProperty = alignment.isNucleotide() ? Preferences.DEFAULT_COLOUR_NUC
290 : Preferences.DEFAULT_COLOUR_PROT;
291 String schemeName = Cache.getProperty(colourProperty);
292 if (schemeName == null)
294 // only DEFAULT_COLOUR available in Jalview before 2.9
295 schemeName = Cache.getDefault(Preferences.DEFAULT_COLOUR,
296 ResidueColourScheme.NONE);
298 ColourSchemeI colourScheme = ColourSchemeProperty.getColourScheme(
299 alignment, schemeName);
300 residueShading = new ResidueShader(colourScheme);
302 if (colourScheme instanceof UserColourScheme)
304 residueShading = new ResidueShader(
305 UserDefinedColours.loadDefaultColours());
306 residueShading.setThreshold(0, isIgnoreGapsConsensus());
309 if (residueShading != null)
311 residueShading.setConsensus(hconsensus);
316 * get the consensus sequence as displayed under the PID consensus annotation
319 * @return consensus sequence as a new sequence object
321 public SequenceI getConsensusSeq()
323 if (consensus == null)
325 updateConsensus(null);
327 if (consensus == null)
331 StringBuffer seqs = new StringBuffer();
332 for (int i = 0; i < consensus.annotations.length; i++)
334 Annotation annotation = consensus.annotations[i];
335 if (annotation != null)
337 String description = annotation.description;
338 if (description != null && description.startsWith("["))
340 // consensus is a tie - just pick the first one
341 seqs.append(description.charAt(1));
345 seqs.append(annotation.displayCharacter);
350 SequenceI sq = new Sequence("Consensus", seqs.toString());
351 sq.setDescription("Percentage Identity Consensus "
352 + ((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
356 boolean validCharWidth;
362 public void setFont(Font f, boolean setGrid)
366 Container c = new Container();
370 FontMetrics fm = c.getFontMetrics(font);
371 int ww = fm.charWidth('M');
372 setCharHeight(fm.getHeight());
375 viewStyle.setFontName(font.getName());
376 viewStyle.setFontStyle(font.getStyle());
377 viewStyle.setFontSize(font.getSize());
379 validCharWidth = true;
383 public void setViewStyle(ViewStyleI settingsForView)
385 super.setViewStyle(settingsForView);
386 setFont(new Font(viewStyle.getFontName(), viewStyle.getFontStyle(),
387 viewStyle.getFontSize()), false);
393 * @return DOCUMENT ME!
395 public Font getFont()
407 public void setAlignment(AlignmentI align)
409 replaceMappings(align);
410 super.setAlignment(align);
414 * Replace any codon mappings for this viewport with those for the given
419 public void replaceMappings(AlignmentI align)
423 * Deregister current mappings (if any)
425 deregisterMappings();
428 * Register new mappings (if any)
432 StructureSelectionManager ssm = StructureSelectionManager
433 .getStructureSelectionManager(Desktop.instance);
434 ssm.registerMappings(align.getCodonFrames());
438 * replace mappings on our alignment
440 if (alignment != null && align != null)
442 alignment.setCodonFrames(align.getCodonFrames());
446 protected void deregisterMappings()
448 AlignmentI al = getAlignment();
451 List<AlignedCodonFrame> mappings = al.getCodonFrames();
452 if (mappings != null)
454 StructureSelectionManager ssm = StructureSelectionManager
455 .getStructureSelectionManager(Desktop.instance);
456 for (AlignedCodonFrame acf : mappings)
458 if (noReferencesTo(acf))
460 ssm.deregisterMapping(acf);
470 * @return DOCUMENT ME!
473 public char getGapCharacter()
475 return getAlignment().getGapCharacter();
484 public void setGapCharacter(char gap)
486 if (getAlignment() != null)
488 getAlignment().setGapCharacter(gap);
498 public void setCurrentTree(TreeModel tree)
506 * @return DOCUMENT ME!
508 public TreeModel getCurrentTree()
514 * returns the visible column regions of the alignment
516 * @param selectedRegionOnly
517 * true to just return the contigs intersecting with the selected
521 public int[] getViewAsVisibleContigs(boolean selectedRegionOnly)
523 int[] viscontigs = null;
524 int start = 0, end = 0;
525 if (selectedRegionOnly && selectionGroup != null)
527 start = selectionGroup.getStartRes();
528 end = selectionGroup.getEndRes() + 1;
532 end = alignment.getWidth();
534 viscontigs = alignment.getHiddenColumns().getVisibleContigs(start, end);
539 * get hash of undo and redo list for the alignment
541 * @return long[] { historyList.hashCode, redoList.hashCode };
543 public long[] getUndoRedoHash()
546 if (historyList == null || redoList == null)
548 return new long[] { -1, -1 };
550 return new long[] { historyList.hashCode(), this.redoList.hashCode() };
554 * test if a particular set of hashcodes are different to the hashcodes for
555 * the undo and redo list.
558 * the stored set of hashcodes as returned by getUndoRedoHash
559 * @return true if the hashcodes differ (ie the alignment has been edited) or
560 * the stored hashcode array differs in size
562 public boolean isUndoRedoHashModified(long[] undoredo)
564 if (undoredo == null)
568 long[] cstate = getUndoRedoHash();
569 if (cstate.length != undoredo.length)
574 for (int i = 0; i < cstate.length; i++)
576 if (cstate[i] != undoredo[i])
584 public boolean followSelection = true;
587 * @return true if view selection should always follow the selections
588 * broadcast by other selection sources
590 public boolean getFollowSelection()
592 return followSelection;
596 * Send the current selection to be broadcast to any selection listeners.
599 public void sendSelection()
601 jalview.structure.StructureSelectionManager
602 .getStructureSelectionManager(Desktop.instance).sendSelection(
603 new SequenceGroup(getSelectionGroup()),
604 new ColumnSelection(getColumnSelection()),
605 new HiddenColumns(getAlignment().getHiddenColumns()),
610 * return the alignPanel containing the given viewport. Use this to get the
611 * components currently handling the given viewport.
614 * @return null or an alignPanel guaranteed to have non-null alignFrame
617 public AlignmentPanel getAlignPanel()
619 AlignmentPanel[] aps = PaintRefresher.getAssociatedPanels(this
620 .getSequenceSetId());
621 for (int p = 0; aps != null && p < aps.length; p++)
623 if (aps[p].av == this)
631 public boolean getSortByTree()
636 public void setSortByTree(boolean sort)
642 * Returns the (Desktop) instance of the StructureSelectionManager
645 public StructureSelectionManager getStructureSelectionManager()
647 return StructureSelectionManager
648 .getStructureSelectionManager(Desktop.instance);
654 * @return an array of SequenceI arrays, one for each PDBEntry, listing which
655 * sequences in the alignment hold a reference to it
657 public SequenceI[][] collateForPDB(PDBEntry[] pdbEntries)
659 List<SequenceI[]> seqvectors = new ArrayList<SequenceI[]>();
660 for (PDBEntry pdb : pdbEntries)
662 List<SequenceI> choosenSeqs = new ArrayList<SequenceI>();
663 for (SequenceI sq : alignment.getSequences())
665 Vector<PDBEntry> pdbRefEntries = sq.getDatasetSequence()
667 if (pdbRefEntries == null)
671 for (PDBEntry pdbRefEntry : pdbRefEntries)
673 if (pdbRefEntry.getId().equals(pdb.getId()))
675 if (pdbRefEntry.getChainCode() != null
676 && pdb.getChainCode() != null)
678 if (pdbRefEntry.getChainCode().equalsIgnoreCase(
680 && !choosenSeqs.contains(sq))
688 if (!choosenSeqs.contains(sq))
699 .add(choosenSeqs.toArray(new SequenceI[choosenSeqs.size()]));
701 return seqvectors.toArray(new SequenceI[seqvectors.size()][]);
705 public boolean isNormaliseSequenceLogo()
707 return normaliseSequenceLogo;
710 public void setNormaliseSequenceLogo(boolean state)
712 normaliseSequenceLogo = state;
717 * @return true if alignment characters should be displayed
720 public boolean isValidCharWidth()
722 return validCharWidth;
725 private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<String, AutoCalcSetting>();
727 public AutoCalcSetting getCalcIdSettingsFor(String calcId)
729 return calcIdParams.get(calcId);
732 public void setCalcIdSettingsFor(String calcId, AutoCalcSetting settings,
735 calcIdParams.put(calcId, settings);
736 // TODO: create a restart list to trigger any calculations that need to be
737 // restarted after load
738 // calculator.getRegisteredWorkersOfClass(settings.getWorkerClass())
741 Cache.log.debug("trigger update for " + calcId);
746 * Method called when another alignment's edit (or possibly other) command is
749 * To allow for sequence mappings (e.g. protein to cDNA), we have to first
750 * 'unwind' the command on the source sequences (in simulation, not in fact),
751 * and then for each edit in turn:
753 * <li>compute the equivalent edit on the mapped sequences</li>
754 * <li>apply the mapped edit</li>
755 * <li>'apply' the source edit to the working copy of the source sequences</li>
763 public void mirrorCommand(CommandI command, boolean undo,
764 StructureSelectionManager ssm, VamsasSource source)
767 * Do nothing unless we are a 'complement' of the source. May replace this
768 * with direct calls not via SSM.
770 if (source instanceof AlignViewportI
771 && ((AlignViewportI) source).getCodingComplement() == this)
780 CommandI mappedCommand = ssm.mapCommand(command, undo, getAlignment(),
782 if (mappedCommand != null)
784 AlignmentI[] views = getAlignPanel().alignFrame.getViewAlignments();
785 mappedCommand.doCommand(views);
786 getAlignPanel().alignmentChanged();
791 * Add the sequences from the given alignment to this viewport. Optionally,
792 * may give the user the option to open a new frame, or split panel, with cDNA
793 * and protein linked.
798 public void addAlignment(AlignmentI toAdd, String title)
800 // TODO: promote to AlignViewportI? applet CutAndPasteTransfer is different
802 // JBPComment: title is a largely redundant parameter at the moment
803 // JBPComment: this really should be an 'insert/pre/append' controller
804 // JBPComment: but the DNA/Protein check makes it a bit more complex
806 // refactored from FileLoader / CutAndPasteTransfer / SequenceFetcher with
808 // TODO: create undo object for this JAL-1101
811 * Ensure datasets are created for the new alignment as
812 * mappings operate on dataset sequences
814 toAdd.setDataset(null);
817 * Check if any added sequence could be the object of a mapping or
818 * cross-reference; if so, make the mapping explicit
820 getAlignment().realiseMappings(toAdd.getSequences());
823 * If any cDNA/protein mappings exist or can be made between the alignments,
824 * offer to open a split frame with linked alignments
826 if (Cache.getDefault(Preferences.ENABLE_SPLIT_FRAME, true))
828 if (AlignmentUtils.isMappable(toAdd, getAlignment()))
830 if (openLinkedAlignment(toAdd, title))
838 * No mappings, or offer declined - add sequences to this alignment
840 // TODO: JAL-407 regardless of above - identical sequences (based on ID and
841 // provenance) should share the same dataset sequence
843 AlignmentI al = getAlignment();
844 String gap = String.valueOf(al.getGapCharacter());
845 for (int i = 0; i < toAdd.getHeight(); i++)
847 SequenceI seq = toAdd.getSequenceAt(i);
850 * - 'align' any mapped sequences as per existing
851 * e.g. cdna to genome, domain hit to protein sequence
852 * very experimental! (need a separate menu option for this)
853 * - only add mapped sequences ('select targets from a dataset')
855 if (true /*AlignmentUtils.alignSequenceAs(seq, al, gap, true, true)*/)
861 ranges.setEndSeq(getAlignment().getHeight());
862 firePropertyChange("alignment", null, getAlignment().getSequences());
866 * Show a dialog with the option to open and link (cDNA <-> protein) as a new
867 * alignment, either as a standalone alignment or in a split frame. Returns
868 * true if the new alignment was opened, false if not, because the user
869 * declined the offer.
874 protected boolean openLinkedAlignment(AlignmentI al, String title)
876 String[] options = new String[] {
877 MessageManager.getString("action.no"),
878 MessageManager.getString("label.split_window"),
879 MessageManager.getString("label.new_window"), };
880 final String question = JvSwingUtils.wrapTooltip(true,
881 MessageManager.getString("label.open_split_window?"));
882 int response = JvOptionPane.showOptionDialog(Desktop.desktop, question,
883 MessageManager.getString("label.open_split_window"),
884 JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null,
885 options, options[0]);
887 if (response != 1 && response != 2)
891 final boolean openSplitPane = (response == 1);
892 final boolean openInNewWindow = (response == 2);
895 * Identify protein and dna alignments. Make a copy of this one if opening
896 * in a new split pane.
898 AlignmentI thisAlignment = openSplitPane ? new Alignment(getAlignment())
900 AlignmentI protein = al.isNucleotide() ? thisAlignment : al;
901 final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment;
904 * Map sequences. At least one should get mapped as we have already passed
905 * the test for 'mappability'. Any mappings made will be added to the
906 * protein alignment. Note creating dataset sequences on the new alignment
907 * is a pre-requisite for building mappings.
910 AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna);
913 * Create the AlignFrame for the added alignment. If it is protein, mappings
914 * are registered with StructureSelectionManager as a side-effect.
916 AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
917 AlignFrame.DEFAULT_HEIGHT);
918 newAlignFrame.setTitle(title);
919 newAlignFrame.statusBar.setText(MessageManager.formatMessage(
920 "label.successfully_loaded_file", new Object[] { title }));
922 // TODO if we want this (e.g. to enable reload of the alignment from file),
923 // we will need to add parameters to the stack.
924 // if (!protocol.equals(DataSourceType.PASTE))
926 // alignFrame.setFileName(file, format);
931 Desktop.addInternalFrame(newAlignFrame, title,
932 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
937 newAlignFrame.setMaximum(jalview.bin.Cache.getDefault(
938 "SHOW_FULLSCREEN", false));
939 } catch (java.beans.PropertyVetoException ex)
945 al.alignAs(thisAlignment);
946 protein = openSplitFrame(newAlignFrame, thisAlignment);
953 * Helper method to open a new SplitFrame holding linked dna and protein
956 * @param newAlignFrame
957 * containing a new alignment to be shown
959 * cdna/protein complement alignment to show in the other split half
960 * @return the protein alignment in the split frame
962 protected AlignmentI openSplitFrame(AlignFrame newAlignFrame,
963 AlignmentI complement)
966 * Make a new frame with a copy of the alignment we are adding to. If this
967 * is protein, the mappings to cDNA will be registered with
968 * StructureSelectionManager as a side-effect.
970 AlignFrame copyMe = new AlignFrame(complement,
971 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
972 copyMe.setTitle(getAlignPanel().alignFrame.getTitle());
974 AlignmentI al = newAlignFrame.viewport.getAlignment();
975 final AlignFrame proteinFrame = al.isNucleotide() ? copyMe
977 final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame : copyMe;
978 cdnaFrame.setVisible(true);
979 proteinFrame.setVisible(true);
980 String linkedTitle = MessageManager
981 .getString("label.linked_view_title");
984 * Open in split pane. DNA sequence above, protein below.
986 JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame);
987 Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1);
989 return proteinFrame.viewport.getAlignment();
992 public AnnotationColumnChooser getAnnotationColumnSelectionState()
994 return annotationColumnSelectionState;
997 public void setAnnotationColumnSelectionState(
998 AnnotationColumnChooser currentAnnotationColumnSelectionState)
1000 this.annotationColumnSelectionState = currentAnnotationColumnSelectionState;
1004 public void setIdWidth(int i)
1006 super.setIdWidth(i);
1007 AlignmentPanel ap = getAlignPanel();
1010 // modify GUI elements to reflect geometry change
1011 Dimension idw = getAlignPanel().getIdPanel().getIdCanvas()
1012 .getPreferredSize();
1014 getAlignPanel().getIdPanel().getIdCanvas().setPreferredSize(idw);
1018 public Rectangle getExplodedGeometry()
1020 return explodedGeometry;
1023 public void setExplodedGeometry(Rectangle explodedPosition)
1025 this.explodedGeometry = explodedPosition;
1028 public boolean isGatherViewsHere()
1030 return gatherViewsHere;
1033 public void setGatherViewsHere(boolean gatherViewsHere)
1035 this.gatherViewsHere = gatherViewsHere;
1039 * If this viewport has a (Protein/cDNA) complement, then scroll the
1040 * complementary alignment to match this one.
1042 public void scrollComplementaryAlignment()
1045 * Populate a SearchResults object with the mapped location to scroll to. If
1046 * there is no complement, or it is not following highlights, or no mapping
1047 * is found, the result will be empty.
1049 SearchResultsI sr = new SearchResults();
1050 int verticalOffset = findComplementScrollTarget(sr);
1053 // TODO would like next line without cast but needs more refactoring...
1054 final AlignmentPanel complementPanel = ((AlignViewport) getCodingComplement())
1056 complementPanel.setToScrollComplementPanel(false);
1057 complementPanel.scrollToCentre(sr, verticalOffset);
1058 complementPanel.setToScrollComplementPanel(true);
1063 * Answers true if no alignment holds a reference to the given mapping
1068 protected boolean noReferencesTo(AlignedCodonFrame acf)
1070 AlignFrame[] frames = Desktop.getAlignFrames();
1075 for (AlignFrame af : frames)
1079 for (AlignmentViewPanel ap : af.getAlignPanels())
1081 AlignmentI al = ap.getAlignment();
1082 if (al != null && al.getCodonFrames().contains(acf))
1093 * Applies the supplied feature settings descriptor to currently known
1094 * features. This supports an 'initial configuration' of feature colouring
1095 * based on a preset or user favourite. This may then be modified in the usual
1096 * way using the Feature Settings dialogue.
1098 * @param featureSettings
1101 public void applyFeaturesStyle(FeatureSettingsModelI featureSettings)
1103 if (featureSettings == null)
1108 FeatureRenderer fr = getAlignPanel().getSeqPanel().seqCanvas
1109 .getFeatureRenderer();
1110 fr.findAllFeatures(true);
1111 List<String> renderOrder = fr.getRenderOrder();
1112 FeaturesDisplayedI displayed = fr.getFeaturesDisplayed();
1114 // TODO this clears displayed.featuresRegistered - do we care?
1117 * set feature colour if specified by feature settings
1118 * set visibility of all features
1120 for (String type : renderOrder)
1122 FeatureColourI preferredColour = featureSettings
1123 .getFeatureColour(type);
1124 if (preferredColour != null)
1126 fr.setColour(type, preferredColour);
1128 if (featureSettings.isFeatureDisplayed(type))
1130 displayed.setVisible(type);
1135 * set visibility of feature groups
1137 for (String group : fr.getFeatureGroups())
1139 fr.setGroupVisibility(group, featureSettings.isGroupDisplayed(group));
1143 * order the features
1145 if (featureSettings.optimiseOrder())
1147 // TODO not supported (yet?)
1151 fr.orderFeatures(featureSettings);
1153 fr.setTransparency(featureSettings.getTransparency());