1:
8:
9: package ;
10:
11: import ;
12: import ;
13:
14:
24: public class GC implements Cloneable
25: {
26:
28: protected GC(Drawable target)
29: {
30: this.target = target;
31: initStructure(null);
32: }
33:
34:
37: public Object clone()
38: {
39: try
40: {
41: GC gcClone = target.getGCFromCache ();
42: if (gcClone==null)
43: {
44: gcClone = (GC) super.clone();
45: gcClone.structure = null;
46: }
47: gcClone.initStructure(this);
48: gcClone.updateClip(clipRectangles);
49: return gcClone;
50: }
51: catch (CloneNotSupportedException ex)
52: {
53:
54: throw new InternalError ();
55: }
56: }
57:
58: private native void initStructure(GC copyFrom);
59:
60: public GC create()
61: {
62: return (GC) clone();
63: }
64:
65:
69: static public GC create (Drawable target)
70: {
71: GC returnValue = target.getGCFromCache ();
72: if (returnValue == null)
73: returnValue = new GC (target);
74: return returnValue;
75: }
76:
77: public void finalize()
78: {
79: disposeImpl();
80: }
81:
82:
86: public void dispose()
87: {
88: target.putGCInCache (this);
89: }
90:
91: public synchronized native void disposeImpl();
92:
93: public native void setForeground(long pixel);
94: public native void setFont(gnu.gcj.xlib.Font font);
95:
96:
108: public void setClipRectangles(Rectangle[] rectangles)
109: {
110: clipRectangles = rectangles;
111: updateClip(clipRectangles);
112: }
113:
114: public native void drawString(String text, int x, int y);
115: public native void drawLine(int x1, int y1, int x2, int y2);
116: public native void drawRectangle(int x, int y, int w, int h);
117:
118: public native void fillRectangle(int x, int y, int w, int h);
119: public native void fillPolygon(int[] xPoints, int[] yPoints, int nPoints,
120: int translateX, int translateY);
121:
122: public native void drawArc(int x, int y, int w, int h,
123: int startAngle, int arcAngle);
124: public native void fillArc(int x, int y, int w, int h,
125: int startAngle, int arcAngle);
126:
127:
132: public native void clearArea(int x, int y, int w, int h,
133: boolean exposures);
134:
135:
139: public native void drawPoint (int x, int y);
140:
141: public native void putImage(XImage image,
142: int srcX, int srcY,
143: int destX, int destY,
144: int width, int height);
145:
146: public native void copyArea (Drawable source,
147: int srcX, int srcY,
148: int destX, int destY,
149: int width, int height);
150:
151: public Drawable getDrawable()
152: {
153: return target;
154: }
155:
156: private native void updateClip(Rectangle[] rectangles);
157:
158: private Drawable target;
159: private RawData structure;
160: private Rectangle[] clipRectangles;
161: }