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.SearchResultsI;
29 import jalview.datamodel.SequenceI;
30 import jalview.structure.StructureSelectionManager;
31 import jalview.viewmodel.ViewportListenerI;
32 import jalview.viewmodel.ViewportRanges;
34 import java.awt.BorderLayout;
35 import java.awt.Color;
36 import java.awt.Dimension;
37 import java.awt.FontMetrics;
38 import java.awt.Frame;
39 import java.awt.Graphics;
40 import java.awt.Panel;
41 import java.awt.Scrollbar;
42 import java.awt.event.AdjustmentEvent;
43 import java.awt.event.AdjustmentListener;
44 import java.awt.event.ComponentAdapter;
45 import java.awt.event.ComponentEvent;
46 import java.beans.PropertyChangeEvent;
47 import java.util.List;
49 @SuppressWarnings("serial")
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 SequenceRenderer 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.getCount() > 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().getVisibleWidth();
674 int height = av.getAlignment().getHeight();
681 hextent = seqPanel.seqCanvas.getSize().width / av.getCharWidth();
682 vextent = seqPanel.seqCanvas.getSize().height / av.getCharHeight();
689 if (vextent > height)
694 if ((hextent + x) > width)
696 System.err.println("hextent was " + hextent + " and x was " + x);
701 if ((vextent + y) > height)
703 y = height - vextent;
713 System.err.println("x was " + x);
717 hscroll.setValues(x, hextent, 0, width);
718 vscroll.setValues(y, vextent, 0, height);
720 // AWT scrollbar does not fire adjustmentValueChanged for setValues
721 // so also call adjustment code!
730 * Respond to adjustment event when horizontal or vertical scrollbar is
734 * adjustment event encoding whether apvscroll, hscroll or vscroll
738 public void adjustmentValueChanged(AdjustmentEvent evt)
740 // Note that this event is NOT fired by the AWT scrollbar when setValues is
741 // called. Instead manually call adjustHorizontal and adjustVertical
743 if (evt == null || evt.getSource() == apvscroll)
745 annotationPanel.setScrollOffset(apvscroll.getValue(), false);
746 alabels.setScrollOffset(apvscroll.getValue(), false);
748 if (evt == null || evt.getSource() == hscroll)
750 int x = hscroll.getValue();
754 if (evt == null || evt.getSource() == vscroll)
756 int offy = vscroll.getValue();
757 adjustVertical(offy);
762 private void adjustHorizontal(int x)
764 int oldX = vpRanges.getStartRes();
765 int oldwidth = vpRanges.getViewportWidth();
766 int width = seqPanel.seqCanvas.getWidth() / av.getCharWidth();
768 // if we're scrolling to the position we're already at, stop
769 // this prevents infinite recursion of events when the scroll/viewport
770 // ranges values are the same
771 if ((x == oldX) && (width == oldwidth))
775 vpRanges.setViewportStartAndWidth(x, width);
777 if (av.getWrapAlignment() || !fastPaint)
784 private void adjustVertical(int newY)
786 if (av.getWrapAlignment())
789 * if we're scrolling to the position we're already at, stop
790 * this prevents infinite recursion of events when the scroll/viewport
791 * ranges values are the same
793 int oldX = vpRanges.getStartRes();
794 int oldY = vpRanges.getWrappedScrollPosition(oldX);
802 * limit page up/down to one width's worth of positions
804 int rowSize = vpRanges.getViewportWidth();
805 int newX = newY > oldY ? oldX + rowSize : oldX - rowSize;
806 vpRanges.setViewportStartAndWidth(Math.max(0, newX), rowSize);
811 int height = seqPanel.seqCanvas.getHeight() / av.getCharHeight();
812 int oldY = vpRanges.getStartSeq();
813 int oldheight = vpRanges.getViewportHeight();
815 // if we're scrolling to the position we're already at, stop
816 // this prevents infinite recursion of events when the scroll/viewport
817 // ranges values are the same
818 if ((newY == oldY) && (height == oldheight))
822 vpRanges.setViewportStartAndHeight(newY, height);
824 if (av.getWrapAlignment() || !fastPaint)
832 * A helper method to return the AlignmentPanel in the other (complementary)
833 * half of a SplitFrame view. Returns null if not in a SplitFrame.
837 private AlignmentPanel getComplementPanel()
839 AlignmentPanel ap = null;
840 if (alignFrame != null)
842 SplitFrame sf = alignFrame.getSplitFrame();
845 AlignFrame other = sf.getComplement(alignFrame);
848 ap = other.alignPanel;
856 * Follow a scrolling change in the (cDNA/Protein) complementary alignment.
857 * The aim is to keep the two alignments 'lined up' on their centre columns.
860 * holds mapped region(s) of this alignment that we are scrolling
861 * 'to'; may be modified for sequence offset by this method
863 * the number of visible sequences to show above the mapped region
865 protected void scrollToCentre(SearchResultsI sr, int seqOffset)
868 * To avoid jumpy vertical scrolling (if some sequences are gapped or not
869 * mapped), we can make the scroll-to location a sequence above the one
872 SequenceI mappedTo = sr.getResults().get(0).getSequence();
873 List<SequenceI> seqs = av.getAlignment().getSequences();
876 * This is like AlignmentI.findIndex(seq) but here we are matching the
877 * dataset sequence not the aligned sequence
879 boolean matched = false;
880 for (SequenceI seq : seqs)
882 if (mappedTo == seq.getDatasetSequence())
890 return; // failsafe, shouldn't happen
894 * Scroll to position but centring the target residue. Also set a state flag
895 * to prevent adjustmentValueChanged performing this recursively.
897 scrollToPosition(sr, seqOffset, true, true);
900 private void sendViewPosition()
902 StructureSelectionManager.getStructureSelectionManager(av.applet)
903 .sendViewPosition(this, vpRanges.getStartRes(),
904 vpRanges.getEndRes(), vpRanges.getStartSeq(),
905 vpRanges.getEndSeq());
909 * Repaint the alignment and annotations, and, optionally, any overview window
912 public void paintAlignment(boolean updateOverview,
913 boolean updateStructures)
915 final AnnotationSorter sorter = new AnnotationSorter(getAlignment(),
916 av.isShowAutocalculatedAbove());
917 sorter.sort(getAlignment().getAlignmentAnnotation(),
918 av.getSortAnnotationsBy());
921 if (updateStructures)
923 jalview.structure.StructureSelectionManager
924 .getStructureSelectionManager(av.applet)
925 .sequenceColoursChanged(this);
929 if (overviewPanel != null)
931 overviewPanel.updateOverviewImage();
937 public void update(Graphics g)
943 public void paint(Graphics g)
946 Dimension d = idPanel.idCanvas.getSize();
947 final int canvasHeight = seqPanel.seqCanvas.getSize().height;
948 if (canvasHeight != d.height)
950 idPanel.idCanvas.setSize(d.width, canvasHeight);
953 setScrollValues(vpRanges.getStartRes(), vpRanges.getStartSeq());
955 seqPanel.seqCanvas.repaint();
956 idPanel.idCanvas.repaint();
957 if (!av.getWrapAlignment())
959 if (av.isShowAnnotation())
962 annotationPanel.repaint();
964 scalePanel.repaint();
970 * Set vertical scroll bar parameters for wrapped panel
972 * @param topLeftColumn
973 * the column position at top left (0..)
975 private void setScrollingForWrappedPanel(int topLeftColumn)
977 int scrollPosition = vpRanges.getWrappedScrollPosition(topLeftColumn);
978 int maxScroll = vpRanges.getWrappedMaxScroll(topLeftColumn);
981 * a scrollbar's value can be set to at most (maximum-extent)
982 * so we add extent (1) to the maxScroll value
984 vscroll.setUnitIncrement(1);
985 vscroll.setValues(scrollPosition, 1, 0, maxScroll + 1);
988 protected Panel sequenceHolderPanel = new Panel();
990 protected Scrollbar vscroll = new Scrollbar();
992 protected Scrollbar hscroll = new Scrollbar();
994 protected Panel seqPanelHolder = new Panel();
996 protected Panel scalePanelHolder = new Panel();
998 protected Panel idPanelHolder = new Panel();
1000 protected Panel idSpaceFillerPanel1 = new Panel();
1002 public Panel annotationSpaceFillerHolder = new Panel();
1004 protected Panel hscrollFillerPanel = new Panel();
1006 Panel annotationPanelHolder = new Panel();
1008 protected Scrollbar apvscroll = new Scrollbar();
1011 * Flag set while scrolling to follow complementary cDNA/protein scroll. When
1012 * false, suppresses invoking the same method recursively.
1014 private boolean scrollComplementaryPanel = true;
1016 private void jbInit() throws Exception
1018 // idPanelHolder.setPreferredSize(new Dimension(70, 10));
1019 this.setLayout(new BorderLayout());
1021 // sequenceHolderPanel.setPreferredSize(new Dimension(150, 150));
1022 sequenceHolderPanel.setLayout(new BorderLayout());
1023 seqPanelHolder.setLayout(new BorderLayout());
1024 scalePanelHolder.setBackground(Color.white);
1026 // scalePanelHolder.setPreferredSize(new Dimension(10, 30));
1027 scalePanelHolder.setLayout(new BorderLayout());
1028 idPanelHolder.setLayout(new BorderLayout());
1029 idSpaceFillerPanel1.setBackground(Color.white);
1031 // idSpaceFillerPanel1.setPreferredSize(new Dimension(10, 30));
1032 idSpaceFillerPanel1.setLayout(new BorderLayout());
1033 annotationSpaceFillerHolder.setBackground(Color.white);
1035 // annotationSpaceFillerHolder.setPreferredSize(new Dimension(10, 80));
1036 annotationSpaceFillerHolder.setLayout(new BorderLayout());
1037 hscroll.setOrientation(Scrollbar.HORIZONTAL);
1039 Panel hscrollHolder = new Panel();
1040 hscrollHolder.setLayout(new BorderLayout());
1041 hscrollFillerPanel.setBackground(Color.white);
1042 apvscroll.setOrientation(Scrollbar.VERTICAL);
1043 apvscroll.setVisible(true);
1044 apvscroll.addAdjustmentListener(this);
1046 annotationPanelHolder.setBackground(Color.white);
1047 annotationPanelHolder.setLayout(new BorderLayout());
1048 annotationPanelHolder.add(apvscroll, BorderLayout.EAST);
1049 // hscrollFillerPanel.setPreferredSize(new Dimension(70, 10));
1050 hscrollHolder.setBackground(Color.white);
1052 // annotationScroller.setPreferredSize(new Dimension(10, 80));
1053 // this.setPreferredSize(new Dimension(220, 166));
1054 seqPanelHolder.setBackground(Color.white);
1055 idPanelHolder.setBackground(Color.white);
1056 sequenceHolderPanel.add(scalePanelHolder, BorderLayout.NORTH);
1057 sequenceHolderPanel.add(seqPanelHolder, BorderLayout.CENTER);
1058 seqPanelHolder.add(vscroll, BorderLayout.EAST);
1060 // Panel3.add(secondaryPanelHolder, BorderLayout.SOUTH);
1061 this.add(idPanelHolder, BorderLayout.WEST);
1062 idPanelHolder.add(idSpaceFillerPanel1, BorderLayout.NORTH);
1063 idPanelHolder.add(annotationSpaceFillerHolder, BorderLayout.SOUTH);
1064 this.add(hscrollHolder, BorderLayout.SOUTH);
1065 hscrollHolder.add(hscroll, BorderLayout.CENTER);
1066 hscrollHolder.add(hscrollFillerPanel, BorderLayout.WEST);
1067 this.add(sequenceHolderPanel, BorderLayout.CENTER);
1071 * hides or shows dynamic annotation rows based on groups and av state flags
1073 public void updateAnnotation()
1075 updateAnnotation(false);
1078 public void updateAnnotation(boolean applyGlobalSettings)
1080 updateAnnotation(applyGlobalSettings, false);
1083 public void updateAnnotation(boolean applyGlobalSettings,
1084 boolean preserveNewGroupSettings)
1086 av.updateGroupAnnotationSettings(applyGlobalSettings,
1087 preserveNewGroupSettings);
1088 adjustAnnotationHeight();
1092 public AlignmentI getAlignment()
1094 return av.getAlignment();
1098 public String getViewName()
1104 public StructureSelectionManager getStructureSelectionManager()
1106 return StructureSelectionManager
1107 .getStructureSelectionManager(av.applet);
1111 public void raiseOOMWarning(String string, OutOfMemoryError error)
1114 System.err.println("Out of memory whilst '" + string + "'");
1115 error.printStackTrace();
1119 * Set a flag to say we are scrolling to follow a (cDNA/protein) complement.
1123 protected void setToScrollComplementPanel(boolean b)
1125 this.scrollComplementaryPanel = b;
1129 * Get whether to scroll complement panel
1131 * @return true if cDNA/protein complement panels should be scrolled
1133 protected boolean isSetToScrollComplementPanel()
1135 return this.scrollComplementaryPanel;
1140 * Property change event fired when a change is made to the viewport ranges
1141 * object associated with this alignment panel's viewport
1143 public void propertyChange(PropertyChangeEvent evt)
1145 // update this panel's scroll values based on the new viewport ranges values
1146 int x = vpRanges.getStartRes();
1147 int y = vpRanges.getStartSeq();
1148 setScrollValues(x, y);
1150 // now update any complementary alignment (its viewport ranges object
1151 // is different so does not get automatically updated)
1152 if (isSetToScrollComplementPanel())
1154 setToScrollComplementPanel(false);
1155 av.scrollComplementaryAlignment(getComplementPanel());
1156 setToScrollComplementPanel(true);