Last updated

API / geotoolkit / renderer / DocumentRenderingContext / DocumentRenderingContext

Class: DocumentRenderingContext

renderer.DocumentRenderingContext.DocumentRenderingContext

Represents context to traverse nodes during picking and rendering

Hierarchy

Table of contents

Constructors
Methods

Contents

Constructors

new DocumentRenderingContext()

Protected new DocumentRenderingContext()

Overrides

RenderingContext.constructor

Methods

addFilter

addFilter(filter): DocumentRenderingContext

Add filter to be applied

Parameters

Name Type Description
filterIFilterfilter to add

Returns

DocumentRenderingContext

Inherited from

RenderingContext.addFilter


arcTo

Abstract arcTo(x1, y1, x2, y2, radius): DocumentRenderingContext

Draws an arc to the target point as part of a path.

Parameters

Name Type Description
x1numbercoordinate of destination
y1numbercoordinate of destination
x2numbercoordinate
y2numbercoordinate
radiusnumberradius of arc

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.arcTo


beginPath

Abstract beginPath(): DocumentRenderingContext

Begin path

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.beginPath


beginRendering

beginRendering(): DocumentRenderingContext

Prepare rendering context. The default implementation blocks notifications from nodes and styles. if you call beginRendering then call the endRendering.

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.beginRendering


bezierCurveTo

Abstract bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y): DocumentRenderingContext

Draws a cubic B\u00e9zier curve from the current point to the point (x, y), with control points (cp1x, cp1y) and (cp2x, cp2y).

Parameters

Name Type Description
cp1xnumberthe x coordinate of the first control point
cp1ynumberthe y coordinate of the first control point
cp2xnumberthe x coordinate of the second control point
cp2ynumberthe y coordinate of the second control point
xnumberthe x coordinate of the end point
ynumberthe y coordinate of the end point

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.bezierCurveTo


closePath

Abstract closePath(): DocumentRenderingContext

Do nothing if the context has no subpaths. Otherwise, it marks the last subpath as closed, create a new subpath whose first point is the same as the previous subpath's first point, and finally add this new subpath to the path.

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.closePath


createRenderingState

Abstract createRenderingState(): RenderingState

Creates rendering state

Returns

RenderingState

a new instance of the rendering state

Inherited from

RenderingContext.createRenderingState


createSurface

Abstract createSurface(width, height, devicePixel?): Surface

Creates a new surface

Parameters

Name Type Description
widthnumberwidth of surface
heightnumberheight of surface
Optional devicePixelbooleanIf set to true, width and height will be used as 'device' pixels.

Returns

Surface

a new instance of surface

Inherited from

RenderingContext.createSurface


drawAnnulusArc

Abstract drawAnnulusArc(x, y, innerRadius, outerRadius, startAngle, endAngle, sweepAngle?): DocumentRenderingContext

Draws a portion of an annulus clockwise ranging from startAngle to endAngle. If endAngle exceeds startAngle by Math.PI * 2 or more than annulus is drawn. Will fill in between the two arcs if fillStyle exists.

Parameters

Name Type Description
xnumberx-coordinate of the center of the arc.
ynumbery-coordinate of the center of the arc.
innerRadiusnumberinner radius of the arc
outerRadiusnumberouter radius of the arc
startAnglenumberangle in radians measured from x-axis to the starting point of the arc (clockwise means positive angle; counterclockwise - otherwise).
endAnglenumberAngle in radians measured from x-axis to ending point of the arc.
Optional sweepAnglenumberDefines the sweep of the arc

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.drawAnnulusArc


drawArc

Abstract drawArc(x, y, width, height, startAngle, endAngle, sweepAngle?, suppressLineToCenter?): DocumentRenderingContext

Draws an arc clockwise from startAngle to endAngle. If endAngle exceeds startAngle by Math.PI * 2 or more than ellipse is drawn. If fillStyle is not null, will fill the arc area using a direct line to close the path between start and end of arc. By default, this function renders a "pie" shape, using given fill and stroke style. In order to draw a real arc, set suppressLineToCenter=true.

Parameters

Name Type Description
xnumberx-coordinate of the upper-left corner of the rectangle that bounds the ellipse.
ynumbery-coordinate of the upper-left corner of the rectangle that bounds the ellipse.
widthnumberwidth of the rectangle that bounds the ellipse.
heightnumberheight of the rectangle that bounds the ellipse.
startAnglenumberangle in radians measured clockwise from positive x-axis to the starting point of the arc.
endAnglenumberAngle in radians measured clockwise from positive x-axis to the ending point of the arc.
Optional sweepAnglenumberDefines the sweep of the arc in radians. This parameter used if and only if startAngle == endAngle
Optional suppressLineToCenterbooleanDoes not draw lines from the edges of arc to center point

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.drawArc


