2 * (C) Copyright IBM Corp. 1998-2004. All Rights Reserved.
\r
4 * The program is provided "as is" without any warranty express or
\r
5 * implied, including the warranty of non-infringement and the implied
\r
6 * warranties of merchantibility and fitness for a particular purpose.
\r
7 * IBM will not be liable for any damages suffered by you as a result
\r
8 * of using the Program. In no event will IBM be liable for any
\r
9 * special, indirect or consequential damages or lost profits even if
\r
10 * IBM has been advised of the possibility of their occurrence. IBM
\r
11 * will not be liable for any third party claims against you.
\r
13 package com.ibm.richtext.textpanel;
\r
15 import java.awt.Image;
\r
16 import java.awt.Component;
\r
18 class OffscreenBufferCache {
\r
20 static final String COPYRIGHT =
\r
21 "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
\r
22 private Image fOffscreenBuffer = null;
\r
23 private Component fHost;
\r
25 OffscreenBufferCache(Component host) {
\r
30 private Image makeBuffer(int width, int height) {
\r
32 return fHost.createImage(Math.max(width, 1), Math.max(height, 1));
\r
35 Image getBuffer(int width, int height) {
\r
37 Image buffer = fOffscreenBuffer;
\r
39 if (buffer != null) {
\r
40 if (buffer.getWidth(fHost) >= width &&
\r
41 buffer.getHeight(fHost) >= height) {
\r
46 buffer = makeBuffer(width, height);
\r
47 fOffscreenBuffer = buffer;
\r