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.
21 package jalview.appletgui;
23 import jalview.analysis.AnnotationSorter;
24 import jalview.api.AlignViewportI;
25 import jalview.api.AlignmentViewPanel;
26 import jalview.bin.JalviewLite;
27 import jalview.datamodel.AlignmentI;
28 import jalview.datamodel.SearchResults;
29 import jalview.datamodel.SequenceI;
30 import jalview.structure.StructureSelectionManager;
32 import java.awt.BorderLayout;
33 import java.awt.Color;
34 import java.awt.Dimension;
35 import java.awt.FontMetrics;
36 import java.awt.Frame;
37 import java.awt.Graphics;
38 import java.awt.Panel;
39 import java.awt.Scrollbar;
40 import java.awt.event.AdjustmentEvent;
41 import java.awt.event.AdjustmentListener;
42 import java.awt.event.ComponentAdapter;
43 import java.awt.event.ComponentEvent;
44 import java.util.List;
46 public class AlignmentPanel extends Panel implements AdjustmentListener,
50 public AlignViewport av;
52 OverviewPanel overviewPanel;
58 IdwidthAdjuster idwidthAdjuster;
60 public AlignFrame alignFrame;
62 ScalePanel scalePanel;
64 AnnotationPanel annotationPanel;
66 AnnotationLabels alabels;
68 // this value is set false when selection area being dragged
69 boolean fastPaint = true;
71 public void finalize()
76 seqPanelHolder = null;
77 sequenceHolderPanel = null;
79 scalePanelHolder = null;
80 annotationPanel = null;
81 annotationPanelHolder = null;
82 annotationSpaceFillerHolder = null;
85 public AlignmentPanel(AlignFrame af, final AlignViewport av)
97 seqPanel = new SeqPanel(av, this);
98 idPanel = new IdPanel(av, this);
99 scalePanel = new ScalePanel(av, this);
100 idwidthAdjuster = new IdwidthAdjuster(this);
101 annotationPanel = new AnnotationPanel(this);
102 annotationPanelHolder.add(annotationPanel, BorderLayout.CENTER);
104 sequenceHolderPanel.add(annotationPanelHolder, BorderLayout.SOUTH);
105 alabels = new AnnotationLabels(this);
107 setAnnotationVisible(av.isShowAnnotation());
109 idPanelHolder.add(idPanel, BorderLayout.CENTER);
110 idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER);
111 annotationSpaceFillerHolder.add(alabels, BorderLayout.CENTER);
112 scalePanelHolder.add(scalePanel, BorderLayout.CENTER);
113 seqPanelHolder.add(seqPanel, BorderLayout.CENTER);
116 setScrollValues(0, 0);
118 apvscroll.addAdjustmentListener(this);
119 hscroll.addAdjustmentListener(this);
120 vscroll.addAdjustmentListener(this);
122 addComponentListener(new ComponentAdapter()
124 public void componentResized(ComponentEvent evt)
126 setScrollValues(av.getStartRes(), av.getStartSeq());
127 if (getSize().height > 0
128 && annotationPanelHolder.getSize().height > 0)
130 validateAnnotationDimensions(false);
137 Dimension d = calculateIdWidth();
138 idPanel.idCanvas.setSize(d);
140 hscrollFillerPanel.setSize(d.width, annotationPanel.getSize().height);
142 idPanel.idCanvas.setSize(d.width, seqPanel.seqCanvas.getSize().height);
143 annotationSpaceFillerHolder.setSize(d.width,
144 annotationPanel.getSize().height);
145 alabels.setSize(d.width, annotationPanel.getSize().height);
146 final AlignmentPanel ap = this;
147 av.addPropertyChangeListener(new java.beans.PropertyChangeListener()
149 public void propertyChange(java.beans.PropertyChangeEvent evt)
151 if (evt.getPropertyName().equals("alignment"))
153 PaintRefresher.Refresh(ap, av.getSequenceSetId(), true, true);
161 public AlignViewportI getAlignViewport()
166 public SequenceRenderer getSequenceRenderer()
168 return seqPanel.seqCanvas.sr;
172 public jalview.api.FeatureRenderer getFeatureRenderer()
174 return seqPanel.seqCanvas.fr;
178 public jalview.api.FeatureRenderer cloneFeatureRenderer()
180 FeatureRenderer nfr = new FeatureRenderer(av);
181 nfr.transferSettings(seqPanel.seqCanvas.fr);
185 public void alignmentChanged()
187 av.alignmentChanged(this);
189 if (overviewPanel != null)
191 overviewPanel.updateOverviewImage();
194 alignFrame.updateEditMenuBar();
199 public void fontChanged()
201 // set idCanvas bufferedImage to null
202 // to prevent drawing old image
203 idPanel.idCanvas.image = null;
204 FontMetrics fm = getFontMetrics(av.getFont());
206 scalePanel.setSize(new Dimension(10, av.getCharHeight()
208 idwidthAdjuster.setSize(new Dimension(10, av.getCharHeight()
210 av.updateSequenceIdColours();
211 annotationPanel.image = null;
212 int ap = annotationPanel.adjustPanelHeight(false);
213 Dimension d = calculateIdWidth();
214 d.setSize(d.width + 4, seqPanel.seqCanvas.getSize().height);
215 alabels.setSize(d.width + 4, ap);
217 idPanel.idCanvas.setSize(d);
218 hscrollFillerPanel.setSize(d);
220 validateAnnotationDimensions(false);
221 annotationPanel.repaint();
225 if (overviewPanel != null)
227 overviewPanel.updateOverviewImage();
231 public void setIdWidth(int w, int h)
233 idPanel.idCanvas.setSize(w, h);
234 idPanelHolder.setSize(w, idPanelHolder.getSize().height);
235 annotationSpaceFillerHolder.setSize(w,
236 annotationSpaceFillerHolder.getSize().height);
237 alabels.setSize(w, alabels.getSize().height);
241 Dimension calculateIdWidth()
243 if (av.nullFrame == null)
245 av.nullFrame = new Frame();
246 av.nullFrame.addNotify();
249 Graphics g = av.nullFrame.getGraphics();
251 FontMetrics fm = g.getFontMetrics(av.font);
252 AlignmentI al = av.getAlignment();
257 while (i < al.getHeight() && al.getSequenceAt(i) != null)
259 SequenceI s = al.getSequenceAt(i);
260 id = s.getDisplayId(av.getShowJVSuffix());
262 if (fm.stringWidth(id) > idWidth)
264 idWidth = fm.stringWidth(id);
269 // Also check annotation label widths
271 if (al.getAlignmentAnnotation() != null)
273 fm = g.getFontMetrics(av.nullFrame.getFont());
274 while (i < al.getAlignmentAnnotation().length)
276 String label = al.getAlignmentAnnotation()[i].label;
277 if (fm.stringWidth(label) > idWidth)
279 idWidth = fm.stringWidth(label);
285 return new Dimension(idWidth, idPanel.idCanvas.getSize().height);
289 * Highlight the given results on the alignment.
292 public void highlightSearchResults(SearchResults results)
294 scrollToPosition(results);
295 seqPanel.seqCanvas.highlightSearchResults(results);
299 * scroll the view to show the position of the highlighted region in results
300 * (if any) and redraw the overview
303 * @return false if results were not found
305 public boolean scrollToPosition(SearchResults results)
307 return scrollToPosition(results, true);
311 * scroll the view to show the position of the highlighted region in results
315 * @param redrawOverview
316 * - when set, the overview will be recalculated (takes longer)
317 * @return false if results were not found
319 public boolean scrollToPosition(SearchResults results,
320 boolean redrawOverview)
322 return scrollToPosition(results, redrawOverview, false);
326 * scroll the view to show the position of the highlighted region in results
330 * @param redrawOverview
331 * - when set, the overview will be recalculated (takes longer)
332 * @return false if results were not found
334 public boolean scrollToPosition(SearchResults results,
335 boolean redrawOverview, boolean centre)
337 // do we need to scroll the panel?
338 if (results != null && results.getSize() > 0)
340 AlignmentI alignment = av.getAlignment();
341 int seqIndex = alignment.findIndex(results);
346 SequenceI seq = alignment.getSequenceAt(seqIndex);
347 int[] r = results.getResults(seq, 0, alignment.getWidth());
350 if (JalviewLite.debug)
353 .println("DEBUG: scroll didn't happen - results not within alignment : "
354 + seq.getStart() + "," + seq.getEnd());
358 if (JalviewLite.debug)
362 * System.out.println("DEBUG: scroll: start=" + r[0] +
363 * " av.getStartRes()=" + av.getStartRes() + " end=" + r[1] +
364 * " seq.end=" + seq.getEnd() + " av.getEndRes()=" + av.getEndRes() +
365 * " hextent=" + hextent);
372 * To centre results, scroll to positions half the visible width
373 * left/right of the start/end positions
377 int offset = (av.getEndRes() - av.getStartRes() + 1) / 2 - 1;
378 start = Math.max(start - offset, 0);
379 end = Math.min(end + offset, seq.getEnd() - 1);
386 if (end == seq.getEnd())
390 return scrollTo(start, end, seqIndex, false, redrawOverview);
395 public boolean scrollTo(int ostart, int end, int seqIndex,
396 boolean scrollToNearest, boolean redrawOverview)
398 int startv, endv, starts, ends, width;
401 if (av.hasHiddenColumns())
403 start = av.getColumnSelection().findColumnPosition(ostart);
404 end = av.getColumnSelection().findColumnPosition(end);
407 if (!scrollToNearest && !av.getColumnSelection().isVisible(ostart))
409 // don't scroll - position isn't visible
418 if (!av.getWrapAlignment())
421 * int spos=av.getStartRes(),sqpos=av.getStartSeq(); if ((startv =
422 * av.getStartRes()) >= start) { spos=start-1; // seqIn //
423 * setScrollValues(start - 1, seqIndex); } else if ((endv =
424 * av.getEndRes()) <= end) { // setScrollValues(spos=startv + 1 + end -
425 * endv, seqIndex); spos=startv + 1 + end - endv; } else if ((starts =
426 * av.getStartSeq()) > seqIndex) { setScrollValues(av.getStartRes(),
427 * seqIndex); } else if ((ends = av.getEndSeq()) <= seqIndex) {
428 * setScrollValues(av.getStartRes(), starts + seqIndex - ends + 1); }
431 // below is scrolling logic up to Jalview 2.8.2
432 // if ((av.getStartRes() > end)
433 // || (av.getEndRes() < start)
434 // || ((av.getStartSeq() > seqIndex) || (av.getEndSeq() < seqIndex)))
436 // if (start > av.getAlignment().getWidth() - hextent)
438 // start = av.getAlignment().getWidth() - hextent;
445 // if (seqIndex > av.getAlignment().getHeight() - vextent)
447 // seqIndex = av.getAlignment().getHeight() - vextent;
453 // setScrollValues(start, seqIndex);
455 // logic copied from jalview.gui.AlignmentPanel:
456 if ((startv = av.getStartRes()) >= start)
459 * Scroll left to make start of search results visible
461 setScrollValues(start - 1, seqIndex);
463 else if ((endv = av.getEndRes()) <= end)
466 * Scroll right to make end of search results visible
468 setScrollValues(startv + 1 + end - endv, seqIndex);
470 else if ((starts = av.getStartSeq()) > seqIndex)
473 * Scroll up to make start of search results visible
475 setScrollValues(av.getStartRes(), seqIndex);
477 else if ((ends = av.getEndSeq()) <= seqIndex)
480 * Scroll down to make end of search results visible
482 setScrollValues(av.getStartRes(), starts + seqIndex - ends + 1);
485 * Else results are already visible - no need to scroll
490 scrollToWrappedVisible(start);
492 if (redrawOverview && overviewPanel != null)
494 overviewPanel.setBoxPosition();
496 paintAlignment(redrawOverview);
500 void scrollToWrappedVisible(int res)
502 int cwidth = seqPanel.seqCanvas
503 .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width);
504 if (res <= av.getStartRes() || res >= (av.getStartRes() + cwidth))
506 vscroll.setValue(res / cwidth);
507 av.startRes = vscroll.getValue() * cwidth;
511 public OverviewPanel getOverviewPanel()
513 return overviewPanel;
516 public void setOverviewPanel(OverviewPanel op)
521 public void setAnnotationVisible(boolean b)
523 if (!av.getWrapAlignment())
525 annotationSpaceFillerHolder.setVisible(b);
526 annotationPanelHolder.setVisible(b);
530 annotationSpaceFillerHolder.setVisible(false);
531 annotationPanelHolder.setVisible(false);
538 * automatically adjust annotation panel height for new annotation whilst
539 * ensuring the alignment is still visible.
541 public void adjustAnnotationHeight()
543 // TODO: display vertical annotation scrollbar if necessary
544 // this is called after loading new annotation onto alignment
545 if (alignFrame.getSize().height == 0)
548 .println("adjustAnnotationHeight frame size zero NEEDS FIXING");
551 validateAnnotationDimensions(true);
552 apvscroll.addNotify();
555 paintAlignment(true);
559 * Calculate the annotation dimensions and refresh slider values accordingly.
560 * Need to do repaints/notifys afterwards.
562 protected void validateAnnotationDimensions(boolean adjustPanelHeight)
564 int rowHeight = av.getCharHeight();
565 int alignmentHeight = rowHeight * av.getAlignment().getHeight();
566 int annotationHeight = av.calcPanelHeight();
568 int mheight = annotationHeight;
569 Dimension d = sequenceHolderPanel.getSize();
571 int availableHeight = d.height - scalePanelHolder.getHeight();
573 if (adjustPanelHeight)
576 * If not enough vertical space, maximize annotation height while keeping
577 * at least two rows of alignment visible
579 if (annotationHeight + alignmentHeight > availableHeight)
581 annotationHeight = Math.min(annotationHeight, availableHeight - 2
587 // maintain same window layout whilst updating sliders
588 annotationHeight = annotationPanelHolder.getSize().height;
591 if (availableHeight - annotationHeight < 5)
593 annotationHeight = availableHeight;
596 annotationPanel.setSize(new Dimension(d.width, annotationHeight));
597 annotationPanelHolder.setSize(new Dimension(d.width, annotationHeight));
598 // seqPanelHolder.setSize(d.width, seqandannot - height);
600 .setSize(d.width, seqPanel.seqCanvas.getSize().height);
602 Dimension e = idPanel.getSize();
603 alabels.setSize(new Dimension(e.width, annotationHeight));
604 annotationSpaceFillerHolder.setSize(new Dimension(e.width,
607 int s = apvscroll.getValue();
608 if (s > mheight - annotationHeight)
612 apvscroll.setValues(s, annotationHeight, 0, mheight);
613 annotationPanel.setScrollOffset(apvscroll.getValue(), false);
614 alabels.setScrollOffset(apvscroll.getValue(), false);
617 public void setWrapAlignment(boolean wrap)
621 scalePanelHolder.setVisible(!wrap);
623 hscroll.setVisible(!wrap);
624 idwidthAdjuster.setVisible(!wrap);
628 annotationPanelHolder.setVisible(false);
629 annotationSpaceFillerHolder.setVisible(false);
631 else if (av.isShowAnnotation())
633 annotationPanelHolder.setVisible(true);
634 annotationSpaceFillerHolder.setVisible(true);
637 idSpaceFillerPanel1.setVisible(!wrap);
639 fontChanged(); // This is so that the scalePanel is resized correctly
642 sequenceHolderPanel.validate();
651 // return value is true if the scroll is valid
652 public boolean scrollUp(boolean up)
656 if (vscroll.getValue() < 1)
660 setScrollValues(hscroll.getValue(), vscroll.getValue() - 1);
664 if (vextent + vscroll.getValue() >= av.getAlignment().getHeight())
668 setScrollValues(hscroll.getValue(), vscroll.getValue() + 1);
675 public boolean scrollRight(boolean right)
679 if (hscroll.getValue() < 1)
683 setScrollValues(hscroll.getValue() - 1, vscroll.getValue());
687 if (hextent + hscroll.getValue() >= av.getAlignment().getWidth())
691 setScrollValues(hscroll.getValue() + 1, vscroll.getValue());
698 public void setScrollValues(int x, int y)
700 int width = av.getAlignment().getWidth();
701 int height = av.getAlignment().getHeight();
703 if (av.hasHiddenColumns())
705 width = av.getColumnSelection().findColumnPosition(width);
713 hextent = seqPanel.seqCanvas.getSize().width / av.getCharWidth();
714 vextent = seqPanel.seqCanvas.getSize().height / av.getCharHeight();
721 if (vextent > height)
726 if ((hextent + x) > width)
728 System.err.println("hextent was " + hextent + " and x was " + x);
733 if ((vextent + y) > height)
735 y = height - vextent;
745 System.err.println("x was " + x);
751 int endSeq = y + vextent;
752 if (endSeq > av.getAlignment().getHeight())
754 endSeq = av.getAlignment().getHeight();
757 av.setEndSeq(endSeq);
759 av.setEndRes((x + (seqPanel.seqCanvas.getSize().width / av
760 .getCharWidth())) - 1);
762 hscroll.setValues(x, hextent, 0, width);
763 vscroll.setValues(y, vextent, 0, height);
765 if (overviewPanel != null)
767 overviewPanel.setBoxPosition();
773 public void adjustmentValueChanged(AdjustmentEvent evt)
775 int oldX = av.getStartRes();
776 int oldY = av.getStartSeq();
778 if (evt == null || evt.getSource() == apvscroll)
780 annotationPanel.setScrollOffset(apvscroll.getValue(), false);
781 alabels.setScrollOffset(apvscroll.getValue(), false);
782 // annotationPanel.image=null;
783 // alabels.image=null;
784 // alabels.repaint();
785 // annotationPanel.repaint();
787 if (evt == null || evt.getSource() == hscroll)
789 int x = hscroll.getValue();
791 av.setEndRes(x + seqPanel.seqCanvas.getSize().width
792 / av.getCharWidth() - 1);
795 if (evt == null || evt.getSource() == vscroll)
797 int offy = vscroll.getValue();
798 if (av.getWrapAlignment())
800 int rowSize = seqPanel.seqCanvas
801 .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width);
802 av.setStartRes(vscroll.getValue() * rowSize);
803 av.setEndRes((vscroll.getValue() + 1) * rowSize);
807 av.setStartSeq(offy);
808 av.setEndSeq(offy + seqPanel.seqCanvas.getSize().height
809 / av.getCharHeight());
813 if (overviewPanel != null)
815 overviewPanel.setBoxPosition();
818 int scrollX = av.startRes - oldX;
819 int scrollY = av.startSeq - oldY;
821 if (av.getWrapAlignment() || !fastPaint || av.MAC)
827 // Make sure we're not trying to draw a panel
828 // larger than the visible window
829 if (scrollX > av.endRes - av.startRes)
831 scrollX = av.endRes - av.startRes;
833 else if (scrollX < av.startRes - av.endRes)
835 scrollX = av.startRes - av.endRes;
838 idPanel.idCanvas.fastPaint(scrollY);
839 seqPanel.seqCanvas.fastPaint(scrollX, scrollY);
841 scalePanel.repaint();
842 if (av.isShowAnnotation())
844 annotationPanel.fastPaint(av.getStartRes() - oldX);
850 * If there is one, scroll the (Protein/cDNA) complementary alignment to
851 * match, unless we are ourselves doing that.
853 if (isFollowingComplementScroll())
855 setFollowingComplementScroll(false);
859 AlignmentPanel ap = getComplementPanel();
860 av.scrollComplementaryAlignment(ap);
866 * A helper method to return the AlignmentPanel in the other (complementary)
867 * half of a SplitFrame view. Returns null if not in a SplitFrame.
871 private AlignmentPanel getComplementPanel()
873 AlignmentPanel ap = null;
874 if (alignFrame != null)
876 SplitFrame sf = alignFrame.getSplitFrame();
879 AlignFrame other = sf.getComplement(alignFrame);
882 ap = other.alignPanel;
890 * Follow a scrolling change in the (cDNA/Protein) complementary alignment.
891 * The aim is to keep the two alignments 'lined up' on their centre columns.
894 * holds mapped region(s) of this alignment that we are scrolling
895 * 'to'; may be modified for sequence offset by this method
897 * the number of visible sequences to show above the mapped region
899 protected void scrollToCentre(SearchResults sr, int seqOffset)
902 * To avoid jumpy vertical scrolling (if some sequences are gapped or not
903 * mapped), we can make the scroll-to location a sequence above the one
906 SequenceI mappedTo = sr.getResultSequence(0);
907 List<SequenceI> seqs = av.getAlignment().getSequences();
910 * This is like AlignmentI.findIndex(seq) but here we are matching the
911 * dataset sequence not the aligned sequence
913 int sequenceIndex = 0;
914 boolean matched = false;
915 for (SequenceI seq : seqs)
917 if (mappedTo == seq.getDatasetSequence())
926 return; // failsafe, shouldn't happen
928 sequenceIndex = Math.max(0, sequenceIndex - seqOffset);
929 sr.getResults().get(0)
930 .setSequence(av.getAlignment().getSequenceAt(sequenceIndex));
933 * Scroll to position but centring the target residue. Also set a state flag
934 * to prevent adjustmentValueChanged performing this recursively.
936 setFollowingComplementScroll(true);
937 scrollToPosition(sr, true, true);
940 private void sendViewPosition()
942 StructureSelectionManager.getStructureSelectionManager(av.applet)
943 .sendViewPosition(this, av.startRes, av.endRes, av.startSeq,
948 * Repaint the alignment and annotations, and, optionally, any overview window
950 public void paintAlignment(boolean updateOverview)
952 final AnnotationSorter sorter = new AnnotationSorter(getAlignment(),
953 av.isShowAutocalculatedAbove());
954 sorter.sort(getAlignment().getAlignmentAnnotation(),
955 av.getSortAnnotationsBy());
960 // TODO: determine if this paintAlignment changed structure colours
961 jalview.structure.StructureSelectionManager
962 .getStructureSelectionManager(av.applet)
963 .sequenceColoursChanged(this);
965 if (overviewPanel != null)
967 overviewPanel.updateOverviewImage();
972 public void update(Graphics g)
977 public void paint(Graphics g)
980 Dimension d = idPanel.idCanvas.getSize();
981 final int canvasHeight = seqPanel.seqCanvas.getSize().height;
982 if (canvasHeight != d.height)
984 idPanel.idCanvas.setSize(d.width, canvasHeight);
987 if (av.getWrapAlignment())
989 int maxwidth = av.getAlignment().getWidth();
991 if (av.hasHiddenColumns())
993 maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
996 int canvasWidth = seqPanel.seqCanvas
997 .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width);
1001 int max = maxwidth / canvasWidth;
1002 vscroll.setMaximum(1 + max);
1003 vscroll.setUnitIncrement(1);
1004 vscroll.setVisibleAmount(1);
1009 setScrollValues(av.getStartRes(), av.getStartSeq());
1012 seqPanel.seqCanvas.repaint();
1013 idPanel.idCanvas.repaint();
1014 if (!av.getWrapAlignment())
1016 if (av.isShowAnnotation())
1019 annotationPanel.repaint();
1021 scalePanel.repaint();
1026 protected Panel sequenceHolderPanel = new Panel();
1028 protected Scrollbar vscroll = new Scrollbar();
1030 protected Scrollbar hscroll = new Scrollbar();
1032 protected Panel seqPanelHolder = new Panel();
1034 protected Panel scalePanelHolder = new Panel();
1036 protected Panel idPanelHolder = new Panel();
1038 protected Panel idSpaceFillerPanel1 = new Panel();
1040 public Panel annotationSpaceFillerHolder = new Panel();
1042 protected Panel hscrollFillerPanel = new Panel();
1044 Panel annotationPanelHolder = new Panel();
1046 protected Scrollbar apvscroll = new Scrollbar();
1049 * Flag set while scrolling to follow complementary cDNA/protein scroll. When
1050 * true, suppresses invoking the same method recursively.
1052 private boolean followingComplementScroll;
1054 private void jbInit() throws Exception
1056 // idPanelHolder.setPreferredSize(new Dimension(70, 10));
1057 this.setLayout(new BorderLayout());
1059 // sequenceHolderPanel.setPreferredSize(new Dimension(150, 150));
1060 sequenceHolderPanel.setLayout(new BorderLayout());
1061 seqPanelHolder.setLayout(new BorderLayout());
1062 scalePanelHolder.setBackground(Color.white);
1064 // scalePanelHolder.setPreferredSize(new Dimension(10, 30));
1065 scalePanelHolder.setLayout(new BorderLayout());
1066 idPanelHolder.setLayout(new BorderLayout());
1067 idSpaceFillerPanel1.setBackground(Color.white);
1069 // idSpaceFillerPanel1.setPreferredSize(new Dimension(10, 30));
1070 idSpaceFillerPanel1.setLayout(new BorderLayout());
1071 annotationSpaceFillerHolder.setBackground(Color.white);
1073 // annotationSpaceFillerHolder.setPreferredSize(new Dimension(10, 80));
1074 annotationSpaceFillerHolder.setLayout(new BorderLayout());
1075 hscroll.setOrientation(Scrollbar.HORIZONTAL);
1077 Panel hscrollHolder = new Panel();
1078 hscrollHolder.setLayout(new BorderLayout());
1079 hscrollFillerPanel.setBackground(Color.white);
1080 apvscroll.setOrientation(Scrollbar.VERTICAL);
1081 apvscroll.setVisible(true);
1082 apvscroll.addAdjustmentListener(this);
1084 annotationPanelHolder.setBackground(Color.white);
1085 annotationPanelHolder.setLayout(new BorderLayout());
1086 annotationPanelHolder.add(apvscroll, BorderLayout.EAST);
1087 // hscrollFillerPanel.setPreferredSize(new Dimension(70, 10));
1088 hscrollHolder.setBackground(Color.white);
1090 // annotationScroller.setPreferredSize(new Dimension(10, 80));
1091 // this.setPreferredSize(new Dimension(220, 166));
1092 seqPanelHolder.setBackground(Color.white);
1093 idPanelHolder.setBackground(Color.white);
1094 sequenceHolderPanel.add(scalePanelHolder, BorderLayout.NORTH);
1095 sequenceHolderPanel.add(seqPanelHolder, BorderLayout.CENTER);
1096 seqPanelHolder.add(vscroll, BorderLayout.EAST);
1098 // Panel3.add(secondaryPanelHolder, BorderLayout.SOUTH);
1099 this.add(idPanelHolder, BorderLayout.WEST);
1100 idPanelHolder.add(idSpaceFillerPanel1, BorderLayout.NORTH);
1101 idPanelHolder.add(annotationSpaceFillerHolder, BorderLayout.SOUTH);
1102 this.add(hscrollHolder, BorderLayout.SOUTH);
1103 hscrollHolder.add(hscroll, BorderLayout.CENTER);
1104 hscrollHolder.add(hscrollFillerPanel, BorderLayout.WEST);
1105 this.add(sequenceHolderPanel, BorderLayout.CENTER);
1109 * hides or shows dynamic annotation rows based on groups and av state flags
1111 public void updateAnnotation()
1113 updateAnnotation(false);
1116 public void updateAnnotation(boolean applyGlobalSettings)
1118 updateAnnotation(applyGlobalSettings, false);
1121 public void updateAnnotation(boolean applyGlobalSettings,
1122 boolean preserveNewGroupSettings)
1124 av.updateGroupAnnotationSettings(applyGlobalSettings,
1125 preserveNewGroupSettings);
1126 adjustAnnotationHeight();
1130 public AlignmentI getAlignment()
1132 return av.getAlignment();
1136 public String getViewName()
1142 public StructureSelectionManager getStructureSelectionManager()
1144 return StructureSelectionManager
1145 .getStructureSelectionManager(av.applet);
1149 public void raiseOOMWarning(String string, OutOfMemoryError error)
1152 System.err.println("Out of memory whilst '" + string + "'");
1153 error.printStackTrace();
1157 * Set a flag to say we are scrolling to follow a (cDNA/protein) complement.
1161 protected void setFollowingComplementScroll(boolean b)
1163 this.followingComplementScroll = b;
1166 protected boolean isFollowingComplementScroll()
1168 return this.followingComplementScroll;