An abstract base class that makes it possible to easily implement a custom GeneralPath-based IEdgeStyle.
Remarks
The only method that needs to be implemented by subclasses is getPath. The other callback methods like getStroke, getSourceArrow, and getTargetArrow can be overridden to easily customize the path visualization.
This implementation differs from the straightforward IEdgeStyle implementation in that there is no visible separation between the style and its IEdgeStyleRenderer. Instead, the renderer used by the base class is fixed and delegates all calls back to the style instance.
Type Details
- yFiles module
- view
Constructors
Initializes a new instance of the PathEdgeStyleBase class.
Properties
Gets whether the rendered path should use the BridgeManager to add bridges to it.
Gets the renderer implementation for this instance.
Remarks
Implements
Methods
Creates a new object that is a copy of the current instance.
Remarks
this
.Returns
- ↪Object
- A new object that is a copy of this instance using a memberwise clone.
Implements
Creates the visualization for the edge's path.
Remarks
This method is called in response to a createVisual call to the instance that has been queried from the renderer.
This visualization uses the callbacks getCroppedPath, getStroke, getSourceArrow, getTargetArrow, getSourceArrowAnchor, getTargetArrowAnchor, addBridges, and getBridgeCreator.
Parameters
A map of options to pass to the method.
- context - IRenderContext
- The render context.
- edge - IEdge
- The edge to which this style instance is assigned.
Returns
- ↪Visual?
- The visual as required by the createVisual interface.
See Also
Gets the bounds of the visual for the edge in the given context.
Remarks
Parameters
A map of options to pass to the method.
- context - ICanvasContext
- The canvas context.
- edge - IEdge
- The edge to which this style instance is assigned.
Returns
- ↪Rect
- The visual bounds of the visual representation.
Yields the IBridgeCreator to use for adding bridges to the visualized path.
Remarks
null
) will be passed to the BridgeManager's addBridges method.Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge.
Returns
- ↪IBridgeCreator?
- This implementation returns
null
.
Crops the raw path obtained from getPath to accommodate for cropping and arrow heads.
Remarks
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge to create the path for.
Returns
- ↪GeneralPath?
- The path for the given edge or
null
if the edge is currently invisible.
Returns getCroppedPath unless isVisible yields false
for the provided context and clip.
Parameters
A map of options to pass to the method.
- context - IRenderContext
- The context to yield the obstacles for.
- edge - IEdge
- The edge.
Returns
- ↪GeneralPath?
- Either
null
or the result of getCroppedPath.
See Also
Gets the raw, un-cropped, and un-smoothed path that shall be used for the given edge.
Remarks
Implementations may create their own GeneralPath or use the utility methods createPolylinePath and createSelfLoopPath to create simple polyline paths.
Cropping of the path will be performed in getCroppedPath which delegates to this method, first. For visualization, hit testing, and the like, it will be smoothed, if getSmoothingLength returns a positive value.
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge to create the path for.
Returns
- ↪GeneralPath?
- The path for the given edge or
null
if the edge is currently invisible.
Gets the value that determines the radius of the smoothing arcs that can be added to the path at the bends.
Remarks
0.0d
, which effectively turns off path smoothing.Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge.
Returns
- ↪number
- The radius of the arcs to use at the bends of the path.
Gets the policy with which smoothing is applied to the path when getSmoothingLength returns a value larger than 0.
Remarks
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge.
Returns
- ↪SmoothingPolicy
- The policy with which smoothing is applied to the path.
Gets the source arrow for the edge
.
Calculates the source arrow anchor and direction for a given arrow and path.
Parameters
A map of options to pass to the method.
- path - GeneralPath
- The path of the edge.
- arrow - IArrow
- The arrow.
Returns
- ↪Tangent?
- The anchor and directional vector of the arrow, if it exists.
Gets a value indicating whether the first and last segments of the path should always begin and end with a straight line segment, respectively.
Remarks
Given high enough values for getSmoothingLength, the first and last segments may become completely curved. This property prevents this from happening, e.g., to prevent arrowheads from colliding with the smoothed edge path.
This implementation returns false
.
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge.
Returns
- ↪boolean
true
if the first and last segments should remain straight; otherwise,false
.
Gets the Stroke to use for rendering the path of the edge
.
Gets the tangent to the edge at the specified ratio and the corresponding touch point.
Gets the tangent to the edge at the specified ratio of a segment of the edge and the corresponding touch point.
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge.
- segmentIndex - number
- Index of the segment of the edge.
- ratio - number
- A value between 0 and 1 inclusively that indicates a ratio from the beginning to the end of the segment of the edge.
Returns
- ↪Tangent?
- The tangent, if it exists.
Gets the target arrow for the edge
.
Calculates the target arrow anchor and direction for a given arrow and path.
Parameters
A map of options to pass to the method.
- path - GeneralPath
- The path of the edge.
- arrow - IArrow
- The arrow.
Returns
- ↪Tangent?
- The anchor and directional vector of the arrow, if it exists.
Determines whether the visual representation of the edge has been hit at the given location.
Remarks
This method is called in response to a isHit call to the instance that has been queried from the renderer.
This implementation returns the result of the pathContains method considering the pen thickness and the hitTestRadius.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The input mode context.
- location - Point
- The point to test.
- edge - IEdge
- The edge to which this style instance is assigned.
Returns
- ↪boolean
true
if the specified edge representation is hit;false
otherwise.
See Also
Determines whether the visualization for the specified edge is included in the marquee selection.
Remarks
This method is called in response to a isInBox call to the instance that has been queried from the renderer.
This implementation returns the result of the pathIntersects method considering the pen thickness and the hitTestRadius.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The input mode context.
- rectangle - Rect
- The marquee selection box.
- edge - IEdge
- The edge to which this style instance is assigned.
Returns
- ↪boolean
true
if the specified edge is visible and selected by the marquee rectangle;false
otherwise.
Determines whether the visualization for the specified edge is included in the lasso selection.
Remarks
This method is called in response to a isInPath call to the instance that has been queried from the renderer.
This implementation uses the results of the areaIntersects method considering the pen thickness and the hitTestRadius.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The input mode context.
- lassoPath - GeneralPath
- The lasso selection path.
- edge - IEdge
- The edge to which this style instance is assigned.
Returns
- ↪boolean
true
if the specified edge is visible and selected by the lasso path;false
otherwise.
Determines whether the visualization for the specified edge is visible in the context.
Remarks
Parameters
A map of options to pass to the method.
- context - ICanvasContext
- The canvas context.
- rectangle - Rect
- The clipping rectangle.
- edge - IEdge
- The edge to which this style instance is assigned.
Returns
- ↪boolean
true
if the specified edge is visible in the clipping rectangle;false
otherwise.
Performs the lookup operation for the getContext that has been queried from the renderer.
Remarks
This implementation yields null
for everything but:
- IHitTestable
- IVisualCreator
- IBoundsProvider
- IVisibilityTestable
- IMarqueeTestable
- ILassoTestable
- ILookup
- IPathGeometry
- IObstacleProvider
For these interfaces, an implementation will be returned that delegates to the methods in this instance.
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge to use for the context lookup.
- type - Constructor
- The type to query.
Returns
- ↪any?
- An implementation of the
type
ornull
.
Updates the visual previously created by createVisual.
Remarks
Parameters
A map of options to pass to the method.
- context - IRenderContext
- The render context.
- oldVisual - Visual
- The visual that has been created in the call to createVisual.
- edge - IEdge
- The edge to which this style instance is assigned.
Returns
- ↪Visual?
- The visual as required by the createVisual interface.
See Also
Static Methods
Creates a polyline path from the sourcePort via the bends to the targetPort of the edge
.
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge to create the polyline path for.
Returns
- ↪GeneralPath
- A polyline path including the ports and bends of the edge.
Special implementation that will create a self-loop path for the given edge.
Remarks
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge to create the self-loop path for.
- roundSelfLoop - boolean
- Whether to create a round self-loop path. If
false
, a rectangular path will be created. - selfLoopDistance - number
- The distance the self-loop stretches from the node bounds. This has only an effect if the edge has no bends.
Returns
- ↪GeneralPath
- A path for a self-loop.
Crops the edge's path at its source and target nodes.
Remarks
Parameters
A map of options to pass to the method.
- edge - IEdge
- The edge to crop the path for.
- path - GeneralPath
- The path that should be cropped.
- sourceArrow - IArrow
- The optional arrow at the source side of the path to consider when cropping.
- targetArrow - IArrow
- The optional arrow at the target side of the path to consider when cropping.
Returns
- ↪GeneralPath
- The cropped path. This can be either the same instance of the given path or a newly created instance.