diff options
Diffstat (limited to 'libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphics.java')
-rw-r--r-- | libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphics.java | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphics.java b/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphics.java index d7217aa7a3f..3c3cbdf32d2 100644 --- a/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphics.java +++ b/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphics.java @@ -48,6 +48,7 @@ import java.awt.Graphics; import java.awt.Image; import java.awt.Rectangle; import java.awt.Shape; +import java.awt.Toolkit; import java.awt.image.ImageObserver; import java.text.AttributedCharacterIterator; @@ -218,8 +219,10 @@ public class GdkGraphics extends Graphics public boolean drawImage (Image img, int x, int y, Color bgcolor, ImageObserver observer) { - return drawImage(img, x, y, img.getWidth(null), img.getHeight(null), - bgcolor, observer); + if (img != null) + return drawImage(img, x, y, img.getWidth(null), img.getHeight(null), + bgcolor, observer); + return false; } public boolean drawImage (Image img, int x, int y, ImageObserver observer) @@ -227,16 +230,19 @@ public class GdkGraphics extends Graphics return drawImage (img, x, y, null, observer); } - public boolean drawImage (Image img, int x, int y, int width, int height, - Color bgcolor, ImageObserver observer) + public boolean drawImage(Image img, int x, int y, int width, int height, + Color bgcolor, ImageObserver observer) { - if (img instanceof GtkImage) - return ((GtkImage)img).drawImage (this, x, y, width, height, - bgcolor, observer); - else - return (new GtkImage(img.getSource())).drawImage (this, x, y, - width, height, - bgcolor, observer); + if (img != null) + { + if (img instanceof GtkImage) + return ((GtkImage) img).drawImage(this, x, y, width, height, bgcolor, + observer); + return (new GtkImage(img.getSource())).drawImage(this, x, y, width, + height, bgcolor, + observer); + } + return false; } public boolean drawImage (Image img, int x, int y, int width, int height, @@ -249,14 +255,16 @@ public class GdkGraphics extends Graphics int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) { - if (img instanceof GtkImage) - return ((GtkImage)img).drawImage(this, dx1, dy1, dx2, dy2, - sx1, sy1, sx2, sy2, bgcolor, observer); - else - return (new GtkImage(img.getSource())).drawImage(this, dx1, dy1, - dx2, dy2, - sx1, sy1, sx2, sy2, - bgcolor, observer); + if (img != null) + { + if (img instanceof GtkImage) + return ((GtkImage) img).drawImage(this, dx1, dy1, dx2, dy2, sx1, sy1, + sx2, sy2, bgcolor, observer); + return (new GtkImage(img.getSource())).drawImage(this, dx1, dy1, dx2, + dy2, sx1, sy1, sx2, + sy2, bgcolor, observer); + } + return false; } public boolean drawImage (Image img, int dx1, int dy1, int dx2, int dy2, @@ -373,7 +381,9 @@ public class GdkGraphics extends Graphics public FontMetrics getFontMetrics (Font font) { - return new GdkFontMetrics (font); + // Get the font metrics through GtkToolkit to take advantage of + // the metrics cache. + return Toolkit.getDefaultToolkit().getFontMetrics (font); } native void setClipRectangle (int x, int y, int width, int height); |