2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 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.api.AlignmentViewPanel;
24 import jalview.datamodel.AlignmentI;
25 import jalview.datamodel.SearchResults;
26 import jalview.datamodel.SequenceI;
27 import jalview.structure.StructureSelectionManager;
29 import java.awt.BorderLayout;
30 import java.awt.Color;
31 import java.awt.Dimension;
32 import java.awt.FontMetrics;
33 import java.awt.Frame;
34 import java.awt.Graphics;
35 import java.awt.Panel;
36 import java.awt.Scrollbar;
37 import java.awt.event.AdjustmentEvent;
38 import java.awt.event.AdjustmentListener;
39 import java.awt.event.ComponentAdapter;
40 import java.awt.event.ComponentEvent;
42 public class AlignmentPanel extends Panel implements AdjustmentListener,
46 public AlignViewport av;
48 OverviewPanel overviewPanel;
54 IdwidthAdjuster idwidthAdjuster;
56 public AlignFrame alignFrame;
58 ScalePanel scalePanel;
60 AnnotationPanel annotationPanel;
62 AnnotationLabels alabels;
64 // this value is set false when selection area being dragged
65 boolean fastPaint = true;
67 public void finalize()
72 seqPanelHolder = null;
73 sequenceHolderPanel = null;
75 scalePanelHolder = null;
76 annotationPanel = null;
77 annotationPanelHolder = null;
78 annotationSpaceFillerHolder = null;
81 public AlignmentPanel(AlignFrame af, final AlignViewport av)
93 seqPanel = new SeqPanel(av, this);
94 idPanel = new IdPanel(av, this);
95 scalePanel = new ScalePanel(av, this);
96 idwidthAdjuster = new IdwidthAdjuster(this);
97 annotationPanel = new AnnotationPanel(this);
98 annotationPanelHolder.add(annotationPanel, BorderLayout.CENTER);
100 sequenceHolderPanel.add(annotationPanelHolder, BorderLayout.SOUTH);
101 alabels = new AnnotationLabels(this);
103 setAnnotationVisible(av.showAnnotation);
105 idPanelHolder.add(idPanel, BorderLayout.CENTER);
106 idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER);
107 annotationSpaceFillerHolder.add(alabels, BorderLayout.CENTER);
108 scalePanelHolder.add(scalePanel, BorderLayout.CENTER);
109 seqPanelHolder.add(seqPanel, BorderLayout.CENTER);
112 setScrollValues(0, 0);
114 apvscroll.addAdjustmentListener(this);
115 hscroll.addAdjustmentListener(this);
116 vscroll.addAdjustmentListener(this);
118 addComponentListener(new ComponentAdapter()
120 public void componentResized(ComponentEvent evt)
122 setScrollValues(av.getStartRes(), av.getStartSeq());
123 if (getSize().height > 0
124 && annotationPanelHolder.getSize().height > 0)
126 validateAnnotationDimensions(false);
133 Dimension d = calculateIdWidth();
134 idPanel.idCanvas.setSize(d);
136 hscrollFillerPanel.setSize(d.width, annotationPanel.getSize().height);
138 idPanel.idCanvas.setSize(d.width, seqPanel.seqCanvas.getSize().height);
139 annotationSpaceFillerHolder.setSize(d.width,
140 annotationPanel.getSize().height);
141 alabels.setSize(d.width, annotationPanel.getSize().height);
142 final AlignmentPanel ap = this;
143 av.addPropertyChangeListener(new java.beans.PropertyChangeListener()
145 public void propertyChange(java.beans.PropertyChangeEvent evt)
147 if (evt.getPropertyName().equals("alignment"))
149 PaintRefresher.Refresh(ap, av.getSequenceSetId(), true, true);
156 public SequenceRenderer getSequenceRenderer()
158 return seqPanel.seqCanvas.sr;
161 public FeatureRenderer getFeatureRenderer()
163 return seqPanel.seqCanvas.fr;
166 public void alignmentChanged()
168 av.alignmentChanged(this);
170 if (overviewPanel != null)
172 overviewPanel.updateOverviewImage();
175 alignFrame.updateEditMenuBar();
180 public void fontChanged()
182 // set idCanvas bufferedImage to null
183 // to prevent drawing old image
184 idPanel.idCanvas.image = null;
185 FontMetrics fm = getFontMetrics(av.getFont());
187 scalePanel.setSize(new Dimension(10, av.charHeight + fm.getDescent()));
188 idwidthAdjuster.setSize(new Dimension(10, av.charHeight
190 av.updateSequenceIdColours();
191 annotationPanel.image = null;
192 int ap = annotationPanel.adjustPanelHeight(false);
193 Dimension d = calculateIdWidth();
194 d.setSize(d.width + 4, seqPanel.seqCanvas.getSize().height);
195 alabels.setSize(d.width + 4, ap);
197 idPanel.idCanvas.setSize(d);
198 hscrollFillerPanel.setSize(d);
200 validateAnnotationDimensions(false);
201 annotationPanel.repaint();
205 if (overviewPanel != null)
207 overviewPanel.updateOverviewImage();
211 public void setIdWidth(int w, int h)
213 idPanel.idCanvas.setSize(w, h);
214 idPanelHolder.setSize(w, idPanelHolder.getSize().height);
215 annotationSpaceFillerHolder.setSize(w,
216 annotationSpaceFillerHolder.getSize().height);
217 alabels.setSize(w, alabels.getSize().height);
221 Dimension calculateIdWidth()
223 if (av.nullFrame == null)
225 av.nullFrame = new Frame();
226 av.nullFrame.addNotify();
229 Graphics g = av.nullFrame.getGraphics();
231 FontMetrics fm = g.getFontMetrics(av.font);
232 AlignmentI al = av.getAlignment();
237 while (i < al.getHeight() && al.getSequenceAt(i) != null)
239 SequenceI s = al.getSequenceAt(i);
240 id = s.getDisplayId(av.getShowJVSuffix());
242 if (fm.stringWidth(id) > idWidth)
244 idWidth = fm.stringWidth(id);
249 // Also check annotation label widths
251 if (al.getAlignmentAnnotation() != null)
253 fm = g.getFontMetrics(av.nullFrame.getFont());
254 while (i < al.getAlignmentAnnotation().length)
256 String label = al.getAlignmentAnnotation()[i].label;
257 if (fm.stringWidth(label) > idWidth)
259 idWidth = fm.stringWidth(label);
265 return new Dimension(idWidth, idPanel.idCanvas.getSize().height);
269 * Highlight the given results on the alignment.
272 public void highlightSearchResults(SearchResults results)
274 scrollToPosition(results);
275 seqPanel.seqCanvas.highlightSearchResults(results);
279 * scroll the view to show the position of the highlighted region in results
280 * (if any) and redraw the overview
283 * @return false if results were not found
285 public boolean scrollToPosition(SearchResults results)
287 return scrollToPosition(results, true);
291 * scroll the view to show the position of the highlighted region in results
295 * @param redrawOverview
296 * - when set, the overview will be recalculated (takes longer)
297 * @return false if results were not found
299 public boolean scrollToPosition(SearchResults results,
300 boolean redrawOverview)
303 // do we need to scroll the panel?
304 if (results != null && results.getSize() > 0)
306 AlignmentI alignment = av.getAlignment();
307 int seqIndex = alignment.findIndex(results);
312 SequenceI seq = alignment.getSequenceAt(seqIndex);
313 int[] r = results.getResults(seq, 0, alignment.getWidth());
319 .println("DEBUG: scroll didn't happen - results not within alignment : "
320 + seq.getStart() + "," + seq.getEnd());
328 * System.out.println("DEBUG: scroll: start=" + r[0] +
329 * " av.getStartRes()=" + av.getStartRes() + " end=" + r[1] +
330 * " seq.end=" + seq.getEnd() + " av.getEndRes()=" + av.getEndRes() +
331 * " hextent=" + hextent);
340 if (end == seq.getEnd())
344 return scrollTo(start, end, seqIndex, false, redrawOverview);
349 public boolean scrollTo(int ostart, int end, int seqIndex,
350 boolean scrollToNearest, boolean redrawOverview)
352 int startv, endv, starts, ends, width;
355 if (av.hasHiddenColumns())
357 start = av.getColumnSelection().findColumnPosition(ostart);
358 end = av.getColumnSelection().findColumnPosition(end);
361 if (!scrollToNearest && !av.getColumnSelection().isVisible(ostart))
363 // don't scroll - position isn't visible
372 if (!av.wrapAlignment)
375 * int spos=av.getStartRes(),sqpos=av.getStartSeq(); if ((startv =
376 * av.getStartRes()) >= start) { spos=start-1; // seqIn //
377 * setScrollValues(start - 1, seqIndex); } else if ((endv =
378 * av.getEndRes()) <= end) { // setScrollValues(spos=startv + 1 + end -
379 * endv, seqIndex); spos=startv + 1 + end - endv; } else if ((starts =
380 * av.getStartSeq()) > seqIndex) { setScrollValues(av.getStartRes(),
381 * seqIndex); } else if ((ends = av.getEndSeq()) <= seqIndex) {
382 * setScrollValues(av.getStartRes(), starts + seqIndex - ends + 1); }
386 if ((av.getStartRes() > end)
387 || (av.getEndRes() < start)
388 || ((av.getStartSeq() > seqIndex) || (av.getEndSeq() < seqIndex)))
390 if (start > av.getAlignment().getWidth() - hextent)
392 start = av.getAlignment().getWidth() - hextent;
399 if (seqIndex > av.getAlignment().getHeight() - vextent)
401 seqIndex = av.getAlignment().getHeight() - vextent;
407 // System.out.println("trying to scroll to: "+start+" "+seqIndex);
408 setScrollValues(start, seqIndex);
413 scrollToWrappedVisible(start);
415 if (redrawOverview && overviewPanel != null)
417 overviewPanel.setBoxPosition();
419 paintAlignment(redrawOverview);
423 void scrollToWrappedVisible(int res)
425 int cwidth = seqPanel.seqCanvas
426 .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width);
427 if (res <= av.getStartRes() || res >= (av.getStartRes() + cwidth))
429 vscroll.setValue(res / cwidth);
430 av.startRes = vscroll.getValue() * cwidth;
434 public OverviewPanel getOverviewPanel()
436 return overviewPanel;
439 public void setOverviewPanel(OverviewPanel op)
444 public void setAnnotationVisible(boolean b)
446 if (!av.wrapAlignment)
448 annotationSpaceFillerHolder.setVisible(b);
449 annotationPanelHolder.setVisible(b);
453 annotationSpaceFillerHolder.setVisible(false);
454 annotationPanelHolder.setVisible(false);
461 * automatically adjust annotation panel height for new annotation whilst
462 * ensuring the alignment is still visible.
464 public void adjustAnnotationHeight()
466 // TODO: display vertical annotation scrollbar if necessary
467 // this is called after loading new annotation onto alignment
468 if (alignFrame.getSize().height == 0)
470 System.out.println("NEEDS FIXING");
473 validateAnnotationDimensions(true);
474 apvscroll.addNotify();
477 paintAlignment(true);
481 * calculate the annotation dimensions and refresh slider values accordingly.
482 * need to do repaints/notifys afterwards.
484 protected void validateAnnotationDimensions(boolean adjustPanelHeight)
486 boolean modified = false;
487 int height = av.calcPanelHeight();
489 if (hscroll.isVisible())
491 height += (minsize = hscroll.getPreferredSize().height);
493 if (apvscroll.isVisible())
495 minsize += apvscroll.getPreferredSize().height;
497 int mheight = height;
498 Dimension d = sequenceHolderPanel.getSize(), e = idPanel.getSize();
499 int seqandannot = d.height - scalePanelHolder.getSize().height;
501 if (adjustPanelHeight)
503 // NOTE: this logic is different in the application. Need a better
504 // algorithm to define behaviour
505 // sets initial preferred height
506 // try and set height according to alignment
507 float sscaling = (float) ((av.getCharHeight() * av.getAlignment()
508 .getHeight()) / (1.0 * mheight));
511 // if the alignment is too big then
512 // default is 0.5 split
513 height = seqandannot / 2;
517 // otherwise just set the panel so that one row of sequence is visible
518 height = -av.getCharHeight() * 1
519 + (int) (seqandannot * (1 - sscaling));
524 // maintain same window layout whilst updating sliders
525 height = annotationPanelHolder.getSize().height;
528 if (seqandannot - height < 5)
530 height = seqandannot;
532 annotationPanel.setSize(new Dimension(d.width, height));
533 alabels.setSize(new Dimension(e.width, height));
534 annotationSpaceFillerHolder.setSize(new Dimension(e.width, height));
535 annotationPanelHolder.setSize(new Dimension(d.width, height));
536 // seqPanelHolder.setSize(d.width, seqandannot - height);
538 .setSize(d.width, seqPanel.seqCanvas.getSize().height);
539 int s = apvscroll.getValue();
540 if (s > mheight - height)
544 apvscroll.setValues(s, height, 0, mheight);
545 annotationPanel.setScrollOffset(apvscroll.getValue(), false);
546 alabels.setScrollOffset(apvscroll.getValue(), false);
549 public void setWrapAlignment(boolean wrap)
553 scalePanelHolder.setVisible(!wrap);
555 hscroll.setVisible(!wrap);
556 idwidthAdjuster.setVisible(!wrap);
560 annotationPanelHolder.setVisible(false);
561 annotationSpaceFillerHolder.setVisible(false);
563 else if (av.showAnnotation)
565 annotationPanelHolder.setVisible(true);
566 annotationSpaceFillerHolder.setVisible(true);
569 idSpaceFillerPanel1.setVisible(!wrap);
571 fontChanged(); // This is so that the scalePanel is resized correctly
574 sequenceHolderPanel.validate();
583 // return value is true if the scroll is valid
584 public boolean scrollUp(boolean up)
588 if (vscroll.getValue() < 1)
592 setScrollValues(hscroll.getValue(), vscroll.getValue() - 1);
596 if (vextent + vscroll.getValue() >= av.getAlignment().getHeight())
600 setScrollValues(hscroll.getValue(), vscroll.getValue() + 1);
607 public boolean scrollRight(boolean right)
611 if (hscroll.getValue() < 1)
615 setScrollValues(hscroll.getValue() - 1, vscroll.getValue());
619 if (hextent + hscroll.getValue() >= av.getAlignment().getWidth())
623 setScrollValues(hscroll.getValue() + 1, vscroll.getValue());
630 public void setScrollValues(int x, int y)
632 int width = av.getAlignment().getWidth();
633 int height = av.getAlignment().getHeight();
635 if (av.hasHiddenColumns())
637 width = av.getColumnSelection().findColumnPosition(width);
645 hextent = seqPanel.seqCanvas.getSize().width / av.charWidth;
646 vextent = seqPanel.seqCanvas.getSize().height / av.charHeight;
653 if (vextent > height)
658 if ((hextent + x) > width)
660 System.err.println("hextent was " + hextent + " and x was " + x);
665 if ((vextent + y) > height)
667 y = height - vextent;
677 System.err.println("x was " + x);
683 int endSeq = y + vextent;
684 if (endSeq > av.getAlignment().getHeight())
686 endSeq = av.getAlignment().getHeight();
689 av.setEndSeq(endSeq);
691 av.setEndRes((x + (seqPanel.seqCanvas.getSize().width / av.charWidth)) - 1);
693 hscroll.setValues(x, hextent, 0, width);
694 vscroll.setValues(y, vextent, 0, height);
696 if (overviewPanel != null)
698 overviewPanel.setBoxPosition();
704 public void adjustmentValueChanged(AdjustmentEvent evt)
706 int oldX = av.getStartRes();
707 int oldY = av.getStartSeq();
709 if (evt == null || evt.getSource() == apvscroll)
711 annotationPanel.setScrollOffset(apvscroll.getValue(), false);
712 alabels.setScrollOffset(apvscroll.getValue(), false);
713 // annotationPanel.image=null;
714 // alabels.image=null;
715 // alabels.repaint();
716 // annotationPanel.repaint();
718 if (evt == null || evt.getSource() == hscroll)
720 int x = hscroll.getValue();
722 av.setEndRes(x + seqPanel.seqCanvas.getSize().width
723 / av.getCharWidth() - 1);
726 if (evt == null || evt.getSource() == vscroll)
728 int offy = vscroll.getValue();
729 if (av.getWrapAlignment())
731 int rowSize = seqPanel.seqCanvas
732 .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width);
733 av.setStartRes(vscroll.getValue() * rowSize);
734 av.setEndRes((vscroll.getValue() + 1) * rowSize);
738 av.setStartSeq(offy);
739 av.setEndSeq(offy + seqPanel.seqCanvas.getSize().height
740 / av.getCharHeight());
744 if (overviewPanel != null)
746 overviewPanel.setBoxPosition();
749 int scrollX = av.startRes - oldX;
750 int scrollY = av.startSeq - oldY;
752 if (av.getWrapAlignment() || !fastPaint || av.MAC)
758 // Make sure we're not trying to draw a panel
759 // larger than the visible window
760 if (scrollX > av.endRes - av.startRes)
762 scrollX = av.endRes - av.startRes;
764 else if (scrollX < av.startRes - av.endRes)
766 scrollX = av.startRes - av.endRes;
769 idPanel.idCanvas.fastPaint(scrollY);
770 seqPanel.seqCanvas.fastPaint(scrollX, scrollY);
772 scalePanel.repaint();
773 if (av.getShowAnnotation())
775 annotationPanel.fastPaint(av.getStartRes() - oldX);
782 private void sendViewPosition()
784 StructureSelectionManager.getStructureSelectionManager(av.applet)
785 .sendViewPosition(this, av.startRes, av.endRes, av.startSeq,
789 public void paintAlignment(boolean updateOverview)
795 jalview.structure.StructureSelectionManager
796 .getStructureSelectionManager(av.applet)
797 .sequenceColoursChanged(this);
799 if (overviewPanel != null)
801 overviewPanel.updateOverviewImage();
806 public void update(Graphics g)
811 public void paint(Graphics g)
814 Dimension d = idPanel.idCanvas.getSize();
815 idPanel.idCanvas.setSize(d.width, seqPanel.seqCanvas.getSize().height);
817 if (av.getWrapAlignment())
819 int maxwidth = av.getAlignment().getWidth();
821 if (av.hasHiddenColumns())
823 maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
826 int canvasWidth = seqPanel.seqCanvas
827 .getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width);
831 int max = maxwidth / canvasWidth;
832 vscroll.setMaximum(1 + max);
833 vscroll.setUnitIncrement(1);
834 vscroll.setVisibleAmount(1);
839 setScrollValues(av.getStartRes(), av.getStartSeq());
842 seqPanel.seqCanvas.repaint();
843 idPanel.idCanvas.repaint();
844 if (!av.wrapAlignment)
846 if (av.showAnnotation)
849 annotationPanel.repaint();
851 scalePanel.repaint();
856 protected Panel sequenceHolderPanel = new Panel();
858 protected Scrollbar vscroll = new Scrollbar();
860 protected Scrollbar hscroll = new Scrollbar();
862 protected Panel seqPanelHolder = new Panel();
864 BorderLayout borderLayout1 = new BorderLayout();
866 BorderLayout borderLayout3 = new BorderLayout();
868 protected Panel scalePanelHolder = new Panel();
870 protected Panel idPanelHolder = new Panel();
872 BorderLayout borderLayout5 = new BorderLayout();
874 protected Panel idSpaceFillerPanel1 = new Panel();
876 public Panel annotationSpaceFillerHolder = new Panel();
878 BorderLayout borderLayout6 = new BorderLayout();
880 BorderLayout borderLayout7 = new BorderLayout();
882 Panel hscrollHolder = new Panel();
884 BorderLayout borderLayout10 = new BorderLayout();
886 protected Panel hscrollFillerPanel = new Panel();
888 BorderLayout borderLayout11 = new BorderLayout();
890 BorderLayout borderLayout4 = new BorderLayout();
892 BorderLayout borderLayout2 = new BorderLayout();
894 Panel annotationPanelHolder = new Panel();
896 protected Scrollbar apvscroll = new Scrollbar();
898 BorderLayout borderLayout12 = new BorderLayout();
900 private void jbInit() throws Exception
902 // idPanelHolder.setPreferredSize(new Dimension(70, 10));
903 this.setLayout(borderLayout7);
905 // sequenceHolderPanel.setPreferredSize(new Dimension(150, 150));
906 sequenceHolderPanel.setLayout(borderLayout3);
907 seqPanelHolder.setLayout(borderLayout1);
908 scalePanelHolder.setBackground(Color.white);
910 // scalePanelHolder.setPreferredSize(new Dimension(10, 30));
911 scalePanelHolder.setLayout(borderLayout6);
912 idPanelHolder.setLayout(borderLayout5);
913 idSpaceFillerPanel1.setBackground(Color.white);
915 // idSpaceFillerPanel1.setPreferredSize(new Dimension(10, 30));
916 idSpaceFillerPanel1.setLayout(borderLayout11);
917 annotationSpaceFillerHolder.setBackground(Color.white);
919 // annotationSpaceFillerHolder.setPreferredSize(new Dimension(10, 80));
920 annotationSpaceFillerHolder.setLayout(borderLayout4);
921 hscroll.setOrientation(Scrollbar.HORIZONTAL);
922 hscrollHolder.setLayout(borderLayout10);
923 hscrollFillerPanel.setBackground(Color.white);
924 apvscroll.setOrientation(Scrollbar.VERTICAL);
925 apvscroll.setVisible(true);
926 apvscroll.addAdjustmentListener(this);
928 annotationPanelHolder.setBackground(Color.white);
929 annotationPanelHolder.setLayout(borderLayout12);
930 annotationPanelHolder.add(apvscroll, BorderLayout.EAST);
931 // hscrollFillerPanel.setPreferredSize(new Dimension(70, 10));
932 hscrollHolder.setBackground(Color.white);
934 // annotationScroller.setPreferredSize(new Dimension(10, 80));
935 // this.setPreferredSize(new Dimension(220, 166));
936 seqPanelHolder.setBackground(Color.white);
937 idPanelHolder.setBackground(Color.white);
938 sequenceHolderPanel.add(scalePanelHolder, BorderLayout.NORTH);
939 sequenceHolderPanel.add(seqPanelHolder, BorderLayout.CENTER);
940 seqPanelHolder.add(vscroll, BorderLayout.EAST);
942 // Panel3.add(secondaryPanelHolder, BorderLayout.SOUTH);
943 this.add(idPanelHolder, BorderLayout.WEST);
944 idPanelHolder.add(idSpaceFillerPanel1, BorderLayout.NORTH);
945 idPanelHolder.add(annotationSpaceFillerHolder, BorderLayout.SOUTH);
946 this.add(hscrollHolder, BorderLayout.SOUTH);
947 hscrollHolder.add(hscroll, BorderLayout.CENTER);
948 hscrollHolder.add(hscrollFillerPanel, BorderLayout.WEST);
949 this.add(sequenceHolderPanel, BorderLayout.CENTER);
953 * hides or shows dynamic annotation rows based on groups and av state flags
955 public void updateAnnotation()
957 updateAnnotation(false);
960 public void updateAnnotation(boolean applyGlobalSettings)
962 updateAnnotation(applyGlobalSettings, false);
965 public void updateAnnotation(boolean applyGlobalSettings,
966 boolean preserveNewGroupSettings)
968 av.updateGroupAnnotationSettings(applyGlobalSettings,
969 preserveNewGroupSettings);
970 adjustAnnotationHeight();
974 public AlignmentI getAlignment()
976 return av.getAlignment();
980 public String getViewName()
986 public StructureSelectionManager getStructureSelectionManager()
988 return StructureSelectionManager
989 .getStructureSelectionManager(av.applet);
993 public void raiseOOMWarning(String string, OutOfMemoryError error)
996 System.err.println("Out of memory whilst '" + string + "'");
997 error.printStackTrace();