I have “Custom” named object which is the same figure generated using defineFigureGenerator and only by using this object in combination with Shape.geometryString i am able to get angle of the rotation in the model. And also if i am not using Custom with shape then adornment is also not rotating.
go.Shape.defineFigureGenerator("Custom", function(shape, w, h) {
var geo = go.Geometry.parse(CustomFigures.Nx);
geo.normalize();
return geo;
});
Without Custom:
var NxTemplate =
$(go.Node,
"Spot", nodeStyle(),
{
selectionAdornmentTemplate: // custom selection adornment
$(go.Adornment, "Spot",
$(go.Placeholder),
$(go.Shape,
{
geometryString: CustomFigures.ADNx,
alignment: go.Spot.Center,
alignmentFocus: go.Spot.Left,
stroke: "pink",
})
)
},
$(go.Shape,
{
name: "NX",
geometryString: CustomFigures.Nx,
width: 90,
height:30,
stroke: "red",
fill: "lightgray",
geometryStretch: go.GraphObject.Uniform
},
new go.Binding("figure", "key")),
{ rotatable: true, rotateObjectName: "NX" },
{ resizable: true, resizeObjectName: "NX" },
new go.Binding("angle").makeTwoWay(),
);
“Model data : { “class”: “GraphLinksModel”,
“nodeDataArray”: [
{“category”:“NX”, “key”:-7, “loc”:“1001.9999999999993 142”}
],”
With Custom:
var NxTemplate =
$(go.Node,
"Spot", nodeStyle(),
{
selectionAdornmentTemplate: // custom selection adornment
$(go.Adornment, "Spot",
$(go.Placeholder),
$(go.Shape,
{
geometryString: CustomFigures.ADNx,
alignment: go.Spot.Center,
alignmentFocus: go.Spot.Left,
stroke: "pink",
})
)
},
$(go.Shape, "Custom",
{
name: "NX",
geometryString: CustomFigures.Nx,
width: 90,
height:30,
stroke: "red",
fill: "lightgray",
geometryStretch: go.GraphObject.Uniform
},
new go.Binding("figure", "key")),
{ rotatable: true, rotateObjectName: "Custom" },
{ resizable: true, resizeObjectName: "NX" },
new go.Binding("angle").makeTwoWay(),
);
“Model data : { “class”: “GraphLinksModel”,
“nodeDataArray”: [
{“category”:“NX”, “key”:-7, “loc”:“642 131”, “angle”: 36.18477897677684 }
],”
Location with angle coming in model.
Rotation is only working fine with “Custom” and Resizing only working fine with “NX”