public class SWTGraphics2D
extends java.awt.Graphics2D
| Constructor and Description |
|---|
SWTGraphics2D(GC gc)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addRenderingHints(java.util.Map hints)
Adds the hints in the specified map to the graphics context, replacing
any existing hints.
|
void |
clearRect(int x,
int y,
int width,
int height)
Fills the specified rectangle with the current background colour.
|
void |
clip(java.awt.Shape s)
Applies the specified clip.
|
void |
clipRect(int x,
int y,
int width,
int height)
Sets the clipping to the intersection of the current clip region and
the specified rectangle.
|
void |
copyArea(int x,
int y,
int width,
int height,
int dx,
int dy)
Not implemented - see
Graphics.copyArea(int, int, int, int, int,
int). |
java.awt.Graphics |
create()
Not implemented yet - see
Graphics.create(). |
void |
dispose()
Releases resources held by this instance (but note that the caller
must dispose of the 'GC' passed to the constructor).
|
void |
draw(java.awt.Shape shape)
Draws the outline of the specified shape using the current stroke and
paint settings.
|
void |
drawArc(int x,
int y,
int width,
int height,
int arcStart,
int arcAngle)
Draws an arc that is part of an ellipse that fits within the specified
framing rectangle.
|
void |
drawGlyphVector(java.awt.font.GlyphVector g,
float x,
float y)
Draws the specified glyph vector at the location
(x, y). |
void |
drawImage(java.awt.image.BufferedImage image,
java.awt.image.BufferedImageOp op,
int x,
int y)
Draws an image.
|
boolean |
drawImage(java.awt.Image image,
java.awt.geom.AffineTransform xform,
java.awt.image.ImageObserver obs)
Not implemented - see
Graphics2D.drawImage(Image,
AffineTransform, ImageObserver). |
boolean |
drawImage(java.awt.Image image,
int x,
int y,
java.awt.Color bgcolor,
java.awt.image.ImageObserver observer)
Draws an image.
|
boolean |
drawImage(java.awt.Image image,
int x,
int y,
java.awt.image.ImageObserver observer)
Draws an image with the top left corner aligned to the point (x, y).
|
boolean |
drawImage(java.awt.Image image,
int x,
int y,
int width,
int height,
java.awt.Color bgcolor,
java.awt.image.ImageObserver observer)
Draws an image.
|
boolean |
drawImage(java.awt.Image image,
int x,
int y,
int width,
int height,
java.awt.image.ImageObserver observer)
Draws an image with the top left corner aligned to the point (x, y),
and scaled to the specified width and height.
|
boolean |
drawImage(java.awt.Image image,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
java.awt.Color bgcolor,
java.awt.image.ImageObserver observer)
Not implemented - see
Graphics.drawImage(Image, int, int, int,
int, int, int, int, int, Color, ImageObserver). |
boolean |
drawImage(java.awt.Image image,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
java.awt.image.ImageObserver observer)
Not implemented - see
Graphics.drawImage(Image, int, int, int,
int, int, int, int, int, ImageObserver). |
void |
drawImage(org.eclipse.swt.graphics.Image image,
int x,
int y)
Draws an SWT image with the top left corner of the image aligned to the
point (x, y).
|
void |
drawLine(int x1,
int y1,
int x2,
int y2)
Draws a line from (x1, y1) to (x2, y2) using the current stroke
and paint settings.
|
void |
drawOval(int x,
int y,
int width,
int height)
Draws an oval that fits within the specified rectangular region.
|
void |
drawPolygon(int[] xPoints,
int[] yPoints,
int npoints)
Draws the outline of the polygon specified by the given points, using
the current paint and stroke settings.
|
void |
drawPolyline(int[] xPoints,
int[] yPoints,
int npoints)
Draws a sequence of connected lines specified by the given points, using
the current paint and stroke settings.
|
void |
drawRenderableImage(java.awt.image.renderable.RenderableImage image,
java.awt.geom.AffineTransform xform)
Not implemented - see
Graphics2D.drawRenderableImage(
RenderableImage, AffineTransform). |
void |
drawRenderedImage(java.awt.image.RenderedImage image,
java.awt.geom.AffineTransform xform)
Not implemented - see
Graphics2D.drawRenderedImage(RenderedImage,
AffineTransform). |
void |
drawRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
Draws a rectangle with rounded corners that fits within the specified
framing rectangle.
|
void |
drawString(java.text.AttributedCharacterIterator iterator,
float x,
float y)
Draws a string at the specified position.
|
void |
drawString(java.text.AttributedCharacterIterator iterator,
int x,
int y)
Draws a string at the specified position.
|
void |
drawString(java.lang.String text,
float x,
float y)
Draws a string at the specified position.
|
void |
drawString(java.lang.String text,
int x,
int y)
Draws a string on the receiver.
|
void |
fill(java.awt.Shape shape)
Fills the specified shape using the current paint.
|
void |
fillArc(int x,
int y,
int width,
int height,
int arcStart,
int arcAngle)
Fills an arc that is part of an ellipse that fits within the specified
framing rectangle.
|
void |
fillOval(int x,
int y,
int width,
int height)
Fills an oval that fits within the specified rectangular region.
|
void |
fillPolygon(int[] xPoints,
int[] yPoints,
int npoints)
Fills the specified polygon.
|
void |
fillRect(int x,
int y,
int width,
int height)
Fill a rectangle area on the swt graphic composite.
|
void |
fillRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
Draws a rectangle with rounded corners that fits within the specified
framing rectangle.
|
java.awt.Color |
getBackground()
Returns the background colour.
|
java.awt.Shape |
getClip()
Returns the current clip.
|
java.awt.Rectangle |
getClipBounds()
Returns the clip bounds.
|
java.awt.Color |
getColor()
Returns the current color for this graphics context.
|
java.awt.Composite |
getComposite()
Returns the current composite.
|
java.awt.GraphicsConfiguration |
getDeviceConfiguration()
Not implemented yet - see
Graphics2D.getDeviceConfiguration(). |
java.awt.Font |
getFont()
Returns the font in form of an awt font created
with the parameters of the font of the swt graphic
composite.
|
java.awt.FontMetrics |
getFontMetrics(java.awt.Font font)
Returns the font metrics.
|
java.awt.font.FontRenderContext |
getFontRenderContext()
Returns the font render context.
|
java.awt.Paint |
getPaint()
Returns the current paint for this graphics context.
|
java.lang.Object |
getRenderingHint(java.awt.RenderingHints.Key hintKey)
Returns the current value for the specified hint key, or
null if no value is set. |
java.awt.RenderingHints |
getRenderingHints()
Returns a copy of the hints collection for this graphics context.
|
java.awt.Stroke |
getStroke()
Returns the current stroke for this graphics context.
|
java.awt.geom.AffineTransform |
getTransform()
Returns the current transform.
|
boolean |
hit(java.awt.Rectangle rect,
java.awt.Shape s,
boolean onStroke)
Returns
true if the rectangle (in device space) intersects
with the shape (the interior, if onStroke is false,
otherwise the stroked outline of the shape). |
void |
rotate(double theta)
Applies a rotation transform.
|
void |
rotate(double theta,
double x,
double y)
Not implemented - see
Graphics2D.rotate(double, double, double). |
void |
scale(double scaleX,
double scaleY)
Applies a scale transform.
|
void |
setBackground(java.awt.Color color)
Sets the background colour.
|
void |
setClip(int x,
int y,
int width,
int height)
Sets the clip region to the specified rectangle.
|
void |
setClip(java.awt.Shape clip)
Sets the clip region.
|
void |
setColor(java.awt.Color color)
Sets the current color for this graphics context.
|
void |
setComposite(java.awt.Composite comp)
Sets the current composite.
|
void |
setFont(java.awt.Font font)
Set the font swt graphic composite from the specified
awt font.
|
void |
setPaint(java.awt.Paint paint)
Sets the paint for this graphics context.
|
void |
setPaintMode()
Not implemented - see
Graphics.setPaintMode(). |
void |
setRenderingHint(java.awt.RenderingHints.Key hintKey,
java.lang.Object hintValue)
Sets the value for a rendering hint.
|
void |
setRenderingHints(java.util.Map hints)
Replaces the existing hints with those contained in the specified
map.
|
void |
setStroke(java.awt.Stroke stroke)
Sets the stroke for this graphics context.
|
void |
setTransform(java.awt.geom.AffineTransform t)
Sets the current transform.
|
void |
setXORMode(java.awt.Color color)
Not implemented - see
Graphics.setXORMode(Color). |
void |
shear(double shearX,
double shearY)
Applies a shear transform.
|
void |
transform(java.awt.geom.AffineTransform t)
Concatenates the specified transform to the existing transform.
|
void |
translate(double tx,
double ty)
Applies a translation.
|
void |
translate(int x,
int y)
Applies a translation.
|
public SWTGraphics2D(GC gc)
gc - the graphics context.public java.awt.Graphics create()
Graphics.create().create in class java.awt.Graphicsnull.public java.awt.GraphicsConfiguration getDeviceConfiguration()
Graphics2D.getDeviceConfiguration().getDeviceConfiguration in class java.awt.Graphics2Dnull.public java.lang.Object getRenderingHint(java.awt.RenderingHints.Key hintKey)
null if no value is set.getRenderingHint in class java.awt.Graphics2DhintKey - the hint key (null permitted).null.setRenderingHint(RenderingHints.Key, Object)public void setRenderingHint(java.awt.RenderingHints.Key hintKey,
java.lang.Object hintValue)
setRenderingHint in class java.awt.Graphics2DhintKey - the key (null not permitted).hintValue - the value (must be compatible with the specified key).java.lang.IllegalArgumentException - if hintValue is not
compatible with the hintKey.getRenderingHint(RenderingHints.Key)public java.awt.RenderingHints getRenderingHints()
getRenderingHints in class java.awt.Graphics2Dpublic void addRenderingHints(java.util.Map hints)
addRenderingHints in class java.awt.Graphics2Dhints - the hints (null not permitted).setRenderingHints(Map)public void setRenderingHints(java.util.Map hints)
setRenderingHints in class java.awt.Graphics2Dhints - the hints (null not permitted).addRenderingHints(Map)public java.awt.Paint getPaint()
getPaint in class java.awt.Graphics2DsetPaint(Paint)public void setPaint(java.awt.Paint paint)
Color or
GradientPaint (in the latter case there is no real gradient
support, the paint used is the Color returned by
getColor1()).setPaint in class java.awt.Graphics2Dpaint - the paint (null permitted, ignored).getPaint(),
setColor(Color)public java.awt.Color getColor()
getColor in class java.awt.GraphicssetColor(Color)public void setColor(java.awt.Color color)
setColor in class java.awt.Graphicscolor - the color (null permitted but ignored).getColor()public void setBackground(java.awt.Color color)
setBackground in class java.awt.Graphics2Dcolor - the colour.public java.awt.Color getBackground()
getBackground in class java.awt.Graphics2Dnull)..public void setPaintMode()
Graphics.setPaintMode().setPaintMode in class java.awt.Graphicspublic void setXORMode(java.awt.Color color)
Graphics.setXORMode(Color).setXORMode in class java.awt.Graphicscolor - the colour.public java.awt.Composite getComposite()
getComposite in class java.awt.Graphics2DsetComposite(Composite)public void setComposite(java.awt.Composite comp)
AlphaComposite class.setComposite in class java.awt.Graphics2Dcomp - the composite (null not permitted).public java.awt.Stroke getStroke()
getStroke in class java.awt.Graphics2DsetStroke(Stroke)public void setStroke(java.awt.Stroke stroke)
BasicStroke class.setStroke in class java.awt.Graphics2Dstroke - the stroke (null not permitted).getStroke()public void clip(java.awt.Shape s)
clip in class java.awt.Graphics2Ds - the shape for the clip.public java.awt.Rectangle getClipBounds()
getClipBounds in class java.awt.Graphicspublic void clipRect(int x,
int y,
int width,
int height)
clipRect in class java.awt.Graphicsx - the x-coordinate.y - the y-coordinate.width - the width.height - the height.public java.awt.Shape getClip()
getClip in class java.awt.Graphicspublic void setClip(java.awt.Shape clip)
setClip in class java.awt.Graphicsclip - the clip.public void setClip(int x,
int y,
int width,
int height)
setClip in class java.awt.Graphicsx - the x-coordinate.y - the y-coordinate.width - the width.height - the height.public java.awt.geom.AffineTransform getTransform()
getTransform in class java.awt.Graphics2Dpublic void setTransform(java.awt.geom.AffineTransform t)
setTransform in class java.awt.Graphics2Dt - the transform.public void transform(java.awt.geom.AffineTransform t)
transform in class java.awt.Graphics2Dt - the transform.public void translate(int x,
int y)
translate in class java.awt.Graphics2Dx - the translation along the x-axis.y - the translation along the y-axis.public void translate(double tx,
double ty)
translate in class java.awt.Graphics2Dtx - the translation along the x-axis.ty - the translation along the y-axis.public void rotate(double theta)
rotate in class java.awt.Graphics2Dtheta - the angle of rotation.public void rotate(double theta,
double x,
double y)
Graphics2D.rotate(double, double, double).rotate in class java.awt.Graphics2DGraphics2D.rotate(double, double, double)public void scale(double scaleX,
double scaleY)
scale in class java.awt.Graphics2DscaleX - the scale factor along the x-axis.scaleY - the scale factor along the y-axis.public void shear(double shearX,
double shearY)
shear in class java.awt.Graphics2DshearX - the x-factor.shearY - the y-factor.public void draw(java.awt.Shape shape)
draw in class java.awt.Graphics2Dshape - the shape (null not permitted).getPaint(),
getStroke(),
fill(Shape)public void drawLine(int x1,
int y1,
int x2,
int y2)
drawLine in class java.awt.Graphicsx1 - the x-coordinate for the starting point.y1 - the y-coordinate for the starting point.x2 - the x-coordinate for the ending point.y2 - the y-coordinate for the ending point.draw(Shape)public void drawPolygon(int[] xPoints,
int[] yPoints,
int npoints)
drawPolygon in class java.awt.GraphicsxPoints - the x-coordinates.yPoints - the y-coordinates.npoints - the number of points in the polygon.draw(Shape)public void drawPolyline(int[] xPoints,
int[] yPoints,
int npoints)
drawPolyline in class java.awt.GraphicsxPoints - the x-coordinates.yPoints - the y-coordinates.npoints - the number of points in the polygon.draw(Shape)public void drawOval(int x,
int y,
int width,
int height)
drawOval in class java.awt.Graphicsx - the x-coordinate.y - the y-coordinate.width - the frame width.height - the frame height.fillOval(int, int, int, int),
draw(Shape)public void drawArc(int x,
int y,
int width,
int height,
int arcStart,
int arcAngle)
drawArc in class java.awt.Graphicsx - the x-coordinate.y - the y-coordinate.width - the frame width.height - the frame height.arcStart - the arc starting point, in degrees.arcAngle - the extent of the arc.fillArc(int, int, int, int, int, int)public void drawRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
drawRoundRect in class java.awt.Graphicsx - the x-coordinate.y - the y-coordinate.width - the frame width.height - the frame height.arcWidth - the width of the arc defining the roundedness of the
rectangle's corners.arcHeight - the height of the arc defining the roundedness of the
rectangle's corners.fillRoundRect(int, int, int, int, int, int)public void fill(java.awt.Shape shape)
fill in class java.awt.Graphics2Dshape - the shape (null not permitted).getPaint(),
draw(Shape)public void fillRect(int x,
int y,
int width,
int height)
fillRectangle method of the GC
class uses the background color so we must switch colors.fillRect in class java.awt.GraphicsGraphics.fillRect(int, int, int, int)public void clearRect(int x,
int y,
int width,
int height)
clearRect in class java.awt.Graphicsx - the x-coordinate for the rectangle.y - the y-coordinate for the rectangle.width - the width.height - the height.fillRect(int, int, int, int)public void fillPolygon(int[] xPoints,
int[] yPoints,
int npoints)
fillPolygon in class java.awt.GraphicsxPoints - the x-coordinates.yPoints - the y-coordinates.npoints - the number of points.public void fillRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
fillRoundRect in class java.awt.Graphicsx - the x-coordinate.y - the y-coordinate.width - the frame width.height - the frame height.arcWidth - the width of the arc defining the roundedness of the
rectangle's corners.arcHeight - the height of the arc defining the roundedness of the
rectangle's corners.drawRoundRect(int, int, int, int, int, int)public void fillOval(int x,
int y,
int width,
int height)
fillOval in class java.awt.Graphicsx - the x-coordinate.y - the y-coordinate.width - the frame width.height - the frame height.drawOval(int, int, int, int),
fill(Shape)public void fillArc(int x,
int y,
int width,
int height,
int arcStart,
int arcAngle)
fillArc in class java.awt.Graphicsx - the x-coordinate.y - the y-coordinate.width - the frame width.height - the frame height.arcStart - the arc starting point, in degrees.arcAngle - the extent of the arc.drawArc(int, int, int, int, int, int)public java.awt.Font getFont()
getFont in class java.awt.GraphicsGraphics.getFont()public void setFont(java.awt.Font font)
setFont in class java.awt.GraphicsGraphics.setFont(java.awt.Font)public java.awt.FontMetrics getFontMetrics(java.awt.Font font)
getFontMetrics in class java.awt.Graphicsfont - the font.public java.awt.font.FontRenderContext getFontRenderContext()
getFontRenderContext in class java.awt.Graphics2Dpublic void drawGlyphVector(java.awt.font.GlyphVector g,
float x,
float y)
(x, y).drawGlyphVector in class java.awt.Graphics2Dg - the glyph vector (null not permitted).x - the x-coordinate.y - the y-coordinate.public void drawString(java.lang.String text,
int x,
int y)
drawString in class java.awt.Graphics2DGraphics.drawString(java.lang.String, int, int)public void drawString(java.lang.String text,
float x,
float y)
drawString in class java.awt.Graphics2Dtext - the string.x - the x-coordinate.y - the y-coordinate.public void drawString(java.text.AttributedCharacterIterator iterator,
int x,
int y)
drawString in class java.awt.Graphics2Diterator - the string.x - the x-coordinate.y - the y-coordinate.public void drawString(java.text.AttributedCharacterIterator iterator,
float x,
float y)
drawString in class java.awt.Graphics2Diterator - the string.x - the x-coordinate.y - the y-coordinate.public boolean hit(java.awt.Rectangle rect,
java.awt.Shape s,
boolean onStroke)
true if the rectangle (in device space) intersects
with the shape (the interior, if onStroke is false,
otherwise the stroked outline of the shape).hit in class java.awt.Graphics2Drect - a rectangle (in device space).s - the shape.onStroke - test the stroked outline only?public void copyArea(int x,
int y,
int width,
int height,
int dx,
int dy)
Graphics.copyArea(int, int, int, int, int,
int).copyArea in class java.awt.Graphicspublic boolean drawImage(java.awt.Image image,
java.awt.geom.AffineTransform xform,
java.awt.image.ImageObserver obs)
Graphics2D.drawImage(Image,
AffineTransform, ImageObserver).drawImage in class java.awt.Graphics2Dimage - the image.xform - the transform.obs - an image observer.public void drawImage(java.awt.image.BufferedImage image,
java.awt.image.BufferedImageOp op,
int x,
int y)
drawImage in class java.awt.Graphics2Dimage - the image.op - the image operation.x - the x-coordinate.y - the y-coordinate.public void drawImage(org.eclipse.swt.graphics.Image image,
int x,
int y)
image - the image.x - the x-coordinate.y - the y-coordinate.public void drawRenderedImage(java.awt.image.RenderedImage image,
java.awt.geom.AffineTransform xform)
Graphics2D.drawRenderedImage(RenderedImage,
AffineTransform).drawRenderedImage in class java.awt.Graphics2Dimage - the image.xform - the transform.public void drawRenderableImage(java.awt.image.renderable.RenderableImage image,
java.awt.geom.AffineTransform xform)
Graphics2D.drawRenderableImage(
RenderableImage, AffineTransform).drawRenderableImage in class java.awt.Graphics2Dimage - the image.xform - the transform.public boolean drawImage(java.awt.Image image,
int x,
int y,
java.awt.image.ImageObserver observer)
drawImage in class java.awt.Graphicsimage - the image.x - the x-coordinate.y - the y-coordinate.observer - ignored here.true if the image has been drawn.public boolean drawImage(java.awt.Image image,
int x,
int y,
int width,
int height,
java.awt.image.ImageObserver observer)
drawImage in class java.awt.Graphicsimage - the image.x - the x-coordinate.y - the y-coordinate.width - the width for the rendered image.height - the height for the rendered image.observer - ignored here.true if the image has been drawn.public boolean drawImage(java.awt.Image image,
int x,
int y,
java.awt.Color bgcolor,
java.awt.image.ImageObserver observer)
drawImage in class java.awt.Graphicsimage - (null not permitted).x - the x-coordinate.y - the y-coordinate.bgcolor - the background color.observer - an image observer.public boolean drawImage(java.awt.Image image,
int x,
int y,
int width,
int height,
java.awt.Color bgcolor,
java.awt.image.ImageObserver observer)
drawImage in class java.awt.Graphicsimage - the image (null not permitted).x - the x-coordinate.y - the y-coordinate.width - the width.height - the height.bgcolor - the background colour.observer - an image observer.public boolean drawImage(java.awt.Image image,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
java.awt.image.ImageObserver observer)
Graphics.drawImage(Image, int, int, int,
int, int, int, int, int, ImageObserver).drawImage in class java.awt.Graphicsimage - the image.dx1 - dy1 - dx2 - dy2 - sx1 - sy1 - sx2 - sy2 - observer - public boolean drawImage(java.awt.Image image,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
java.awt.Color bgcolor,
java.awt.image.ImageObserver observer)
Graphics.drawImage(Image, int, int, int,
int, int, int, int, int, Color, ImageObserver).drawImage in class java.awt.Graphicsimage - the image.dx1 - dy1 - dx2 - dy2 - sx1 - sy1 - sx2 - sy2 - bgcolor - observer - public void dispose()
dispose in class java.awt.GraphicsGraphics.dispose()