public class SWTGraphics2D extends Graphics2D
Modifier and Type | Field and Description |
---|---|
protected static BufferedImage |
BUFFER
Buffer used to extract the graphics device.
|
protected static int |
CACHE_COUNT
The number of Graphics Contexts active as determined by called to
incrementGCCount and decrementGCCount.
|
protected static HashMap |
COLOR_CACHE
Map from awt colors to swt colors.
|
protected org.eclipse.swt.graphics.Font |
curFont
The current font to use when drawing text.
|
protected org.eclipse.swt.graphics.Device |
device
Device onto which all graphics operations will ultimately take place.
|
protected static HashMap |
FONT_CACHE
Map from font names to Fonts.
|
protected org.eclipse.swt.graphics.GC |
gc
The Underlying GraphicsContext provided by swt.
|
protected double |
lineWidth
The current stroke width to use when drawing lines.
|
protected static HashMap |
SHAPE_CACHE
Map from awt shapess to swt Paths.
|
protected AffineTransform |
transform
The current transform to apply to drawing operations.
|
Constructor and Description |
---|
SWTGraphics2D(org.eclipse.swt.graphics.GC gc,
org.eclipse.swt.graphics.Device device)
Constructor for SWTGraphics2D.
|
Modifier and Type | Method and Description |
---|---|
void |
addRenderingHints(Map hints) |
void |
clearRect(int x,
int y,
int width,
int height) |
void |
clip(Shape s)
This method isn't really supported by SWT - so will use the shape bounds.
|
void |
clipRect(int x,
int y,
int width,
int height) |
void |
copyArea(org.eclipse.swt.graphics.Image img,
double x,
double y)
Copies the image to the specified position.
|
void |
copyArea(int x,
int y,
int width,
int height,
int dx,
int dy) |
Graphics |
create() |
static void |
decrementGCCount()
Decreases the number of uses of this graphics 2d object.
|
void |
dispose()
DO NOTHING - DISPOSED IN RENDERING CLASS.
|
void |
draw(Shape s) |
void |
drawArc(double x,
double y,
double width,
double height,
double startAngle,
double extent)
Draws the outline of a circular or elliptical arc covering the specified
rectangle.
|
void |
drawArc(int x,
int y,
int width,
int height,
int startAngle,
int extent) |
void |
drawGlyphVector(GlyphVector g,
float x,
float y) |
void |
drawImage(BufferedImage img,
BufferedImageOp op,
int x,
int y) |
boolean |
drawImage(Image img,
AffineTransform xform,
ImageObserver obs) |
void |
drawImage(org.eclipse.swt.graphics.Image image,
double x,
double y)
Draws the provided image at the position specified.
|
boolean |
drawImage(Image img,
int x,
int y,
Color bgcolor,
ImageObserver observer) |
boolean |
drawImage(Image img,
int x,
int y,
ImageObserver observer) |
boolean |
drawImage(Image img,
int x,
int y,
int width,
int height,
Color bgcolor,
ImageObserver observer) |
void |
drawImage(org.eclipse.swt.graphics.Image image,
int srcX,
int srcY,
int srcW,
int srcH,
double destX,
double destY,
double destW,
double destH)
Draws the source region from the image onto the destination region of the
graphics context.
|
boolean |
drawImage(Image img,
int x,
int y,
int width,
int height,
ImageObserver observer) |
boolean |
drawImage(Image img,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
Color bgcolor,
ImageObserver observer) |
boolean |
drawImage(Image img,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
ImageObserver observer) |
void |
drawLine(double x1,
double y1,
double x2,
double y2)
Draws a line, using the current color, between the points (x1, y1) and
(x2, y2) in this graphics context's coordinate system.
|
void |
drawLine(int x1,
int y1,
int x2,
int y2) |
void |
drawOval(double x,
double y,
double width,
double height)
Draws the outline of an oval.
|
void |
drawOval(int x,
int y,
int width,
int height) |
void |
drawPath(org.eclipse.swt.graphics.Path p)
Draws the provided path.
|
void |
drawPolygon(int[] xPoints,
int[] yPoints,
int nPoints) |
void |
drawPolyline(double[] pts)
Draw a polyline from the specified double array of points.
|
void |
drawPolyline(int[] xPoints,
int[] yPoints,
int nPoints) |
void |
drawRect(double x,
double y,
double width,
double height)
Draws the outline of the specified rectangle.
|
void |
drawRect(int x,
int y,
int width,
int height) |
void |
drawRenderableImage(RenderableImage img,
AffineTransform xform) |
void |
drawRenderedImage(RenderedImage img,
AffineTransform xform) |
void |
drawRoundRect(double x,
double y,
double width,
double height,
double arcWidth,
double arcHeight)
Draws an outlined round-cornered rectangle using this graphics context's
current color.
|
void |
drawRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight) |
void |
drawString(AttributedCharacterIterator iterator,
float x,
float y) |
void |
drawString(AttributedCharacterIterator iterator,
int x,
int y) |
void |
drawString(String str,
double x,
double y)
Renders the text of the specified String, using the current text
attribute state in the Graphics2D context.
|
void |
drawString(String str,
double x,
double y,
boolean isTransparent)
Renders the text of the specified String, using the current text
attribute state in the Graphics2D context.
|
void |
drawString(String str,
float x,
float y) |
void |
drawString(String str,
int x,
int y) |
void |
drawString(String str,
int x,
int y,
boolean isTransparent)
Renders the text of the specified String, using the current text
attribute state in the Graphics2D context.
|
void |
drawText(String str,
double x,
double y)
Renders the text of the specified String, using the current text
attribute state in the Graphics2D context.
|
void |
drawText(String str,
double x,
double y,
int flags)
Renders the text of the specified String, using the current text
attribute state in the Graphics2D context.
|
void |
drawText(String str,
int x,
int y,
int flags)
Renders the text of the specified String, using the current text
attribute state in the Graphics2D context.
|
void |
fill(Shape s) |
void |
fillArc(double x,
double y,
double width,
double height,
double startAngle,
double extent)
Draws a filledArc with the options provided.
|
void |
fillArc(int x,
int y,
int width,
int height,
int startAngle,
int extent) |
void |
fillGradientRectangle(double x,
double y,
double width,
double height,
boolean vertical)
Fills a gradient rectangle of in the direction specified.
|
void |
fillOval(double x,
double y,
double width,
double height)
Fills an oval bounded by the specified rectangle with the current color.
|
void |
fillOval(int x,
int y,
int width,
int height) |
void |
fillPath(org.eclipse.swt.graphics.Path p)
Draws a filled version of the provided path.
|
void |
fillPolygon(double[] pts)
Fill a polyline from the specified double array of points.
|
void |
fillPolygon(int[] xPoints,
int[] yPoints,
int nPoints) |
void |
fillRect(double x,
double y,
double width,
double height)
Fills the specified rectangle.
|
void |
fillRect(int x,
int y,
int width,
int height) |
void |
fillRoundRect(double x,
double y,
double width,
double height,
double arcWidth,
double arcHeight)
Fills the specified rounded corner rectangle with the current color.
|
void |
fillRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight) |
int |
getAdvanceWidth(char ch)
Returns the advance width of the character provided in the current font.
|
Color |
getBackground() |
int |
getCharWidth(char ch)
Returns the width of the character provided in the current font.
|
Shape |
getClip() |
Rectangle |
getClipBounds() |
Color |
getColor() |
Composite |
getComposite() |
GraphicsConfiguration |
getDeviceConfiguration()
Returns a dummy device configuration.
|
Font |
getFont() |
org.eclipse.swt.graphics.Font |
getFont(String fontString)
Returns the SWT font matching the given font string.
|
FontMetrics |
getFontMetrics(Font f) |
FontRenderContext |
getFontRenderContext() |
Paint |
getPaint() |
Object |
getRenderingHint(RenderingHints.Key hintKey) |
RenderingHints |
getRenderingHints() |
Stroke |
getStroke() |
org.eclipse.swt.graphics.Font |
getSWTFont()
Returns the current swt font to use when drawing.
|
org.eclipse.swt.graphics.FontMetrics |
getSWTFontMetrics()
Returns the font metrics of the current SWT font.
|
AffineTransform |
getTransform() |
protected org.eclipse.swt.graphics.Font |
getTransformedFont()
Deprecated.
|
protected int |
getTransformedLineWidth()
Computes the width of the line after it passes through the current
transform.
|
boolean |
hit(Rectangle rect,
Shape s,
boolean onStroke)
Returns whether the given rect and shape touch.
|
static void |
incrementGCCount()
Increases the number of uses of this graphics 2d object.
|
void |
rotate(double theta) |
void |
rotate(double theta,
double x,
double y) |
void |
scale(double sx,
double sy) |
void |
setBackground(Color c) |
void |
setBackground(org.eclipse.swt.graphics.Color backgroundColor)
Sets the background color to the provided swt color.
|
void |
setClip(int x,
int y,
int width,
int height) |
void |
setClip(Shape clip)
This method isn't really supported by SWT - so will use the shape bounds.
|
void |
setColor(Color c) |
void |
setColor(org.eclipse.swt.graphics.Color foregroundColor)
Sets the foreground color to the provided swt color.
|
void |
setComposite(Composite comp) |
void |
setFont(Font font) |
void |
setFont(org.eclipse.swt.graphics.Font font)
Set the font for this SWTGraphics2D to
font . |
void |
setLineWidth(double lineWidth)
Sets the line width to use when drawing shapes.
|
void |
setPaint(Paint paint) |
void |
setPaintMode() |
void |
setRenderingHint(RenderingHints.Key hintKey,
Object hintValue) |
void |
setRenderingHints(Map hints) |
void |
setStroke(Stroke s) |
void |
setTransform(AffineTransform newTransform) |
void |
setXORMode(boolean xOr)
Deprecated.
since underlying method has been deprecated
|
void |
setXORMode(Color c1) |
void |
shear(double shx,
double shy) |
org.eclipse.swt.graphics.Point |
stringExtent(String str)
Returns the extent of the provided string in the current font.
|
org.eclipse.swt.graphics.Point |
textExtent(String str)
Returns the extent of the provided text in the current font.
|
org.eclipse.swt.graphics.Point |
textExtent(String str,
int flags)
Returns the extent of the provided text in the current font assuming the
flags given.
|
void |
transform(AffineTransform srcTransform) |
void |
translate(double tx,
double ty) |
void |
translate(int x,
int y) |
draw3DRect, fill3DRect
create, drawBytes, drawChars, drawPolygon, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClip, toString
protected static int CACHE_COUNT
protected static HashMap FONT_CACHE
protected static HashMap COLOR_CACHE
protected static HashMap SHAPE_CACHE
protected static BufferedImage BUFFER
protected org.eclipse.swt.graphics.GC gc
protected org.eclipse.swt.graphics.Device device
protected AffineTransform transform
protected org.eclipse.swt.graphics.Font curFont
protected double lineWidth
public SWTGraphics2D(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Device device)
gc
- The Eclipse Graphics Context onto which all Graphics2D
operations are delegatingdevice
- Device onto which ultimately all gc operations are drawn
ontopublic Rectangle getClipBounds()
getClipBounds
in class Graphics
public void clipRect(int x, int y, int width, int height)
public void setClip(int x, int y, int width, int height)
public void clip(Shape s)
clip
in class Graphics2D
s
- shape of the clipping region to apply to graphics operationspublic void setClip(Shape clip)
public GraphicsConfiguration getDeviceConfiguration()
getDeviceConfiguration
in class Graphics2D
public Paint getPaint()
getPaint
in class Graphics2D
public void setPaint(Paint paint)
setPaint
in class Graphics2D
public void setColor(org.eclipse.swt.graphics.Color foregroundColor)
foregroundColor
- new foreground colorpublic void setBackground(Color c)
setBackground
in class Graphics2D
public void setBackground(org.eclipse.swt.graphics.Color backgroundColor)
backgroundColor
- new background colorpublic Color getBackground()
getBackground
in class Graphics2D
public org.eclipse.swt.graphics.Font getSWTFont()
public org.eclipse.swt.graphics.FontMetrics getSWTFontMetrics()
public void setFont(org.eclipse.swt.graphics.Font font)
font
.font
- font for this SWTGraphics2Dpublic org.eclipse.swt.graphics.Font getFont(String fontString)
fontString
- description of the font desiredprotected org.eclipse.swt.graphics.Font getTransformedFont()
public void translate(int x, int y)
translate
in class Graphics2D
public void translate(double tx, double ty)
translate
in class Graphics2D
public void rotate(double theta)
rotate
in class Graphics2D
public void rotate(double theta, double x, double y)
rotate
in class Graphics2D
public void scale(double sx, double sy)
scale
in class Graphics2D
public void shear(double shx, double shy)
shear
in class Graphics2D
public void transform(AffineTransform srcTransform)
transform
in class Graphics2D
public void setTransform(AffineTransform newTransform)
setTransform
in class Graphics2D
public AffineTransform getTransform()
getTransform
in class Graphics2D
public void clearRect(int x, int y, int width, int height)
public void draw(Shape s)
draw
in class Graphics2D
public void fill(Shape s)
fill
in class Graphics2D
public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
drawPolyline
in class Graphics
public void drawPolyline(double[] pts)
pts
- double array of pointspublic void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
drawPolygon
in class Graphics
public void fillPolygon(double[] pts)
pts
- double array of pointspublic void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
fillPolygon
in class Graphics
public void drawLine(int x1, int y1, int x2, int y2)
public void drawLine(double x1, double y1, double x2, double y2)
x1
- the first point's x coordinate.y1
- the first point's y coordinate.x2
- the second point's x coordinate.y2
- the second point's y coordinate.public void copyArea(org.eclipse.swt.graphics.Image img, double x, double y)
img
- swt image to be copiedx
- x component of positiony
- y component of positionpublic void copyArea(int x, int y, int width, int height, int dx, int dy)
public void drawString(String str, int x, int y, boolean isTransparent)
str
- the string to be renderedx
- the x coordinate of the location where the String should be
renderedy
- the y coordinate of the location where the String should be
renderedisTransparent
- whether a background should be painted behind the
textpublic void drawString(String str, int x, int y)
drawString
in class Graphics2D
public void drawString(String str, double x, double y)
str
- the string to be renderedx
- the x coordinate of the location where the String should be
renderedy
- the y coordinate of the location where the String should be
renderedpublic void drawString(String str, double x, double y, boolean isTransparent)
str
- the string to be renderedx
- the x coordinate of the location where the String should be
renderedy
- the y coordinate of the location where the String should be
renderedisTransparent
- whether a background should be painted behind the
textpublic void drawString(String str, float x, float y)
drawString
in class Graphics2D
public void drawText(String str, double x, double y)
str
- the string to be renderedx
- the x coordinate of the location where the String should be
renderedy
- the y coordinate of the location where the String should be
renderedpublic void drawText(String str, double x, double y, int flags)
str
- the string to be renderedx
- the x coordinate of the location where the String should be
renderedy
- the y coordinate of the location where the String should be
renderedflags
- flags to apply to the string as defined by SWTpublic void drawText(String str, int x, int y, int flags)
str
- the string to be renderedx
- the x coordinate of the location where the String should be
renderedy
- the y coordinate of the location where the String should be
renderedflags
- flags to apply to the string as defined by SWTpublic void drawRect(int x, int y, int width, int height)
public void drawRect(double x, double y, double width, double height)
x
- the x coordinate of the rectangle to be drawn.y
- the y coordinate of the rectangle to be drawn.width
- the width of the rectangle to be drawn.height
- the height of the rectangle to be drawn.public void fillRect(int x, int y, int width, int height)
public void fillRect(double x, double y, double width, double height)
x
- the x coordinate of the rectangle to be filled.y
- the y coordinate of the rectangle to be filled.width
- the width of the rectangle to be filled.height
- the height of the rectangle to be filled.public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
drawRoundRect
in class Graphics
public void drawRoundRect(double x, double y, double width, double height, double arcWidth, double arcHeight)
x
- the x coordinate of the rectangle to be drawn.y
- the y coordinate of the rectangle to be drawn.width
- the width of the rectangle to be drawn.height
- the height of the rectangle to be drawn.arcWidth
- the horizontal diameter of the arc at the four corners.arcHeight
- the vertical diameter of the arc at the four corners.public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
fillRoundRect
in class Graphics
public void fillRoundRect(double x, double y, double width, double height, double arcWidth, double arcHeight)
x
- the x coordinate of the rectangle to be filled.y
- the y coordinate of the rectangle to be filled.width
- the width of the rectangle to be filled.height
- the height of the rectangle to be filled.arcWidth
- the horizontal diameter of the arc at the four corners.arcHeight
- the vertical diameter of the arc at the four corners.public void drawOval(int x, int y, int width, int height)
public void drawOval(double x, double y, double width, double height)
x
- the x coordinate of the upper left corner of the oval to be
drawn.y
- the y coordinate of the upper left corner of the oval to be
drawn.width
- the width of the oval to be drawn.height
- the height of the oval to be drawn.public void fillOval(int x, int y, int width, int height)
public void fillOval(double x, double y, double width, double height)
x
- the x coordinate of the upper left corner of the oval to be
filled.y
- the y coordinate of the upper left corner of the oval to be
filled.width
- the width of the oval to be filled.height
- the height of the oval to be filled.public void drawArc(int x, int y, int width, int height, int startAngle, int extent)
public void drawArc(double x, double y, double width, double height, double startAngle, double extent)
x
- the x coordinate of the upper-left corner of the arc to be
drawn.y
- the y coordinate of the upper-left corner of the arc to be
drawn.width
- the width of the arc to be drawn.height
- the height of the arc to be drawn.startAngle
- the beginning angle.extent
- the angular extent of the arc, relative to the start angle.public void fillArc(int x, int y, int width, int height, int startAngle, int extent)
public void fillArc(double x, double y, double width, double height, double startAngle, double extent)
x
- the x coordinate of the upper-left corner of the arc to be
filled.y
- the y coordinate of the upper-left corner of the arc to be
filled.width
- the width of the arc to be filled.height
- the height of the arc to be filled.startAngle
- the beginning angle.extent
- the angular extent of the arc, relative to the start angle.public void drawPath(org.eclipse.swt.graphics.Path p)
p
- path to drawpublic void fillPath(org.eclipse.swt.graphics.Path p)
p
- path to draw filledpublic void drawImage(org.eclipse.swt.graphics.Image image, double x, double y)
image
- image to drawx
- x component of the positiony
- y component of the positionpublic void drawImage(org.eclipse.swt.graphics.Image image, int srcX, int srcY, int srcW, int srcH, double destX, double destY, double destW, double destH)
image
- image from which to copysrcX
- the left of the source regionsrcY
- the top of the source regionsrcW
- the width of the source regionsrcH
- the height of the source regiondestX
- the left of the destination regiondestY
- the top of the destination regiondestW
- the width of the destination regiondestH
- the height of the destination regionpublic void setLineWidth(double lineWidth)
lineWidth
- width of line when drawing shapesprotected int getTransformedLineWidth()
public void fillGradientRectangle(double x, double y, double width, double height, boolean vertical)
x
- left of resulting rectangley
- top of resulting rectanglewidth
- width of resulting rectangleheight
- height of resulting rectanglevertical
- whether the gradient should be drawn vertically or
horizontallypublic void setXORMode(boolean xOr)
xOr
- whether to be in xOr modepublic int getAdvanceWidth(char ch)
ch
- character to calculate the advance width of.public int getCharWidth(char ch)
ch
- character to calculate the width of.public org.eclipse.swt.graphics.Point stringExtent(String str)
str
- string to calculate the extent of.public org.eclipse.swt.graphics.Point textExtent(String str)
str
- string to calculate the extent of.public org.eclipse.swt.graphics.Point textExtent(String str, int flags)
str
- string to calculate the extent offlags
- flags to apply to the rendered font before calculation of
extent takes placepublic void drawString(AttributedCharacterIterator iterator, int x, int y)
drawString
in class Graphics2D
public void drawString(AttributedCharacterIterator iterator, float x, float y)
drawString
in class Graphics2D
public void drawGlyphVector(GlyphVector g, float x, float y)
drawGlyphVector
in class Graphics2D
public boolean hit(Rectangle rect, Shape s, boolean onStroke)
hit
in class Graphics2D
rect
- rect to tests
- shape to testonStroke
- whether to consider the width of the strokepublic void setComposite(Composite comp)
setComposite
in class Graphics2D
public void setStroke(Stroke s)
setStroke
in class Graphics2D
public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
setRenderingHint
in class Graphics2D
public Object getRenderingHint(RenderingHints.Key hintKey)
getRenderingHint
in class Graphics2D
public void setRenderingHints(Map hints)
setRenderingHints
in class Graphics2D
Graphics2D.setRenderingHints(Map)
public void addRenderingHints(Map hints)
addRenderingHints
in class Graphics2D
Graphics2D.addRenderingHints(Map)
public RenderingHints getRenderingHints()
getRenderingHints
in class Graphics2D
Graphics2D.getRenderingHints()
public Composite getComposite()
getComposite
in class Graphics2D
Graphics2D.getComposite()
public Stroke getStroke()
getStroke
in class Graphics2D
Graphics2D.getStroke()
public FontRenderContext getFontRenderContext()
getFontRenderContext
in class Graphics2D
Graphics2D.getFontRenderContext()
public Graphics create()
create
in class Graphics
Graphics.create()
public void setPaintMode()
setPaintMode
in class Graphics
Graphics.setPaintMode()
public void setXORMode(Color c1)
setXORMode
in class Graphics
Graphics.setXORMode(Color)
public FontMetrics getFontMetrics(Font f)
getFontMetrics
in class Graphics
Graphics.getFontMetrics(Font)
public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs)
drawImage
in class Graphics2D
Graphics2D.drawImage(Image, AffineTransform, ImageObserver)
public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y)
drawImage
in class Graphics2D
Graphics2D.drawImage(BufferedImage, BufferedImageOp, int,
int)
public void drawRenderedImage(RenderedImage img, AffineTransform xform)
drawRenderedImage
in class Graphics2D
Graphics2D.drawRenderedImage(RenderedImage,
AffineTransform)
public void drawRenderableImage(RenderableImage img, AffineTransform xform)
drawRenderableImage
in class Graphics2D
Graphics2D.drawRenderableImage(RenderableImage,
AffineTransform)
public boolean drawImage(Image img, int x, int y, ImageObserver observer)
drawImage
in class Graphics
Graphics.drawImage(Image, int, int, ImageObserver)
public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)
drawImage
in class Graphics
Graphics.drawImage(Image, int, int, int, int,
ImageObserver)
public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer)
drawImage
in class Graphics
Graphics.drawImage(Image, int, int, Color, ImageObserver)
public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer)
drawImage
in class Graphics
Graphics.drawImage(Image, int, int, int, int, Color,
ImageObserver)
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
drawImage
in class Graphics
Graphics.drawImage(Image, int, int, int, int, int, int,
int, int, ImageObserver)
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer)
drawImage
in class Graphics
Graphics.drawImage(Image, int, int, int, int, int, int,
int, int, Color, ImageObserver)
public void dispose()
public static void incrementGCCount()
public static void decrementGCCount()
Copyright © 1995–2013 Piccolo2D. All rights reserved.