Imported GNU Classpath 0.20
Imported GNU Classpath 0.20
* Makefile.am (AM_CPPFLAGS): Add classpath/include.
* java/nio/charset/spi/CharsetProvider.java: New override file.
* java/security/Security.java: Likewise.
* sources.am: Regenerated.
* Makefile.in: Likewise.
From-SVN: r109831
This commit is contained in:
@@ -48,7 +48,6 @@ import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Shape;
|
||||
import java.awt.SystemColor;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.text.AttributedCharacterIterator;
|
||||
|
||||
@@ -81,18 +80,23 @@ public class GdkGraphics extends Graphics
|
||||
native void initStateUnlocked (GtkComponentPeer component);
|
||||
native void initState (int width, int height);
|
||||
native void initFromImage (GtkImage image);
|
||||
native void copyState (GdkGraphics g);
|
||||
native void nativeCopyState (GdkGraphics g);
|
||||
|
||||
/**
|
||||
* A cached instance that is used by {@link #create} in order to avoid
|
||||
* massive allocation of graphics contexts.
|
||||
*/
|
||||
GdkGraphics cached = null;
|
||||
|
||||
/**
|
||||
* A link to the parent context. This is used in {@link #dispose} to put
|
||||
* this graphics context into the cache.
|
||||
*/
|
||||
GdkGraphics parent = null;
|
||||
|
||||
GdkGraphics (GdkGraphics g)
|
||||
{
|
||||
color = g.color;
|
||||
xorColor = g.xorColor;
|
||||
font = g.font;
|
||||
if (font == null)
|
||||
font = new Font ("Dialog", Font.PLAIN, 12);
|
||||
clip = new Rectangle (g.clip);
|
||||
component = g.component;
|
||||
|
||||
parent = g;
|
||||
copyState (g);
|
||||
}
|
||||
|
||||
@@ -162,12 +166,54 @@ public class GdkGraphics extends Graphics
|
||||
public native void copyArea(int x, int y, int width, int height,
|
||||
int dx, int dy);
|
||||
|
||||
public Graphics create ()
|
||||
/**
|
||||
* Creates a copy of this GdkGraphics instance. This implementation can
|
||||
* reuse a cached instance to avoid massive instantiation of Graphics objects
|
||||
* during painting.
|
||||
*
|
||||
* @return a copy of this graphics context
|
||||
*/
|
||||
public Graphics create()
|
||||
{
|
||||
return new GdkGraphics (this);
|
||||
GdkGraphics copy = cached;
|
||||
if (copy == null)
|
||||
copy = new GdkGraphics(this);
|
||||
else
|
||||
{
|
||||
copy.copyState(this);
|
||||
cached = null;
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
public native void dispose();
|
||||
public native void nativeDispose();
|
||||
|
||||
/**
|
||||
* Disposes this graphics object. This puts this graphics context into the
|
||||
* cache of its parent graphics if there is one.
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
if (parent != null)
|
||||
{
|
||||
parent.cached = this;
|
||||
parent = null;
|
||||
}
|
||||
else
|
||||
nativeDispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called when this object gets finalized by the garbage collector.
|
||||
* In addition to {@link Graphics#finalize()} this calls nativeDispose() to
|
||||
* make sure the native resources are freed before the graphics context is
|
||||
* thrown away.
|
||||
*/
|
||||
public void finalize()
|
||||
{
|
||||
super.finalize();
|
||||
nativeDispose();
|
||||
}
|
||||
|
||||
public boolean drawImage (Image img, int x, int y,
|
||||
Color bgcolor, ImageObserver observer)
|
||||
@@ -248,9 +294,8 @@ public class GdkGraphics extends Graphics
|
||||
public void drawString (String str, int x, int y)
|
||||
{
|
||||
drawString(getFontPeer(), str, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void drawString (AttributedCharacterIterator ci, int x, int y)
|
||||
{
|
||||
throw new Error ("not implemented");
|
||||
@@ -419,4 +464,23 @@ public class GdkGraphics extends Graphics
|
||||
|
||||
translateNative (x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies over the state of another GdkGraphics to this instance. This is
|
||||
* used by the {@link #GdkGraphics(GdkGraphics)} constructor and the
|
||||
* {@link #create()} method.
|
||||
*
|
||||
* @param g the GdkGraphics object to copy the state from
|
||||
*/
|
||||
private void copyState(GdkGraphics g)
|
||||
{
|
||||
color = g.color;
|
||||
xorColor = g.xorColor;
|
||||
font = g.font;
|
||||
if (font == null)
|
||||
font = new Font ("Dialog", Font.PLAIN, 12);
|
||||
clip = new Rectangle (g.clip);
|
||||
component = g.component;
|
||||
nativeCopyState(g);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user