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.NJTree;
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.ws.params.AutoCalcSetting;
56 import java.awt.Container;
57 import java.awt.Dimension;
59 import java.awt.Rectangle;
60 import java.util.ArrayList;
61 import java.util.Hashtable;
62 import java.util.List;
63 import java.util.Vector;
65 import javax.swing.JInternalFrame;
71 * @version $Revision: 1.141 $
73 public class AlignViewport extends AlignmentViewport implements
78 NJTree currentTree = null;
80 boolean cursorMode = false;
82 boolean antiAlias = false;
84 private Rectangle explodedGeometry;
89 * Flag set true on the view that should 'gather' multiple views of the same
90 * sequence set id when a project is reloaded. Set false on all views when
91 * they are 'exploded' into separate windows. Set true on the current view
92 * when 'Gather' is performed, and also on the first tab when the first new
95 private boolean gatherViewsHere = false;
97 private AnnotationColumnChooser annotationColumnSelectionState;
100 * Creates a new AlignViewport object.
105 public AlignViewport(AlignmentI al)
112 * Create a new AlignViewport object with a specific sequence set ID
116 * (may be null - but potential for ambiguous constructor exception)
118 public AlignViewport(AlignmentI al, String seqsetid)
120 this(al, seqsetid, null);
123 public AlignViewport(AlignmentI al, String seqsetid, String viewid)
125 sequenceSetID = seqsetid;
127 // TODO remove these once 2.4.VAMSAS release finished
128 if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null)
130 Cache.log.debug("Setting viewport's sequence set id : "
133 if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null)
135 Cache.log.debug("Setting viewport's view id : " + viewId);
142 * Create a new AlignViewport with hidden regions
146 * @param hiddenColumns
149 public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns)
152 if (hiddenColumns != null)
154 colSel = hiddenColumns;
160 * New viewport with hidden columns and an existing sequence set id
163 * @param hiddenColumns
167 public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns,
170 this(al, hiddenColumns, seqsetid, null);
174 * New viewport with hidden columns and an existing sequence set id and viewid
177 * @param hiddenColumns
183 public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns,
184 String seqsetid, String viewid)
186 sequenceSetID = seqsetid;
188 // TODO remove these once 2.4.VAMSAS release finished
189 if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null)
191 Cache.log.debug("Setting viewport's sequence set id : "
194 if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null)
196 Cache.log.debug("Setting viewport's view id : " + viewId);
199 if (hiddenColumns != null)
201 colSel = hiddenColumns;
207 * Apply any settings saved in user preferences
209 private void applyViewProperties()
211 antiAlias = Cache.getDefault("ANTI_ALIAS", false);
213 viewStyle.setShowJVSuffix(Cache.getDefault("SHOW_JVSUFFIX", true));
214 setShowAnnotation(Cache.getDefault("SHOW_ANNOTATIONS", true));
216 setRightAlignIds(Cache.getDefault("RIGHT_ALIGN_IDS", false));
217 setCentreColumnLabels(Cache.getDefault("CENTRE_COLUMN_LABELS", false));
218 autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
220 setPadGaps(Cache.getDefault("PAD_GAPS", true));
221 setShowNPFeats(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
222 setShowDBRefs(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
223 viewStyle.setSeqNameItalics(Cache.getDefault("ID_ITALICS", true));
224 viewStyle.setWrapAlignment(Cache.getDefault("WRAP_ALIGNMENT", false));
225 viewStyle.setShowUnconserved(Cache
226 .getDefault("SHOW_UNCONSERVED", false));
227 sortByTree = Cache.getDefault("SORT_BY_TREE", false);
228 followSelection = Cache.getDefault("FOLLOW_SELECTIONS", true);
229 sortAnnotationsBy = SequenceAnnotationOrder.valueOf(Cache.getDefault(
230 Preferences.SORT_ANNOTATIONS,
231 SequenceAnnotationOrder.NONE.name()));
232 showAutocalculatedAbove = Cache.getDefault(
233 Preferences.SHOW_AUTOCALC_ABOVE, false);
234 viewStyle.setScaleProteinAsCdna(Cache.getDefault(
235 Preferences.SCALE_PROTEIN_TO_CDNA, true));
241 this.endRes = alignment.getWidth() - 1;
243 this.endSeq = alignment.getHeight() - 1;
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 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);
386 if (residueShading != null)
388 residueShading.setConservationApplied(settingsForView
389 .isConservationColourSelected());
396 * @return DOCUMENT ME!
398 public Font getFont()
410 public void setAlignment(AlignmentI align)
412 replaceMappings(align);
413 super.setAlignment(align);
417 * Replace any codon mappings for this viewport with those for the given
422 public void replaceMappings(AlignmentI align)
426 * Deregister current mappings (if any)
428 deregisterMappings();
431 * Register new mappings (if any)
435 StructureSelectionManager ssm = StructureSelectionManager
436 .getStructureSelectionManager(Desktop.instance);
437 ssm.registerMappings(align.getCodonFrames());
441 * replace mappings on our alignment
443 if (alignment != null && align != null)
445 alignment.setCodonFrames(align.getCodonFrames());
449 protected void deregisterMappings()
451 AlignmentI al = getAlignment();
454 List<AlignedCodonFrame> mappings = al.getCodonFrames();
455 if (mappings != null)
457 StructureSelectionManager ssm = StructureSelectionManager
458 .getStructureSelectionManager(Desktop.instance);
459 for (AlignedCodonFrame acf : mappings)
461 if (noReferencesTo(acf))
463 ssm.deregisterMapping(acf);
473 * @return DOCUMENT ME!
476 public char getGapCharacter()
478 return getAlignment().getGapCharacter();
487 public void setGapCharacter(char gap)
489 if (getAlignment() != null)
491 getAlignment().setGapCharacter(gap);
501 public void setCurrentTree(NJTree tree)
509 * @return DOCUMENT ME!
511 public NJTree getCurrentTree()
517 * returns the visible column regions of the alignment
519 * @param selectedRegionOnly
520 * true to just return the contigs intersecting with the selected
524 public int[] getViewAsVisibleContigs(boolean selectedRegionOnly)
526 int[] viscontigs = null;
527 int start = 0, end = 0;
528 if (selectedRegionOnly && selectionGroup != null)
530 start = selectionGroup.getStartRes();
531 end = selectionGroup.getEndRes() + 1;
535 end = alignment.getWidth();
537 viscontigs = colSel.getVisibleContigs(start, end);
542 * get hash of undo and redo list for the alignment
544 * @return long[] { historyList.hashCode, redoList.hashCode };
546 public long[] getUndoRedoHash()
549 if (historyList == null || redoList == null)
551 return new long[] { -1, -1 };
553 return new long[] { historyList.hashCode(), this.redoList.hashCode() };
557 * test if a particular set of hashcodes are different to the hashcodes for
558 * the undo and redo list.
561 * the stored set of hashcodes as returned by getUndoRedoHash
562 * @return true if the hashcodes differ (ie the alignment has been edited) or
563 * the stored hashcode array differs in size
565 public boolean isUndoRedoHashModified(long[] undoredo)
567 if (undoredo == null)
571 long[] cstate = getUndoRedoHash();
572 if (cstate.length != undoredo.length)
577 for (int i = 0; i < cstate.length; i++)
579 if (cstate[i] != undoredo[i])
587 public boolean followSelection = true;
590 * @return true if view selection should always follow the selections
591 * broadcast by other selection sources
593 public boolean getFollowSelection()
595 return followSelection;
599 * Send the current selection to be broadcast to any selection listeners.
602 public void sendSelection()
604 jalview.structure.StructureSelectionManager
605 .getStructureSelectionManager(Desktop.instance).sendSelection(
606 new SequenceGroup(getSelectionGroup()),
607 new ColumnSelection(getColumnSelection()), this);
611 * return the alignPanel containing the given viewport. Use this to get the
612 * components currently handling the given viewport.
615 * @return null or an alignPanel guaranteed to have non-null alignFrame
618 public AlignmentPanel getAlignPanel()
620 AlignmentPanel[] aps = PaintRefresher.getAssociatedPanels(this
621 .getSequenceSetId());
622 for (int p = 0; aps != null && p < aps.length; p++)
624 if (aps[p].av == this)
632 public boolean getSortByTree()
637 public void setSortByTree(boolean sort)
643 * Returns the (Desktop) instance of the StructureSelectionManager
646 public StructureSelectionManager getStructureSelectionManager()
648 return StructureSelectionManager
649 .getStructureSelectionManager(Desktop.instance);
655 * @return an array of SequenceI arrays, one for each PDBEntry, listing which
656 * sequences in the alignment hold a reference to it
658 public SequenceI[][] collateForPDB(PDBEntry[] pdbEntries)
660 List<SequenceI[]> seqvectors = new ArrayList<SequenceI[]>();
661 for (PDBEntry pdb : pdbEntries)
663 List<SequenceI> choosenSeqs = new ArrayList<SequenceI>();
664 for (SequenceI sq : alignment.getSequences())
666 Vector<PDBEntry> pdbRefEntries = sq.getDatasetSequence()
668 if (pdbRefEntries == null)
672 for (PDBEntry pdbRefEntry : pdbRefEntries)
674 if (pdbRefEntry.getId().equals(pdb.getId()))
676 if (pdbRefEntry.getChainCode() != null
677 && pdb.getChainCode() != null)
679 if (pdbRefEntry.getChainCode().equalsIgnoreCase(
681 && !choosenSeqs.contains(sq))
689 if (!choosenSeqs.contains(sq))
700 .add(choosenSeqs.toArray(new SequenceI[choosenSeqs.size()]));
702 return seqvectors.toArray(new SequenceI[seqvectors.size()][]);
706 public boolean isNormaliseSequenceLogo()
708 return normaliseSequenceLogo;
711 public void setNormaliseSequenceLogo(boolean state)
713 normaliseSequenceLogo = state;
718 * @return true if alignment characters should be displayed
721 public boolean isValidCharWidth()
723 return validCharWidth;
726 private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<String, AutoCalcSetting>();
728 public AutoCalcSetting getCalcIdSettingsFor(String calcId)
730 return calcIdParams.get(calcId);
733 public void setCalcIdSettingsFor(String calcId, AutoCalcSetting settings,
736 calcIdParams.put(calcId, settings);
737 // TODO: create a restart list to trigger any calculations that need to be
738 // restarted after load
739 // calculator.getRegisteredWorkersOfClass(settings.getWorkerClass())
742 Cache.log.debug("trigger update for " + calcId);
747 * Method called when another alignment's edit (or possibly other) command is
750 * To allow for sequence mappings (e.g. protein to cDNA), we have to first
751 * 'unwind' the command on the source sequences (in simulation, not in fact),
752 * and then for each edit in turn:
754 * <li>compute the equivalent edit on the mapped sequences</li>
755 * <li>apply the mapped edit</li>
756 * <li>'apply' the source edit to the working copy of the source sequences</li>
764 public void mirrorCommand(CommandI command, boolean undo,
765 StructureSelectionManager ssm, VamsasSource source)
768 * Do nothing unless we are a 'complement' of the source. May replace this
769 * with direct calls not via SSM.
771 if (source instanceof AlignViewportI
772 && ((AlignViewportI) source).getCodingComplement() == this)
781 CommandI mappedCommand = ssm.mapCommand(command, undo, getAlignment(),
783 if (mappedCommand != null)
785 AlignmentI[] views = getAlignPanel().alignFrame.getViewAlignments();
786 mappedCommand.doCommand(views);
787 getAlignPanel().alignmentChanged();
792 * Add the sequences from the given alignment to this viewport. Optionally,
793 * may give the user the option to open a new frame, or split panel, with cDNA
794 * and protein linked.
799 public void addAlignment(AlignmentI toAdd, String title)
801 // TODO: promote to AlignViewportI? applet CutAndPasteTransfer is different
803 // JBPComment: title is a largely redundant parameter at the moment
804 // JBPComment: this really should be an 'insert/pre/append' controller
805 // JBPComment: but the DNA/Protein check makes it a bit more complex
807 // refactored from FileLoader / CutAndPasteTransfer / SequenceFetcher with
809 // TODO: create undo object for this JAL-1101
812 * Ensure datasets are created for the new alignment as
813 * mappings operate on dataset sequences
815 toAdd.setDataset(null);
818 * Check if any added sequence could be the object of a mapping or
819 * cross-reference; if so, make the mapping explicit
821 getAlignment().realiseMappings(toAdd.getSequences());
824 * If any cDNA/protein mappings exist or can be made between the alignments,
825 * offer to open a split frame with linked alignments
827 if (Cache.getDefault(Preferences.ENABLE_SPLIT_FRAME, true))
829 if (AlignmentUtils.isMappable(toAdd, getAlignment()))
831 if (openLinkedAlignment(toAdd, title))
839 * No mappings, or offer declined - add sequences to this alignment
841 // TODO: JAL-407 regardless of above - identical sequences (based on ID and
842 // provenance) should share the same dataset sequence
844 AlignmentI al = getAlignment();
845 String gap = String.valueOf(al.getGapCharacter());
846 for (int i = 0; i < toAdd.getHeight(); i++)
848 SequenceI seq = toAdd.getSequenceAt(i);
851 * - 'align' any mapped sequences as per existing
852 * e.g. cdna to genome, domain hit to protein sequence
853 * very experimental! (need a separate menu option for this)
854 * - only add mapped sequences ('select targets from a dataset')
856 if (true /*AlignmentUtils.alignSequenceAs(seq, al, gap, true, true)*/)
862 setEndSeq(getAlignment().getHeight());
863 firePropertyChange("alignment", null, getAlignment().getSequences());
867 * Show a dialog with the option to open and link (cDNA <-> protein) as a new
868 * alignment, either as a standalone alignment or in a split frame. Returns
869 * true if the new alignment was opened, false if not, because the user
870 * declined the offer.
875 protected boolean openLinkedAlignment(AlignmentI al, String title)
877 String[] options = new String[] {
878 MessageManager.getString("action.no"),
879 MessageManager.getString("label.split_window"),
880 MessageManager.getString("label.new_window"), };
881 final String question = JvSwingUtils.wrapTooltip(true,
882 MessageManager.getString("label.open_split_window?"));
883 int response = JvOptionPane.showOptionDialog(Desktop.desktop, question,
884 MessageManager.getString("label.open_split_window"),
885 JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null,
886 options, options[0]);
888 if (response != 1 && response != 2)
892 final boolean openSplitPane = (response == 1);
893 final boolean openInNewWindow = (response == 2);
896 * Identify protein and dna alignments. Make a copy of this one if opening
897 * in a new split pane.
899 AlignmentI thisAlignment = openSplitPane ? new Alignment(getAlignment())
901 AlignmentI protein = al.isNucleotide() ? thisAlignment : al;
902 final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment;
905 * Map sequences. At least one should get mapped as we have already passed
906 * the test for 'mappability'. Any mappings made will be added to the
907 * protein alignment. Note creating dataset sequences on the new alignment
908 * is a pre-requisite for building mappings.
911 AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna);
914 * Create the AlignFrame for the added alignment. If it is protein, mappings
915 * are registered with StructureSelectionManager as a side-effect.
917 AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
918 AlignFrame.DEFAULT_HEIGHT);
919 newAlignFrame.setTitle(title);
920 newAlignFrame.statusBar.setText(MessageManager.formatMessage(
921 "label.successfully_loaded_file", new Object[] { title }));
923 // TODO if we want this (e.g. to enable reload of the alignment from file),
924 // we will need to add parameters to the stack.
925 // if (!protocol.equals(DataSourceType.PASTE))
927 // alignFrame.setFileName(file, format);
932 Desktop.addInternalFrame(newAlignFrame, title,
933 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
938 newAlignFrame.setMaximum(jalview.bin.Cache.getDefault(
939 "SHOW_FULLSCREEN", false));
940 } catch (java.beans.PropertyVetoException ex)
946 al.alignAs(thisAlignment);
947 protein = openSplitFrame(newAlignFrame, thisAlignment);
954 * Helper method to open a new SplitFrame holding linked dna and protein
957 * @param newAlignFrame
958 * containing a new alignment to be shown
960 * cdna/protein complement alignment to show in the other split half
961 * @return the protein alignment in the split frame
963 protected AlignmentI openSplitFrame(AlignFrame newAlignFrame,
964 AlignmentI complement)
967 * Make a new frame with a copy of the alignment we are adding to. If this
968 * is protein, the mappings to cDNA will be registered with
969 * StructureSelectionManager as a side-effect.
971 AlignFrame copyMe = new AlignFrame(complement,
972 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
973 copyMe.setTitle(getAlignPanel().alignFrame.getTitle());
975 AlignmentI al = newAlignFrame.viewport.getAlignment();
976 final AlignFrame proteinFrame = al.isNucleotide() ? copyMe
978 final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame : copyMe;
979 cdnaFrame.setVisible(true);
980 proteinFrame.setVisible(true);
981 String linkedTitle = MessageManager
982 .getString("label.linked_view_title");
985 * Open in split pane. DNA sequence above, protein below.
987 JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame);
988 Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1);
990 return proteinFrame.viewport.getAlignment();
993 public AnnotationColumnChooser getAnnotationColumnSelectionState()
995 return annotationColumnSelectionState;
998 public void setAnnotationColumnSelectionState(
999 AnnotationColumnChooser currentAnnotationColumnSelectionState)
1001 this.annotationColumnSelectionState = currentAnnotationColumnSelectionState;
1005 public void setIdWidth(int i)
1007 super.setIdWidth(i);
1008 AlignmentPanel ap = getAlignPanel();
1011 // modify GUI elements to reflect geometry change
1012 Dimension idw = getAlignPanel().getIdPanel().getIdCanvas()
1013 .getPreferredSize();
1015 getAlignPanel().getIdPanel().getIdCanvas().setPreferredSize(idw);
1019 public Rectangle getExplodedGeometry()
1021 return explodedGeometry;
1024 public void setExplodedGeometry(Rectangle explodedPosition)
1026 this.explodedGeometry = explodedPosition;
1029 public boolean isGatherViewsHere()
1031 return gatherViewsHere;
1034 public void setGatherViewsHere(boolean gatherViewsHere)
1036 this.gatherViewsHere = gatherViewsHere;
1040 * If this viewport has a (Protein/cDNA) complement, then scroll the
1041 * complementary alignment to match this one.
1043 public void scrollComplementaryAlignment()
1046 * Populate a SearchResults object with the mapped location to scroll to. If
1047 * there is no complement, or it is not following highlights, or no mapping
1048 * is found, the result will be empty.
1050 SearchResultsI sr = new SearchResults();
1051 int verticalOffset = findComplementScrollTarget(sr);
1054 // TODO would like next line without cast but needs more refactoring...
1055 final AlignmentPanel complementPanel = ((AlignViewport) getCodingComplement())
1057 complementPanel.setDontScrollComplement(true);
1058 complementPanel.scrollToCentre(sr, verticalOffset);
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());