Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 7069

Shapes on links moved procentual by resegmenting

$
0
0

@markus wrote:

Hello,

We draw a shape on a link. This link is resegmentable. If we make a subdivision of a link, then the shape is been slipped to an offset. We think that there is an offset been set in code behind, but can not figure out why and where. The position of the points (start and end) remain the same even after the move.

The aim is that the shape is always drawn on the link, even if points are added or removed.

Can you give us a hint on this?

LinkTemplate:

go.GraphObject.make(go.Link,
        {
            name: "LINK",
            selectable: true,
            relinkableFrom: true,
            relinkableTo: true,
            reshapable: true,
            resegmentable: true,
            adjusting: go.Link.End,
            fromEndSegmentLength: 45,
            toEndSegmentLength: 45,
            movable: false,
            selectionChanged: function(part) {
                if (part.data.from !== undefined && part.data.to !== undefined && !part.isSelected) {
                    part.diagram.model.setDataProperty(part.data, 'visible', false);
                }
                else {
                    part.diagram.model.setDataProperty(part.data, 'visible', true);
                }
            }
        },
        new go.Binding("points", "points"),
        go.GraphObject.make(go.Shape,
            {
                name: "FLOW",
                fill: "green",
                stroke: "transparent",
                pickable: true,
                click: function(e, obj) {
                    obj.part.isSelected = true;
                },
            },
            new go.Binding("segmentOffset", "flowSegmentOffset", function(targetprop, sourceprop) {
                return new go.Point(0, 0);
            }).makeTwoWay(),
            new go.Binding("geometryString", "points", function(targetprop, sourceprop) {
                if (sourceprop.part.data.from !== undefined && sourceprop.part.data.to !== undefined) {
                    return self.calculatePath(targetprop.n);
                }
                return "";
            }).ofObject()
        ),
        go.GraphObject.make(go.Shape, {
            name: "AA",
            isPanelMain: true,
        },
            new go.Binding("visible", "visible")
        ),
        go.GraphObject.make(go.Shape,
            {
                toArrow: "Standard"
            },
            new go.Binding("visible", "visible")
        ),
        go.GraphObject.make(go.Panel, "Auto",
            {
                cursor: "pointer"
            },
            go.GraphObject.make(go.TextBlock, "transition",  // the label
                {
                    textAlign: "center",
                    font: "9pt sans-serif",
                    stroke: "black",
                    editable: false
                },
                new go.Binding("text", "text").makeTwoWay()
            ),
            // The GraphObject.segmentOffset property is what the LinkLabelDraggingTool modifies.
            // This TwoWay binding saves any changes to the same named property on the link data.
            new go.Binding("segmentOffset", "segmentOffset", go.Point.parse).makeTwoWay(go.Point.stringify)
        )

    )

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles