Very good guess. However the red rectangle was just a way to visualize my geometry.
Here is an abbreviated version of the full template.
The node is created as a spot so that the various text elements may be positioned outside the main SHAPE. So to with the ports. I have avoided the Auto panel due to its constraints.
/*
Loosely based on the pipes and planogram examples
We have modified the resizing and dragging tools to
behave with this template as well.
*/
$$(go.Node, "Spot", //a spot panel because the textblocks below MAY be positioned outside the main rectangle.
{
resizable: true, resizeObjectName: "SHAPE",
contextMenu: panelContextMenu,
resizeAdornmentTemplate: barnyPanelAdornment,
resizeCellSize: new go.Size(1, 17.5),
locationSpot: new go.Spot(0, 0, cellSize.width / 2, cellSize.height / 2),
mouseDragLeave: function (e, node) {
node.updateTargetBindings();
},
name: "Barny",
// hide a port when it is connected
linkConnected: function (node, link, port) {
port.visible = false;
},
linkDisconnected: function (node, link, port) {
port.visible = true;
}
},
new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify),
// this is the primary thing people see
$$(go.Shape, "Rectangle",
{
name: "SHAPE",
fill: "transparent",
minSize: cellSize,
desiredSize: cellSize,
strokeWidth: .5,
},
/*Other bindings go here*/
new go.Binding("desiredSize", "size", go.Size.parse).makeTwoWay(go.Size.stringify),
new go.Binding("position", "pos", go.Point.parse).makeTwoWay(go.Point.stringify)),
//optional picture
$$(go.Picture, { /*imageStretch: go.GraphObject.Fill */ },
new go.Binding("source", "imageSrc").makeTwoWay(),
new go.Binding("imageStretch", "imageStretch", go.Binding.parseEnum(go.GraphObject, go.GraphObject.Fill)).makeTwoWay(go.Binding.toString),
new go.Binding("desiredSize", "", function (p, o) {
var main = o.part.findMainElement();
return main.desiredSize;
}).makeTwoWay()),
$$(go.TextBlock,
{ _kind: "descriptor_text", _isNodeLabel: true, cursor: "move", alignmentFocus: go.Spot.TopLeft, font: "normal normal normal 9px Segoe UI,sans-serif", stroke: "black", editable: true, isMultiline: false, name: "ManuName" },
/*Other bindings go here*/
new go.Binding("alignment", "ManuAlignment", function (p) {
if (p == null) {
return new go.Spot(0, 0, 0, 0);
}
else {
return go.Spot.parse(p);
}
}).makeTwoWay(go.Spot.stringify)),
/*Many other TextBlocks go here. Removed for brevity*/
//And now for the ports which MAY also be positioned outside the "SHAPE"
$$(go.Panel, "Spot",
new go.Binding("itemArray", "snapGlueArray"),
{
name: "gluePortPanel",
itemTemplate:
// each port is an "X" shape whose alignment spot and port ID are given by the item data
$$(go.Panel, "Spot",
new go.Binding("portId", "portId"),
new go.Binding("desiredSize", "", function (s, e) {
var main = e.part.findMainElement();
return main.desiredSize;
}),
new go.Binding("position", "", function (s, e) {
var main = e.part.findMainElement();
return main.position;
}),
$$(go.Shape, "Rectangle",
{
//desiredSize: cellSize,
stroke: "red",
fill: "transparent",
visible: true //just so we can see what we are creating. We will set this to false later.
},
new go.Binding("portId", "portId")),
$$(go.Shape, "XLine",
{ contextMenu: gluePortContextMenu, name: "Port XLine", width: gluePortSize, height: gluePortSize, background: "transparent", fill: null, stroke: gluePortColor, strokeWidth: .5, cursor: "move" },
new go.Binding("figure", "portId", portFigure),//from the pipes example
new go.Binding("portId", "portId"),
new go.Binding("alignmentFocus", "spotFocus", go.Spot.parse),
new go.Binding("alignment", "spot", go.Spot.parse).makeTwoWay(go.Spot.stringify),
new go.Binding("angle", "angle")),
$$(go.TextBlock,
{ font: "normal normal normal 3px Segoe UI, san-serif", alignmentFocus: go.Spot.BottomLeft, editable: true },
new go.Binding("text", "portConn").makeTwoWay(),
new go.Binding("alignment", "spot", go.Spot.parse).makeTwoWay(go.Spot.stringify))
)
})
); // end Node
I have tried eliminating the red rectangle and marking SHAPE as isPanelMain:true.
I have tried binding the itemArray directly to the parent spot node.
No joy.
How would you structure this?
Thanks again.