drawEllipse

Abstract drawEllipse(x, y, width, height): DocumentRenderingContext

Draw and fill ellipse

Parameters

Name Type Description
xnumberx-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse
ynumbery--coordinate of the upper-left corner of the bounding rectangle that defines the ellipse
widthnumberwidth of the bounding rectangle that defines the ellipse.
heightnumberheight of the bounding rectangle that defines the ellipse.

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.drawEllipse


drawImage

Abstract drawImage(image, srcX, srcY, srcW?, srcH?, dstX?, dstY?, dstW?, dstH?): DocumentRenderingContext

Draw an image onto the graphics context

Example

// Draw image can be used it the three different ways

// Provide only destination x and y
graphics.drawImage(image, dstX, dstY);
// Provide destination x and y and destination width and height
graphics.drawImage(image, dstX, dstY, dstW, dstW);
// Provide source x, y, width, height and destination x and y and destination width and height
graphics.drawImage(image, srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstW);

Parameters

Name Type Description
imageSurface | IBaseImageimage to be rendered
srcXnumberThe x-axis coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context. Use the 7- or 9-argument syntax to use it as a source or the x-axis coordinate in the destination context at which to place the top-left corner of the source image. Use the 3- or 5-argument syntax to apply this argument as destination position.
srcYnumberThe y-axis coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context. Use the 7- or 9-argument syntax to use it as a source or the y-axis coordinate in the destination context at which to place the top-left corner of the source image. Use the 3- or 5-argument syntax to apply this argument as destination position.
Optional srcWnumbersource width if 7- or 9-argument is used or image width for other cases
Optional srcHnumbersource height if y-argument | image height for other cases
Optional dstXnumberdestination x position
Optional dstYnumberdestination y position
Optional dstWnumberdestination width This allows scaling of the drawn image. If not specified, the image is not scaled in height when drawn.
Optional dstHnumberdestination height. If not specified, the image is not scaled in height when drawn.

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.drawImage


drawLine

Abstract drawLine(x1, y1, x2, y2): DocumentRenderingContext

Draw line

Parameters

Name Type Description
x1numberx-position of start point
y1numbery-position of start point
x2numberx-position of end point
y2numbery-position of end point

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.drawLine


drawPath

drawPath(path): DocumentRenderingContext

Apply geometry on the rendering context. The method stroke must be called to draw path outlines or fillPath to fill the geometry

Parameters

Name Type Description
pathGraphicsPathpath to draw

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.drawPath


drawPolygon

Abstract drawPolygon(x, array, start?, end?): DocumentRenderingContext

Draw and fill polygon. If fill style is null then it draws outline only.

Parameters

Name Type Description
xnumber[]array of x coordinates of points
arraynumber[]of y coordinates of points
Optional startnumberindex of the first point in the array
Optional endnumberindex of the last point in the array

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.drawPolygon


drawPolyline

Abstract drawPolyline(x, y, start?, end?, multiDirection?): DocumentRenderingContext

Draw polyline

Parameters

Name Type Description
xnumber[]array of x coordinates of points
ynumber[]array of y coordinates of points
Optional startnumberindex of the first point in the array
Optional endnumberindex of the last point in the array
Optional multiDirectionbooleanfalse for one direction array

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.drawPolyline


drawRectangle

Abstract drawRectangle(x, y?, width?, height?): DocumentRenderingContext

Draw and fill rectangle with the current style. If fill style is null then it draws outline only.

Parameters

Name Type Description
xnumber | RectX coordinate of the start point
Optional ynumberY coordinate of the start point
Optional widthnumberWidth of rectangle
Optional heightnumberHeight of rectangle

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.drawRectangle


drawText

Abstract drawText(x, y, text): DocumentRenderingContext

Draw text

Parameters

Name Type Description
xnumberx anchor position
ynumbery anchor position
textstringtext to draw

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.drawText


endRendering

endRendering(): DocumentRenderingContext

End usage ot the rendering context

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.endRendering


fillPath

Abstract fillPath(): DocumentRenderingContext

Fill all the subpaths of the current path, using fillStyle, and using the non-zero winding number rule. Open subpaths will be implicitly closed when being filled (without affecting the actual subpaths).

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.fillPath


filter

filter(node): boolean

Filter node

Parameters

Name Type Description
nodeNodenode to be rendered

Returns

boolean

Inherited from

RenderingContext.filter


getContextAt

getContextAt(point): RenderingContext

