1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
/* Copyright (C) 2000 Free Software Foundation
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.awt;
import java.awt.image.ImageObserver;
/**
* @author Warren Levy <warrenl@cygnus.com>
* @date March 15, 2000.
*/
/**
* Written using on-line Java Platform 1.2 API Specification, as well
* as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
* Status: Almost complete
*/
public abstract class Graphics
{
protected Graphics() {}
public abstract Graphics create();
public Graphics create(int x, int y, int width, int height)
{
Graphics gfx = create();
gfx.translate(x, y);
gfx.setClip(0, y, width, height);
return gfx;
}
public abstract void translate(int x, int y);
public abstract Color getColor();
public abstract void setColor(Color color);
public abstract void setPaintMode();
public abstract void setXORMode(Color altColor);
public abstract Font getFont();
public abstract void setFont(Font font);
public FontMetrics getFontMetrics()
{
return getFontMetrics(getFont());
}
public abstract FontMetrics getFontMetrics(Font font);
public abstract Rectangle getClipBounds();
public abstract void clipRect(int x, int y, int width, int height);
public abstract void setClip(int x, int y, int width, int height);
public abstract Shape getClip();
public abstract void setClip(Shape clip);
public abstract void copyArea(int x, int y, int width, int height,
int dx, int dy);
public abstract void drawLine(int x1, int y1, int x2, int y2);
public abstract void fillRect(int x, int y, int width, int height);
public void drawRect(int x, int y, int width, int height)
{
int x1 = x;
int y1 = y;
int x2 = x + width;
int y2 = y + height;
drawLine(x1, y1, x2, y1);
drawLine(x2, y1, x2, y2);
drawLine(x2, y2, x1, y2);
drawLine(x1, y2, x1, y1);
}
public abstract void clearRect(int x, int y, int width, int height);
public abstract void drawRoundRect(int x, int y, int width, int height,
int arcWidth, int arcHeight);
public abstract void fillRoundRect(int x, int y, int width, int height,
int arcWidth, int arcHeight);
public void draw3DRect(int x, int y, int width, int height,
boolean raised)
{
Color color = getColor();
Color tl = color.brighter();
Color br = color.darker();
if (!raised)
{
Color tmp = tl;
tl = br;
br = tmp;
}
int x1 = x;
int y1 = y;
int x2 = x + width;
int y2 = y + height;
setColor(tl);
drawLine(x1, y1, x2, y1);
drawLine(x1, y2, x1, y1);
setColor(br);
drawLine(x2, y1, x2, y2);
drawLine(x2, y1, x1, y2);
setColor(color);
}
public void fill3DRect(int x, int y, int width, int height,
boolean raised)
{
fillRect(x, y, width, height);
draw3DRect(x, y, width-1, height-1, raised);
}
public abstract void drawOval(int x, int y, int width, int height);
public abstract void fillOval(int x, int y, int width, int height);
public abstract void drawArc(int x, int y, int width, int height,
int startAngle, int arcAngle);
public abstract void fillArc(int x, int y, int width, int height,
int startAngle, int arcAngle);
public abstract void drawPolyline(int[] xPoints, int[] yPoints,
int nPoints);
public abstract void drawPolygon(int[] xPoints, int[] yPoints,
int nPoints);
//public void drawPolygon(Polygon p);
public abstract void fillPolygon(int[] xPoints, int[] yPoints,
int nPoints);
//public void fillPolygon(Polygon p);
public abstract void drawString(String str, int x, int y);
/*
public abstract void drawString(AttributedCharacterIterator iterator,
int x, int y)
*/
public void drawChars(char[] data, int offset, int length,
int x, int y)
{
String str = new String(data, offset, length);
drawString(str, x, y);
}
public void drawBytes(byte[] data, int offset, int length,
int x, int y)
{
String str = new String(data, offset, length);
drawString(str, x, y);
}
public abstract boolean drawImage(Image img, int x, int y,
ImageObserver observer);
public abstract boolean drawImage(Image img, int x, int y,
int width, int height,
ImageObserver observer);
public abstract boolean drawImage(Image img, int x, int y, Color bgcolor,
ImageObserver observer);
public abstract boolean drawImage(Image img, int x, int y,
int width, int height, Color bgcolor,
ImageObserver observer);
public abstract boolean drawImage(Image img,
int dx1, int dy1, int dx2, int dy2,
int sx1, int sy1, int sx2, int sy2,
ImageObserver observer);
public abstract boolean drawImage(Image img,
int dx1, int dy1, int dx2, int dy2,
int sx1, int sy1, int sx2, int sy2,
Color bgcolor, ImageObserver observer);
public abstract void dispose();
public void finalize()
{
dispose();
}
public String toString()
{
return super.toString(); // FIXME
}
/** @deprecated */
public Rectangle getClipRect()
{
return getClipBounds(null);
}
public boolean hitClip(int x, int y, int width, int height)
{
throw new UnsupportedOperationException("not implemented yet");
}
public Rectangle getClipBounds(Rectangle r)
{
Rectangle clipBounds = getClipBounds();
if (r == null)
return clipBounds;
r.x = clipBounds.x;
r.y = clipBounds.y;
r.width = clipBounds.width;
r.height = clipBounds.height;
return r;
}
}
|