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 awt2swing.Frame;
37 import java.awt.Graphics;
38 import awt2swing.Panel;
39 import awt2swing.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)
87 setName("alignmentPanel");
98 seqPanel = new SeqPanel(av, this);
99 idPanel = new IdPanel(av, this);
100 scalePanel = new ScalePanel(av, this);
101 idwidthAdjuster = new IdwidthAdjuster(this);
102 annotationPanel = new AnnotationPanel(this);
103 annotationPanelHolder.add(annotationPanel, BorderLayout.CENTER);
105 sequenceHolderPanel.add(annotationPanelHolder, BorderLayout.SOUTH);
106 alabels = new AnnotationLabels(this);
108 setAnnotationVisible(av.isShowAnnotation());
110 idPanelHolder.add(idPanel, BorderLayout.CENTER);
111 idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER);
112 annotationSpaceFillerHolder.add(alabels, BorderLayout.CENTER);
113 scalePanelHolder.add(scalePanel, BorderLayout.CENTER);
114 seqPanelHolder.add(seqPanel, BorderLayout.CENTER);
117 setScrollValues(0, 0);
119 apvscroll.addAdjustmentListener(this);
120 hscroll.addAdjustmentListener(this);
121 vscroll.addAdjustmentListener(this);
123 addComponentListener(new ComponentAdapter()
125 public void componentResized(ComponentEvent evt)
127 setScrollValues(av.getStartRes(), av.getStartSeq());
128 if (getSize().height > 0
129 && annotationPanelHolder.getSize().height > 0)
131 validateAnnotationDimensions(false);
138 Dimension d = calculateIdWidth();
139 idPanel.idCanvas.setSize(d);
141 hscrollFillerPanel.setSize(d.width, annotationPanel.getSize().height);
143 idPanel.idCanvas.setSize(d.width, seqPanel.seqCanvas.getSize().height);
144 annotationSpaceFillerHolder.setSize(d.width,
145 annotationPanel.getSize().height);
146 alabels.setSize(d.width, annotationPanel.getSize().height);
147 final AlignmentPanel ap = this;
148 av.addPropertyChangeListener(new java.beans.PropertyChangeListener()
150 public void propertyChange(java.beans.PropertyChangeEvent evt)
152 if (evt.getPropertyName().equals("alignment"))
154 PaintRefresher.Refresh(ap, av.getSequenceSetId(), true, true);
162 public AlignViewportI getAlignViewport()
166 public SequenceRenderer getSequenceRenderer()
168 return seqPanel.seqCanvas.sr;
171 public jalview.api.FeatureRenderer getFeatureRenderer()
173 return seqPanel.seqCanvas.fr;
176 public jalview.api.FeatureRenderer cloneFeatureRenderer()
178 FeatureRenderer nfr = new FeatureRenderer(av);
179 nfr.transferSettings(seqPanel.seqCanvas.fr);
182 public void alignmentChanged()
184 av.alignmentChanged(this);
186 if (overviewPanel != null)
188 overviewPanel.updateOverviewImage();
191 alignFrame.updateEditMenuBar();
196 public void fontChanged()
198 // set idCanvas bufferedImage to null
199 // to prevent drawing old image
200 idPanel.idCanvas.image = null;
201 FontMetrics fm = getFontMetrics(av.getFont());
203 scalePanel.setSize(new Dimension(10, av.getCharHeight()
205 idwidthAdjuster.setSize(new Dimension(10, av.getCharHeight()
207 av.updateSequenceIdColours();
208 annotationPanel.image = null;
209 int ap = annotationPanel.adjustPanelHeight(false);
210 Dimension d = calculateIdWidth();
211 d.setSize(d.width + 4, seqPanel.seqCanvas.getSize().height);
212 alabels.setSize(d.width + 4, ap);
214 idPanel.idCanvas.setSize(d);
215 hscrollFillerPanel.setSize(d);
217 validateAnnotationDimensions(false);
218 annotationPanel.repaint();
222 if (overviewPanel != null)
224 overviewPanel.updateOverviewImage();
228 public void setIdWidth(int w, int h)
230 idPanel.idCanvas.setSize(w, h);
231 idPanelHolder.setSize(w, idPanelHolder.getSize().height);
232 annotationSpaceFillerHolder.setSize(w,
233 annotationSpaceFillerHolder.getSize().height);
234 alabels.setSize(w, alabels.getSize().height);
238 Dimension calculateIdWidth()
240 if (av.nullFrame == null)
242 av.nullFrame = new Frame();
243 av.nullFrame.addNotify();
244 av.nullFrame.setFont(av.font);
246 Graphics g = av.nullFrame.getGraphics();
247 FontMetrics fm = g.getFontMetrics(av.font);
248 AlignmentI al = av.getAlignment();
253 while (i < al.getHeight() && al.getSequenceAt(i) != null)
255 SequenceI s = al.getSequenceAt(i);
256 id = s.getDisplayId(av.getShowJVSuffix());
258 if (fm.stringWidth(id) > idWidth)
260 idWidth = fm.stringWidth(id);
265 // Also check annotation label widths
267 if (al.getAlignmentAnnotation() != null)
269 fm = g.getFontMetrics(av.nullFrame.getFont());
270 while (i < al.getAlignmentAnnotation().length)
272 String label = al.getAlignmentAnnotation()[i].label;
273 if (fm.stringWidth(label) > idWidth)
275 idWidth = fm.stringWidth(label);
281 return new Dimension(idWidth, idPanel.idCanvas.getSize().height);
285 * Highlight the given results on the alignment.
288 public void highlightSearchResults(SearchResults results)
290 scrollToPosition(results);
291 seqPanel.seqCanvas.highlightSearchResults(results);
295 * scroll the view to show the position of the highlighted region in results
296 * (if any) and redraw the overview
299 * @return false if results were not found
301 public boolean scrollToPosition(SearchResults results)
303 return scrollToPosition(results, true);
307 * scroll the view to show the position of the highlighted region in results
311 * @param redrawOverview
312 * - when set, the overview will be recalculated (takes longer)
313 * @return false if results were not found
315 public boolean scrollToPosition(SearchResults results,
316 boolean redrawOverview)
318 return scrollToPosition(results, redrawOverview, false);
322 * scroll the view to show the position of the highlighted region in results
326 * @param redrawOverview
327 * - when set, the overview will be recalculated (takes longer)
328 * @return false if results were not found
330 public boolean scrollToPosition(SearchResults results,
331 boolean redrawOverview, boolean centre)
333 // do we need to scroll the panel?
334 if (results != null && results.getSize() > 0)
336 AlignmentI alignment = av.getAlignment();
337 int seqIndex = alignment.findIndex(results);
342 SequenceI seq = alignment.getSequenceAt(seqIndex);
343 int[] r = results.getResults(seq, 0, alignment.getWidth());
346 if (JalviewLite.debug)
349 .println("DEBUG: scroll didn't happen - results not within alignment : "
350 + seq.getStart() + "," + seq.getEnd());
354 if (JalviewLite.debug)
358 * System.out.println("DEBUG: scroll: start=" + r[0] +
359 * " av.getStartRes()=" + av.getStartRes() + " end=" + r[1] +
360 * " seq.end=" + seq.getEnd() + " av.getEndRes()=" + av.getEndRes() +
361 * " hextent=" + hextent);
368 * To centre results, scroll to positions half the visible width
369 * left/right of the start/end positions
373 int offset = (av.getEndRes() - av.getStartRes() + 1) / 2 - 1;
374 start = Math.max(start - offset, 0);
375 end = Math.min(end + offset, seq.getEnd() - 1);
382 if (end == seq.getEnd())
386 return scrollTo(start, end, seqIndex, false, redrawOverview);
391 public boolean scrollTo(int ostart, int end, int seqIndex,
392 boolean scrollToNearest, boolean redrawOverview)
394 int startv, endv, starts, ends, width;
397 if (av.hasHiddenColumns())
399 start = av.getColumnSelection().findColumnPosition(ostart);
400 end = av.getColumnSelection().findColumnPosition(end);
403 if (!scrollToNearest && !av.getColumnSelection().isVisible(ostart))
405 // don't scroll - position isn't visible
414 if (!av.getWrapAlignment())
417 * int spos=av.getStartRes(),sqpos=av.getStartSeq(); if ((startv =
418 * av.getStartRes()) >= start) { spos=start-1; // seqIn //
419 * setScrollValues(start - 1, seqIndex); } else if ((endv =
420 * av.getEndRes()) <= end) { // setScrollValues(spos=startv + 1 + end -
421 * endv, seqIndex); spos=startv + 1 + end - endv; } else if ((starts =
422 * av.getStartSeq()) > seqIndex) { setScrollValues(av.getStartRes(),
423 * seqIndex); } else if ((ends = av.getEndSeq()) <= seqIndex) {
424 * setScrollValues(av.getStartRes(), starts + seqIndex - ends + 1); }
427 // below is scrolling logic up to Jalview 2.8.2
428 // if ((av.getStartRes() > end)
429 // || (av.getEndRes() < start)
430 // || ((av.getStartSeq() > seqIndex) || (av.getEndSeq() < seqIndex)))
432 // if (start > av.getAlignment().getWidth() - hextent)
434 // start = av.getAlignment().getWidth() - hextent;
441 // if (seqIndex > av.getAlignment().getHeight() - vextent)
443 // seqIndex = av.getAlignment().getHeight() - vextent;
449 // setScrollValues(start, seqIndex);
451 // logic copied from jalview.gui.AlignmentPanel:
452 if ((startv = av.getStartRes()) >= start)
455 * Scroll left to make start of search results visible
457 setScrollValues(start - 1, seqIndex);
459 else if ((endv = av.getEndRes()) <= end)
462 * Scroll right to make end of search results visible
464 setScrollValues(startv + 1 + end - endv, seqIndex);
466 else if ((starts = av.getStartSeq()) > seqIndex)
469 * Scroll up to make start of search results visible
471 setScrollValues(av.getStartRes(), seqIndex);
473 else if ((ends = av.getEndSeq()) <= seqIndex)
476 * Scroll down to make end of search results visible
478 setScrollValues(av.getStartRes(), starts + seqIndex - ends + 1);
481 * Else results are already visible - no need to scroll
486 scrollToWrappedVisible(start);
488 if (redrawOverview && overviewPanel != null)
490 overviewPanel.setBoxPosition();
492 paintAlignment(redrawOverview);
496 void scrollToWrappedVisible(int res)
498 int cwidth = seqPanel.seqCanvas
499 .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width);
500 if (res <= av.getStartRes() || res >= (av.getStartRes() + cwidth))
502 vscroll.setValue(res / cwidth);
503 av.startRes = vscroll.getValue() * cwidth;
507 public OverviewPanel getOverviewPanel()
509 return overviewPanel;
512 public void setOverviewPanel(OverviewPanel op)
517 public void setAnnotationVisible(boolean b)
519 if (!av.getWrapAlignment())
521 annotationSpaceFillerHolder.setVisible(b);
522 annotationPanelHolder.setVisible(b);
526 annotationSpaceFillerHolder.setVisible(false);
527 annotationPanelHolder.setVisible(false);
534 * automatically adjust annotation panel height for new annotation whilst
535 * ensuring the alignment is still visible.
537 public void adjustAnnotationHeight()
539 // TODO: display vertical annotation scrollbar if necessary
540 // this is called after loading new annotation onto alignment
541 if (alignFrame.getSize().height == 0)
544 .println("adjustAnnotationHeight frame size zero NEEDS FIXING");
547 validateAnnotationDimensions(true);
548 apvscroll.addNotify();
551 paintAlignment(true);
555 * Calculate the annotation dimensions and refresh slider values accordingly.
556 * Need to do repaints/notifys afterwards.
558 protected void validateAnnotationDimensions(boolean adjustPanelHeight)
560 int rowHeight = av.getCharHeight();
561 int alignmentHeight = rowHeight * av.getAlignment().getHeight();
562 int annotationHeight = av.calcPanelHeight();
564 int mheight = annotationHeight;
565 Dimension d = sequenceHolderPanel.getSize();
567 int availableHeight = d.height - scalePanelHolder.getHeight();
569 if (adjustPanelHeight)
572 * If not enough vertical space, maximize annotation height while keeping
573 * at least two rows of alignment visible
575 if (annotationHeight + alignmentHeight > availableHeight)
577 annotationHeight = Math.min(annotationHeight, availableHeight - 2
583 // maintain same window layout whilst updating sliders
584 annotationHeight = annotationPanelHolder.getSize().height;
587 if (availableHeight - annotationHeight < 5)
589 annotationHeight = availableHeight;
592 annotationPanel.setSize(new Dimension(d.width, annotationHeight));
593 annotationPanelHolder.setSize(new Dimension(d.width, annotationHeight));
594 // seqPanelHolder.setSize(d.width, seqandannot - height);
596 .setSize(d.width, seqPanel.seqCanvas.getSize().height);
598 Dimension e = idPanel.getSize();
599 alabels.setSize(new Dimension(e.width, annotationHeight));
600 annotationSpaceFillerHolder.setSize(new Dimension(e.width,
603 int s = apvscroll.getValue();
604 if (s > mheight - annotationHeight)
608 apvscroll.setValues(s, annotationHeight, 0, mheight);
609 annotationPanel.setScrollOffset(apvscroll.getValue(), false);
610 alabels.setScrollOffset(apvscroll.getValue(), false);
613 public void setWrapAlignment(boolean wrap)
617 scalePanelHolder.setVisible(!wrap);
619 hscroll.setVisible(!wrap);
620 idwidthAdjuster.setVisible(!wrap);
624 annotationPanelHolder.setVisible(false);
625 annotationSpaceFillerHolder.setVisible(false);
627 else if (av.isShowAnnotation())
629 annotationPanelHolder.setVisible(true);
630 annotationSpaceFillerHolder.setVisible(true);
633 idSpaceFillerPanel1.setVisible(!wrap);
635 fontChanged(); // This is so that the scalePanel is resized correctly
638 sequenceHolderPanel.validate();
647 // return value is true if the scroll is valid
648 public boolean scrollUp(boolean up)
652 if (vscroll.getValue() < 1)
656 setScrollValues(hscroll.getValue(), vscroll.getValue() - 1);
660 if (vextent + vscroll.getValue() >= av.getAlignment().getHeight())
664 setScrollValues(hscroll.getValue(), vscroll.getValue() + 1);
671 public boolean scrollRight(boolean right)
675 if (hscroll.getValue() < 1)
679 setScrollValues(hscroll.getValue() - 1, vscroll.getValue());
683 if (hextent + hscroll.getValue() >= av.getAlignment().getWidth())
687 setScrollValues(hscroll.getValue() + 1, vscroll.getValue());
694 public void setScrollValues(int x, int y)
696 int width = av.getAlignment().getWidth();
697 int height = av.getAlignment().getHeight();
699 if (av.hasHiddenColumns())
701 width = av.getColumnSelection().findColumnPosition(width);
709 hextent = seqPanel.seqCanvas.getSize().width / av.getCharWidth();
710 vextent = seqPanel.seqCanvas.getSize().height / av.getCharHeight();
717 if (vextent > height)
722 if ((hextent + x) > width)
724 System.err.println("hextent was " + hextent + " and x was " + x);
729 if ((vextent + y) > height)
731 y = height - vextent;
741 System.err.println("x was " + x);
747 int endSeq = y + vextent;
748 if (endSeq > av.getAlignment().getHeight())
750 endSeq = av.getAlignment().getHeight();
753 av.setEndSeq(endSeq);
755 av.setEndRes((x + (seqPanel.seqCanvas.getSize().width / av
756 .getCharWidth())) - 1);
758 hscroll.setValues(x, hextent, 0, width);
759 vscroll.setValues(y, vextent, 0, height);
761 if (overviewPanel != null)
763 overviewPanel.setBoxPosition();
769 public void adjustmentValueChanged(AdjustmentEvent evt)
771 if (annotationPanel == null)
772 return; // BH in process of loading
773 int oldX = av.getStartRes();
774 int oldY = av.getStartSeq();
776 if (evt == null || evt.getSource() == apvscroll)
778 annotationPanel.setScrollOffset(apvscroll.getValue(), false);
779 alabels.setScrollOffset(apvscroll.getValue(), false);
780 // annotationPanel.image=null;
781 // alabels.image=null;
782 // alabels.repaint();
783 // annotationPanel.repaint();
785 if (evt == null || evt.getSource() == hscroll)
787 int x = hscroll.getValue();
789 av.setEndRes(x + seqPanel.seqCanvas.getSize().width
790 / av.getCharWidth() - 1);
793 if (evt == null || evt.getSource() == vscroll)
795 int offy = vscroll.getValue();
796 if (av.getWrapAlignment())
798 int rowSize = seqPanel.seqCanvas
799 .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width);
800 av.setStartRes(vscroll.getValue() * rowSize);
801 av.setEndRes((vscroll.getValue() + 1) * rowSize);
805 av.setStartSeq(offy);
806 av.setEndSeq(offy + seqPanel.seqCanvas.getSize().height
807 / av.getCharHeight());
811 if (overviewPanel != null)
813 overviewPanel.setBoxPosition();
816 int scrollX = av.startRes - oldX;
817 int scrollY = av.startSeq - oldY;
819 if (av.getWrapAlignment() || !fastPaint || av.MAC)
825 // Make sure we're not trying to draw a panel
826 // larger than the visible window
827 if (scrollX > av.endRes - av.startRes)
829 scrollX = av.endRes - av.startRes;
831 else if (scrollX < av.startRes - av.endRes)
833 scrollX = av.startRes - av.endRes;
836 idPanel.idCanvas.fastPaint(scrollY);
837 seqPanel.seqCanvas.fastPaint(scrollX, scrollY);
839 scalePanel.repaint();
840 if (av.isShowAnnotation())
842 annotationPanel.fastPaint(av.getStartRes() - oldX);
848 * If there is one, scroll the (Protein/cDNA) complementary alignment to
849 * match, unless we are ourselves doing that.
851 if (isFollowingComplementScroll())
853 setFollowingComplementScroll(false);
857 AlignmentPanel ap = getComplementPanel();
858 av.scrollComplementaryAlignment(ap);
864 * A helper method to return the AlignmentPanel in the other (complementary)
865 * half of a SplitFrame view. Returns null if not in a SplitFrame.
869 private AlignmentPanel getComplementPanel()
871 AlignmentPanel ap = null;
872 if (alignFrame != null)
874 SplitFrame sf = alignFrame.getSplitFrame();
877 AlignFrame other = sf.getComplement(alignFrame);
880 ap = other.alignPanel;
888 * Follow a scrolling change in the (cDNA/Protein) complementary alignment.
889 * The aim is to keep the two alignments 'lined up' on their centre columns.
892 * holds mapped region(s) of this alignment that we are scrolling
893 * 'to'; may be modified for sequence offset by this method
895 * the number of visible sequences to show above the mapped region
897 protected void scrollToCentre(SearchResults sr, int seqOffset)
900 * To avoid jumpy vertical scrolling (if some sequences are gapped or not
901 * mapped), we can make the scroll-to location a sequence above the one
904 SequenceI mappedTo = sr.getResultSequence(0);
905 List<SequenceI> seqs = av.getAlignment().getSequences();
908 * This is like AlignmentI.findIndex(seq) but here we are matching the
909 * dataset sequence not the aligned sequence
911 int sequenceIndex = 0;
912 boolean matched = false;
913 for (SequenceI seq : seqs)
915 if (mappedTo == seq.getDatasetSequence())
924 return; // failsafe, shouldn't happen
926 sequenceIndex = Math.max(0, sequenceIndex - seqOffset);
927 sr.getResults().get(0)
928 .setSequence(av.getAlignment().getSequenceAt(sequenceIndex));
931 * Scroll to position but centring the target residue. Also set a state flag
932 * to prevent adjustmentValueChanged performing this recursively.
934 setFollowingComplementScroll(true);
935 scrollToPosition(sr, true, true);
938 private void sendViewPosition()
940 StructureSelectionManager.getStructureSelectionManager(av.applet)
941 .sendViewPosition(this, av.startRes, av.endRes, av.startSeq,
946 * Repaint the alignment and annotations, and, optionally, any overview window
948 public void paintAlignment(boolean updateOverview)
950 final AnnotationSorter sorter = new AnnotationSorter(getAlignment(),
951 av.isShowAutocalculatedAbove());
952 sorter.sort(getAlignment().getAlignmentAnnotation(),
953 av.getSortAnnotationsBy());
958 StructureSelectionManager.getStructureSelectionManager(av.applet)
959 .sequenceColoursChanged(this);
961 if (overviewPanel != null)
963 overviewPanel.updateOverviewImage();
968 public void paintComponent(Graphics g)
970 System.out.println("alignframe paintcomp");
972 Dimension d = idPanel.idCanvas.getSize();
973 final int canvasHeight = seqPanel.seqCanvas.getSize().height;
974 if (canvasHeight != d.height)
976 idPanel.idCanvas.setSize(d.width, canvasHeight);
979 if (av.getWrapAlignment())
981 int maxwidth = av.getAlignment().getWidth();
983 if (av.hasHiddenColumns())
985 maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
988 int canvasWidth = seqPanel.seqCanvas
989 .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width);
993 int max = maxwidth / canvasWidth;
994 vscroll.setMaximum(1 + max);
995 vscroll.setUnitIncrement(1);
996 vscroll.setVisibleAmount(1);
1001 setScrollValues(av.getStartRes(), av.getStartSeq());
1004 //bh handled by Swing
1006 // seqPanel.seqCanvas.repaint();
1007 // idPanel.idCanvas.repaint();
1008 // if (!av.getWrapAlignment())
1010 // if (av.isShowAnnotation())
1012 // alabels.repaint();
1013 // annotationPanel.repaint();
1015 // scalePanel.repaint();
1020 protected Panel sequenceHolderPanel = new Panel();
1022 protected Scrollbar vscroll = new Scrollbar();
1024 protected Scrollbar hscroll = new Scrollbar();
1026 protected Panel seqPanelHolder = new Panel();
1028 protected Panel scalePanelHolder = new Panel();
1030 protected Panel idPanelHolder = new Panel();
1032 protected Panel idSpaceFillerPanel1 = new Panel();
1034 public Panel annotationSpaceFillerHolder = new Panel();
1036 protected Panel hscrollFillerPanel = new Panel();
1038 Panel annotationPanelHolder = new Panel();
1040 protected Scrollbar apvscroll = new Scrollbar();
1043 * Flag set while scrolling to follow complementary cDNA/protein scroll. When
1044 * true, suppresses invoking the same method recursively.
1046 private boolean followingComplementScroll;
1048 private void jbInit() throws Exception
1050 // idPanelHolder.setPreferredSize(new Dimension(70, 10));
1051 this.setLayout(new BorderLayout());
1053 // sequenceHolderPanel.setPreferredSize(new Dimension(150, 150));
1054 sequenceHolderPanel.setLayout(new BorderLayout());
1055 seqPanelHolder.setLayout(new BorderLayout());
1056 scalePanelHolder.setBackground(Color.white);
1058 // scalePanelHolder.setPreferredSize(new Dimension(10, 30));
1059 scalePanelHolder.setLayout(new BorderLayout());
1060 idPanelHolder.setLayout(new BorderLayout());
1061 idSpaceFillerPanel1.setBackground(Color.white);
1063 // idSpaceFillerPanel1.setPreferredSize(new Dimension(10, 30));
1064 idSpaceFillerPanel1.setLayout(new BorderLayout());
1065 annotationSpaceFillerHolder.setBackground(Color.white);
1067 // annotationSpaceFillerHolder.setPreferredSize(new Dimension(10, 80));
1068 annotationSpaceFillerHolder.setLayout(new BorderLayout());
1069 hscroll.setOrientation(Scrollbar.HORIZONTAL);
1071 Panel hscrollHolder = new Panel();
1072 hscrollHolder.setLayout(new BorderLayout());
1073 hscrollFillerPanel.setBackground(Color.white);
1074 apvscroll.setOrientation(Scrollbar.VERTICAL);
1075 apvscroll.setVisible(true);
1076 apvscroll.addAdjustmentListener(this);
1078 annotationPanelHolder.setBackground(Color.white);
1079 annotationPanelHolder.setLayout(new BorderLayout());
1080 annotationPanelHolder.add(apvscroll, BorderLayout.EAST);
1081 // hscrollFillerPanel.setPreferredSize(new Dimension(70, 10));
1082 hscrollHolder.setBackground(Color.white);
1084 // annotationScroller.setPreferredSize(new Dimension(10, 80));
1085 // this.setPreferredSize(new Dimension(220, 166));
1086 seqPanelHolder.setBackground(Color.white);
1087 idPanelHolder.setBackground(Color.white);
1088 sequenceHolderPanel.add(scalePanelHolder, BorderLayout.NORTH);
1089 sequenceHolderPanel.add(seqPanelHolder, BorderLayout.CENTER);
1090 seqPanelHolder.add(vscroll, BorderLayout.EAST);
1092 // Panel3.add(secondaryPanelHolder, BorderLayout.SOUTH);
1093 this.add(idPanelHolder, BorderLayout.WEST);
1094 idPanelHolder.add(idSpaceFillerPanel1, BorderLayout.NORTH);
1095 idPanelHolder.add(annotationSpaceFillerHolder, BorderLayout.SOUTH);
1096 this.add(hscrollHolder, BorderLayout.SOUTH);
1097 hscrollHolder.add(hscroll, BorderLayout.CENTER);
1098 hscrollHolder.add(hscrollFillerPanel, BorderLayout.WEST);
1099 this.add(sequenceHolderPanel, BorderLayout.CENTER);
1103 * hides or shows dynamic annotation rows based on groups and av state flags
1105 public void updateAnnotation()
1107 updateAnnotation(false);
1110 public void updateAnnotation(boolean applyGlobalSettings)
1112 updateAnnotation(applyGlobalSettings, false);
1115 public void updateAnnotation(boolean applyGlobalSettings,
1116 boolean preserveNewGroupSettings)
1118 av.updateGroupAnnotationSettings(applyGlobalSettings,
1119 preserveNewGroupSettings);
1120 adjustAnnotationHeight();
1124 public AlignmentI getAlignment()
1126 return av.getAlignment();
1130 public String getViewName()
1136 public StructureSelectionManager getStructureSelectionManager()
1138 return StructureSelectionManager
1139 .getStructureSelectionManager(av.applet);
1143 public void raiseOOMWarning(String string, OutOfMemoryError error)
1146 System.err.println("Out of memory whilst '" + string + "'");
1147 error.printStackTrace();
1151 * Set a flag to say we are scrolling to follow a (cDNA/protein) complement.
1155 protected void setFollowingComplementScroll(boolean b)
1157 this.followingComplementScroll = b;
1160 protected boolean isFollowingComplementScroll()
1162 return this.followingComplementScroll;