Extending DefaultLinkModel
Last updated
Last updated
Much like extending nodes, custom links can also be created. In the below example, we have created a link that renders a circle animating from the source port to the target port.
In this specific example, we extended the DefaultLinkModel
because we wanted to retain a lot of the functionality that it provides in the base class:
Now we need to create a new link factory to tell the system how our new link model fits into the core system. We specifically are going to extend the DefaultLinkFactory
because we still want to render a DefaultLinkWidget
. The only difference is that we want each path segment to be a red line with an animating circle. Fortunately, the DefaultLinkWidget
already uses the generateLinkSegment()
method defined in the DefaultLinkFactory
to accomplish this. The only thing we need to do, is provide a different type of segment:
The actual code for the AdvancedLinkSegment
can be found here (it is in the demo-custom-link1
folder in the demo gallery).
This is the easiest and most simple way to get started with custom links.