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.Graphics;
37 import java.awt.event.AdjustmentEvent;
38 import java.awt.event.AdjustmentListener;
39 import java.awt.event.ComponentAdapter;
40 import java.awt.event.ComponentEvent;
41 import java.util.List;
43 import javax.swing.JPanel;
44 import javax.swing.JFrame;
45 import javax.swing.JScrollBar;
47 public class AlignmentPanel extends JPanel implements AdjustmentListener,
51 public AlignViewport av;
53 OverviewPanel overviewPanel;
59 IdwidthAdjuster idwidthAdjuster;
61 public AlignFrame alignFrame;
63 ScalePanel scalePanel;
65 AnnotationPanel annotationPanel;
67 AnnotationLabels alabels;
69 // this value is set false when selection area being dragged
70 boolean fastPaint = true;
72 public void finalize()
77 seqPanelHolder = null;
78 sequenceHolderPanel = null;
80 scalePanelHolder = null;
81 annotationPanel = null;
82 annotationPanelHolder = null;
83 annotationSpaceFillerHolder = null;
86 public AlignmentPanel(AlignFrame af, final AlignViewport av)
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 JFrame();
243 av.nullFrame.addNotify();
246 Graphics g = av.nullFrame.getGraphics();
248 FontMetrics fm = g.getFontMetrics(av.font);
249 AlignmentI al = av.getAlignment();
254 while (i < al.getHeight() && al.getSequenceAt(i) != null)
256 SequenceI s = al.getSequenceAt(i);
257 id = s.getDisplayId(av.getShowJVSuffix());
259 if (fm.stringWidth(id) > idWidth)
261 idWidth = fm.stringWidth(id);
266 // Also check annotation label widths
268 if (al.getAlignmentAnnotation() != null)
270 fm = g.getFontMetrics(av.nullFrame.getFont());
271 while (i < al.getAlignmentAnnotation().length)
273 String label = al.getAlignmentAnnotation()[i].label;
274 if (fm.stringWidth(label) > idWidth)
276 idWidth = fm.stringWidth(label);
282 return new Dimension(idWidth, idPanel.idCanvas.getSize().height);
286 * Highlight the given results on the alignment.
289 public void highlightSearchResults(SearchResults results)
291 scrollToPosition(results);
292 seqPanel.seqCanvas.highlightSearchResults(results);
296 * scroll the view to show the position of the highlighted region in results
297 * (if any) and redraw the overview
300 * @return false if results were not found
302 public boolean scrollToPosition(SearchResults results)
304 return scrollToPosition(results, true);
308 * scroll the view to show the position of the highlighted region in results
312 * @param redrawOverview
313 * - when set, the overview will be recalculated (takes longer)
314 * @return false if results were not found
316 public boolean scrollToPosition(SearchResults results,
317 boolean redrawOverview)
319 return scrollToPosition(results, redrawOverview, false);
323 * scroll the view to show the position of the highlighted region in results
327 * @param redrawOverview
328 * - when set, the overview will be recalculated (takes longer)
329 * @return false if results were not found
331 public boolean scrollToPosition(SearchResults results,
332 boolean redrawOverview, boolean centre)
334 // do we need to scroll the panel?
335 if (results != null && results.getSize() > 0)
337 AlignmentI alignment = av.getAlignment();
338 int seqIndex = alignment.findIndex(results);
343 SequenceI seq = alignment.getSequenceAt(seqIndex);
344 int[] r = results.getResults(seq, 0, alignment.getWidth());
347 if (JalviewLite.debug)
350 .println("DEBUG: scroll didn't happen - results not within alignment : "
351 + seq.getStart() + "," + seq.getEnd());
355 if (JalviewLite.debug)
359 * System.out.println("DEBUG: scroll: start=" + r[0] +
360 * " av.getStartRes()=" + av.getStartRes() + " end=" + r[1] +
361 * " seq.end=" + seq.getEnd() + " av.getEndRes()=" + av.getEndRes() +
362 * " hextent=" + hextent);
369 * To centre results, scroll to positions half the visible width
370 * left/right of the start/end positions
374 int offset = (av.getEndRes() - av.getStartRes() + 1) / 2 - 1;
375 start = Math.max(start - offset, 0);
376 end = Math.min(end + offset, seq.getEnd() - 1);
383 if (end == seq.getEnd())
387 return scrollTo(start, end, seqIndex, false, redrawOverview);
392 public boolean scrollTo(int ostart, int end, int seqIndex,
393 boolean scrollToNearest, boolean redrawOverview)
395 int startv, endv, starts, ends, width;
398 if (av.hasHiddenColumns())
400 start = av.getColumnSelection().findColumnPosition(ostart);
401 end = av.getColumnSelection().findColumnPosition(end);
404 if (!scrollToNearest && !av.getColumnSelection().isVisible(ostart))
406 // don't scroll - position isn't visible
415 if (!av.getWrapAlignment())
418 * int spos=av.getStartRes(),sqpos=av.getStartSeq(); if ((startv =
419 * av.getStartRes()) >= start) { spos=start-1; // seqIn //
420 * setScrollValues(start - 1, seqIndex); } else if ((endv =
421 * av.getEndRes()) <= end) { // setScrollValues(spos=startv + 1 + end -
422 * endv, seqIndex); spos=startv + 1 + end - endv; } else if ((starts =
423 * av.getStartSeq()) > seqIndex) { setScrollValues(av.getStartRes(),
424 * seqIndex); } else if ((ends = av.getEndSeq()) <= seqIndex) {
425 * setScrollValues(av.getStartRes(), starts + seqIndex - ends + 1); }
428 // below is scrolling logic up to Jalview 2.8.2
429 // if ((av.getStartRes() > end)
430 // || (av.getEndRes() < start)
431 // || ((av.getStartSeq() > seqIndex) || (av.getEndSeq() < seqIndex)))
433 // if (start > av.getAlignment().getWidth() - hextent)
435 // start = av.getAlignment().getWidth() - hextent;
442 // if (seqIndex > av.getAlignment().getHeight() - vextent)
444 // seqIndex = av.getAlignment().getHeight() - vextent;
450 // setScrollValues(start, seqIndex);
452 // logic copied from jalview.gui.AlignmentPanel:
453 if ((startv = av.getStartRes()) >= start)
456 * Scroll left to make start of search results visible
458 setScrollValues(start - 1, seqIndex);
460 else if ((endv = av.getEndRes()) <= end)
463 * Scroll right to make end of search results visible
465 setScrollValues(startv + 1 + end - endv, seqIndex);
467 else if ((starts = av.getStartSeq()) > seqIndex)
470 * Scroll up to make start of search results visible
472 setScrollValues(av.getStartRes(), seqIndex);
474 else if ((ends = av.getEndSeq()) <= seqIndex)
477 * Scroll down to make end of search results visible
479 setScrollValues(av.getStartRes(), starts + seqIndex - ends + 1);
482 * Else results are already visible - no need to scroll
487 scrollToWrappedVisible(start);
489 if (redrawOverview && overviewPanel != null)
491 overviewPanel.setBoxPosition();
493 paintAlignment(redrawOverview);
497 void scrollToWrappedVisible(int res)
499 int cwidth = seqPanel.seqCanvas
500 .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width);
501 if (res <= av.getStartRes() || res >= (av.getStartRes() + cwidth))
503 vscroll.setValue(res / cwidth);
504 av.startRes = vscroll.getValue() * cwidth;
508 public OverviewPanel getOverviewPanel()
510 return overviewPanel;
513 public void setOverviewPanel(OverviewPanel op)
518 public void setAnnotationVisible(boolean b)
520 if (!av.getWrapAlignment())
522 annotationSpaceFillerHolder.setVisible(b);
523 annotationPanelHolder.setVisible(b);
527 annotationSpaceFillerHolder.setVisible(false);
528 annotationPanelHolder.setVisible(false);
535 * automatically adjust annotation panel height for new annotation whilst
536 * ensuring the alignment is still visible.
538 public void adjustAnnotationHeight()
540 // TODO: display vertical annotation scrollbar if necessary
541 // this is called after loading new annotation onto alignment
542 if (alignFrame.getSize().height == 0)
545 .println("adjustAnnotationHeight frame size zero NEEDS FIXING");
548 validateAnnotationDimensions(true);
549 apvscroll.addNotify();
552 paintAlignment(true);
556 * Calculate the annotation dimensions and refresh slider values accordingly.
557 * Need to do repaints/notifys afterwards.
559 protected void validateAnnotationDimensions(boolean adjustPanelHeight)
561 int rowHeight = av.getCharHeight();
562 int alignmentHeight = rowHeight * av.getAlignment().getHeight();
563 int annotationHeight = av.calcPanelHeight();
565 int mheight = annotationHeight;
566 Dimension d = sequenceHolderPanel.getSize();
568 int availableHeight = d.height - scalePanelHolder.getHeight();
570 if (adjustPanelHeight)
573 * If not enough vertical space, maximize annotation height while keeping
574 * at least two rows of alignment visible
576 if (annotationHeight + alignmentHeight > availableHeight)
578 annotationHeight = Math.min(annotationHeight, availableHeight - 2
584 // maintain same window layout whilst updating sliders
585 annotationHeight = annotationPanelHolder.getSize().height;
588 if (availableHeight - annotationHeight < 5)
590 annotationHeight = availableHeight;
593 annotationPanel.setSize(new Dimension(d.width, annotationHeight));
594 annotationPanelHolder.setSize(new Dimension(d.width, annotationHeight));
595 // seqPanelHolder.setSize(d.width, seqandannot - height);
597 .setSize(d.width, seqPanel.seqCanvas.getSize().height);
599 Dimension e = idPanel.getSize();
600 alabels.setSize(new Dimension(e.width, annotationHeight));
601 annotationSpaceFillerHolder.setSize(new Dimension(e.width,
604 int s = apvscroll.getValue();
605 if (s > mheight - annotationHeight)
609 apvscroll.setValues(s, annotationHeight, 0, mheight);
610 annotationPanel.setScrollOffset(apvscroll.getValue(), false);
611 alabels.setScrollOffset(apvscroll.getValue(), false);
614 public void setWrapAlignment(boolean wrap)
618 scalePanelHolder.setVisible(!wrap);
620 hscroll.setVisible(!wrap);
621 idwidthAdjuster.setVisible(!wrap);
625 annotationPanelHolder.setVisible(false);
626 annotationSpaceFillerHolder.setVisible(false);
628 else if (av.isShowAnnotation())
630 annotationPanelHolder.setVisible(true);
631 annotationSpaceFillerHolder.setVisible(true);
634 idSpaceFillerPanel1.setVisible(!wrap);
636 fontChanged(); // This is so that the scalePanel is resized correctly
639 sequenceHolderPanel.validate();
648 // return value is true if the scroll is valid
649 public boolean scrollUp(boolean up)
653 if (vscroll.getValue() < 1)
657 setScrollValues(hscroll.getValue(), vscroll.getValue() - 1);
661 if (vextent + vscroll.getValue() >= av.getAlignment().getHeight())
665 setScrollValues(hscroll.getValue(), vscroll.getValue() + 1);
672 public boolean scrollRight(boolean right)
676 if (hscroll.getValue() < 1)
680 setScrollValues(hscroll.getValue() - 1, vscroll.getValue());
684 if (hextent + hscroll.getValue() >= av.getAlignment().getWidth())
688 setScrollValues(hscroll.getValue() + 1, vscroll.getValue());
695 public void setScrollValues(int x, int y)
697 int width = av.getAlignment().getWidth();
698 int height = av.getAlignment().getHeight();
700 if (av.hasHiddenColumns())
702 width = av.getColumnSelection().findColumnPosition(width);
710 hextent = seqPanel.seqCanvas.getSize().width / av.getCharWidth();
711 vextent = seqPanel.seqCanvas.getSize().height / av.getCharHeight();
718 if (vextent > height)
723 if ((hextent + x) > width)
725 System.err.println("hextent was " + hextent + " and x was " + x);
730 if ((vextent + y) > height)
732 y = height - vextent;
742 System.err.println("x was " + x);
748 int endSeq = y + vextent;
749 if (endSeq > av.getAlignment().getHeight())
751 endSeq = av.getAlignment().getHeight();
754 av.setEndSeq(endSeq);
756 av.setEndRes((x + (seqPanel.seqCanvas.getSize().width / av
757 .getCharWidth())) - 1);
759 hscroll.setValues(x, hextent, 0, width);
760 vscroll.setValues(y, vextent, 0, height);
762 if (overviewPanel != null)
764 overviewPanel.setBoxPosition();
770 public void adjustmentValueChanged(AdjustmentEvent evt)
772 int oldX = av.getStartRes();
773 int oldY = av.getStartSeq();
775 if (evt == null || evt.getSource() == apvscroll)
777 annotationPanel.setScrollOffset(apvscroll.getValue(), false);
778 alabels.setScrollOffset(apvscroll.getValue(), false);
779 // annotationPanel.image=null;
780 // alabels.image=null;
781 // alabels.repaint();
782 // annotationPanel.repaint();
784 if (evt == null || evt.getSource() == hscroll)
786 int x = hscroll.getValue();
788 av.setEndRes(x + seqPanel.seqCanvas.getSize().width
789 / av.getCharWidth() - 1);
792 if (evt == null || evt.getSource() == vscroll)
794 int offy = vscroll.getValue();
795 if (av.getWrapAlignment())
797 int rowSize = seqPanel.seqCanvas
798 .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width);
799 av.setStartRes(vscroll.getValue() * rowSize);
800 av.setEndRes((vscroll.getValue() + 1) * rowSize);
804 av.setStartSeq(offy);
805 av.setEndSeq(offy + seqPanel.seqCanvas.getSize().height
806 / av.getCharHeight());
810 if (overviewPanel != null)
812 overviewPanel.setBoxPosition();
815 int scrollX = av.startRes - oldX;
816 int scrollY = av.startSeq - oldY;
818 if (av.getWrapAlignment() || !fastPaint || av.MAC)
824 // Make sure we're not trying to draw a panel
825 // larger than the visible window
826 if (scrollX > av.endRes - av.startRes)
828 scrollX = av.endRes - av.startRes;
830 else if (scrollX < av.startRes - av.endRes)
832 scrollX = av.startRes - av.endRes;
835 idPanel.idCanvas.fastPaint(scrollY);
836 seqPanel.seqCanvas.fastPaint(scrollX, scrollY);
838 scalePanel.repaint();
839 if (av.isShowAnnotation())
841 annotationPanel.fastPaint(av.getStartRes() - oldX);
847 * If there is one, scroll the (Protein/cDNA) complementary alignment to
848 * match, unless we are ourselves doing that.
850 if (isFollowingComplementScroll())
852 setFollowingComplementScroll(false);
856 AlignmentPanel ap = getComplementPanel();
857 av.scrollComplementaryAlignment(ap);
863 * A helper method to return the AlignmentPanel in the other (complementary)
864 * half of a SplitFrame view. Returns null if not in a SplitFrame.
868 private AlignmentPanel getComplementPanel()
870 AlignmentPanel ap = null;
871 if (alignFrame != null)
873 SplitFrame sf = alignFrame.getSplitFrame();
876 AlignFrame other = sf.getComplement(alignFrame);
879 ap = other.alignPanel;
887 * Follow a scrolling change in the (cDNA/Protein) complementary alignment.
888 * The aim is to keep the two alignments 'lined up' on their centre columns.
891 * holds mapped region(s) of this alignment that we are scrolling
892 * 'to'; may be modified for sequence offset by this method
894 * the number of visible sequences to show above the mapped region
896 protected void scrollToCentre(SearchResults sr, int seqOffset)
899 * To avoid jumpy vertical scrolling (if some sequences are gapped or not
900 * mapped), we can make the scroll-to location a sequence above the one
903 SequenceI mappedTo = sr.getResultSequence(0);
904 List<SequenceI> seqs = av.getAlignment().getSequences();
907 * This is like AlignmentI.findIndex(seq) but here we are matching the
908 * dataset sequence not the aligned sequence
910 int sequenceIndex = 0;
911 boolean matched = false;
912 for (SequenceI seq : seqs)
914 if (mappedTo == seq.getDatasetSequence())
923 return; // failsafe, shouldn't happen
925 sequenceIndex = Math.max(0, sequenceIndex - seqOffset);
926 sr.getResults().get(0)
927 .setSequence(av.getAlignment().getSequenceAt(sequenceIndex));
930 * Scroll to position but centring the target residue. Also set a state flag
931 * to prevent adjustmentValueChanged performing this recursively.
933 setFollowingComplementScroll(true);
934 scrollToPosition(sr, true, true);
937 private void sendViewPosition()
939 StructureSelectionManager.getStructureSelectionManager(av.applet)
940 .sendViewPosition(this, av.startRes, av.endRes, av.startSeq,
945 * Repaint the alignment and annotations, and, optionally, any overview window
947 public void paintAlignment(boolean updateOverview)
949 final AnnotationSorter sorter = new AnnotationSorter(getAlignment(),
950 av.isShowAutocalculatedAbove());
951 sorter.sort(getAlignment().getAlignmentAnnotation(),
952 av.getSortAnnotationsBy());
957 StructureSelectionManager.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 JPanel sequenceHolderPanel = new JPanel();
1023 protected JScrollBar vscroll = new JScrollBar();
1025 protected JScrollBar hscroll = new JScrollBar();
1027 protected JPanel seqPanelHolder = new JPanel();
1029 protected JPanel scalePanelHolder = new JPanel();
1031 protected JPanel idPanelHolder = new JPanel();
1033 protected JPanel idSpaceFillerPanel1 = new JPanel();
1035 public JPanel annotationSpaceFillerHolder = new JPanel();
1037 protected JPanel hscrollFillerPanel = new JPanel();
1039 JPanel annotationPanelHolder = new JPanel();
1041 protected JScrollBar apvscroll = new JScrollBar();
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(JScrollBar.HORIZONTAL);
1072 JPanel hscrollHolder = new JPanel();
1073 hscrollHolder.setLayout(new BorderLayout());
1074 hscrollFillerPanel.setBackground(Color.white);
1075 apvscroll.setOrientation(JScrollBar.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;