gnu.java.awt.peer.x

Class XGraphics

Implemented Interfaces:
Cloneable

public class XGraphics
extends Graphics
implements Cloneable

Method Summary

void
clearRect(int x, int y, int width, int height)
Clears the specified rectangle.
void
clipRect(int x, int y, int width, int height)
Clips the current clip with the specified clip.
protected Object
clone()
Creates and returns an exact copy of this XGraphics.
void
copyArea(int x, int y, int width, int height, int dx, int dy)
Copies the specified rectangle to the specified offset location.
Graphics
create()
Creates an exact copy of this graphics context.
void
dispose()
Frees any resources associated with this object.
void
drawArc(int x, int y, int width, int height, int arcStart, int arcAngle)
Draws an arc using the specified bounding rectangle and the specified angle parameter.
boolean
drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer)
FIXME: Write Javadocs for this when you understand it.
boolean
drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
FIXME: Write Javadocs for this when you understand it.
boolean
drawImage(Image image, int x, int y, int width, int height, Color bgcolor, ImageObserver observer)
Draws all of the image that is available and returns.
boolean
drawImage(Image image, int x, int y, int width, int height, ImageObserver observer)
Draws all of the image that is available and returns.
boolean
drawImage(Image image, int x, int y, Color bgcolor, ImageObserver observer)
Draws all of the image that is available and returns.
boolean
drawImage(Image image, int x, int y, ImageObserver observer)
Draws the specified image on the drawable at position (x,y).
void
drawLine(int x1, int y1, int x2, int y2)
Draws a line from point (x1, y1) to point (x2, y2).
void
drawOval(int x, int y, int width, int height)
Draws an oval that just fits within the specified rectangle.
void
drawPolygon(int[] xPoints, int[] yPoints, int npoints)
void
drawPolyline(int[] xPoints, int[] yPoints, int npoints)
void
drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
Draws the outline of the specified rectangle with rounded cornders.
void
drawString(String string, int x, int y)
Draws the specified string at (x, y).
void
drawString(AttributedCharacterIterator ci, int x, int y)
void
fillArc(int x, int y, int width, int height, int arcStart, int arcAngle)
Fills the arc define by the specified bounding rectangle and the specified angle parameter.
void
fillOval(int x, int y, int width, int height)
Fills an oval that just fits within the specified rectangle.
void
fillPolygon(int[] xPoints, int[] yPoints, int npoints)
void
fillRect(int x, int y, int width, int height)
Fills the specified rectangle.
void
fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
Fills the specified rectangle with rounded cornders.
Shape
getClip()
Returns the current clipping region as a Shape object.
Rectangle
getClipBounds()
Returns the bounds of the current clip.
Color
getColor()
Returns the current foreground color, possibly null.
Font
getFont()
Returns the current font, possibly null.
FontMetrics
getFontMetrics(Font font)
Returns the font metrics for the specified font.
boolean
hitClip(int x, int y, int w, int h)
Returns true when the specified rectangle intersects with the current clip, false otherwise.
void
setClip(int x, int y, int width, int height)
Sets the clipping region to the rectangle determined by the specified parameters.
void
setClip(Shape c)
Sets the current clip.
void
setColor(Color c)
Sets the current foreground color.
void
setFont(Font f)
Sets the font on the graphics context.
void
setPaintMode()
Sets this context into "paint" mode, where the target pixels are completely overwritten when drawn on.
void
setXORMode(Color color)
Sets this context info "XOR" mode, where the targe pixles are XOR-ed when drawn on.
void
translate(int x, int y)
Translates the origin by (x, y).

Methods inherited from class java.awt.Graphics

clearRect, clipRect, copyArea, create, create, dispose, draw3DRect, drawArc, drawBytes, drawChars, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawLine, drawOval, drawPolygon, drawPolygon, drawPolyline, drawRect, drawRoundRect, drawString, drawString, fill3DRect, fillArc, fillOval, fillPolygon, fillPolygon, fillRect, fillRoundRect, finalize, getClip, getClipBounds, getClipBounds, getClipRect, getColor, getFont, getFontMetrics, getFontMetrics, hitClip, setClip, setClip, setColor, setFont, setPaintMode, setXORMode, toString, translate

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Details

clearRect

public void clearRect(int x,
                      int y,
                      int width,
                      int height)
Clears the specified rectangle.
Overrides:
clearRect in interface Graphics
Parameters:
x - The X coordinate of the upper left corner of the clear rect.
y - The Y coordinate of the upper left corner of the clear rect.
width - The width of the clear rect.
height - The height of the clear rect.

clipRect

public void clipRect(int x,
                     int y,
                     int width,
                     int height)
Clips the current clip with the specified clip.
Overrides:
clipRect in interface Graphics

clone

protected Object clone()
Creates and returns an exact copy of this XGraphics.
Overrides:
clone in interface Object

copyArea

public void copyArea(int x,
                     int y,
                     int width,
                     int height,
                     int dx,
                     int dy)
