Source code: javax/microedition/lcdui/Graphics.java
1 /*
2 * MicroEmulator
3 * Copyright (C) 2001 Bartek Teodorczyk <barteo@it.pl>
4 *
5 * This library is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU Lesser General Public License as published by the
7 * Free Software Foundation; either version 2.1 of the License, or (at your
8 * option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13 * for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this library; if not, write to the Free Software Foundation,
17 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Contributor(s):
20 * 3GLab
21 */
22
23 package javax.microedition.lcdui;
24
25 public class Graphics
26 {
27 public static final int SOLID = 0;
28 public static final int DOTTED = 1;
29
30 public static final int LEFT = 4;
31 public static final int RIGHT = 8;
32 public static final int TOP = 16;
33 public static final int BASELINE = 64;
34 public static final int BOTTOM = 32;
35 public static final int HCENTER = 1;
36 public static final int VCENTER = 2;
37
38 int strokeStyle = SOLID;
39
40 int translateX = 0;
41 int translateY = 0;
42
43
44 public void clipRect(int x, int y, int width, int height)
45 {
46 // Implemented in DisplayGraphics
47 }
48
49
50 public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
51 {
52 // Implemented in DisplayGraphics
53 }
54
55
56 public void drawChar(char character, int x, int y, int anchor)
57 {
58 char[] carr = new char[1];
59 carr[0] = character;
60
61 drawString(new String(carr), x, y, anchor);
62 }
63
64
65 public void drawChars(char[] data, int offset, int length, int x, int y, int anchor)
66 {
67 drawString(new String(data, offset, length), x, y, anchor);
68 }
69
70
71 public void drawImage(Image img, int x, int y, int anchor)
72 {
73 // Implemented in DisplayGraphics
74 }
75
76
77 public void drawLine(int x1, int y1, int x2, int y2)
78 {
79 // Implemented in DisplayGraphics
80 }
81
82
83 public void drawRect(int x, int y, int width, int height)
84 {
85 // Implemented in DisplayGraphics
86 }
87
88
89 public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {
90 // Implemented in DisplayGraphics
91 }
92
93
94 public void drawString(String str, int x, int y, int anchor)
95 {
96 // Implemented in DisplayGraphics
97 }
98
99
100 public void drawSubstring(String str, int offset, int len, int x, int y, int anchor)
101 {
102 drawString(str.substring(offset, offset + len), x, y, anchor);
103 }
104
105
106 public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
107 {
108 // Implemented in DisplayGraphics
109 }
110
111
112 public void fillRect(int x, int y, int width, int height)
113 {
114 // Implemented in DisplayGraphics
115 }
116
117
118 public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
119 {
120 // Implemented in DisplayGraphics
121 }
122
123
124 public int getBlueComponent()
125 {
126 return getColor() & 255;
127 }
128
129
130 public int getClipHeight()
131 {
132 // Implemented in DisplayGraphics
133 throw new IllegalStateException();
134 }
135
136
137 public int getClipWidth()
138 {
139 // Implemented in DisplayGraphics
140 throw new IllegalStateException();
141 }
142
143
144 public int getClipX()
145 {
146 // Implemented in DisplayGraphics
147 throw new IllegalStateException();
148 }
149
150
151 public int getClipY()
152 {
153 // Implemented in DisplayGraphics
154 throw new IllegalStateException();
155 }
156
157
158 public int getColor()
159 {
160 // Implemented in DisplayGraphics
161 throw new IllegalStateException();
162 }
163
164
165 public Font getFont()
166 {
167 // Implemented in DisplayGraphics
168 throw new IllegalStateException();
169 }
170
171
172 public int getGrayScale()
173 {
174 return (getRedComponent() + getGreenComponent() + getBlueComponent()) / 3;
175 }
176
177
178 public int getGreenComponent()
179 {
180 return (getColor() >> 8) & 255;
181 }
182
183
184 public int getRedComponent()
185 {
186 return (getColor() >> 16) & 255;
187 }
188
189
190 public int getStrokeStyle()
191 {
192 return strokeStyle;
193 }
194
195
196 public int getTranslateX()
197 {
198 return translateX;
199 }
200
201
202 public int getTranslateY()
203 {
204 return translateY;
205 }
206
207
208 public void setClip(int x, int y, int width, int height)
209 {
210 // Implemented in DisplayGraphics
211 }
212
213
214 public void setColor(int RGB)
215 {
216 // Implemented in DisplayGraphics
217 }
218
219
220 public void setColor(int red, int green, int blue)
221 {
222 int rgb = blue; //0XRRGGBB
223 rgb += green << 8;
224 rgb += red << 16;
225 setColor(rgb);
226 }
227
228
229 public void setFont(Font font)
230 {
231 // Implemented in DisplayGraphics
232 }
233
234
235 public void setGrayScale(int grey)
236 {
237 setColor(grey, grey, grey);
238 }
239
240
241 public void setStrokeStyle(int style)
242 {
243 if (style != SOLID && style != DOTTED) {
244 throw new IllegalArgumentException();
245 }
246 strokeStyle = style;
247 }
248
249
250 public void translate(int x, int y)
251 {
252 translateX += x;
253 translateY += y;
254 }
255
256 }