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.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)
127 sequenceSetID = seqsetid;
129 // TODO remove these once 2.4.VAMSAS release finished
130 if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null)
132 Cache.log.debug("Setting viewport's sequence set id : "
135 if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null)
137 Cache.log.debug("Setting viewport's view id : " + viewId);
144 * Create a new AlignViewport with hidden regions
148 * @param hiddenColumns
151 public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns)
154 if (hiddenColumns != null)
156 colSel = hiddenColumns;
162 * New viewport with hidden columns and an existing sequence set id
165 * @param hiddenColumns
169 public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns,
172 this(al, hiddenColumns, seqsetid, null);
176 * New viewport with hidden columns and an existing sequence set id and viewid
179 * @param hiddenColumns
185 public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns,
186 String seqsetid, String viewid)
188 sequenceSetID = seqsetid;
190 // TODO remove these once 2.4.VAMSAS release finished
191 if (Cache.log != null && Cache.log.isDebugEnabled() && seqsetid != null)
193 Cache.log.debug("Setting viewport's sequence set id : "
196 if (Cache.log != null && Cache.log.isDebugEnabled() && viewId != null)
198 Cache.log.debug("Setting viewport's view id : " + viewId);
201 if (hiddenColumns != null)
203 colSel = hiddenColumns;
209 * Apply any settings saved in user preferences
211 private void applyViewProperties()
213 antiAlias = Cache.getDefault("ANTI_ALIAS", false);
215 viewStyle.setShowJVSuffix(Cache.getDefault("SHOW_JVSUFFIX", true));
216 setShowAnnotation(Cache.getDefault("SHOW_ANNOTATIONS", true));
218 setRightAlignIds(Cache.getDefault("RIGHT_ALIGN_IDS", false));
219 setCentreColumnLabels(Cache.getDefault("CENTRE_COLUMN_LABELS", false));
220 autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
222 setPadGaps(Cache.getDefault("PAD_GAPS", true));
223 setShowNPFeats(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true));
224 setShowDBRefs(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true));
225 viewStyle.setSeqNameItalics(Cache.getDefault("ID_ITALICS", true));
226 viewStyle.setWrapAlignment(Cache.getDefault("WRAP_ALIGNMENT", false));
227 viewStyle.setShowUnconserved(Cache
228 .getDefault("SHOW_UNCONSERVED", false));
229 sortByTree = Cache.getDefault("SORT_BY_TREE", false);
230 followSelection = Cache.getDefault("FOLLOW_SELECTIONS", true);
231 sortAnnotationsBy = SequenceAnnotationOrder.valueOf(Cache.getDefault(
232 Preferences.SORT_ANNOTATIONS,
233 SequenceAnnotationOrder.NONE.name()));
234 showAutocalculatedAbove = Cache.getDefault(
235 Preferences.SHOW_AUTOCALC_ABOVE, false);
236 viewStyle.setScaleProteinAsCdna(Cache.getDefault(
237 Preferences.SCALE_PROTEIN_TO_CDNA, true));
242 ranges = new ViewportRanges(this.alignment);
243 applyViewProperties();
245 String fontName = Cache.getDefault("FONT_NAME", "SansSerif");
246 String fontStyle = Cache.getDefault("FONT_STYLE", Font.PLAIN + "");
247 String fontSize = Cache.getDefault("FONT_SIZE", "10");
251 if (fontStyle.equals("bold"))
255 else if (fontStyle.equals("italic"))
260 setFont(new Font(fontName, style, Integer.parseInt(fontSize)), true);
263 .setGapCharacter(Cache.getDefault("GAP_SYMBOL", "-").charAt(0));
265 // We must set conservation and consensus before setting colour,
266 // as Blosum and Clustal require this to be done
267 if (hconsensus == null && !isDataset)
269 if (!alignment.isNucleotide())
271 showConservation = Cache.getDefault("SHOW_CONSERVATION", true);
272 showQuality = Cache.getDefault("SHOW_QUALITY", true);
273 showGroupConservation = Cache.getDefault("SHOW_GROUP_CONSERVATION",
276 showConsensusHistogram = Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM",
278 showSequenceLogo = Cache.getDefault("SHOW_CONSENSUS_LOGO", false);
279 normaliseSequenceLogo = Cache.getDefault("NORMALISE_CONSENSUS_LOGO",
281 showGroupConsensus = Cache.getDefault("SHOW_GROUP_CONSENSUS", false);
282 showConsensus = Cache.getDefault("SHOW_IDENTITY", true);
284 showOccupancy = Cache.getDefault(Preferences.SHOW_OCCUPANCY, true);
286 initAutoAnnotation();
287 String colourProperty = alignment.isNucleotide() ? Preferences.DEFAULT_COLOUR_NUC
288 : Preferences.DEFAULT_COLOUR_PROT;
289 String schemeName = Cache.getProperty(colourProperty);
290 if (schemeName == null)
292 // only DEFAULT_COLOUR available in Jalview before 2.9
293 schemeName = Cache.getDefault(Preferences.DEFAULT_COLOUR,
294 ResidueColourScheme.NONE);
296 ColourSchemeI colourScheme = ColourSchemeProperty.getColourScheme(
297 alignment, schemeName);
298 residueShading = new ResidueShader(colourScheme);
300 if (colourScheme instanceof UserColourScheme)
302 residueShading = new ResidueShader(
303 UserDefinedColours.loadDefaultColours());
304 residueShading.setThreshold(0, isIgnoreGapsConsensus());
307 if (residueShading != null)
309 residueShading.setConsensus(hconsensus);
314 * get the consensus sequence as displayed under the PID consensus annotation
317 * @return consensus sequence as a new sequence object
319 public SequenceI getConsensusSeq()
321 if (consensus == null)
323 updateConsensus(null);
325 if (consensus == null)
329 StringBuffer seqs = new StringBuffer();
330 for (int i = 0; i < consensus.annotations.length; i++)
332 if (consensus.annotations[i] != null)
334 if (consensus.annotations[i].description.charAt(0) == '[')
336 seqs.append(consensus.annotations[i].description.charAt(1));
340 seqs.append(consensus.annotations[i].displayCharacter);
345 SequenceI sq = new Sequence("Consensus", seqs.toString());
346 sq.setDescription("Percentage Identity Consensus "
347 + ((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
351 boolean validCharWidth;
357 public void setFont(Font f, boolean setGrid)
361 Container c = new Container();
365 FontMetrics fm = c.getFontMetrics(font);
366 int ww = fm.charWidth('M');
367 setCharHeight(fm.getHeight());
370 viewStyle.setFontName(font.getName());
371 viewStyle.setFontStyle(font.getStyle());
372 viewStyle.setFontSize(font.getSize());
374 validCharWidth = true;
378 public void setViewStyle(ViewStyleI settingsForView)
380 super.setViewStyle(settingsForView);
381 setFont(new Font(viewStyle.getFontName(), viewStyle.getFontStyle(),
382 viewStyle.getFontSize()), false);
388 * @return DOCUMENT ME!
390 public Font getFont()
402 public void setAlignment(AlignmentI align)
404 replaceMappings(align);
405 super.setAlignment(align);
409 * Replace any codon mappings for this viewport with those for the given
414 public void replaceMappings(AlignmentI align)
418 * Deregister current mappings (if any)
420 deregisterMappings();
423 * Register new mappings (if any)
427 StructureSelectionManager ssm = StructureSelectionManager
428 .getStructureSelectionManager(Desktop.instance);
429 ssm.registerMappings(align.getCodonFrames());
433 * replace mappings on our alignment
435 if (alignment != null && align != null)
437 alignment.setCodonFrames(align.getCodonFrames());
441 protected void deregisterMappings()
443 AlignmentI al = getAlignment();
446 List<AlignedCodonFrame> mappings = al.getCodonFrames();
447 if (mappings != null)
449 StructureSelectionManager ssm = StructureSelectionManager
450 .getStructureSelectionManager(Desktop.instance);
451 for (AlignedCodonFrame acf : mappings)
453 if (noReferencesTo(acf))
455 ssm.deregisterMapping(acf);
465 * @return DOCUMENT ME!
468 public char getGapCharacter()
470 return getAlignment().getGapCharacter();
479 public void setGapCharacter(char gap)
481 if (getAlignment() != null)
483 getAlignment().setGapCharacter(gap);
493 public void setCurrentTree(TreeModel tree)
501 * @return DOCUMENT ME!
503 public TreeModel getCurrentTree()
509 * returns the visible column regions of the alignment
511 * @param selectedRegionOnly
512 * true to just return the contigs intersecting with the selected
516 public int[] getViewAsVisibleContigs(boolean selectedRegionOnly)
518 int[] viscontigs = null;
519 int start = 0, end = 0;
520 if (selectedRegionOnly && selectionGroup != null)
522 start = selectionGroup.getStartRes();
523 end = selectionGroup.getEndRes() + 1;
527 end = alignment.getWidth();
529 viscontigs = colSel.getVisibleContigs(start, end);
534 * get hash of undo and redo list for the alignment
536 * @return long[] { historyList.hashCode, redoList.hashCode };
538 public long[] getUndoRedoHash()
541 if (historyList == null || redoList == null)
543 return new long[] { -1, -1 };
545 return new long[] { historyList.hashCode(), this.redoList.hashCode() };
549 * test if a particular set of hashcodes are different to the hashcodes for
550 * the undo and redo list.
553 * the stored set of hashcodes as returned by getUndoRedoHash
554 * @return true if the hashcodes differ (ie the alignment has been edited) or
555 * the stored hashcode array differs in size
557 public boolean isUndoRedoHashModified(long[] undoredo)
559 if (undoredo == null)
563 long[] cstate = getUndoRedoHash();
564 if (cstate.length != undoredo.length)
569 for (int i = 0; i < cstate.length; i++)
571 if (cstate[i] != undoredo[i])
579 public boolean followSelection = true;
582 * @return true if view selection should always follow the selections
583 * broadcast by other selection sources
585 public boolean getFollowSelection()
587 return followSelection;
591 * Send the current selection to be broadcast to any selection listeners.
594 public void sendSelection()
596 jalview.structure.StructureSelectionManager
597 .getStructureSelectionManager(Desktop.instance).sendSelection(
598 new SequenceGroup(getSelectionGroup()),
599 new ColumnSelection(getColumnSelection()), this);
603 * return the alignPanel containing the given viewport. Use this to get the
604 * components currently handling the given viewport.
607 * @return null or an alignPanel guaranteed to have non-null alignFrame
610 public AlignmentPanel getAlignPanel()
612 AlignmentPanel[] aps = PaintRefresher.getAssociatedPanels(this
613 .getSequenceSetId());
614 for (int p = 0; aps != null && p < aps.length; p++)
616 if (aps[p].av == this)
624 public boolean getSortByTree()
629 public void setSortByTree(boolean sort)
635 * Returns the (Desktop) instance of the StructureSelectionManager
638 public StructureSelectionManager getStructureSelectionManager()
640 return StructureSelectionManager
641 .getStructureSelectionManager(Desktop.instance);
647 * @return an array of SequenceI arrays, one for each PDBEntry, listing which
648 * sequences in the alignment hold a reference to it
650 public SequenceI[][] collateForPDB(PDBEntry[] pdbEntries)
652 List<SequenceI[]> seqvectors = new ArrayList<SequenceI[]>();
653 for (PDBEntry pdb : pdbEntries)
655 List<SequenceI> choosenSeqs = new ArrayList<SequenceI>();
656 for (SequenceI sq : alignment.getSequences())
658 Vector<PDBEntry> pdbRefEntries = sq.getDatasetSequence()
660 if (pdbRefEntries == null)
664 for (PDBEntry pdbRefEntry : pdbRefEntries)
666 if (pdbRefEntry.getId().equals(pdb.getId()))
668 if (pdbRefEntry.getChainCode() != null
669 && pdb.getChainCode() != null)
671 if (pdbRefEntry.getChainCode().equalsIgnoreCase(
673 && !choosenSeqs.contains(sq))
681 if (!choosenSeqs.contains(sq))
692 .add(choosenSeqs.toArray(new SequenceI[choosenSeqs.size()]));
694 return seqvectors.toArray(new SequenceI[seqvectors.size()][]);
698 public boolean isNormaliseSequenceLogo()
700 return normaliseSequenceLogo;
703 public void setNormaliseSequenceLogo(boolean state)
705 normaliseSequenceLogo = state;
710 * @return true if alignment characters should be displayed
713 public boolean isValidCharWidth()
715 return validCharWidth;
718 private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<String, AutoCalcSetting>();
720 public AutoCalcSetting getCalcIdSettingsFor(String calcId)
722 return calcIdParams.get(calcId);
725 public void setCalcIdSettingsFor(String calcId, AutoCalcSetting settings,
728 calcIdParams.put(calcId, settings);
729 // TODO: create a restart list to trigger any calculations that need to be
730 // restarted after load
731 // calculator.getRegisteredWorkersOfClass(settings.getWorkerClass())
734 Cache.log.debug("trigger update for " + calcId);
739 * Method called when another alignment's edit (or possibly other) command is
742 * To allow for sequence mappings (e.g. protein to cDNA), we have to first
743 * 'unwind' the command on the source sequences (in simulation, not in fact),
744 * and then for each edit in turn:
746 * <li>compute the equivalent edit on the mapped sequences</li>
747 * <li>apply the mapped edit</li>
748 * <li>'apply' the source edit to the working copy of the source sequences</li>
756 public void mirrorCommand(CommandI command, boolean undo,
757 StructureSelectionManager ssm, VamsasSource source)
760 * Do nothing unless we are a 'complement' of the source. May replace this
761 * with direct calls not via SSM.
763 if (source instanceof AlignViewportI
764 && ((AlignViewportI) source).getCodingComplement() == this)
773 CommandI mappedCommand = ssm.mapCommand(command, undo, getAlignment(),
775 if (mappedCommand != null)
777 AlignmentI[] views = getAlignPanel().alignFrame.getViewAlignments();
778 mappedCommand.doCommand(views);
779 getAlignPanel().alignmentChanged();
784 * Add the sequences from the given alignment to this viewport. Optionally,
785 * may give the user the option to open a new frame, or split panel, with cDNA
786 * and protein linked.
791 public void addAlignment(AlignmentI toAdd, String title)
793 // TODO: promote to AlignViewportI? applet CutAndPasteTransfer is different
795 // JBPComment: title is a largely redundant parameter at the moment
796 // JBPComment: this really should be an 'insert/pre/append' controller
797 // JBPComment: but the DNA/Protein check makes it a bit more complex
799 // refactored from FileLoader / CutAndPasteTransfer / SequenceFetcher with
801 // TODO: create undo object for this JAL-1101
804 * Ensure datasets are created for the new alignment as
805 * mappings operate on dataset sequences
807 toAdd.setDataset(null);
810 * Check if any added sequence could be the object of a mapping or
811 * cross-reference; if so, make the mapping explicit
813 getAlignment().realiseMappings(toAdd.getSequences());
816 * If any cDNA/protein mappings exist or can be made between the alignments,
817 * offer to open a split frame with linked alignments
819 if (Cache.getDefault(Preferences.ENABLE_SPLIT_FRAME, true))
821 if (AlignmentUtils.isMappable(toAdd, getAlignment()))
823 if (openLinkedAlignment(toAdd, title))
831 * No mappings, or offer declined - add sequences to this alignment
833 // TODO: JAL-407 regardless of above - identical sequences (based on ID and
834 // provenance) should share the same dataset sequence
836 AlignmentI al = getAlignment();
837 String gap = String.valueOf(al.getGapCharacter());
838 for (int i = 0; i < toAdd.getHeight(); i++)
840 SequenceI seq = toAdd.getSequenceAt(i);
843 * - 'align' any mapped sequences as per existing
844 * e.g. cdna to genome, domain hit to protein sequence
845 * very experimental! (need a separate menu option for this)
846 * - only add mapped sequences ('select targets from a dataset')
848 if (true /*AlignmentUtils.alignSequenceAs(seq, al, gap, true, true)*/)
854 ranges.setEndSeq(getAlignment().getHeight());
855 firePropertyChange("alignment", null, getAlignment().getSequences());
859 * Show a dialog with the option to open and link (cDNA <-> protein) as a new
860 * alignment, either as a standalone alignment or in a split frame. Returns
861 * true if the new alignment was opened, false if not, because the user
862 * declined the offer.
867 protected boolean openLinkedAlignment(AlignmentI al, String title)
869 String[] options = new String[] {
870 MessageManager.getString("action.no"),
871 MessageManager.getString("label.split_window"),
872 MessageManager.getString("label.new_window"), };
873 final String question = JvSwingUtils.wrapTooltip(true,
874 MessageManager.getString("label.open_split_window?"));
875 int response = JvOptionPane.showOptionDialog(Desktop.desktop, question,
876 MessageManager.getString("label.open_split_window"),
877 JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null,
878 options, options[0]);
880 if (response != 1 && response != 2)
884 final boolean openSplitPane = (response == 1);
885 final boolean openInNewWindow = (response == 2);
888 * Identify protein and dna alignments. Make a copy of this one if opening
889 * in a new split pane.
891 AlignmentI thisAlignment = openSplitPane ? new Alignment(getAlignment())
893 AlignmentI protein = al.isNucleotide() ? thisAlignment : al;
894 final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment;
897 * Map sequences. At least one should get mapped as we have already passed
898 * the test for 'mappability'. Any mappings made will be added to the
899 * protein alignment. Note creating dataset sequences on the new alignment
900 * is a pre-requisite for building mappings.
903 AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna);
906 * Create the AlignFrame for the added alignment. If it is protein, mappings
907 * are registered with StructureSelectionManager as a side-effect.
909 AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
910 AlignFrame.DEFAULT_HEIGHT);
911 newAlignFrame.setTitle(title);
912 newAlignFrame.statusBar.setText(MessageManager.formatMessage(
913 "label.successfully_loaded_file", new Object[] { title }));
915 // TODO if we want this (e.g. to enable reload of the alignment from file),
916 // we will need to add parameters to the stack.
917 // if (!protocol.equals(DataSourceType.PASTE))
919 // alignFrame.setFileName(file, format);
924 Desktop.addInternalFrame(newAlignFrame, title,
925 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
930 newAlignFrame.setMaximum(jalview.bin.Cache.getDefault(
931 "SHOW_FULLSCREEN", false));
932 } catch (java.beans.PropertyVetoException ex)
938 al.alignAs(thisAlignment);
939 protein = openSplitFrame(newAlignFrame, thisAlignment);
946 * Helper method to open a new SplitFrame holding linked dna and protein
949 * @param newAlignFrame
950 * containing a new alignment to be shown
952 * cdna/protein complement alignment to show in the other split half
953 * @return the protein alignment in the split frame
955 protected AlignmentI openSplitFrame(AlignFrame newAlignFrame,
956 AlignmentI complement)
959 * Make a new frame with a copy of the alignment we are adding to. If this
960 * is protein, the mappings to cDNA will be registered with
961 * StructureSelectionManager as a side-effect.
963 AlignFrame copyMe = new AlignFrame(complement,
964 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
965 copyMe.setTitle(getAlignPanel().alignFrame.getTitle());
967 AlignmentI al = newAlignFrame.viewport.getAlignment();
968 final AlignFrame proteinFrame = al.isNucleotide() ? copyMe
970 final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame : copyMe;
971 cdnaFrame.setVisible(true);
972 proteinFrame.setVisible(true);
973 String linkedTitle = MessageManager
974 .getString("label.linked_view_title");
977 * Open in split pane. DNA sequence above, protein below.
979 JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame);
980 Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1);
982 return proteinFrame.viewport.getAlignment();
985 public AnnotationColumnChooser getAnnotationColumnSelectionState()
987 return annotationColumnSelectionState;
990 public void setAnnotationColumnSelectionState(
991 AnnotationColumnChooser currentAnnotationColumnSelectionState)
993 this.annotationColumnSelectionState = currentAnnotationColumnSelectionState;
997 public void setIdWidth(int i)
1000 AlignmentPanel ap = getAlignPanel();
1003 // modify GUI elements to reflect geometry change
1004 Dimension idw = getAlignPanel().getIdPanel().getIdCanvas()
1005 .getPreferredSize();
1007 getAlignPanel().getIdPanel().getIdCanvas().setPreferredSize(idw);
1011 public Rectangle getExplodedGeometry()
1013 return explodedGeometry;
1016 public void setExplodedGeometry(Rectangle explodedPosition)
1018 this.explodedGeometry = explodedPosition;
1021 public boolean isGatherViewsHere()
1023 return gatherViewsHere;
1026 public void setGatherViewsHere(boolean gatherViewsHere)
1028 this.gatherViewsHere = gatherViewsHere;
1032 * If this viewport has a (Protein/cDNA) complement, then scroll the
1033 * complementary alignment to match this one.
1035 public void scrollComplementaryAlignment()
1038 * Populate a SearchResults object with the mapped location to scroll to. If
1039 * there is no complement, or it is not following highlights, or no mapping
1040 * is found, the result will be empty.
1042 SearchResultsI sr = new SearchResults();
1043 int verticalOffset = findComplementScrollTarget(sr);
1046 // TODO would like next line without cast but needs more refactoring...
1047 final AlignmentPanel complementPanel = ((AlignViewport) getCodingComplement())
1049 complementPanel.setDontScrollComplement(true);
1050 complementPanel.scrollToCentre(sr, verticalOffset);
1055 * Answers true if no alignment holds a reference to the given mapping
1060 protected boolean noReferencesTo(AlignedCodonFrame acf)
1062 AlignFrame[] frames = Desktop.getAlignFrames();
1067 for (AlignFrame af : frames)
1071 for (AlignmentViewPanel ap : af.getAlignPanels())
1073 AlignmentI al = ap.getAlignment();
1074 if (al != null && al.getCodonFrames().contains(acf))
1085 * Applies the supplied feature settings descriptor to currently known
1086 * features. This supports an 'initial configuration' of feature colouring
1087 * based on a preset or user favourite. This may then be modified in the usual
1088 * way using the Feature Settings dialogue.
1090 * @param featureSettings
1093 public void applyFeaturesStyle(FeatureSettingsModelI featureSettings)
1095 if (featureSettings == null)
1100 FeatureRenderer fr = getAlignPanel().getSeqPanel().seqCanvas
1101 .getFeatureRenderer();
1102 fr.findAllFeatures(true);
1103 List<String> renderOrder = fr.getRenderOrder();
1104 FeaturesDisplayedI displayed = fr.getFeaturesDisplayed();
1106 // TODO this clears displayed.featuresRegistered - do we care?
1109 * set feature colour if specified by feature settings
1110 * set visibility of all features
1112 for (String type : renderOrder)
1114 FeatureColourI preferredColour = featureSettings
1115 .getFeatureColour(type);
1116 if (preferredColour != null)
1118 fr.setColour(type, preferredColour);
1120 if (featureSettings.isFeatureDisplayed(type))
1122 displayed.setVisible(type);
1127 * set visibility of feature groups
1129 for (String group : fr.getFeatureGroups())
1131 fr.setGroupVisibility(group, featureSettings.isGroupDisplayed(group));
1135 * order the features
1137 if (featureSettings.optimiseOrder())
1139 // TODO not supported (yet?)
1143 fr.orderFeatures(featureSettings);
1145 fr.setTransparency(featureSettings.getTransparency());