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;
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)
97 seqPanel = new SeqPanel(av, this);
98 idPanel = new IdPanel(av, this);
99 scalePanel = new ScalePanel(av, this);
100 idwidthAdjuster = new IdwidthAdjuster(this);
101 annotationPanel = new AnnotationPanel(this);
102 annotationPanelHolder.add(annotationPanel, BorderLayout.CENTER);
104 sequenceHolderPanel.add(annotationPanelHolder, BorderLayout.SOUTH);
105 alabels = new AnnotationLabels(this);
107 setAnnotationVisible(av.isShowAnnotation());
109 idPanelHolder.add(idPanel, BorderLayout.CENTER);
110 idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER);
111 annotationSpaceFillerHolder.add(alabels, BorderLayout.CENTER);
112 scalePanelHolder.add(scalePanel, BorderLayout.CENTER);
113 seqPanelHolder.add(seqPanel, BorderLayout.CENTER);
116 setScrollValues(0, 0);
118 apvscroll.addAdjustmentListener(this);
119 hscroll.addAdjustmentListener(this);
120 vscroll.addAdjustmentListener(this);
122 addComponentListener(new ComponentAdapter()
124 public void componentResized(ComponentEvent evt)
126 setScrollValues(av.getStartRes(), av.getStartSeq());
127 if (getSize().height > 0
128 && annotationPanelHolder.getSize().height > 0)
130 validateAnnotationDimensions(false);
137 Dimension d = calculateIdWidth();
138 idPanel.idCanvas.setSize(d);
140 hscrollFillerPanel.setSize(d.width, annotationPanel.getSize().height);
142 idPanel.idCanvas.setSize(d.width, seqPanel.seqCanvas.getSize().height);
143 annotationSpaceFillerHolder.setSize(d.width,
144 annotationPanel.getSize().height);
145 alabels.setSize(d.width, annotationPanel.getSize().height);
146 final AlignmentPanel ap = this;
147 av.addPropertyChangeListener(new java.beans.PropertyChangeListener()
149 public void propertyChange(java.beans.PropertyChangeEvent evt)
151 if (evt.getPropertyName().equals("alignment"))
153 PaintRefresher.Refresh(ap, av.getSequenceSetId(), true, true);
161 public AlignViewportI getAlignViewport()
165 public SequenceRenderer getSequenceRenderer()
167 return seqPanel.seqCanvas.sr;
170 public jalview.api.FeatureRenderer getFeatureRenderer()
172 return seqPanel.seqCanvas.fr;
175 public jalview.api.FeatureRenderer cloneFeatureRenderer()
177 FeatureRenderer nfr = new FeatureRenderer(av);
178 nfr.transferSettings(seqPanel.seqCanvas.fr);
181 public void alignmentChanged()
183 av.alignmentChanged(this);
185 if (overviewPanel != null)
187 overviewPanel.updateOverviewImage();
190 alignFrame.updateEditMenuBar();
195 public void fontChanged()
197 // set idCanvas bufferedImage to null
198 // to prevent drawing old image
199 idPanel.idCanvas.image = null;
200 FontMetrics fm = getFontMetrics(av.getFont());
202 scalePanel.setSize(new Dimension(10, av.getCharHeight()
204 idwidthAdjuster.setSize(new Dimension(10, av.getCharHeight()
206 av.updateSequenceIdColours();
207 annotationPanel.image = null;
208 int ap = annotationPanel.adjustPanelHeight(false);
209 Dimension d = calculateIdWidth();
210 d.setSize(d.width + 4, seqPanel.seqCanvas.getSize().height);
211 alabels.setSize(d.width + 4, ap);
213 idPanel.idCanvas.setSize(d);
214 hscrollFillerPanel.setSize(d);
216 validateAnnotationDimensions(false);
217 annotationPanel.repaint();
221 if (overviewPanel != null)
223 overviewPanel.updateOverviewImage();
227 public void setIdWidth(int w, int h)
229 idPanel.idCanvas.setSize(w, h);
230 idPanelHolder.setSize(w, idPanelHolder.getSize().height);
231 annotationSpaceFillerHolder.setSize(w,
232 annotationSpaceFillerHolder.getSize().height);
233 alabels.setSize(w, alabels.getSize().height);
237 Dimension calculateIdWidth()
239 if (av.nullFrame == null)
241 av.nullFrame = new Frame();
242 av.nullFrame.addNotify();
245 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 int oldX = av.getStartRes();
772 int oldY = av.getStartSeq();
774 if (evt == null || evt.getSource() == apvscroll)
776 annotationPanel.setScrollOffset(apvscroll.getValue(), false);
777 alabels.setScrollOffset(apvscroll.getValue(), false);
778 // annotationPanel.image=null;
779 // alabels.image=null;
780 // alabels.repaint();
781 // annotationPanel.repaint();
783 if (evt == null || evt.getSource() == hscroll)
785 int x = hscroll.getValue();
787 av.setEndRes(x + seqPanel.seqCanvas.getSize().width
788 / av.getCharWidth() - 1);
791 if (evt == null || evt.getSource() == vscroll)
793 int offy = vscroll.getValue();
794 if (av.getWrapAlignment())
796 int rowSize = seqPanel.seqCanvas
797 .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width);
798 av.setStartRes(vscroll.getValue() * rowSize);
799 av.setEndRes((vscroll.getValue() + 1) * rowSize);
803 av.setStartSeq(offy);
804 av.setEndSeq(offy + seqPanel.seqCanvas.getSize().height
805 / av.getCharHeight());
809 if (overviewPanel != null)
811 overviewPanel.setBoxPosition();
814 int scrollX = av.startRes - oldX;
815 int scrollY = av.startSeq - oldY;
817 if (av.getWrapAlignment() || !fastPaint || av.MAC)
823 // Make sure we're not trying to draw a panel
824 // larger than the visible window
825 if (scrollX > av.endRes - av.startRes)
827 scrollX = av.endRes - av.startRes;
829 else if (scrollX < av.startRes - av.endRes)
831 scrollX = av.startRes - av.endRes;
834 idPanel.idCanvas.fastPaint(scrollY);
835 seqPanel.seqCanvas.fastPaint(scrollX, scrollY);
837 scalePanel.repaint();
838 if (av.isShowAnnotation())
840 annotationPanel.fastPaint(av.getStartRes() - oldX);
846 * If there is one, scroll the (Protein/cDNA) complementary alignment to
847 * match, unless we are ourselves doing that.
849 if (isFollowingComplementScroll())
851 setFollowingComplementScroll(false);
855 AlignmentPanel ap = getComplementPanel();
856 av.scrollComplementaryAlignment(ap);
862 * A helper method to return the AlignmentPanel in the other (complementary)
863 * half of a SplitFrame view. Returns null if not in a SplitFrame.
867 private AlignmentPanel getComplementPanel()
869 AlignmentPanel ap = null;
870 if (alignFrame != null)
872 SplitFrame sf = alignFrame.getSplitFrame();
875 AlignFrame other = sf.getComplement(alignFrame);
878 ap = other.alignPanel;
886 * Follow a scrolling change in the (cDNA/Protein) complementary alignment.
887 * The aim is to keep the two alignments 'lined up' on their centre columns.
890 * holds mapped region(s) of this alignment that we are scrolling
891 * 'to'; may be modified for sequence offset by this method
893 * the number of visible sequences to show above the mapped region
895 protected void scrollToCentre(SearchResults sr, int seqOffset)
898 * To avoid jumpy vertical scrolling (if some sequences are gapped or not
899 * mapped), we can make the scroll-to location a sequence above the one
902 SequenceI mappedTo = sr.getResultSequence(0);
903 List<SequenceI> seqs = av.getAlignment().getSequences();
906 * This is like AlignmentI.findIndex(seq) but here we are matching the
907 * dataset sequence not the aligned sequence
909 int sequenceIndex = 0;
910 boolean matched = false;
911 for (SequenceI seq : seqs)
913 if (mappedTo == seq.getDatasetSequence())
922 return; // failsafe, shouldn't happen
924 sequenceIndex = Math.max(0, sequenceIndex - seqOffset);
925 sr.getResults().get(0)
926 .setSequence(av.getAlignment().getSequenceAt(sequenceIndex));
929 * Scroll to position but centring the target residue. Also set a state flag
930 * to prevent adjustmentValueChanged performing this recursively.
932 setFollowingComplementScroll(true);
933 scrollToPosition(sr, true, true);
936 private void sendViewPosition()
938 StructureSelectionManager.getStructureSelectionManager(av.applet)
939 .sendViewPosition(this, av.startRes, av.endRes, av.startSeq,
944 * Repaint the alignment and annotations, and, optionally, any overview window
946 public void paintAlignment(boolean updateOverview)
948 final AnnotationSorter sorter = new AnnotationSorter(getAlignment(),
949 av.isShowAutocalculatedAbove());
950 sorter.sort(getAlignment().getAlignmentAnnotation(),
951 av.getSortAnnotationsBy());
956 jalview.structure.StructureSelectionManager
957 .getStructureSelectionManager(av.applet)
958 .sequenceColoursChanged(this);
960 if (overviewPanel != null)
962 overviewPanel.updateOverviewImage();
967 public void update(Graphics g)
972 public void paint(Graphics g)
975 Dimension d = idPanel.idCanvas.getSize();
976 final int canvasHeight = seqPanel.seqCanvas.getSize().height;
977 if (canvasHeight != d.height)
979 idPanel.idCanvas.setSize(d.width, canvasHeight);
982 if (av.getWrapAlignment())
984 int maxwidth = av.getAlignment().getWidth();
986 if (av.hasHiddenColumns())
988 maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
991 int canvasWidth = seqPanel.seqCanvas
992 .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width);
996 int max = maxwidth / canvasWidth;
997 vscroll.setMaximum(1 + max);
998 vscroll.setUnitIncrement(1);
999 vscroll.setVisibleAmount(1);
1004 setScrollValues(av.getStartRes(), av.getStartSeq());
1007 seqPanel.seqCanvas.repaint();
1008 idPanel.idCanvas.repaint();
1009 if (!av.getWrapAlignment())
1011 if (av.isShowAnnotation())
1014 annotationPanel.repaint();
1016 scalePanel.repaint();
1021 protected Panel sequenceHolderPanel = new Panel();
1023 protected Scrollbar vscroll = new Scrollbar();
1025 protected Scrollbar hscroll = new Scrollbar();
1027 protected Panel seqPanelHolder = new Panel();
1029 protected Panel scalePanelHolder = new Panel();
1031 protected Panel idPanelHolder = new Panel();
1033 protected Panel idSpaceFillerPanel1 = new Panel();
1035 public Panel annotationSpaceFillerHolder = new Panel();
1037 protected Panel hscrollFillerPanel = new Panel();
1039 Panel annotationPanelHolder = new Panel();
1041 protected Scrollbar apvscroll = new Scrollbar();
1044 * Flag set while scrolling to follow complementary cDNA/protein scroll. When
1045 * true, suppresses invoking the same method recursively.
1047 private boolean followingComplementScroll;
1049 private void jbInit() throws Exception
1051 // idPanelHolder.setPreferredSize(new Dimension(70, 10));
1052 this.setLayout(new BorderLayout());
1054 // sequenceHolderPanel.setPreferredSize(new Dimension(150, 150));
1055 sequenceHolderPanel.setLayout(new BorderLayout());
1056 seqPanelHolder.setLayout(new BorderLayout());
1057 scalePanelHolder.setBackground(Color.white);
1059 // scalePanelHolder.setPreferredSize(new Dimension(10, 30));
1060 scalePanelHolder.setLayout(new BorderLayout());
1061 idPanelHolder.setLayout(new BorderLayout());
1062 idSpaceFillerPanel1.setBackground(Color.white);
1064 // idSpaceFillerPanel1.setPreferredSize(new Dimension(10, 30));
1065 idSpaceFillerPanel1.setLayout(new BorderLayout());
1066 annotationSpaceFillerHolder.setBackground(Color.white);
1068 // annotationSpaceFillerHolder.setPreferredSize(new Dimension(10, 80));
1069 annotationSpaceFillerHolder.setLayout(new BorderLayout());
1070 hscroll.setOrientation(Scrollbar.HORIZONTAL);
1072 Panel hscrollHolder = new Panel();
1073 hscrollHolder.setLayout(new BorderLayout());
1074 hscrollFillerPanel.setBackground(Color.white);
1075 apvscroll.setOrientation(Scrollbar.VERTICAL);
1076 apvscroll.setVisible(true);
1077 apvscroll.addAdjustmentListener(this);
1079 annotationPanelHolder.setBackground(Color.white);
1080 annotationPanelHolder.setLayout(new BorderLayout());
1081 annotationPanelHolder.add(apvscroll, BorderLayout.EAST);
1082 // hscrollFillerPanel.setPreferredSize(new Dimension(70, 10));
1083 hscrollHolder.setBackground(Color.white);
1085 // annotationScroller.setPreferredSize(new Dimension(10, 80));
1086 // this.setPreferredSize(new Dimension(220, 166));
1087 seqPanelHolder.setBackground(Color.white);
1088 idPanelHolder.setBackground(Color.white);
1089 sequenceHolderPanel.add(scalePanelHolder, BorderLayout.NORTH);
1090 sequenceHolderPanel.add(seqPanelHolder, BorderLayout.CENTER);
1091 seqPanelHolder.add(vscroll, BorderLayout.EAST);
1093 // Panel3.add(secondaryPanelHolder, BorderLayout.SOUTH);
1094 this.add(idPanelHolder, BorderLayout.WEST);
1095 idPanelHolder.add(idSpaceFillerPanel1, BorderLayout.NORTH);
1096 idPanelHolder.add(annotationSpaceFillerHolder, BorderLayout.SOUTH);
1097 this.add(hscrollHolder, BorderLayout.SOUTH);
1098 hscrollHolder.add(hscroll, BorderLayout.CENTER);
1099 hscrollHolder.add(hscrollFillerPanel, BorderLayout.WEST);
1100 this.add(sequenceHolderPanel, BorderLayout.CENTER);
1104 * hides or shows dynamic annotation rows based on groups and av state flags
1106 public void updateAnnotation()
1108 updateAnnotation(false);
1111 public void updateAnnotation(boolean applyGlobalSettings)
1113 updateAnnotation(applyGlobalSettings, false);
1116 public void updateAnnotation(boolean applyGlobalSettings,
1117 boolean preserveNewGroupSettings)
1119 av.updateGroupAnnotationSettings(applyGlobalSettings,
1120 preserveNewGroupSettings);
1121 adjustAnnotationHeight();
1125 public AlignmentI getAlignment()
1127 return av.getAlignment();
1131 public String getViewName()
1137 public StructureSelectionManager getStructureSelectionManager()
1139 return StructureSelectionManager
1140 .getStructureSelectionManager(av.applet);
1144 public void raiseOOMWarning(String string, OutOfMemoryError error)
1147 System.err.println("Out of memory whilst '" + string + "'");
1148 error.printStackTrace();
1152 * Set a flag to say we are scrolling to follow a (cDNA/protein) complement.
1156 protected void setFollowingComplementScroll(boolean b)
1158 this.followingComplementScroll = b;
1161 protected boolean isFollowingComplementScroll()
1163 return this.followingComplementScroll;