什么是 JointJS 库中元素形状的 fsa.State 方法

What is fsa.State method of element Shapes in JointJS library

我正在尝试了解 Joint Js lib v-2.2Finite State Machine 演示的源代码。我卡在下面 function

function state(x, y, label) {

var cell = new joint.shapes.fsa.State({
    position: { x: x, y: y },
    size: { width: 60, height: 60 },
    attrs: { text : { text: label }}
});
graph.addCell(cell);
return cell;
};

在上面,我试图在官方文档中为 fsa.State 获取以下构造函数的引用,但找不到。

var cell = new joint.shapes.fsa.State({..});

任何提示它是如何工作的。

参考链接:

https://resources.jointjs.com/demos/fsa

https://resources.jointjs.com/demos/joint/demo/fsa/src/fsa.js

如果您查看 fsa 演示示例的源代码,您可以在此处找到 - https://resources.jointjs.com/demos/joint/demo/fsa/index.html

您会看到除了 joinjs 库及其依赖项之外,还添加了一个脚本

<script src="../../plugins/shapes/joint.shapes.fsa.js"></script>

如果你查看它的源代码,这个插件定义了 fsa.State

joint.shapes.basic.Circle.define('fsa.State', {...

fsa.State 不是核心 jointjs 库的一部分。要使用它,您必须包含此插件。

可能因为这个原因,它不是官方文档的一部分。但是你可以在GitHubhttps://github.com/clientIO/joint/tree/master/dist上找到源代码有一个文件joint.shapes.fsa.js.

在官方文档中阅读有关定义您自己的形状的信息https://resources.jointjs.com/docs/jointjs/v2.2/joint.html#dia.Cell.define