Copies the specified rectangle to the specified offset location.
Overrides:
copyArea in interface Graphics
Parameters:
x - The X coordinate of the upper left corner of the copy rect.
y - The Y coordinate of the upper left corner of the copy rect.
width - The width of the copy rect.
height - The height of the copy rect.
dx - The offset from the X value to start drawing.
dy - The offset from the Y value to start drawing.

create

public Graphics create()
Creates an exact copy of this graphics context.
Overrides:
create in interface Graphics
Returns:
an exact copy of this graphics context

dispose

public void dispose()
Frees any resources associated with this object.
Overrides:
dispose in interface Graphics

drawArc

public void drawArc(int x,
                    int y,
                    int width,
                    int height,
                    int arcStart,
                    int arcAngle)
Draws an arc using the specified bounding rectangle and the specified angle parameter. The arc is centered at the center of the rectangle. The arc starts at the arcAngle position and extend for arcAngle degrees. The degree origin is at the 3 o'clock position.
Overrides:
drawArc in interface Graphics
Parameters:
x - The X coordinate of the upper left corner of the rect.
y - The Y coordinate of the upper left corner of the rect.
width - The width of the rect.
height - The height of the rect.
arcStart - The beginning angle of the arc.
arcAngle - The extent of the arc.

drawImage

public boolean drawImage(Image image,
                         int dx1,
                         int dy1,
                         int dx2,
                         int dy2,
                         int sx1,
                         int sy1,
                         int sx2,
                         int sy2,
                         Color bgcolor,
                         ImageObserver observer)
FIXME: Write Javadocs for this when you understand it.
Overrides:
drawImage in interface Graphics

drawImage

public boolean drawImage(Image image,
                         int dx1,
                         int dy1,
                         int dx2,
                         int dy2,
                         int sx1,
                         int sy1,
                         int sx2,
                         int sy2,
                         ImageObserver observer)
FIXME: Write Javadocs for this when you understand it.
Overrides:
drawImage in interface Graphics

drawImage

public boolean drawImage(Image image,
                         int x,
                         int y,
                         int width,
                         int height,
                         Color bgcolor,
                         ImageObserver observer)
Draws all of the image that is available and returns. The image is scaled to fit in the specified rectangle. If the image is not completely loaded, false is returned and the specified iamge observer is notified as more data becomes available.
Overrides:
drawImage in interface Graphics
Parameters:
image - The image to draw.
x - The X coordinate of the point to draw at.
y - The Y coordinate of the point to draw at.
width - The width of the rectangle to draw in.
height - The height of the rectangle to draw in.
bgcolor - The background color to use for the image.
observer - The image observer to notify as data becomes available.
Returns:
true if all the image data is available, false otherwise.

drawImage

public boolean drawImage(Image image,
                         int x,
                         int y,
                         int width,
                         int height,
                         ImageObserver observer)
Draws all of the image that is available and returns. The image is scaled to fit in the specified rectangle. If the image is not completely loaded, false is returned and the specified iamge observer is notified as more data becomes available.
Overrides:
drawImage in interface Graphics
Parameters:
image - The image to draw.
x - The X coordinate of the point to draw at.
y - The Y coordinate of the point to draw at.
width - The width of the rectangle to draw in.
height - The height of the rectangle to draw in.
observer - The image observer to notify as data becomes available.
Returns:
true if all the image data is available, false otherwise.

drawImage

public boolean drawImage(Image image,
                         int x,
                         int y,
                         Color bgcolor,
                         ImageObserver observer)
Draws all of the image that is available and returns. If the image is not completely loaded, false is returned and the specified iamge observer is notified as more data becomes available.
Overrides:
drawImage in interface Graphics
Parameters:
image - The image to draw.
x - The X coordinate of the point to draw at.
y - The Y coordinate of the point to draw at.
bgcolor - The background color to use for the image.
observer - The image observer to notify as data becomes available.
Returns:
true if all the image data is available, false otherwise.

drawImage

public boolean drawImage(Image image,
                         int x,
                         int y,
                         ImageObserver observer)
Draws the specified image on the drawable at position (x,y).
Overrides:
drawImage in interface Graphics

drawLine

public void drawLine(int x1,
                     int y1,
                     int x2,
                     int y2)
Draws a line from point (x1, y1) to point (x2, y2).
Overrides:
drawLine in interface Graphics

drawOval

public void drawOval(int x,
                     int y,
                     int width,
                     int height)
Draws an oval that just fits within the specified rectangle.
Overrides:
drawOval in interface Graphics
Parameters:
x - The X coordinate of the upper left corner of the rect.
y - The Y coordinate of the upper left corner of the rect.
width - The width of the rect.
height - The height of the rect.

drawPolygon

public void drawPolygon(int[] xPoints,
                        int[] yPoints,
                        int npoints)

drawPolyline

public void drawPolyline(int[] xPoints,
                         int[] yPoints,
                         int npoints)

drawRoundRect

public void drawRoundRect(int x,
                          int y,
                          int width,
                          int height,
                          int arcWidth,
                          int arcHeight)
