C

PathEdgeStyleBase
abstract

An abstract base class that makes it possible to easily implement a custom GeneralPath-based IEdgeStyle.
ImplementsInheritance Hierarchy

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.

Unlike a direct IEdgeStyle implementation, PathEdgeStyleBase does not expose a separate IEdgeStyleRenderer. The base class uses a fixed renderer and simply forwards its calls back to the style instance.

Note that if your subclass has private fields (defined with JavaScript's # name syntax), the clone method needs to be overridden for the cloning to work properly.

See Also

Developer's Guide

Members

Show:

Constructors

Initializes a new instance of the PathEdgeStyleBase class.

Properties

Gets whether the rendered path should use the BridgeManager to add bridges to it.
protectedreadonly

See Also

API
getBridgeCreator
Gets a string that will be set as class attribute of the created SVG elements.

Multiple CSS classes can be set by separating them with spaces, just like with the class attribute.

The default value is the empty string.

protectedreadonly
Gets the renderer implementation for this instance.
The private implementation will delegate all API calls back to this instance.
readonlyfinal

Methods

Creates a new object that is a copy of the current instance.

Immutable subclasses should consider returning this for the best performance.

The base class implementation creates a simple shallow clone that copies all own properties to a new instance. This will not work for classes that use private fields or properties (defined with JavaScript's # name syntax) as no constructors will be run and implementations like this cannot be accessed from outside the classes that declare them.

Classes that use private members or require special initialization must override this method and manually create a new instance or call super.clone() and then explicitly copy the private fields and properties explicitly.

Return Value

Object
A new object that is a copy of this instance using a memberwise clone.
Creates the visualization for the edge's path.

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.

protected

Parameters

context: IRenderContext
The render context.
edge: IEdge
The edge to which this style instance is assigned.

Return Value

Visual
The visual as required by the createVisual interface.

See Also

API
updateVisual
Gets the bounds of the visual for the edge in the given context.
This method is called in response to a getBounds call to the instance that has been queried from the renderer.
protected

Parameters

context: ICanvasContext
The canvas context.
edge: IEdge
The edge to which this style instance is assigned.

Return Value

Rect
The visual bounds of the visual representation.
Yields the IBridgeCreator to use for adding bridges to the visualized path.
The return value of this method (which may be null) will be passed to the BridgeManager's addBridges method.
protected

Parameters

edge: IEdge
The edge.

Return Value

IBridgeCreator
This implementation returns null.
Crops the raw path obtained from getPath to accommodate for cropping and arrow heads.
To customize cropping, override this method to depend on getPath. This implementation calls getSourceArrow and getTargetArrow to obtain the cropping lengths and behavior for the arrows.
protected

Parameters

edge: IEdge
The edge to create the path for.

Return Value

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.
protected

Parameters

context: IRenderContext
The context to yield the obstacles for.
edge: IEdge
The edge.

Return Value

GeneralPath
Either null or the result of getCroppedPath.

See Also

API
IObstacleProvider
Gets the raw, un-cropped, and un-smoothed path that shall be used for the given edge.

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.

protectedabstract

Parameters

edge: IEdge
The edge to create the path for.

Return Value

GeneralPath
The path for the given edge or null if the edge is currently invisible.
Gets the number of segments of the edge.
protected

Parameters

edge: IEdge
The edge.

Return Value

number
The segment count.
Gets the value that determines the radius of the smoothing arcs that can be added to the path at the bends.
This implementation returns 0.0d, which effectively turns off path smoothing.
protected

Parameters

edge: IEdge
The edge.

Return Value

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.
This implementation returns SYMMETRIC.
protected

Parameters

edge: IEdge
The edge.

Return Value

SmoothingPolicy
The policy with which smoothing is applied to the path.
Gets the source arrow for the edge.

The default implementation returns NONE.

For the best performance, subclasses should return the same instances, whenever possible.

protected

Parameters

edge: IEdge
The edge to return the source arrow for.

Return Value

IArrow
The arrow to use.
Calculates the source arrow anchor and direction for a given arrow and path.
protected

Parameters

path: GeneralPath
The path of the edge.
arrow: IArrow
The arrow.

Return Value

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.

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.

protected

Parameters

edge: IEdge
The edge.

Return Value

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.

The default implementation returns BLACK.

For the best performance, subclasses should return the same instances, whenever possible.

protected

Parameters

edge: IEdge
The edge to return the pen for.

Return Value

Stroke
The pen or null.
Gets the tangent to the edge at the specified ratio and the corresponding touch point.
protected

Parameters

edge: IEdge
The edge.
ratio: number
A value between 0 and 1 inclusively that indicates a ratio from the beginning to the end of the path of the edge.

Return Value

Tangent
The tangent, if it exists.
Gets the tangent to the edge at the specified ratio of a segment of the edge and the corresponding touch point.
protected

Parameters

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.

Return Value

Tangent
The tangent, if it exists.
Gets the target arrow for the edge.

The default implementation returns NONE.

For the best performance, subclasses should return the same instances, whenever possible.

protected

Parameters

edge: IEdge
The edge to return the target arrow for.

Return Value

IArrow
The arrow to use.
Calculates the target arrow anchor and direction for a given arrow and path.
protected

Parameters

path: GeneralPath
The path of the edge.
arrow: IArrow
The arrow.

Return Value

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.

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.

protected

Parameters

context: IInputModeContext
The input mode context.
location: Point
The point to test.
edge: IEdge
The edge to which this style instance is assigned.

Return Value

boolean
true if the specified edge representation is hit; false otherwise.

See Also

API
hitsPolyline
Determines whether the visualization for the specified edge is included in the marquee selection.

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.

protected

Parameters

context: IInputModeContext
The input mode context.
rectangle: Rect
The marquee selection box.
edge: IEdge
The edge to which this style instance is assigned.

Return Value

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.

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.

protected

Parameters

context: IInputModeContext
The input mode context.
lassoPath: GeneralPath
The lasso selection path.
edge: IEdge
The edge to which this style instance is assigned.

Return Value

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.
This method is called in response to a isVisible call to the instance that has been queried from the renderer. This implementation simply tests whether the bounds intersect the clip.
protected

Parameters

context: ICanvasContext
The canvas context.
rectangle: Rect
The clipping rectangle.
edge: IEdge
The edge to which this style instance is assigned.

Return Value

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.

This implementation yields null for everything but:

For these interfaces, an implementation will be returned that delegates to the methods in this instance.

protected

Parameters

edge: IEdge
The edge to use for the context lookup.
type: Constructor
The type to query.

Return Value

any
An implementation of the type or null.
Updates the visual previously created by createVisual.
This method is called in response to a updateVisual call to the instance that has been queried from the renderer.
protected

Parameters

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.

Return Value

Visual
The visual as required by the createVisual interface.

See Also

API
createVisual

Static Methods

Creates a polyline path from the sourcePort via the bends to the targetPort of the edge.
static

Parameters

edge: IEdge
The edge to create the polyline path for.

Return Value

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.
The returned path ends at the source and target ports.
static

Parameters

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.

Return Value

GeneralPath
A path for a self-loop.
Crops the edge's path at its source and target nodes.
This implementation uses the IEdgePathCropper instances found in the lookup of the source and target port of the edge to perform the actual path cropping.
static

Parameters

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.

Return Value

GeneralPath
The cropped path. This can be either the same instance of the given path or a newly created instance.