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.api.SequenceRendererI;
27 import jalview.bin.JalviewLite;
28 import jalview.datamodel.AlignmentI;
29 import jalview.datamodel.SearchResultsI;
30 import jalview.datamodel.SequenceI;
31 import jalview.structure.StructureSelectionManager;
32 import jalview.viewmodel.ViewportListenerI;
33 import jalview.viewmodel.ViewportRanges;
35 import java.awt.BorderLayout;
36 import java.awt.Color;
37 import java.awt.Dimension;
38 import java.awt.FontMetrics;
39 import java.awt.Frame;
40 import java.awt.Graphics;
41 import java.awt.Panel;
42 import java.awt.Scrollbar;
43 import java.awt.event.AdjustmentEvent;
44 import java.awt.event.AdjustmentListener;
45 import java.awt.event.ComponentAdapter;
46 import java.awt.event.ComponentEvent;
47 import java.beans.PropertyChangeEvent;
48 import java.util.List;
50 public class AlignmentPanel extends Panel
51 implements AdjustmentListener, AlignmentViewPanel, ViewportListenerI
54 public AlignViewport av;
56 OverviewPanel overviewPanel;
62 IdwidthAdjuster idwidthAdjuster;
64 public AlignFrame alignFrame;
66 ScalePanel scalePanel;
68 AnnotationPanel annotationPanel;
70 AnnotationLabels alabels;
72 ViewportRanges vpRanges;
74 // this value is set false when selection area being dragged
75 boolean fastPaint = true;
77 public AlignmentPanel(AlignFrame af, final AlignViewport av)
89 vpRanges = av.getRanges();
90 seqPanel = new SeqPanel(av, this);
91 idPanel = new IdPanel(av, this);
92 scalePanel = new ScalePanel(av, this);
93 idwidthAdjuster = new IdwidthAdjuster(this);
94 annotationPanel = new AnnotationPanel(this);
95 annotationPanelHolder.add(annotationPanel, BorderLayout.CENTER);
97 sequenceHolderPanel.add(annotationPanelHolder, BorderLayout.SOUTH);
98 alabels = new AnnotationLabels(this);
100 setAnnotationVisible(av.isShowAnnotation());
102 idPanelHolder.add(idPanel, BorderLayout.CENTER);
103 idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER);
104 annotationSpaceFillerHolder.add(alabels, BorderLayout.CENTER);
105 scalePanelHolder.add(scalePanel, BorderLayout.CENTER);
106 seqPanelHolder.add(seqPanel, BorderLayout.CENTER);
109 setScrollValues(0, 0);
111 apvscroll.addAdjustmentListener(this);
112 hscroll.addAdjustmentListener(this);
113 vscroll.addAdjustmentListener(this);
115 addComponentListener(new ComponentAdapter()
118 public void componentResized(ComponentEvent evt)
120 // reset the viewport ranges when the alignment panel is resized
121 // in particular, this initialises the end residue value when Jalview
123 if (av.getWrapAlignment())
125 int widthInRes = seqPanel.seqCanvas
126 .getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());
127 vpRanges.setViewportWidth(widthInRes);
131 int widthInRes = seqPanel.seqCanvas.getWidth()
133 int heightInSeq = seqPanel.seqCanvas.getHeight()
134 / av.getCharHeight();
136 vpRanges.setViewportWidth(widthInRes);
137 vpRanges.setViewportHeight(heightInSeq);
139 // setScrollValues(vpRanges.getStartRes(), vpRanges.getStartSeq());
140 if (getSize().height > 0
141 && annotationPanelHolder.getSize().height > 0)
143 validateAnnotationDimensions(false);
150 Dimension d = calculateIdWidth();
151 idPanel.idCanvas.setSize(d);
153 hscrollFillerPanel.setSize(d.width, annotationPanel.getSize().height);
155 idPanel.idCanvas.setSize(d.width, seqPanel.seqCanvas.getSize().height);
156 annotationSpaceFillerHolder.setSize(d.width,
157 annotationPanel.getSize().height);
158 alabels.setSize(d.width, annotationPanel.getSize().height);
159 final AlignmentPanel ap = this;
160 av.addPropertyChangeListener(new java.beans.PropertyChangeListener()
163 public void propertyChange(java.beans.PropertyChangeEvent evt)
165 if (evt.getPropertyName().equals("alignment"))
167 PaintRefresher.Refresh(ap, av.getSequenceSetId(), true, true);
172 av.getRanges().addPropertyChangeListener(this);
176 public AlignViewportI getAlignViewport()
181 public SequenceRendererI getSequenceRenderer()
183 return seqPanel.seqCanvas.sr;
187 public jalview.api.FeatureRenderer getFeatureRenderer()
189 return seqPanel.seqCanvas.fr;
193 public jalview.api.FeatureRenderer cloneFeatureRenderer()
195 FeatureRenderer nfr = new FeatureRenderer(av);
196 nfr.transferSettings(seqPanel.seqCanvas.fr);
200 public void alignmentChanged()
202 av.alignmentChanged(this);
204 if (overviewPanel != null)
206 overviewPanel.updateOverviewImage();
209 alignFrame.updateEditMenuBar();
214 public void fontChanged()
216 // set idCanvas bufferedImage to null
217 // to prevent drawing old image
218 idPanel.idCanvas.image = null;
219 FontMetrics fm = getFontMetrics(av.getFont());
222 new Dimension(10, av.getCharHeight() + fm.getDescent()));
223 idwidthAdjuster.setSize(
224 new Dimension(10, av.getCharHeight() + fm.getDescent()));
225 av.updateSequenceIdColours();
226 annotationPanel.image = null;
227 int ap = annotationPanel.adjustPanelHeight(false);
228 Dimension d = calculateIdWidth();
229 d.setSize(d.width + 4, seqPanel.seqCanvas.getSize().height);
230 alabels.setSize(d.width + 4, ap);
232 idPanel.idCanvas.setSize(d);
233 hscrollFillerPanel.setSize(d);
235 validateAnnotationDimensions(false);
236 annotationPanel.repaint();
241 public void setIdWidth(int w, int h)
243 idPanel.idCanvas.setSize(w, h);
244 idPanelHolder.setSize(w, idPanelHolder.getSize().height);
245 annotationSpaceFillerHolder.setSize(w,
246 annotationSpaceFillerHolder.getSize().height);
247 alabels.setSize(w, alabels.getSize().height);
251 Dimension calculateIdWidth()
253 if (av.nullFrame == null)
255 av.nullFrame = new Frame();
256 av.nullFrame.addNotify();
259 Graphics g = av.nullFrame.getGraphics();
261 FontMetrics fm = g.getFontMetrics(av.font);
262 AlignmentI al = av.getAlignment();
267 while (i < al.getHeight() && al.getSequenceAt(i) != null)
269 SequenceI s = al.getSequenceAt(i);
270 id = s.getDisplayId(av.getShowJVSuffix());
272 if (fm.stringWidth(id) > idWidth)
274 idWidth = fm.stringWidth(id);
279 // Also check annotation label widths
281 if (al.getAlignmentAnnotation() != null)
283 fm = g.getFontMetrics(av.nullFrame.getFont());
284 while (i < al.getAlignmentAnnotation().length)
286 String label = al.getAlignmentAnnotation()[i].label;
287 if (fm.stringWidth(label) > idWidth)
289 idWidth = fm.stringWidth(label);
295 return new Dimension(idWidth, idPanel.idCanvas.getSize().height);
299 * Highlight the given results on the alignment.
302 public void highlightSearchResults(SearchResultsI results)
304 scrollToPosition(results);
305 seqPanel.seqCanvas.highlightSearchResults(results);
309 * scroll the view to show the position of the highlighted region in results
310 * (if any) and redraw the overview
313 * @return false if results were not found
315 public boolean scrollToPosition(SearchResultsI results)
317 return scrollToPosition(results, true);
321 * scroll the view to show the position of the highlighted region in results
325 * @param redrawOverview
326 * - when set, the overview will be recalculated (takes longer)
327 * @return false if results were not found
329 public boolean scrollToPosition(SearchResultsI results,
330 boolean redrawOverview)
332 return scrollToPosition(results, 0, redrawOverview, false);
336 * scroll the view to show the position of the highlighted region in results
340 * @param redrawOverview
341 * - when set, the overview will be recalculated (takes longer)
342 * @return false if results were not found
344 public boolean scrollToPosition(SearchResultsI results,
345 int verticalOffset, boolean redrawOverview, boolean centre)
347 // do we need to scroll the panel?
348 if (results != null && results.getSize() > 0)
350 AlignmentI alignment = av.getAlignment();
351 int seqIndex = alignment.findIndex(results);
357 * allow for offset of target sequence (actually scroll to one above it)
360 SequenceI seq = alignment.getSequenceAt(seqIndex);
361 int[] r = results.getResults(seq, 0, alignment.getWidth());
364 if (JalviewLite.debug)
367 "DEBUG: scroll didn't happen - results not within alignment : "
368 + seq.getStart() + "," + seq.getEnd());
372 if (JalviewLite.debug)
376 * System.out.println("DEBUG: scroll: start=" + r[0] +
377 * " av.getStartRes()=" + av.getStartRes() + " end=" + r[1] +
378 * " seq.end=" + seq.getEnd() + " av.getEndRes()=" + av.getEndRes() +
379 * " hextent=" + hextent);
386 * To centre results, scroll to positions half the visible width
387 * left/right of the start/end positions
391 int offset = (vpRanges.getEndRes() - vpRanges.getStartRes() + 1) / 2
393 start = Math.max(start - offset, 0);
394 end = end + offset - 1;
395 // end = Math.min(end + offset, seq.getEnd() - 1);
402 if (end == seq.getEnd())
408 * allow for offset of target sequence (actually scroll to one above it)
410 seqIndex = Math.max(0, seqIndex - verticalOffset);
411 return scrollTo(start, end, seqIndex, false, redrawOverview);
416 public boolean scrollTo(int ostart, int end, int seqIndex,
417 boolean scrollToNearest, boolean redrawOverview)
419 int startv, endv, starts, ends, width;
422 if (av.hasHiddenColumns())
424 AlignmentI al = av.getAlignment();
425 start = al.getHiddenColumns().absoluteToVisibleColumn(ostart);
426 end = al.getHiddenColumns().absoluteToVisibleColumn(end);
429 if (!scrollToNearest && !al.getHiddenColumns().isVisible(ostart))
431 // don't scroll - position isn't visible
441 if (!av.getWrapAlignment())
444 * int spos=av.getStartRes(),sqpos=av.getStartSeq(); if ((startv =
445 * av.getStartRes()) >= start) { spos=start-1; // seqIn //
446 * setScrollValues(start - 1, seqIndex); } else if ((endv =
447 * av.getEndRes()) <= end) { // setScrollValues(spos=startv + 1 + end -
448 * endv, seqIndex); spos=startv + 1 + end - endv; } else if ((starts =
449 * av.getStartSeq()) > seqIndex) { setScrollValues(av.getStartRes(),
450 * seqIndex); } else if ((ends = av.getEndSeq()) <= seqIndex) {
451 * setScrollValues(av.getStartRes(), starts + seqIndex - ends + 1); }
454 // below is scrolling logic up to Jalview 2.8.2
455 // if ((av.getStartRes() > end)
456 // || (av.getEndRes() < start)
457 // || ((av.getStartSeq() > seqIndex) || (av.getEndSeq() < seqIndex)))
459 // if (start > av.getAlignment().getWidth() - hextent)
461 // start = av.getAlignment().getWidth() - hextent;
468 // if (seqIndex > av.getAlignment().getHeight() - vextent)
470 // seqIndex = av.getAlignment().getHeight() - vextent;
476 // setScrollValues(start, seqIndex);
478 // logic copied from jalview.gui.AlignmentPanel:
479 if ((startv = vpRanges.getStartRes()) >= start)
482 * Scroll left to make start of search results visible
484 setScrollValues(start - 1, seqIndex);
486 else if ((endv = vpRanges.getEndRes()) <= end)
489 * Scroll right to make end of search results visible
491 setScrollValues(startv + 1 + end - endv, seqIndex);
493 else if ((starts = vpRanges.getStartSeq()) > seqIndex)
496 * Scroll up to make start of search results visible
498 setScrollValues(vpRanges.getStartRes(), seqIndex);
500 else if ((ends = vpRanges.getEndSeq()) <= seqIndex)
503 * Scroll down to make end of search results visible
505 setScrollValues(vpRanges.getStartRes(),
506 starts + seqIndex - ends + 1);
509 * Else results are already visible - no need to scroll
514 vpRanges.scrollToWrappedVisible(start);
517 paintAlignment(redrawOverview, false);
521 public OverviewPanel getOverviewPanel()
523 return overviewPanel;
526 public void setOverviewPanel(OverviewPanel op)
531 public void setAnnotationVisible(boolean b)
533 if (!av.getWrapAlignment())
535 annotationSpaceFillerHolder.setVisible(b);
536 annotationPanelHolder.setVisible(b);
540 annotationSpaceFillerHolder.setVisible(false);
541 annotationPanelHolder.setVisible(false);
548 * automatically adjust annotation panel height for new annotation whilst
549 * ensuring the alignment is still visible.
552 public void adjustAnnotationHeight()
554 // TODO: display vertical annotation scrollbar if necessary
555 // this is called after loading new annotation onto alignment
556 if (alignFrame.getSize().height == 0)
559 "adjustAnnotationHeight frame size zero NEEDS FIXING");
562 validateAnnotationDimensions(true);
563 apvscroll.addNotify();
566 paintAlignment(true, false);
570 * Calculate the annotation dimensions and refresh slider values accordingly.
571 * Need to do repaints/notifys afterwards.
573 protected void validateAnnotationDimensions(boolean adjustPanelHeight)
575 int rowHeight = av.getCharHeight();
576 int alignmentHeight = rowHeight * av.getAlignment().getHeight();
577 int annotationHeight = av.calcPanelHeight();
579 int mheight = annotationHeight;
580 Dimension d = sequenceHolderPanel.getSize();
582 int availableHeight = d.height - scalePanelHolder.getHeight();
584 if (adjustPanelHeight)
587 * If not enough vertical space, maximize annotation height while keeping
588 * at least two rows of alignment visible
590 if (annotationHeight + alignmentHeight > availableHeight)
592 annotationHeight = Math.min(annotationHeight,
593 availableHeight - 2 * rowHeight);
598 // maintain same window layout whilst updating sliders
599 annotationHeight = annotationPanelHolder.getSize().height;
602 if (availableHeight - annotationHeight < 5)
604 annotationHeight = availableHeight;
607 annotationPanel.setSize(new Dimension(d.width, annotationHeight));
608 annotationPanelHolder.setSize(new Dimension(d.width, annotationHeight));
609 // seqPanelHolder.setSize(d.width, seqandannot - height);
610 seqPanel.seqCanvas.setSize(d.width,
611 seqPanel.seqCanvas.getSize().height);
613 Dimension e = idPanel.getSize();
614 alabels.setSize(new Dimension(e.width, annotationHeight));
615 annotationSpaceFillerHolder
616 .setSize(new Dimension(e.width, annotationHeight));
618 int s = apvscroll.getValue();
619 if (s > mheight - annotationHeight)
623 apvscroll.setValues(s, annotationHeight, 0, mheight);
624 annotationPanel.setScrollOffset(apvscroll.getValue(), false);
625 alabels.setScrollOffset(apvscroll.getValue(), false);
628 public void setWrapAlignment(boolean wrap)
630 vpRanges.setStartEndSeq(0, vpRanges.getVisibleAlignmentHeight());
631 vpRanges.setStartRes(0);
632 scalePanelHolder.setVisible(!wrap);
634 hscroll.setVisible(!wrap);
635 idwidthAdjuster.setVisible(!wrap);
639 annotationPanelHolder.setVisible(false);
640 annotationSpaceFillerHolder.setVisible(false);
642 else if (av.isShowAnnotation())
644 annotationPanelHolder.setVisible(true);
645 annotationSpaceFillerHolder.setVisible(true);
648 idSpaceFillerPanel1.setVisible(!wrap);
650 fontChanged(); // This is so that the scalePanel is resized correctly
653 sequenceHolderPanel.validate();
662 public void setScrollValues(int xpos, int ypos)
667 if (av.getWrapAlignment())
669 setScrollingForWrappedPanel(x);
673 int width = av.getAlignment().getWidth();
674 int height = av.getAlignment().getHeight();
676 if (av.hasHiddenColumns())
678 width = av.getAlignment().getHiddenColumns()
679 .absoluteToVisibleColumn(width);
686 hextent = seqPanel.seqCanvas.getSize().width / av.getCharWidth();
687 vextent = seqPanel.seqCanvas.getSize().height / av.getCharHeight();
694 if (vextent > height)
699 if ((hextent + x) > width)
701 System.err.println("hextent was " + hextent + " and x was " + x);
706 if ((vextent + y) > height)
708 y = height - vextent;
718 System.err.println("x was " + x);
722 hscroll.setValues(x, hextent, 0, width);
723 vscroll.setValues(y, vextent, 0, height);
725 // AWT scrollbar does not fire adjustmentValueChanged for setValues
726 // so also call adjustment code!
735 * Respond to adjustment event when horizontal or vertical scrollbar is
739 * adjustment event encoding whether apvscroll, hscroll or vscroll
743 public void adjustmentValueChanged(AdjustmentEvent evt)
745 // Note that this event is NOT fired by the AWT scrollbar when setValues is
746 // called. Instead manually call adjustHorizontal and adjustVertical
748 if (evt == null || evt.getSource() == apvscroll)
750 annotationPanel.setScrollOffset(apvscroll.getValue(), false);
751 alabels.setScrollOffset(apvscroll.getValue(), false);
753 if (evt == null || evt.getSource() == hscroll)
755 int x = hscroll.getValue();
759 if (evt == null || evt.getSource() == vscroll)
761 int offy = vscroll.getValue();
762 adjustVertical(offy);
767 private void adjustHorizontal(int x)
769 int oldX = vpRanges.getStartRes();
770 int oldwidth = vpRanges.getViewportWidth();
771 int width = seqPanel.seqCanvas.getWidth() / av.getCharWidth();
773 // if we're scrolling to the position we're already at, stop
774 // this prevents infinite recursion of events when the scroll/viewport
775 // ranges values are the same
776 if ((x == oldX) && (width == oldwidth))
780 vpRanges.setViewportStartAndWidth(x, width);
782 if (av.getWrapAlignment() || !fastPaint)
789 private void adjustVertical(int newY)
791 if (av.getWrapAlignment())
794 * if we're scrolling to the position we're already at, stop
795 * this prevents infinite recursion of events when the scroll/viewport
796 * ranges values are the same
798 int oldX = vpRanges.getStartRes();
799 int oldY = vpRanges.getWrappedScrollPosition(oldX);
807 * limit page up/down to one width's worth of positions
809 int rowSize = vpRanges.getViewportWidth();
810 int newX = newY > oldY ? oldX + rowSize : oldX - rowSize;
811 vpRanges.setViewportStartAndWidth(Math.max(0, newX), rowSize);
816 int height = seqPanel.seqCanvas.getHeight() / av.getCharHeight();
817 int oldY = vpRanges.getStartSeq();
818 int oldheight = vpRanges.getViewportHeight();
820 // if we're scrolling to the position we're already at, stop
821 // this prevents infinite recursion of events when the scroll/viewport
822 // ranges values are the same
823 if ((newY == oldY) && (height == oldheight))
827 vpRanges.setViewportStartAndHeight(newY, height);
829 if (av.getWrapAlignment() || !fastPaint)
837 * A helper method to return the AlignmentPanel in the other (complementary)
838 * half of a SplitFrame view. Returns null if not in a SplitFrame.
842 private AlignmentPanel getComplementPanel()
844 AlignmentPanel ap = null;
845 if (alignFrame != null)
847 SplitFrame sf = alignFrame.getSplitFrame();
850 AlignFrame other = sf.getComplement(alignFrame);
853 ap = other.alignPanel;
861 * Follow a scrolling change in the (cDNA/Protein) complementary alignment.
862 * The aim is to keep the two alignments 'lined up' on their centre columns.
865 * holds mapped region(s) of this alignment that we are scrolling
866 * 'to'; may be modified for sequence offset by this method
868 * the number of visible sequences to show above the mapped region
870 protected void scrollToCentre(SearchResultsI sr, int seqOffset)
873 * To avoid jumpy vertical scrolling (if some sequences are gapped or not
874 * mapped), we can make the scroll-to location a sequence above the one
877 SequenceI mappedTo = sr.getResults().get(0).getSequence();
878 List<SequenceI> seqs = av.getAlignment().getSequences();
881 * This is like AlignmentI.findIndex(seq) but here we are matching the
882 * dataset sequence not the aligned sequence
884 boolean matched = false;
885 for (SequenceI seq : seqs)
887 if (mappedTo == seq.getDatasetSequence())
895 return; // failsafe, shouldn't happen
899 * Scroll to position but centring the target residue. Also set a state flag
900 * to prevent adjustmentValueChanged performing this recursively.
902 scrollToPosition(sr, seqOffset, true, true);
905 private void sendViewPosition()
907 StructureSelectionManager.getStructureSelectionManager(av.applet)
908 .sendViewPosition(this, vpRanges.getStartRes(),
909 vpRanges.getEndRes(), vpRanges.getStartSeq(),
910 vpRanges.getEndSeq());
914 * Repaint the alignment and annotations, and, optionally, any overview window
917 public void paintAlignment(boolean updateOverview,
918 boolean updateStructures)
920 final AnnotationSorter sorter = new AnnotationSorter(getAlignment(),
921 av.isShowAutocalculatedAbove());
922 sorter.sort(getAlignment().getAlignmentAnnotation(),
923 av.getSortAnnotationsBy());
926 if (updateStructures)
928 jalview.structure.StructureSelectionManager
929 .getStructureSelectionManager(av.applet)
930 .sequenceColoursChanged(this);
934 if (overviewPanel != null)
936 overviewPanel.updateOverviewImage();
942 public void update(Graphics g)
948 public void paint(Graphics g)
951 Dimension d = idPanel.idCanvas.getSize();
952 final int canvasHeight = seqPanel.seqCanvas.getSize().height;
953 if (canvasHeight != d.height)
955 idPanel.idCanvas.setSize(d.width, canvasHeight);
958 setScrollValues(vpRanges.getStartRes(), vpRanges.getStartSeq());
960 seqPanel.seqCanvas.repaint();
961 idPanel.idCanvas.repaint();
962 if (!av.getWrapAlignment())
964 if (av.isShowAnnotation())
967 annotationPanel.repaint();
969 scalePanel.repaint();
975 * Set vertical scroll bar parameters for wrapped panel
977 * @param topLeftColumn
978 * the column position at top left (0..)
980 private void setScrollingForWrappedPanel(int topLeftColumn)
982 int scrollPosition = vpRanges.getWrappedScrollPosition(topLeftColumn);
983 int maxScroll = vpRanges.getWrappedMaxScroll(topLeftColumn);
986 * a scrollbar's value can be set to at most (maximum-extent)
987 * so we add extent (1) to the maxScroll value
989 vscroll.setUnitIncrement(1);
990 vscroll.setValues(scrollPosition, 1, 0, maxScroll + 1);
993 protected Panel sequenceHolderPanel = new Panel();
995 protected Scrollbar vscroll = new Scrollbar();
997 protected Scrollbar hscroll = new Scrollbar();
999 protected Panel seqPanelHolder = new Panel();
1001 protected Panel scalePanelHolder = new Panel();
1003 protected Panel idPanelHolder = new Panel();
1005 protected Panel idSpaceFillerPanel1 = new Panel();
1007 public Panel annotationSpaceFillerHolder = new Panel();
1009 protected Panel hscrollFillerPanel = new Panel();
1011 Panel annotationPanelHolder = new Panel();
1013 protected Scrollbar apvscroll = new Scrollbar();
1016 * Flag set while scrolling to follow complementary cDNA/protein scroll. When
1017 * false, suppresses invoking the same method recursively.
1019 private boolean scrollComplementaryPanel = true;
1021 private void jbInit() throws Exception
1023 // idPanelHolder.setPreferredSize(new Dimension(70, 10));
1024 this.setLayout(new BorderLayout());
1026 // sequenceHolderPanel.setPreferredSize(new Dimension(150, 150));
1027 sequenceHolderPanel.setLayout(new BorderLayout());
1028 seqPanelHolder.setLayout(new BorderLayout());
1029 scalePanelHolder.setBackground(Color.white);
1031 // scalePanelHolder.setPreferredSize(new Dimension(10, 30));
1032 scalePanelHolder.setLayout(new BorderLayout());
1033 idPanelHolder.setLayout(new BorderLayout());
1034 idSpaceFillerPanel1.setBackground(Color.white);
1036 // idSpaceFillerPanel1.setPreferredSize(new Dimension(10, 30));
1037 idSpaceFillerPanel1.setLayout(new BorderLayout());
1038 annotationSpaceFillerHolder.setBackground(Color.white);
1040 // annotationSpaceFillerHolder.setPreferredSize(new Dimension(10, 80));
1041 annotationSpaceFillerHolder.setLayout(new BorderLayout());
1042 hscroll.setOrientation(Scrollbar.HORIZONTAL);
1044 Panel hscrollHolder = new Panel();
1045 hscrollHolder.setLayout(new BorderLayout());
1046 hscrollFillerPanel.setBackground(Color.white);
1047 apvscroll.setOrientation(Scrollbar.VERTICAL);
1048 apvscroll.setVisible(true);
1049 apvscroll.addAdjustmentListener(this);
1051 annotationPanelHolder.setBackground(Color.white);
1052 annotationPanelHolder.setLayout(new BorderLayout());
1053 annotationPanelHolder.add(apvscroll, BorderLayout.EAST);
1054 // hscrollFillerPanel.setPreferredSize(new Dimension(70, 10));
1055 hscrollHolder.setBackground(Color.white);
1057 // annotationScroller.setPreferredSize(new Dimension(10, 80));
1058 // this.setPreferredSize(new Dimension(220, 166));
1059 seqPanelHolder.setBackground(Color.white);
1060 idPanelHolder.setBackground(Color.white);
1061 sequenceHolderPanel.add(scalePanelHolder, BorderLayout.NORTH);
1062 sequenceHolderPanel.add(seqPanelHolder, BorderLayout.CENTER);
1063 seqPanelHolder.add(vscroll, BorderLayout.EAST);
1065 // Panel3.add(secondaryPanelHolder, BorderLayout.SOUTH);
1066 this.add(idPanelHolder, BorderLayout.WEST);
1067 idPanelHolder.add(idSpaceFillerPanel1, BorderLayout.NORTH);
1068 idPanelHolder.add(annotationSpaceFillerHolder, BorderLayout.SOUTH);
1069 this.add(hscrollHolder, BorderLayout.SOUTH);
1070 hscrollHolder.add(hscroll, BorderLayout.CENTER);
1071 hscrollHolder.add(hscrollFillerPanel, BorderLayout.WEST);
1072 this.add(sequenceHolderPanel, BorderLayout.CENTER);
1076 * hides or shows dynamic annotation rows based on groups and av state flags
1078 public void updateAnnotation()
1080 updateAnnotation(false);
1083 public void updateAnnotation(boolean applyGlobalSettings)
1085 updateAnnotation(applyGlobalSettings, false);
1088 public void updateAnnotation(boolean applyGlobalSettings,
1089 boolean preserveNewGroupSettings)
1091 av.updateGroupAnnotationSettings(applyGlobalSettings,
1092 preserveNewGroupSettings);
1093 adjustAnnotationHeight();
1097 public AlignmentI getAlignment()
1099 return av.getAlignment();
1103 public String getViewName()
1109 public StructureSelectionManager getStructureSelectionManager()
1111 return StructureSelectionManager
1112 .getStructureSelectionManager(av.applet);
1116 public void raiseOOMWarning(String string, OutOfMemoryError error)
1119 System.err.println("Out of memory whilst '" + string + "'");
1120 error.printStackTrace();
1124 * Set a flag to say we are scrolling to follow a (cDNA/protein) complement.
1128 protected void setToScrollComplementPanel(boolean b)
1130 this.scrollComplementaryPanel = b;
1134 * Get whether to scroll complement panel
1136 * @return true if cDNA/protein complement panels should be scrolled
1138 protected boolean isSetToScrollComplementPanel()
1140 return this.scrollComplementaryPanel;
1145 * Property change event fired when a change is made to the viewport ranges
1146 * object associated with this alignment panel's viewport
1148 public void propertyChange(PropertyChangeEvent evt)
1150 // update this panel's scroll values based on the new viewport ranges values
1151 int x = vpRanges.getStartRes();
1152 int y = vpRanges.getStartSeq();
1153 setScrollValues(x, y);
1155 // now update any complementary alignment (its viewport ranges object
1156 // is different so does not get automatically updated)
1157 if (isSetToScrollComplementPanel())
1159 setToScrollComplementPanel(false);
1160 av.scrollComplementaryAlignment(getComplementPanel());
1161 setToScrollComplementPanel(true);