01: /*
02: * (C) Copyright IBM Corp. 1998-2004. All Rights Reserved.
03: *
04: * The program is provided "as is" without any warranty express or
05: * implied, including the warranty of non-infringement and the implied
06: * warranties of merchantibility and fitness for a particular purpose.
07: * IBM will not be liable for any damages suffered by you as a result
08: * of using the Program. In no event will IBM be liable for any
09: * special, indirect or consequential damages or lost profits even if
10: * IBM has been advised of the possibility of their occurrence. IBM
11: * will not be liable for any third party claims against you.
12: */
13: // Requires Java2
14: package com.ibm.richtext.textlayout;
15:
16: import java.awt.Graphics;
17: import java.awt.Graphics2D;
18: import java.awt.Paint;
19:
20: /**
21: * This class allows JDK 1.1 code to use a "fake" Graphics2D
22: * for source-code compatibility with Java2 code. On Java2 it's
23: * a trivial class. The JDK 1.1 version of this class does interesting
24: * work.
25: */
26: public final class Graphics2DConversion {
27:
28: static final String COPYRIGHT = "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
29:
30: public static Graphics2D getGraphics2D(Graphics g) {
31: return (Graphics2D) g;
32: }
33:
34: public static Graphics getGraphics(Graphics2D g) {
35: return g;
36: }
37:
38: /**
39: * Will return an instance of Paint.
40: */
41: public static Object getColorState(Graphics2D g) {
42:
43: return g.getPaint();
44: }
45:
46: /**
47: * State must be an instance of Paint.
48: */
49: public static void restoreColorState(Graphics2D g, Object state) {
50:
51: g.setPaint((Paint) state);
52: }
53: }
|