Draws the outline of the specified rectangle with rounded cornders.
Overrides:
drawRoundRect in interface Graphics
Parameters:
x - The X coordinate of the upper left corner of the draw rect.
y - The Y coordinate of the upper left corner of the draw rect.
width - The width of the draw rect.
height - The height of the draw rect.
arcWidth - The width of the corner arcs.
arcHeight - The height of the corner arcs.

drawString

public void drawString(String string,
                       int x,
                       int y)
Draws the specified string at (x, y).
Overrides:
drawString in interface Graphics

drawString

public void drawString(AttributedCharacterIterator ci,
                       int x,
                       int y)
Overrides:
drawString in interface Graphics

fillArc

public void fillArc(int x,
                    int y,
                    int width,
                    int height,
                    int arcStart,
                    int arcAngle)
Fills the arc define by the specified bounding rectangle and the specified angle parameter. The arc is centered at the center of the rectangle. The arc starts at the arcAngle position and extend for arcAngle degrees. The degree origin is at the 3 o'clock position.
Overrides:
fillArc in interface Graphics
Parameters:
x - The X coordinate of the upper left corner of the rect.
y - The Y coordinate of the upper left corner of the rect.
width - The width of the rect.
height - The height of the rect.
arcStart - The beginning angle of the arc.
arcAngle - The extent of the arc.

fillOval

public void fillOval(int x,
                     int y,
                     int width,
                     int height)
Fills an oval that just fits within the specified rectangle.
Overrides:
fillOval in interface Graphics
Parameters:
x - The X coordinate of the upper left corner of the rect.
y - The Y coordinate of the upper left corner of the rect.
width - The width of the rect.
height - The height of the rect.

fillPolygon

public void fillPolygon(int[] xPoints,
                        int[] yPoints,
                        int npoints)

fillRect

public void fillRect(int x,
                     int y,
                     int width,
                     int height)
Fills the specified rectangle.
Overrides:
fillRect in interface Graphics

fillRoundRect

public void fillRoundRect(int x,
                          int y,
                          int width,
                          int height,
                          int arcWidth,
                          int arcHeight)
Fills the specified rectangle with rounded cornders.
Overrides:
fillRoundRect in interface Graphics
Parameters:
x - The X coordinate of the upper left corner of the fill rect.
y - The Y coordinate of the upper left corner of the fill rect.
width - The width of the fill rect.
height - The height of the fill rect.
arcWidth - The width of the corner arcs.
arcHeight - The height of the corner arcs.

getClip

public Shape getClip()
Returns the current clipping region as a Shape object.
Overrides:
getClip in interface Graphics
Returns:
The clipping region as a Shape.

getClipBounds

public Rectangle getClipBounds()
Returns the bounds of the current clip.
Overrides:
getClipBounds in interface Graphics
Returns:
the bounds of the current clip

getColor

public Color getColor()
Returns the current foreground color, possibly null.
Overrides:
getColor in interface Graphics
Returns:
the current foreground color, possibly null

getFont

public Font getFont()
Returns the current font, possibly null.
Overrides:
getFont in interface Graphics
Returns:
the current font, possibly null

getFontMetrics

public FontMetrics getFontMetrics(Font font)
Returns the font metrics for the specified font.
Overrides:
getFontMetrics in interface Graphics
Parameters:
font - the font for which we want the font metrics
Returns:
the font metrics for the specified font

hitClip

public boolean hitClip(int x,
                       int y,
                       int w,
                       int h)
Returns true when the specified rectangle intersects with the current clip, false otherwise. This is overridden to avoid unnecessary creation of Rectangles via getBounds().
Overrides:
hitClip in interface Graphics
Parameters:
x - the x coordinate of the rectangle
y - the y coordinate of the rectangle
w - the width of the rectangle
h - the height of the rectangle
Returns:
true when the specified rectangle intersects with the current clip, false otherwise

setClip

public void setClip(int x,
                    int y,
                    int width,
                    int height)
Sets the clipping region to the rectangle determined by the specified parameters.
Overrides:
setClip in interface Graphics
Parameters:
x - The X coordinate of the upper left corner of the rect.
y - The Y coordinate of the upper left corner of the rect.
width - The width of the rect.
height - The height of the rect.

setClip

public void setClip(Shape c)
Sets the current clip.
Overrides:
setClip in interface Graphics
Parameters:
c - the clip to set

setColor

public void setColor(Color c)
Sets the current foreground color. A null value doesn't change the current setting.
Overrides:
setColor in interface Graphics
Parameters:
c - the foreground color to set

setFont

public void setFont(Font f)
Sets the font on the graphics context. A null value doesn't change the current setting.
Overrides:
setFont in interface Graphics
Parameters:
f - the font to set

setPaintMode

public void setPaintMode()
Sets this context into "paint" mode, where the target pixels are completely overwritten when drawn on.
Overrides:
setPaintMode in interface Graphics

setXORMode

public void setXORMode(Color color)
Sets this context info "XOR" mode, where the targe pixles are XOR-ed when drawn on.
Overrides:
setXORMode in interface Graphics
Parameters:
color - The color to XOR against.

translate

public void translate(int x,
                      int y)
Translates the origin by (x, y).
Overrides:
translate in interface Graphics

XGraphics.java -- The Graphics implementation for X Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.