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;
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(SearchResultsI 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(SearchResultsI 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(SearchResultsI results,
324 boolean redrawOverview)
326 return scrollToPosition(results, 0, 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(SearchResultsI results,
340 boolean redrawOverview, boolean centre)
342 // do we need to scroll the panel?
343 if (results != null && results.getSize() > 0)
345 AlignmentI alignment = av.getAlignment();
346 int seqIndex = alignment.findIndex(results);
352 * allow for offset of target sequence (actually scroll to one above it)
355 SequenceI seq = alignment.getSequenceAt(seqIndex);
356 int[] r = results.getResults(seq, 0, alignment.getWidth());
359 if (JalviewLite.debug)
362 .println("DEBUG: scroll didn't happen - results not within alignment : "
363 + seq.getStart() + "," + seq.getEnd());
367 if (JalviewLite.debug)
371 * System.out.println("DEBUG: scroll: start=" + r[0] +
372 * " av.getStartRes()=" + av.getStartRes() + " end=" + r[1] +
373 * " seq.end=" + seq.getEnd() + " av.getEndRes()=" + av.getEndRes() +
374 * " hextent=" + hextent);
381 * To centre results, scroll to positions half the visible width
382 * left/right of the start/end positions
386 int offset = (av.getEndRes() - av.getStartRes() + 1) / 2 - 1;
387 start = Math.max(start - offset, 0);
388 end = Math.min(end + offset, seq.getEnd() - 1);
395 if (end == seq.getEnd())
401 * allow for offset of target sequence (actually scroll to one above it)
403 seqIndex = Math.max(0, seqIndex - verticalOffset);
404 return scrollTo(start, end, seqIndex, false, redrawOverview);
409 public boolean scrollTo(int ostart, int end, int seqIndex,
410 boolean scrollToNearest, boolean redrawOverview)
412 int startv, endv, starts, ends, width;
415 if (av.hasHiddenColumns())
417 start = av.getColumnSelection().findColumnPosition(ostart);
418 end = av.getColumnSelection().findColumnPosition(end);
421 if (!scrollToNearest && !av.getColumnSelection().isVisible(ostart))
423 // don't scroll - position isn't visible
433 if (!av.getWrapAlignment())
436 * int spos=av.getStartRes(),sqpos=av.getStartSeq(); if ((startv =
437 * av.getStartRes()) >= start) { spos=start-1; // seqIn //
438 * setScrollValues(start - 1, seqIndex); } else if ((endv =
439 * av.getEndRes()) <= end) { // setScrollValues(spos=startv + 1 + end -
440 * endv, seqIndex); spos=startv + 1 + end - endv; } else if ((starts =
441 * av.getStartSeq()) > seqIndex) { setScrollValues(av.getStartRes(),
442 * seqIndex); } else if ((ends = av.getEndSeq()) <= seqIndex) {
443 * setScrollValues(av.getStartRes(), starts + seqIndex - ends + 1); }
446 // below is scrolling logic up to Jalview 2.8.2
447 // if ((av.getStartRes() > end)
448 // || (av.getEndRes() < start)
449 // || ((av.getStartSeq() > seqIndex) || (av.getEndSeq() < seqIndex)))
451 // if (start > av.getAlignment().getWidth() - hextent)
453 // start = av.getAlignment().getWidth() - hextent;
460 // if (seqIndex > av.getAlignment().getHeight() - vextent)
462 // seqIndex = av.getAlignment().getHeight() - vextent;
468 // setScrollValues(start, seqIndex);
470 // logic copied from jalview.gui.AlignmentPanel:
471 if ((startv = av.getStartRes()) >= start)
474 * Scroll left to make start of search results visible
476 setScrollValues(start - 1, seqIndex);
478 else if ((endv = av.getEndRes()) <= end)
481 * Scroll right to make end of search results visible
483 setScrollValues(startv + 1 + end - endv, seqIndex);
485 else if ((starts = av.getStartSeq()) > seqIndex)
488 * Scroll up to make start of search results visible
490 setScrollValues(av.getStartRes(), seqIndex);
492 else if ((ends = av.getEndSeq()) <= seqIndex)
495 * Scroll down to make end of search results visible
497 setScrollValues(av.getStartRes(), starts + seqIndex - ends + 1);
500 * Else results are already visible - no need to scroll
505 scrollToWrappedVisible(start);
507 if (redrawOverview && overviewPanel != null)
509 overviewPanel.setBoxPosition();
511 paintAlignment(redrawOverview);
515 void scrollToWrappedVisible(int res)
517 int cwidth = seqPanel.seqCanvas
518 .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width);
519 if (res <= av.getStartRes() || res >= (av.getStartRes() + cwidth))
521 vscroll.setValue(res / cwidth);
522 av.startRes = vscroll.getValue() * cwidth;
526 public OverviewPanel getOverviewPanel()
528 return overviewPanel;
531 public void setOverviewPanel(OverviewPanel op)
536 public void setAnnotationVisible(boolean b)
538 if (!av.getWrapAlignment())
540 annotationSpaceFillerHolder.setVisible(b);
541 annotationPanelHolder.setVisible(b);
545 annotationSpaceFillerHolder.setVisible(false);
546 annotationPanelHolder.setVisible(false);
553 * automatically adjust annotation panel height for new annotation whilst
554 * ensuring the alignment is still visible.
557 public void adjustAnnotationHeight()
559 // TODO: display vertical annotation scrollbar if necessary
560 // this is called after loading new annotation onto alignment
561 if (alignFrame.getSize().height == 0)
564 .println("adjustAnnotationHeight frame size zero NEEDS FIXING");
567 validateAnnotationDimensions(true);
568 apvscroll.addNotify();
571 paintAlignment(true);
575 * Calculate the annotation dimensions and refresh slider values accordingly.
576 * Need to do repaints/notifys afterwards.
578 protected void validateAnnotationDimensions(boolean adjustPanelHeight)
580 int rowHeight = av.getCharHeight();
581 int alignmentHeight = rowHeight * av.getAlignment().getHeight();
582 int annotationHeight = av.calcPanelHeight();
584 int mheight = annotationHeight;
585 Dimension d = sequenceHolderPanel.getSize();
587 int availableHeight = d.height - scalePanelHolder.getHeight();
589 if (adjustPanelHeight)
592 * If not enough vertical space, maximize annotation height while keeping
593 * at least two rows of alignment visible
595 if (annotationHeight + alignmentHeight > availableHeight)
597 annotationHeight = Math.min(annotationHeight, availableHeight - 2
603 // maintain same window layout whilst updating sliders
604 annotationHeight = annotationPanelHolder.getSize().height;
607 if (availableHeight - annotationHeight < 5)
609 annotationHeight = availableHeight;
612 annotationPanel.setSize(new Dimension(d.width, annotationHeight));
613 annotationPanelHolder.setSize(new Dimension(d.width, annotationHeight));
614 // seqPanelHolder.setSize(d.width, seqandannot - height);
616 .setSize(d.width, seqPanel.seqCanvas.getSize().height);
618 Dimension e = idPanel.getSize();
619 alabels.setSize(new Dimension(e.width, annotationHeight));
620 annotationSpaceFillerHolder.setSize(new Dimension(e.width,
623 int s = apvscroll.getValue();
624 if (s > mheight - annotationHeight)
628 apvscroll.setValues(s, annotationHeight, 0, mheight);
629 annotationPanel.setScrollOffset(apvscroll.getValue(), false);
630 alabels.setScrollOffset(apvscroll.getValue(), false);
633 public void setWrapAlignment(boolean wrap)
637 scalePanelHolder.setVisible(!wrap);
639 hscroll.setVisible(!wrap);
640 idwidthAdjuster.setVisible(!wrap);
644 annotationPanelHolder.setVisible(false);
645 annotationSpaceFillerHolder.setVisible(false);
647 else if (av.isShowAnnotation())
649 annotationPanelHolder.setVisible(true);
650 annotationSpaceFillerHolder.setVisible(true);
653 idSpaceFillerPanel1.setVisible(!wrap);
655 fontChanged(); // This is so that the scalePanel is resized correctly
658 sequenceHolderPanel.validate();
667 // return value is true if the scroll is valid
668 public boolean scrollUp(boolean up)
672 if (vscroll.getValue() < 1)
676 setScrollValues(hscroll.getValue(), vscroll.getValue() - 1);
680 if (vextent + vscroll.getValue() >= av.getAlignment().getHeight())
684 setScrollValues(hscroll.getValue(), vscroll.getValue() + 1);
691 public boolean scrollRight(boolean right)
695 if (hscroll.getValue() < 1)
699 setScrollValues(hscroll.getValue() - 1, vscroll.getValue());
703 if (hextent + hscroll.getValue() >= av.getAlignment().getWidth())
707 setScrollValues(hscroll.getValue() + 1, vscroll.getValue());
714 public void setScrollValues(int x, int y)
716 int width = av.getAlignment().getWidth();
717 int height = av.getAlignment().getHeight();
719 if (av.hasHiddenColumns())
721 width = av.getColumnSelection().findColumnPosition(width);
729 hextent = seqPanel.seqCanvas.getSize().width / av.getCharWidth();
730 vextent = seqPanel.seqCanvas.getSize().height / av.getCharHeight();
737 if (vextent > height)
742 if ((hextent + x) > width)
744 System.err.println("hextent was " + hextent + " and x was " + x);
749 if ((vextent + y) > height)
751 y = height - vextent;
761 System.err.println("x was " + x);
767 int endSeq = y + vextent;
768 if (endSeq > av.getAlignment().getHeight())
770 endSeq = av.getAlignment().getHeight();
773 av.setEndSeq(endSeq);
775 av.setEndRes((x + (seqPanel.seqCanvas.getSize().width / av
776 .getCharWidth())) - 1);
778 hscroll.setValues(x, hextent, 0, width);
779 vscroll.setValues(y, vextent, 0, height);
781 if (overviewPanel != null)
783 overviewPanel.setBoxPosition();
790 public void adjustmentValueChanged(AdjustmentEvent evt)
792 int oldX = av.getStartRes();
793 int oldY = av.getStartSeq();
795 if (evt == null || evt.getSource() == apvscroll)
797 annotationPanel.setScrollOffset(apvscroll.getValue(), false);
798 alabels.setScrollOffset(apvscroll.getValue(), false);
799 // annotationPanel.image=null;
800 // alabels.image=null;
801 // alabels.repaint();
802 // annotationPanel.repaint();
804 if (evt == null || evt.getSource() == hscroll)
806 int x = hscroll.getValue();
808 av.setEndRes(x + seqPanel.seqCanvas.getSize().width
809 / av.getCharWidth() - 1);
812 if (evt == null || evt.getSource() == vscroll)
814 int offy = vscroll.getValue();
815 if (av.getWrapAlignment())
817 int rowSize = seqPanel.seqCanvas
818 .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width);
819 av.setStartRes(vscroll.getValue() * rowSize);
820 av.setEndRes((vscroll.getValue() + 1) * rowSize);
824 av.setStartSeq(offy);
825 av.setEndSeq(offy + seqPanel.seqCanvas.getSize().height
826 / av.getCharHeight());
830 if (overviewPanel != null)
832 overviewPanel.setBoxPosition();
835 int scrollX = av.startRes - oldX;
836 int scrollY = av.startSeq - oldY;
838 if (av.getWrapAlignment() || !fastPaint || av.MAC)
844 // Make sure we're not trying to draw a panel
845 // larger than the visible window
846 if (scrollX > av.endRes - av.startRes)
848 scrollX = av.endRes - av.startRes;
850 else if (scrollX < av.startRes - av.endRes)
852 scrollX = av.startRes - av.endRes;
855 idPanel.idCanvas.fastPaint(scrollY);
856 seqPanel.seqCanvas.fastPaint(scrollX, scrollY);
858 scalePanel.repaint();
859 if (av.isShowAnnotation())
861 annotationPanel.fastPaint(av.getStartRes() - oldX);
867 * If there is one, scroll the (Protein/cDNA) complementary alignment to
868 * match, unless we are ourselves doing that.
870 if (isFollowingComplementScroll())
872 setFollowingComplementScroll(false);
876 AlignmentPanel ap = getComplementPanel();
877 av.scrollComplementaryAlignment(ap);
883 * A helper method to return the AlignmentPanel in the other (complementary)
884 * half of a SplitFrame view. Returns null if not in a SplitFrame.
888 private AlignmentPanel getComplementPanel()
890 AlignmentPanel ap = null;
891 if (alignFrame != null)
893 SplitFrame sf = alignFrame.getSplitFrame();
896 AlignFrame other = sf.getComplement(alignFrame);
899 ap = other.alignPanel;
907 * Follow a scrolling change in the (cDNA/Protein) complementary alignment.
908 * The aim is to keep the two alignments 'lined up' on their centre columns.
911 * holds mapped region(s) of this alignment that we are scrolling
912 * 'to'; may be modified for sequence offset by this method
914 * the number of visible sequences to show above the mapped region
916 protected void scrollToCentre(SearchResultsI sr, int seqOffset)
919 * To avoid jumpy vertical scrolling (if some sequences are gapped or not
920 * mapped), we can make the scroll-to location a sequence above the one
923 SequenceI mappedTo = sr.getResults().get(0).getSequence();
924 List<SequenceI> seqs = av.getAlignment().getSequences();
927 * This is like AlignmentI.findIndex(seq) but here we are matching the
928 * dataset sequence not the aligned sequence
930 int sequenceIndex = 0;
931 boolean matched = false;
932 for (SequenceI seq : seqs)
934 if (mappedTo == seq.getDatasetSequence())
943 return; // failsafe, shouldn't happen
947 * Scroll to position but centring the target residue. Also set a state flag
948 * to prevent adjustmentValueChanged performing this recursively.
950 setFollowingComplementScroll(true);
951 // this should be scrollToPosition(sr,verticalOffset,
952 scrollToPosition(sr, seqOffset, true, true);
955 private void sendViewPosition()
957 StructureSelectionManager.getStructureSelectionManager(av.applet)
958 .sendViewPosition(this, av.startRes, av.endRes, av.startSeq,
963 * Repaint the alignment and annotations, and, optionally, any overview window
966 public void paintAlignment(boolean updateOverview)
968 final AnnotationSorter sorter = new AnnotationSorter(getAlignment(),
969 av.isShowAutocalculatedAbove());
970 sorter.sort(getAlignment().getAlignmentAnnotation(),
971 av.getSortAnnotationsBy());
976 // TODO: determine if this paintAlignment changed structure colours
977 jalview.structure.StructureSelectionManager
978 .getStructureSelectionManager(av.applet)
979 .sequenceColoursChanged(this);
981 if (overviewPanel != null)
983 overviewPanel.updateOverviewImage();
989 public void update(Graphics g)
995 public void paint(Graphics g)
998 Dimension d = idPanel.idCanvas.getSize();
999 final int canvasHeight = seqPanel.seqCanvas.getSize().height;
1000 if (canvasHeight != d.height)
1002 idPanel.idCanvas.setSize(d.width, canvasHeight);
1005 if (av.getWrapAlignment())
1007 int maxwidth = av.getAlignment().getWidth();
1009 if (av.hasHiddenColumns())
1011 maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
1014 int canvasWidth = seqPanel.seqCanvas
1015 .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width);
1017 if (canvasWidth > 0)
1019 int max = maxwidth / canvasWidth;
1020 vscroll.setMaximum(1 + max);
1021 vscroll.setUnitIncrement(1);
1022 vscroll.setVisibleAmount(1);
1027 setScrollValues(av.getStartRes(), av.getStartSeq());
1030 seqPanel.seqCanvas.repaint();
1031 idPanel.idCanvas.repaint();
1032 if (!av.getWrapAlignment())
1034 if (av.isShowAnnotation())
1037 annotationPanel.repaint();
1039 scalePanel.repaint();
1044 protected Panel sequenceHolderPanel = new Panel();
1046 protected Scrollbar vscroll = new Scrollbar();
1048 protected Scrollbar hscroll = new Scrollbar();
1050 protected Panel seqPanelHolder = new Panel();
1052 protected Panel scalePanelHolder = new Panel();
1054 protected Panel idPanelHolder = new Panel();
1056 protected Panel idSpaceFillerPanel1 = new Panel();
1058 public Panel annotationSpaceFillerHolder = new Panel();
1060 protected Panel hscrollFillerPanel = new Panel();
1062 Panel annotationPanelHolder = new Panel();
1064 protected Scrollbar apvscroll = new Scrollbar();
1067 * Flag set while scrolling to follow complementary cDNA/protein scroll. When
1068 * true, suppresses invoking the same method recursively.
1070 private boolean followingComplementScroll;
1072 private void jbInit() throws Exception
1074 // idPanelHolder.setPreferredSize(new Dimension(70, 10));
1075 this.setLayout(new BorderLayout());
1077 // sequenceHolderPanel.setPreferredSize(new Dimension(150, 150));
1078 sequenceHolderPanel.setLayout(new BorderLayout());
1079 seqPanelHolder.setLayout(new BorderLayout());
1080 scalePanelHolder.setBackground(Color.white);
1082 // scalePanelHolder.setPreferredSize(new Dimension(10, 30));
1083 scalePanelHolder.setLayout(new BorderLayout());
1084 idPanelHolder.setLayout(new BorderLayout());
1085 idSpaceFillerPanel1.setBackground(Color.white);
1087 // idSpaceFillerPanel1.setPreferredSize(new Dimension(10, 30));
1088 idSpaceFillerPanel1.setLayout(new BorderLayout());
1089 annotationSpaceFillerHolder.setBackground(Color.white);
1091 // annotationSpaceFillerHolder.setPreferredSize(new Dimension(10, 80));
1092 annotationSpaceFillerHolder.setLayout(new BorderLayout());
1093 hscroll.setOrientation(Scrollbar.HORIZONTAL);
1095 Panel hscrollHolder = new Panel();
1096 hscrollHolder.setLayout(new BorderLayout());
1097 hscrollFillerPanel.setBackground(Color.white);
1098 apvscroll.setOrientation(Scrollbar.VERTICAL);
1099 apvscroll.setVisible(true);
1100 apvscroll.addAdjustmentListener(this);
1102 annotationPanelHolder.setBackground(Color.white);
1103 annotationPanelHolder.setLayout(new BorderLayout());
1104 annotationPanelHolder.add(apvscroll, BorderLayout.EAST);
1105 // hscrollFillerPanel.setPreferredSize(new Dimension(70, 10));
1106 hscrollHolder.setBackground(Color.white);
1108 // annotationScroller.setPreferredSize(new Dimension(10, 80));
1109 // this.setPreferredSize(new Dimension(220, 166));
1110 seqPanelHolder.setBackground(Color.white);
1111 idPanelHolder.setBackground(Color.white);
1112 sequenceHolderPanel.add(scalePanelHolder, BorderLayout.NORTH);
1113 sequenceHolderPanel.add(seqPanelHolder, BorderLayout.CENTER);
1114 seqPanelHolder.add(vscroll, BorderLayout.EAST);
1116 // Panel3.add(secondaryPanelHolder, BorderLayout.SOUTH);
1117 this.add(idPanelHolder, BorderLayout.WEST);
1118 idPanelHolder.add(idSpaceFillerPanel1, BorderLayout.NORTH);
1119 idPanelHolder.add(annotationSpaceFillerHolder, BorderLayout.SOUTH);
1120 this.add(hscrollHolder, BorderLayout.SOUTH);
1121 hscrollHolder.add(hscroll, BorderLayout.CENTER);
1122 hscrollHolder.add(hscrollFillerPanel, BorderLayout.WEST);
1123 this.add(sequenceHolderPanel, BorderLayout.CENTER);
1127 * hides or shows dynamic annotation rows based on groups and av state flags
1129 public void updateAnnotation()
1131 updateAnnotation(false);
1134 public void updateAnnotation(boolean applyGlobalSettings)
1136 updateAnnotation(applyGlobalSettings, false);
1139 public void updateAnnotation(boolean applyGlobalSettings,
1140 boolean preserveNewGroupSettings)
1142 av.updateGroupAnnotationSettings(applyGlobalSettings,
1143 preserveNewGroupSettings);
1144 adjustAnnotationHeight();
1148 public AlignmentI getAlignment()
1150 return av.getAlignment();
1154 public String getViewName()
1160 public StructureSelectionManager getStructureSelectionManager()
1162 return StructureSelectionManager
1163 .getStructureSelectionManager(av.applet);
1167 public void raiseOOMWarning(String string, OutOfMemoryError error)
1170 System.err.println("Out of memory whilst '" + string + "'");
1171 error.printStackTrace();
1175 * Set a flag to say we are scrolling to follow a (cDNA/protein) complement.
1179 protected void setFollowingComplementScroll(boolean b)
1181 this.followingComplementScroll = b;
1184 protected boolean isFollowingComplementScroll()
1186 return this.followingComplementScroll;