24 */ |
24 */ |
25 |
25 |
26 package sun.awt; |
26 package sun.awt; |
27 |
27 |
28 import java.awt.*; |
28 import java.awt.*; |
|
29 import java.awt.geom.Point2D; |
|
30 import java.awt.image.BufferedImage; |
|
31 |
29 import sun.misc.Unsafe; |
32 import sun.misc.Unsafe; |
30 |
33 |
31 /** The AWTAccessor utility class. |
34 /** The AWTAccessor utility class. |
32 * The main purpose of this class is to enable accessing |
35 * The main purpose of this class is to enable accessing |
33 * private and package-private fields of classes from |
36 * private and package-private fields of classes from |
34 * different classes/packages. See sun.misc.SharedSecretes |
37 * different classes/packages. See sun.misc.SharedSecretes |
35 * for another example. |
38 * for another example. |
36 */ |
39 */ |
37 public final class AWTAccessor { |
40 public final class AWTAccessor { |
|
41 |
38 private static final Unsafe unsafe = Unsafe.getUnsafe(); |
42 private static final Unsafe unsafe = Unsafe.getUnsafe(); |
39 |
43 |
40 /** We don't need any objects of this class. |
44 /* |
|
45 * We don't need any objects of this class. |
41 * It's rather a collection of static methods |
46 * It's rather a collection of static methods |
42 * and interfaces. |
47 * and interfaces. |
43 */ |
48 */ |
44 private AWTAccessor() { |
49 private AWTAccessor() { |
45 } |
50 } |
46 |
51 |
47 /** An accessor for the java.awt.Component class. |
52 /* |
|
53 * An interface of accessor for the java.awt.Component class. |
48 */ |
54 */ |
49 public interface ComponentAccessor { |
55 public interface ComponentAccessor { |
50 // See 6797587 |
56 /* |
51 // Also see: 6776743, 6768307, and 6768332. |
57 * Sets whether the native background erase for a component |
52 /** |
58 * has been disabled via SunToolkit.disableBackgroundErase(). |
|
59 */ |
|
60 void setBackgroundEraseDisabled(Component comp, boolean disabled); |
|
61 /* |
|
62 * Indicates whether the native background erase for a |
|
63 * component has been disabled via |
|
64 * SunToolkit.disableBackgroundErase(). |
|
65 */ |
|
66 boolean getBackgroundEraseDisabled(Component comp); |
|
67 /* |
|
68 * |
|
69 * Gets the bounds of this component in the form of a |
|
70 * <code>Rectangle</code> object. The bounds specify this |
|
71 * component's width, height, and location relative to |
|
72 * its parent. |
|
73 */ |
|
74 Rectangle getBounds(Component comp); |
|
75 /* |
53 * Sets the shape of a lw component to cut out from hw components. |
76 * Sets the shape of a lw component to cut out from hw components. |
|
77 * |
|
78 * See 6797587, 6776743, 6768307, and 6768332 for details |
54 */ |
79 */ |
55 void setMixingCutoutShape(Component comp, Shape shape); |
80 void setMixingCutoutShape(Component comp, Shape shape); |
56 } |
81 } |
57 |
82 |
58 /* The java.awt.Component class accessor object. |
83 /* |
|
84 * An interface of accessor for java.awt.Window class. |
|
85 */ |
|
86 public interface WindowAccessor { |
|
87 /* |
|
88 * Get opacity level of the given window. |
|
89 */ |
|
90 float getOpacity(Window window); |
|
91 /* |
|
92 * Set opacity level to the given window. |
|
93 */ |
|
94 void setOpacity(Window window, float opacity); |
|
95 /* |
|
96 * Get a shape assigned to the given window. |
|
97 */ |
|
98 Shape getShape(Window window); |
|
99 /* |
|
100 * Set a shape to the given window. |
|
101 */ |
|
102 void setShape(Window window, Shape shape); |
|
103 /* |
|
104 * Identify whether the given window is opaque (true) |
|
105 * or translucent (false). |
|
106 */ |
|
107 boolean isOpaque(Window window); |
|
108 /* |
|
109 * Set the opaque preoperty to the given window. |
|
110 */ |
|
111 void setOpaque(Window window, boolean isOpaque); |
|
112 /* |
|
113 * Update the image of a non-opaque (translucent) window. |
|
114 */ |
|
115 void updateWindow(Window window, BufferedImage backBuffer); |
|
116 } |
|
117 |
|
118 /* |
|
119 * An accessor for the AWTEvent class. |
|
120 */ |
|
121 public interface AWTEventAccessor { |
|
122 /* |
|
123 * |
|
124 * Sets the flag on this AWTEvent indicating that it was |
|
125 * generated by the system. |
|
126 */ |
|
127 void setSystemGenerated(AWTEvent ev); |
|
128 /* |
|
129 * |
|
130 * Indicates whether this AWTEvent was generated by the system. |
|
131 */ |
|
132 boolean isSystemGenerated(AWTEvent ev); |
|
133 } |
|
134 |
|
135 /* |
|
136 * The java.awt.Component class accessor object. |
59 */ |
137 */ |
60 private static ComponentAccessor componentAccessor; |
138 private static ComponentAccessor componentAccessor; |
61 |
139 |
62 /** Set an accessor object for the java.awt.Component class. |
140 /* |
|
141 * The java.awt.Window class accessor object. |
|
142 */ |
|
143 private static WindowAccessor windowAccessor; |
|
144 |
|
145 /* |
|
146 * The java.awt.AWTEvent class accessor object. |
|
147 */ |
|
148 private static AWTEventAccessor awtEventAccessor; |
|
149 |
|
150 /* |
|
151 * Set an accessor object for the java.awt.Component class. |
63 */ |
152 */ |
64 public static void setComponentAccessor(ComponentAccessor ca) { |
153 public static void setComponentAccessor(ComponentAccessor ca) { |
65 componentAccessor = ca; |
154 componentAccessor = ca; |
66 } |
155 } |
67 |
156 |
68 /** Retrieve the accessor object for the java.awt.Window class. |
157 /* |
|
158 * Retrieve the accessor object for the java.awt.Window class. |
69 */ |
159 */ |
70 public static ComponentAccessor getComponentAccessor() { |
160 public static ComponentAccessor getComponentAccessor() { |
71 if (componentAccessor == null) { |
161 if (componentAccessor == null) { |
72 unsafe.ensureClassInitialized(Component.class); |
162 unsafe.ensureClassInitialized(Component.class); |
73 } |
163 } |
74 |
164 |
75 return componentAccessor; |
165 return componentAccessor; |
76 } |
166 } |
|
167 |
|
168 /* |
|
169 * Set an accessor object for the java.awt.Window class. |
|
170 */ |
|
171 public static void setWindowAccessor(WindowAccessor wa) { |
|
172 windowAccessor = wa; |
|
173 } |
|
174 |
|
175 /* |
|
176 * Retrieve the accessor object for the java.awt.Window class. |
|
177 */ |
|
178 public static WindowAccessor getWindowAccessor() { |
|
179 if (windowAccessor == null) { |
|
180 unsafe.ensureClassInitialized(Window.class); |
|
181 } |
|
182 return windowAccessor; |
|
183 } |
|
184 |
|
185 /* |
|
186 * Set an accessor object for the java.awt.AWTEvent class. |
|
187 */ |
|
188 public static void setAWTEventAccessor(AWTEventAccessor aea) { |
|
189 awtEventAccessor = aea; |
|
190 } |
|
191 |
|
192 /* |
|
193 * Retrieve the accessor object for the java.awt.AWTEvent class. |
|
194 */ |
|
195 public static AWTEventAccessor getAWTEventAccessor() { |
|
196 return awtEventAccessor; |
|
197 } |
77 } |
198 } |