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.
23 import jalview.analysis.AnnotationSorter;
24 import jalview.api.AlignViewportI;
25 import jalview.api.AlignmentViewPanel;
26 import jalview.api.SequenceRenderer;
27 import jalview.bin.Cache;
28 import jalview.bin.Jalview;
29 import jalview.datamodel.AlignmentI;
30 import jalview.datamodel.HiddenColumns;
31 import jalview.datamodel.SearchResultsI;
32 import jalview.datamodel.SequenceFeature;
33 import jalview.datamodel.SequenceGroup;
34 import jalview.datamodel.SequenceI;
35 import jalview.gui.ImageExporter.ImageWriterI;
36 import jalview.io.HTMLOutput;
37 import jalview.jbgui.GAlignmentPanel;
38 import jalview.math.AlignmentDimension;
39 import jalview.schemes.ResidueProperties;
40 import jalview.structure.StructureSelectionManager;
41 import jalview.util.Comparison;
42 import jalview.util.ImageMaker;
43 import jalview.util.MessageManager;
44 import jalview.viewmodel.ViewportListenerI;
45 import jalview.viewmodel.ViewportRanges;
47 import java.awt.BorderLayout;
48 import java.awt.Color;
49 import java.awt.Container;
50 import java.awt.Dimension;
52 import java.awt.FontMetrics;
53 import java.awt.Graphics;
54 import java.awt.Graphics2D;
55 import java.awt.event.AdjustmentEvent;
56 import java.awt.event.AdjustmentListener;
57 import java.awt.event.ComponentAdapter;
58 import java.awt.event.ComponentEvent;
59 import java.awt.image.BufferedImage;
60 import java.awt.print.PageFormat;
61 import java.awt.print.Printable;
62 import java.awt.print.PrinterException;
63 import java.beans.PropertyChangeEvent;
64 import java.beans.PropertyChangeListener;
66 import java.io.FileWriter;
67 import java.io.PrintWriter;
68 import java.util.List;
70 import javax.swing.JScrollBar;
73 * The main panel of an AlignFrame, containing holders for the IdPanel,
74 * SeqPanel, AnnotationLabels (a JPanel), and AnnotationPanel.
76 * Additional holders contain an IdPanelWidthAdjuster space above the idPanel,
77 * AnnotationScroller (JScrollPane for AnnotationPanel), and vertical and
78 * horizontal scrollbars.
83 * @version $Revision: 1.161 $
85 @SuppressWarnings("serial")
86 public class AlignmentPanel extends GAlignmentPanel implements
87 AdjustmentListener, Printable, AlignmentViewPanel, ViewportListenerI
89 public AlignViewport av;
91 OverviewPanel overviewPanel;
93 private SeqPanel seqPanel;
95 private IdPanel idPanel;
97 IdwidthAdjuster idwidthAdjuster;
99 public AlignFrame alignFrame;
101 private ScalePanel scalePanel;
103 private AnnotationPanel annotationPanel;
105 private AnnotationLabels alabels;
107 private int hextent = 0;
109 private int vextent = 0;
112 * Flag set while scrolling to follow complementary cDNA/protein scroll. When
113 * false, suppresses invoking the same method recursively.
115 private boolean scrollComplementaryPanel = true;
117 private PropertyChangeListener propertyChangeListener;
119 private CalculationChooser calculationDialog;
122 * Creates a new AlignmentPanel object.
127 public AlignmentPanel(AlignFrame af, final AlignViewport av)
129 setBackground(Color.white); // BH 2019
133 setSeqPanel(new SeqPanel(av, this));
134 setIdPanel(new IdPanel(av, this));
136 setScalePanel(new ScalePanel(av, this));
138 idPanelHolder.add(getIdPanel(), BorderLayout.CENTER);
139 idwidthAdjuster = new IdwidthAdjuster(this);
140 idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER);
142 setAnnotationPanel(new AnnotationPanel(this));
143 setAlabels(new AnnotationLabels(this));
145 annotationScroller.setViewportView(getAnnotationPanel());
146 annotationSpaceFillerHolder.add(getAlabels(), BorderLayout.CENTER);
147 if (!av.isShowAnnotation())
149 annotationScroller.setVisible(false);
150 annotationSpaceFillerHolder.setVisible(false);
152 scalePanelHolder.add(getScalePanel(), BorderLayout.CENTER);
153 seqPanelHolder.add(getSeqPanel(), BorderLayout.CENTER);
155 setScrollValues(0, 0);
157 hscroll.addAdjustmentListener(this);
158 vscroll.addAdjustmentListener(this);
161 addComponentListener(new ComponentAdapter()
164 public void componentResized(ComponentEvent evt)
166 System.out.println("AlignmentPanel resized " + evt);
167 // reset the viewport ranges when the alignment panel is resized
168 // in particular, this initialises the end residue value when Jalview
170 ViewportRanges ranges = av.getRanges();
171 if (av.getWrapAlignment())
173 int widthInRes = getSeqPanel().seqCanvas.getWrappedCanvasWidth(
174 getSeqPanel().seqCanvas.getWidth());
175 ranges.setViewportWidth(widthInRes);
179 int widthInRes = getSeqPanel().seqCanvas.getWidth()
181 int heightInSeq = getSeqPanel().seqCanvas.getHeight()
182 / av.getCharHeight();
184 ranges.setViewportWidth(widthInRes);
185 ViewportRanges.sTest += "AP.resize chht=" + av.getCharHeight()
186 + "canvHt=" + getSeqPanel().seqCanvas.getHeight() + " "
187 + heightInSeq + "\n";
188 ranges.setViewportHeight(heightInSeq);
194 final AlignmentPanel ap = this;
195 propertyChangeListener = new PropertyChangeListener()
198 public void propertyChange(PropertyChangeEvent evt)
200 if (evt.getPropertyName().equals("alignment"))
202 PaintRefresher.Refresh(ap, av.getSequenceSetId(), true, true);
207 av.addPropertyChangeListener(propertyChangeListener);
209 av.getRanges().addPropertyChangeListener(this);
211 adjustAnnotationHeight();
216 public void setBounds(int x, int y, int width, int height)
218 System.out.println("?AlignmentPanel.setBounds " + this.getX() + " "
219 + this.getY() + " " + this.getWidth() + " " + getHeight() + " "
220 + x + " " + y + " " + width + " " + height);
221 // BH 2020.03.23 when the Desktop changes its progress bar it re-lays out
224 // children, for unclear reasons. Maybe because they could be tiled?
225 if (x == this.getX() && y == this.getY() && width == this.getWidth()
226 && height == this.getHeight())
230 System.out.println("!AlignmentPanel.setBounds " + this.getX() + " "
231 + this.getY() + " " + this.getWidth() + " " + getHeight() + " "
232 + x + " " + y + " " + width + " " + height);
233 super.setBounds(x, y, width, height);
237 // public void reshape(int x, int y, int width, int height)
239 // // BH 2020.03.23 when the Desktop changes its progress bar it relays out
241 // // children, for unclear reasons. Maybe because they could be tiled?
242 // if (x == this.getX() && y == this.getY() && width == this.getWidth()
243 // && height == this.getHeight())
248 // System.out.println("AlignmentPanel.reshape " + this.getX() + " "
249 // + this.getY() + " " + this.getWidth() + " " + getHeight() + " "
251 // + " " + y + " " + width + " " + height);
252 // super.reshape(x, y, width, height);
256 public AlignViewportI getAlignViewport()
261 public void alignmentChanged()
263 av.alignmentChanged(this);
265 if (getCalculationDialog() != null)
267 getCalculationDialog().validateCalcTypes();
270 alignFrame.updateEditMenuBar();
272 // no idea if we need to update structure
273 paintAlignment(true, true);
280 public void fontChanged()
282 // set idCanvas bufferedImage to null
283 // to prevent drawing old image
284 FontMetrics fm = getFontMetrics(av.getFont());
286 scalePanelHolder.setPreferredSize(
287 new Dimension(10, av.getCharHeight() + fm.getDescent()));
288 idSpaceFillerPanel1.setPreferredSize(
289 new Dimension(10, av.getCharHeight() + fm.getDescent()));
290 idwidthAdjuster.invalidate();
291 scalePanelHolder.invalidate();
292 // BH 2018 getIdPanel().getIdCanvas().gg = null;
293 getSeqPanel().seqCanvas.img = null;
294 getAnnotationPanel().adjustPanelHeight();
296 Dimension d = calculateIdWidth();
298 d.setSize(d.width + 4, d.height);
299 getIdPanel().getIdCanvas().setPreferredSize(d);
300 hscrollFillerPanel.setPreferredSize(d);
306 * Calculate the width of the alignment labels based on the displayed names
307 * and any bounds on label width set in preferences.
309 * @return Dimension giving the maximum width of the alignment label panel
310 * that should be used.
312 public Dimension calculateIdWidth()
314 // calculate sensible default width when no preference is available
316 if (av.getIdWidth() < 0)
318 int afwidth = (alignFrame != null ? alignFrame.getWidth() : 300);
319 int maxwidth = Math.max(20, Math.min(afwidth - 200, 2 * afwidth / 3));
320 r = calculateIdWidth(maxwidth);
321 av.setIdWidth(r.width);
326 r.width = av.getIdWidth();
333 * Calculate the width of the alignment labels based on the displayed names
334 * and any bounds on label width set in preferences.
337 * -1 or maximum width allowed for IdWidth
338 * @return Dimension giving the maximum width of the alignment label panel
339 * that should be used.
341 public Dimension calculateIdWidth(int maxwidth)
343 Container c = new Container();
345 FontMetrics fm = c.getFontMetrics(
346 new Font(av.font.getName(), Font.ITALIC, av.font.getSize()));
348 AlignmentI al = av.getAlignment();
353 while ((i < al.getHeight()) && (al.getSequenceAt(i) != null))
355 SequenceI s = al.getSequenceAt(i);
357 id = s.getDisplayId(av.getShowJVSuffix());
359 if (fm.stringWidth(id) > idWidth)
361 idWidth = fm.stringWidth(id);
367 // Also check annotation label widths
370 if (al.getAlignmentAnnotation() != null)
372 fm = c.getFontMetrics(getAlabels().getFont());
374 while (i < al.getAlignmentAnnotation().length)
376 String label = al.getAlignmentAnnotation()[i].label;
378 if (fm.stringWidth(label) > idWidth)
380 idWidth = fm.stringWidth(label);
387 return new Dimension(
388 maxwidth < 0 ? idWidth : Math.min(maxwidth, idWidth), 12);
392 * Highlight the given results on the alignment
395 public void highlightSearchResults(SearchResultsI results)
397 boolean scrolled = scrollToPosition(results, 0, false);
399 boolean fastPaint = !(scrolled && av.getWrapAlignment());
401 getSeqPanel().seqCanvas.highlightSearchResults(results, fastPaint);
405 * Scroll the view to show the position of the highlighted region in results
408 * @param searchResults
411 public boolean scrollToPosition(SearchResultsI searchResults)
413 return scrollToPosition(searchResults, 0, false);
417 * Scrolls the view (if necessary) to show the position of the first
418 * highlighted region in results (if any). Answers true if the view was
419 * scrolled, or false if no matched region was found, or it is already
423 * @param verticalOffset
424 * if greater than zero, allows scrolling to a position below the
425 * first displayed sequence
427 * if true, try to centre the search results horizontally in the view
430 protected boolean scrollToPosition(SearchResultsI results,
431 int verticalOffset, boolean centre)
433 int startv, endv, starts, ends;
434 ViewportRanges ranges = av.getRanges();
436 if (results == null || results.isEmpty() || av == null
437 || av.getAlignment() == null)
441 int seqIndex = av.getAlignment().findIndex(results);
446 SequenceI seq = av.getAlignment().getSequenceAt(seqIndex);
448 int[] r = results.getResults(seq, 0, av.getAlignment().getWidth());
457 * To centre results, scroll to positions half the visible width
458 * left/right of the start/end positions
462 int offset = (ranges.getEndRes() - ranges.getStartRes() + 1) / 2 - 1;
463 start = Math.max(start - offset, 0);
464 end = end + offset - 1;
470 if (end == seq.getEnd())
475 if (av.hasHiddenColumns())
477 HiddenColumns hidden = av.getAlignment().getHiddenColumns();
478 start = hidden.absoluteToVisibleColumn(start);
479 end = hidden.absoluteToVisibleColumn(end);
482 if (!hidden.isVisible(r[0]))
484 // don't scroll - position isn't visible
491 * allow for offset of target sequence (actually scroll to one above it)
493 seqIndex = Math.max(0, seqIndex - verticalOffset);
494 boolean scrollNeeded = true;
496 if (!av.getWrapAlignment())
498 if ((startv = ranges.getStartRes()) >= start)
501 * Scroll left to make start of search results visible
503 setScrollValues(start, seqIndex);
505 else if ((endv = ranges.getEndRes()) <= end)
508 * Scroll right to make end of search results visible
510 setScrollValues(startv + end - endv, seqIndex);
512 else if ((starts = ranges.getStartSeq()) > seqIndex)
515 * Scroll up to make start of search results visible
517 setScrollValues(ranges.getStartRes(), seqIndex);
519 else if ((ends = ranges.getEndSeq()) <= seqIndex)
522 * Scroll down to make end of search results visible
524 setScrollValues(ranges.getStartRes(), starts + seqIndex - ends
528 * Else results are already visible - no need to scroll
530 scrollNeeded = false;
534 scrollNeeded = ranges.scrollToWrappedVisible(start);
537 paintAlignment(false, false);
545 * @return DOCUMENT ME!
547 public OverviewPanel getOverviewPanel()
549 return overviewPanel;
558 public void setOverviewPanel(OverviewPanel op)
566 * Hide or show annotation panel
569 public void setAnnotationVisible(boolean b)
571 if (!av.getWrapAlignment())
573 annotationSpaceFillerHolder.setVisible(b);
574 annotationScroller.setVisible(b);
580 * automatically adjust annotation panel height for new annotation whilst
581 * ensuring the alignment is still visible.
584 public void adjustAnnotationHeight()
586 // TODO: display vertical annotation scrollbar if necessary
587 // this is called after loading new annotation onto alignment
588 if (alignFrame.getHeight() == 0)
590 System.out.println("NEEDS FIXING");
592 validateAnnotationDimensions(true);
594 // TODO: many places call this method and also paintAlignment with various
595 // different settings. this means multiple redraws are triggered...
596 paintAlignment(true, av.needToUpdateStructureViews());
600 * calculate the annotation dimensions and refresh slider values accordingly.
601 * need to do repaints/notifys afterwards.
603 protected void validateAnnotationDimensions(boolean adjustPanelHeight)
605 // BH 2018.04.18 comment: addNotify() is not appropriate here. We
606 // are not changing ancestors, and keyboard action listeners do
607 // not need to be reset. addNotify() is a very expensive operation,
608 // requiring a full re-layout of all parents and children.
609 // Note in JComponent:
610 // This method is called by the toolkit internally and should
611 // not be called directly by programs.
612 // I note that addNotify() is called in several areas of Jalview.
614 int annotationHeight = getAnnotationPanel().adjustPanelHeight();
615 annotationHeight = getAnnotationPanel()
616 .adjustForAlignFrame(adjustPanelHeight, annotationHeight);
619 annotationScroller.setPreferredSize(
620 new Dimension(annotationScroller.getWidth(), annotationHeight));
622 Dimension e = idPanel.getSize();
623 alabels.setSize(new Dimension(e.width, annotationHeight));
626 annotationSpaceFillerHolder.setPreferredSize(new Dimension(
627 annotationSpaceFillerHolder.getWidth(), annotationHeight));
628 annotationScroller.validate();
629 annotationScroller.addNotify();
633 * update alignment layout for viewport settings
638 public void updateLayout()
640 fontChanged(); // fires repaint
641 setAnnotationVisible(av.isShowAnnotation());
642 boolean wrap = av.getWrapAlignment();
643 ViewportRanges ranges = av.getRanges();
644 ranges.setStartSeq(0);
645 scalePanelHolder.setVisible(!wrap);
646 hscroll.setVisible(!wrap);
647 idwidthAdjuster.setVisible(!wrap);
651 annotationScroller.setVisible(false);
652 annotationSpaceFillerHolder.setVisible(false);
654 else if (av.isShowAnnotation())
656 annotationScroller.setVisible(true);
657 annotationSpaceFillerHolder.setVisible(true);
658 validateAnnotationDimensions(false);
661 int canvasWidth = getSeqPanel().seqCanvas.getWidth();
663 { // may not yet be laid out
666 int widthInRes = getSeqPanel().seqCanvas
667 .getWrappedCanvasWidth(canvasWidth);
668 ranges.setViewportWidth(widthInRes);
672 int widthInRes = (canvasWidth / av.getCharWidth());
673 int heightInSeq = (getSeqPanel().seqCanvas.getHeight()
674 / av.getCharHeight());
676 ranges.setViewportWidth(widthInRes);
677 ranges.setViewportHeight(heightInSeq);
681 idSpaceFillerPanel1.setVisible(!wrap);
687 * Adjust row/column scrollers to show a visible position in the alignment.
690 * visible column to scroll to
692 * visible row to scroll to
694 * @return true if scrollbars will fire property changes
697 public boolean setScrollValues(int xpos, int ypos)
702 if (av == null || av.getAlignment() == null)
707 if (av.getWrapAlignment())
709 return setScrollingForWrappedPanel(x);
711 int width = av.getAlignment().getVisibleWidth();
712 int height = av.getAlignment().getHeight();
714 hextent = getSeqPanel().seqCanvas.getWidth() / av.getCharWidth();
715 vextent = getSeqPanel().seqCanvas.getHeight() / av.getCharHeight();
722 if (vextent > height)
727 if ((hextent + x) > width)
732 if ((vextent + y) > height)
734 y = height - vextent;
747 // update the scroll values and return true if they changed
749 return (setIfChanged(hscroll, x, hextent, 0, width)
750 + setIfChanged(vscroll, y, vextent, 0, height) != 0);
755 * Update a horizontal or vertical scrollbar and indicate if it is actually changed
756 * (and so will be firing an AdjustmentChangedEvent)
762 * @return 1 if JScrollBar is changed; 0 if not
764 private int setIfChanged(JScrollBar sb, int val, int extent, int min,
767 if (sb.getValue() == val && sb.getModel().getExtent() == extent
768 && sb.getMinimum() == min && sb.getMaximum() == max)
772 sb.setValues(val, extent, min, max);
777 * Respond to adjustment event when horizontal or vertical scrollbar is
781 * adjustment event encoding whether hscroll or vscroll changed
784 public void adjustmentValueChanged(AdjustmentEvent evt)
786 if (av.getWrapAlignment())
788 adjustScrollingWrapped(evt);
792 ViewportRanges ranges = av.getRanges();
794 if (evt.getSource() == hscroll)
796 int oldX = ranges.getStartRes();
797 int oldwidth = ranges.getViewportWidth();
798 int x = hscroll.getValue();
799 int width = getSeqPanel().seqCanvas.getWidth() / av.getCharWidth();
801 // if we're scrolling to the position we're already at, stop
802 // this prevents infinite recursion of events when the scroll/viewport
803 // ranges values are the same
804 if ((x == oldX) && (width == oldwidth))
808 ranges.setViewportStartAndWidth(x, width);
810 else if (evt.getSource() == vscroll)
812 int oldY = ranges.getStartSeq();
813 int oldheight = ranges.getViewportHeight();
814 int y = vscroll.getValue();
815 int height = getSeqPanel().seqCanvas.getHeight() / av.getCharHeight();
818 // if we're scrolling to the position we're already at, stop
819 // this prevents infinite recursion of events when the scroll/viewport
820 // ranges values are the same
821 if ((y == oldY) && (height == oldheight))
826 ViewportRanges.sTest += "AP.adjvalChanged chht=" + av.getCharHeight()
827 + "canvHt=" + getSeqPanel().seqCanvas.getHeight() + " newHt="
830 ranges.setViewportStartAndHeight(y, height);
836 * Responds to a scroll change by setting the start position of the viewport.
841 protected void adjustScrollingWrapped(AdjustmentEvent evt)
843 if (evt.getSource() == hscroll)
845 return; // no horizontal scroll when wrapped
847 final ViewportRanges ranges = av.getRanges();
849 if (evt.getSource() == vscroll)
851 int newY = vscroll.getValue();
854 * if we're scrolling to the position we're already at, stop
855 * this prevents infinite recursion of events when the scroll/viewport
856 * ranges values are the same
858 int oldX = ranges.getStartRes();
859 int oldY = ranges.getWrappedScrollPosition(oldX);
867 * limit page up/down to one width's worth of positions
869 int rowSize = ranges.getViewportWidth();
870 int newX = newY > oldY ? oldX + rowSize : oldX - rowSize;
871 ranges.setViewportStartAndWidth(Math.max(0, newX), rowSize);
876 // This is only called if file loaded is a jar file that
877 // was wrapped when saved and user has wrap alignment true
878 // as preference setting
879 Jalview.execRunnable(new Runnable()
884 // When updating scrolling to use ViewportChange events, this code
885 // could not be validated and it is not clear if it is now being
886 // called. Log warning here in case it is called and unforeseen
889 "Unexpected path through code: Wrapped jar file opened with wrap alignment set in preferences");
891 // scroll to start of panel
892 ranges.setStartRes(0);
893 ranges.setStartSeq(0);
901 * @see jalview.api.AlignmentViewPanel#paintAlignment(boolean)
904 public void paintAlignment(boolean updateOverview,
905 boolean updateStructures)
907 final AnnotationSorter sorter = new AnnotationSorter(getAlignment(),
908 av.isShowAutocalculatedAbove());
909 sorter.sort(getAlignment().getAlignmentAnnotation(),
910 av.getSortAnnotationsBy());
913 if (updateStructures)
915 av.getStructureSelectionManager().sequenceColoursChanged(this);
919 if (overviewPanel != null)
921 overviewPanel.updateOverviewImage();
927 public void invalidate()
929 System.out.println("AlignmentPanel invalidate");
934 public void validate()
936 System.out.println("AlignmentPanel validate");
947 public void paintComponent(Graphics g)
950 System.out.println("AlignmentPanel paintComponent");
952 invalidate(); // needed so that the id width adjuster works correctly
954 Dimension d = getIdPanel().getIdCanvas().getPreferredSize();
955 idPanelHolder.setPreferredSize(d);
956 hscrollFillerPanel.setPreferredSize(new Dimension(d.width, 12));
958 validate(); // needed so that the id width adjuster works correctly
961 * set scroll bar positions - tried to remove but necessary for split panel to resize correctly
962 * though I still think this call should be elsewhere.
964 ViewportRanges ranges = av.getRanges();
965 if (!setScrollValues(ranges.getStartRes(), ranges.getStartSeq()))
967 // super.paintComponent(g);
969 super.paintComponent(g);
973 * Set vertical scroll bar position, and number of increments, for wrapped
976 * @param topLeftColumn
977 * the column position at top left (0..)
979 private boolean setScrollingForWrappedPanel(int topLeftColumn)
981 ViewportRanges ranges = av.getRanges();
982 int scrollPosition = ranges.getWrappedScrollPosition(topLeftColumn);
983 int maxScroll = ranges.getWrappedMaxScroll(topLeftColumn);
986 * a scrollbar's value can be set to at most (maximum-extent)
987 * so we add extent (1) to the maxScroll value
989 vscroll.setUnitIncrement(1);
990 return (setIfChanged(vscroll, scrollPosition, 1, 0,
991 maxScroll + 1) != 0);
1004 * @return DOCUMENT ME!
1006 * @throws PrinterException
1010 public int print(Graphics pg, PageFormat pf, int pi)
1011 throws PrinterException
1013 pg.translate((int) pf.getImageableX(), (int) pf.getImageableY());
1015 int pwidth = (int) pf.getImageableWidth();
1016 int pheight = (int) pf.getImageableHeight();
1018 if (av.getWrapAlignment())
1020 return printWrappedAlignment(pwidth, pheight, pi, pg);
1024 return printUnwrapped(pwidth, pheight, pi, pg, pg);
1029 * Draws the alignment image, including sequence ids, sequences, and
1030 * annotation labels and annotations if shown, on either one or two Graphics
1040 * the graphics context for sequence ids and annotation labels
1041 * @param alignmentGraphics
1042 * the graphics context for sequences and annotations (may or may not
1043 * be the same context as idGraphics)
1045 * @throws PrinterException
1047 public int printUnwrapped(int pageWidth, int pageHeight, int pageIndex,
1048 Graphics idGraphics, Graphics alignmentGraphics)
1049 throws PrinterException
1051 final int idWidth = getVisibleIdWidth(false);
1054 * Get the horizontal offset to where we draw the sequences.
1055 * This is idWidth if using a single Graphics context, else zero.
1057 final int alignmentGraphicsOffset = idGraphics != alignmentGraphics ? 0
1060 FontMetrics fm = getFontMetrics(av.getFont());
1061 final int charHeight = av.getCharHeight();
1062 final int scaleHeight = charHeight + fm.getDescent();
1064 idGraphics.setColor(Color.white);
1065 idGraphics.fillRect(0, 0, pageWidth, pageHeight);
1066 idGraphics.setFont(av.getFont());
1069 * How many sequences and residues can we fit on a printable page?
1071 final int totalRes = (pageWidth - idWidth) / av.getCharWidth();
1073 final int totalSeq = (pageHeight - scaleHeight) / charHeight - 1;
1075 final int alignmentWidth = av.getAlignment().getVisibleWidth();
1076 int pagesWide = (alignmentWidth / totalRes) + 1;
1078 final int startRes = (pageIndex % pagesWide) * totalRes;
1079 final int endRes = Math.min(startRes + totalRes - 1,
1080 alignmentWidth - 1);
1082 final int startSeq = (pageIndex / pagesWide) * totalSeq;
1083 final int alignmentHeight = av.getAlignment().getHeight();
1084 final int endSeq = Math.min(startSeq + totalSeq, alignmentHeight);
1086 int pagesHigh = ((alignmentHeight / totalSeq) + 1) * pageHeight;
1088 if (av.isShowAnnotation())
1090 pagesHigh += getAnnotationPanel().adjustPanelHeight() + 3;
1093 pagesHigh /= pageHeight;
1095 if (pageIndex >= (pagesWide * pagesHigh))
1097 return Printable.NO_SUCH_PAGE;
1099 final int alignmentDrawnHeight = (endSeq - startSeq) * charHeight + 3;
1102 * draw the Scale at horizontal offset, then reset to top left (0, 0)
1104 alignmentGraphics.translate(alignmentGraphicsOffset, 0);
1105 getScalePanel().drawScale(alignmentGraphics, startRes, endRes,
1106 pageWidth - idWidth, scaleHeight);
1107 alignmentGraphics.translate(-alignmentGraphicsOffset, 0);
1110 * Draw the sequence ids, offset for scale height,
1111 * then reset to top left (0, 0)
1113 idGraphics.translate(0, scaleHeight);
1114 IdCanvas idCanvas = getIdPanel().getIdCanvas();
1115 List<SequenceI> selection = av.getSelectionGroup() == null ? null
1116 : av.getSelectionGroup().getSequences(null);
1117 idCanvas.drawIds((Graphics2D) idGraphics, av, startSeq, endSeq - 1,
1120 idGraphics.setFont(av.getFont());
1121 idGraphics.translate(0, -scaleHeight);
1124 * draw the sequences, offset for scale height, and id width (if using a
1125 * single graphics context), then reset to (0, scale height)
1127 alignmentGraphics.translate(alignmentGraphicsOffset, scaleHeight);
1128 getSeqPanel().seqCanvas.drawPanelForPrinting(alignmentGraphics, startRes,
1129 endRes, startSeq, endSeq - 1);
1130 alignmentGraphics.translate(-alignmentGraphicsOffset, 0);
1132 if (av.isShowAnnotation() && (endSeq == alignmentHeight))
1135 * draw annotation labels; drawComponent() translates by
1136 * getScrollOffset(), so compensate for that first;
1137 * then reset to (0, scale height)
1139 int offset = getAlabels().getScrollOffset();
1140 idGraphics.translate(0, -offset);
1141 idGraphics.translate(0, alignmentDrawnHeight);
1142 getAlabels().drawComponent(idGraphics, idWidth);
1143 idGraphics.translate(0, -alignmentDrawnHeight);
1146 * draw the annotations starting at
1147 * (idOffset, alignmentHeight) from (0, scaleHeight)
1149 alignmentGraphics.translate(alignmentGraphicsOffset,
1150 alignmentDrawnHeight);
1151 getAnnotationPanel().renderer.drawComponent(getAnnotationPanel(), av,
1152 alignmentGraphics, -1, startRes, endRes + 1);
1155 return Printable.PAGE_EXISTS;
1159 * Prints one page of an alignment in wrapped mode. Returns
1160 * Printable.PAGE_EXISTS (0) if a page was drawn, or Printable.NO_SUCH_PAGE if
1161 * no page could be drawn (page number out of range).
1171 * @throws PrinterException
1173 public int printWrappedAlignment(int pageWidth, int pageHeight, int pageNumber,
1174 Graphics g) throws PrinterException
1177 int annotationHeight = 0;
1178 if (av.isShowAnnotation())
1180 annotationHeight = getAnnotationPanel().adjustPanelHeight();
1183 int hgap = av.getCharHeight();
1184 if (av.getScaleAboveWrapped())
1186 hgap += av.getCharHeight();
1189 int cHeight = av.getAlignment().getHeight() * av.getCharHeight() + hgap
1192 int idWidth = getVisibleIdWidth(false);
1194 int maxwidth = av.getAlignment().getVisibleWidth();
1196 int resWidth = getSeqPanel().seqCanvas
1197 .getWrappedCanvasWidth(pageWidth - idWidth);
1199 int totalHeight = cHeight * (maxwidth / resWidth + 1);
1203 g.setColor(Color.white);
1204 g.fillRect(0, 0, pageWidth, pageHeight);
1205 g.setFont(av.getFont());
1206 g.setColor(Color.black);
1209 * method: print the whole wrapped alignment, but with a clip region that
1210 * is restricted to the requested page; this supports selective print of
1211 * single pages or ranges, (at the cost of some repeated processing in
1212 * the 'normal' case, when all pages are printed)
1214 g.translate(0, -pageNumber * pageHeight);
1216 // BH 2020.03.19 avoiding g.setClip
1217 g.clipRect(0, pageNumber * pageHeight, pageWidth, pageHeight);
1220 * draw sequence ids and annotation labels (if shown)
1222 IdCanvas idCanvas = getIdPanel().getIdCanvas();
1223 idCanvas.drawIdsWrapped((Graphics2D) g, av, 0, totalHeight);
1225 g.translate(idWidth, 0);
1227 getSeqPanel().seqCanvas.drawWrappedPanelForPrinting(g, pageWidth - idWidth,
1231 if ((pageNumber * pageHeight) < totalHeight)
1233 return Printable.PAGE_EXISTS;
1237 return Printable.NO_SUCH_PAGE;
1242 * get current sequence ID panel width, or nominal value if panel were to be
1243 * displayed using default settings
1247 public int getVisibleIdWidth()
1249 return getVisibleIdWidth(true);
1253 * get current sequence ID panel width, or nominal value if panel were to be
1254 * displayed using default settings
1257 * indicate if the Id width for onscreen or offscreen display should
1261 public int getVisibleIdWidth(boolean onscreen)
1263 // see if rendering offscreen - check preferences and calc width accordingly
1264 if (!onscreen && Cache.getDefault(Preferences.FIGURE_AUTOIDWIDTH, false))
1266 return calculateIdWidth(-1).width + 4;
1268 Integer idwidth = null;
1269 if (onscreen || (idwidth = Cache
1270 .getIntegerProperty(Preferences.FIGURE_FIXEDIDWIDTH)) == null)
1272 int w = getIdPanel().getWidth();
1273 return (w > 0 ? w : calculateIdWidth().width + 4);
1275 return idwidth.intValue() + 4;
1279 * Builds an image of the alignment of the specified type (EPS/PNG/SVG) and
1280 * writes it to the specified file
1285 void makeAlignmentImage(ImageMaker.TYPE type, File file)
1287 final int borderBottomOffset = 5;
1289 AlignmentDimension aDimension = getAlignmentDimension();
1290 // todo use a lambda function in place of callback here?
1291 ImageWriterI writer = new ImageWriterI()
1294 public void exportImage(Graphics graphics) throws Exception
1296 if (av.getWrapAlignment())
1298 printWrappedAlignment(aDimension.getWidth(),
1299 aDimension.getHeight() + borderBottomOffset, 0, graphics);
1303 printUnwrapped(aDimension.getWidth(), aDimension.getHeight(), 0,
1304 graphics, graphics);
1309 String fileTitle = alignFrame.getTitle();
1310 ImageExporter exporter = new ImageExporter(writer, alignFrame, type,
1312 int imageWidth = aDimension.getWidth();
1313 int imageHeight = aDimension.getHeight() + borderBottomOffset;
1314 String of = MessageManager.getString("label.alignment");
1315 exporter.doExport(file, this, imageWidth, imageHeight, of);
1319 * Calculates and returns a suitable width and height (in pixels) for an
1324 public AlignmentDimension getAlignmentDimension()
1326 int maxwidth = av.getAlignment().getVisibleWidth();
1328 int height = ((av.getAlignment().getHeight() + 1) * av.getCharHeight())
1329 + getScalePanel().getHeight();
1330 int width = getVisibleIdWidth(false) + (maxwidth * av.getCharWidth());
1332 if (av.getWrapAlignment())
1334 height = getWrappedHeight();
1335 if (Jalview.isHeadlessMode())
1337 // need to obtain default alignment width and then add in any
1338 // additional allowance for id margin
1339 // this duplicates the calculation in getWrappedHeight but adjusts for
1341 width = alignFrame.getWidth() - vscroll.getPreferredSize().width
1342 - alignFrame.getInsets().left - alignFrame.getInsets().right
1343 - getVisibleIdWidth() + getVisibleIdWidth(false);
1347 width = getSeqPanel().getWidth() + getVisibleIdWidth(false);
1351 else if (av.isShowAnnotation())
1353 height += getAnnotationPanel().adjustPanelHeight() + 3;
1355 return new AlignmentDimension(width, height);
1359 public void makePNGImageMap(File imgMapFile, String imageName)
1361 // /////ONLY WORKS WITH NON WRAPPED ALIGNMENTS
1362 // ////////////////////////////////////////////
1363 int idWidth = getVisibleIdWidth(false);
1364 FontMetrics fm = getFontMetrics(av.getFont());
1365 int scaleHeight = av.getCharHeight() + fm.getDescent();
1368 // ////////////////////////////////
1369 if (imgMapFile != null)
1373 int sSize = av.getAlignment().getHeight();
1374 int alwidth = av.getAlignment().getWidth();
1375 PrintWriter out = new PrintWriter(new FileWriter(imgMapFile));
1376 out.println(HTMLOutput.getImageMapHTML());
1377 out.println("<img src=\"" + imageName
1378 + "\" border=\"0\" usemap=\"#Map\" >"
1379 + "<map name=\"Map\">");
1381 for (int s = 0; s < sSize; s++)
1383 int sy = s * av.getCharHeight() + scaleHeight;
1385 SequenceI seq = av.getAlignment().getSequenceAt(s);
1386 SequenceGroup[] groups = av.getAlignment().findAllGroups(seq);
1387 for (int column = 0; column < alwidth; column++)
1389 StringBuilder text = new StringBuilder(512);
1390 String triplet = null;
1391 if (av.getAlignment().isNucleotide())
1393 triplet = ResidueProperties.nucleotideName.get(seq
1394 .getCharAt(column) + "");
1398 triplet = ResidueProperties.aa2Triplet.get(seq.getCharAt(column)
1402 if (triplet == null)
1407 int seqPos = seq.findPosition(column);
1408 int gSize = groups.length;
1409 for (int g = 0; g < gSize; g++)
1411 if (text.length() < 1)
1413 text.append("<area shape=\"rect\" coords=\"")
1414 .append((idWidth + column * av.getCharWidth()))
1415 .append(",").append(sy).append(",")
1416 .append((idWidth + (column + 1) * av.getCharWidth()))
1417 .append(",").append((av.getCharHeight() + sy))
1418 .append("\"").append(" onMouseOver=\"toolTip('")
1419 .append(seqPos).append(" ").append(triplet);
1422 if (groups[g].getStartRes() < column
1423 && groups[g].getEndRes() > column)
1425 text.append("<br><em>").append(groups[g].getName())
1430 if (text.length() < 1)
1432 text.append("<area shape=\"rect\" coords=\"")
1433 .append((idWidth + column * av.getCharWidth()))
1434 .append(",").append(sy).append(",")
1435 .append((idWidth + (column + 1) * av.getCharWidth()))
1436 .append(",").append((av.getCharHeight() + sy))
1437 .append("\"").append(" onMouseOver=\"toolTip('")
1438 .append(seqPos).append(" ").append(triplet);
1440 if (!Comparison.isGap(seq.getCharAt(column)))
1442 List<SequenceFeature> features = seq.findFeatures(column, column);
1443 for (SequenceFeature sf : features)
1445 if (sf.isContactFeature())
1447 text.append("<br>").append(sf.getType()).append(" ")
1448 .append(sf.getBegin()).append(":")
1449 .append(sf.getEnd());
1453 text.append("<br>");
1454 text.append(sf.getType());
1455 String description = sf.getDescription();
1456 if (description != null
1457 && !sf.getType().equals(description))
1459 description = description.replace("\"", """);
1460 text.append(" ").append(description);
1463 String status = sf.getStatus();
1464 if (status != null && !"".equals(status))
1466 text.append(" (").append(status).append(")");
1469 if (text.length() > 1)
1471 text.append("')\"; onMouseOut=\"toolTip()\"; href=\"#\">");
1472 out.println(text.toString());
1477 out.println("</map></body></html>");
1480 } catch (Exception ex)
1482 ex.printStackTrace();
1484 } // /////////END OF IMAGE MAP
1488 int getWrappedHeight()
1490 int seqPanelWidth = getSeqPanel().seqCanvas.getWidth();
1492 if (Jalview.isHeadlessMode())
1494 seqPanelWidth = alignFrame.getWidth() - getVisibleIdWidth()
1495 - vscroll.getPreferredSize().width
1496 - alignFrame.getInsets().left - alignFrame.getInsets().right;
1499 int chunkWidth = getSeqPanel().seqCanvas
1500 .getWrappedCanvasWidth(seqPanelWidth);
1502 int hgap = av.getCharHeight();
1503 if (av.getScaleAboveWrapped())
1505 hgap += av.getCharHeight();
1508 int annotationHeight = 0;
1509 if (av.isShowAnnotation())
1511 annotationHeight = getAnnotationPanel().adjustPanelHeight();
1514 int cHeight = av.getAlignment().getHeight() * av.getCharHeight() + hgap
1517 int maxwidth = av.getAlignment().getWidth();
1518 if (av.hasHiddenColumns())
1520 maxwidth = av.getAlignment().getHiddenColumns()
1521 .absoluteToVisibleColumn(maxwidth) - 1;
1524 int height = ((maxwidth / chunkWidth) + 1) * cHeight;
1530 * close the panel - deregisters all listeners and nulls any references to
1533 public void closePanel()
1535 PaintRefresher.RemoveComponent(getSeqPanel().seqCanvas);
1536 PaintRefresher.RemoveComponent(getIdPanel().getIdCanvas());
1537 PaintRefresher.RemoveComponent(this);
1542 * try to ensure references are nulled
1544 if (annotationPanel != null)
1546 annotationPanel.dispose();
1547 annotationPanel = null;
1552 av.removePropertyChangeListener(propertyChangeListener);
1553 propertyChangeListener = null;
1554 StructureSelectionManager ssm = av.getStructureSelectionManager();
1555 ssm.removeStructureViewerListener(getSeqPanel(), null);
1556 ssm.removeSelectionListener(getSeqPanel());
1557 ssm.removeCommandListener(av);
1558 ssm.removeStructureViewerListener(getSeqPanel(), null);
1559 ssm.removeSelectionListener(getSeqPanel());
1565 if (Cache.log.isDebugEnabled())
1567 Cache.log.warn("Closing alignment panel which is already closed.");
1573 * Close any open dialogs that would be orphaned when this one is closed
1575 protected void closeChildFrames()
1577 if (overviewPanel != null)
1579 overviewPanel.dispose();
1580 overviewPanel = null;
1582 if (calculationDialog != null)
1584 calculationDialog.closeFrame();
1585 calculationDialog = null;
1590 * hides or shows dynamic annotation rows based on groups and av state flags
1592 public void updateAnnotation()
1594 updateAnnotation(false, false);
1597 public void updateAnnotation(boolean applyGlobalSettings)
1599 updateAnnotation(applyGlobalSettings, false);
1602 public void updateAnnotation(boolean applyGlobalSettings,
1603 boolean preserveNewGroupSettings)
1605 av.updateGroupAnnotationSettings(applyGlobalSettings,
1606 preserveNewGroupSettings);
1607 adjustAnnotationHeight();
1611 public AlignmentI getAlignment()
1613 return av == null ? null : av.getAlignment();
1617 public String getViewName()
1619 return av.getViewName();
1623 * Make/Unmake this alignment panel the current input focus
1627 public void setSelected(boolean b)
1631 if (alignFrame.getSplitViewContainer() != null)
1634 * bring enclosing SplitFrame to front first if there is one
1636 ((SplitFrame) alignFrame.getSplitViewContainer()).setSelected(b);
1638 alignFrame.setSelected(b);
1639 } catch (Exception ex)
1645 alignFrame.setDisplayedView(this);
1650 public StructureSelectionManager getStructureSelectionManager()
1652 return av.getStructureSelectionManager();
1656 public void raiseOOMWarning(String string, OutOfMemoryError error)
1658 new OOMWarning(string, error, this);
1662 public jalview.api.FeatureRenderer cloneFeatureRenderer()
1665 return new FeatureRenderer(this);
1669 public jalview.api.FeatureRenderer getFeatureRenderer()
1671 return seqPanel.seqCanvas.getFeatureRenderer();
1674 public void updateFeatureRenderer(
1675 jalview.renderer.seqfeatures.FeatureRenderer fr)
1677 fr.transferSettings(getSeqPanel().seqCanvas.getFeatureRenderer());
1680 public void updateFeatureRendererFrom(jalview.api.FeatureRenderer fr)
1682 if (getSeqPanel().seqCanvas.getFeatureRenderer() != null)
1684 getSeqPanel().seqCanvas.getFeatureRenderer().transferSettings(fr);
1688 public ScalePanel getScalePanel()
1693 public void setScalePanel(ScalePanel scalePanel)
1695 this.scalePanel = scalePanel;
1698 public SeqPanel getSeqPanel()
1703 public void setSeqPanel(SeqPanel seqPanel)
1705 this.seqPanel = seqPanel;
1708 public AnnotationPanel getAnnotationPanel()
1710 return annotationPanel;
1713 public void setAnnotationPanel(AnnotationPanel annotationPanel)
1715 this.annotationPanel = annotationPanel;
1718 public AnnotationLabels getAlabels()
1723 public void setAlabels(AnnotationLabels alabels)
1725 this.alabels = alabels;
1728 public IdPanel getIdPanel()
1733 public void setIdPanel(IdPanel idPanel)
1735 this.idPanel = idPanel;
1739 * Follow a scrolling change in the (cDNA/Protein) complementary alignment.
1740 * The aim is to keep the two alignments 'lined up' on their centre columns.
1743 * holds mapped region(s) of this alignment that we are scrolling
1744 * 'to'; may be modified for sequence offset by this method
1745 * @param verticalOffset
1746 * the number of visible sequences to show above the mapped region
1748 protected void scrollToCentre(SearchResultsI sr, int verticalOffset)
1750 scrollToPosition(sr, verticalOffset, true);
1754 * Set a flag to say do not scroll any (cDNA/protein) complement.
1758 protected void setToScrollComplementPanel(boolean b)
1760 this.scrollComplementaryPanel = b;
1764 * Get whether to scroll complement panel
1766 * @return true if cDNA/protein complement panels should be scrolled
1768 protected boolean isSetToScrollComplementPanel()
1770 return this.scrollComplementaryPanel;
1776 * @adjustHeight if true, try to recalculate panel height for visible
1779 protected void refresh(boolean adjustHeight)
1781 validateAnnotationDimensions(adjustHeight);
1785 // sort, repaint, update overview
1786 paintAlignment(true, false);
1790 // lightweight repaint
1797 * Property change event fired when a change is made to the viewport ranges
1798 * object associated with this alignment panel's viewport
1800 public void propertyChange(PropertyChangeEvent evt)
1802 // update this panel's scroll values based on the new viewport ranges values
1803 ViewportRanges ranges = av.getRanges();
1804 int x = ranges.getStartRes();
1805 int y = ranges.getStartSeq();
1806 setScrollValues(x, y);
1808 // now update any complementary alignment (its viewport ranges object
1809 // is different so does not get automatically updated)
1810 if (isSetToScrollComplementPanel())
1812 setToScrollComplementPanel(false);
1813 av.scrollComplementaryAlignment();
1814 setToScrollComplementPanel(true);
1819 * Set the reference to the PCA/Tree chooser dialog for this panel. This
1820 * reference should be nulled when the dialog is closed.
1822 * @param calculationChooser
1824 public void setCalculationDialog(CalculationChooser calculationChooser)
1826 calculationDialog = calculationChooser;
1830 * Returns the reference to the PCA/Tree chooser dialog for this panel (null
1833 public CalculationChooser getCalculationDialog()
1835 return calculationDialog;
1839 public SequenceRenderer getSequenceRenderer()
1841 return seqPanel.seqCanvas.getSequenceRenderer();
1844 public boolean scrollTo(int ostart, int end, int seqIndex,
1845 boolean scrollToNearest, boolean redrawOverview)
1847 int startv, endv, starts, ends;// , width;
1850 if (av.hasHiddenColumns())
1852 AlignmentI al = av.getAlignment();
1853 start = al.getHiddenColumns().absoluteToVisibleColumn(ostart);
1854 end = al.getHiddenColumns().absoluteToVisibleColumn(end);
1857 if (!scrollToNearest && !al.getHiddenColumns().isVisible(ostart))
1859 // don't scroll - position isn't visible
1869 ViewportRanges ranges = av.getRanges();
1870 if (!av.getWrapAlignment())
1873 * int spos=av.getStartRes(),sqpos=av.getStartSeq(); if ((startv =
1874 * av.getStartRes()) >= start) { spos=start-1; // seqIn //
1875 * setScrollValues(start - 1, seqIndex); } else if ((endv =
1876 * av.getEndRes()) <= end) { // setScrollValues(spos=startv + 1 + end -
1877 * endv, seqIndex); spos=startv + 1 + end - endv; } else if ((starts =
1878 * av.getStartSeq()) > seqIndex) { setScrollValues(av.getStartRes(),
1879 * seqIndex); } else if ((ends = av.getEndSeq()) <= seqIndex) {
1880 * setScrollValues(av.getStartRes(), starts + seqIndex - ends + 1); }
1883 // below is scrolling logic up to Jalview 2.8.2
1884 // if ((av.getStartRes() > end)
1885 // || (av.getEndRes() < start)
1886 // || ((av.getStartSeq() > seqIndex) || (av.getEndSeq() < seqIndex)))
1888 // if (start > av.getAlignment().getWidth() - hextent)
1890 // start = av.getAlignment().getWidth() - hextent;
1897 // if (seqIndex > av.getAlignment().getHeight() - vextent)
1899 // seqIndex = av.getAlignment().getHeight() - vextent;
1900 // if (seqIndex < 0)
1905 // setScrollValues(start, seqIndex);
1907 // logic copied from jalview.gui.AlignmentPanel:
1908 if ((startv = ranges.getStartRes()) >= start)
1911 * Scroll left to make start of search results visible
1913 setScrollValues(start - 1, seqIndex);
1915 else if ((endv = ranges.getEndRes()) <= end)
1918 * Scroll right to make end of search results visible
1920 setScrollValues(startv + 1 + end - endv, seqIndex);
1922 else if ((starts = ranges.getStartSeq()) > seqIndex)
1925 * Scroll up to make start of search results visible
1927 setScrollValues(ranges.getStartRes(), seqIndex);
1929 else if ((ends = ranges.getEndSeq()) <= seqIndex)
1932 * Scroll down to make end of search results visible
1934 setScrollValues(ranges.getStartRes(), starts + seqIndex - ends + 1);
1937 * Else results are already visible - no need to scroll
1942 ranges.scrollToWrappedVisible(start);
1945 paintAlignment(redrawOverview, false);
1950 public void overviewDone(BufferedImage miniMe)
1952 overviewPanel.canvas.finalizeDraw(miniMe);
1956 private boolean holdRepaint = false;
1958 public boolean getHoldRepaint()
1963 public void setHoldRepaint(boolean b)
1965 if (holdRepaint == b)
1977 public void repaint()
1981 // System.out.println("AP repaint holding");
1982 // Platform.stackTrace();