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

Set the distance of the link from the object for the label side

$
0
0

@ahmetgundogdu wrote:

I use this nodeTemplate,

this.diagram.nodeTemplateMap.add("",
goMake(go.Node, “Spot”,
{
name: “MainNode”,
locationObjectName: “Shape”,
locationSpot: go.Spot.Center,
selectable: true,
isPanelMain: true,
selectionAdornmentTemplate: nodeSelectionAdornmentTemplate,
selectionObjectName: “Shape”,
resizeObjectName: “Shape”,
rotateObjectName: “Shape”,
resizeAdornmentTemplate: nodeResizeAdornmentTemplate,
resizable: this.props.config.nodeConfig.resizable,
rotatable: true,
rotateAdornmentTemplate: nodeRotateAdornmentTemplate,
isShadowed: true,
shadowVisible: false,
shadowBlur: 10,
shadowOffset: new go.Point(0, 0),
background: “transparent”,
opacity: 1,
zOrder: 1,

                click: (e: go.InputEvent, obj: go.GraphObject) => {
                    if (obj && obj.part && obj.part.data && obj.part.data.nodeConfig && obj.part.data.nodeConfig.isLock) {
                        this.diagram.select(obj.part);
                    }
                },
                mouseEnter: (e: go.InputEvent, obj: go.GraphObject) => {
                    this.toggleHighlightLinksAndNodes(obj.part.data.key, true);
                },
                mouseLeave: (e: go.InputEvent, obj: go.GraphObject) => {
                    this.toggleHighlightLinksAndNodes(obj.part.data.key, false);
                },
                doubleClick: () => {
                    this.openPropertyInspector();
                },

            },
            new go.Binding("shadowColor", "", this.bindShapeTextBackgroundColor),
            new go.Binding("location", "", this.bindShapeLocation).makeTwoWay(this.converterShapeLocation),
            new go.Binding("isActionable", "", this.bindShapeLock),
            goMake(go.Panel, "Auto",

                goMake(go.Panel, "Vertical",
                    goMake(go.Panel, "Position",
                        {
                            name: "Shape",
                            fromSpot: go.Spot.AllSides,
                            toSpot: go.Spot.AllSides,
                            portId: "",
                            toLinkable: true,
                            fromLinkableSelfNode: false,
                            fromLinkableDuplicates: true,
                            toLinkableSelfNode: false,
                            toLinkableDuplicates: true,
                            shadowVisible: false,

                            //shadowVisible: true,
                        },
                        new go.Binding("fromLinkable", "", this.bindNodeFromLinkable.bind(this)),
                        new go.Binding("toLinkable", "", this.bindNodeToLinkable.bind(this)),
                        new go.Binding("cursor", "", this.bindNodeCursor.bind(this)),
                        goMake(go.Panel, "Viewbox",
                            goMake(go.Panel, "Position", {
                                alignment: new go.Spot(-1, -1),

                            },
                                this.getLockedFigure(lockedSVGPath),
                                this.getLockedFigure(lockedSVGPath2),
                                new go.Binding("visible", "", this.bindShapeLock),

                            ),
                        ),

                        //goMake(go.Shape, "Rectangle",
                        //    {
                        //        geometryString: lockedSVGPath,
                        //        fill: "black",
                        //        stroke: "black",
                        //        alignment: new go.Spot(-1, -1)
                        //    },
                        //    new go.Binding("visible", "", this.bindShapeLock),
                        //    new go.Binding("desiredSize", "", (sourceData: IFlowItemBase) => {
                        //        let scale = 10 / 50;
                        //        return new go.Size(sourceData.nodeConfig.size.width * scale, sourceData.nodeConfig.size.height * scale);
                        //    }),
                        //),

                        goMake(go.Shape, "Rectangle", //link drawn provider
                            {
                                stretch: go.GraphObject.Fill,
                                fill: "transparent",
                                strokeWidth: 0,
                                shadowVisible: false,
                            }),
                        goMake(go.Panel, "Viewbox",
                            {
                                _isGuideObject: true,
                                padding: new go.Margin(5),
                            },
                            new go.Binding("desiredSize", "", this.bindShapeSize),
                            goMake(go.Panel, "Position",
                                {
                                    itemTemplate:
                                        goMake(go.Panel,
                                            goMake(go.Shape, "RoundedRectangle",
                                                {
                                                    fill: "transparent",
                                                    isGeometryPositioned: true,
                                                    strokeWidth: 2,
                                                    shadowVisible: false,
                                                    //shadowVisible: true,
                                                    //geometryStretch: go.GraphObject.Fill,
                                                },

                                                new go.Binding("stroke", "", this.bindPanelItemBorderColor.bind(this)),
                                                new go.Binding("fill", "", this.bindPanelItemColor.bind(this)),
                                                new go.Binding("geometry", "", this.bindShapeGeometry.bind(this)),
                                                new go.Binding("strokeWidth", "", (sourceData: IUnifiedShape) => { return sourceData.stroke ? 1 : 0 })
                                            )
                                        )
                                },
                                new go.Binding("itemArray", "", this.bindPanelItemArray.bind(this)),

                            ),
                        ),

                        new go.Binding("desiredSize", "", this.bindShapeSize).makeTwoWay(this.converterShapeSize),
                        new go.Binding("angle", "", this.bindShapeAngle).makeTwoWay(this.converterShapeAngle),
                    ),
                    goMake(go.Panel, "Horizontal", {
                        //margin: new go.Margin(5, 0, 5, 0),
                    },
                        goMake(go.TextBlock,
                            {
                                name: "textBlock",
                                editable: true,  // editing the text automatically updates the model data
                                cursor: "pointer",  // visual hint that the user can do something with this node label
                                shadowVisible: true,
                                stroke: "transparent",
                            },
                            new go.Binding("text", "", this.bindShapeText).makeTwoWay(this.converterShapeText),
                            new go.Binding("stroke", "", this.bindShapeTextColor),
                            new go.Binding("visible", "", (sourceData: IFlowItemBase) => {
                                return !(sourceData.typeCode == 33 || sourceData.typeCode == 13);
                            }),

                            new go.Binding("font", "", this.bindShapeTextFont),
                            new go.Binding("isUnderline", "", this.bindShapeTextUnderline),
                            new go.Binding("background", "", this.bindShapeTextBackgroundColor),
                            new go.Binding("textAlign", "", this.bindShapeTextAlignment),
                        )
                    )
                ),
                goMake(go.Shape,  // provide interior area where the user can grab the node
                    {
                        //_isGuideObject: true,
                        fill: "transparent",
                        stroke: "smokewihte",
                        opacity: 0,
                        cursor: "move",
                        //position: new go.Point(0, 0),
                        click: function (e: any, obj: go.Shape) {
                            obj.part.rotateAdornmentTemplate.visible = true;
                            if (obj.diagram.lastInput.shift) {
                                obj.cursor = "pointer";
                            }
                        }
                    },
                    new go.Binding("desiredSize", "", (sourceData: IFlowItemBase) => {
                        return new go.Size(sourceData.nodeConfig.size.width - (sourceData.nodeConfig.size.width / 2), sourceData.nodeConfig.size.height - (sourceData.nodeConfig.size.height / 2))
                    }).makeTwoWay(),
                ),
            ),
        )
    );

And i draw link

You see red link, fromNode:FlowStarter toNode:DeleteDocument .
If the link is linked from the corner of the text, I want to leave a space between the link and the shape.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles