Questions about links

Hi, i have some questions about the links

1/ i define a node with 3 ports on it like this:

myDiagram.nodeTemplateMap.add(“pic”,
$$(go.Node, go.Panel.Spot,{ locationSpot: go.Spot.Center, isShadowed: false},new go.Binding(“location”, “loc”).makeTwoWay(),
$$(go.Panel, go.Panel.Table,
<span =“Apple-tab-span” style=“white-space:pre”> …
<span =“Apple-tab-span” style=“white-space:pre”> $$(go.Picture,
<span =“Apple-tab-span” style=“white-space:pre”> {row: 0, column: 0 },new go.Binding(“source”, “img”)),
<span =“Apple-tab-span” style=“white-space:pre”> makePort(“T”, go.Spot.Top, true, true),
makePort(“L”, go.Spot.Left, true, true),
makePort(“R”, go.Spot.Right, true, true),
makePort(“B”, go.Spot.Bottom, true, true),

));

Function makePort i reuse of the sample http://gojs.net/latest/samples/flowchart.html

I want to do this:

Node A ------> Node B (port Right on node A links to port Left on Node B)

through relinkingTool how can i make the port Right on Node A connect to the whole Node B not through any port and vice versa, any port on Node B can connect with the whole Node A

2/ Can i add more “waypoint” on the link as many as i want so that i can reshape the link more flexible? I also enable “reshapable” property but it seems to enable two waypoints on the links

Thanks

  1. Are you sure you want to continue using ports if you want to be able to connect to a Node as a whole? If you do, then you just need to declare the whole Node to be a port by setting its GraphObject.portId, and also setting GraphObject.toLinkable and/or GraphObject.fromLinkable and any other linking related properties.

  2. Yes, this is possible with a custom LinkReshapingTool, which is what implements the “Part.reshapable” property’s behavior on Links. In fact, we have already implemented such functionality in version 1.2. But it will be a couple of months before that becomes available.

  1. Yeah, i know, but in this case i want to utilize both ability to use the ports and the whole node is another port. The problem is how to switch between these two modes (turn the link connecting to a port into connecting to the whole node- as i mentioned and vice versa) through the RelinkingTool

2)So , now can i do something like right-clicking on a specific link and the context menu has a section like “add more way point” and when i choose that section the link will be added 1 more way point with the current version 1.1.3 ?

  1. If you allow users to draw links to both a small port and a port that is the whole Node, then the user can decide which one he wants to connect with.

Or are you asking how to change which port a link connects with? In the model, call GraphLinksModel.setFromPortIdForLinkData or setToPortIdForLinkData.

  1. No, if you set Link.resegmentable to true as well as Link.reshapable, then when the user selects the Link additional reshape handles will be placed in the middle of each segment and the user can drag it to insert a new segment there. Drag a regular reshape handle (i.e. one of the ones you see in version 1.1 when Link.reshapable is true) to be on a straight line between the previous and next reshape handle, then the segment is automatically removed.

No context menu is needed. However you could still implement such functionality if you wanted…

  1. yes, that is what is need :)). Thanks

  2. i met this
    Uncaught Error: Trying to set undefined property “resegmentable” on object: Link#6625

and i’m using gojs ver 1.1.3.
Here is the code:

myDiagram.linkTemplate =
$$(go.Link,
{ selectionAdornmentTemplate:
$$(go.Adornment,
$$(go.Shape,
{ isPanelMain: true, stroke: “dodgerblue”, strokeWidth: 3 }),
$$(go.Shape,
{ toArrow: “Standard”, fill: “dodgerblue”, stroke: null, scale: 1 })),
routing: go.Link.Normal,
curve: go.Link.Bezier,
toShortLength: 2 },

      {
        routing: go.Link.AvoidsNodes,
        curve: go.Link.JumpOver,
        toShortLength: 2,

<span =“Apple-tab-span” style=“white-space:pre”> relinkableFrom: true, corner: 5,
<span =“Apple-tab-span” style=“white-space:pre”> relinkableTo: true, reshapable:true ,resegmentable: true,
<span =“Apple-tab-span” style=“white-space:pre”> },
… });

As I said earlier, this feature will be new in version 1.2.

ok thanks :)