Last updated

API / geotoolkit / selection / SelectionContext / SelectionContext

Class: SelectionContext

selection.SelectionContext.SelectionContext

Define a base selection context to be used for picking strategies

Hierarchy

Table of contents

Constructors
Methods

Contents

Constructors

new SelectionContext(deviceUnit, filters)

Protected new SelectionContext(deviceUnit?, filters?)

Parameters

Name Type Description
Optional deviceUnitstring | AbstractUnitrepresent the {string} name, {string} symbol or {AbstractUnit} unit to be used as unit for device
Optional filters(IFilter | (node: Node, context?: RenderingContext) => boolean)[]an array of filters

Inherited from

RenderingContext.constructor

Methods

addFilter

addFilter(filter): SelectionContext

Add filter to be applied

Parameters

Name Type Description
filterIFilterfilter to add

Returns

SelectionContext

Inherited from

RenderingContext.addFilter


arcTo

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

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

SelectionContext

this

Inherited from

RenderingContext.arcTo


beginPath

Abstract beginPath(): SelectionContext

Begin path

Returns

SelectionContext

this

Inherited from

RenderingContext.beginPath


beginRendering

beginRendering(): SelectionContext

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

Returns

SelectionContext

this

Inherited from

RenderingContext.beginRendering


bezierCurveTo

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

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

SelectionContext

this

Inherited from

RenderingContext.bezierCurveTo


closePath

Abstract closePath(): SelectionContext

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

SelectionContext

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?): SelectionContext

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

SelectionContext

this

Inherited from

RenderingContext.drawAnnulusArc


drawArc

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

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

SelectionContext

this

Inherited from

RenderingContext.drawArc


drawEllipse

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

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

SelectionContext

this

Inherited from

RenderingContext.drawEllipse


drawImage

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

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

SelectionContext

this

Inherited from

RenderingContext.drawImage


drawLine

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

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

SelectionContext

this

Inherited from

RenderingContext.drawLine


drawPath

drawPath(path): SelectionContext

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

SelectionContext

this

Inherited from

RenderingContext.drawPath


drawPolygon

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

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

SelectionContext

this

Inherited from

RenderingContext.drawPolygon


drawPolyline

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

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

SelectionContext

this

Inherited from

RenderingContext.drawPolyline


drawRectangle

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

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

SelectionContext

this

Inherited from

RenderingContext.drawRectangle


drawText

Abstract drawText(x, y, text): SelectionContext

Draw text

Parameters

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

Returns

SelectionContext

this

Inherited from

RenderingContext.drawText


endRendering

endRendering(): SelectionContext

End usage ot the rendering context

Returns

SelectionContext

this

Inherited from

RenderingContext.endRendering


fillPath

Abstract fillPath(): SelectionContext

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

SelectionContext

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


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): SelectionContext

Draw line from the current position to the specified position

Parameters

Name Type Description
xnumberx position
ynumbery position

Returns

SelectionContext

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): SelectionContext

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

SelectionContext

this

Inherited from

RenderingContext.moveTo


pick

Abstract pick(node, listener): void

Check selection of node and call onselect if node is selected

Parameters

Name Type Description
nodeNodenode to pick
listener(node: Node) => voidfunction to be called on select

Returns

void


pushSelection

Abstract pushSelection(selection): SelectionContext

Push selection

Parameters

Name Type Description
selectionNode | SelectedItem<any>selected object

Returns

SelectionContext

this


pushTransformation

Abstract pushTransformation(tr): SelectionContext

Creates a new context with concatenated transformation

Parameters

Name Type Description
trTransformationa transformation to concatenate

Returns

SelectionContext

a new context

Inherited from

RenderingContext.pushTransformation


removeFilter

removeFilter(filter): SelectionContext

Remove an instance of the filter

Parameters

Name Type Description
filterIFilterfilter to remove

Returns

SelectionContext

Inherited from

RenderingContext.removeFilter


restore

Abstract restore(): SelectionContext

Restore current state

Returns

SelectionContext

this

Inherited from

RenderingContext.restore


save

Abstract save(): SelectionContext

Save the current state

Returns

SelectionContext

this

Inherited from

RenderingContext.save


setClip

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

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

SelectionContext

this

Inherited from

RenderingContext.setClip


setCurrentNode

setCurrentNode(node): SelectionContext

Specify node to be rendered

Parameters

Name Type Description
nodeNodenode to be rendered

Returns

SelectionContext

this

Inherited from

RenderingContext.setCurrentNode


setDeviceRect

Abstract setDeviceRect(rect): SelectionContext

Sets device rectangle area of interest

Parameters

Name Type
rectRect

Returns

SelectionContext

this

Inherited from

RenderingContext.setDeviceRect


setFillPattern

Abstract setFillPattern(pattern): SelectionContext

Set fill pattern

Parameters

Name Type Description
patternPatternpattern to fill the area

Returns

SelectionContext

this

Inherited from

RenderingContext.setFillPattern


setFillStyle

Abstract setFillStyle(style, area?): SelectionContext

Set fill style

Parameters

Name Type Description
styleFillStylefill style
Optional areaRectarea

Returns

SelectionContext

this

Inherited from

RenderingContext.setFillStyle


setFilters

Protected setFilters(filters): SelectionContext

Sets an array of filters

Parameters

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

Returns

SelectionContext

Inherited from

RenderingContext.setFilters


setGlobalAlpha

setGlobalAlpha(alpha, mode?): SelectionContext

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

SelectionContext

this

Inherited from

RenderingContext.setGlobalAlpha


setGlobalViewPort

setGlobalViewPort(globalViewPort): SelectionContext

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

Parameters

Name Type Description
globalViewPortRect"global" view port

Returns

SelectionContext

Inherited from

RenderingContext.setGlobalViewPort


setImageSmoothing

setImageSmoothing(enable): SelectionContext

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

SelectionContext

this

Inherited from

RenderingContext.setImageSmoothing


setLineStyle

Abstract setLineStyle(style, area?): SelectionContext

Set line style

Parameters

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

Returns

SelectionContext

this

Inherited from

RenderingContext.setLineStyle


setModelRect

Abstract setModelRect(rect): SelectionContext

Sets model rectangle

Parameters

Name Type Description
rectRectmodel area of interest

Returns

SelectionContext

this

Inherited from

RenderingContext.setModelRect


setTextStyle

Abstract setTextStyle(textStyle): SelectionContext

Set text style

Parameters

Name Type Description
textStyleTextStylestyle

Returns

SelectionContext

this

Inherited from

RenderingContext.setTextStyle


setTransformation

Abstract setTransformation(transformation): SelectionContext

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

Parameters

Name Type Description
transformationTransformationtransformation to be set

Returns

SelectionContext

this

Inherited from

RenderingContext.setTransformation


stroke

Abstract stroke(): SelectionContext

Calculate the strokes of all the subpaths of the current path

Returns

SelectionContext

this

Inherited from

RenderingContext.stroke