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 java.awt.BorderLayout;
24 import java.awt.Color;
25 import java.awt.Dimension;
26 import java.awt.FontMetrics;
27 import java.awt.Frame;
28 import java.awt.Graphics;
29 import java.awt.Panel;
30 import java.awt.Scrollbar;
31 import java.awt.event.AdjustmentEvent;
32 import java.awt.event.AdjustmentListener;
33 import java.awt.event.ComponentAdapter;
34 import java.awt.event.ComponentEvent;
35 import java.util.List;
37 import jalview.analysis.AnnotationSorter;
38 import jalview.api.AlignViewportI;
39 import jalview.api.AlignmentViewPanel;
40 import jalview.bin.JalviewLite;
41 import jalview.datamodel.AlignmentI;
42 import jalview.datamodel.SearchResults;
43 import jalview.datamodel.SequenceI;
44 import jalview.structure.StructureSelectionManager;
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 boolean modified = false;
561 int height = av.calcPanelHeight();
563 if (hscroll.isVisible())
565 height += (minsize = hscroll.getPreferredSize().height);
567 if (apvscroll.isVisible())
569 minsize += apvscroll.getPreferredSize().height;
571 int mheight = height;
572 Dimension d = sequenceHolderPanel.getSize(), e = idPanel.getSize();
573 int seqandannot = d.height - scalePanelHolder.getSize().height;
575 if (adjustPanelHeight)
577 // NOTE: this logic is different in the application. Need a better
578 // algorithm to define behaviour
579 // sets initial preferred height
580 // try and set height according to alignment
581 float sscaling = (float) ((av.getCharHeight() * av.getAlignment()
582 .getHeight()) / (1.0 * mheight));
585 // if the alignment is too big then
586 // default is 0.5 split
587 height = seqandannot / 2;
591 // otherwise just set the panel so that one row of sequence is visible
592 height = -av.getCharHeight() * 1
593 + (int) (seqandannot * (1 - sscaling));
598 // maintain same window layout whilst updating sliders
599 height = annotationPanelHolder.getSize().height;
602 if (seqandannot - height < 5)
604 height = seqandannot;
606 annotationPanel.setSize(new Dimension(d.width, height));
607 alabels.setSize(new Dimension(e.width, height));
608 annotationSpaceFillerHolder.setSize(new Dimension(e.width, height));
609 annotationPanelHolder.setSize(new Dimension(d.width, height));
610 // seqPanelHolder.setSize(d.width, seqandannot - height);
612 .setSize(d.width, seqPanel.seqCanvas.getSize().height);
613 int s = apvscroll.getValue();
614 if (s > mheight - height)
618 apvscroll.setValues(s, height, 0, mheight);
619 annotationPanel.setScrollOffset(apvscroll.getValue(), false);
620 alabels.setScrollOffset(apvscroll.getValue(), false);
623 public void setWrapAlignment(boolean wrap)
627 scalePanelHolder.setVisible(!wrap);
629 hscroll.setVisible(!wrap);
630 idwidthAdjuster.setVisible(!wrap);
634 annotationPanelHolder.setVisible(false);
635 annotationSpaceFillerHolder.setVisible(false);
637 else if (av.isShowAnnotation())
639 annotationPanelHolder.setVisible(true);
640 annotationSpaceFillerHolder.setVisible(true);
643 idSpaceFillerPanel1.setVisible(!wrap);
645 fontChanged(); // This is so that the scalePanel is resized correctly
648 sequenceHolderPanel.validate();
657 // return value is true if the scroll is valid
658 public boolean scrollUp(boolean up)
662 if (vscroll.getValue() < 1)
666 setScrollValues(hscroll.getValue(), vscroll.getValue() - 1);
670 if (vextent + vscroll.getValue() >= av.getAlignment().getHeight())
674 setScrollValues(hscroll.getValue(), vscroll.getValue() + 1);
681 public boolean scrollRight(boolean right)
685 if (hscroll.getValue() < 1)
689 setScrollValues(hscroll.getValue() - 1, vscroll.getValue());
693 if (hextent + hscroll.getValue() >= av.getAlignment().getWidth())
697 setScrollValues(hscroll.getValue() + 1, vscroll.getValue());
704 public void setScrollValues(int x, int y)
706 int width = av.getAlignment().getWidth();
707 int height = av.getAlignment().getHeight();
709 if (av.hasHiddenColumns())
711 width = av.getColumnSelection().findColumnPosition(width);
719 hextent = seqPanel.seqCanvas.getSize().width / av.getCharWidth();
720 vextent = seqPanel.seqCanvas.getSize().height / av.getCharHeight();
727 if (vextent > height)
732 if ((hextent + x) > width)
734 System.err.println("hextent was " + hextent + " and x was " + x);
739 if ((vextent + y) > height)
741 y = height - vextent;
751 System.err.println("x was " + x);
757 int endSeq = y + vextent;
758 if (endSeq > av.getAlignment().getHeight())
760 endSeq = av.getAlignment().getHeight();
763 av.setEndSeq(endSeq);
765 av.setEndRes((x + (seqPanel.seqCanvas.getSize().width / av
766 .getCharWidth())) - 1);
768 hscroll.setValues(x, hextent, 0, width);
769 vscroll.setValues(y, vextent, 0, height);
771 if (overviewPanel != null)
773 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
956 public void paintAlignment(boolean updateOverview)
958 final AnnotationSorter sorter = new AnnotationSorter(getAlignment(),
959 av.isShowAutocalculatedAbove());
960 sorter.sort(getAlignment().getAlignmentAnnotation(),
961 av.getSortAnnotationsBy());
966 jalview.structure.StructureSelectionManager
967 .getStructureSelectionManager(av.applet)
968 .sequenceColoursChanged(this);
970 if (overviewPanel != null)
972 overviewPanel.updateOverviewImage();
977 public void update(Graphics g)
982 public void paint(Graphics g)
985 Dimension d = idPanel.idCanvas.getSize();
986 final int canvasHeight = seqPanel.seqCanvas.getSize().height;
987 if (canvasHeight != d.height)
989 idPanel.idCanvas.setSize(d.width, canvasHeight);
992 if (av.getWrapAlignment())
994 int maxwidth = av.getAlignment().getWidth();
996 if (av.hasHiddenColumns())
998 maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
1001 int canvasWidth = seqPanel.seqCanvas
1002 .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width);
1004 if (canvasWidth > 0)
1006 int max = maxwidth / canvasWidth;
1007 vscroll.setMaximum(1 + max);
1008 vscroll.setUnitIncrement(1);
1009 vscroll.setVisibleAmount(1);
1014 setScrollValues(av.getStartRes(), av.getStartSeq());
1017 seqPanel.seqCanvas.repaint();
1018 idPanel.idCanvas.repaint();
1019 if (!av.getWrapAlignment())
1021 if (av.isShowAnnotation())
1024 annotationPanel.repaint();
1026 scalePanel.repaint();
1031 protected Panel sequenceHolderPanel = new Panel();
1033 protected Scrollbar vscroll = new Scrollbar();
1035 protected Scrollbar hscroll = new Scrollbar();
1037 protected Panel seqPanelHolder = new Panel();
1039 protected Panel scalePanelHolder = new Panel();
1041 protected Panel idPanelHolder = new Panel();
1043 protected Panel idSpaceFillerPanel1 = new Panel();
1045 public Panel annotationSpaceFillerHolder = new Panel();
1047 protected Panel hscrollFillerPanel = new Panel();
1049 Panel annotationPanelHolder = new Panel();
1051 protected Scrollbar apvscroll = new Scrollbar();
1054 * Flag set while scrolling to follow complementary cDNA/protein scroll. When
1055 * true, suppresses invoking the same method recursively.
1057 private boolean followingComplementScroll;
1059 private void jbInit() throws Exception
1061 // idPanelHolder.setPreferredSize(new Dimension(70, 10));
1062 this.setLayout(new BorderLayout());
1064 // sequenceHolderPanel.setPreferredSize(new Dimension(150, 150));
1065 sequenceHolderPanel.setLayout(new BorderLayout());
1066 seqPanelHolder.setLayout(new BorderLayout());
1067 scalePanelHolder.setBackground(Color.white);
1069 // scalePanelHolder.setPreferredSize(new Dimension(10, 30));
1070 scalePanelHolder.setLayout(new BorderLayout());
1071 idPanelHolder.setLayout(new BorderLayout());
1072 idSpaceFillerPanel1.setBackground(Color.white);
1074 // idSpaceFillerPanel1.setPreferredSize(new Dimension(10, 30));
1075 idSpaceFillerPanel1.setLayout(new BorderLayout());
1076 annotationSpaceFillerHolder.setBackground(Color.white);
1078 // annotationSpaceFillerHolder.setPreferredSize(new Dimension(10, 80));
1079 annotationSpaceFillerHolder.setLayout(new BorderLayout());
1080 hscroll.setOrientation(Scrollbar.HORIZONTAL);
1082 Panel hscrollHolder = new Panel();
1083 hscrollHolder.setLayout(new BorderLayout());
1084 hscrollFillerPanel.setBackground(Color.white);
1085 apvscroll.setOrientation(Scrollbar.VERTICAL);
1086 apvscroll.setVisible(true);
1087 apvscroll.addAdjustmentListener(this);
1089 annotationPanelHolder.setBackground(Color.white);
1090 annotationPanelHolder.setLayout(new BorderLayout());
1091 annotationPanelHolder.add(apvscroll, BorderLayout.EAST);
1092 // hscrollFillerPanel.setPreferredSize(new Dimension(70, 10));
1093 hscrollHolder.setBackground(Color.white);
1095 // annotationScroller.setPreferredSize(new Dimension(10, 80));
1096 // this.setPreferredSize(new Dimension(220, 166));
1097 seqPanelHolder.setBackground(Color.white);
1098 idPanelHolder.setBackground(Color.white);
1099 sequenceHolderPanel.add(scalePanelHolder, BorderLayout.NORTH);
1100 sequenceHolderPanel.add(seqPanelHolder, BorderLayout.CENTER);
1101 seqPanelHolder.add(vscroll, BorderLayout.EAST);
1103 // Panel3.add(secondaryPanelHolder, BorderLayout.SOUTH);
1104 this.add(idPanelHolder, BorderLayout.WEST);
1105 idPanelHolder.add(idSpaceFillerPanel1, BorderLayout.NORTH);
1106 idPanelHolder.add(annotationSpaceFillerHolder, BorderLayout.SOUTH);
1107 this.add(hscrollHolder, BorderLayout.SOUTH);
1108 hscrollHolder.add(hscroll, BorderLayout.CENTER);
1109 hscrollHolder.add(hscrollFillerPanel, BorderLayout.WEST);
1110 this.add(sequenceHolderPanel, BorderLayout.CENTER);
1114 * hides or shows dynamic annotation rows based on groups and av state flags
1116 public void updateAnnotation()
1118 updateAnnotation(false);
1121 public void updateAnnotation(boolean applyGlobalSettings)
1123 updateAnnotation(applyGlobalSettings, false);
1126 public void updateAnnotation(boolean applyGlobalSettings,
1127 boolean preserveNewGroupSettings)
1129 av.updateGroupAnnotationSettings(applyGlobalSettings,
1130 preserveNewGroupSettings);
1131 adjustAnnotationHeight();
1135 public AlignmentI getAlignment()
1137 return av.getAlignment();
1141 public String getViewName()
1147 public StructureSelectionManager getStructureSelectionManager()
1149 return StructureSelectionManager
1150 .getStructureSelectionManager(av.applet);
1154 public void raiseOOMWarning(String string, OutOfMemoryError error)
1157 System.err.println("Out of memory whilst '" + string + "'");
1158 error.printStackTrace();
1162 * Set a flag to say we are scrolling to follow a (cDNA/protein) complement.
1166 protected void setFollowingComplementScroll(boolean b)
1168 this.followingComplementScroll = b;
1171 protected boolean isFollowingComplementScroll()
1173 return this.followingComplementScroll;