|
Eclipse Draw2d 2.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.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_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 Graphics object. |
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 srcImage,
Point p)
|
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)
|
abstract void |
drawPolygon(PointList points)
Draws a closed polygon defined by the given PointList containing the
vertices. |
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)
|
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,
Point p)
|
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)
|
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)
|
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)
|
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. |
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. |
abstract int |
getLineStyle()
Returns the line style. |
abstract int |
getLineWidth()
Returns the current line width. |
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. |
abstract void |
scale(double amount)
Scales this graphics object by the given amount. |
abstract void |
setBackgroundColor(Color rgb)
Sets the background color. |
abstract void |
setClip(Rectangle r)
Sets the clip rectangle. |
abstract void |
setFont(Font f)
Sets the font. |
abstract void |
setForegroundColor(Color rgb)
Sets the foreground color. |
abstract void |
setLineStyle(int style)
Sets the line style. |
abstract void |
setLineWidth(int width)
Sets the line width. |
abstract void |
setXORMode(boolean b)
Sets the XOR mode. |
abstract void |
translate(int dx,
int dy)
Translates this graphics object so that its origin is offset horizontally by dx and vertically by dy. |
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_SOLID
SWT.LINE_SOLID
,
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 ValuesConstructor Detail |
public Graphics()
Method Detail |
public abstract void clipRect(Rectangle r)
r
- the clip rectanglepublic abstract void dispose()
public final void drawArc(Rectangle r, int offset, int length)
drawArc(int, int, int, int, int, int)
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 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 final void fillGradient(Rectangle r, boolean vertical)
fillGradient(int, int, int, int, boolean)
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 drawFocus(Rectangle r)
drawFocus(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 drawImage(Image srcImage, Point p)
drawImage(Image, int, int)
public abstract void drawImage(Image srcImage, int x, int y)
srcImage
- the Imagex
- the x coordinatey
- the y coordinatepublic final void drawImage(Image srcImage, Rectangle src, Rectangle dest)
drawImage(Image, int, int, int, int, int, int, int, int)
public 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 drawLine(Point p1, Point p2)
drawLine(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 drawOval(Rectangle r)
drawOval(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 fillOval(Rectangle r)
fillOval(int, int, int, int)
public abstract void fillOval(int x, int y, int w, int h)
x
- the x coordinatey
- the y coordinatew
- the widthh
- the heightpublic abstract void drawPolygon(PointList points)
PointList
containing the
vertices. The first and last points in the list will be connected.
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 drawPolyline(PointList points)
PointList
containing the vertices.
The first and last points in the list will not be connected.
points
- the verticespublic final void drawRectangle(Rectangle r)
drawRectangle(int, int, int, int)
public abstract void drawRectangle(int x, int y, int width, int height)
x
- the x coordinatey
- the y coordinatewidth
- the widthheight
- the heightpublic final void fillRectangle(Rectangle r)
fillRectangle(int, int, int, int)
public abstract void fillRectangle(int x, int y, int width, int height)
x
- the x coordinatey
- the y coordinatewidth
- the widthheight
- the heightpublic abstract void drawRoundRectangle(Rectangle r, int arcWidth, int arcHeight)
r
- the rectanglearcWidth
- the arc widtharcHeight
- the arc heightpublic abstract void fillRoundRectangle(Rectangle r, int arcWidth, int arcHeight)
r
- the rectanglearcWidth
- the arc widtharcHeight
- the arc heightpublic abstract void drawText(String s, int x, int y)
s
- the textx
- the x coordinatey
- the y coordinatepublic 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 final void drawText(String s, Point p)
drawText(String, int, int)
public final void fillString(String s, Point p)
fillString(String, int, int)
public abstract void fillString(String s, int x, int y)
s
- the stringx
- the x coordinatey
- the y coordinatepublic final void fillText(String s, Point p)
fillText(String, int, int)
public abstract void fillText(String s, int x, int y)
s
- the textx
- the x coordinatey
- the y coordinatepublic abstract Color getBackgroundColor()
public abstract Rectangle getClip(Rectangle rect)
rect
- the rectangle to hold the clip region
public abstract Font getFont()
public abstract FontMetrics getFontMetrics()
public abstract Color getForegroundColor()
public abstract int getLineStyle()
public abstract int getLineWidth()
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 abstract void scale(double amount)
amount
- the scale factorpublic abstract void setBackgroundColor(Color rgb)
rgb
- the new background colorpublic abstract void setClip(Rectangle r)
r
- the new clip rectanglepublic abstract void setFont(Font f)
f
- the new fontpublic abstract void setForegroundColor(Color rgb)
rgb
- the new foreground colorpublic abstract void setLineStyle(int style)
style
- the new stylepublic abstract void setLineWidth(int width)
width
- the new widthpublic abstract void setXORMode(boolean b)
b
- the new XOR modepublic final void translate(Point pt)
translate(int, int)
public abstract void translate(int dx, int dy)
dx
- the horizontal offsetdy
- the vertical offset
|
Eclipse Draw2d 2.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |