]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_2_1-src/src/com/ibm/richtext/textlayout/Graphics2DConversion.java
icu4jsrc
[Dictionary.git] / jars / icu4j-4_2_1-src / src / com / ibm / richtext / textlayout / Graphics2DConversion.java
1 /*\r
2  * (C) Copyright IBM Corp. 1998-2004.  All Rights Reserved.\r
3  *\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
12  */\r
13 // Requires Java2\r
14 package com.ibm.richtext.textlayout;\r
15 \r
16 import java.awt.Graphics;\r
17 import java.awt.Graphics2D;\r
18 import java.awt.Paint;\r
19 \r
20 /**\r
21  * This class allows JDK 1.1 code to use a "fake" Graphics2D\r
22  * for source-code compatibility with Java2 code.  On Java2 it's\r
23  * a trivial class.  The JDK 1.1 version of this class does interesting\r
24  * work.\r
25  */ \r
26 public final class Graphics2DConversion {\r
27 \r
28     static final String COPYRIGHT =\r
29                 "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";\r
30                 \r
31     public static Graphics2D getGraphics2D(Graphics g) {\r
32         return (Graphics2D) g;\r
33     }\r
34 \r
35     public static Graphics getGraphics(Graphics2D g) {\r
36         return g;\r
37     }\r
38 \r
39     /**\r
40      * Will return an instance of Paint.\r
41      */\r
42     public static Object getColorState(Graphics2D g) {\r
43 \r
44         return g.getPaint();\r
45     }\r
46 \r
47     /**\r
48      * State must be an instance of Paint.\r
49      */\r
50     public static void restoreColorState(Graphics2D g, Object state) {\r
51 \r
52         g.setPaint((Paint) state);\r
53     }\r
54 }