1:
37:
38: package ;
39:
40: import ;
41: import ;
42:
43: import ;
44: import ;
45: import ;
46: import ;
47: import ;
48: import ;
49: import ;
50: import ;
51: import ;
52: import ;
53: import ;
54: import ;
55: import ;
56: import ;
57: import ;
58: import ;
59: import ;
60:
61: public class XGraphicsConfiguration
62: extends GraphicsConfiguration
63: {
64:
65: XGraphicsDevice device;
66:
67: XGraphicsConfiguration(XGraphicsDevice dev)
68: {
69: device = dev;
70: }
71:
72: public GraphicsDevice getDevice()
73: {
74: return device;
75: }
76:
77: public BufferedImage createCompatibleImage(int w, int h)
78: {
79: return createCompatibleImage(w, h, Transparency.OPAQUE);
80: }
81:
82: public BufferedImage createCompatibleImage(int w, int h, int transparency)
83: {
84: BufferedImage bi;
85: switch (transparency)
86: {
87: case Transparency.OPAQUE:
88: DataBuffer buffer = new ZPixmapDataBuffer(w, h);
89: SampleModel sm = new ComponentSampleModel(DataBuffer.TYPE_BYTE, w, h,
90: 4, w * 4,
91: new int[]{0, 1, 2, 3 });
92: ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB);
93: ColorModel cm = new ComponentColorModel(cs, true, false,
94: Transparency.OPAQUE,
95: DataBuffer.TYPE_BYTE);
96: WritableRaster raster = Raster.createWritableRaster(sm, buffer,
97: new Point(0, 0));
98: bi = new BufferedImage(cm, raster, false, null);
99: break;
100: case Transparency.BITMASK:
101: case Transparency.TRANSLUCENT:
102: bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
103: break;
104: default:
105: throw new IllegalArgumentException("Illegal transparency: "
106: + transparency);
107: }
108: return bi;
109: }
110:
111: public VolatileImage createCompatibleVolatileImage(int w, int h)
112: {
113: return createCompatibleVolatileImage(w, h, Transparency.OPAQUE);
114: }
115:
116: public VolatileImage createCompatibleVolatileImage(int width, int height,
117: int transparency)
118: {
119: VolatileImage im;
120: switch (transparency)
121: {
122: case Transparency.OPAQUE:
123: im = new PixmapVolatileImage(width, height);
124: break;
125: case Transparency.BITMASK:
126: case Transparency.TRANSLUCENT:
127: throw new UnsupportedOperationException("Not yet implemented");
128: default:
129: throw new IllegalArgumentException("Unknown transparency type: "
130: + transparency);
131: }
132: return im;
133: }
134:
135: public ColorModel getColorModel()
136: {
137:
138: throw new UnsupportedOperationException("Not yet implemented.");
139: }
140:
141: public ColorModel getColorModel(int transparency)
142: {
143:
144: throw new UnsupportedOperationException("Not yet implemented.");
145: }
146:
147: public AffineTransform getDefaultTransform()
148: {
149: return new AffineTransform();
150: }
151:
152: public AffineTransform getNormalizingTransform()
153: {
154:
155: throw new UnsupportedOperationException("Not yet implemented.");
156: }
157:
158: public Rectangle getBounds()
159: {
160: Display d = device.getDisplay();
161: Screen screen = d.default_screen;
162:
163: return new Rectangle(0, 0, screen.width, screen.height);
164: }
165:
166:
171: Dimension getSize()
172: {
173:
174: Display d = device.getDisplay();
175: Screen screen = d.default_screen;
176: int w = screen.width;
177: int h = screen.height;
178: return new Dimension(w, h);
179: }
180:
181:
186: int getResolution()
187: {
188: Display d = device.getDisplay();
189: Screen screen = d.default_screen;
190: int w = screen.width * 254;
191: int h = screen.height * 254;
192: int wmm = screen.width_in_mm * 10;
193: int hmm = screen.height_in_mm * 10;
194: int xdpi = w / wmm;
195: int ydpi = h / hmm;
196: int dpi = (xdpi + ydpi) / 2;
197: return dpi;
198: }
199:
200: }