API / geotoolkit / selection / SelectionContext / SelectionContext
selection.SelectionContext.SelectionContext
Define a base selection context to be used for picking strategies
↳
SelectionContext
Constructors
Methods
Constructors
• Protected new SelectionContext(deviceUnit?, filters?)
| Name | Type | Description |
|---|---|---|
Optional deviceUnit | string | AbstractUnit | represent 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 |
RenderingContext.constructor
Methods
▸ addFilter(filter): SelectionContext
Add filter to be applied
| Name | Type | Description |
|---|---|---|
filter | IFilter | filter to add |
▸ Abstract arcTo(x1, y1, x2, y2, radius): SelectionContext
Draws an arc to the target point as part of a path.
| Name | Type | Description |
|---|---|---|
x1 | number | coordinate of destination |
y1 | number | coordinate of destination |
x2 | number | coordinate |
y2 | number | coordinate |
radius | number | radius of arc |
this
▸ Abstract beginPath(): SelectionContext
Begin path
this
▸ beginRendering(): SelectionContext
Prepare rendering context. The default implementation blocks notifications from nodes and styles. if you call beginRendering then call the endRendering.
this
RenderingContext.beginRendering
▸ 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).
| Name | Type | Description |
|---|---|---|
cp1x | number | the x coordinate of the first control point |
cp1y | number | the y coordinate of the first control point |
cp2x | number | the x coordinate of the second control point |
cp2y | number | the y coordinate of the second control point |
x | number | the x coordinate of the end point |
y | number | the y coordinate of the end point |
this
RenderingContext.bezierCurveTo
▸ 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.
this
▸ Abstract createRenderingState(): RenderingState
Creates rendering state
a new instance of the rendering state
RenderingContext.createRenderingState
▸ Abstract createSurface(width, height, devicePixel?): Surface
Creates a new surface
| Name | Type | Description |
|---|---|---|
width | number | width of surface |
height | number | height of surface |
Optional devicePixel | boolean | If set to true, width and height will be used as 'device' pixels. |
a new instance of surface
RenderingContext.createSurface
▸ 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.
| Name | Type | Description |
|---|---|---|
x | number | x-coordinate of the center of the arc. |
y | number | y-coordinate of the center of the arc. |
innerRadius | number | inner radius of the arc |
outerRadius | number | outer radius of the arc |
startAngle | number | angle in radians measured from x-axis to the starting point of the arc (clockwise means positive angle; counterclockwise - otherwise). |
endAngle | number | Angle in radians measured from x-axis to ending point of the arc. |
Optional sweepAngle | number | Defines the sweep of the arc |
this
RenderingContext.drawAnnulusArc
▸ 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.
| Name | Type | Description |
|---|---|---|
x | number | x-coordinate of the upper-left corner of the rectangle that bounds the ellipse. |
y | number | y-coordinate of the upper-left corner of the rectangle that bounds the ellipse. |
width | number | width of the rectangle that bounds the ellipse. |
height | number | height of the rectangle that bounds the ellipse. |
startAngle | number | angle in radians measured clockwise from positive x-axis to the starting point of the arc. |
endAngle | number | Angle in radians measured clockwise from positive x-axis to the ending point of the arc. |
Optional sweepAngle | number | Defines the sweep of the arc in radians. This parameter used if and only if startAngle == endAngle |
Optional suppressLineToCenter | boolean | Does not draw lines from the edges of arc to center point |
this
▸ Abstract drawEllipse(x, y, width, height): SelectionContext
Draw and fill ellipse
| Name | Type | Description |
|---|---|---|
x | number | x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse |
y | number | y--coordinate of the upper-left corner of the bounding rectangle that defines the ellipse |
width | number | width of the bounding rectangle that defines the ellipse. |
height | number | height of the bounding rectangle that defines the ellipse. |
this
▸ 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);| Name | Type | Description |
|---|---|---|
image | Surface | IBaseImage | image to be rendered |
srcX | number | The 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. |
srcY | number | The 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 srcW | number | source width if 7- or 9-argument is used or image width for other cases |
Optional srcH | number | source height if y-argument | image height for other cases |
Optional dstX | number | destination x position |
Optional dstY | number | destination y position |
Optional dstW | number | destination width This allows scaling of the drawn image. If not specified, the image is not scaled in height when drawn. |
Optional dstH | number | destination height. If not specified, the image is not scaled in height when drawn. |
this
▸ Abstract drawLine(x1, y1, x2, y2): SelectionContext
Draw line
| Name | Type | Description |
|---|---|---|
x1 | number | x-position of start point |
y1 | number | y-position of start point |
x2 | number | x-position of end point |
y2 | number | y-position of end point |
this
▸ 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
| Name | Type | Description |
|---|---|---|
path | GraphicsPath | path to draw |
this
▸ Abstract drawPolygon(x, array, start?, end?): SelectionContext
Draw and fill polygon. If fill style is null then it draws outline only.
| Name | Type | Description |
|---|---|---|
x | number[] | array of x coordinates of points |
array | number[] | of y coordinates of points |
Optional start | number | index of the first point in the array |
Optional end | number | index of the last point in the array |
this
▸ Abstract drawPolyline(x, y, start?, end?, multiDirection?): SelectionContext
Draw polyline
| Name | Type | Description |
|---|---|---|
x | number[] | array of x coordinates of points |
y | number[] | array of y coordinates of points |
Optional start | number | index of the first point in the array |
Optional end | number | index of the last point in the array |
Optional multiDirection | boolean | false for one direction array |
this
▸ 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.
| Name | Type | Description |
|---|---|---|
x | number | Rect | X coordinate of the start point |
Optional y | number | Y coordinate of the start point |
Optional width | number | Width of rectangle |
Optional height | number | Height of rectangle |
this
RenderingContext.drawRectangle
▸ Abstract drawText(x, y, text): SelectionContext
Draw text
| Name | Type | Description |
|---|---|---|
x | number | x anchor position |
y | number | y anchor position |
text | string | text to draw |
this
▸ endRendering(): SelectionContext
End usage ot the rendering context
this
▸ 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).
this
▸ filter(node): boolean
Filter node
| Name | Type | Description |
|---|---|---|
node | Node | node to be rendered |
boolean
▸ getContextAt(point): RenderingContext
Gets context with non-deviated transformation at the specified location. The base implementation returns itself.
| Name | Type | Description |
|---|---|---|
point | Point | point to get non-deviated context at |
context with non-deviated transformation
▸ getDevicePathLength(pt1, pt2): number
Gets path length in device space.
The default implementation returns straight distance between transformed points
number
RenderingContext.getDevicePathLength
▸ Abstract getDeviceRect(): Rect
Gets rectangular area (defined in device space) to invalidate
RenderingContext.getDeviceRect
▸ Protected getFilters(): (IFilter | (node: Node, context?: RenderingContext) => boolean)[]
Gets an array of filters
(IFilter | (node: Node, context?: RenderingContext) => boolean)[]
▸ getGlobalAlpha(): number
Gets the alpha (transparency) value that is applied to shapes and images before they are drawn
number
RenderingContext.getGlobalAlpha
▸ getGlobalViewPort(): Rect
Gets "global" view port (defined in device space). The implementation calls for "this.getDeviceRect()"
RenderingContext.getGlobalViewPort
▸ getImageSmoothing(): boolean
Return images smoothing enabled flag if context is supported. By default it returns false
boolean
enable enable or disable smoothing
RenderingContext.getImageSmoothing
▸ 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).
RenderingContext.getInverseTransformation
▸ getModelArea(): Area
Returns model area (rect/polygon/etc) of current context.
▸ 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).
▸ Abstract getTransformation(): Transformation
Gets the current transformation, which defines transformation from model coordinates to device coordinates
RenderingContext.getTransformation
▸ getTransformationAt(point): Transformation
Gets non-deviated transformation at the specified location. The base implementation returns "this.getTransformation()".
| Name | Type | Description |
|---|---|---|
point | Point | point to get the transformation |
the transformation
RenderingContext.getTransformationAt
▸ Abstract isPicking(): this is SelectionContext
Return true if context is doing picking now
this is SelectionContext
true if this is picking context
▸ Abstract lineTo(x, y): SelectionContext
Draw line from the current position to the specified position
| Name | Type | Description |
|---|---|---|
x | number | x position |
y | number | y position |
this
▸ measureLine(lineStyle): number
Returns line dimension at the current context
| Name | Type | Description |
|---|---|---|
lineStyle | LineStyle | the line style |
number
the line width
▸ Abstract measureText(text, textStyle?): TextMetrics
Return text metrics
| Name | Type | Description |
|---|---|---|
text | string | text |
Optional textStyle | TextStyle | the text style |
text metrics
▸ 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.
| Name | Type | Description |
|---|---|---|
x | number | x position |
y | number | y position |
this
▸ Abstract pick(node, listener): void
Check selection of node and call onselect if node is selected
| Name | Type | Description |
|---|---|---|
node | Node | node to pick |
listener | (node: Node) => void | function to be called on select |
void
▸ Abstract pushSelection(selection): SelectionContext
Push selection
| Name | Type | Description |
|---|---|---|
selection | Node | SelectedItem<any> | selected object |
this
▸ Abstract pushTransformation(tr): SelectionContext
Creates a new context with concatenated transformation
| Name | Type | Description |
|---|---|---|
tr | Transformation | a transformation to concatenate |
a new context
RenderingContext.pushTransformation
▸ removeFilter(filter): SelectionContext
Remove an instance of the filter
| Name | Type | Description |
|---|---|---|
filter | IFilter | filter to remove |
▸ Abstract restore(): SelectionContext
Restore current state
this
▸ Abstract save(): SelectionContext
Save the current state
this
▸ Abstract setClip(geometry, operation?, isModel?, evenOdd?): SelectionContext
Sets clipping
| Name | Type | Description |
|---|---|---|
geometry | Rect | GraphicsPath | Region | geometry to clip |
Optional operation | GeometryOperation | operation to be applied for a new clipping |
Optional isModel | boolean | model coordinates flag |
Optional evenOdd | boolean | Defines if clipping to apply is even-odd |
this
▸ setCurrentNode(node): SelectionContext
Specify node to be rendered
| Name | Type | Description |
|---|---|---|
node | Node | node to be rendered |
this
RenderingContext.setCurrentNode
▸ Abstract setDeviceRect(rect): SelectionContext
Sets device rectangle area of interest
| Name | Type |
|---|---|
rect | Rect |
this
RenderingContext.setDeviceRect
▸ Abstract setFillPattern(pattern): SelectionContext
Set fill pattern
| Name | Type | Description |
|---|---|---|
pattern | Pattern | pattern to fill the area |
this
RenderingContext.setFillPattern
▸ Abstract setFillStyle(style, area?): SelectionContext
Set fill style
this
▸ Protected setFilters(filters): SelectionContext
Sets an array of filters
| Name | Type | Description |
|---|---|---|
filters | (IFilter | (node: Node, context?: RenderingContext) => boolean)[] | filters |
▸ setGlobalAlpha(alpha, mode?): SelectionContext
Specifies the alpha (transparency) value that is applied to shapes and images before they are drawn
| Name | Type | Description |
|---|---|---|
alpha | number | A number between 0.0 (fully transparent) and 1.0 (fully opaque). Not all implementations can support it |
Optional mode | BlendMode | defines mode to blend opacity |
this
RenderingContext.setGlobalAlpha
▸ setGlobalViewPort(globalViewPort): SelectionContext
Sets "global" view port (defined in device space) The implementation is empty
| Name | Type | Description |
|---|---|---|
globalViewPort | Rect | "global" view port |
RenderingContext.setGlobalViewPort
▸ 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
| Name | Type | Description |
|---|---|---|
enable | boolean | enable or disable smoothing |
this
RenderingContext.setImageSmoothing
▸ Abstract setLineStyle(style, area?): SelectionContext
Set line style
| Name | Type | Description |
|---|---|---|
style | LineStyle | GradientStyle | a line style |
Optional area | Rect | area to apply fill property of line style |
this
▸ Abstract setModelRect(rect): SelectionContext
Sets model rectangle
| Name | Type | Description |
|---|---|---|
rect | Rect | model area of interest |
this
▸ Abstract setTextStyle(textStyle): SelectionContext
Set text style
| Name | Type | Description |
|---|---|---|
textStyle | TextStyle | style |
this
▸ Abstract setTransformation(transformation): SelectionContext
Sets the current transformation, which defines transformation from model coordinates to device coordinates
| Name | Type | Description |
|---|---|---|
transformation | Transformation | transformation to be set |
this
RenderingContext.setTransformation
▸ Abstract stroke(): SelectionContext
Calculate the strokes of all the subpaths of the current path
this