I have this NOTE shape from bpmn shapes, when Im trying to make it resizable, the shapes is getting distorted. Following is the code for the shape.
Image before resizable
Image after resizing
export class TextAnnotationShape {
constructor() {
this.leftCShape();
}
getTemplate = (contextMenu: go.Adornment | go.HTMLInfo) => {
const $ = go.GraphObject.make;
return $(
go.Node,
"Spot",
{
contextMenu,
resizable: true,
linkValidation: GRAPH_CONFIG.LINK_VALIDATIONS.TEXT_ANNOTATION,
dragComputation: avoidNodeOverlap,
},
new go.Binding("location"),
$(
go.Panel,
"Auto", { padding: 2, },
$(go.Shape, "Annotation", // A left bracket shape
{
cursor: "pointer",
strokeWidth: 4,
stroke: "gray",
fill: "transparent",
}
),
$(go.Shape, "Rectangle",
{
fill: "#fff",
stroke: "#000",
strokeWidth: 1,
width: 155,
height: 60,
shadowVisible: true,
},
new go.Binding("figure", "shape"),
new go.Binding("stroke", "isSelected", function (
sel,
shape: go.Shape
) {
return sel ? "#2A7DE1" : "#fff";
}).ofObject()
),
$(go.TextBlock,
{
alignment: go.Spot.Left,
margin: new go.Margin(0, 0, 0, 10),
stroke: "#060322",
font: "normal 10px sans-serif",
editable: true,
isActionable: true,
isMultiline: true,
width: 120,
textValidation: GRAPH_CONFIG.TEXT_VALIDATIONS.TEXT_ANNOTATION,
textEdited: GRAPH_CONFIG.TEXT_EDITED.TEXT_ANNOTATION,
},
new go.Binding("text", "name").makeTwoWay()
)
),
...GRAPH_CONFIG.ENTITY_PORTS.TEXT_ANNOTATION,
GRAPH_CONFIG.REMOVE_DEFAULT_BORDER
);
};
leftCShape = () => {
go.Shape.defineFigureGenerator("Annotation", function (shape, w, h) {
const len = Math.min(w, 10);
return new go.Geometry().add(
new go.PathFigure(len, 0)
.add(new go.PathSegment(go.PathSegment.Line, 0, 0))
.add(new go.PathSegment(go.PathSegment.Line, 0, h))
.add(new go.PathSegment(go.PathSegment.Line, len, h))
);
});
};
}
What should be done so that it remains same shape as before only the height and width changes
Note: Ratio can be same.