1:
37:
38:
39: package ;
40:
41: import ;
42: import ;
43:
44: import ;
45: import ;
46: import ;
47: import ;
48: import ;
49: import ;
50: import ;
51: import ;
52: import ;
53: import ;
54: import ;
55:
56: import ;
57:
58: public class GdkGraphicsEnvironment extends ClasspathGraphicsEnvironment
59: {
60: private final int native_state = GtkGenericPeer.getUniqueInteger ();
61:
62: private GdkScreenGraphicsDevice defaultDevice;
63:
64: private GdkScreenGraphicsDevice[] devices;
65:
66:
72: private Pointer display;
73:
74: static
75: {
76: if (true)
77: {
78: System.loadLibrary("gtkpeer");
79: }
80:
81: GtkToolkit.initializeGlobalIDs();
82: initIDs();
83: }
84:
85: private static native void initIDs();
86:
87: public GdkGraphicsEnvironment ()
88: {
89: nativeInitState();
90: }
91:
92: native void nativeInitState();
93:
94: public GraphicsDevice[] getScreenDevices ()
95: {
96: if (devices == null)
97: {
98: devices = nativeGetScreenDevices();
99: }
100:
101: return (GraphicsDevice[]) devices.clone();
102: }
103:
104: private native GdkScreenGraphicsDevice[] nativeGetScreenDevices();
105:
106: public GraphicsDevice getDefaultScreenDevice ()
107: {
108: if (GraphicsEnvironment.isHeadless ())
109: throw new HeadlessException ();
110:
111: synchronized (GdkGraphicsEnvironment.class)
112: {
113: if (defaultDevice == null)
114: {
115: defaultDevice = nativeGetDefaultScreenDevice();
116: }
117: }
118:
119: return defaultDevice;
120: }
121:
122: private native GdkScreenGraphicsDevice nativeGetDefaultScreenDevice();
123:
124: public Graphics2D createGraphics (BufferedImage image)
125: {
126: Raster raster = image.getRaster();
127: if(raster instanceof CairoSurface)
128: return ((CairoSurface)raster).getGraphics();
129:
130: return new BufferedImageGraphics( image );
131: }
132:
133: private native int nativeGetNumFontFamilies();
134: private native void nativeGetFontFamilies(String[] family_names);
135:
136: public Font[] getAllFonts ()
137: {
138: throw new java.lang.UnsupportedOperationException ();
139: }
140:
141: public String[] getAvailableFontFamilyNames ()
142: {
143: String[] family_names;
144: int array_size;
145:
146: array_size = nativeGetNumFontFamilies();
147: family_names = new String[array_size];
148:
149: nativeGetFontFamilies(family_names);
150: return family_names;
151: }
152:
153: public String[] getAvailableFontFamilyNames (Locale l)
154: {
155: throw new java.lang.UnsupportedOperationException ();
156: }
157:
158:
161: native int[] getMouseCoordinates();
162: native boolean isWindowUnderMouse(GtkWindowPeer windowPeer);
163:
164: public WritableRaster createRaster(ColorModel cm, SampleModel sm)
165: {
166: if (CairoSurface.isCompatibleSampleModel(sm)
167: && CairoSurface.isCompatibleColorModel(cm))
168: return new CairoSurface(sm.getWidth(), sm.getHeight());
169: else
170: return null;
171: }
172: }