|
Eclipse Draw2d 3.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.draw2d.Graphics
The Graphics class allows you to draw to a surface. The drawXxx() methods that pertain to shapes draw an outline of the shape, whereas the fillXxx() methods fill in the shape. Also provides for drawing text, lines and images.
Field Summary | |
static int |
LINE_CUSTOM
|
static int |
LINE_DASH
|
static int |
LINE_DASHDOT
|
static int |
LINE_DASHDOTDOT
|
static int |
LINE_DOT
|
static int |
LINE_SOLID
|
Constructor Summary | |
Graphics()
|
Method Summary | |
abstract void |
clipRect(Rectangle r)
Sets the clip region to the given rectangle. |
abstract void |
dispose()
Disposes this object, releasing any resources. |
abstract void |
drawArc(int x,
int y,
int w,
int h,
int offset,
int length)
Draws the outline of an arc located at (x,y) with width w and height h. |
void |
drawArc(Rectangle r,
int offset,
int length)
|
abstract void |
drawFocus(int x,
int y,
int w,
int h)
Draws a focus rectangle. |
void |
drawFocus(Rectangle r)
|
abstract void |
drawImage(Image srcImage,
int x,
int y)
Draws the given Image at the location (x,y). |
abstract void |
drawImage(Image srcImage,
int x1,
int y1,
int w1,
int h1,
int x2,
int y2,
int w2,
int h2)
Draws a rectangular section of the given Image to the specified rectangular reagion on the canvas. |
void |
drawImage(Image image,
Point p)
Draws the given image at a point. |
void |
drawImage(Image srcImage,
Rectangle src,
Rectangle dest)
|
abstract void |
drawLine(int x1,
int y1,
int x2,
int y2)
Draws a line between the points (x1,y1) and (x2,y2) using the
foreground color. |
void |
drawLine(Point p1,
Point p2)
|
abstract void |
drawOval(int x,
int y,
int w,
int h)
Draws the outline of an ellipse that fits inside the rectangle with the given properties using the foreground color. |
void |
drawOval(Rectangle r)
Draws an oval inside the given rectangle using the current foreground color. |
void |
drawPath(Path path)
Draws the given path. |
void |
drawPoint(int x,
int y)
Draws a pixel, using the foreground color, at the specified point ( x ,
y ).
|
void |
drawPolygon(int[] points)
Draws a closed polygon defined by the given Integer array containing the vertices in x,y order. |
abstract void |
drawPolygon(PointList points)
Draws a closed polygon defined by the given PointList containing the
vertices. |
void |
drawPolyline(int[] points)
Draws a polyline defined by the given Integer array containing the vertices in x,y order. |
abstract void |
drawPolyline(PointList points)
Draws a polyline defined by the given PointList containing the vertices.
|
abstract void |
drawRectangle(int x,
int y,
int width,
int height)
Draws a rectangle whose top-left corner is located at the point (x,y) with the given width and height. |
void |
drawRectangle(Rectangle r)
Draws the given rectangle using the current foreground color. |
abstract void |
drawRoundRectangle(Rectangle r,
int arcWidth,
int arcHeight)
Draws a rectangle with rounded corners using the foreground color. |
abstract void |
drawString(String s,
int x,
int y)
Draws the given string using the current font and foreground color. |
void |
drawString(String s,
Point p)
|
abstract void |
drawText(String s,
int x,
int y)
Draws the given string using the current font and foreground color. |
void |
drawText(String s,
int x,
int y,
int style)
Draws a string using the specified styles. |
void |
drawText(String s,
Point p)
|
void |
drawText(String s,
Point p,
int style)
Draws a string using the specified styles. |
void |
drawTextLayout(TextLayout layout,
int x,
int y)
Renders the specified TextLayout to this Graphics. |
void |
drawTextLayout(TextLayout layout,
int x,
int y,
int selectionStart,
int selectionEnd,
Color selectionForeground,
Color selectionBackground)
|
abstract void |
fillArc(int x,
int y,
int w,
int h,
int offset,
int length)
Fills the interior of an arc located at (x,y) with width w and height h. |
void |
fillArc(Rectangle r,
int offset,
int length)
|
abstract void |
fillGradient(int x,
int y,
int w,
int h,
boolean vertical)
Fills the the given rectangle with a gradient from the foreground color to the background color. |
void |
fillGradient(Rectangle r,
boolean vertical)
|
abstract void |
fillOval(int x,
int y,
int w,
int h)
Fills an ellipse that fits inside the rectangle with the given properties using the background color. |
void |
fillOval(Rectangle r)
|
void |
fillPath(Path path)
Fills the given path. |
void |
fillPolygon(int[] points)
Fills a closed polygon defined by the given Integer array containing the vertices in x,y order. |
abstract void |
fillPolygon(PointList points)
Fills a closed polygon defined by the given PointList containing the
vertices. |
abstract void |
fillRectangle(int x,
int y,
int width,
int height)
Fills a rectangle whose top-left corner is located at the point (x,y) with the given width and height. |
void |
fillRectangle(Rectangle r)
Fills the given rectangle using the current background color. |
abstract void |
fillRoundRectangle(Rectangle r,
int arcWidth,
int arcHeight)
Fills a rectangle with rounded corners using the background color. |
abstract void |
fillString(String s,
int x,
int y)
Draws the given string using the current font and foreground color. |
void |
fillString(String s,
Point p)
|
abstract void |
fillText(String s,
int x,
int y)
Draws the given string using the current font and foreground color. |
void |
fillText(String s,
Point p)
|
double |
getAbsoluteScale()
Returns the current absolute scaling which will be applied to the underlying Device when painting to this Graphics. |
int |
getAlpha()
Returns the current alpha value of the graphics. |
int |
getAntialias()
Returns the anti-aliasing setting value, which will be one of SWT.DEFAULT ,
SWT.OFF or SWT.ON . |
abstract Color |
getBackgroundColor()
Returns the background color used for filling. |
abstract Rectangle |
getClip(Rectangle rect)
Modifies the given rectangle to match the clip region and returns that rectangle. |
int |
getFillRule()
Returns the fill rule, which will be one of SWT.FILL_EVEN_ODD or
SWT.FILL_WINDING . |
abstract Font |
getFont()
Returns the font used to draw and fill text. |
abstract FontMetrics |
getFontMetrics()
Returns the font metrics for the current font. |
abstract Color |
getForegroundColor()
Returns the foreground color used to draw lines and text. |
int |
getInterpolation()
Returns the interpolation setting, which will be one of SWT.DEFAULT ,
SWT.NONE , SWT.LOW or SWT.HIGH . |
int |
getLineCap()
Returns the current line cap style, which will be one of the constants SWT.CAP_FLAT , SWT.CAP_ROUND , or SWT.CAP_SQUARE . |
int |
getLineJoin()
Returns the line join style, which will be one of the constants SWT.JOIN_MITER , SWT.JOIN_ROUND , or
SWT.JOIN_BEVEL . |
abstract int |
getLineStyle()
Returns the line style. |
abstract int |
getLineWidth()
Returns the current line width. |
int |
getTextAntialias()
Returns the textual anti-aliasing setting value, which will be one of SWT.DEFAULT , SWT.OFF or SWT.ON . |
abstract boolean |
getXORMode()
Returns true if this graphics object should use XOR mode with painting. |
abstract void |
popState()
Pops the previous state of this graphics object off the stack (if pushState()
has previously been called) and restores the current state to that popped state. |
abstract void |
pushState()
Pushes the current state of this graphics object onto a stack. |
abstract void |
restoreState()
Restores the previous state of this graphics object. |
void |
rotate(float degrees)
Rotates the coordinates by the given counter-clockwise angle. |
abstract void |
scale(double amount)
Scales this graphics object by the given amount. |
void |
scale(float horizontal,
float vertical)
Scales the graphics by the given horizontal and vertical components. |
void |
setAlpha(int alpha)
Sets the alpha to the given value. |
void |
setAntialias(int value)
Sets the anti-aliasing value to the parameter, which must be one of SWT.DEFAULT , SWT.OFF or SWT.ON . |
abstract void |
setBackgroundColor(Color rgb)
Sets the background color. |
void |
setBackgroundPattern(Pattern pattern)
Sets the pattern used for fill-type graphics operations. |
void |
setClip(Path path)
Sets the area which can be affected by drawing operations to the specified Path . |
abstract void |
setClip(Rectangle r)
Sets the clip rectangle. |
void |
setFillRule(int rule)
Sets the fill rule to the given value, which must be one of SWT.FILL_EVEN_ODD or SWT.FILL_WINDING . |
abstract void |
setFont(Font f)
Sets the font. |
abstract void |
setForegroundColor(Color rgb)
Sets the foreground color. |
void |
setForegroundPattern(Pattern pattern)
Sets the foreground pattern for draw and text operations. |
void |
setInterpolation(int interpolation)
Sets the interpolation setting to the given value, which must be one of SWT.DEFAULT , SWT.NONE , SWT.LOW or
SWT.HIGH . |
void |
setLineCap(int cap)
Sets the line cap style to the argument, which must be one of the constants SWT.CAP_FLAT , SWT.CAP_ROUND , or SWT.CAP_SQUARE . |
void |
setLineDash(int[] dash)
Sets the dash pattern when the custom line style is in use. |
void |
setLineJoin(int join)
Sets the line join style to the argument, which must be one of the constants SWT.JOIN_MITER , SWT.JOIN_ROUND , or
SWT.JOIN_BEVEL . |
abstract void |
setLineStyle(int style)
Sets the line style to the argument, which must be one of the constants SWT.LINE_SOLID , SWT.LINE_DASH , SWT.LINE_DOT ,
SWT.LINE_DASHDOT or SWT.LINE_DASHDOTDOT . |
abstract void |
setLineWidth(int width)
Sets the line width. |
void |
setTextAntialias(int value)
Sets the textual anti-aliasing value to the parameter, which must be one of SWT.DEFAULT , SWT.OFF or SWT.ON . |
abstract void |
setXORMode(boolean b)
Sets the XOR mode. |
void |
shear(float horz,
float vert)
Modifies the current transformation by shearing the graphics in the specified horizontal and vertical amounts. |
void |
translate(float dx,
float dy)
Modifies the current transform by translating the given x and y amounts. |
abstract void |
translate(int dx,
int dy)
Translates the receiver's coordinates by the specified x and y amounts. |
void |
translate(Point pt)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int LINE_CUSTOM
SWT.LINE_CUSTOM
,
Constant Field Valuespublic static final int LINE_DASH
SWT.LINE_DASH
,
Constant Field Valuespublic static final int LINE_DASHDOT
SWT.LINE_DASHDOT
,
Constant Field Valuespublic static final int LINE_DASHDOTDOT
SWT.LINE_DASHDOTDOT
,
Constant Field Valuespublic static final int LINE_DOT
SWT.LINE_DOT
,
Constant Field Valuespublic static final int LINE_SOLID
SWT.LINE_SOLID
,
Constant Field ValuesConstructor Detail |
public Graphics()
Method Detail |
public abstract void clipRect(Rectangle r)
r
- the clip rectanglepublic abstract void dispose()
public abstract void drawArc(int x, int y, int w, int h, int offset, int length)
x
- the x coordinatey
- the y coordinatew
- the widthh
- the heightoffset
- the start anglelength
- the length of the arcpublic final void drawArc(Rectangle r, int offset, int length)
drawArc(int, int, int, int, int, int)
public abstract void drawFocus(int x, int y, int w, int h)
x
- the x coordinatey
- the y coordinatew
- the widthh
- the heightpublic final void drawFocus(Rectangle r)
drawFocus(int, int, int, int)
public abstract void drawImage(Image srcImage, int x, int y)
srcImage
- the Imagex
- the x coordinatey
- the y coordinatepublic abstract void drawImage(Image srcImage, int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2)
srcImage
- the imagex1
- the x coordinate of the sourcey1
- the y coordinate of the sourcew1
- the width of the sourceh1
- the height of the sourcex2
- the x coordinate of the destinationy2
- the y coordinate of the destinationw2
- the width of the destinationh2
- the height of the destinationpublic final void drawImage(Image image, Point p)
image
- the image to drawp
- where to draw the imagedrawImage(Image, int, int)
public final void drawImage(Image srcImage, Rectangle src, Rectangle dest)
drawImage(Image, int, int, int, int, int, int, int, int)
public abstract void drawLine(int x1, int y1, int x2, int y2)
(x1,y1)
and (x2,y2)
using the
foreground color.
x1
- the x coordinate for the first pointy1
- the y coordinate for the first pointx2
- the x coordinate for the second pointy2
- the y coordinate for the second pointpublic final void drawLine(Point p1, Point p2)
drawLine(int, int, int, int)
public abstract void drawOval(int x, int y, int w, int h)
x
- the x coordinatey
- the y coordinatew
- the widthh
- the heightpublic final void drawOval(Rectangle r)
r
- the rectangle circumscribing the oval to be drawndrawOval(int, int, int, int)
public void drawPath(Path path)
path
- the path to drawpublic void drawPoint(int x, int y)
x
,
y
).
Note that the current line attributes do not affect this operation.
x
- the point's x coordinatey
- the point's y coordinatepublic void drawPolygon(int[] points)
points
- the verticespublic abstract void drawPolygon(PointList points)
PointList
containing the
vertices. The first and last points in the list will be connected.
points
- the verticespublic void drawPolyline(int[] points)
points
- the verticespublic abstract void drawPolyline(PointList points)
PointList
containing the vertices.
The first and last points in the list will not be connected.
points
- the verticespublic abstract void drawRectangle(int x, int y, int width, int height)
x
- the x coordinatey
- the y coordinatewidth
- the widthheight
- the heightpublic final void drawRectangle(Rectangle r)
r
- the rectangle to drawdrawRectangle(int, int, int, int)
public abstract void drawRoundRectangle(Rectangle r, int arcWidth, int arcHeight)
r
- the rectanglearcWidth
- the arc widtharcHeight
- the arc heightpublic abstract void drawString(String s, int x, int y)
s
- the stringx
- the x coordinatey
- the y coordinatepublic final void drawString(String s, Point p)
drawString(String, int, int)
public abstract void drawText(String s, int x, int y)
s
- the textx
- the x coordinatey
- the y coordinatepublic void drawText(String s, int x, int y, int style)
GC.drawText(String, int, int, int)
.
s
- the String to drawx
- the x locationy
- the y locationstyle
- the styles used to render the stringpublic final void drawText(String s, Point p)
drawText(String, int, int)
public final void drawText(String s, Point p, int style)
GC.drawText(String, int, int, int)
.
s
- the String to drawp
- the point at which to draw the stringstyle
- the styles used to render the stringpublic final void drawTextLayout(TextLayout layout, int x, int y)
layout
- the TextLayoutx
- the x coordinatey
- the y coordinatepublic void drawTextLayout(TextLayout layout, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground)
x
- the x locationy
- the y locationlayout
- the TextLayout being renderedselectionStart
- the start of selectionselectionEnd
- the end of selectionselectionForeground
- the foreground selection colorselectionBackground
- the background selection colordrawTextLayout(TextLayout, int, int)
public abstract void fillArc(int x, int y, int w, int h, int offset, int length)
x
- the x coordinatey
- the y coordinatew
- the widthh
- the heightoffset
- the start anglelength
- the length of the arcpublic final void fillArc(Rectangle r, int offset, int length)
fillArc(int, int, int, int, int, int)
public abstract void fillGradient(int x, int y, int w, int h, boolean vertical)
true
, the gradient will go from
top to bottom. Otherwise, it will go from left to right.
background color.
x
- the x coordinatey
- the y coordinatew
- the widthh
- the heightvertical
- whether the gradient should be verticalpublic final void fillGradient(Rectangle r, boolean vertical)
fillGradient(int, int, int, int, boolean)
public abstract void fillOval(int x, int y, int w, int h)
x
- the x coordinatey
- the y coordinatew
- the widthh
- the heightpublic final void fillOval(Rectangle r)
fillOval(int, int, int, int)
public void fillPath(Path path)
path
- the path to fillpublic void fillPolygon(int[] points)
points
- the verticespublic abstract void fillPolygon(PointList points)
PointList
containing the
vertices. The first and last points in the list will be connected.
points
- the verticespublic abstract void fillRectangle(int x, int y, int width, int height)
x
- the x coordinatey
- the y coordinatewidth
- the widthheight
- the heightpublic final void fillRectangle(Rectangle r)
r
- the rectangle to fillfillRectangle(int, int, int, int)
public abstract void fillRoundRectangle(Rectangle r, int arcWidth, int arcHeight)
r
- the rectanglearcWidth
- the arc widtharcHeight
- the arc heightpublic abstract void fillString(String s, int x, int y)
s
- the stringx
- the x coordinatey
- the y coordinatepublic final void fillString(String s, Point p)
fillString(String, int, int)
public abstract void fillText(String s, int x, int y)
s
- the textx
- the x coordinatey
- the y coordinatepublic final void fillText(String s, Point p)
fillText(String, int, int)
public double getAbsoluteScale()
public int getAlpha()
public int getAntialias()
SWT.DEFAULT
,
SWT.OFF
or SWT.ON
. Note that this controls anti-aliasing for
all non-text drawing operations.
getTextAntialias()
public abstract Color getBackgroundColor()
public abstract Rectangle getClip(Rectangle rect)
rect
- the rectangle to hold the clip region
public int getFillRule()
SWT.FILL_EVEN_ODD
or
SWT.FILL_WINDING
.
public abstract Font getFont()
public abstract FontMetrics getFontMetrics()
public abstract Color getForegroundColor()
public int getInterpolation()
SWT.DEFAULT
,
SWT.NONE
, SWT.LOW
or SWT.HIGH
.
public int getLineCap()
SWT.CAP_FLAT
, SWT.CAP_ROUND
, or SWT.CAP_SQUARE
.
public int getLineJoin()
SWT.JOIN_MITER
, SWT.JOIN_ROUND
, or
SWT.JOIN_BEVEL
.
public abstract int getLineStyle()
public abstract int getLineWidth()
public int getTextAntialias()
SWT.DEFAULT
, SWT.OFF
or SWT.ON
. Note that this
controls anti-aliasing only for text drawing operations.
getAntialias()
public abstract boolean getXORMode()
true
if this graphics object should use XOR mode with painting.
public abstract void popState()
pushState()
has previously been called) and restores the current state to that popped state.
public abstract void pushState()
public abstract void restoreState()
public void rotate(float degrees)
degrees
- the degrees to rotatepublic abstract void scale(double amount)
amount
- the scale factorpublic void scale(float horizontal, float vertical)
horizontal
- the horizontal scaling factorvertical
- the vertical scaling factorpublic void setAlpha(int alpha)
alpha
- an alpha value (0-255)public void setAntialias(int value)
SWT.DEFAULT
, SWT.OFF
or SWT.ON
. Note that this
controls anti-aliasing for all non-text drawing operations.
value
- the anti-alias valuepublic abstract void setBackgroundColor(Color rgb)
rgb
- the new background colorpublic void setBackgroundPattern(Pattern pattern)
pattern
- the background patternpublic void setClip(Path path)
Path
.
path
- the clipping pathpublic abstract void setClip(Rectangle r)
r
- the new clip rectanglepublic void setFillRule(int rule)
SWT.FILL_EVEN_ODD
or SWT.FILL_WINDING
.
rule
- the fill rulepublic abstract void setFont(Font f)
f
- the new fontpublic abstract void setForegroundColor(Color rgb)
rgb
- the new foreground colorpublic void setForegroundPattern(Pattern pattern)
pattern
- the foreground patternpublic void setInterpolation(int interpolation)
SWT.DEFAULT
, SWT.NONE
, SWT.LOW
or
SWT.HIGH
. This setting is relevant when working with Images.
interpolation
- the interpolationpublic void setLineCap(int cap)
SWT.CAP_FLAT
, SWT.CAP_ROUND
, or SWT.CAP_SQUARE
.
cap
- the line cappublic void setLineDash(int[] dash)
pushState()
and popState()
.
dash
- the pixel patternpublic void setLineJoin(int join)
SWT.JOIN_MITER
, SWT.JOIN_ROUND
, or
SWT.JOIN_BEVEL
.
join
- the join typepublic abstract void setLineStyle(int style)
SWT.LINE_SOLID
, SWT.LINE_DASH
, SWT.LINE_DOT
,
SWT.LINE_DASHDOT
or SWT.LINE_DASHDOTDOT
.
style
- the new stylepublic abstract void setLineWidth(int width)
width
- the new widthpublic void setTextAntialias(int value)
SWT.DEFAULT
, SWT.OFF
or SWT.ON
. Note that this
controls anti-aliasing only for all text drawing operations.
value
- the textual anti-alias settingpublic void shear(float horz, float vert)
horz
- the horizontal shearing amountvert
- the vertical shearming amountpublic abstract void setXORMode(boolean b)
b
- the new XOR modepublic abstract void translate(int dx, int dy)
dx
- the horizontal offsetdy
- the vertical offsetpublic void translate(float dx, float dy)
dx
- the horizontal offsetdy
- the vertical offsetpublic final void translate(Point pt)
translate(int, int)
|
Eclipse Draw2d 3.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |