package gnu.gcj.xlib;
import gnu.gcj.RawData;
import java.awt.Rectangle;
public class GC implements Cloneable
{
protected GC(Drawable target)
{
this.target = target;
initStructure(null);
}
public Object clone()
{
try
{
GC gcClone = target.getGCFromCache ();
if (gcClone==null)
{
gcClone = (GC) super.clone();
gcClone.structure = null;
}
gcClone.initStructure(this);
gcClone.updateClip(clipRectangles);
return gcClone;
}
catch (CloneNotSupportedException ex)
{
throw new InternalError ();
}
}
private native void initStructure(GC copyFrom);
public GC create()
{
return (GC) clone();
}
static public GC create (Drawable target)
{
GC returnValue = target.getGCFromCache ();
if (returnValue == null)
returnValue = new GC (target);
return returnValue;
}
public void finalize()
{
disposeImpl();
}
public void dispose()
{
target.putGCInCache (this);
}
public synchronized native void disposeImpl();
public native void setForeground(long pixel);
public native void setFont(gnu.gcj.xlib.Font font);
public void setClipRectangles(Rectangle[] rectangles)
{
clipRectangles = rectangles;
updateClip(clipRectangles);
}
public native void drawString(String text, int x, int y);
public native void drawLine(int x1, int y1, int x2, int y2);
public native void drawRectangle(int x, int y, int w, int h);
public native void fillRectangle(int x, int y, int w, int h);
public native void fillPolygon(int[] xPoints, int[] yPoints, int nPoints,
int translateX, int translateY);
public native void drawArc(int x, int y, int w, int h,
int startAngle, int arcAngle);
public native void fillArc(int x, int y, int w, int h,
int startAngle, int arcAngle);
public native void clearArea(int x, int y, int w, int h,
boolean exposures);
public native void drawPoint (int x, int y);
public native void putImage(XImage image,
int srcX, int srcY,
int destX, int destY,
int width, int height);
public native void copyArea (Drawable source,
int srcX, int srcY,
int destX, int destY,
int width, int height);
public Drawable getDrawable()
{
return target;
}
private native void updateClip(Rectangle[] rectangles);
private Drawable target;
private RawData structure;
private Rectangle[] clipRectangles;
}