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.PDBEntry;
39 import jalview.datamodel.SearchResults;
40 import jalview.datamodel.SearchResultsI;
41 import jalview.datamodel.Sequence;
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.viewmodel.ViewportRanges;
55 import jalview.ws.params.AutoCalcSetting;
57 import java.awt.Container;
58 import java.awt.Dimension;
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 implements
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)
126 sequenceSetID = seqsetid;
128 // TODO remove these once 2.4.VAMSAS release finished
129 if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null)
131 Cache.log.debug("Setting viewport's sequence set id : "
134 if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null)
136 Cache.log.debug("Setting viewport's view id : " + viewId);
143 * Create a new AlignViewport with hidden regions
147 * @param hiddenColumns
150 public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns)
153 if (hiddenColumns != null)
155 colSel = hiddenColumns;
161 * New viewport with hidden columns and an existing sequence set id
164 * @param hiddenColumns
168 public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns,
171 this(al, hiddenColumns, seqsetid, null);
175 * New viewport with hidden columns and an existing sequence set id and viewid
178 * @param hiddenColumns
184 public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns,
185 String seqsetid, String viewid)
187 sequenceSetID = seqsetid;
189 // TODO remove these once 2.4.VAMSAS release finished
190 if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null)
192 Cache.log.debug("Setting viewport's sequence set id : "
195 if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null)
197 Cache.log.debug("Setting viewport's view id : " + viewId);
200 if (hiddenColumns != null)
202 colSel = hiddenColumns;
208 * Apply any settings saved in user preferences
210 private void applyViewProperties()
212 antiAlias = Cache.getDefault("ANTI_ALIAS", false);
214 viewStyle.setShowJVSuffix(Cache.getDefault("SHOW_JVSUFFIX", true));
215 setShowAnnotation(Cache.getDefault("SHOW_ANNOTATIONS", true));
217 setRightAlignIds(Cache.getDefault("RIGHT_ALIGN_IDS", false));
218 setCentreColumnLabels(Cache.getDefault("CENTRE_COLUMN_LABELS", false));
219 autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
221 setPadGaps(Cache.getDefault("PAD_GAPS", true));
222 setShowNPFeats(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
223 setShowDBRefs(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
224 viewStyle.setSeqNameItalics(Cache.getDefault("ID_ITALICS", true));
225 viewStyle.setWrapAlignment(Cache.getDefault("WRAP_ALIGNMENT", false));
226 viewStyle.setShowUnconserved(Cache
227 .getDefault("SHOW_UNCONSERVED", false));
228 sortByTree = Cache.getDefault("SORT_BY_TREE", false);
229 followSelection = Cache.getDefault("FOLLOW_SELECTIONS", true);
230 sortAnnotationsBy = SequenceAnnotationOrder.valueOf(Cache.getDefault(
231 Preferences.SORT_ANNOTATIONS,
232 SequenceAnnotationOrder.NONE.name()));
233 showAutocalculatedAbove = Cache.getDefault(
234 Preferences.SHOW_AUTOCALC_ABOVE, false);
235 viewStyle.setScaleProteinAsCdna(Cache.getDefault(
236 Preferences.SCALE_PROTEIN_TO_CDNA, true));
241 ranges = new ViewportRanges(this.alignment);
242 applyViewProperties();
244 String fontName = Cache.getDefault("FONT_NAME", "SansSerif");
245 String fontStyle = Cache.getDefault("FONT_STYLE", Font.PLAIN + "");
246 String fontSize = Cache.getDefault("FONT_SIZE", "10");
250 if (fontStyle.equals("bold"))
254 else if (fontStyle.equals("italic"))
259 setFont(new Font(fontName, style, Integer.parseInt(fontSize)), true);
262 .setGapCharacter(Cache.getDefault("GAP_SYMBOL", "-").charAt(0));
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("SHOW_CONSERVATION", true);
271 showQuality = Cache.getDefault("SHOW_QUALITY", true);
272 showGroupConservation = Cache.getDefault("SHOW_GROUP_CONSERVATION",
275 showConsensusHistogram = Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM",
277 showSequenceLogo = Cache.getDefault("SHOW_CONSENSUS_LOGO", false);
278 normaliseSequenceLogo = Cache.getDefault("NORMALISE_CONSENSUS_LOGO",
280 showGroupConsensus = Cache.getDefault("SHOW_GROUP_CONSENSUS", false);
281 showConsensus = Cache.getDefault("SHOW_IDENTITY", true);
283 showOccupancy = Cache.getDefault(Preferences.SHOW_OCCUPANCY, true);
285 initAutoAnnotation();
286 String colourProperty = alignment.isNucleotide() ? Preferences.DEFAULT_COLOUR_NUC
287 : Preferences.DEFAULT_COLOUR_PROT;
288 String schemeName = Cache.getProperty(colourProperty);
289 if (schemeName == null)
291 // only DEFAULT_COLOUR available in Jalview before 2.9
292 schemeName = Cache.getDefault(Preferences.DEFAULT_COLOUR,
293 ResidueColourScheme.NONE);
295 ColourSchemeI colourScheme = ColourSchemeProperty.getColourScheme(
296 alignment, schemeName);
297 residueShading = new ResidueShader(colourScheme);
299 if (colourScheme instanceof UserColourScheme)
301 residueShading = new ResidueShader(
302 UserDefinedColours.loadDefaultColours());
303 residueShading.setThreshold(0, isIgnoreGapsConsensus());
306 if (residueShading != null)
308 residueShading.setConsensus(hconsensus);
313 * get the consensus sequence as displayed under the PID consensus annotation
316 * @return consensus sequence as a new sequence object
318 public SequenceI getConsensusSeq()
320 if (consensus == null)
322 updateConsensus(null);
324 if (consensus == null)
328 StringBuffer seqs = new StringBuffer();
329 for (int i = 0; i < consensus.annotations.length; i++)
331 if (consensus.annotations[i] != null)
333 if (consensus.annotations[i].description.charAt(0) == '[')
335 seqs.append(consensus.annotations[i].description.charAt(1));
339 seqs.append(consensus.annotations[i].displayCharacter);
344 SequenceI sq = new Sequence("Consensus", seqs.toString());
345 sq.setDescription("Percentage Identity Consensus "
346 + ((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
350 boolean validCharWidth;
353 * update view settings with the given font. You may need to call
354 * alignPanel.fontChanged to update the layout geometry
357 * when true, charWidth/height is set according to font mentrics
359 public void setFont(Font f, boolean setGrid)
363 Container c = new Container();
365 java.awt.FontMetrics fm = c.getFontMetrics(font);
366 int w = viewStyle.getCharWidth(), ww = fm.charWidth('M'), h = viewStyle
370 setCharHeight(fm.getHeight());
373 viewStyle.setFontName(font.getName());
374 viewStyle.setFontStyle(font.getStyle());
375 viewStyle.setFontSize(font.getSize());
377 validCharWidth = true;
381 public void setViewStyle(ViewStyleI settingsForView)
383 super.setViewStyle(settingsForView);
384 setFont(new Font(viewStyle.getFontName(), viewStyle.getFontStyle(),
385 viewStyle.getFontSize()), false);
391 * @return DOCUMENT ME!
393 public Font getFont()
405 public void setAlignment(AlignmentI align)
407 replaceMappings(align);
408 super.setAlignment(align);
412 * Replace any codon mappings for this viewport with those for the given
417 public void replaceMappings(AlignmentI align)
421 * Deregister current mappings (if any)
423 deregisterMappings();
426 * Register new mappings (if any)
430 StructureSelectionManager ssm = StructureSelectionManager
431 .getStructureSelectionManager(Desktop.instance);
432 ssm.registerMappings(align.getCodonFrames());
436 * replace mappings on our alignment
438 if (alignment != null && align != null)
440 alignment.setCodonFrames(align.getCodonFrames());
444 protected void deregisterMappings()
446 AlignmentI al = getAlignment();
449 List<AlignedCodonFrame> mappings = al.getCodonFrames();
450 if (mappings != null)
452 StructureSelectionManager ssm = StructureSelectionManager
453 .getStructureSelectionManager(Desktop.instance);
454 for (AlignedCodonFrame acf : mappings)
456 if (noReferencesTo(acf))
458 ssm.deregisterMapping(acf);
468 * @return DOCUMENT ME!
471 public char getGapCharacter()
473 return getAlignment().getGapCharacter();
482 public void setGapCharacter(char gap)
484 if (getAlignment() != null)
486 getAlignment().setGapCharacter(gap);
496 public void setCurrentTree(TreeModel tree)
504 * @return DOCUMENT ME!
506 public TreeModel getCurrentTree()
512 * returns the visible column regions of the alignment
514 * @param selectedRegionOnly
515 * true to just return the contigs intersecting with the selected
519 public int[] getViewAsVisibleContigs(boolean selectedRegionOnly)
521 int[] viscontigs = null;
522 int start = 0, end = 0;
523 if (selectedRegionOnly && selectionGroup != null)
525 start = selectionGroup.getStartRes();
526 end = selectionGroup.getEndRes() + 1;
530 end = alignment.getWidth();
532 viscontigs = colSel.getVisibleContigs(start, end);
537 * get hash of undo and redo list for the alignment
539 * @return long[] { historyList.hashCode, redoList.hashCode };
541 public long[] getUndoRedoHash()
544 if (historyList == null || redoList == null)
546 return new long[] { -1, -1 };
548 return new long[] { historyList.hashCode(), this.redoList.hashCode() };
552 * test if a particular set of hashcodes are different to the hashcodes for
553 * the undo and redo list.
556 * the stored set of hashcodes as returned by getUndoRedoHash
557 * @return true if the hashcodes differ (ie the alignment has been edited) or
558 * the stored hashcode array differs in size
560 public boolean isUndoRedoHashModified(long[] undoredo)
562 if (undoredo == null)
566 long[] cstate = getUndoRedoHash();
567 if (cstate.length != undoredo.length)
572 for (int i = 0; i < cstate.length; i++)
574 if (cstate[i] != undoredo[i])
582 public boolean followSelection = true;
585 * @return true if view selection should always follow the selections
586 * broadcast by other selection sources
588 public boolean getFollowSelection()
590 return followSelection;
594 * Send the current selection to be broadcast to any selection listeners.
597 public void sendSelection()
599 jalview.structure.StructureSelectionManager
600 .getStructureSelectionManager(Desktop.instance).sendSelection(
601 new SequenceGroup(getSelectionGroup()),
602 new ColumnSelection(getColumnSelection()), this);
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<SequenceI[]>();
656 for (PDBEntry pdb : pdbEntries)
658 List<SequenceI> choosenSeqs = new ArrayList<SequenceI>();
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;
706 public void setNormaliseSequenceLogo(boolean state)
708 normaliseSequenceLogo = state;
713 * @return true if alignment characters should be displayed
716 public boolean isValidCharWidth()
718 return validCharWidth;
721 private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<String, AutoCalcSetting>();
723 public AutoCalcSetting getCalcIdSettingsFor(String calcId)
725 return calcIdParams.get(calcId);
728 public void setCalcIdSettingsFor(String calcId, AutoCalcSetting settings,
731 calcIdParams.put(calcId, settings);
732 // TODO: create a restart list to trigger any calculations that need to be
733 // restarted after load
734 // calculator.getRegisteredWorkersOfClass(settings.getWorkerClass())
737 Cache.log.debug("trigger update for " + calcId);
742 * Method called when another alignment's edit (or possibly other) command is
745 * To allow for sequence mappings (e.g. protein to cDNA), we have to first
746 * 'unwind' the command on the source sequences (in simulation, not in fact),
747 * and then for each edit in turn:
749 * <li>compute the equivalent edit on the mapped sequences</li>
750 * <li>apply the mapped edit</li>
751 * <li>'apply' the source edit to the working copy of the source sequences</li>
759 public void mirrorCommand(CommandI command, boolean undo,
760 StructureSelectionManager ssm, VamsasSource source)
763 * Do nothing unless we are a 'complement' of the source. May replace this
764 * with direct calls not via SSM.
766 if (source instanceof AlignViewportI
767 && ((AlignViewportI) source).getCodingComplement() == this)
776 CommandI mappedCommand = ssm.mapCommand(command, undo, getAlignment(),
778 if (mappedCommand != null)
780 AlignmentI[] views = getAlignPanel().alignFrame.getViewAlignments();
781 mappedCommand.doCommand(views);
782 getAlignPanel().alignmentChanged();
787 * Add the sequences from the given alignment to this viewport. Optionally,
788 * may give the user the option to open a new frame, or split panel, with cDNA
789 * and protein linked.
794 public void addAlignment(AlignmentI toAdd, String title)
796 // TODO: promote to AlignViewportI? applet CutAndPasteTransfer is different
798 // JBPComment: title is a largely redundant parameter at the moment
799 // JBPComment: this really should be an 'insert/pre/append' controller
800 // JBPComment: but the DNA/Protein check makes it a bit more complex
802 // refactored from FileLoader / CutAndPasteTransfer / SequenceFetcher with
804 // TODO: create undo object for this JAL-1101
807 * Ensure datasets are created for the new alignment as
808 * mappings operate on dataset sequences
810 toAdd.setDataset(null);
813 * Check if any added sequence could be the object of a mapping or
814 * cross-reference; if so, make the mapping explicit
816 getAlignment().realiseMappings(toAdd.getSequences());
819 * If any cDNA/protein mappings exist or can be made between the alignments,
820 * offer to open a split frame with linked alignments
822 if (Cache.getDefault(Preferences.ENABLE_SPLIT_FRAME, true))
824 if (AlignmentUtils.isMappable(toAdd, getAlignment()))
826 if (openLinkedAlignment(toAdd, title))
834 * No mappings, or offer declined - add sequences to this alignment
836 // TODO: JAL-407 regardless of above - identical sequences (based on ID and
837 // provenance) should share the same dataset sequence
839 AlignmentI al = getAlignment();
840 String gap = String.valueOf(al.getGapCharacter());
841 for (int i = 0; i < toAdd.getHeight(); i++)
843 SequenceI seq = toAdd.getSequenceAt(i);
846 * - 'align' any mapped sequences as per existing
847 * e.g. cdna to genome, domain hit to protein sequence
848 * very experimental! (need a separate menu option for this)
849 * - only add mapped sequences ('select targets from a dataset')
851 if (true /*AlignmentUtils.alignSequenceAs(seq, al, gap, true, true)*/)
857 ranges.setEndSeq(getAlignment().getHeight());
858 firePropertyChange("alignment", null, getAlignment().getSequences());
862 * Show a dialog with the option to open and link (cDNA <-> protein) as a new
863 * alignment, either as a standalone alignment or in a split frame. Returns
864 * true if the new alignment was opened, false if not, because the user
865 * declined the offer.
870 protected boolean openLinkedAlignment(AlignmentI al, String title)
872 String[] options = new String[] {
873 MessageManager.getString("action.no"),
874 MessageManager.getString("label.split_window"),
875 MessageManager.getString("label.new_window"), };
876 final String question = JvSwingUtils.wrapTooltip(true,
877 MessageManager.getString("label.open_split_window?"));
878 int response = JvOptionPane.showOptionDialog(Desktop.desktop, question,
879 MessageManager.getString("label.open_split_window"),
880 JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null,
881 options, options[0]);
883 if (response != 1 && response != 2)
887 final boolean openSplitPane = (response == 1);
888 final boolean openInNewWindow = (response == 2);
891 * Identify protein and dna alignments. Make a copy of this one if opening
892 * in a new split pane.
894 AlignmentI thisAlignment = openSplitPane ? new Alignment(getAlignment())
896 AlignmentI protein = al.isNucleotide() ? thisAlignment : al;
897 final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment;
900 * Map sequences. At least one should get mapped as we have already passed
901 * the test for 'mappability'. Any mappings made will be added to the
902 * protein alignment. Note creating dataset sequences on the new alignment
903 * is a pre-requisite for building mappings.
906 AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna);
909 * Create the AlignFrame for the added alignment. If it is protein, mappings
910 * are registered with StructureSelectionManager as a side-effect.
912 AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
913 AlignFrame.DEFAULT_HEIGHT);
914 newAlignFrame.setTitle(title);
915 newAlignFrame.statusBar.setText(MessageManager.formatMessage(
916 "label.successfully_loaded_file", new Object[] { title }));
918 // TODO if we want this (e.g. to enable reload of the alignment from file),
919 // we will need to add parameters to the stack.
920 // if (!protocol.equals(DataSourceType.PASTE))
922 // alignFrame.setFileName(file, format);
927 Desktop.addInternalFrame(newAlignFrame, title,
928 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
933 newAlignFrame.setMaximum(jalview.bin.Cache.getDefault(
934 "SHOW_FULLSCREEN", false));
935 } catch (java.beans.PropertyVetoException ex)
941 al.alignAs(thisAlignment);
942 protein = openSplitFrame(newAlignFrame, thisAlignment);
949 * Helper method to open a new SplitFrame holding linked dna and protein
952 * @param newAlignFrame
953 * containing a new alignment to be shown
955 * cdna/protein complement alignment to show in the other split half
956 * @return the protein alignment in the split frame
958 protected AlignmentI openSplitFrame(AlignFrame newAlignFrame,
959 AlignmentI complement)
962 * Make a new frame with a copy of the alignment we are adding to. If this
963 * is protein, the mappings to cDNA will be registered with
964 * StructureSelectionManager as a side-effect.
966 AlignFrame copyMe = new AlignFrame(complement,
967 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
968 copyMe.setTitle(getAlignPanel().alignFrame.getTitle());
970 AlignmentI al = newAlignFrame.viewport.getAlignment();
971 final AlignFrame proteinFrame = al.isNucleotide() ? copyMe
973 final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame : copyMe;
974 cdnaFrame.setVisible(true);
975 proteinFrame.setVisible(true);
976 String linkedTitle = MessageManager
977 .getString("label.linked_view_title");
980 * Open in split pane. DNA sequence above, protein below.
982 JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame);
983 Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1);
985 return proteinFrame.viewport.getAlignment();
988 public AnnotationColumnChooser getAnnotationColumnSelectionState()
990 return annotationColumnSelectionState;
993 public void setAnnotationColumnSelectionState(
994 AnnotationColumnChooser currentAnnotationColumnSelectionState)
996 this.annotationColumnSelectionState = currentAnnotationColumnSelectionState;
1000 public void setIdWidth(int i)
1002 super.setIdWidth(i);
1003 AlignmentPanel ap = getAlignPanel();
1006 // modify GUI elements to reflect geometry change
1007 Dimension idw = getAlignPanel().getIdPanel().getIdCanvas()
1008 .getPreferredSize();
1010 getAlignPanel().getIdPanel().getIdCanvas().setPreferredSize(idw);
1014 public Rectangle getExplodedGeometry()
1016 return explodedGeometry;
1019 public void setExplodedGeometry(Rectangle explodedPosition)
1021 this.explodedGeometry = explodedPosition;
1024 public boolean isGatherViewsHere()
1026 return gatherViewsHere;
1029 public void setGatherViewsHere(boolean gatherViewsHere)
1031 this.gatherViewsHere = gatherViewsHere;
1035 * If this viewport has a (Protein/cDNA) complement, then scroll the
1036 * complementary alignment to match this one.
1038 public void scrollComplementaryAlignment()
1041 * Populate a SearchResults object with the mapped location to scroll to. If
1042 * there is no complement, or it is not following highlights, or no mapping
1043 * is found, the result will be empty.
1045 SearchResultsI sr = new SearchResults();
1046 int verticalOffset = findComplementScrollTarget(sr);
1049 // TODO would like next line without cast but needs more refactoring...
1050 final AlignmentPanel complementPanel = ((AlignViewport) getCodingComplement())
1052 complementPanel.setDontScrollComplement(true);
1053 complementPanel.scrollToCentre(sr, verticalOffset);
1058 * Answers true if no alignment holds a reference to the given mapping
1063 protected boolean noReferencesTo(AlignedCodonFrame acf)
1065 AlignFrame[] frames = Desktop.getAlignFrames();
1070 for (AlignFrame af : frames)
1074 for (AlignmentViewPanel ap : af.getAlignPanels())
1076 AlignmentI al = ap.getAlignment();
1077 if (al != null && al.getCodonFrames().contains(acf))
1088 * Applies the supplied feature settings descriptor to currently known
1089 * features. This supports an 'initial configuration' of feature colouring
1090 * based on a preset or user favourite. This may then be modified in the usual
1091 * way using the Feature Settings dialogue.
1093 * @param featureSettings
1096 public void applyFeaturesStyle(FeatureSettingsModelI featureSettings)
1098 if (featureSettings == null)
1103 FeatureRenderer fr = getAlignPanel().getSeqPanel().seqCanvas
1104 .getFeatureRenderer();
1105 fr.findAllFeatures(true);
1106 List<String> renderOrder = fr.getRenderOrder();
1107 FeaturesDisplayedI displayed = fr.getFeaturesDisplayed();
1109 // TODO this clears displayed.featuresRegistered - do we care?
1112 * set feature colour if specified by feature settings
1113 * set visibility of all features
1115 for (String type : renderOrder)
1117 FeatureColourI preferredColour = featureSettings
1118 .getFeatureColour(type);
1119 if (preferredColour != null)
1121 fr.setColour(type, preferredColour);
1123 if (featureSettings.isFeatureDisplayed(type))
1125 displayed.setVisible(type);
1130 * set visibility of feature groups
1132 for (String group : fr.getFeatureGroups())
1134 fr.setGroupVisibility(group, featureSettings.isGroupDisplayed(group));
1138 * order the features
1140 if (featureSettings.optimiseOrder())
1142 // TODO not supported (yet?)
1146 fr.orderFeatures(featureSettings);
1148 fr.setTransparency(featureSettings.getTransparency());