public class RenderingContext2D extends RenderingContextBase
| Constructor and Description |
|---|
RenderingContext2D(BaseCanvasComponent<?,?> canvas) |
| Modifier and Type | Method and Description |
|---|---|
void |
arc(double x,
double y,
double radius,
double startAngle,
double endAngle)
Adds an arc to the path which is centered at (x, y) position with radius r starting at
startAngle and ending at endAngle going in the given direction by anticlockwise.
|
void |
arc(double x,
double y,
double radius,
double startAngle,
double endAngle,
boolean anticlockwise)
Adds an arc to the path which is centered at (x, y) position with radius r starting at
startAngle and ending at endAngle going in the given direction by anticlockwise.
|
void |
arcTo(double x1,
double y1,
double x2,
double y2,
double radius)
Adds an arc to the path with the given control points and radius.
|
void |
beginPath()
Starts a new path by emptying the list of sub-paths.
|
void |
bezierCurveTo(double cp1x,
double cp1y,
double cp2x,
double cp2y,
double x,
double y)
Adds a cubic Bézier curve to the path.
|
void |
clearRect(double x,
double y,
double width,
double height)
Sets all pixels in the rectangle defined by starting point (x, y) and size (width, height) to
transparent black, erasing any previously drawn content.
|
void |
clip()
Turns the path currently being built into the current clipping path.
|
void |
clip(FillRule fillRule)
Turns the path currently being built into the current clipping path.
|
void |
closePath()
Causes the point of the pen to move back to the start of the current sub-path.
|
void |
createImageData(double height,
double width)
Creates a new, blank ImageData object with the specified dimensions.
|
CanvasGradient |
createLinearGradient(double x0,
double y0,
double x1,
double y1)
Creates a gradient along the line given by the coordinates represented by the parameters.
|
CanvasPattern |
createPattern(Image image,
Repetition repetition)
Creates a pattern using the specified image.
|
CanvasGradient |
createRadialGradient(double x0,
double y0,
double r0,
double x1,
double y1,
double r1)
Creates a radial gradient given by the coordinates of the two circles represented by the
parameters.
|
void |
fill()
Fills the current or given path with the current fill style using the non-zero winding rule.
|
void |
fill(FillRule fillRule)
Fills the current or given path with the current fill style using the specified winding rule.
|
void |
fillRect(double x,
double y,
double width,
double height)
Draws a filled rectangle whose starting point is at the coordinates (x, y) with the specified
width and height and whose style is determined by the fillStyle attribute.
|
void |
fillText(String text,
double x,
double y)
Draws a text string at the specified coordinates, filling the string's characters with the
current foreground color.
|
void |
fillText(String text,
double x,
double y,
Integer maxWidth)
Draws a text string at the specified coordinates, filling the string's characters with the
current foreground color.
|
Object |
getFillStyle()
Returns the color or style to use inside shapes.
|
String |
getFont()
Returns the current text style being used when drawing text.
|
double |
getGlobalAlpha()
Returns the alpha value that is applied to shapes and images before they are drawn onto the
canvas.
|
CompositeOperation |
getGlobalCompositeOperation()
Returns the type of compositing operation to apply when drawing new shapes, where type is a
string identifying which of the compositing or blending mode operations to use.
|
LineCap |
getLineCap()
Returns the line cap style.
|
double |
getLineDashOffset()
A float specifying the amount of the offset.
|
LineJoin |
getLineJoin()
Returns the line join behavior.
|
double |
getLineWidth()
Returns the thickness of lines in space units.
|
double |
getMiterLimit()
Returns a number specifying the miter limit ratio in space units.
|
double |
getShadowBlur()
Returns the level of the blurring effect.
|
String |
getShadowColor()
Returns the shadow color.
|
double |
getShadowOffsetX()
Returns the distance that the shadow will be offset in horizontal distance.
|
double |
getShadowOffsetY()
Returns the distance that the shadow will be offset in vertical distance.
|
Object |
getStrokeStyle()
Returns the color, gradient or style to use for the lines around shapes.
|
TextAlign |
getTextAlign()
Returns the current text alignment being used when drawing text.
|
TextBaseline |
getTextBaseline()
Returns the current text baseline being used when drawing text.
|
void |
lineTo(double x,
double y)
Connects the last point in the sub-path to the x, y coordinates with a straight line (but
does not actually draw it).
|
void |
moveTo(double x,
double y)
Moves the starting point of a new sub-path to the (x, y) coordinates.
|
void |
quadraticCurveTo(double cpx,
double cpy,
double x,
double y) |
void |
rect(double x,
double y,
double width,
double height)
Creates a path for a rectangle at position (x, y) with a size that is determined by width and
height.
|
void |
restore()
Restores the most recently saved canvas state by popping the top entry in the drawing state
stack.
|
void |
rotateDegrees(double angle)
Adds a rotation to the transformation matrix.
|
void |
rotateRadians(double angle)
Adds a rotation to the transformation matrix.
|
void |
save()
Saves the entire state of the canvas by pushing the current state onto a stack.
|
void |
scale(double x,
double y)
Adds a scaling transformation to the canvas units by x horizontally and by y vertically.
|
void |
setFillStyle(CanvasGradient gradient)
Sets the fill style using a canvas gradient.
|
void |
setFillStyle(CanvasPattern pattern)
Sets the fill style using a canvas pattern.
|
void |
setFillStyle(String color)
Sets the fill style using a color.
|
void |
setFont(String font)
Sets the current text style to be used when drawing text.
|
void |
setGlobalAlpha(double globalAlpha)
Sets the alpha value that is applied to shapes and images before they are drawn onto the
canvas.
|
void |
setGlobalCompositeOperation(CompositeOperation globalCompositeOperation)
Sets the type of compositing operation to apply when drawing new shapes, where type is a
string identifying which of the compositing or blending mode operations to use.
|
void |
setLineCap(LineCap lineCap)
Sets the line cap style.
|
void |
setLineDash(double[] segments)
Sets the line dash pattern used when stroking lines, using an array of values which specify
alternating lengths of lines and gaps which describe the pattern.
|
void |
setLineDashOffset(double lineDashOffset)
A float specifying the amount of the offset.
|
void |
setLineJoin(LineJoin lineJoin)
Sets the line join behavior.
|
void |
setLineWidth(double lineWidth)
Sets the thickness of lines in space units.
|
void |
setMiterLimit(double miterLimit)
Specifies the miter limit ratio in space units.
|
void |
setShadowBlur(double shadowBlur)
Sets the level of the blurring effect.
|
void |
setShadowColor(String shadowColor)
Sets the shadow color.
|
void |
setShadowOffsetX(double shadowOffsetX)
Sets the distance that the shadow will be offset in horizontal distance.
|
void |
setShadowOffsetY(double shadowOffsetY)
Sets the distance that the shadow will be offset in vertical distance.
|
void |
setStrokeStyle(CanvasGradient gradient)
Sets the gradient to use for the lines around shapes.
|
void |
setStrokeStyle(CanvasPattern pattern)
Sets the pattern to use for the lines around shapes.
|
void |
setStrokeStyle(String color)
Sets the color to use for the lines around shapes.
|
void |
setTextAlign(TextAlign textAlign)
Sets the current text alignment being used when drawing text.
|
void |
setTextBaseline(TextBaseline textBaseline)
Sets the current text baseline being used when drawing text.
|
void |
setTransform(double a,
double b,
double c,
double d,
double dx,
double dy)
Resets (overrides) the current transformation to the identity matrix and then invokes a
transformation described by the arguments of this method.
|
void |
stroke()
Strokes the current or given path with the current stroke style using the non-zero winding
rule.
|
void |
strokeRect(double x,
double y,
double width,
double height)
Paints a rectangle which has a starting point at (x, y) and has a w width and an h height
onto the canvas, using the current stroke style.
|
void |
strokeText(String text,
double x,
double y)
Draws the outlines of the characters of a specified text string at the given (x, y) position.
|
void |
strokeText(String text,
double x,
double y,
double maxWidth)
Draws the outlines of the characters of a specified text string at the given (x, y) position.
|
void |
transform(double a,
double b,
double c,
double d,
double dx,
double dy)
Multiplies the current transformation with the matrix described by the arguments of this
method.
|
void |
translate(double x,
double y)
Adds a translation transformation by moving the canvas and its origin x horizontally and y
vertically on the grid.
|
getTypecallback, config, config, destroy, finalize, getCanvas, init, init, initResource, invoke, invoke, transformForClientpublic RenderingContext2D(BaseCanvasComponent<?,?> canvas)
public void arc(double x,
double y,
double radius,
double startAngle,
double endAngle)
x - The x coordinate of the arc's center.y - The y coordinate of the arc's center.radius - The arc's radius.startAngle - The angle at which the arc starts, measured clockwise from the positive x
axis and expressed in radians.endAngle - The angle at which the arc ends, measured clockwise from the positive x axis
and expressed in radians.public void arc(double x,
double y,
double radius,
double startAngle,
double endAngle,
boolean anticlockwise)
x - The x coordinate of the arc's center.y - The y coordinate of the arc's center.radius - The arc's radius.startAngle - The angle at which the arc starts, measured clockwise from the positive x
axis and expressed in radians.endAngle - The angle at which the arc ends, measured clockwise from the positive x axis
and expressed in radians.anticlockwise - if true, causes the arc to be drawn counter-clockwise between the two
angles.public void arcTo(double x1,
double y1,
double x2,
double y2,
double radius)
x1 - x-axis coordinates for the first control point.y1 - y-axis coordinates for the first control point.x2 - x-axis coordinates for the second control point.y2 - y-axis coordinates for the second control point.radius - The arc's radius.public void beginPath()
public void bezierCurveTo(double cp1x,
double cp1y,
double cp2x,
double cp2y,
double x,
double y)
cp1x - The x axis of the coordinate for the first control point.cp1y - The y axis of the coordinate for the first control point.cp2x - The x axis of the coordinate for the second control point.cp2y - The y axis of the coordinate for the second control point.x - The x axis of the coordinate for the end point.y - The y axis of the coordinate for the end point.public void clearRect(double x,
double y,
double width,
double height)
x - The x axis of the coordinate for the rectangle starting point.y - The y axis of the coordinate for the rectangle starting point.width - The rectangle's width.height - The rectangle's height.public void clip()
public void clip(FillRule fillRule)
fillRule - The fill rule.public void closePath()
public void createImageData(double height,
double width)
height - The image height.width - The image width.public CanvasGradient createLinearGradient(double x0, double y0, double x1, double y1)
x0 - The x axis of the coordinate of the start point.y0 - The y axis of the coordinate of the start point.x1 - The x axis of the coordinate of the end point.y1 - The y axis of the coordinate of the end point.public CanvasPattern createPattern(Image image, Repetition repetition)
image - The image to repeat.repetition - The repetition.public CanvasGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1)
x0 - The x axis of the coordinate of the start circle.y0 - The y axis of the coordinate of the start circle.r0 - The radius of the start circle.x1 - The x axis of the coordinate of the end circle.y1 - The y axis of the coordinate of the end circle.r1 - The radius of the end circle.public void fill()
public void fill(FillRule fillRule)
fillRule - The fill rule.public void fillRect(double x,
double y,
double width,
double height)
x - The x component of the coordinates for the rectangle's starting point.y - The y component of the coordinates for the rectangle's starting point.width - The rectangle's width.height - The rectangle's height.public void fillText(String text, double x, double y)
text - The text string to render into the context. The text is rendered using the
settings specified by font, textAlign, textBaseline, and direction.x - The x-coordinate of the point at which to begin drawing the text, in pixels.y - The y-coordinate of the point at which to begin drawing the text, in pixels.public void fillText(String text, double x, double y, Integer maxWidth)
text - The text string to render into the context. The text is rendered using the
settings specified by font, textAlign, textBaseline, and direction.x - The x-coordinate of the point at which to begin drawing the text, in pixels.y - The y-coordinate of the point at which to begin drawing the text, in pixels.maxWidth - The maximum number of pixels wide the string may be once rendered. If not
specified, there is no limit to the width of the string. However, if this value is
provided, the user agent will adjust the kerning, select a more horizontally
condensed font (if one is available or can be generated without loss of quality),
or scale down to a smaller font size in order to fit the text in the specified
width.public Object getFillStyle()
public String getFont()
public double getGlobalAlpha()
public CompositeOperation getGlobalCompositeOperation()
public LineCap getLineCap()
public double getLineDashOffset()
public LineJoin getLineJoin()
public double getLineWidth()
public double getMiterLimit()
public double getShadowBlur()
public String getShadowColor()
public double getShadowOffsetX()
Default: 0
public double getShadowOffsetY()
Default: 0
public Object getStrokeStyle()
Default: "#000" (black).
public TextAlign getTextAlign()
public TextBaseline getTextBaseline()
public void lineTo(double x,
double y)
x - The x axis of the coordinate for the end of the line.y - The y axis of the coordinate for the end of the line.public void moveTo(double x,
double y)
x - The x axis of the point.y - The y axis of the point.public void quadraticCurveTo(double cpx,
double cpy,
double x,
double y)
cpx - The x axis of the coordinate for the control point.cpy - The y axis of the coordinate for the control point.x - The x axis of the coordinate for the end point.y - The y axis of the coordinate for the end point.public void rect(double x,
double y,
double width,
double height)
x - The x coordinate for the left side of the rectangle.y - The y coordinate for the left side of the rectangle.width - The rectangle's width.height - The rectangle's height.public void restore()
public void rotateDegrees(double angle)
angle - The angle to rotate clockwise in radians.public void rotateRadians(double angle)
angle - The angle to rotate clockwise in radians.public void save()
public void scale(double x,
double y)
By default, one unit on the canvas is exactly one pixel. If we apply, for instance, a scaling factor of 0.5, the resulting unit would become 0.5 pixels and so shapes would be drawn at half size. In a similar way setting the scaling factor to 2.0 would increase the unit size and one unit now becomes two pixels. This results in shapes being drawn twice as large.
x - Scaling factor in the horizontal direction.y - Scaling factor in the vertical direction.public void setFillStyle(CanvasGradient gradient)
gradient - The canvas gradient to use as the fill style.public void setFillStyle(CanvasPattern pattern)
pattern - The canvas pattern to use as the fill style.public void setFillStyle(String color)
color - The color to use as the fill style.public void setFont(String font)
font - The current text style to be used when drawing text.public void setGlobalAlpha(double globalAlpha)
globalAlpha - The global alpha value.public void setGlobalCompositeOperation(CompositeOperation globalCompositeOperation)
globalCompositeOperation - The global compositing operation.public void setLineCap(LineCap lineCap)
lineCap - The line cap style.public void setLineDash(double[] segments)
segments - An array of numbers which specify distances to alternately draw a line and a
gap (in coordinate space units). If the number of elements in the array is odd,
the elements of the array get copied and concatenated. For example, [5, 15, 25]
will become [5, 15, 25, 5, 15, 25]. If the array is empty, the line dash list is
cleared and line strokes return to being solid.public void setLineDashOffset(double lineDashOffset)
lineDashOffset - The amount of the offset.public void setLineJoin(LineJoin lineJoin)
lineJoin - The line join behavior.public void setLineWidth(double lineWidth)
lineWidth - The thickness of lines in space units.public void setMiterLimit(double miterLimit)
miterLimit - The miter limit ratio.public void setShadowBlur(double shadowBlur)
shadowBlur - The level of the blurring effect.public void setShadowColor(String shadowColor)
shadowColor - The shadow color.public void setShadowOffsetX(double shadowOffsetX)
shadowOffsetX - The distance that the shadow will be offset in horizontal distance.public void setShadowOffsetY(double shadowOffsetY)
shadowOffsetY - The distance that the shadow will be offset in vertical distance.public void setStrokeStyle(CanvasGradient gradient)
gradient - The color or style to use for the lines around shapes.public void setStrokeStyle(CanvasPattern pattern)
pattern - The pattern to use for the lines around shapes.public void setStrokeStyle(String color)
color - The color or style to use for the lines around shapes.public void setTextAlign(TextAlign textAlign)
textAlign - The current text alignment being used when drawing text.public void setTextBaseline(TextBaseline textBaseline)
textBaseline - The current text baseline being used when drawing text.public void setTransform(double a,
double b,
double c,
double d,
double dx,
double dy)
a - Horizontal scaling.b - Horizontal skewing.c - Vertical skewing.d - Vertical scaling.dx - Horizontal moving.dy - Vertical moving.public void stroke()
public void strokeRect(double x,
double y,
double width,
double height)
x - The x axis of the coordinate for the rectangle starting point.y - The y axis of the coordinate for the rectangle starting point.width - The rectangle's width.height - The rectangle's height.public void strokeText(String text, double x, double y)
fillText(java.lang.String, double, double) method to draw the text with the characters filled with
color rather than having just their outlines drawn.text - The text to draw using the current font, textAlign, textBaseline, and direction
values.x - The x axis of the coordinate for the text starting point.y - The y axis of the coordinate for the text starting point.public void strokeText(String text, double x, double y, double maxWidth)
fillText(java.lang.String, double, double) method to draw the text with the characters filled with
color rather than having just their outlines drawn.text - The text to draw using the current font, textAlign, textBaseline, and direction
values.x - The x axis of the coordinate for the text starting point.y - The y axis of the coordinate for the text starting point.maxWidth - The maximum width to draw. When specified, and the string is computed to be
wider than this width, the font is adjusted to use a more horizontally condensed
font (if one is available or if a reasonably readable one can be synthesized by
scaling the current font horizontally) or a smaller font.public void transform(double a,
double b,
double c,
double d,
double dx,
double dy)
setTransform(double, double, double, double, double, double) method which resets the current transform to the identity matrix and
then invokes transform().a - Horizontal scaling.b - Horizontal skewing.c - Vertical skewing.d - Vertical scaling.dx - Horizontal moving.dy - Vertical moving.public void translate(double x,
double y)
x - Distance to move in the horizontal direction.y - Distance to move in the vertical direction.Copyright © 2018 Regenstrief Center for Biomedical Informatics. All rights reserved.