|
Eclipse Draw2d 3.0.1 |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.eclipse.draw2d.Graphics
org.eclipse.draw2d.SWTGraphics
Implementation of providing the drawing capabilities of SWT's GC class in Draw2d. There are 2 states contained in this graphics class -- the applied state which is the actual state of the GC and the current state which is the current state of this graphics object. Certain properties can be changed multiple times and the GC won't be updated until it's actually used.
| Nested Class Summary | |
protected static class |
SWTGraphics.State
Contains the state variables of this SWTGraphics object |
| Field Summary | |
static boolean |
debug
debug flag. |
| Fields inherited from class org.eclipse.draw2d.Graphics |
LINE_DASH, LINE_DASHDOT, LINE_DASHDOTDOT, LINE_DOT, LINE_SOLID |
| Constructor Summary | |
SWTGraphics(GC gc)
Constructs a new SWTGraphics that draws to the Canvas using the given GC. |
|
| Method Summary | |
protected void |
checkFill()
If the background color has changed, this change will be pushed to the GC. |
protected void |
checkGC()
If the XOR or the clip region has change, these changes will be pushed to the GC. |
protected void |
checkPaint()
If the line width, line style, foreground or background colors have changed, these changes will be pushed to the GC. |
protected void |
checkText()
If the font has changed, this change will be pushed to the GC. |
void |
clipRect(Rectangle rect)
Sets the clip region to the given rectangle. |
void |
dispose()
Disposes this Graphics object. |
void |
drawArc(int x,
int y,
int width,
int height,
int offset,
int length)
Draws the outline of an arc located at (x,y) with width w and height h. |
void |
drawFocus(int x,
int y,
int w,
int h)
Draws a focus rectangle. |
void |
drawImage(Image srcImage,
int x,
int y)
Draws the given Image at the location (x,y). |
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 |
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 |
drawOval(int x,
int y,
int width,
int height)
Draws the outline of an ellipse that fits inside the rectangle with the given properties using the foreground color. |
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. |
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. |
void |
drawPolyline(PointList points)
Draws a polyline defined by the given PointList containing the vertices.
|
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 |
drawRoundRectangle(Rectangle r,
int arcWidth,
int arcHeight)
Draws a rectangle with rounded corners using the foreground color. |
void |
drawString(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)
Draws the given string using the current font and foreground color. |
void |
drawTextLayout(TextLayout layout,
int x,
int y,
int selectionStart,
int selectionEnd,
Color selectionForeground,
Color selectionBackground)
|
void |
fillArc(int x,
int y,
int width,
int height,
int offset,
int length)
Fills the interior of an arc located at (x,y) with width w and height h. |
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 |
fillOval(int x,
int y,
int width,
int height)
Fills an ellipse that fits inside the rectangle with the given properties using the background color. |
void |
fillPolygon(int[] points)
Fills a closed polygon defined by the given Integer array containing the vertices in x,y order. |
void |
fillPolygon(PointList points)
Fills a closed polygon defined by the given PointList containing the
vertices. |
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 |
fillRoundRectangle(Rectangle r,
int arcWidth,
int arcHeight)
Fills a rectangle with rounded corners using the background color. |
void |
fillString(String s,
int x,
int y)
Draws the given string using the current font and foreground color. |
void |
fillText(String s,
int x,
int y)
Draws the given string using the current font and foreground color. |
Color |
getBackgroundColor()
Returns the background color used for filling. |
Rectangle |
getClip(Rectangle rect)
Modifies the given rectangle to match the clip region and returns that rectangle. |
Font |
getFont()
Returns the font used to draw and fill text. |
FontMetrics |
getFontMetrics()
Returns the font metrics for the current font. |
Color |
getForegroundColor()
Returns the foreground color used to draw lines and text. |
int |
getLineStyle()
Returns the line style. |
int |
getLineWidth()
Returns the current line width. |
boolean |
getXORMode()
Returns true if this graphics object should use XOR mode with painting. |
protected void |
init()
Called by constructor, initializes all State information for currentState |
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. |
void |
pushState()
Pushes the current state of this graphics object onto a stack. |
void |
restoreState()
Restores the previous state of this graphics object. |
protected void |
restoreState(SWTGraphics.State s)
Sets all State information to that of the given State, called by restoreState() |
void |
scale(double factor)
Scales this graphics object by the given amount. |
void |
setBackgroundColor(Color color)
Sets the background color. |
void |
setClip(Rectangle rect)
Sets the clip rectangle. |
protected void |
setClipAbsolute(int x,
int y,
int w,
int h)
Sets clip values to the given values. |
void |
setFont(Font f)
Sets the font. |
void |
setForegroundColor(Color color)
Sets the foreground color. |
void |
setLineStyle(int style)
Sets the line style. |
void |
setLineWidth(int width)
Sets the line width. |
protected void |
setTranslation(int x,
int y)
Sets the translation values of this to the given values |
void |
setXORMode(boolean b)
Sets the XOR mode. |
void |
translate(int x,
int y)
Translates this graphics object so that its origin is offset horizontally by dx and vertically by dy. |
| Methods inherited from class org.eclipse.draw2d.Graphics |
drawArc, drawFocus, drawImage, drawImage, drawLine, drawOval, drawRectangle, drawString, drawText, drawText, drawText, drawTextLayout, fillArc, fillGradient, fillOval, fillRectangle, fillString, fillText, getAbsoluteScale, translate |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static boolean debug
| Constructor Detail |
public SWTGraphics(GC gc)
gc - the GC| Method Detail |
protected final void checkFill()
checkGC().
protected final void checkGC()
protected final void checkPaint()
checkGC().
protected final void checkText()
checkPaint() and checkFill().
public void clipRect(Rectangle rect)
Graphics
clipRect in class Graphicsrect - the clip rectangleGraphics.clipRect(Rectangle)public void dispose()
Graphics
dispose in class GraphicsGraphics.dispose()
public void drawArc(int x,
int y,
int width,
int height,
int offset,
int length)
Graphics
drawArc in class Graphicsx - the x coordinatey - the y coordinatewidth - the widthheight - the heightoffset - the start anglelength - the length of the arcGraphics.drawArc(int, int, int, int, int, int)
public void drawFocus(int x,
int y,
int w,
int h)
Graphics
drawFocus in class Graphicsx - the x coordinatey - the y coordinatew - the widthh - the heightGraphics.drawFocus(int, int, int, int)
public void drawImage(Image srcImage,
int x,
int y)
Graphics
drawImage in class GraphicssrcImage - the Imagex - the x coordinatey - the y coordinateGraphics.drawImage(Image, int, int)
public void drawImage(Image srcImage,
int x1,
int y1,
int w1,
int h1,
int x2,
int y2,
int w2,
int h2)
Graphics
drawImage in class GraphicssrcImage - 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 destinationGraphics.drawImage(Image, int, int, int, int, int, int, int, int)
public void drawLine(int x1,
int y1,
int x2,
int y2)
Graphics(x1,y1) and (x2,y2) using the
foreground color.
drawLine in class Graphicsx1 - 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 pointGraphics.drawLine(int, int, int, int)
public void drawOval(int x,
int y,
int width,
int height)
Graphics
drawOval in class Graphicsx - the x coordinatey - the y coordinatewidth - the widthheight - the heightGraphics.drawOval(int, int, int, int)
public void drawPoint(int x,
int y)
Graphicsx, y).
Note that the receiver's line attributes do not affect this operation.
drawPoint in class Graphicsx - the point's x coordinatey - the point's y coordinateGraphics.drawPoint(int, int)public void drawPolygon(int[] points)
Graphics
drawPolygon in class Graphicspoints - the verticesGraphics.drawPolygon(int[])public void drawPolygon(PointList points)
GraphicsPointList containing the
vertices. The first and last points in the list will be connected.
drawPolygon in class Graphicspoints - the verticesGraphics.drawPolygon(PointList)public void drawPolyline(int[] points)
Graphics
drawPolyline in class Graphicspoints - the verticesGraphics.drawPolyline(int[])public void drawPolyline(PointList points)
GraphicsPointList containing the vertices.
The first and last points in the list will not be connected.
drawPolyline in class Graphicspoints - the verticesGraphics.drawPolyline(PointList)
public void drawRectangle(int x,
int y,
int width,
int height)
Graphics
drawRectangle in class Graphicsx - the x coordinatey - the y coordinatewidth - the widthheight - the heightGraphics.drawRectangle(int, int, int, int)
public void drawRoundRectangle(Rectangle r,
int arcWidth,
int arcHeight)
Graphics
drawRoundRectangle in class Graphicsr - the rectanglearcWidth - the arc widtharcHeight - the arc heightGraphics.drawRoundRectangle(Rectangle, int, int)
public void drawString(String s,
int x,
int y)
Graphics
drawString in class Graphicss - the stringx - the x coordinatey - the y coordinateGraphics.drawString(String, int, int)
public void drawText(String s,
int x,
int y)
Graphics
drawText in class Graphicss - the textx - the x coordinatey - the y coordinateGraphics.drawText(String, int, int)
public void drawTextLayout(TextLayout layout,
int x,
int y,
int selectionStart,
int selectionEnd,
Color selectionForeground,
Color selectionBackground)
drawTextLayout in class Graphicsx - 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 colorGraphics.drawTextLayout(TextLayout, int, int, int, int, Color, Color)
public void fillArc(int x,
int y,
int width,
int height,
int offset,
int length)
Graphics
fillArc in class Graphicsx - the x coordinatey - the y coordinatewidth - the widthheight - the heightoffset - the start anglelength - the length of the arcGraphics.fillArc(int, int, int, int, int, int)
public void fillGradient(int x,
int y,
int w,
int h,
boolean vertical)
Graphicstrue, the gradient will go from
top to bottom. Otherwise, it will go from left to right.
background color.
fillGradient in class Graphicsx - the x coordinatey - the y coordinatew - the widthh - the heightvertical - whether the gradient should be verticalGraphics.fillGradient(int, int, int, int, boolean)
public void fillOval(int x,
int y,
int width,
int height)
Graphics
fillOval in class Graphicsx - the x coordinatey - the y coordinatewidth - the widthheight - the heightGraphics.fillOval(int, int, int, int)public void fillPolygon(int[] points)
Graphics
fillPolygon in class Graphicspoints - the verticesGraphics.fillPolygon(int[])public void fillPolygon(PointList points)
GraphicsPointList containing the
vertices. The first and last points in the list will be connected.
fillPolygon in class Graphicspoints - the verticesGraphics.fillPolygon(PointList)
public void fillRectangle(int x,
int y,
int width,
int height)
Graphics
fillRectangle in class Graphicsx - the x coordinatey - the y coordinatewidth - the widthheight - the heightGraphics.fillRectangle(int, int, int, int)
public void fillRoundRectangle(Rectangle r,
int arcWidth,
int arcHeight)
Graphics
fillRoundRectangle in class Graphicsr - the rectanglearcWidth - the arc widtharcHeight - the arc heightGraphics.fillRoundRectangle(Rectangle, int, int)
public void fillString(String s,
int x,
int y)
Graphics
fillString in class Graphicss - the stringx - the x coordinatey - the y coordinateGraphics.fillString(String, int, int)
public void fillText(String s,
int x,
int y)
Graphics
fillText in class Graphicss - the textx - the x coordinatey - the y coordinateGraphics.fillText(String, int, int)public Color getBackgroundColor()
Graphics
getBackgroundColor in class GraphicsGraphics.getBackgroundColor()public Rectangle getClip(Rectangle rect)
Graphics
getClip in class Graphicsrect - the rectangle to hold the clip region
Graphics.getClip(Rectangle)public Font getFont()
Graphics
getFont in class GraphicsGraphics.getFont()public FontMetrics getFontMetrics()
Graphics
getFontMetrics in class GraphicsGraphics.getFontMetrics()public Color getForegroundColor()
Graphics
getForegroundColor in class GraphicsGraphics.getForegroundColor()public int getLineStyle()
Graphics
getLineStyle in class GraphicsGraphics.getLineStyle()public int getLineWidth()
Graphics
getLineWidth in class GraphicsGraphics.getLineWidth()public boolean getXORMode()
Graphicstrue if this graphics object should use XOR mode with painting.
getXORMode in class GraphicsGraphics.getXORMode()protected void init()
public void popState()
GraphicsGraphics.pushState()
has previously been called) and restores the current state to that popped state.
popState in class GraphicsGraphics.popState()public void pushState()
Graphics
pushState in class GraphicsGraphics.pushState()public void restoreState()
Graphics
restoreState in class GraphicsGraphics.restoreState()protected void restoreState(SWTGraphics.State s)
s - the Statepublic void scale(double factor)
Graphics
scale in class Graphicsfactor - the scale factorGraphics.scale(double)public void setBackgroundColor(Color color)
Graphics
setBackgroundColor in class Graphicscolor - the new background colorGraphics.setBackgroundColor(Color)public void setClip(Rectangle rect)
Graphics
setClip in class Graphicsrect - the new clip rectangleGraphics.setClip(Rectangle)
protected void setClipAbsolute(int x,
int y,
int w,
int h)
x - the X valuey - the Y valuew - the width valueh - the height valuepublic void setFont(Font f)
Graphics
setFont in class Graphicsf - the new fontGraphics.setFont(Font)public void setForegroundColor(Color color)
Graphics
setForegroundColor in class Graphicscolor - the new foreground colorGraphics.setForegroundColor(Color)public void setLineStyle(int style)
Graphics
setLineStyle in class Graphicsstyle - the new styleGraphics.setLineStyle(int)public void setLineWidth(int width)
Graphics
setLineWidth in class Graphicswidth - the new widthGraphics.setLineWidth(int)
protected void setTranslation(int x,
int y)
x - The x valuey - The y valuepublic void setXORMode(boolean b)
Graphics
setXORMode in class Graphicsb - the new XOR modeGraphics.setXORMode(boolean)
public void translate(int x,
int y)
Graphics
translate in class Graphicsx - the horizontal offsety - the vertical offsetGraphics.translate(int, int)
|
Eclipse Draw2d 3.0.1 |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||