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.api.AlignViewportI;
24 import jalview.bin.Cache;
25 import jalview.commands.EditCommand;
26 import jalview.commands.EditCommand.Action;
27 import jalview.commands.EditCommand.Edit;
28 import jalview.datamodel.AlignmentI;
29 import jalview.datamodel.ColumnSelection;
30 import jalview.datamodel.HiddenColumns;
31 import jalview.datamodel.SearchResultMatchI;
32 import jalview.datamodel.SearchResults;
33 import jalview.datamodel.SearchResultsI;
34 import jalview.datamodel.Sequence;
35 import jalview.datamodel.SequenceFeature;
36 import jalview.datamodel.SequenceGroup;
37 import jalview.datamodel.SequenceI;
38 import jalview.io.SequenceAnnotationReport;
39 import jalview.renderer.ResidueShaderI;
40 import jalview.schemes.ResidueProperties;
41 import jalview.structure.SelectionListener;
42 import jalview.structure.SelectionSource;
43 import jalview.structure.SequenceListener;
44 import jalview.structure.StructureSelectionManager;
45 import jalview.structure.VamsasSource;
46 import jalview.util.Comparison;
47 import jalview.util.MappingUtils;
48 import jalview.util.MessageManager;
49 import jalview.util.Platform;
50 import jalview.viewmodel.AlignmentViewport;
51 import jalview.viewmodel.ViewportRanges;
53 import java.awt.BorderLayout;
54 import java.awt.Color;
56 import java.awt.FontMetrics;
57 import java.awt.Point;
58 import java.awt.event.MouseEvent;
59 import java.awt.event.MouseListener;
60 import java.awt.event.MouseMotionListener;
61 import java.awt.event.MouseWheelEvent;
62 import java.awt.event.MouseWheelListener;
63 import java.util.Collections;
64 import java.util.List;
66 import javax.swing.JLabel;
67 import javax.swing.JPanel;
68 import javax.swing.JToolTip;
69 import javax.swing.SwingUtilities;
70 import javax.swing.ToolTipManager;
76 * @version $Revision: 1.130 $
78 public class SeqPanel extends JPanel
79 implements MouseListener, MouseMotionListener, MouseWheelListener,
80 SequenceListener, SelectionListener
82 private static final int MAX_TOOLTIP_LENGTH = 300;
84 public SeqCanvas seqCanvas;
86 public AlignmentPanel ap;
89 * last column position for mouseMoved event
91 private int lastMouseColumn;
94 * last sequence offset for mouseMoved event
96 private int lastMouseSeq;
98 protected int lastres;
100 protected int startseq;
102 protected AlignViewport av;
104 ScrollThread scrollThread = null;
106 boolean mouseDragging = false;
108 boolean editingSeqs = false;
110 boolean groupEditing = false;
112 // ////////////////////////////////////////
113 // ///Everything below this is for defining the boundary of the rubberband
114 // ////////////////////////////////////////
117 boolean changeEndSeq = false;
119 boolean changeStartSeq = false;
121 boolean changeEndRes = false;
123 boolean changeStartRes = false;
125 SequenceGroup stretchGroup = null;
127 boolean remove = false;
129 Point lastMousePress;
131 boolean mouseWheelPressed = false;
133 StringBuffer keyboardNo1;
135 StringBuffer keyboardNo2;
137 java.net.URL linkImageURL;
139 private final SequenceAnnotationReport seqARep;
141 StringBuilder tooltipText = new StringBuilder();
145 EditCommand editCommand;
147 StructureSelectionManager ssm;
149 SearchResultsI lastSearchResults;
152 * Creates a new SeqPanel object
157 public SeqPanel(AlignViewport viewport, AlignmentPanel alignPanel)
159 linkImageURL = getClass().getResource("/images/link.gif");
160 seqARep = new SequenceAnnotationReport(linkImageURL.toString());
161 ToolTipManager.sharedInstance().registerComponent(this);
162 ToolTipManager.sharedInstance().setInitialDelay(0);
163 ToolTipManager.sharedInstance().setDismissDelay(10000);
167 setBackground(Color.white);
169 seqCanvas = new SeqCanvas(alignPanel);
170 setLayout(new BorderLayout());
171 add(seqCanvas, BorderLayout.CENTER);
173 this.ap = alignPanel;
175 if (!viewport.isDataset())
177 addMouseMotionListener(this);
178 addMouseListener(this);
179 addMouseWheelListener(this);
180 ssm = viewport.getStructureSelectionManager();
181 ssm.addStructureViewerListener(this);
182 ssm.addSelectionListener(this);
185 lastMouseColumn = -1;
189 int startWrapBlock = -1;
191 int wrappedBlock = -1;
194 * Returns the aligned sequence position (base 0) at the mouse position, or
195 * the closest visible one
200 int findColumn(MouseEvent evt)
205 int startRes = av.getRanges().getStartRes();
206 if (av.getWrapAlignment())
209 int hgap = av.getCharHeight();
210 if (av.getScaleAboveWrapped())
212 hgap += av.getCharHeight();
215 int cHeight = av.getAlignment().getHeight() * av.getCharHeight()
216 + hgap + seqCanvas.getAnnotationHeight();
219 y = Math.max(0, y - hgap);
220 x = Math.max(0, x - seqCanvas.getLabelWidthWest());
222 int cwidth = seqCanvas.getWrappedCanvasWidth(this.getWidth());
228 wrappedBlock = y / cHeight;
229 wrappedBlock += startRes / cwidth;
230 // allow for wrapped view scrolled right (possible from Overview)
231 int startOffset = startRes % cwidth;
232 res = wrappedBlock * cwidth + startOffset
233 + +Math.min(cwidth - 1, x / av.getCharWidth());
237 if (x > seqCanvas.getX() + seqCanvas.getWidth())
239 // make sure we calculate relative to visible alignment, rather than
241 x = seqCanvas.getX() + seqCanvas.getWidth();
243 res = (x / av.getCharWidth()) + startRes;
244 if (res > av.getRanges().getEndRes())
247 res = av.getRanges().getEndRes();
251 if (av.hasHiddenColumns())
253 res = av.getAlignment().getHiddenColumns()
254 .visibleToAbsoluteColumn(res);
261 int findSeq(MouseEvent evt)
266 if (av.getWrapAlignment())
268 int hgap = av.getCharHeight();
269 if (av.getScaleAboveWrapped())
271 hgap += av.getCharHeight();
274 int cHeight = av.getAlignment().getHeight() * av.getCharHeight()
275 + hgap + seqCanvas.getAnnotationHeight();
279 seq = Math.min((y % cHeight) / av.getCharHeight(),
280 av.getAlignment().getHeight() - 1);
285 (y / av.getCharHeight()) + av.getRanges().getStartSeq(),
286 av.getAlignment().getHeight() - 1);
293 * When all of a sequence of edits are complete, put the resulting edit list
294 * on the history stack (undo list), and reset flags for editing in progress.
300 if (editCommand != null && editCommand.getSize() > 0)
302 ap.alignFrame.addHistoryItem(editCommand);
303 av.firePropertyChange("alignment", null,
304 av.getAlignment().getSequences());
309 * Tidy up come what may...
314 groupEditing = false;
323 seqCanvas.cursorY = getKeyboardNo1() - 1;
324 scrollToVisible(true);
327 void setCursorColumn()
329 seqCanvas.cursorX = getKeyboardNo1() - 1;
330 scrollToVisible(true);
333 void setCursorRowAndColumn()
335 if (keyboardNo2 == null)
337 keyboardNo2 = new StringBuffer();
341 seqCanvas.cursorX = getKeyboardNo1() - 1;
342 seqCanvas.cursorY = getKeyboardNo2() - 1;
343 scrollToVisible(true);
347 void setCursorPosition()
349 SequenceI sequence = av.getAlignment().getSequenceAt(seqCanvas.cursorY);
351 seqCanvas.cursorX = sequence.findIndex(getKeyboardNo1()) - 1;
352 scrollToVisible(true);
355 void moveCursor(int dx, int dy)
357 seqCanvas.cursorX += dx;
358 seqCanvas.cursorY += dy;
360 HiddenColumns hidden = av.getAlignment().getHiddenColumns();
362 if (av.hasHiddenColumns() && !hidden.isVisible(seqCanvas.cursorX))
364 int original = seqCanvas.cursorX - dx;
365 int maxWidth = av.getAlignment().getWidth();
367 if (!hidden.isVisible(seqCanvas.cursorX))
369 int visx = hidden.absoluteToVisibleColumn(seqCanvas.cursorX - dx);
370 int[] region = hidden.getRegionWithEdgeAtRes(visx);
372 if (region != null) // just in case
377 seqCanvas.cursorX = region[1] + 1;
382 seqCanvas.cursorX = region[0] - 1;
385 seqCanvas.cursorX = (seqCanvas.cursorX < 0) ? 0 : seqCanvas.cursorX;
388 if (seqCanvas.cursorX >= maxWidth
389 || !hidden.isVisible(seqCanvas.cursorX))
391 seqCanvas.cursorX = original;
395 scrollToVisible(false);
399 * Scroll to make the cursor visible in the viewport.
402 * just jump to the location rather than scrolling
404 void scrollToVisible(boolean jump)
406 if (seqCanvas.cursorX < 0)
408 seqCanvas.cursorX = 0;
410 else if (seqCanvas.cursorX > av.getAlignment().getWidth() - 1)
412 seqCanvas.cursorX = av.getAlignment().getWidth() - 1;
415 if (seqCanvas.cursorY < 0)
417 seqCanvas.cursorY = 0;
419 else if (seqCanvas.cursorY > av.getAlignment().getHeight() - 1)
421 seqCanvas.cursorY = av.getAlignment().getHeight() - 1;
426 boolean repaintNeeded = true;
429 // only need to repaint if the viewport did not move, as otherwise it will
431 repaintNeeded = !av.getRanges().setViewportLocation(seqCanvas.cursorX,
436 if (av.getWrapAlignment())
438 // scrollToWrappedVisible expects x-value to have hidden cols subtracted
439 int x = av.getAlignment().getHiddenColumns()
440 .absoluteToVisibleColumn(seqCanvas.cursorX);
441 av.getRanges().scrollToWrappedVisible(x);
445 av.getRanges().scrollToVisible(seqCanvas.cursorX,
450 if (av.getAlignment().getHiddenColumns().isVisible(seqCanvas.cursorX))
452 setStatusMessage(av.getAlignment().getSequenceAt(seqCanvas.cursorY),
453 seqCanvas.cursorX, seqCanvas.cursorY);
463 void setSelectionAreaAtCursor(boolean topLeft)
465 SequenceI sequence = av.getAlignment().getSequenceAt(seqCanvas.cursorY);
467 if (av.getSelectionGroup() != null)
469 SequenceGroup sg = av.getSelectionGroup();
470 // Find the top and bottom of this group
471 int min = av.getAlignment().getHeight(), max = 0;
472 for (int i = 0; i < sg.getSize(); i++)
474 int index = av.getAlignment().findIndex(sg.getSequenceAt(i));
489 sg.setStartRes(seqCanvas.cursorX);
490 if (sg.getEndRes() < seqCanvas.cursorX)
492 sg.setEndRes(seqCanvas.cursorX);
495 min = seqCanvas.cursorY;
499 sg.setEndRes(seqCanvas.cursorX);
500 if (sg.getStartRes() > seqCanvas.cursorX)
502 sg.setStartRes(seqCanvas.cursorX);
505 max = seqCanvas.cursorY + 1;
510 // Only the user can do this
511 av.setSelectionGroup(null);
515 // Now add any sequences between min and max
516 sg.getSequences(null).clear();
517 for (int i = min; i < max; i++)
519 sg.addSequence(av.getAlignment().getSequenceAt(i), false);
524 if (av.getSelectionGroup() == null)
526 SequenceGroup sg = new SequenceGroup();
527 sg.setStartRes(seqCanvas.cursorX);
528 sg.setEndRes(seqCanvas.cursorX);
529 sg.addSequence(sequence, false);
530 av.setSelectionGroup(sg);
533 ap.paintAlignment(false, false);
537 void insertGapAtCursor(boolean group)
539 groupEditing = group;
540 startseq = seqCanvas.cursorY;
541 lastres = seqCanvas.cursorX;
542 editSequence(true, false, seqCanvas.cursorX + getKeyboardNo1());
546 void deleteGapAtCursor(boolean group)
548 groupEditing = group;
549 startseq = seqCanvas.cursorY;
550 lastres = seqCanvas.cursorX + getKeyboardNo1();
551 editSequence(false, false, seqCanvas.cursorX);
555 void insertNucAtCursor(boolean group, String nuc)
557 // TODO not called - delete?
558 groupEditing = group;
559 startseq = seqCanvas.cursorY;
560 lastres = seqCanvas.cursorX;
561 editSequence(false, true, seqCanvas.cursorX + getKeyboardNo1());
565 void numberPressed(char value)
567 if (keyboardNo1 == null)
569 keyboardNo1 = new StringBuffer();
572 if (keyboardNo2 != null)
574 keyboardNo2.append(value);
578 keyboardNo1.append(value);
586 if (keyboardNo1 != null)
588 int value = Integer.parseInt(keyboardNo1.toString());
592 } catch (Exception x)
603 if (keyboardNo2 != null)
605 int value = Integer.parseInt(keyboardNo2.toString());
609 } catch (Exception x)
623 public void mouseReleased(MouseEvent evt)
625 boolean didDrag = mouseDragging; // did we come here after a drag
626 mouseDragging = false;
627 mouseWheelPressed = false;
629 if (evt.isPopupTrigger()) // Windows: mouseReleased
642 doMouseReleasedDefineMode(evt, didDrag);
653 public void mousePressed(MouseEvent evt)
655 lastMousePress = evt.getPoint();
657 if (SwingUtilities.isMiddleMouseButton(evt))
659 mouseWheelPressed = true;
663 boolean isControlDown = Platform.isControlDown(evt);
664 if (evt.isShiftDown() || isControlDown)
674 doMousePressedDefineMode(evt);
678 int seq = findSeq(evt);
679 int res = findColumn(evt);
681 if (seq < 0 || res < 0)
686 if ((seq < av.getAlignment().getHeight())
687 && (res < av.getAlignment().getSequenceAt(seq).getLength()))
703 private String formattedTooltipText;
706 public void mouseOverSequence(SequenceI sequence, int index, int pos)
708 String tmp = sequence.hashCode() + " " + index + " " + pos;
710 if (lastMessage == null || !lastMessage.equals(tmp))
712 // System.err.println("mouseOver Sequence: "+tmp);
713 ssm.mouseOverSequence(sequence, index, pos, av);
719 * Highlight the mapped region described by the search results object (unless
720 * unchanged). This supports highlight of protein while mousing over linked
721 * cDNA and vice versa. The status bar is also updated to show the location of
722 * the start of the highlighted region.
725 public void highlightSequence(SearchResultsI results)
727 if (results == null || results.equals(lastSearchResults))
731 lastSearchResults = results;
733 boolean wasScrolled = false;
735 if (av.isFollowHighlight())
737 // don't allow highlight of protein/cDNA to also scroll a complementary
738 // panel,as this sets up a feedback loop (scrolling panel 1 causes moused
739 // over residue to change abruptly, causing highlighted residue in panel 2
740 // to change, causing a scroll in panel 1 etc)
741 ap.setToScrollComplementPanel(false);
742 wasScrolled = ap.scrollToPosition(results, false);
745 seqCanvas.revalidate();
747 ap.setToScrollComplementPanel(true);
750 boolean fastPaint = !(wasScrolled && av.getWrapAlignment());
751 if (seqCanvas.highlightSearchResults(results, fastPaint))
753 setStatusMessage(results);
758 public VamsasSource getVamsasSource()
760 return this.ap == null ? null : this.ap.av;
764 public void updateColours(SequenceI seq, int index)
766 System.out.println("update the seqPanel colours");
771 * Action on mouse movement is to update the status bar to show the current
772 * sequence position, and (if features are shown) to show any features at the
773 * position in a tooltip. Does nothing if the mouse move does not change
779 public void mouseMoved(MouseEvent evt)
783 // This is because MacOSX creates a mouseMoved
784 // If control is down, other platforms will not.
788 final int column = findColumn(evt);
789 final int seq = findSeq(evt);
791 if (column < 0 || seq < 0 || seq >= av.getAlignment().getHeight())
796 if (column == lastMouseColumn && seq == lastMouseSeq)
799 * just a pixel move without change of residue
803 lastMouseColumn = column;
806 SequenceI sequence = av.getAlignment().getSequenceAt(seq);
808 if (column >= sequence.getLength())
814 * set status bar message, returning residue position in sequence
816 boolean isGapped = Comparison.isGap(sequence.getCharAt(column));
817 final int pos = setStatusMessage(sequence, column, seq);
818 if (ssm != null && !isGapped)
820 mouseOverSequence(sequence, column, pos);
823 tooltipText.setLength(6); // Cuts the buffer back to <html>
825 SequenceGroup[] groups = av.getAlignment().findAllGroups(sequence);
828 for (int g = 0; g < groups.length; g++)
830 if (groups[g].getStartRes() <= column
831 && groups[g].getEndRes() >= column)
833 if (!groups[g].getName().startsWith("JTreeGroup")
834 && !groups[g].getName().startsWith("JGroup"))
836 tooltipText.append(groups[g].getName());
839 if (groups[g].getDescription() != null)
841 tooltipText.append(": " + groups[g].getDescription());
848 * add any features at the position to the tooltip; if over a gap, only
849 * add features that straddle the gap (pos may be the residue before or
852 if (av.isShowSequenceFeatures())
854 List<SequenceFeature> features = ap.getFeatureRenderer()
855 .findFeaturesAtColumn(sequence, column + 1);
856 seqARep.appendFeatures(tooltipText, pos, features,
857 this.ap.getSeqPanel().seqCanvas.fr);
859 if (tooltipText.length() == 6) // <html>
861 setToolTipText(null);
866 if (tooltipText.length() > MAX_TOOLTIP_LENGTH) // constant
868 tooltipText.setLength(MAX_TOOLTIP_LENGTH);
869 tooltipText.append("...");
871 String textString = tooltipText.toString();
872 if (lastTooltip == null || !lastTooltip.equals(textString))
874 formattedTooltipText = JvSwingUtils.wrapTooltip(true,
876 setToolTipText(formattedTooltipText);
878 lastTooltip = textString;
884 private Point lastp = null;
886 private JToolTip tempTip = new JLabel().createToolTip();
891 * @see javax.swing.JComponent#getToolTipLocation(java.awt.event.MouseEvent)
894 public Point getToolTipLocation(MouseEvent event)
898 if (tooltipText == null || tooltipText.length() == 6)
901 if (lastp != null && event.isShiftDown())
905 int x = event.getX();
906 int y = event.getY();
909 tempTip.setTipText(formattedTooltipText);
910 int tipWidth = (int) tempTip.getPreferredSize().getWidth();
912 // was x += (w - x < 200) ? -(w / 2) : 5;
913 x = (x + tipWidth < w ? x + 10 : w - tipWidth);
914 p = new Point(x, y + 20); // BH 2018 was - 20?
916 * TODO: try to modify position region is not obcured by tooltip
927 * set when the current UI interaction has resulted in a change that requires
928 * shading in overviews and structures to be recalculated. this could be
929 * changed to a something more expressive that indicates what actually has
930 * changed, so selective redraws can be applied (ie. only structures, only
933 private boolean updateOverviewAndStructs = false; // TODO: refactor to avcontroller
936 * set if av.getSelectionGroup() refers to a group that is defined on the
937 * alignment view, rather than a transient selection
939 // private boolean editingDefinedGroup = false; // TODO: refactor to
940 // avcontroller or viewModel
943 * Sets the status message in alignment panel, showing the sequence number
944 * (index) and id, and residue and residue position if not at a gap, for the
945 * given sequence and column position. Returns the residue position returned
946 * by Sequence.findPosition. Note this may be for the nearest adjacent residue
947 * if at a gapped position.
950 * aligned sequence object
954 * index of sequence in alignment
955 * @return sequence position of residue at column, or adjacent residue if at a
958 int setStatusMessage(SequenceI sequence, final int column, int seqIndex)
960 char sequenceChar = sequence.getCharAt(column);
961 int pos = sequence.findPosition(column);
962 setStatusMessage(sequence, seqIndex, sequenceChar, pos);
968 * Builds the status message for the current cursor location and writes it to
969 * the status bar, for example
972 * Sequence 3 ID: FER1_SOLLC
973 * Sequence 5 ID: FER1_PEA Residue: THR (4)
974 * Sequence 5 ID: FER1_PEA Residue: B (3)
975 * Sequence 6 ID: O.niloticus.3 Nucleotide: Uracil (2)
980 * sequence position in the alignment (1..)
981 * @param sequenceChar
982 * the character under the cursor
984 * the sequence residue position (if not over a gap)
986 protected void setStatusMessage(SequenceI sequence, int seqIndex,
987 char sequenceChar, int residuePos)
989 StringBuilder text = new StringBuilder(32);
992 * Sequence number (if known), and sequence name.
994 String seqno = seqIndex == -1 ? "" : " " + (seqIndex + 1);
995 text.append("Sequence").append(seqno).append(" ID: ")
996 .append(sequence.getName());
998 String residue = null;
1001 * Try to translate the display character to residue name (null for gap).
1003 boolean isGapped = Comparison.isGap(sequenceChar);
1007 boolean nucleotide = av.getAlignment().isNucleotide();
1008 String displayChar = String.valueOf(sequenceChar);
1011 residue = ResidueProperties.nucleotideName.get(displayChar);
1015 residue = "X".equalsIgnoreCase(displayChar) ? "X"
1016 : ("*".equals(displayChar) ? "STOP"
1017 : ResidueProperties.aa2Triplet.get(displayChar));
1019 text.append(" ").append(nucleotide ? "Nucleotide" : "Residue")
1020 .append(": ").append(residue == null ? displayChar : residue);
1022 text.append(" (").append(Integer.toString(residuePos)).append(")");
1024 ap.alignFrame.statusBar.setText(text.toString());
1028 * Set the status bar message to highlight the first matched position in
1033 private void setStatusMessage(SearchResultsI results)
1035 AlignmentI al = this.av.getAlignment();
1036 int sequenceIndex = al.findIndex(results);
1037 if (sequenceIndex == -1)
1041 SequenceI ds = al.getSequenceAt(sequenceIndex).getDatasetSequence();
1042 for (SearchResultMatchI m : results.getResults())
1044 SequenceI seq = m.getSequence();
1045 if (seq.getDatasetSequence() != null)
1047 seq = seq.getDatasetSequence();
1052 int start = m.getStart();
1053 setStatusMessage(seq, sequenceIndex, seq.getCharAt(start - 1),
1064 public void mouseDragged(MouseEvent evt)
1066 if (mouseWheelPressed)
1068 boolean inSplitFrame = ap.av.getCodingComplement() != null;
1069 boolean copyChanges = inSplitFrame && av.isProteinFontAsCdna();
1071 int oldWidth = av.getCharWidth();
1073 // Which is bigger, left-right or up-down?
1074 if (Math.abs(evt.getY() - lastMousePress.getY()) > Math
1075 .abs(evt.getX() - lastMousePress.getX()))
1078 * on drag up or down, decrement or increment font size
1080 int fontSize = av.font.getSize();
1081 boolean fontChanged = false;
1083 if (evt.getY() < lastMousePress.getY())
1088 else if (evt.getY() > lastMousePress.getY())
1101 Font newFont = new Font(av.font.getName(), av.font.getStyle(),
1103 av.setFont(newFont, true);
1104 av.setCharWidth(oldWidth);
1108 ap.av.getCodingComplement().setFont(newFont, true);
1109 SplitFrame splitFrame = (SplitFrame) ap.alignFrame
1110 .getSplitViewContainer();
1111 splitFrame.adjustLayout();
1112 splitFrame.repaint();
1119 * on drag left or right, decrement or increment character width
1122 if (evt.getX() < lastMousePress.getX() && av.getCharWidth() > 1)
1124 newWidth = av.getCharWidth() - 1;
1125 av.setCharWidth(newWidth);
1127 else if (evt.getX() > lastMousePress.getX())
1129 newWidth = av.getCharWidth() + 1;
1130 av.setCharWidth(newWidth);
1134 ap.paintAlignment(false, false);
1138 * need to ensure newWidth is set on cdna, regardless of which
1139 * panel the mouse drag happened in; protein will compute its
1140 * character width as 1:1 or 3:1
1142 av.getCodingComplement().setCharWidth(newWidth);
1143 SplitFrame splitFrame = (SplitFrame) ap.alignFrame
1144 .getSplitViewContainer();
1145 splitFrame.adjustLayout();
1146 splitFrame.repaint();
1151 FontMetrics fm = getFontMetrics(av.getFont());
1152 av.validCharWidth = fm.charWidth('M') <= av.getCharWidth();
1154 lastMousePress = evt.getPoint();
1161 doMouseDraggedDefineMode(evt);
1165 int res = findColumn(evt);
1172 if ((lastres == -1) || (lastres == res))
1177 if ((res < av.getAlignment().getWidth()) && (res < lastres))
1179 // dragLeft, delete gap
1180 editSequence(false, false, res);
1184 editSequence(true, false, res);
1187 mouseDragging = true;
1188 if (scrollThread != null)
1190 scrollThread.setMousePosition(evt.getPoint());
1194 // TODO: Make it more clever than many booleans
1195 synchronized void editSequence(boolean insertGap, boolean editSeq,
1199 int fixedRight = -1;
1200 boolean fixedColumns = false;
1201 SequenceGroup sg = av.getSelectionGroup();
1203 SequenceI seq = av.getAlignment().getSequenceAt(startseq);
1205 // No group, but the sequence may represent a group
1206 if (!groupEditing && av.hasHiddenRows())
1208 if (av.isHiddenRepSequence(seq))
1210 sg = av.getRepresentedSequences(seq);
1211 groupEditing = true;
1215 StringBuilder message = new StringBuilder(64);
1218 message.append("Edit group:");
1219 if (editCommand == null)
1221 editCommand = new EditCommand(
1222 MessageManager.getString("action.edit_group"));
1227 message.append("Edit sequence: " + seq.getName());
1228 String label = seq.getName();
1229 if (label.length() > 10)
1231 label = label.substring(0, 10);
1233 if (editCommand == null)
1235 editCommand = new EditCommand(MessageManager
1236 .formatMessage("label.edit_params", new String[]
1243 message.append(" insert ");
1247 message.append(" delete ");
1250 message.append(Math.abs(startres - lastres) + " gaps.");
1251 ap.alignFrame.statusBar.setText(message.toString());
1253 // Are we editing within a selection group?
1254 if (groupEditing || (sg != null
1255 && sg.getSequences(av.getHiddenRepSequences()).contains(seq)))
1257 fixedColumns = true;
1259 // sg might be null as the user may only see 1 sequence,
1260 // but the sequence represents a group
1263 if (!av.isHiddenRepSequence(seq))
1268 sg = av.getRepresentedSequences(seq);
1271 fixedLeft = sg.getStartRes();
1272 fixedRight = sg.getEndRes();
1274 if ((startres < fixedLeft && lastres >= fixedLeft)
1275 || (startres >= fixedLeft && lastres < fixedLeft)
1276 || (startres > fixedRight && lastres <= fixedRight)
1277 || (startres <= fixedRight && lastres > fixedRight))
1283 if (fixedLeft > startres)
1285 fixedRight = fixedLeft - 1;
1288 else if (fixedRight < startres)
1290 fixedLeft = fixedRight;
1295 if (av.hasHiddenColumns())
1297 fixedColumns = true;
1298 int y1 = av.getAlignment().getHiddenColumns()
1299 .getNextHiddenBoundary(true, startres);
1300 int y2 = av.getAlignment().getHiddenColumns()
1301 .getNextHiddenBoundary(false, startres);
1303 if ((insertGap && startres > y1 && lastres < y1)
1304 || (!insertGap && startres < y2 && lastres > y2))
1310 // System.out.print(y1+" "+y2+" "+fixedLeft+" "+fixedRight+"~~");
1311 // Selection spans a hidden region
1312 if (fixedLeft < y1 && (fixedRight > y2 || fixedRight == -1))
1320 fixedRight = y2 - 1;
1327 List<SequenceI> vseqs = sg.getSequences(av.getHiddenRepSequences());
1328 int g, groupSize = vseqs.size();
1329 SequenceI[] groupSeqs = new SequenceI[groupSize];
1330 for (g = 0; g < groupSeqs.length; g++)
1332 groupSeqs[g] = vseqs.get(g);
1338 // If the user has selected the whole sequence, and is dragging to
1339 // the right, we can still extend the alignment and selectionGroup
1340 if (sg.getStartRes() == 0 && sg.getEndRes() == fixedRight
1341 && sg.getEndRes() == av.getAlignment().getWidth() - 1)
1343 sg.setEndRes(av.getAlignment().getWidth() + startres - lastres);
1344 fixedRight = sg.getEndRes();
1347 // Is it valid with fixed columns??
1348 // Find the next gap before the end
1349 // of the visible region boundary
1350 boolean blank = false;
1351 for (; fixedRight > lastres; fixedRight--)
1355 for (g = 0; g < groupSize; g++)
1357 for (int j = 0; j < startres - lastres; j++)
1359 if (!Comparison.isGap(groupSeqs[g].getCharAt(fixedRight - j)))
1374 if (sg.getSize() == av.getAlignment().getHeight())
1376 if ((av.hasHiddenColumns() && startres < av.getAlignment()
1378 .getNextHiddenBoundary(false, startres)))
1384 int alWidth = av.getAlignment().getWidth();
1385 if (av.hasHiddenRows())
1387 int hwidth = av.getAlignment().getHiddenSequences()
1389 if (hwidth > alWidth)
1394 // We can still insert gaps if the selectionGroup
1395 // contains all the sequences
1396 sg.setEndRes(sg.getEndRes() + startres - lastres);
1397 fixedRight = alWidth + startres - lastres;
1408 else if (!insertGap)
1410 // / Are we able to delete?
1411 // ie are all columns blank?
1413 for (g = 0; g < groupSize; g++)
1415 for (int j = startres; j < lastres; j++)
1417 if (groupSeqs[g].getLength() <= j)
1422 if (!Comparison.isGap(groupSeqs[g].getCharAt(j)))
1424 // Not a gap, block edit not valid
1434 // dragging to the right
1435 if (fixedColumns && fixedRight != -1)
1437 for (int j = lastres; j < startres; j++)
1439 insertChar(j, groupSeqs, fixedRight);
1444 appendEdit(Action.INSERT_GAP, groupSeqs, startres,
1445 startres - lastres);
1450 // dragging to the left
1451 if (fixedColumns && fixedRight != -1)
1453 for (int j = lastres; j > startres; j--)
1455 deleteChar(startres, groupSeqs, fixedRight);
1460 appendEdit(Action.DELETE_GAP, groupSeqs, startres,
1461 lastres - startres);
1467 // ///Editing a single sequence///////////
1471 // dragging to the right
1472 if (fixedColumns && fixedRight != -1)
1474 for (int j = lastres; j < startres; j++)
1476 insertChar(j, new SequenceI[] { seq }, fixedRight);
1481 appendEdit(Action.INSERT_GAP, new SequenceI[] { seq }, lastres,
1482 startres - lastres);
1489 // dragging to the left
1490 if (fixedColumns && fixedRight != -1)
1492 for (int j = lastres; j > startres; j--)
1494 if (!Comparison.isGap(seq.getCharAt(startres)))
1499 deleteChar(startres, new SequenceI[] { seq }, fixedRight);
1504 // could be a keyboard edit trying to delete none gaps
1506 for (int m = startres; m < lastres; m++)
1508 if (!Comparison.isGap(seq.getCharAt(m)))
1517 appendEdit(Action.DELETE_GAP, new SequenceI[] { seq },
1523 {// insertGap==false AND editSeq==TRUE;
1524 if (fixedColumns && fixedRight != -1)
1526 for (int j = lastres; j < startres; j++)
1528 insertChar(j, new SequenceI[] { seq }, fixedRight);
1533 appendEdit(Action.INSERT_NUC, new SequenceI[] { seq }, lastres,
1534 startres - lastres);
1541 seqCanvas.repaint();
1544 void insertChar(int j, SequenceI[] seq, int fixedColumn)
1546 int blankColumn = fixedColumn;
1547 for (int s = 0; s < seq.length; s++)
1549 // Find the next gap before the end of the visible region boundary
1550 // If lastCol > j, theres a boundary after the gap insertion
1552 for (blankColumn = fixedColumn; blankColumn > j; blankColumn--)
1554 if (Comparison.isGap(seq[s].getCharAt(blankColumn)))
1556 // Theres a space, so break and insert the gap
1561 if (blankColumn <= j)
1563 blankColumn = fixedColumn;
1569 appendEdit(Action.DELETE_GAP, seq, blankColumn, 1);
1571 appendEdit(Action.INSERT_GAP, seq, j, 1);
1576 * Helper method to add and perform one edit action.
1583 protected void appendEdit(Action action, SequenceI[] seq, int pos,
1587 final Edit edit = new EditCommand().new Edit(action, seq, pos, count,
1588 av.getAlignment().getGapCharacter());
1590 editCommand.appendEdit(edit, av.getAlignment(), true, null);
1593 void deleteChar(int j, SequenceI[] seq, int fixedColumn)
1596 appendEdit(Action.DELETE_GAP, seq, j, 1);
1598 appendEdit(Action.INSERT_GAP, seq, fixedColumn, 1);
1602 * On reentering the panel, stops any scrolling that was started on dragging
1608 public void mouseEntered(MouseEvent e)
1618 * On leaving the panel, if the mouse is being dragged, starts a thread to
1619 * scroll it until the mouse is released (in unwrapped mode only)
1624 public void mouseExited(MouseEvent e)
1626 if (!av.getWrapAlignment() && mouseDragging && scrollThread == null)
1628 scrollThread = new ScrollThread();
1633 * Handler for double-click on a position with one or more sequence features.
1634 * Opens the Amend Features dialog to allow feature details to be amended, or
1635 * the feature deleted.
1638 public void mouseClicked(MouseEvent evt)
1640 SequenceGroup sg = null;
1641 SequenceI sequence = av.getAlignment().getSequenceAt(findSeq(evt));
1642 if (evt.getClickCount() > 1)
1644 sg = av.getSelectionGroup();
1645 if (sg != null && sg.getSize() == 1
1646 && sg.getEndRes() - sg.getStartRes() < 2)
1648 av.setSelectionGroup(null);
1651 int column = findColumn(evt);
1654 * find features at the position (if not gapped), or straddling
1655 * the position (if at a gap)
1657 List<SequenceFeature> features = seqCanvas.getFeatureRenderer()
1658 .findFeaturesAtColumn(sequence, column + 1);
1660 if (!features.isEmpty())
1663 * highlight the first feature at the position on the alignment
1665 SearchResultsI highlight = new SearchResults();
1666 highlight.addResult(sequence, features.get(0).getBegin(), features
1668 seqCanvas.highlightSearchResults(highlight, true);
1671 * open the Amend Features dialog
1673 new FeatureEditor(ap, Collections.singletonList(sequence), features,
1674 false).showDialog();
1680 public void mouseWheelMoved(MouseWheelEvent e)
1683 double wheelRotation = e.getPreciseWheelRotation();
1684 if (wheelRotation > 0)
1686 if (e.isShiftDown())
1688 av.getRanges().scrollRight(true);
1693 av.getRanges().scrollUp(false);
1696 else if (wheelRotation < 0)
1698 if (e.isShiftDown())
1700 av.getRanges().scrollRight(false);
1704 av.getRanges().scrollUp(true);
1709 * update status bar and tooltip for new position
1710 * (need to synthesize a mouse movement to refresh tooltip)
1713 ToolTipManager.sharedInstance().mouseMoved(e);
1722 public void doMousePressedDefineMode(MouseEvent evt)
1724 final int res = findColumn(evt);
1725 final int seq = findSeq(evt);
1727 updateOverviewAndStructs = false;
1729 startWrapBlock = wrappedBlock;
1731 if (av.getWrapAlignment() && seq > av.getAlignment().getHeight())
1733 JvOptionPane.showInternalMessageDialog(Desktop.desktop,
1734 MessageManager.getString(
1735 "label.cannot_edit_annotations_in_wrapped_view"),
1736 MessageManager.getString("label.wrapped_view_no_edit"),
1737 JvOptionPane.WARNING_MESSAGE);
1741 if (seq < 0 || res < 0)
1746 SequenceI sequence = av.getAlignment().getSequenceAt(seq);
1748 if ((sequence == null) || (res > sequence.getLength()))
1753 stretchGroup = av.getSelectionGroup();
1755 if (stretchGroup == null || !stretchGroup.contains(sequence, res))
1757 stretchGroup = av.getAlignment().findGroup(sequence, res);
1758 if (stretchGroup != null)
1760 // only update the current selection if the popup menu has a group to
1762 av.setSelectionGroup(stretchGroup);
1766 if (evt.isPopupTrigger()) // Mac: mousePressed
1773 * defer right-mouse click handling to mouseReleased on Windows
1774 * (where isPopupTrigger() will answer true)
1775 * NB isRightMouseButton is also true for Cmd-click on Mac
1777 if (SwingUtilities.isRightMouseButton(evt) && !Platform.isAMac())
1784 seqCanvas.cursorX = findColumn(evt);
1785 seqCanvas.cursorY = findSeq(evt);
1786 seqCanvas.repaint();
1790 if (stretchGroup == null)
1792 createStretchGroup(res, sequence);
1795 if (stretchGroup != null)
1797 stretchGroup.addPropertyChangeListener(seqCanvas);
1800 seqCanvas.repaint();
1803 private void createStretchGroup(int res, SequenceI sequence)
1805 // Only if left mouse button do we want to change group sizes
1806 // define a new group here
1807 SequenceGroup sg = new SequenceGroup();
1808 sg.setStartRes(res);
1810 sg.addSequence(sequence, false);
1811 av.setSelectionGroup(sg);
1814 if (av.getConservationSelected())
1816 SliderPanel.setConservationSlider(ap, av.getResidueShading(),
1820 if (av.getAbovePIDThreshold())
1822 SliderPanel.setPIDSliderSource(ap, av.getResidueShading(),
1825 // TODO: stretchGroup will always be not null. Is this a merge error ?
1826 // or is there a threading issue here?
1827 if ((stretchGroup != null) && (stretchGroup.getEndRes() == res))
1829 // Edit end res position of selected group
1830 changeEndRes = true;
1832 else if ((stretchGroup != null) && (stretchGroup.getStartRes() == res))
1834 // Edit end res position of selected group
1835 changeStartRes = true;
1837 stretchGroup.getWidth();
1842 * Build and show a pop-up menu at the right-click mouse position
1848 void showPopupMenu(MouseEvent evt)
1850 final int column = findColumn(evt);
1851 final int seq = findSeq(evt);
1852 SequenceI sequence = av.getAlignment().getSequenceAt(seq);
1853 List<SequenceFeature> features = ap.getFeatureRenderer()
1854 .findFeaturesAtColumn(sequence, column + 1);
1856 PopupMenu pop = new PopupMenu(ap, null, features);
1857 pop.show(this, evt.getX(), evt.getY());
1861 * Update the display after mouse up on a selection or group
1864 * mouse released event details
1866 * true if this event is happening after a mouse drag (rather than a
1869 public void doMouseReleasedDefineMode(MouseEvent evt, boolean afterDrag)
1871 if (stretchGroup == null)
1876 stretchGroup.removePropertyChangeListener(seqCanvas);
1878 // always do this - annotation has own state
1879 // but defer colourscheme update until hidden sequences are passed in
1880 boolean vischange = stretchGroup.recalcConservation(true);
1881 updateOverviewAndStructs |= vischange && av.isSelectionDefinedGroup()
1883 if (stretchGroup.cs != null)
1885 stretchGroup.cs.alignmentChanged(stretchGroup,
1886 av.getHiddenRepSequences());
1888 ResidueShaderI groupColourScheme = stretchGroup
1889 .getGroupColourScheme();
1890 String name = stretchGroup.getName();
1891 if (stretchGroup.cs.conservationApplied())
1893 SliderPanel.setConservationSlider(ap, groupColourScheme, name);
1895 if (stretchGroup.cs.getThreshold() > 0)
1897 SliderPanel.setPIDSliderSource(ap, groupColourScheme, name);
1900 PaintRefresher.Refresh(this, av.getSequenceSetId());
1901 // TODO: structure colours only need updating if stretchGroup used to or now
1902 // does contain sequences with structure views
1903 ap.paintAlignment(updateOverviewAndStructs, updateOverviewAndStructs);
1904 updateOverviewAndStructs = false;
1905 changeEndRes = false;
1906 changeStartRes = false;
1907 stretchGroup = null;
1917 public void doMouseDraggedDefineMode(MouseEvent evt)
1919 int res = findColumn(evt);
1920 int y = findSeq(evt);
1922 if (wrappedBlock != startWrapBlock)
1927 if (stretchGroup == null)
1932 res = Math.min(res, av.getAlignment().getWidth()-1);
1934 if (stretchGroup.getEndRes() == res)
1936 // Edit end res position of selected group
1937 changeEndRes = true;
1939 else if (stretchGroup.getStartRes() == res)
1941 // Edit start res position of selected group
1942 changeStartRes = true;
1945 if (res < av.getRanges().getStartRes())
1947 res = av.getRanges().getStartRes();
1952 if (res > (stretchGroup.getStartRes() - 1))
1954 stretchGroup.setEndRes(res);
1955 updateOverviewAndStructs |= av.isSelectionDefinedGroup();
1958 else if (changeStartRes)
1960 if (res < (stretchGroup.getEndRes() + 1))
1962 stretchGroup.setStartRes(res);
1963 updateOverviewAndStructs |= av.isSelectionDefinedGroup();
1967 int dragDirection = 0;
1973 else if (y < oldSeq)
1978 while ((y != oldSeq) && (oldSeq > -1)
1979 && (y < av.getAlignment().getHeight()))
1981 // This routine ensures we don't skip any sequences, as the
1982 // selection is quite slow.
1983 Sequence seq = (Sequence) av.getAlignment().getSequenceAt(oldSeq);
1985 oldSeq += dragDirection;
1992 Sequence nextSeq = (Sequence) av.getAlignment().getSequenceAt(oldSeq);
1994 if (stretchGroup.getSequences(null).contains(nextSeq))
1996 stretchGroup.deleteSequence(seq, false);
1997 updateOverviewAndStructs |= av.isSelectionDefinedGroup();
2003 stretchGroup.addSequence(seq, false);
2006 stretchGroup.addSequence(nextSeq, false);
2007 updateOverviewAndStructs |= av.isSelectionDefinedGroup();
2016 mouseDragging = true;
2018 if (scrollThread != null)
2020 scrollThread.setMousePosition(evt.getPoint());
2025 * Stops the scroll thread if it is running
2027 void stopScrolling()
2029 if (scrollThread != null)
2031 scrollThread.stopScrolling();
2032 scrollThread = null;
2034 mouseDragging = false;
2038 * Starts a thread to scroll the alignment, towards a given mouse position
2039 * outside the panel bounds
2043 void startScrolling(Point mousePos)
2045 if (scrollThread == null)
2047 scrollThread = new ScrollThread();
2050 mouseDragging = true;
2051 scrollThread.setMousePosition(mousePos);
2055 * Performs scrolling of the visible alignment left, right, up or down
2057 class ScrollThread extends Thread
2059 private Point mousePos;
2061 private volatile boolean threadRunning = true;
2066 public ScrollThread()
2068 setName("SeqPanel$ScrollThread");
2073 * Sets the position of the mouse that determines the direction of the
2078 public void setMousePosition(Point p)
2084 * Sets a flag that will cause the thread to exit
2086 public void stopScrolling()
2088 threadRunning = false;
2092 * Scrolls the alignment left or right, and/or up or down, depending on the
2093 * last notified mouse position, until the limit of the alignment is
2094 * reached, or a flag is set to stop the scroll
2099 while (threadRunning && mouseDragging)
2101 if (mousePos != null)
2103 boolean scrolled = false;
2104 ViewportRanges ranges = SeqPanel.this.av.getRanges();
2111 // mouse is above this panel - try scroll up
2112 scrolled = ranges.scrollUp(true);
2114 else if (mousePos.y >= getHeight())
2116 // mouse is below this panel - try scroll down
2117 scrolled = ranges.scrollUp(false);
2121 * scroll left or right
2125 scrolled |= ranges.scrollRight(false);
2127 else if (mousePos.x >= getWidth())
2129 scrolled |= ranges.scrollRight(true);
2134 * we have reached the limit of the visible alignment - quit
2136 threadRunning = false;
2137 SeqPanel.this.ap.repaint();
2144 } catch (Exception ex)
2152 * modify current selection according to a received message.
2155 public void selection(SequenceGroup seqsel, ColumnSelection colsel,
2156 HiddenColumns hidden, SelectionSource source)
2158 // TODO: fix this hack - source of messages is align viewport, but SeqPanel
2159 // handles selection messages...
2160 // TODO: extend config options to allow user to control if selections may be
2161 // shared between viewports.
2162 boolean iSentTheSelection = (av == source
2163 || (source instanceof AlignViewport
2164 && ((AlignmentViewport) source).getSequenceSetId()
2165 .equals(av.getSequenceSetId())));
2167 if (iSentTheSelection)
2169 // respond to our own event by updating dependent dialogs
2170 if (ap.getCalculationDialog() != null)
2172 ap.getCalculationDialog().validateCalcTypes();
2178 // process further ?
2179 if (!av.followSelection)
2185 * Ignore the selection if there is one of our own pending.
2187 if (av.isSelectionGroupChanged(false) || av.isColSelChanged(false))
2193 * Check for selection in a view of which this one is a dna/protein
2196 if (selectionFromTranslation(seqsel, colsel, hidden, source))
2201 // do we want to thread this ? (contention with seqsel and colsel locks, I
2204 * only copy colsel if there is a real intersection between
2205 * sequence selection and this panel's alignment
2207 boolean repaint = false;
2208 boolean copycolsel = false;
2210 SequenceGroup sgroup = null;
2211 if (seqsel != null && seqsel.getSize() > 0)
2213 if (av.getAlignment() == null)
2215 Cache.log.warn("alignviewport av SeqSetId=" + av.getSequenceSetId()
2216 + " ViewId=" + av.getViewId()
2217 + " 's alignment is NULL! returning immediately.");
2220 sgroup = seqsel.intersect(av.getAlignment(),
2221 (av.hasHiddenRows()) ? av.getHiddenRepSequences() : null);
2222 if ((sgroup != null && sgroup.getSize() > 0))
2227 if (sgroup != null && sgroup.getSize() > 0)
2229 av.setSelectionGroup(sgroup);
2233 av.setSelectionGroup(null);
2235 av.isSelectionGroupChanged(true);
2240 // the current selection is unset or from a previous message
2241 // so import the new colsel.
2242 if (colsel == null || colsel.isEmpty())
2244 if (av.getColumnSelection() != null)
2246 av.getColumnSelection().clear();
2252 // TODO: shift colSel according to the intersecting sequences
2253 if (av.getColumnSelection() == null)
2255 av.setColumnSelection(new ColumnSelection(colsel));
2259 av.getColumnSelection().setElementsFrom(colsel,
2260 av.getAlignment().getHiddenColumns());
2263 av.isColSelChanged(true);
2267 if (copycolsel && av.hasHiddenColumns()
2268 && (av.getAlignment().getHiddenColumns() == null))
2270 System.err.println("Bad things");
2272 if (repaint) // always true!
2274 // probably finessing with multiple redraws here
2275 PaintRefresher.Refresh(this, av.getSequenceSetId());
2276 // ap.paintAlignment(false);
2279 // lastly, update dependent dialogs
2280 if (ap.getCalculationDialog() != null)
2282 ap.getCalculationDialog().validateCalcTypes();
2288 * If this panel is a cdna/protein translation view of the selection source,
2289 * tries to map the source selection to a local one, and returns true. Else
2296 protected boolean selectionFromTranslation(SequenceGroup seqsel,
2297 ColumnSelection colsel, HiddenColumns hidden,
2298 SelectionSource source)
2300 if (!(source instanceof AlignViewportI))
2304 final AlignViewportI sourceAv = (AlignViewportI) source;
2305 if (sourceAv.getCodingComplement() != av
2306 && av.getCodingComplement() != sourceAv)
2312 * Map sequence selection
2314 SequenceGroup sg = MappingUtils.mapSequenceGroup(seqsel, sourceAv, av);
2315 av.setSelectionGroup(sg);
2316 av.isSelectionGroupChanged(true);
2319 * Map column selection
2321 // ColumnSelection cs = MappingUtils.mapColumnSelection(colsel, sourceAv,
2323 ColumnSelection cs = new ColumnSelection();
2324 HiddenColumns hs = new HiddenColumns();
2325 MappingUtils.mapColumnSelection(colsel, hidden, sourceAv, av, cs, hs);
2326 av.setColumnSelection(cs);
2327 av.getAlignment().setHiddenColumns(hs);
2329 // lastly, update any dependent dialogs
2330 if (ap.getCalculationDialog() != null)
2332 ap.getCalculationDialog().validateCalcTypes();
2335 PaintRefresher.Refresh(this, av.getSequenceSetId());
2342 * @return null or last search results handled by this panel
2344 public SearchResultsI getLastSearchResults()
2346 return lastSearchResults;