|
GWT 2.7.0 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.google.gwt.core.client.JavaScriptObject
com.google.gwt.canvas.dom.client.Context2d
public class Context2d
Rendering interface used to draw on a CanvasElement.
| Nested Class Summary | |
|---|---|
static class |
Context2d.Composite
Enum for composite style. |
static class |
Context2d.LineCap
Enum for line-cap style. |
static class |
Context2d.LineJoin
Enum for line-join style. |
static class |
Context2d.Repetition
Enum for the repetition values. |
static class |
Context2d.TextAlign
Enum for text align style. |
static class |
Context2d.TextBaseline
Enum for text baseline style. |
| Field Summary | |
|---|---|
static java.lang.String |
CONTEXT_ID
Specifies the context id property used in creating a Context. |
| Constructor Summary | |
|---|---|
protected |
Context2d()
|
| Method Summary | |
|---|---|
void |
arc(double x,
double y,
double radius,
double startAngle,
double endAngle)
Draws an arc. |
void |
arc(double x,
double y,
double radius,
double startAngle,
double endAngle,
boolean anticlockwise)
Draws an arc. |
void |
arcTo(double x1,
double y1,
double x2,
double y2,
double radius)
Adds an arc to the current subpath, connecting it to the current point with a line segment. |
void |
beginPath()
Begins a new path. |
void |
bezierCurveTo(double cp1x,
double cp1y,
double cp2x,
double cp2y,
double x,
double y)
Draws a cubic Bézier curve from the current point to the point (x, y), with control points (cp1x, cp1y) and (cp2x, cp2y). |
void |
clearRect(double x,
double y,
double w,
double h)
Clears a rectangle. |
void |
clip()
Creates a new clipping region from the current path. |
void |
closePath()
Closes the current path. |
ImageData |
createImageData(ImageData imagedata)
Creates an image data object of the same size as the given object. |
ImageData |
createImageData(int w,
int h)
Creates an image data object of the given size. |
CanvasGradient |
createLinearGradient(double x0,
double y0,
double x1,
double y1)
Creates a linear gradient. |
CanvasPattern |
createPattern(CanvasElement image,
Context2d.Repetition repetition)
Creates a pattern from another canvas. |
CanvasPattern |
createPattern(CanvasElement image,
java.lang.String repetition)
Creates a pattern from another canvas. |
CanvasPattern |
createPattern(ImageElement image,
Context2d.Repetition repetition)
Creates a pattern from an image. |
CanvasPattern |
createPattern(ImageElement image,
java.lang.String repetition)
Creates a pattern from an image. |
CanvasGradient |
createRadialGradient(double x0,
double y0,
double r0,
double x1,
double y1,
double r1)
Creates a radial gradient. |
void |
drawImage(CanvasElement image,
double dx,
double dy)
Draws an image. |
void |
drawImage(CanvasElement image,
double dx,
double dy,
double dw,
double dh)
Draws a scaled image. |
void |
drawImage(CanvasElement image,
double sx,
double sy,
double sw,
double sh,
double dx,
double dy,
double dw,
double dh)
Draws a scaled subset of an image. |
void |
drawImage(ImageElement image,
double dx,
double dy)
Draws an image. |
void |
drawImage(ImageElement image,
double dx,
double dy,
double dw,
double dh)
Draws a scaled image. |
void |
drawImage(ImageElement image,
double sx,
double sy,
double sw,
double sh,
double dx,
double dy,
double dw,
double dh)
Draws a scaled subset of an image. |
void |
drawImage(VideoElement image,
double dx,
double dy)
Draws a video's current frame. |
void |
drawImage(VideoElement image,
double dx,
double dy,
double dw,
double dh)
Draws a scaled video's current frame. |
void |
drawImage(VideoElement image,
double sx,
double sy,
double sw,
double sh,
double dx,
double dy,
double dw,
double dh)
Draws a scaled subset of a video's current frame. |
void |
fill()
Fills the current path. |
void |
fillRect(double x,
double y,
double w,
double h)
Fills a rectangle. |
void |
fillText(java.lang.String text,
double x,
double y)
Draws filled text. |
void |
fillText(java.lang.String text,
double x,
double y,
double maxWidth)
Draws filled text squeezed into the given max width. |
CanvasElement |
getCanvas()
Gets this context's canvas. |
FillStrokeStyle |
getFillStyle()
Returns the context's fillStyle. |
java.lang.String |
getFont()
Gets this context's font. |
double |
getGlobalAlpha()
Gets the global alpha value. |
java.lang.String |
getGlobalCompositeOperation()
Gets the global composite operation. |
ImageData |
getImageData(double sx,
double sy,
double sw,
double sh)
Returns an image data object for the screen area denoted by sx, sy, sw and sh. |
java.lang.String |
getLineCap()
Gets the current line-cap style. |
java.lang.String |
getLineJoin()
Gets the current line-join style. |
double |
getLineWidth()
Gets the current line-width. |
double |
getMiterLimit()
Gets the current miter-limit. |
double |
getShadowBlur()
Gets the current shadow-blur. |
java.lang.String |
getShadowColor()
Gets the current shadow color. |
double |
getShadowOffsetX()
Gets the current x-shadow-offset. |
double |
getShadowOffsetY()
Gets the current y-shadow-offset. |
FillStrokeStyle |
getStrokeStyle()
Returns the context's strokeStyle. |
java.lang.String |
getTextAlign()
Gets the current text align. |
java.lang.String |
getTextBaseline()
Gets the current text baseline. |
boolean |
isPointInPath(double x,
double y)
Returns true if the given point is in the current path. |
void |
lineTo(double x,
double y)
Adds a line from the current point to the point (x, y) to the current path. |
TextMetrics |
measureText(java.lang.String text)
Returns the metrics for the given text. |
void |
moveTo(double x,
double y)
Terminates the current path and sets the current path position to the point (x, y). |
void |
putImageData(ImageData imagedata,
double x,
double y)
Draws the given image data at the given screen position. |
void |
quadraticCurveTo(double cpx,
double cpy,
double x,
double y)
Draws a quadratic Bézier curve from the current point to the point (x, y), with control point (cpx, cpy). |
void |
rect(double x,
double y,
double w,
double h)
Creates a new rectangular path. |
void |
restore()
Restores the context's state. |
void |
rotate(double angle)
Applies rotation to the current transform. |
void |
save()
Saves the context's state. |
void |
scale(double x,
double y)
Applies scale to the current transform. |
void |
setFillStyle(FillStrokeStyle fillStyle)
Sets the context's fillStyle. |
void |
setFillStyle(java.lang.String fillStyleColor)
Convenience method to set the context's fillStyle to a CssColor,
specified in String form. |
void |
setFont(java.lang.String f)
Sets the font. |
void |
setGlobalAlpha(double alpha)
Sets the global alpha value. |
void |
setGlobalCompositeOperation(Context2d.Composite composite)
Sets the global composite operation. |
void |
setGlobalCompositeOperation(java.lang.String globalCompositeOperation)
Sets the global composite operation. |
void |
setLineCap(Context2d.LineCap lineCap)
Sets the line-cap style. |
void |
setLineCap(java.lang.String lineCap)
Sets the line-cap style. |
void |
setLineJoin(Context2d.LineJoin lineJoin)
Sets the line-join style. |
void |
setLineJoin(java.lang.String lineJoin)
Sets the line-join style. |
void |
setLineWidth(double lineWidth)
Sets the line-width. |
void |
setMiterLimit(double miterLimit)
Sets the miter-limit. |
void |
setShadowBlur(double shadowBlur)
Sets the shadow-blur. |
void |
setShadowColor(java.lang.String shadowColor)
Sets the shadow-color. |
void |
setShadowOffsetX(double shadowOffsetX)
Sets the x-shadow-offset. |
void |
setShadowOffsetY(double shadowOffsetY)
Sets the y-shadow-offset. |
void |
setStrokeStyle(FillStrokeStyle strokeStyle)
Sets the context's stroke style. |
void |
setStrokeStyle(java.lang.String strokeStyleColor)
Convenience method to set the context's strokeStyle to a CssColor. |
void |
setTextAlign(Context2d.TextAlign align)
Sets the text alignment. |
void |
setTextAlign(java.lang.String align)
Sets the text alignment. |
void |
setTextBaseline(Context2d.TextBaseline baseline)
Sets the text baseline. |
void |
setTextBaseline(java.lang.String baseline)
Sets the text baseline. |
void |
setTransform(double m11,
double m12,
double m21,
double m22,
double dx,
double dy)
Sets the 2D transformation matrix. |
void |
stroke()
Draws the current path with the current stroke style. |
void |
strokeRect(double x,
double y,
double w,
double h)
Draws the outline of a rectangle with the current stroke style. |
void |
strokeText(java.lang.String text,
double x,
double y)
Draws the text outline. |
void |
strokeText(java.lang.String text,
double x,
double y,
double maxWidth)
Draws the text outline, squeezing the text into the given max width by compressing the font. |
void |
transform(double m11,
double m12,
double m21,
double m22,
double dx,
double dy)
Multiplies the current transform by the given matrix. |
void |
translate(double x,
double y)
Applies a translation to the current transform. |
| Methods inherited from class com.google.gwt.core.client.JavaScriptObject |
|---|
cast, createArray, createArray, createFunction, createObject, equals, hashCode, toSource, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String CONTEXT_ID
| Constructor Detail |
|---|
protected Context2d()
| Method Detail |
|---|
public final void arc(double x,
double y,
double radius,
double startAngle,
double endAngle)
endAngle -
startAngle is equal to or greater than 2 * Math.Pi, the arc is the
whole circumference of the circle.
x - the x coordinate of the center of the arcy - the y coordinate of the center of the arcradius - the radius of the arcstartAngle - the start angle, measured in radians clockwise from the
positive x-axisendAngle - the end angle, measured in radians clockwise from the
positive x-axis
public final void arc(double x,
double y,
double radius,
double startAngle,
double endAngle,
boolean anticlockwise)
anticlockwise is
false and endAngle - startAngle is equal to or greater than 2 * Math.PI, or if anticlockwise is true and startAngle - endAngle is equal to or greater than 2 * Math.PI,
then the arc is the whole circumference of the circle.
x - the x coordinate of the center of the arcy - the y coordinate of the center of the arcradius - the radius of the arcstartAngle - the start angle, measured in radians clockwise from the
positive x-axisendAngle - the end angle, measured in radians clockwise from the
positive x-axisanticlockwise - if true, the arc is drawn in an anticlockwise
direction
public final void arcTo(double x1,
double y1,
double x2,
double y2,
double radius)
x1 - the x coordinate of the starting point of the arcy1 - the y coordinate of the starting point of the arcx2 - the x coordinate of the ending point of the arcy2 - the y coordinate of the ending point of the arcradius - the radius of a circle containing the arcpublic final void beginPath()
public final void bezierCurveTo(double cp1x,
double cp1y,
double cp2x,
double cp2y,
double x,
double y)
cp1x - the x coordinate of the first control pointcp1y - the y coordinate of the first control pointcp2x - the x coordinate of the second control pointcp2y - the y coordinate of the second control pointx - the x coordinate of the end pointy - the y coordinate of the end point
public final void clearRect(double x,
double y,
double w,
double h)
x - the x coordinate of the rectangle's upper-left cornery - the y coordinate of the rectangle's upper-left cornerw - the width of the rectangleh - the height of the rectanglepublic final void clip()
public final void closePath()
public final ImageData createImageData(ImageData imagedata)
imagedata - an ImageData object
ImageData object
public final ImageData createImageData(int w,
int h)
w - the width of the imageh - the height of the image
ImageData object
public final CanvasGradient createLinearGradient(double x0,
double y0,
double x1,
double y1)
x0 - the x coordinate of the starting point of the gradienty0 - the y coordinate of the starting point of the gradientx1 - the x coordinate of the ending point of the gradienty1 - the y coordinate of the ending point of the gradient
CanvasGradient object
public final CanvasPattern createPattern(CanvasElement image,
Context2d.Repetition repetition)
image - an CanvasElement objectrepetition - a Context2d.Repetition object
CanvasPattern object
public final CanvasPattern createPattern(CanvasElement image,
java.lang.String repetition)
image - an CanvasElement objectrepetition - the repetition type as a String
CanvasPattern object
public final CanvasPattern createPattern(ImageElement image,
Context2d.Repetition repetition)
image - an ImageElement objectrepetition - a Context2d.Repetition object
CanvasPattern object
public final CanvasPattern createPattern(ImageElement image,
java.lang.String repetition)
image - an ImageElement objectrepetition - the repetition type as a String
CanvasPattern object
public final CanvasGradient createRadialGradient(double x0,
double y0,
double r0,
double x1,
double y1,
double r1)
x0 - the x coordinate of the center of the start circle of the gradienty0 - the y coordinate of the center of the start circle of the gradientr0 - the radius of the start circle of the gradientx1 - the x coordinate of the center of the end circle of the gradienty1 - the y coordinate of the center of the end circle of the gradientr1 - the radius of the end circle of the gradient
CanvasGradient object
public final void drawImage(CanvasElement image,
double dx,
double dy)
image - an CanvasElement objectdx - the x coordinate of the upper-left corner of the destination rectangledy - the y coordinate of the upper-left corner of the destination rectangle
public final void drawImage(CanvasElement image,
double dx,
double dy,
double dw,
double dh)
image - an CanvasElement objectdx - the x coordinate of the upper-left corner of the destination rectangledy - the y coordinate of the upper-left corner of the destination rectangledw - the width of the destination rectangledh - the height of the destination rectangle
public final void drawImage(CanvasElement image,
double sx,
double sy,
double sw,
double sh,
double dx,
double dy,
double dw,
double dh)
image - an CanvasElement objectsx - the x coordinate of the upper-left corner of the source rectanglesy - the y coordinate of the upper-left corner of the source rectanglesw - the width of the source rectanglesh - the width of the source rectangledx - the x coordinate of the upper-left corner of the destination rectangledy - the y coordinate of the upper-left corner of the destination rectangledw - the width of the destination rectangledh - the height of the destination rectangle
public final void drawImage(ImageElement image,
double dx,
double dy)
image - an ImageElement objectdx - the x coordinate of the upper-left corner of the destination rectangledy - the y coordinate of the upper-left corner of the destination rectangle
public final void drawImage(ImageElement image,
double dx,
double dy,
double dw,
double dh)
image - an ImageElement objectdx - the x coordinate of the upper-left corner of the destination rectangledy - the y coordinate of the upper-left corner of the destination rectangledw - the width of the destination rectangledh - the height of the destination rectangle
public final void drawImage(ImageElement image,
double sx,
double sy,
double sw,
double sh,
double dx,
double dy,
double dw,
double dh)
image - an ImageElement objectsx - the x coordinate of the upper-left corner of the source rectanglesy - the y coordinate of the upper-left corner of the source rectanglesw - the width of the source rectanglesh - the width of the source rectangledx - the x coordinate of the upper-left corner of the destination rectangledy - the y coordinate of the upper-left corner of the destination rectangledw - the width of the destination rectangledh - the height of the destination rectangle
public final void drawImage(VideoElement image,
double dx,
double dy)
image - a VideoElement objectdx - the x coordinate of the upper-left corner of the destination rectangledy - the y coordinate of the upper-left corner of the destination rectangle
public final void drawImage(VideoElement image,
double dx,
double dy,
double dw,
double dh)
image - a VideoElement objectdx - the x coordinate of the upper-left corner of the destination rectangledy - the y coordinate of the upper-left corner of the destination rectangledw - the width of the destination rectangledh - the height of the destination rectangle
public final void drawImage(VideoElement image,
double sx,
double sy,
double sw,
double sh,
double dx,
double dy,
double dw,
double dh)
image - a VideoElement objectsx - the x coordinate of the upper-left corner of the source rectanglesy - the y coordinate of the upper-left corner of the source rectanglesw - the width of the source rectanglesh - the width of the source rectangledx - the x coordinate of the upper-left corner of the destination rectangledy - the y coordinate of the upper-left corner of the destination rectangledw - the width of the destination rectangledh - the height of the destination rectanglepublic final void fill()
public final void fillRect(double x,
double y,
double w,
double h)
x - the x coordinate of the rectangle's upper-left cornery - the y coordinate of the rectangle's upper-left cornerw - the width of the rectangleh - the height of the rectangle
public final void fillText(java.lang.String text,
double x,
double y)
text - the text as a Stringx - the x coordinate of the text positiony - the y coordinate of the text position
public final void fillText(java.lang.String text,
double x,
double y,
double maxWidth)
text - the text as a Stringx - the x coordinate of the text positiony - the y coordinate of the text positionmaxWidth - the maximum width for the textpublic final CanvasElement getCanvas()
CanvasElement objectpublic final FillStrokeStyle getFillStyle()
FillStrokeStyle objectsetFillStyle(FillStrokeStyle),
setFillStyle(String),
CssColorpublic final java.lang.String getFont()
setFont(String)public final double getGlobalAlpha()
setGlobalAlpha(double)public final java.lang.String getGlobalCompositeOperation()
setGlobalCompositeOperation(Composite),
setGlobalCompositeOperation(String)
public final ImageData getImageData(double sx,
double sy,
double sw,
double sh)
sx - the x coordinate of the upper-left corner of the desired areasy - the y coordinate of the upper-left corner of the desired areasw - the width of the desired areash - the height of the desired area
ImageData object containing screen pixel datapublic final java.lang.String getLineCap()
setLineCap(LineCap),
setLineCap(String)public final java.lang.String getLineJoin()
setLineJoin(LineJoin),
setLineJoin(String)public final double getLineWidth()
setLineWidth(double)public final double getMiterLimit()
setMiterLimit(double)public final double getShadowBlur()
setShadowBlur(double)public final java.lang.String getShadowColor()
setShadowColor(String)public final double getShadowOffsetX()
setShadowOffsetX(double),
getShadowOffsetY()public final double getShadowOffsetY()
setShadowOffsetY(double),
getShadowOffsetX()public final FillStrokeStyle getStrokeStyle()
FillStrokeStyle objectsetStrokeStyle(FillStrokeStyle),
setStrokeStyle(String),
CssColorpublic final java.lang.String getTextAlign()
setTextAlign(TextAlign),
setTextAlign(String)public final java.lang.String getTextBaseline()
setTextBaseline(TextBaseline),
setTextBaseline(String)
public final boolean isPointInPath(double x,
double y)
x - the x coordinate of the point to test.y - the y coordinate of the point to test.
true if the given point is in the current path.
public final void lineTo(double x,
double y)
x - the x coordinate of the line endpointy - the y coordinate of the line endpointpublic final TextMetrics measureText(java.lang.String text)
text - the text to measure, as a String
TextMetrics object
public final void moveTo(double x,
double y)
x - the x coordinate of the new positiony - the y coordinate of the new position
public final void putImageData(ImageData imagedata,
double x,
double y)
imagedata - an ImageData instance to be written to the screenx - the x coordinate of the upper-left corner at which to drawy - the y coordinate of the upper-left corner at which to draw
public final void quadraticCurveTo(double cpx,
double cpy,
double x,
double y)
cpx - the x coordinate of the control pointcpy - the y coordinate of the control pointx - the x coordinate of the end pointy - the y coordinate of the end point
public final void rect(double x,
double y,
double w,
double h)
x - the x coordinate of the rectangle's upper-left cornery - the y coordinate of the rectangle's upper-left cornerw - the width of the rectangleh - the height of the rectanglepublic final void restore()
public final void rotate(double angle)
angle - the clockwise rotation angle, in radianspublic final void save()
public final void scale(double x,
double y)
x - the scale factor along the x-axisy - the scale factor along the y-axispublic final void setFillStyle(FillStrokeStyle fillStyle)
fillStyle - the fill style to set.getFillStyle(),
CssColorpublic final void setFillStyle(java.lang.String fillStyleColor)
CssColor,
specified in String form.
fillStyleColor - the color as a StringgetFillStyle()public final void setFont(java.lang.String f)
f - the font name as a StringgetFont()public final void setGlobalAlpha(double alpha)
alpha - the global alpha value as a doublegetGlobalAlpha()public final void setGlobalCompositeOperation(Context2d.Composite composite)
composite - a Context2d.Composite valuegetGlobalCompositeOperation()public final void setGlobalCompositeOperation(java.lang.String globalCompositeOperation)
globalCompositeOperation - the operation as a StringgetGlobalCompositeOperation()public final void setLineCap(Context2d.LineCap lineCap)
lineCap - the line cap style as a Context2d.LineCap valuegetLineCap()public final void setLineCap(java.lang.String lineCap)
lineCap - the line cap style as a StringgetLineCap()public final void setLineJoin(Context2d.LineJoin lineJoin)
lineJoin - the line join style as a Context2d.LineJoin valuegetLineJoin()public final void setLineJoin(java.lang.String lineJoin)
lineJoin - the ling join style as a StringgetLineJoin()public final void setLineWidth(double lineWidth)
lineWidth - the line width as a doublegetMiterLimit(),
getLineWidth()public final void setMiterLimit(double miterLimit)
miterLimit - the miter limit as a doublegetMiterLimit()public final void setShadowBlur(double shadowBlur)
shadowBlur - the amount of blur as a doublegetShadowBlur()public final void setShadowColor(java.lang.String shadowColor)
shadowColor - the shadow color as a StringgetShadowColor()public final void setShadowOffsetX(double shadowOffsetX)
shadowOffsetX - the x shadow offsetgetShadowOffsetX(),
getShadowOffsetY()public final void setShadowOffsetY(double shadowOffsetY)
shadowOffsetY - the y shadow offsetgetShadowOffsetX(),
getShadowOffsetY()public final void setStrokeStyle(FillStrokeStyle strokeStyle)
strokeStyle - the stroke style to setgetStrokeStyle(),
CssColorpublic final void setStrokeStyle(java.lang.String strokeStyleColor)
CssColor.
strokeStyleColor - the stroke color as a StringgetStrokeStyle()public final void setTextAlign(java.lang.String align)
align - the alignment setting as a StringgetTextAlign()public final void setTextAlign(Context2d.TextAlign align)
align - the alignment setting as a Context2d.TextAlign valuegetTextAlign()public final void setTextBaseline(java.lang.String baseline)
baseline - the baseline setting as a StringgetTextBaseline()public final void setTextBaseline(Context2d.TextBaseline baseline)
baseline - a the baseline setting as a Context2d.TextBaseline valuegetTextBaseline()
public final void setTransform(double m11,
double m12,
double m21,
double m22,
double dx,
double dy)
m11 - the value at position (1, 1) of the matrixm12 - the value at position (1, 2) of the matrixm21 - the value at position (2, 1) of the matrixm22 - the value at position (2, 2) of the matrixdx - the x translation valuedy - the y translation valuepublic final void stroke()
public final void strokeRect(double x,
double y,
double w,
double h)
x - the x coordinate of the rectangle's upper-left cornery - the y coordinate of the rectangle's upper-left cornerw - the width of the rectangleh - the height of the rectangle
public final void strokeText(java.lang.String text,
double x,
double y)
text - the text as a Stringx - the x coordinate of the text positiony - the y coordinate of the text position
public final void strokeText(java.lang.String text,
double x,
double y,
double maxWidth)
text - the text as a Stringx - the x coordinate of the text positiony - the y coordinate of the text positionmaxWidth - the maximum width for the text
public final void transform(double m11,
double m12,
double m21,
double m22,
double dx,
double dy)
m11 - the value at position (1, 1) of the matrixm12 - the value at position (1, 2) of the matrixm21 - the value at position (2, 1) of the matrixm22 - the value at position (2, 2) of the matrixdx - the x translation valuedy - the y translation value
public final void translate(double x,
double y)
x - the amount of translation along the x-axisy - the amount of translation along the y-axis
|
GWT 2.7.0 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||