Gets context with non-deviated transformation at the specified location. The base implementation returns itself.

Parameters

Name Type Description
pointPointpoint to get non-deviated context at

Returns

RenderingContext

context with non-deviated transformation

Inherited from

RenderingContext.getContextAt


getDevicePathLength

getDevicePathLength(pt1, pt2): number

Gets path length in device space.
The default implementation returns straight distance between transformed points

Parameters

Name Type Description
pt1Pointfirst model point
pt2Pointsecond model point

Returns

number

Inherited from

RenderingContext.getDevicePathLength


getDeviceRect

Abstract getDeviceRect(): Rect

Gets rectangular area (defined in device space) to invalidate

Returns

Rect

Inherited from

RenderingContext.getDeviceRect


getDocumentSettings

getDocumentSettings(): Record<string, any>

Return document settings

Returns

Record<string, any>


getFilters

Protected getFilters(): (IFilter | (node: Node, context?: RenderingContext) => boolean)[]

Gets an array of filters

Returns

(IFilter | (node: Node, context?: RenderingContext) => boolean)[]

Inherited from

RenderingContext.getFilters


getGlobalAlpha

getGlobalAlpha(): number

Gets the alpha (transparency) value that is applied to shapes and images before they are drawn

Returns

number

Inherited from

RenderingContext.getGlobalAlpha


getGlobalViewPort

getGlobalViewPort(): Rect

Gets "global" view port (defined in device space). The implementation calls for "this.getDeviceRect()"

Returns

Rect

Inherited from

RenderingContext.getGlobalViewPort


getImageSmoothing

getImageSmoothing(): boolean

Return images smoothing enabled flag if context is supported. By default it returns false

Returns

boolean

enable enable or disable smoothing

Inherited from

RenderingContext.getImageSmoothing


getInverseTransformation

Abstract getInverseTransformation(): Transformation

Gets the current transformation, which defines transformation from device coordinates to model coordinates. Note, that inverse transformation can be calculated based on getTransformation() call (and vice versa).

Returns

Transformation

Inherited from

RenderingContext.getInverseTransformation


getModelArea

getModelArea(): Area

Returns model area (rect/polygon/etc) of current context.

Returns

Area

Inherited from

RenderingContext.getModelArea


getModelRect

Abstract getModelRect(): Rect

Gets rectangular area (defined in model space) to invalidate. Note, that having called getTransformation() (or getInverseTransformation()) model rect can be calculated based on device rect (and vice versa).

Returns

Rect

Inherited from

RenderingContext.getModelRect


getTransformation

Abstract getTransformation(): Transformation

Gets the current transformation, which defines transformation from model coordinates to device coordinates

Returns

Transformation

Inherited from

RenderingContext.getTransformation


getTransformationAt

getTransformationAt(point): Transformation

Gets non-deviated transformation at the specified location. The base implementation returns "this.getTransformation()".

Parameters

Name Type Description
pointPointpoint to get the transformation

Returns

Transformation

the transformation

Inherited from

RenderingContext.getTransformationAt


isPicking

Abstract isPicking(): this is SelectionContext

Return true if context is doing picking now

Returns

this is SelectionContext

true if this is picking context

Inherited from

RenderingContext.isPicking


lineTo

Abstract lineTo(x, y): DocumentRenderingContext

Draw line from the current position to the specified position

Parameters

Name Type Description
xnumberx position
ynumbery position

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.lineTo


measureLine

measureLine(lineStyle): number

Returns line dimension at the current context

Parameters

Name Type Description
lineStyleLineStylethe line style

Returns

number

the line width

Inherited from

RenderingContext.measureLine


measureText

Abstract measureText(text, textStyle?): TextMetrics

Return text metrics

Parameters

Name Type Description
textstringtext
Optional textStyleTextStylethe text style

Returns

TextMetrics

text metrics

Inherited from

RenderingContext.measureText


moveTo

Abstract moveTo(x, y): DocumentRenderingContext

Move current position to x,y. Create a new subpath with the specified point as its first (and only) point.

Parameters

Name Type Description
xnumberx position
ynumbery position

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.moveTo


pushTransformation

Abstract pushTransformation(tr): DocumentRenderingContext

Creates a new context with concatenated transformation

Parameters

Name Type Description
trTransformationa transformation to concatenate

Returns

DocumentRenderingContext

a new context

Overrides

RenderingContext.pushTransformation


removeFilter

removeFilter(filter): DocumentRenderingContext

Remove an instance of the filter

Parameters

Name Type Description
filterIFilterfilter to remove

Returns

DocumentRenderingContext

Inherited from

RenderingContext.removeFilter


