A node style that can display node shapes with a boundary that is defined by a GeneralPath instance.
Type Details
- yFiles module
- view
Constructors
Creates a new instance using the specified path.
Parameters
A map of options to pass to the method.
- path - GeneralPath
- The path that defines the boundary of this style. The path must be defined in such a way that the point (0,0) represents the top left of a node's layout and the point (1,1) the lower right. The path will be scaled accordingly to the node's size. If not specified, a simple rectangular path is used.
- fill - Fill
- stroke - Stroke
- cssClass - string
- A CSS class that will be applied to the visualization. This option sets the cssClass property on the created object.
- aspectRatio - number
- The aspect ratio for scaling the path to a node's size. This option sets the aspectRatio property on the created object.
Properties
Gets or sets the aspect ratio for scaling the path to a node's size.
Remarks
If this value is positive and finite, the path will be scaled to the largest rectangle that a) has a width-to-height ratio that matches this value and b) fits into the node's size. Otherwise, the path is scaled to the node's size (and aspect ratio) without further restrictions.
The default value is 0
. That is, path is scaled to the node's size (and aspect ratio).
Get or sets the path that defines the boundary of the shape.
Remarks
The path must be defined in such a way that the point (0,0) represents the top left of a node's layout and the point (1,1) the lower right. The path will be scaled accordingly to the node's size.
The default is a rectangular path.
Gets the renderer implementation that can be queried for implementations that provide details about the visual appearance and visual behavior for a given node and this style instance.
Remarks
const creator = style.renderer.getVisualCreator(node, style)
const visual = creator.createVisual(context)
Implements
Methods
Create a clone of this object.
Static Methods
Creates a new GeneralPathNodeStyle instance for a copy of the given path.
Remarks
Parameters
A map of options to pass to the method.
- path - GeneralPath
- The path that defines the outline of a node's visualization. The width and height of its bounds have to be positive and finite.
Returns
- ↪GeneralPathNodeStyle
- A GeneralPathNodeStyle instance using the path and its aspect ratio.
Throws
- Exception({ name: 'ArgumentError' })
- If the width or height of the given path's bounds is not positive and finite.
createPolygonPath
(pointCount: number, rotationAngle?: number, stretchToHeight?: boolean, stretchToWidth?: boolean) : GeneralPathCreates a GeneralPath in the form of a polygon.
Parameters
A map of options to pass to the method.
- pointCount - number
- The number of corners of the polygon. For odd numbers, the first corner points to the top.
- rotationAngle - number
- The rotation angle of the polygon. The angle is specified in radians, measured clockwise.
- stretchToHeight - boolean
- Whether to stretch the path to the full bounding box height.
- stretchToWidth - boolean
- Whether to stretch the path to the full bounding box width.
Returns
- ↪GeneralPath
- The polygonal GeneralPath.
createStarPath
(pointCount: number, ratio: number, rotationAngle?: number, stretchToHeight?: boolean, stretchToWidth?: boolean) : GeneralPathCreates a GeneralPath in the form of a star.
Parameters
A map of options to pass to the method.
- pointCount - number
- The number of points of the star. For odd numbers, the first corner points to the top.
- ratio - number
- The ratio between the inner and outer points radius. The ratio should be a positive number smaller or equal to 1. For values > 1, the reciprocal is used.
- rotationAngle - number
- The rotation angle of the star. The angle is specified in radians, measured clockwise.
- stretchToHeight - boolean
- Whether to stretch the path to the full bounding box height.
- stretchToWidth - boolean
- Whether to stretch the path to the full bounding box width.
Returns
- ↪GeneralPath
- A star-shaped GeneralPath.