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;
72 public void finalize() throws Throwable
77 seqPanelHolder = null;
78 sequenceHolderPanel = null;
80 scalePanelHolder = null;
81 annotationPanel = null;
82 annotationPanelHolder = null;
83 annotationSpaceFillerHolder = null;
87 public AlignmentPanel(AlignFrame af, final AlignViewport av)
99 seqPanel = new SeqPanel(av, this);
100 idPanel = new IdPanel(av, this);
101 scalePanel = new ScalePanel(av, this);
102 idwidthAdjuster = new IdwidthAdjuster(this);
103 annotationPanel = new AnnotationPanel(this);
104 annotationPanelHolder.add(annotationPanel, BorderLayout.CENTER);
106 sequenceHolderPanel.add(annotationPanelHolder, BorderLayout.SOUTH);
107 alabels = new AnnotationLabels(this);
109 setAnnotationVisible(av.isShowAnnotation());
111 idPanelHolder.add(idPanel, BorderLayout.CENTER);
112 idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER);
113 annotationSpaceFillerHolder.add(alabels, BorderLayout.CENTER);
114 scalePanelHolder.add(scalePanel, BorderLayout.CENTER);
115 seqPanelHolder.add(seqPanel, BorderLayout.CENTER);
118 setScrollValues(0, 0);
120 apvscroll.addAdjustmentListener(this);
121 hscroll.addAdjustmentListener(this);
122 vscroll.addAdjustmentListener(this);
124 addComponentListener(new ComponentAdapter()
127 public void componentResized(ComponentEvent evt)
129 setScrollValues(av.getStartRes(), av.getStartSeq());
130 if (getSize().height > 0
131 && annotationPanelHolder.getSize().height > 0)
133 validateAnnotationDimensions(false);
140 Dimension d = calculateIdWidth();
141 idPanel.idCanvas.setSize(d);
143 hscrollFillerPanel.setSize(d.width, annotationPanel.getSize().height);
145 idPanel.idCanvas.setSize(d.width, seqPanel.seqCanvas.getSize().height);
146 annotationSpaceFillerHolder.setSize(d.width,
147 annotationPanel.getSize().height);
148 alabels.setSize(d.width, annotationPanel.getSize().height);
149 final AlignmentPanel ap = this;
150 av.addPropertyChangeListener(new java.beans.PropertyChangeListener()
153 public void propertyChange(java.beans.PropertyChangeEvent evt)
155 if (evt.getPropertyName().equals("alignment"))
157 PaintRefresher.Refresh(ap, av.getSequenceSetId(), true, true);
165 public AlignViewportI getAlignViewport()
170 public SequenceRenderer getSequenceRenderer()
172 return seqPanel.seqCanvas.sr;
176 public jalview.api.FeatureRenderer getFeatureRenderer()
178 return seqPanel.seqCanvas.fr;
182 public jalview.api.FeatureRenderer cloneFeatureRenderer()
184 FeatureRenderer nfr = new FeatureRenderer(av);
185 nfr.transferSettings(seqPanel.seqCanvas.fr);
189 public void alignmentChanged()
191 av.alignmentChanged(this);
193 if (overviewPanel != null)
195 overviewPanel.updateOverviewImage();
198 alignFrame.updateEditMenuBar();
203 public void fontChanged()
205 // set idCanvas bufferedImage to null
206 // to prevent drawing old image
207 idPanel.idCanvas.image = null;
208 FontMetrics fm = getFontMetrics(av.getFont());
210 scalePanel.setSize(new Dimension(10, av.getCharHeight()
212 idwidthAdjuster.setSize(new Dimension(10, av.getCharHeight()
214 av.updateSequenceIdColours();
215 annotationPanel.image = null;
216 int ap = annotationPanel.adjustPanelHeight(false);
217 Dimension d = calculateIdWidth();
218 d.setSize(d.width + 4, seqPanel.seqCanvas.getSize().height);
219 alabels.setSize(d.width + 4, ap);
221 idPanel.idCanvas.setSize(d);
222 hscrollFillerPanel.setSize(d);
224 validateAnnotationDimensions(false);
225 annotationPanel.repaint();
229 if (overviewPanel != null)
231 overviewPanel.updateOverviewImage();
235 public void setIdWidth(int w, int h)
237 idPanel.idCanvas.setSize(w, h);
238 idPanelHolder.setSize(w, idPanelHolder.getSize().height);
239 annotationSpaceFillerHolder.setSize(w,
240 annotationSpaceFillerHolder.getSize().height);
241 alabels.setSize(w, alabels.getSize().height);
245 Dimension calculateIdWidth()
247 if (av.nullFrame == null)
249 av.nullFrame = new Frame();
250 av.nullFrame.addNotify();
253 Graphics g = av.nullFrame.getGraphics();
255 FontMetrics fm = g.getFontMetrics(av.font);
256 AlignmentI al = av.getAlignment();
261 while (i < al.getHeight() && al.getSequenceAt(i) != null)
263 SequenceI s = al.getSequenceAt(i);
264 id = s.getDisplayId(av.getShowJVSuffix());
266 if (fm.stringWidth(id) > idWidth)
268 idWidth = fm.stringWidth(id);
273 // Also check annotation label widths
275 if (al.getAlignmentAnnotation() != null)
277 fm = g.getFontMetrics(av.nullFrame.getFont());
278 while (i < al.getAlignmentAnnotation().length)
280 String label = al.getAlignmentAnnotation()[i].label;
281 if (fm.stringWidth(label) > idWidth)
283 idWidth = fm.stringWidth(label);
289 return new Dimension(idWidth, idPanel.idCanvas.getSize().height);
293 * Highlight the given results on the alignment.
296 public void highlightSearchResults(SearchResults results)
298 scrollToPosition(results);
299 seqPanel.seqCanvas.highlightSearchResults(results);
303 * scroll the view to show the position of the highlighted region in results
304 * (if any) and redraw the overview
307 * @return false if results were not found
309 public boolean scrollToPosition(SearchResults results)
311 return scrollToPosition(results, true);
315 * scroll the view to show the position of the highlighted region in results
319 * @param redrawOverview
320 * - when set, the overview will be recalculated (takes longer)
321 * @return false if results were not found
323 public boolean scrollToPosition(SearchResults results,
324 boolean redrawOverview)
326 return scrollToPosition(results, redrawOverview, false);
330 * scroll the view to show the position of the highlighted region in results
334 * @param redrawOverview
335 * - when set, the overview will be recalculated (takes longer)
336 * @return false if results were not found
338 public boolean scrollToPosition(SearchResults results,
339 boolean redrawOverview, boolean centre)
341 // do we need to scroll the panel?
342 if (results != null && results.getSize() > 0)
344 AlignmentI alignment = av.getAlignment();
345 int seqIndex = alignment.findIndex(results);
350 SequenceI seq = alignment.getSequenceAt(seqIndex);
351 int[] r = results.getResults(seq, 0, alignment.getWidth());
354 if (JalviewLite.debug)
357 .println("DEBUG: scroll didn't happen - results not within alignment : "
358 + seq.getStart() + "," + seq.getEnd());
362 if (JalviewLite.debug)
366 * System.out.println("DEBUG: scroll: start=" + r[0] +
367 * " av.getStartRes()=" + av.getStartRes() + " end=" + r[1] +
368 * " seq.end=" + seq.getEnd() + " av.getEndRes()=" + av.getEndRes() +
369 * " hextent=" + hextent);
376 * To centre results, scroll to positions half the visible width
377 * left/right of the start/end positions
381 int offset = (av.getEndRes() - av.getStartRes() + 1) / 2 - 1;
382 start = Math.max(start - offset, 0);
383 end = Math.min(end + offset, seq.getEnd() - 1);
390 if (end == seq.getEnd())
394 return scrollTo(start, end, seqIndex, false, redrawOverview);
399 public boolean scrollTo(int ostart, int end, int seqIndex,
400 boolean scrollToNearest, boolean redrawOverview)
402 int startv, endv, starts, ends, width;
405 if (av.hasHiddenColumns())
407 start = av.getColumnSelection().findColumnPosition(ostart);
408 end = av.getColumnSelection().findColumnPosition(end);
411 if (!scrollToNearest && !av.getColumnSelection().isVisible(ostart))
413 // don't scroll - position isn't visible
422 if (!av.getWrapAlignment())
425 * int spos=av.getStartRes(),sqpos=av.getStartSeq(); if ((startv =
426 * av.getStartRes()) >= start) { spos=start-1; // seqIn //
427 * setScrollValues(start - 1, seqIndex); } else if ((endv =
428 * av.getEndRes()) <= end) { // setScrollValues(spos=startv + 1 + end -
429 * endv, seqIndex); spos=startv + 1 + end - endv; } else if ((starts =
430 * av.getStartSeq()) > seqIndex) { setScrollValues(av.getStartRes(),
431 * seqIndex); } else if ((ends = av.getEndSeq()) <= seqIndex) {
432 * setScrollValues(av.getStartRes(), starts + seqIndex - ends + 1); }
435 // below is scrolling logic up to Jalview 2.8.2
436 // if ((av.getStartRes() > end)
437 // || (av.getEndRes() < start)
438 // || ((av.getStartSeq() > seqIndex) || (av.getEndSeq() < seqIndex)))
440 // if (start > av.getAlignment().getWidth() - hextent)
442 // start = av.getAlignment().getWidth() - hextent;
449 // if (seqIndex > av.getAlignment().getHeight() - vextent)
451 // seqIndex = av.getAlignment().getHeight() - vextent;
457 // setScrollValues(start, seqIndex);
459 // logic copied from jalview.gui.AlignmentPanel:
460 if ((startv = av.getStartRes()) >= start)
463 * Scroll left to make start of search results visible
465 setScrollValues(start - 1, seqIndex);
467 else if ((endv = av.getEndRes()) <= end)
470 * Scroll right to make end of search results visible
472 setScrollValues(startv + 1 + end - endv, seqIndex);
474 else if ((starts = av.getStartSeq()) > seqIndex)
477 * Scroll up to make start of search results visible
479 setScrollValues(av.getStartRes(), seqIndex);
481 else if ((ends = av.getEndSeq()) <= seqIndex)
484 * Scroll down to make end of search results visible
486 setScrollValues(av.getStartRes(), starts + seqIndex - ends + 1);
489 * Else results are already visible - no need to scroll
494 scrollToWrappedVisible(start);
496 if (redrawOverview && overviewPanel != null)
498 overviewPanel.setBoxPosition();
500 paintAlignment(redrawOverview);
504 void scrollToWrappedVisible(int res)
506 int cwidth = seqPanel.seqCanvas
507 .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width);
508 if (res <= av.getStartRes() || res >= (av.getStartRes() + cwidth))
510 vscroll.setValue(res / cwidth);
511 av.startRes = vscroll.getValue() * cwidth;
515 public OverviewPanel getOverviewPanel()
517 return overviewPanel;
520 public void setOverviewPanel(OverviewPanel op)
525 public void setAnnotationVisible(boolean b)
527 if (!av.getWrapAlignment())
529 annotationSpaceFillerHolder.setVisible(b);
530 annotationPanelHolder.setVisible(b);
534 annotationSpaceFillerHolder.setVisible(false);
535 annotationPanelHolder.setVisible(false);
542 * automatically adjust annotation panel height for new annotation whilst
543 * ensuring the alignment is still visible.
546 public void adjustAnnotationHeight()
548 // TODO: display vertical annotation scrollbar if necessary
549 // this is called after loading new annotation onto alignment
550 if (alignFrame.getSize().height == 0)
553 .println("adjustAnnotationHeight frame size zero NEEDS FIXING");
556 validateAnnotationDimensions(true);
557 apvscroll.addNotify();
560 paintAlignment(true);
564 * Calculate the annotation dimensions and refresh slider values accordingly.
565 * Need to do repaints/notifys afterwards.
567 protected void validateAnnotationDimensions(boolean adjustPanelHeight)
569 int rowHeight = av.getCharHeight();
570 int alignmentHeight = rowHeight * av.getAlignment().getHeight();
571 int annotationHeight = av.calcPanelHeight();
573 int mheight = annotationHeight;
574 Dimension d = sequenceHolderPanel.getSize();
576 int availableHeight = d.height - scalePanelHolder.getHeight();
578 if (adjustPanelHeight)
581 * If not enough vertical space, maximize annotation height while keeping
582 * at least two rows of alignment visible
584 if (annotationHeight + alignmentHeight > availableHeight)
586 annotationHeight = Math.min(annotationHeight, availableHeight - 2
592 // maintain same window layout whilst updating sliders
593 annotationHeight = annotationPanelHolder.getSize().height;
596 if (availableHeight - annotationHeight < 5)
598 annotationHeight = availableHeight;
601 annotationPanel.setSize(new Dimension(d.width, annotationHeight));
602 annotationPanelHolder.setSize(new Dimension(d.width, annotationHeight));
603 // seqPanelHolder.setSize(d.width, seqandannot - height);
605 .setSize(d.width, seqPanel.seqCanvas.getSize().height);
607 Dimension e = idPanel.getSize();
608 alabels.setSize(new Dimension(e.width, annotationHeight));
609 annotationSpaceFillerHolder.setSize(new Dimension(e.width,
612 int s = apvscroll.getValue();
613 if (s > mheight - annotationHeight)
617 apvscroll.setValues(s, annotationHeight, 0, mheight);
618 annotationPanel.setScrollOffset(apvscroll.getValue(), false);
619 alabels.setScrollOffset(apvscroll.getValue(), false);
622 public void setWrapAlignment(boolean wrap)
626 scalePanelHolder.setVisible(!wrap);
628 hscroll.setVisible(!wrap);
629 idwidthAdjuster.setVisible(!wrap);
633 annotationPanelHolder.setVisible(false);
634 annotationSpaceFillerHolder.setVisible(false);
636 else if (av.isShowAnnotation())
638 annotationPanelHolder.setVisible(true);
639 annotationSpaceFillerHolder.setVisible(true);
642 idSpaceFillerPanel1.setVisible(!wrap);
644 fontChanged(); // This is so that the scalePanel is resized correctly
647 sequenceHolderPanel.validate();
656 // return value is true if the scroll is valid
657 public boolean scrollUp(boolean up)
661 if (vscroll.getValue() < 1)
665 setScrollValues(hscroll.getValue(), vscroll.getValue() - 1);
669 if (vextent + vscroll.getValue() >= av.getAlignment().getHeight())
673 setScrollValues(hscroll.getValue(), vscroll.getValue() + 1);
680 public boolean scrollRight(boolean right)
684 if (hscroll.getValue() < 1)
688 setScrollValues(hscroll.getValue() - 1, vscroll.getValue());
692 if (hextent + hscroll.getValue() >= av.getAlignment().getWidth())
696 setScrollValues(hscroll.getValue() + 1, vscroll.getValue());
703 public void setScrollValues(int x, int y)
705 int width = av.getAlignment().getWidth();
706 int height = av.getAlignment().getHeight();
708 if (av.hasHiddenColumns())
710 width = av.getColumnSelection().findColumnPosition(width);
718 hextent = seqPanel.seqCanvas.getSize().width / av.getCharWidth();
719 vextent = seqPanel.seqCanvas.getSize().height / av.getCharHeight();
726 if (vextent > height)
731 if ((hextent + x) > width)
733 System.err.println("hextent was " + hextent + " and x was " + x);
738 if ((vextent + y) > height)
740 y = height - vextent;
750 System.err.println("x was " + x);
756 int endSeq = y + vextent;
757 if (endSeq > av.getAlignment().getHeight())
759 endSeq = av.getAlignment().getHeight();
762 av.setEndSeq(endSeq);
764 av.setEndRes((x + (seqPanel.seqCanvas.getSize().width / av
765 .getCharWidth())) - 1);
767 hscroll.setValues(x, hextent, 0, width);
768 vscroll.setValues(y, vextent, 0, height);
770 if (overviewPanel != null)
772 overviewPanel.setBoxPosition();
779 public void adjustmentValueChanged(AdjustmentEvent evt)
781 int oldX = av.getStartRes();
782 int oldY = av.getStartSeq();
784 if (evt == null || evt.getSource() == apvscroll)
786 annotationPanel.setScrollOffset(apvscroll.getValue(), false);
787 alabels.setScrollOffset(apvscroll.getValue(), false);
788 // annotationPanel.image=null;
789 // alabels.image=null;
790 // alabels.repaint();
791 // annotationPanel.repaint();
793 if (evt == null || evt.getSource() == hscroll)
795 int x = hscroll.getValue();
797 av.setEndRes(x + seqPanel.seqCanvas.getSize().width
798 / av.getCharWidth() - 1);
801 if (evt == null || evt.getSource() == vscroll)
803 int offy = vscroll.getValue();
804 if (av.getWrapAlignment())
806 int rowSize = seqPanel.seqCanvas
807 .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width);
808 av.setStartRes(vscroll.getValue() * rowSize);
809 av.setEndRes((vscroll.getValue() + 1) * rowSize);
813 av.setStartSeq(offy);
814 av.setEndSeq(offy + seqPanel.seqCanvas.getSize().height
815 / av.getCharHeight());
819 if (overviewPanel != null)
821 overviewPanel.setBoxPosition();
824 int scrollX = av.startRes - oldX;
825 int scrollY = av.startSeq - oldY;
827 if (av.getWrapAlignment() || !fastPaint || av.MAC)
833 // Make sure we're not trying to draw a panel
834 // larger than the visible window
835 if (scrollX > av.endRes - av.startRes)
837 scrollX = av.endRes - av.startRes;
839 else if (scrollX < av.startRes - av.endRes)
841 scrollX = av.startRes - av.endRes;
844 idPanel.idCanvas.fastPaint(scrollY);
845 seqPanel.seqCanvas.fastPaint(scrollX, scrollY);
847 scalePanel.repaint();
848 if (av.isShowAnnotation())
850 annotationPanel.fastPaint(av.getStartRes() - oldX);
856 * If there is one, scroll the (Protein/cDNA) complementary alignment to
857 * match, unless we are ourselves doing that.
859 if (isFollowingComplementScroll())
861 setFollowingComplementScroll(false);
865 AlignmentPanel ap = getComplementPanel();
866 av.scrollComplementaryAlignment(ap);
872 * A helper method to return the AlignmentPanel in the other (complementary)
873 * half of a SplitFrame view. Returns null if not in a SplitFrame.
877 private AlignmentPanel getComplementPanel()
879 AlignmentPanel ap = null;
880 if (alignFrame != null)
882 SplitFrame sf = alignFrame.getSplitFrame();
885 AlignFrame other = sf.getComplement(alignFrame);
888 ap = other.alignPanel;
896 * Follow a scrolling change in the (cDNA/Protein) complementary alignment.
897 * The aim is to keep the two alignments 'lined up' on their centre columns.
900 * holds mapped region(s) of this alignment that we are scrolling
901 * 'to'; may be modified for sequence offset by this method
903 * the number of visible sequences to show above the mapped region
905 protected void scrollToCentre(SearchResults sr, int seqOffset)
908 * To avoid jumpy vertical scrolling (if some sequences are gapped or not
909 * mapped), we can make the scroll-to location a sequence above the one
912 SequenceI mappedTo = sr.getResultSequence(0);
913 List<SequenceI> seqs = av.getAlignment().getSequences();
916 * This is like AlignmentI.findIndex(seq) but here we are matching the
917 * dataset sequence not the aligned sequence
919 int sequenceIndex = 0;
920 boolean matched = false;
921 for (SequenceI seq : seqs)
923 if (mappedTo == seq.getDatasetSequence())
932 return; // failsafe, shouldn't happen
934 sequenceIndex = Math.max(0, sequenceIndex - seqOffset);
935 sr.getResults().get(0)
936 .setSequence(av.getAlignment().getSequenceAt(sequenceIndex));
939 * Scroll to position but centring the target residue. Also set a state flag
940 * to prevent adjustmentValueChanged performing this recursively.
942 setFollowingComplementScroll(true);
943 scrollToPosition(sr, true, true);
946 private void sendViewPosition()
948 StructureSelectionManager.getStructureSelectionManager(av.applet)
949 .sendViewPosition(this, av.startRes, av.endRes, av.startSeq,
954 * Repaint the alignment and annotations, and, optionally, any overview window
957 public void paintAlignment(boolean updateOverview)
959 final AnnotationSorter sorter = new AnnotationSorter(getAlignment(),
960 av.isShowAutocalculatedAbove());
961 sorter.sort(getAlignment().getAlignmentAnnotation(),
962 av.getSortAnnotationsBy());
967 // TODO: determine if this paintAlignment changed structure colours
968 jalview.structure.StructureSelectionManager
969 .getStructureSelectionManager(av.applet)
970 .sequenceColoursChanged(this);
972 if (overviewPanel != null)
974 overviewPanel.updateOverviewImage();
980 public void update(Graphics g)
986 public void paint(Graphics g)
989 Dimension d = idPanel.idCanvas.getSize();
990 final int canvasHeight = seqPanel.seqCanvas.getSize().height;
991 if (canvasHeight != d.height)
993 idPanel.idCanvas.setSize(d.width, canvasHeight);
996 if (av.getWrapAlignment())
998 int maxwidth = av.getAlignment().getWidth();
1000 if (av.hasHiddenColumns())
1002 maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
1005 int canvasWidth = seqPanel.seqCanvas
1006 .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width);
1008 if (canvasWidth > 0)
1010 int max = maxwidth / canvasWidth;
1011 vscroll.setMaximum(1 + max);
1012 vscroll.setUnitIncrement(1);
1013 vscroll.setVisibleAmount(1);
1018 setScrollValues(av.getStartRes(), av.getStartSeq());
1021 seqPanel.seqCanvas.repaint();
1022 idPanel.idCanvas.repaint();
1023 if (!av.getWrapAlignment())
1025 if (av.isShowAnnotation())
1028 annotationPanel.repaint();
1030 scalePanel.repaint();
1035 protected Panel sequenceHolderPanel = new Panel();
1037 protected Scrollbar vscroll = new Scrollbar();
1039 protected Scrollbar hscroll = new Scrollbar();
1041 protected Panel seqPanelHolder = new Panel();
1043 protected Panel scalePanelHolder = new Panel();
1045 protected Panel idPanelHolder = new Panel();
1047 protected Panel idSpaceFillerPanel1 = new Panel();
1049 public Panel annotationSpaceFillerHolder = new Panel();
1051 protected Panel hscrollFillerPanel = new Panel();
1053 Panel annotationPanelHolder = new Panel();
1055 protected Scrollbar apvscroll = new Scrollbar();
1058 * Flag set while scrolling to follow complementary cDNA/protein scroll. When
1059 * true, suppresses invoking the same method recursively.
1061 private boolean followingComplementScroll;
1063 private void jbInit() throws Exception
1065 // idPanelHolder.setPreferredSize(new Dimension(70, 10));
1066 this.setLayout(new BorderLayout());
1068 // sequenceHolderPanel.setPreferredSize(new Dimension(150, 150));
1069 sequenceHolderPanel.setLayout(new BorderLayout());
1070 seqPanelHolder.setLayout(new BorderLayout());
1071 scalePanelHolder.setBackground(Color.white);
1073 // scalePanelHolder.setPreferredSize(new Dimension(10, 30));
1074 scalePanelHolder.setLayout(new BorderLayout());
1075 idPanelHolder.setLayout(new BorderLayout());
1076 idSpaceFillerPanel1.setBackground(Color.white);
1078 // idSpaceFillerPanel1.setPreferredSize(new Dimension(10, 30));
1079 idSpaceFillerPanel1.setLayout(new BorderLayout());
1080 annotationSpaceFillerHolder.setBackground(Color.white);
1082 // annotationSpaceFillerHolder.setPreferredSize(new Dimension(10, 80));
1083 annotationSpaceFillerHolder.setLayout(new BorderLayout());
1084 hscroll.setOrientation(Scrollbar.HORIZONTAL);
1086 Panel hscrollHolder = new Panel();
1087 hscrollHolder.setLayout(new BorderLayout());
1088 hscrollFillerPanel.setBackground(Color.white);
1089 apvscroll.setOrientation(Scrollbar.VERTICAL);
1090 apvscroll.setVisible(true);
1091 apvscroll.addAdjustmentListener(this);
1093 annotationPanelHolder.setBackground(Color.white);
1094 annotationPanelHolder.setLayout(new BorderLayout());
1095 annotationPanelHolder.add(apvscroll, BorderLayout.EAST);
1096 // hscrollFillerPanel.setPreferredSize(new Dimension(70, 10));
1097 hscrollHolder.setBackground(Color.white);
1099 // annotationScroller.setPreferredSize(new Dimension(10, 80));
1100 // this.setPreferredSize(new Dimension(220, 166));
1101 seqPanelHolder.setBackground(Color.white);
1102 idPanelHolder.setBackground(Color.white);
1103 sequenceHolderPanel.add(scalePanelHolder, BorderLayout.NORTH);
1104 sequenceHolderPanel.add(seqPanelHolder, BorderLayout.CENTER);
1105 seqPanelHolder.add(vscroll, BorderLayout.EAST);
1107 // Panel3.add(secondaryPanelHolder, BorderLayout.SOUTH);
1108 this.add(idPanelHolder, BorderLayout.WEST);
1109 idPanelHolder.add(idSpaceFillerPanel1, BorderLayout.NORTH);
1110 idPanelHolder.add(annotationSpaceFillerHolder, BorderLayout.SOUTH);
1111 this.add(hscrollHolder, BorderLayout.SOUTH);
1112 hscrollHolder.add(hscroll, BorderLayout.CENTER);
1113 hscrollHolder.add(hscrollFillerPanel, BorderLayout.WEST);
1114 this.add(sequenceHolderPanel, BorderLayout.CENTER);
1118 * hides or shows dynamic annotation rows based on groups and av state flags
1120 public void updateAnnotation()
1122 updateAnnotation(false);
1125 public void updateAnnotation(boolean applyGlobalSettings)
1127 updateAnnotation(applyGlobalSettings, false);
1130 public void updateAnnotation(boolean applyGlobalSettings,
1131 boolean preserveNewGroupSettings)
1133 av.updateGroupAnnotationSettings(applyGlobalSettings,
1134 preserveNewGroupSettings);
1135 adjustAnnotationHeight();
1139 public AlignmentI getAlignment()
1141 return av.getAlignment();
1145 public String getViewName()
1151 public StructureSelectionManager getStructureSelectionManager()
1153 return StructureSelectionManager
1154 .getStructureSelectionManager(av.applet);
1158 public void raiseOOMWarning(String string, OutOfMemoryError error)
1161 System.err.println("Out of memory whilst '" + string + "'");
1162 error.printStackTrace();
1166 * Set a flag to say we are scrolling to follow a (cDNA/protein) complement.
1170 protected void setFollowingComplementScroll(boolean b)
1172 this.followingComplementScroll = b;
1175 protected boolean isFollowingComplementScroll()
1177 return this.followingComplementScroll;