restore

Abstract restore(): DocumentRenderingContext

Restore current state

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.restore


save

Abstract save(): DocumentRenderingContext

Save the current state

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.save


setClip

Abstract setClip(geometry, operation?, isModel?, evenOdd?): DocumentRenderingContext

Sets clipping

Parameters

Name Type Description
geometryRect | GraphicsPath | Regiongeometry to clip
Optional operationGeometryOperationoperation to be applied for a new clipping
Optional isModelbooleanmodel coordinates flag
Optional evenOddbooleanDefines if clipping to apply is even-odd

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.setClip


setCurrentNode

setCurrentNode(node): DocumentRenderingContext

Specify node to be rendered

Parameters

Name Type Description
nodeNodenode to be rendered

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.setCurrentNode


setDeviceRect

Abstract setDeviceRect(rect): DocumentRenderingContext

Sets device rectangle area of interest

Parameters

Name Type
rectRect

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.setDeviceRect


setDocumentSettings

setDocumentSettings(documentSettings): DocumentRenderingContext

Sets document settings

Parameters

Name Type Description
documentSettingsRecord<string, any>document settings

Returns

DocumentRenderingContext


setFillPattern

Abstract setFillPattern(pattern): DocumentRenderingContext

Set fill pattern

Parameters

Name Type Description
patternPatternpattern to fill the area

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.setFillPattern


setFillStyle

Abstract setFillStyle(style, area?): DocumentRenderingContext

Set fill style

Parameters

Name Type Description
styleFillStylefill style
Optional areaRectarea

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.setFillStyle


setFilters

Protected setFilters(filters): DocumentRenderingContext

Sets an array of filters

Parameters

Name Type Description
filters(IFilter | (node: Node, context?: RenderingContext) => boolean)[]filters

Returns

DocumentRenderingContext

Inherited from

RenderingContext.setFilters


setGlobalAlpha

setGlobalAlpha(alpha, mode?): DocumentRenderingContext

Specifies the alpha (transparency) value that is applied to shapes and images before they are drawn

Parameters

Name Type Description
alphanumberA number between 0.0 (fully transparent) and 1.0 (fully opaque). Not all implementations can support it
Optional modeBlendModedefines mode to blend opacity

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.setGlobalAlpha


setGlobalViewPort

setGlobalViewPort(globalViewPort): DocumentRenderingContext

Sets "global" view port (defined in device space) The implementation is empty

Parameters

Name Type Description
globalViewPortRect"global" view port

Returns

DocumentRenderingContext

Inherited from

RenderingContext.setGlobalViewPort


setImageSmoothing

setImageSmoothing(enable): DocumentRenderingContext

Enable or disable image smoothing if context is supported determines whether scaled images are smoothed. When enlarging images, the default resizing algorithm will blur the pixels. Set this property to false to retain the pixels' sharpness. By default is ignored

Parameters

Name Type Description
enablebooleanenable or disable smoothing

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.setImageSmoothing


setLineStyle

Abstract setLineStyle(style, area?): DocumentRenderingContext

Set line style

Parameters

Name Type Description
styleLineStyle | GradientStylea line style
Optional areaRectarea to apply fill property of line style

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.setLineStyle


setModelRect

Abstract setModelRect(rect): DocumentRenderingContext

Sets model rectangle

Parameters

Name Type Description
rectRectmodel area of interest

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.setModelRect


setPageClip

setPageClip(rectangle): DocumentRenderingContext

Sets the Page Clipping

Parameters

Name Type Description
rectangleRectclip rectangle

Returns

DocumentRenderingContext

this


setPageInfoSettings

Abstract setPageInfoSettings(pageX, pageY): void

Sets the page info settings

Parameters

Name Type Description
pageXnumberindex of the page by x
pageYnumberindex of the page by y

Returns

void


setPagesCount

Abstract setPagesCount(xPageCount, yPageCount): void

Sets the pages count

Parameters

Name Type Description
xPageCountnumberpage count along x
yPageCountnumberpage count along y

Returns

void


setTextStyle

Abstract setTextStyle(textStyle): DocumentRenderingContext

Set text style

Parameters

Name Type Description
textStyleTextStylestyle

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.setTextStyle


setTransformation

Abstract setTransformation(transformation): DocumentRenderingContext

Sets the current transformation, which defines transformation from model coordinates to device coordinates

Parameters

Name Type Description
transformationTransformationtransformation to be set

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.setTransformation


stroke

Abstract stroke(): DocumentRenderingContext

Calculate the strokes of all the subpaths of the current path

Returns

DocumentRenderingContext

this

Inherited from

RenderingContext.stroke