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.UserColourScheme;
48 import jalview.structure.CommandListener;
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
74 SelectionSource, CommandListener
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 propertyValue = Cache.getProperty(colourProperty);
289 if (propertyValue == null)
291 // fall back on this property for backwards compatibility
292 propertyValue = Cache.getProperty(Preferences.DEFAULT_COLOUR);
294 if (propertyValue != null)
296 ColourSchemeI colourScheme = ColourSchemeProperty.getColourScheme(
297 alignment, propertyValue);
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);
315 * get the consensus sequence as displayed under the PID consensus annotation
318 * @return consensus sequence as a new sequence object
320 public SequenceI getConsensusSeq()
322 if (consensus == null)
324 updateConsensus(null);
326 if (consensus == null)
330 StringBuffer seqs = new StringBuffer();
331 for (int i = 0; i < consensus.annotations.length; i++)
333 if (consensus.annotations[i] != null)
335 if (consensus.annotations[i].description.charAt(0) == '[')
337 seqs.append(consensus.annotations[i].description.charAt(1));
341 seqs.append(consensus.annotations[i].displayCharacter);
346 SequenceI sq = new Sequence("Consensus", seqs.toString());
347 sq.setDescription("Percentage Identity Consensus "
348 + ((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
352 boolean validCharWidth;
355 * update view settings with the given font. You may need to call
356 * alignPanel.fontChanged to update the layout geometry
359 * when true, charWidth/height is set according to font mentrics
361 public void setFont(Font f, boolean setGrid)
365 Container c = new Container();
367 java.awt.FontMetrics fm = c.getFontMetrics(font);
368 int w = viewStyle.getCharWidth(), ww = fm.charWidth('M'), h = viewStyle
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);
388 if (residueShading != null)
390 residueShading.setConservationApplied(settingsForView
391 .isConservationColourSelected());
398 * @return DOCUMENT ME!
400 public Font getFont()
412 public void setAlignment(AlignmentI align)
414 replaceMappings(align);
415 super.setAlignment(align);
419 * Replace any codon mappings for this viewport with those for the given
424 public void replaceMappings(AlignmentI align)
428 * Deregister current mappings (if any)
430 deregisterMappings();
433 * Register new mappings (if any)
437 StructureSelectionManager ssm = StructureSelectionManager
438 .getStructureSelectionManager(Desktop.instance);
439 ssm.registerMappings(align.getCodonFrames());
443 * replace mappings on our alignment
445 if (alignment != null && align != null)
447 alignment.setCodonFrames(align.getCodonFrames());
451 protected void deregisterMappings()
453 AlignmentI al = getAlignment();
456 List<AlignedCodonFrame> mappings = al.getCodonFrames();
457 if (mappings != null)
459 StructureSelectionManager ssm = StructureSelectionManager
460 .getStructureSelectionManager(Desktop.instance);
461 for (AlignedCodonFrame acf : mappings)
463 if (noReferencesTo(acf))
465 ssm.deregisterMapping(acf);
475 * @return DOCUMENT ME!
478 public char getGapCharacter()
480 return getAlignment().getGapCharacter();
489 public void setGapCharacter(char gap)
491 if (getAlignment() != null)
493 getAlignment().setGapCharacter(gap);
503 public void setCurrentTree(NJTree tree)
511 * @return DOCUMENT ME!
513 public NJTree getCurrentTree()
519 * returns the visible column regions of the alignment
521 * @param selectedRegionOnly
522 * true to just return the contigs intersecting with the selected
526 public int[] getViewAsVisibleContigs(boolean selectedRegionOnly)
528 int[] viscontigs = null;
529 int start = 0, end = 0;
530 if (selectedRegionOnly && selectionGroup != null)
532 start = selectionGroup.getStartRes();
533 end = selectionGroup.getEndRes() + 1;
537 end = alignment.getWidth();
539 viscontigs = colSel.getVisibleContigs(start, end);
544 * get hash of undo and redo list for the alignment
546 * @return long[] { historyList.hashCode, redoList.hashCode };
548 public long[] getUndoRedoHash()
551 if (historyList == null || redoList == null)
553 return new long[] { -1, -1 };
555 return new long[] { historyList.hashCode(), this.redoList.hashCode() };
559 * test if a particular set of hashcodes are different to the hashcodes for
560 * the undo and redo list.
563 * the stored set of hashcodes as returned by getUndoRedoHash
564 * @return true if the hashcodes differ (ie the alignment has been edited) or
565 * the stored hashcode array differs in size
567 public boolean isUndoRedoHashModified(long[] undoredo)
569 if (undoredo == null)
573 long[] cstate = getUndoRedoHash();
574 if (cstate.length != undoredo.length)
579 for (int i = 0; i < cstate.length; i++)
581 if (cstate[i] != undoredo[i])
589 public boolean followSelection = true;
592 * @return true if view selection should always follow the selections
593 * broadcast by other selection sources
595 public boolean getFollowSelection()
597 return followSelection;
601 * Send the current selection to be broadcast to any selection listeners.
604 public void sendSelection()
606 jalview.structure.StructureSelectionManager
607 .getStructureSelectionManager(Desktop.instance).sendSelection(
608 new SequenceGroup(getSelectionGroup()),
609 new ColumnSelection(getColumnSelection()), this);
613 * return the alignPanel containing the given viewport. Use this to get the
614 * components currently handling the given viewport.
617 * @return null or an alignPanel guaranteed to have non-null alignFrame
620 public AlignmentPanel getAlignPanel()
622 AlignmentPanel[] aps = PaintRefresher.getAssociatedPanels(this
623 .getSequenceSetId());
624 for (int p = 0; aps != null && p < aps.length; p++)
626 if (aps[p].av == this)
634 public boolean getSortByTree()
639 public void setSortByTree(boolean sort)
645 * Returns the (Desktop) instance of the StructureSelectionManager
648 public StructureSelectionManager getStructureSelectionManager()
650 return StructureSelectionManager
651 .getStructureSelectionManager(Desktop.instance);
657 * @return an array of SequenceI arrays, one for each PDBEntry, listing which
658 * sequences in the alignment hold a reference to it
660 public SequenceI[][] collateForPDB(PDBEntry[] pdbEntries)
662 List<SequenceI[]> seqvectors = new ArrayList<SequenceI[]>();
663 for (PDBEntry pdb : pdbEntries)
665 List<SequenceI> choosenSeqs = new ArrayList<SequenceI>();
666 for (SequenceI sq : alignment.getSequences())
668 Vector<PDBEntry> pdbRefEntries = sq.getDatasetSequence()
670 if (pdbRefEntries == null)
674 for (PDBEntry pdbRefEntry : pdbRefEntries)
676 if (pdbRefEntry.getId().equals(pdb.getId()))
678 if (pdbRefEntry.getChainCode() != null
679 && pdb.getChainCode() != null)
681 if (pdbRefEntry.getChainCode().equalsIgnoreCase(
683 && !choosenSeqs.contains(sq))
691 if (!choosenSeqs.contains(sq))
702 .add(choosenSeqs.toArray(new SequenceI[choosenSeqs.size()]));
704 return seqvectors.toArray(new SequenceI[seqvectors.size()][]);
708 public boolean isNormaliseSequenceLogo()
710 return normaliseSequenceLogo;
713 public void setNormaliseSequenceLogo(boolean state)
715 normaliseSequenceLogo = state;
720 * @return true if alignment characters should be displayed
723 public boolean isValidCharWidth()
725 return validCharWidth;
728 private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<String, AutoCalcSetting>();
730 public AutoCalcSetting getCalcIdSettingsFor(String calcId)
732 return calcIdParams.get(calcId);
735 public void setCalcIdSettingsFor(String calcId, AutoCalcSetting settings,
738 calcIdParams.put(calcId, settings);
739 // TODO: create a restart list to trigger any calculations that need to be
740 // restarted after load
741 // calculator.getRegisteredWorkersOfClass(settings.getWorkerClass())
744 Cache.log.debug("trigger update for " + calcId);
749 * Method called when another alignment's edit (or possibly other) command is
752 * To allow for sequence mappings (e.g. protein to cDNA), we have to first
753 * 'unwind' the command on the source sequences (in simulation, not in fact),
754 * and then for each edit in turn:
756 * <li>compute the equivalent edit on the mapped sequences</li>
757 * <li>apply the mapped edit</li>
758 * <li>'apply' the source edit to the working copy of the source sequences</li>
766 public void mirrorCommand(CommandI command, boolean undo,
767 StructureSelectionManager ssm, VamsasSource source)
770 * Do nothing unless we are a 'complement' of the source. May replace this
771 * with direct calls not via SSM.
773 if (source instanceof AlignViewportI
774 && ((AlignViewportI) source).getCodingComplement() == this)
783 CommandI mappedCommand = ssm.mapCommand(command, undo, getAlignment(),
785 if (mappedCommand != null)
787 AlignmentI[] views = getAlignPanel().alignFrame.getViewAlignments();
788 mappedCommand.doCommand(views);
789 getAlignPanel().alignmentChanged();
794 * Add the sequences from the given alignment to this viewport. Optionally,
795 * may give the user the option to open a new frame, or split panel, with cDNA
796 * and protein linked.
801 public void addAlignment(AlignmentI toAdd, String title)
803 // TODO: promote to AlignViewportI? applet CutAndPasteTransfer is different
805 // JBPComment: title is a largely redundant parameter at the moment
806 // JBPComment: this really should be an 'insert/pre/append' controller
807 // JBPComment: but the DNA/Protein check makes it a bit more complex
809 // refactored from FileLoader / CutAndPasteTransfer / SequenceFetcher with
811 // TODO: create undo object for this JAL-1101
814 * Ensure datasets are created for the new alignment as
815 * mappings operate on dataset sequences
817 toAdd.setDataset(null);
820 * Check if any added sequence could be the object of a mapping or
821 * cross-reference; if so, make the mapping explicit
823 getAlignment().realiseMappings(toAdd.getSequences());
826 * If any cDNA/protein mappings exist or can be made between the alignments,
827 * offer to open a split frame with linked alignments
829 if (Cache.getDefault(Preferences.ENABLE_SPLIT_FRAME, true))
831 if (AlignmentUtils.isMappable(toAdd, getAlignment()))
833 if (openLinkedAlignment(toAdd, title))
841 * No mappings, or offer declined - add sequences to this alignment
843 // TODO: JAL-407 regardless of above - identical sequences (based on ID and
844 // provenance) should share the same dataset sequence
846 AlignmentI al = getAlignment();
847 String gap = String.valueOf(al.getGapCharacter());
848 for (int i = 0; i < toAdd.getHeight(); i++)
850 SequenceI seq = toAdd.getSequenceAt(i);
853 * - 'align' any mapped sequences as per existing
854 * e.g. cdna to genome, domain hit to protein sequence
855 * very experimental! (need a separate menu option for this)
856 * - only add mapped sequences ('select targets from a dataset')
858 if (true /*AlignmentUtils.alignSequenceAs(seq, al, gap, true, true)*/)
864 setEndSeq(getAlignment().getHeight());
865 firePropertyChange("alignment", null, getAlignment().getSequences());
869 * Show a dialog with the option to open and link (cDNA <-> protein) as a new
870 * alignment, either as a standalone alignment or in a split frame. Returns
871 * true if the new alignment was opened, false if not, because the user
872 * declined the offer.
877 protected boolean openLinkedAlignment(AlignmentI al, String title)
879 String[] options = new String[] {
880 MessageManager.getString("action.no"),
881 MessageManager.getString("label.split_window"),
882 MessageManager.getString("label.new_window"), };
883 final String question = JvSwingUtils.wrapTooltip(true,
884 MessageManager.getString("label.open_split_window?"));
885 int response = JvOptionPane.showOptionDialog(Desktop.desktop, question,
886 MessageManager.getString("label.open_split_window"),
887 JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null,
888 options, options[0]);
890 if (response != 1 && response != 2)
894 final boolean openSplitPane = (response == 1);
895 final boolean openInNewWindow = (response == 2);
898 * Identify protein and dna alignments. Make a copy of this one if opening
899 * in a new split pane.
901 AlignmentI thisAlignment = openSplitPane ? new Alignment(getAlignment())
903 AlignmentI protein = al.isNucleotide() ? thisAlignment : al;
904 final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment;
907 * Map sequences. At least one should get mapped as we have already passed
908 * the test for 'mappability'. Any mappings made will be added to the
909 * protein alignment. Note creating dataset sequences on the new alignment
910 * is a pre-requisite for building mappings.
913 AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna);
916 * Create the AlignFrame for the added alignment. If it is protein, mappings
917 * are registered with StructureSelectionManager as a side-effect.
919 AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
920 AlignFrame.DEFAULT_HEIGHT);
921 newAlignFrame.setTitle(title);
922 newAlignFrame.statusBar.setText(MessageManager.formatMessage(
923 "label.successfully_loaded_file", new Object[] { title }));
925 // TODO if we want this (e.g. to enable reload of the alignment from file),
926 // we will need to add parameters to the stack.
927 // if (!protocol.equals(DataSourceType.PASTE))
929 // alignFrame.setFileName(file, format);
934 Desktop.addInternalFrame(newAlignFrame, title,
935 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
940 newAlignFrame.setMaximum(jalview.bin.Cache.getDefault(
941 "SHOW_FULLSCREEN", false));
942 } catch (java.beans.PropertyVetoException ex)
948 al.alignAs(thisAlignment);
949 protein = openSplitFrame(newAlignFrame, thisAlignment);
956 * Helper method to open a new SplitFrame holding linked dna and protein
959 * @param newAlignFrame
960 * containing a new alignment to be shown
962 * cdna/protein complement alignment to show in the other split half
963 * @return the protein alignment in the split frame
965 protected AlignmentI openSplitFrame(AlignFrame newAlignFrame,
966 AlignmentI complement)
969 * Make a new frame with a copy of the alignment we are adding to. If this
970 * is protein, the mappings to cDNA will be registered with
971 * StructureSelectionManager as a side-effect.
973 AlignFrame copyMe = new AlignFrame(complement,
974 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
975 copyMe.setTitle(getAlignPanel().alignFrame.getTitle());
977 AlignmentI al = newAlignFrame.viewport.getAlignment();
978 final AlignFrame proteinFrame = al.isNucleotide() ? copyMe
980 final AlignFrame cdnaFrame = al.isNucleotide() ? newAlignFrame : copyMe;
981 cdnaFrame.setVisible(true);
982 proteinFrame.setVisible(true);
983 String linkedTitle = MessageManager
984 .getString("label.linked_view_title");
987 * Open in split pane. DNA sequence above, protein below.
989 JInternalFrame splitFrame = new SplitFrame(cdnaFrame, proteinFrame);
990 Desktop.addInternalFrame(splitFrame, linkedTitle, -1, -1);
992 return proteinFrame.viewport.getAlignment();
995 public AnnotationColumnChooser getAnnotationColumnSelectionState()
997 return annotationColumnSelectionState;
1000 public void setAnnotationColumnSelectionState(
1001 AnnotationColumnChooser currentAnnotationColumnSelectionState)
1003 this.annotationColumnSelectionState = currentAnnotationColumnSelectionState;
1007 public void setIdWidth(int i)
1009 super.setIdWidth(i);
1010 AlignmentPanel ap = getAlignPanel();
1013 // modify GUI elements to reflect geometry change
1014 Dimension idw = getAlignPanel().getIdPanel().getIdCanvas()
1015 .getPreferredSize();
1017 getAlignPanel().getIdPanel().getIdCanvas().setPreferredSize(idw);
1021 public Rectangle getExplodedGeometry()
1023 return explodedGeometry;
1026 public void setExplodedGeometry(Rectangle explodedPosition)
1028 this.explodedGeometry = explodedPosition;
1031 public boolean isGatherViewsHere()
1033 return gatherViewsHere;
1036 public void setGatherViewsHere(boolean gatherViewsHere)
1038 this.gatherViewsHere = gatherViewsHere;
1042 * If this viewport has a (Protein/cDNA) complement, then scroll the
1043 * complementary alignment to match this one.
1045 public void scrollComplementaryAlignment()
1048 * Populate a SearchResults object with the mapped location to scroll to. If
1049 * there is no complement, or it is not following highlights, or no mapping
1050 * is found, the result will be empty.
1052 SearchResultsI sr = new SearchResults();
1053 int verticalOffset = findComplementScrollTarget(sr);
1056 // TODO would like next line without cast but needs more refactoring...
1057 final AlignmentPanel complementPanel = ((AlignViewport) getCodingComplement())
1059 complementPanel.setDontScrollComplement(true);
1060 complementPanel.scrollToCentre(sr, verticalOffset);
1065 * Answers true if no alignment holds a reference to the given mapping
1070 protected boolean noReferencesTo(AlignedCodonFrame acf)
1072 AlignFrame[] frames = Desktop.getAlignFrames();
1077 for (AlignFrame af : frames)
1081 for (AlignmentViewPanel ap : af.getAlignPanels())
1083 AlignmentI al = ap.getAlignment();
1084 if (al != null && al.getCodonFrames().contains(acf))
1095 * Applies the supplied feature settings descriptor to currently known
1096 * features. This supports an 'initial configuration' of feature colouring
1097 * based on a preset or user favourite. This may then be modified in the usual
1098 * way using the Feature Settings dialogue.
1100 * @param featureSettings
1103 public void applyFeaturesStyle(FeatureSettingsModelI featureSettings)
1105 if (featureSettings == null)
1110 FeatureRenderer fr = getAlignPanel().getSeqPanel().seqCanvas
1111 .getFeatureRenderer();
1112 fr.findAllFeatures(true);
1113 List<String> renderOrder = fr.getRenderOrder();
1114 FeaturesDisplayedI displayed = fr.getFeaturesDisplayed();
1116 // TODO this clears displayed.featuresRegistered - do we care?
1119 * set feature colour if specified by feature settings
1120 * set visibility of all features
1122 for (String type : renderOrder)
1124 FeatureColourI preferredColour = featureSettings
1125 .getFeatureColour(type);
1126 if (preferredColour != null)
1128 fr.setColour(type, preferredColour);
1130 if (featureSettings.isFeatureDisplayed(type))
1132 displayed.setVisible(type);
1137 * set visibility of feature groups
1139 for (String group : fr.getFeatureGroups())
1141 fr.setGroupVisibility(group, featureSettings.isGroupDisplayed(group));
1145 * order the features
1147 if (featureSettings.optimiseOrder())
1149 // TODO not supported (yet?)
1153 fr.orderFeatures(featureSettings);
1155 fr.setTransparency(featureSettings.getTransparency());