KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > microedition > lcdui > Graphics


1
2 /*
3  * MicroEmulator
4  * Copyright (C) 2001 Bartek Teodorczyk <barteo@it.pl>
5  *
6  * This library is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published by the
8  * Free Software Foundation; either version 2.1 of the License, or (at your
9  * option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14  * for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library; if not, write to the Free Software Foundation,
18  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  * Contributor(s):
21  * 3GLab
22  */

23
24 package javax.microedition.lcdui;
25
26 public class Graphics
27 {
28     public static final int SOLID = 0;
29     public static final int DOTTED = 1;
30
31     public static final int LEFT = 4;
32     public static final int RIGHT = 8;
33     public static final int TOP = 16;
34     public static final int BASELINE = 64;
35     public static final int BOTTOM = 32;
36     public static final int HCENTER = 1;
37     public static final int VCENTER = 2;
38
39     int strokeStyle = SOLID;
40
41     int translateX = 0;
42     int translateY = 0;
43
44     
45     public void clipRect(int x, int y, int width, int height)
46     {
47         // Implemented in DisplayGraphics
48
}
49
50     
51     public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
52     {
53         // Implemented in DisplayGraphics
54
}
55
56     
57     public void drawChar(char character, int x, int y, int anchor)
58     {
59         char[] carr = new char[1];
60         carr[0] = character;
61
62         drawString(new String(carr), x, y, anchor);
63     }
64
65     
66     public void drawChars(char[] data, int offset, int length, int x, int y, int anchor)
67     {
68         drawString(new String(data, offset, length), x, y, anchor);
69     }
70
71     
72     public void drawImage(Image img, int x, int y, int anchor)
73     {
74         // Implemented in DisplayGraphics
75
}
76
77     
78     public void drawLine(int x1, int y1, int x2, int y2)
79     {
80         // Implemented in DisplayGraphics
81
}
82
83     
84     public void drawRect(int x, int y, int width, int height)
85     {
86         // Implemented in DisplayGraphics
87
}
88
89     
90     public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {
91         // Implemented in DisplayGraphics
92
}
93
94     
95     public void drawString(String str, int x, int y, int anchor)
96     {
97         // Implemented in DisplayGraphics
98
}
99
100     
101     public void drawSubstring(String str, int offset, int len, int x, int y, int anchor)
102     {
103         drawString(str.substring(offset, offset + len), x, y, anchor);
104     }
105
106     
107     public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
108     {
109         // Implemented in DisplayGraphics
110
}
111
112     
113     public void fillRect(int x, int y, int width, int height)
114     {
115         // Implemented in DisplayGraphics
116
}
117
118     
119     public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
120     {
121         // Implemented in DisplayGraphics
122
}
123
124     
125     public int getBlueComponent()
126     {
127         return getColor() & 255;
128     }
129
130     
131     public int getClipHeight()
132     {
133         // Implemented in DisplayGraphics
134
throw new IllegalStateException();
135     }
136
137     
138     public int getClipWidth()
139     {
140         // Implemented in DisplayGraphics
141
throw new IllegalStateException();
142     }
143
144     
145     public int getClipX()
146     {
147         // Implemented in DisplayGraphics
148
throw new IllegalStateException();
149     }
150
151     
152     public int getClipY()
153     {
154         // Implemented in DisplayGraphics
155
throw new IllegalStateException();
156     }
157
158     
159     public int getColor()
160     {
161         // Implemented in DisplayGraphics
162
throw new IllegalStateException();
163     }
164
165     
166     public Font getFont()
167     {
168         // Implemented in DisplayGraphics
169
throw new IllegalStateException();
170     }
171
172     
173     public int getGrayScale()
174     {
175         return (getRedComponent() + getGreenComponent() + getBlueComponent()) / 3;
176     }
177
178     
179     public int getGreenComponent()
180     {
181         return (getColor() >> 8) & 255;
182     }
183
184     
185     public int getRedComponent()
186     {
187         return (getColor() >> 16) & 255;
188     }
189
190     
191     public int getStrokeStyle()
192     {
193         return strokeStyle;
194     }
195
196     
197     public int getTranslateX()
198     {
199         return translateX;
200     }
201
202     
203     public int getTranslateY()
204     {
205         return translateY;
206     }
207
208     
209     public void setClip(int x, int y, int width, int height)
210     {
211         // Implemented in DisplayGraphics
212
}
213
214     
215     public void setColor(int RGB)
216     {
217         // Implemented in DisplayGraphics
218
}
219
220     
221     public void setColor(int red, int green, int blue)
222     {
223         int rgb = blue; //0XRRGGBB
224
rgb += green << 8;
225         rgb += red << 16;
226         setColor(rgb);
227     }
228
229     
230     public void setFont(Font font)
231     {
232         // Implemented in DisplayGraphics
233
}
234
235     
236     public void setGrayScale(int grey)
237     {
238         setColor(grey, grey, grey);
239     }
240
241     
242     public void setStrokeStyle(int style)
243     {
244         if (style != SOLID && style != DOTTED) {
245             throw new IllegalArgumentException();
246         }
247         strokeStyle = style;
248     }
249
250     
251     public void translate(int x, int y)
252     {
253         translateX += x;
254         translateY += y;
255     }
256
257 }
258
Popular Tags