ice-render 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +229 -141
  3. package/dist/THIRD-PARTY-NOTICES.txt +32 -0
  4. package/dist/index.cjs +30 -0
  5. package/dist/index.mjs +30 -0
  6. package/dist/index.umd.js +6 -1
  7. package/dist/types/FrameManager.d.mts +26 -0
  8. package/dist/types/FrameManager.d.ts +26 -26
  9. package/dist/types/ICE.d.mts +369 -0
  10. package/dist/types/ICE.d.ts +369 -107
  11. package/dist/types/a11y/accessibility.d.mts +46 -0
  12. package/dist/types/a11y/accessibility.d.ts +46 -0
  13. package/dist/types/animation/AnimationManager.d.mts +96 -0
  14. package/dist/types/animation/AnimationManager.d.ts +96 -25
  15. package/dist/types/animation/Easing.d.mts +33 -0
  16. package/dist/types/animation/Easing.d.ts +33 -32
  17. package/dist/types/consts/BIG_ZINDEX_NUMBER.d.mts +14 -0
  18. package/dist/types/consts/BIG_ZINDEX_NUMBER.d.ts +14 -14
  19. package/dist/types/consts/COMPONENT_TYPE_MAPPING.d.mts +45 -0
  20. package/dist/types/consts/COMPONENT_TYPE_MAPPING.d.ts +45 -36
  21. package/dist/types/consts/DOM_EVENT_MAPPING_CONSTS.d.mts +37 -0
  22. package/dist/types/consts/DOM_EVENT_MAPPING_CONSTS.d.ts +37 -19
  23. package/dist/types/consts/ICE_EVENT_NAME_CONSTS.d.mts +27 -0
  24. package/dist/types/consts/ICE_EVENT_NAME_CONSTS.d.ts +27 -20
  25. package/dist/types/control-panel/AlignmentGuideManager.d.mts +92 -0
  26. package/dist/types/control-panel/AlignmentGuideManager.d.ts +92 -0
  27. package/dist/types/control-panel/ICEControlPanel.d.mts +37 -0
  28. package/dist/types/control-panel/ICEControlPanel.d.ts +37 -37
  29. package/dist/types/control-panel/ICEControlPanelManager.d.mts +25 -0
  30. package/dist/types/control-panel/ICEControlPanelManager.d.ts +25 -23
  31. package/dist/types/control-panel/link-controls/LineControlPanel.d.mts +39 -0
  32. package/dist/types/control-panel/link-controls/LineControlPanel.d.ts +39 -39
  33. package/dist/types/control-panel/transform-controls/ResizeControl.d.mts +38 -0
  34. package/dist/types/control-panel/transform-controls/ResizeControl.d.ts +38 -38
  35. package/dist/types/control-panel/transform-controls/RotateControl.d.mts +12 -0
  36. package/dist/types/control-panel/transform-controls/RotateControl.d.ts +12 -12
  37. package/dist/types/control-panel/transform-controls/TransformControlPanel.d.mts +83 -0
  38. package/dist/types/control-panel/transform-controls/TransformControlPanel.d.ts +83 -74
  39. package/dist/types/control-panel/transform-controls/constraints.d.mts +24 -0
  40. package/dist/types/control-panel/transform-controls/constraints.d.ts +24 -0
  41. package/dist/types/cross-platform/PolyfillPath2D.d.mts +31 -0
  42. package/dist/types/cross-platform/PolyfillPath2D.d.ts +31 -0
  43. package/dist/types/cross-platform/root.d.mts +7 -0
  44. package/dist/types/cross-platform/root.d.ts +7 -2
  45. package/dist/types/event/DOMEventDispatcher.d.mts +68 -0
  46. package/dist/types/event/DOMEventDispatcher.d.ts +68 -29
  47. package/dist/types/event/DOMEventInterceptor.d.mts +36 -0
  48. package/dist/types/event/DOMEventInterceptor.d.ts +36 -7
  49. package/dist/types/event/EventBus.d.mts +27 -0
  50. package/dist/types/event/EventBus.d.ts +27 -27
  51. package/dist/types/event/ICEEvent.d.mts +46 -0
  52. package/dist/types/event/ICEEvent.d.ts +46 -46
  53. package/dist/types/event/ICEEventTarget.d.mts +106 -0
  54. package/dist/types/event/ICEEventTarget.d.ts +106 -106
  55. package/dist/types/event/input-normalize.d.mts +75 -0
  56. package/dist/types/event/input-normalize.d.ts +75 -0
  57. package/dist/types/geometry/GeoLine.d.mts +24 -0
  58. package/dist/types/geometry/GeoLine.d.ts +24 -23
  59. package/dist/types/geometry/GeoPoint.d.mts +53 -0
  60. package/dist/types/geometry/GeoPoint.d.ts +53 -66
  61. package/dist/types/geometry/GeoUtil.d.mts +73 -0
  62. package/dist/types/geometry/GeoUtil.d.ts +73 -37
  63. package/dist/types/geometry/ICEBoundingBox.d.mts +81 -0
  64. package/dist/types/geometry/ICEBoundingBox.d.ts +81 -81
  65. package/dist/types/graphic/ICEComponent.d.mts +436 -0
  66. package/dist/types/graphic/ICEComponent.d.ts +436 -264
  67. package/dist/types/graphic/ICEDotPath.d.mts +99 -0
  68. package/dist/types/graphic/ICEDotPath.d.ts +99 -63
  69. package/dist/types/graphic/ICEImage.d.mts +17 -0
  70. package/dist/types/graphic/ICEImage.d.ts +17 -17
  71. package/dist/types/graphic/ICEPath.d.mts +39 -0
  72. package/dist/types/graphic/ICEPath.d.ts +39 -36
  73. package/dist/types/graphic/container/ICEGroup.d.mts +101 -0
  74. package/dist/types/graphic/container/ICEGroup.d.ts +101 -53
  75. package/dist/types/graphic/link/ICEBezier.d.mts +23 -0
  76. package/dist/types/graphic/link/ICEBezier.d.ts +23 -15
  77. package/dist/types/graphic/link/ICELinkHook.d.mts +52 -0
  78. package/dist/types/graphic/link/ICELinkHook.d.ts +52 -52
  79. package/dist/types/graphic/link/ICELinkSlot.d.mts +54 -0
  80. package/dist/types/graphic/link/ICELinkSlot.d.ts +54 -46
  81. package/dist/types/graphic/link/ICELinkSlotManager.d.mts +28 -0
  82. package/dist/types/graphic/link/ICELinkSlotManager.d.ts +28 -28
  83. package/dist/types/graphic/link/ICEPolyLine.d.mts +292 -0
  84. package/dist/types/graphic/link/ICEPolyLine.d.ts +292 -219
  85. package/dist/types/graphic/link/ICEVisioLink.d.mts +163 -0
  86. package/dist/types/graphic/link/ICEVisioLink.d.ts +163 -129
  87. package/dist/types/graphic/shape/ICECircle.d.mts +19 -0
  88. package/dist/types/graphic/shape/ICECircle.d.ts +19 -19
  89. package/dist/types/graphic/shape/ICEEllipse.d.mts +29 -0
  90. package/dist/types/graphic/shape/ICEEllipse.d.ts +29 -23
  91. package/dist/types/graphic/shape/ICEIsogon.d.mts +52 -0
  92. package/dist/types/graphic/shape/ICEIsogon.d.ts +52 -52
  93. package/dist/types/graphic/shape/ICERect.d.mts +10 -0
  94. package/dist/types/graphic/shape/ICERect.d.ts +10 -17
  95. package/dist/types/graphic/shape/ICERose.d.mts +41 -0
  96. package/dist/types/graphic/shape/ICERose.d.ts +41 -41
  97. package/dist/types/graphic/shape/ICEStar.d.mts +45 -0
  98. package/dist/types/graphic/shape/ICEStar.d.ts +45 -45
  99. package/dist/types/graphic/text/ICEText.d.mts +137 -0
  100. package/dist/types/graphic/text/ICEText.d.ts +137 -65
  101. package/dist/types/index.d.mts +55 -0
  102. package/dist/types/index.d.ts +55 -41
  103. package/dist/types/layout/ICEBorderLayout.d.mts +34 -0
  104. package/dist/types/layout/ICEBorderLayout.d.ts +34 -0
  105. package/dist/types/layout/ICEBoxLayout.d.mts +30 -0
  106. package/dist/types/layout/ICEBoxLayout.d.ts +30 -0
  107. package/dist/types/layout/ICECardLayout.d.mts +36 -0
  108. package/dist/types/layout/ICECardLayout.d.ts +36 -0
  109. package/dist/types/layout/ICEFlowLayout.d.mts +31 -0
  110. package/dist/types/layout/ICEFlowLayout.d.ts +31 -0
  111. package/dist/types/layout/ICEGridLayout.d.mts +33 -0
  112. package/dist/types/layout/ICEGridLayout.d.ts +33 -0
  113. package/dist/types/layout/ICELayeredLayout.d.mts +49 -0
  114. package/dist/types/layout/ICELayeredLayout.d.ts +49 -0
  115. package/dist/types/layout/ICELayoutManager.d.mts +33 -0
  116. package/dist/types/layout/ICELayoutManager.d.ts +33 -0
  117. package/dist/types/layout/ICEOverlayLayout.d.mts +25 -0
  118. package/dist/types/layout/ICEOverlayLayout.d.ts +25 -0
  119. package/dist/types/persistence/Deserializer.d.mts +43 -0
  120. package/dist/types/persistence/Deserializer.d.ts +43 -14
  121. package/dist/types/persistence/Serializer.d.mts +35 -0
  122. package/dist/types/persistence/Serializer.d.ts +35 -26
  123. package/dist/types/plugin/PluginHost.d.mts +86 -0
  124. package/dist/types/plugin/PluginHost.d.ts +86 -0
  125. package/dist/types/renderer/CanvasRenderer.d.mts +150 -0
  126. package/dist/types/renderer/CanvasRenderer.d.ts +150 -22
  127. package/dist/types/renderer/ObjectCache.d.mts +79 -0
  128. package/dist/types/renderer/ObjectCache.d.ts +79 -0
  129. package/dist/types/renderer/dirty-rect-util.d.mts +86 -0
  130. package/dist/types/renderer/dirty-rect-util.d.ts +86 -0
  131. package/dist/types/theme/ICETheme.d.mts +382 -0
  132. package/dist/types/theme/ICETheme.d.ts +382 -0
  133. package/dist/types/util/ImageCache.d.mts +19 -0
  134. package/dist/types/util/ImageCache.d.ts +19 -19
  135. package/dist/types/util/data-util.d.mts +43 -0
  136. package/dist/types/util/data-util.d.ts +43 -19
  137. package/dist/types/util/gl-matrix-skew.d.mts +14 -0
  138. package/dist/types/util/gl-matrix-skew.d.ts +14 -14
  139. package/dist/types/util/lang.d.mts +28 -0
  140. package/dist/types/util/lang.d.ts +28 -0
  141. package/dist/types/util/uuid.d.mts +1 -0
  142. package/dist/types/util/uuid.d.ts +1 -1
  143. package/package.json +119 -81
  144. package/dist/index.cjs.js +0 -25
  145. package/dist/index.js +0 -25
@@ -0,0 +1,163 @@
1
+ import ICEPolyLine from './ICEPolyLine.mjs';
2
+ /**
3
+ * ! FIXME: 删掉对 GeoPoint/GeoLine/GeoUtil 的依赖
4
+ * @class ICEVisioLink
5
+ *
6
+ * Visio 型的连接线
7
+ *
8
+ * 模拟 Microsoft Visio 中的折线算法,此实现从 diagramo 改进而来:http://diagramo.com/ 。
9
+ *
10
+ * 基本特性:
11
+ *
12
+ * - ICEVisioLink 只有 2 个端点,起点和终点。
13
+ * - 除起始点和终点坐标之外,其它点会自动插值计算。
14
+ * - ICEVisioLink 只能连接 2 个非线条类的组件。
15
+ * - 线条互相之间不能连接,在 ICE 引擎中,不能用线条连接线条。
16
+ * - 每一个可以被连接的组件上都有 4 个插槽(Slot),4 个插槽分布在组件最小边界盒子 4 条边的几何中点位置上。
17
+ * - ICEVisioLink 的端点在移动时会判断是否与某个插槽发生碰撞,如果与某个插槽发生碰撞, ICEVisioLink 会连接到插槽所在的组件上。
18
+ * - 同一个插槽(Slot)上可以连 N 根线,Slot 与 ICEVisioLink 之间的关系是 1->N 。
19
+ *
20
+ * @author 大漠穷秋<damoqiongqiu@126.com>
21
+ */
22
+ export default class ICEVisioLink extends ICEPolyLine {
23
+ /**
24
+ * FIXME:补全 props 配置项的描述
25
+ */
26
+ constructor(props?: any);
27
+ protected static arrangeParam(props: any): any;
28
+ /**
29
+ * ICEVisioLink 有自己特殊的计算方式。
30
+ *
31
+ * @overwrite
32
+ * @returns
33
+ */
34
+ protected __calcDots(): any;
35
+ /**
36
+ * 贝塞尔形态:从两端点与插槽法线构造三次贝塞尔,等分采样后写回 points/dots。
37
+ *
38
+ * **为什么要把采样点写回 `state.points`**(而不是只算 dots):`ICEPolyLine.isDotsOnSameLine()`
39
+ * 与 `getLabelPosition()` 都只读 `state.points`。若 points 只剩首尾两点会被判「共线」,
40
+ * 包围盒就会走 `splitEndpointsTo4Points()`、只按线宽沿弦外扩 → 曲线鼓出的部分落在盒外
41
+ * → dirty-rect 上屏快照盒偏小、局部重绘会把曲线裁掉。写回之后包围盒/标签/命中都自然正确。
42
+ *
43
+ * @returns
44
+ */
45
+ protected __calcBezierDots(): any;
46
+ /**
47
+ * 由两端点构造三次贝塞尔并等分采样(世界坐标)。
48
+ *
49
+ * 控制点:`C1 = start + dir(start 插槽) * offset`、`C2 = end + dir(end 插槽) * offset`,
50
+ * `offset = max(|end-start| * 0.45, 24)`,方向为插槽**外法线**(与正交布线的语义一致)。
51
+ */
52
+ protected buildBezierPoints(start: number[], end: number[]): number[][];
53
+ /**
54
+ * 某端插槽的外法线方向;C 槽 / 未连接 / 未知位置回落到弦方向。
55
+ *
56
+ * 注意 start 端用 `+chord`、end 端用 `-chord`(指向弦的内侧):两端都取 `+chord` 的话,
57
+ * 控制点会落在两端点连线之外,曲线会先冲出去再拐回来(终点被越过)。
58
+ */
59
+ protected slotDirection(terminal: string, chord: number[]): number[];
60
+ /**
61
+ * @overwrite
62
+ * 贝塞尔形态不走正交路由。
63
+ *
64
+ * 应用层(如 ice-entity-designer 的 `routeRelations()`)会在布局后无条件把 `routeType` 设为
65
+ * `'orthogonal'`;不拦掉的话每次布局/移动都会用正交折线整体覆盖 `state.points`:
66
+ * 虽然下一帧 `__calcDots` 会把曲线重新采样回来,但语义错乱且白算一次。
67
+ */
68
+ protected recalculateRoute(): void;
69
+ /**
70
+ * 在起点和终点之间插值。
71
+ *
72
+ * @returns
73
+ */
74
+ protected interpolate(): any[];
75
+ /**
76
+ * Tests if a vector of points is an orthogonal path (moving in multiples of 90 degrees).
77
+ *
78
+ *
79
+ * 正交判定。Visio 连接线上的每一段要么平行于 X 轴,要么平行于 Y 轴。
80
+ * @param {Array} v - an {Array} of {Point}s
81
+ * @return {Boolean} - true if path is valid, false otherwise
82
+ */
83
+ private orthogonalPath;
84
+ /**
85
+ * FIXME: 用更好的数学方法进行计算。
86
+ * Test to see if 2 {Line}s intersects. They are considered finite segments
87
+ * and not the infinite lines from geometry
88
+ * @param {Line} l1 - fist line/segment
89
+ * @param {Line} l2 - last line/segment
90
+ * @return {Boolean} true - if the lines intersect or false if not
91
+ */
92
+ private lineIntersectsLine;
93
+ /**
94
+ * Tests if a a polyline defined by a set of points intersects a rectangle
95
+ * @param {Array} points - and {Array} of {Point}s
96
+ * @param {Array} boundingRect - the boundingRect
97
+ * @param {Boolean} closedPolyline - incase polyline is closed figure then true, else false
98
+ * @return true - if line intersects the rectangle, false - if not
99
+ */
100
+ private polylineIntersectsRectangle;
101
+ /**
102
+ * Score a ortogonal path made out of Points
103
+ * Iterates over a set of points (minimum 3)
104
+ * For each 3 points (i, i+1, i+2) :
105
+ * - if the 3rd one is after the 2nd on the same line we add +1
106
+ * - if the 3rd is up or down related to the 2nd we do not do anything +0
107
+ * - if the 3rd goes back we imediatelly return -1
108
+ * @param {Array} v - an array of {Point}s
109
+ * @return {Number} - -1 if the path is wrong (goes back) or something >= 0 if is fine.The bigger the number the smooth the path is.
110
+ */
111
+ private scorePath;
112
+ /**
113
+ * Returns the sign of a number
114
+ * @param {Number} x - the number
115
+ * @returns {Number}
116
+ * @see <a href="http://en.wikipedia.org/wiki/Sign_function">http://en.wikipedia.org/wiki/Sign_function</a>
117
+ */
118
+ private signum;
119
+ /**
120
+ * Tests if a vector of points is a valid path (not going back)
121
+ * There are a few problems here. If you have p1, p2, p3 and p4 and p2 = p3 you need to ignore that
122
+ * @param {Array} v - an {Array} of {Point}s
123
+ * @return {Boolean} - true if path is valid, false otherwise
124
+ */
125
+ private forwardPath;
126
+ /**
127
+ * @method distance
128
+ * Calculate the distance between two points.
129
+ *
130
+ *
131
+ * 计算两点之间的距离。
132
+ * @param {Point} p1 - first {Point}
133
+ * @param {Point} p2 - second {Point}
134
+ * @return {Number} - the distance between those 2 points. It is always positive.
135
+ */
136
+ private distance;
137
+ /**
138
+ * Returns the max of a vector
139
+ * @param {Array} v - vector of {Number}s
140
+ * @return {Number} - the maximum number from the vector or NaN if vector is empty
141
+ */
142
+ private max;
143
+ /**
144
+ * Returns the min of a vector
145
+ * @param {Array} v - vector of {Number}s
146
+ * @return {Number} - the minimum number from the vector or NaN if vector is empty
147
+ * @author alex@scriptoid.com
148
+ */
149
+ private min;
150
+ /**
151
+ * ICEVisioLink 中的点都是自动计算出来的,手动添加点没有意义。
152
+ * @overwrite
153
+ * @param point
154
+ * @param index
155
+ */
156
+ addDot(point: [number, number], index: number): void;
157
+ /**
158
+ * ICEVisioLink 中的点都是自动计算出来的,手动删除点没有意义。
159
+ * @overwrite
160
+ * @param index
161
+ */
162
+ rmDot(index: number): boolean;
163
+ }
@@ -1,129 +1,163 @@
1
- import ICEPolyLine from './ICEPolyLine';
2
- /**
3
- * ! FIXME: 删掉对 GeoPoint/GeoLine/GeoUtil 的依赖
4
- * @class ICEVisioLink
5
- *
6
- * Visio 型的连接线
7
- *
8
- * 模拟 Microsoft Visio 中的折线算法,此实现从 diagramo 改进而来:http://diagramo.com/ 。
9
- *
10
- * 基本特性:
11
- *
12
- * - ICEVisioLink 只有 2 个端点,起点和终点。
13
- * - 除起始点和终点坐标之外,其它点会自动插值计算。
14
- * - ICEVisioLink 只能连接 2 个非线条类的组件。
15
- * - 线条互相之间不能连接,在 ICE 引擎中,不能用线条连接线条。
16
- * - 每一个可以被连接的组件上都有 4 个插槽(Slot),4 个插槽分布在组件最小边界盒子 4 条边的几何中点位置上。
17
- * - ICEVisioLink 的端点在移动时会判断是否与某个插槽发生碰撞,如果与某个插槽发生碰撞, ICEVisioLink 会连接到插槽所在的组件上。
18
- * - 同一个插槽(Slot)上可以连 N 根线,Slot 与 ICEVisioLink 之间的关系是 1->N 。
19
- *
20
- * @author 大漠穷秋<damoqiongqiu@126.com>
21
- */
22
- export default class ICEVisioLink extends ICEPolyLine {
23
- /**
24
- * FIXME:补全 props 配置项的描述
25
- */
26
- constructor(props?: any);
27
- protected static arrangeParam(props: any): any;
28
- /**
29
- * ICEVisioLink 有自己特殊的计算方式。
30
- *
31
- * @overwrite
32
- * @returns
33
- */
34
- protected calcDots(): any;
35
- /**
36
- * 在起点和终点之间插值。
37
- *
38
- * @returns
39
- */
40
- protected interpolate(): any[];
41
- /**
42
- * Tests if a vector of points is an orthogonal path (moving in multiples of 90 degrees).
43
- *
44
- *
45
- * 正交判定。Visio 连接线上的每一段要么平行于 X 轴,要么平行于 Y 轴。
46
- * @param {Array} v - an {Array} of {Point}s
47
- * @return {Boolean} - true if path is valid, false otherwise
48
- */
49
- private orthogonalPath;
50
- /**
51
- * FIXME: 用更好的数学方法进行计算。
52
- * Test to see if 2 {Line}s intersects. They are considered finite segments
53
- * and not the infinite lines from geometry
54
- * @param {Line} l1 - fist line/segment
55
- * @param {Line} l2 - last line/segment
56
- * @return {Boolean} true - if the lines intersect or false if not
57
- */
58
- private lineIntersectsLine;
59
- /**
60
- * Tests if a a polyline defined by a set of points intersects a rectangle
61
- * @param {Array} points - and {Array} of {Point}s
62
- * @param {Array} boundingRect - the boundingRect
63
- * @param {Boolean} closedPolyline - incase polyline is closed figure then true, else false
64
- * @return true - if line intersects the rectangle, false - if not
65
- */
66
- private polylineIntersectsRectangle;
67
- /**
68
- * Score a ortogonal path made out of Points
69
- * Iterates over a set of points (minimum 3)
70
- * For each 3 points (i, i+1, i+2) :
71
- * - if the 3rd one is after the 2nd on the same line we add +1
72
- * - if the 3rd is up or down related to the 2nd we do not do anything +0
73
- * - if the 3rd goes back we imediatelly return -1
74
- * @param {Array} v - an array of {Point}s
75
- * @return {Number} - -1 if the path is wrong (goes back) or something >= 0 if is fine.The bigger the number the smooth the path is.
76
- */
77
- private scorePath;
78
- /**
79
- * Returns the sign of a number
80
- * @param {Number} x - the number
81
- * @returns {Number}
82
- * @see <a href="http://en.wikipedia.org/wiki/Sign_function">http://en.wikipedia.org/wiki/Sign_function</a>
83
- */
84
- private signum;
85
- /**
86
- * Tests if a vector of points is a valid path (not going back)
87
- * There are a few problems here. If you have p1, p2, p3 and p4 and p2 = p3 you need to ignore that
88
- * @param {Array} v - an {Array} of {Point}s
89
- * @return {Boolean} - true if path is valid, false otherwise
90
- */
91
- private forwardPath;
92
- /**
93
- * @method distance
94
- * Calculate the distance between two points.
95
- *
96
- *
97
- * 计算两点之间的距离。
98
- * @param {Point} p1 - first {Point}
99
- * @param {Point} p2 - second {Point}
100
- * @return {Number} - the distance between those 2 points. It is always positive.
101
- */
102
- private distance;
103
- /**
104
- * Returns the max of a vector
105
- * @param {Array} v - vector of {Number}s
106
- * @return {Number} - the maximum number from the vector or NaN if vector is empty
107
- */
108
- private max;
109
- /**
110
- * Returns the min of a vector
111
- * @param {Array} v - vector of {Number}s
112
- * @return {Number} - the minimum number from the vector or NaN if vector is empty
113
- * @author alex@scriptoid.com
114
- */
115
- private min;
116
- /**
117
- * ICEVisioLink 中的点都是自动计算出来的,手动添加点没有意义。
118
- * @overwrite
119
- * @param point
120
- * @param index
121
- */
122
- addDot(point: [number, number], index: number): void;
123
- /**
124
- * ICEVisioLink 中的点都是自动计算出来的,手动删除点没有意义。
125
- * @overwrite
126
- * @param index
127
- */
128
- rmDot(index: number): boolean;
129
- }
1
+ import ICEPolyLine from './ICEPolyLine';
2
+ /**
3
+ * ! FIXME: 删掉对 GeoPoint/GeoLine/GeoUtil 的依赖
4
+ * @class ICEVisioLink
5
+ *
6
+ * Visio 型的连接线
7
+ *
8
+ * 模拟 Microsoft Visio 中的折线算法,此实现从 diagramo 改进而来:http://diagramo.com/ 。
9
+ *
10
+ * 基本特性:
11
+ *
12
+ * - ICEVisioLink 只有 2 个端点,起点和终点。
13
+ * - 除起始点和终点坐标之外,其它点会自动插值计算。
14
+ * - ICEVisioLink 只能连接 2 个非线条类的组件。
15
+ * - 线条互相之间不能连接,在 ICE 引擎中,不能用线条连接线条。
16
+ * - 每一个可以被连接的组件上都有 4 个插槽(Slot),4 个插槽分布在组件最小边界盒子 4 条边的几何中点位置上。
17
+ * - ICEVisioLink 的端点在移动时会判断是否与某个插槽发生碰撞,如果与某个插槽发生碰撞, ICEVisioLink 会连接到插槽所在的组件上。
18
+ * - 同一个插槽(Slot)上可以连 N 根线,Slot 与 ICEVisioLink 之间的关系是 1->N 。
19
+ *
20
+ * @author 大漠穷秋<damoqiongqiu@126.com>
21
+ */
22
+ export default class ICEVisioLink extends ICEPolyLine {
23
+ /**
24
+ * FIXME:补全 props 配置项的描述
25
+ */
26
+ constructor(props?: any);
27
+ protected static arrangeParam(props: any): any;
28
+ /**
29
+ * ICEVisioLink 有自己特殊的计算方式。
30
+ *
31
+ * @overwrite
32
+ * @returns
33
+ */
34
+ protected __calcDots(): any;
35
+ /**
36
+ * 贝塞尔形态:从两端点与插槽法线构造三次贝塞尔,等分采样后写回 points/dots。
37
+ *
38
+ * **为什么要把采样点写回 `state.points`**(而不是只算 dots):`ICEPolyLine.isDotsOnSameLine()`
39
+ * 与 `getLabelPosition()` 都只读 `state.points`。若 points 只剩首尾两点会被判「共线」,
40
+ * 包围盒就会走 `splitEndpointsTo4Points()`、只按线宽沿弦外扩 → 曲线鼓出的部分落在盒外
41
+ * → dirty-rect 上屏快照盒偏小、局部重绘会把曲线裁掉。写回之后包围盒/标签/命中都自然正确。
42
+ *
43
+ * @returns
44
+ */
45
+ protected __calcBezierDots(): any;
46
+ /**
47
+ * 由两端点构造三次贝塞尔并等分采样(世界坐标)。
48
+ *
49
+ * 控制点:`C1 = start + dir(start 插槽) * offset`、`C2 = end + dir(end 插槽) * offset`,
50
+ * `offset = max(|end-start| * 0.45, 24)`,方向为插槽**外法线**(与正交布线的语义一致)。
51
+ */
52
+ protected buildBezierPoints(start: number[], end: number[]): number[][];
53
+ /**
54
+ * 某端插槽的外法线方向;C / 未连接 / 未知位置回落到弦方向。
55
+ *
56
+ * 注意 start 端用 `+chord`、end 端用 `-chord`(指向弦的内侧):两端都取 `+chord` 的话,
57
+ * 控制点会落在两端点连线之外,曲线会先冲出去再拐回来(终点被越过)。
58
+ */
59
+ protected slotDirection(terminal: string, chord: number[]): number[];
60
+ /**
61
+ * @overwrite
62
+ * 贝塞尔形态不走正交路由。
63
+ *
64
+ * 应用层(如 ice-entity-designer `routeRelations()`)会在布局后无条件把 `routeType` 设为
65
+ * `'orthogonal'`;不拦掉的话每次布局/移动都会用正交折线整体覆盖 `state.points`:
66
+ * 虽然下一帧 `__calcDots` 会把曲线重新采样回来,但语义错乱且白算一次。
67
+ */
68
+ protected recalculateRoute(): void;
69
+ /**
70
+ * 在起点和终点之间插值。
71
+ *
72
+ * @returns
73
+ */
74
+ protected interpolate(): any[];
75
+ /**
76
+ * Tests if a vector of points is an orthogonal path (moving in multiples of 90 degrees).
77
+ *
78
+ *
79
+ * 正交判定。Visio 连接线上的每一段要么平行于 X 轴,要么平行于 Y 轴。
80
+ * @param {Array} v - an {Array} of {Point}s
81
+ * @return {Boolean} - true if path is valid, false otherwise
82
+ */
83
+ private orthogonalPath;
84
+ /**
85
+ * FIXME: 用更好的数学方法进行计算。
86
+ * Test to see if 2 {Line}s intersects. They are considered finite segments
87
+ * and not the infinite lines from geometry
88
+ * @param {Line} l1 - fist line/segment
89
+ * @param {Line} l2 - last line/segment
90
+ * @return {Boolean} true - if the lines intersect or false if not
91
+ */
92
+ private lineIntersectsLine;
93
+ /**
94
+ * Tests if a a polyline defined by a set of points intersects a rectangle
95
+ * @param {Array} points - and {Array} of {Point}s
96
+ * @param {Array} boundingRect - the boundingRect
97
+ * @param {Boolean} closedPolyline - incase polyline is closed figure then true, else false
98
+ * @return true - if line intersects the rectangle, false - if not
99
+ */
100
+ private polylineIntersectsRectangle;
101
+ /**
102
+ * Score a ortogonal path made out of Points
103
+ * Iterates over a set of points (minimum 3)
104
+ * For each 3 points (i, i+1, i+2) :
105
+ * - if the 3rd one is after the 2nd on the same line we add +1
106
+ * - if the 3rd is up or down related to the 2nd we do not do anything +0
107
+ * - if the 3rd goes back we imediatelly return -1
108
+ * @param {Array} v - an array of {Point}s
109
+ * @return {Number} - -1 if the path is wrong (goes back) or something >= 0 if is fine.The bigger the number the smooth the path is.
110
+ */
111
+ private scorePath;
112
+ /**
113
+ * Returns the sign of a number
114
+ * @param {Number} x - the number
115
+ * @returns {Number}
116
+ * @see <a href="http://en.wikipedia.org/wiki/Sign_function">http://en.wikipedia.org/wiki/Sign_function</a>
117
+ */
118
+ private signum;
119
+ /**
120
+ * Tests if a vector of points is a valid path (not going back)
121
+ * There are a few problems here. If you have p1, p2, p3 and p4 and p2 = p3 you need to ignore that
122
+ * @param {Array} v - an {Array} of {Point}s
123
+ * @return {Boolean} - true if path is valid, false otherwise
124
+ */
125
+ private forwardPath;
126
+ /**
127
+ * @method distance
128
+ * Calculate the distance between two points.
129
+ *
130
+ *
131
+ * 计算两点之间的距离。
132
+ * @param {Point} p1 - first {Point}
133
+ * @param {Point} p2 - second {Point}
134
+ * @return {Number} - the distance between those 2 points. It is always positive.
135
+ */
136
+ private distance;
137
+ /**
138
+ * Returns the max of a vector
139
+ * @param {Array} v - vector of {Number}s
140
+ * @return {Number} - the maximum number from the vector or NaN if vector is empty
141
+ */
142
+ private max;
143
+ /**
144
+ * Returns the min of a vector
145
+ * @param {Array} v - vector of {Number}s
146
+ * @return {Number} - the minimum number from the vector or NaN if vector is empty
147
+ * @author alex@scriptoid.com
148
+ */
149
+ private min;
150
+ /**
151
+ * ICEVisioLink 中的点都是自动计算出来的,手动添加点没有意义。
152
+ * @overwrite
153
+ * @param point
154
+ * @param index
155
+ */
156
+ addDot(point: [number, number], index: number): void;
157
+ /**
158
+ * ICEVisioLink 中的点都是自动计算出来的,手动删除点没有意义。
159
+ * @overwrite
160
+ * @param index
161
+ */
162
+ rmDot(index: number): boolean;
163
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright (c) 2022 大漠穷秋.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import ICEEllipse from './ICEEllipse.mjs';
9
+ /**
10
+ * @class ICECircle 正圆形
11
+ *
12
+ * 采用椭圆绘制方法,正圆形作为椭圆的特殊情况。
13
+ *
14
+ * @author 大漠穷秋<damoqiongqiu@126.com>
15
+ */
16
+ declare class ICECircle extends ICEEllipse {
17
+ constructor(props?: any);
18
+ }
19
+ export default ICECircle;
@@ -1,19 +1,19 @@
1
- /**
2
- * Copyright (c) 2022 大漠穷秋.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
- import ICEEllipse from './ICEEllipse';
9
- /**
10
- * @class ICECircle 正圆形
11
- *
12
- * 采用椭圆绘制方法,正圆形作为椭圆的特殊情况。
13
- *
14
- * @author 大漠穷秋<damoqiongqiu@126.com>
15
- */
16
- declare class ICECircle extends ICEEllipse {
17
- constructor(props?: any);
18
- }
19
- export default ICECircle;
1
+ /**
2
+ * Copyright (c) 2022 大漠穷秋.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import ICEEllipse from './ICEEllipse';
9
+ /**
10
+ * @class ICECircle 正圆形
11
+ *
12
+ * 采用椭圆绘制方法,正圆形作为椭圆的特殊情况。
13
+ *
14
+ * @author 大漠穷秋<damoqiongqiu@126.com>
15
+ */
16
+ declare class ICECircle extends ICEEllipse {
17
+ constructor(props?: any);
18
+ }
19
+ export default ICECircle;
@@ -0,0 +1,29 @@
1
+ import ICEPath from '../ICEPath.mjs';
2
+ /**
3
+ * @class ICEEllipse 椭圆形
4
+ * @author 大漠穷秋<damoqiongqiu@126.com>
5
+ */
6
+ declare class ICEEllipse extends ICEPath {
7
+ constructor(props?: any);
8
+ /**
9
+ * 所有坐标点的坐标都是相对于父层组件,而不是全局坐标。
10
+ * @returns
11
+ */
12
+ protected createPathObject(): any;
13
+ /**
14
+ * 精确命中判定:点是否位于椭圆内部(圆心为本地原点)。
15
+ * 圆作为椭圆的特例(radiusX === radiusY)自动继承此实现。
16
+ * @overwrite
17
+ */
18
+ protected containsLocalPoint(localX: number, localY: number): boolean;
19
+ /**
20
+ * setState 仅仅修改参数,不会立即导致重新渲染,需要等待 FrameManager 调度,最小延迟时间约为 1/60=16.67 ms 。
21
+ *
22
+ * - 如果 setState 时指定了 radiusX 参数,则 width 会被重新计算,如果指定了 radiusY 参数则 height 会被重新计算。
23
+ * - 如果 setState 时仅仅指定 width 参数,则 radiusX 会被重新计算,如果仅仅指定了 height 参数,则 radiusY 会被重新计算。
24
+ * @overwrite
25
+ * @param newState
26
+ */
27
+ setState(newState: any): void;
28
+ }
29
+ export default ICEEllipse;
@@ -1,23 +1,29 @@
1
- import ICEPath from '../ICEPath';
2
- /**
3
- * @class ICEEllipse 椭圆形
4
- * @author 大漠穷秋<damoqiongqiu@126.com>
5
- */
6
- declare class ICEEllipse extends ICEPath {
7
- constructor(props?: any);
8
- /**
9
- * 所有坐标点的坐标都是相对于父层组件,而不是全局坐标。
10
- * @returns
11
- */
12
- protected createPathObject(): Path2D;
13
- /**
14
- * setState 仅仅修改参数,不会立即导致重新渲染,需要等待 FrameManager 调度,最小延迟时间约为 1/60=16.67 ms 。
15
- *
16
- * - 如果 setState 时指定了 radiusX 参数,则 width 会被重新计算,如果指定了 radiusY 参数则 height 会被重新计算。
17
- * - 如果 setState 时仅仅指定 width 参数,则 radiusX 会被重新计算,如果仅仅指定了 height 参数,则 radiusY 会被重新计算。
18
- * @overwrite
19
- * @param newState
20
- */
21
- setState(newState: any): void;
22
- }
23
- export default ICEEllipse;
1
+ import ICEPath from '../ICEPath';
2
+ /**
3
+ * @class ICEEllipse 椭圆形
4
+ * @author 大漠穷秋<damoqiongqiu@126.com>
5
+ */
6
+ declare class ICEEllipse extends ICEPath {
7
+ constructor(props?: any);
8
+ /**
9
+ * 所有坐标点的坐标都是相对于父层组件,而不是全局坐标。
10
+ * @returns
11
+ */
12
+ protected createPathObject(): any;
13
+ /**
14
+ * 精确命中判定:点是否位于椭圆内部(圆心为本地原点)。
15
+ * 圆作为椭圆的特例(radiusX === radiusY)自动继承此实现。
16
+ * @overwrite
17
+ */
18
+ protected containsLocalPoint(localX: number, localY: number): boolean;
19
+ /**
20
+ * setState 仅仅修改参数,不会立即导致重新渲染,需要等待 FrameManager 调度,最小延迟时间约为 1/60=16.67 ms 。
21
+ *
22
+ * - 如果 setState 时指定了 radiusX 参数,则 width 会被重新计算,如果指定了 radiusY 参数则 height 会被重新计算。
23
+ * - 如果 setState 时仅仅指定 width 参数,则 radiusX 会被重新计算,如果仅仅指定了 height 参数,则 radiusY 会被重新计算。
24
+ * @overwrite
25
+ * @param newState
26
+ */
27
+ setState(newState: any): void;
28
+ }
29
+ export default ICEEllipse;
@@ -0,0 +1,52 @@
1
+ import ICEDotPath from '../ICEDotPath.mjs';
2
+ /**
3
+ *
4
+ * @class ICEIsogon 正N边形
5
+ *
6
+ * @author 大漠穷秋<damoqiongqiu@126.com>
7
+ */
8
+ declare class ICEIsogon extends ICEDotPath {
9
+ /**
10
+ * @method constructor
11
+ * radius, edges 会暴露给 AnimationManager ,可能会动态变化。
12
+ * @param props
13
+ */
14
+ constructor(props?: any);
15
+ /**
16
+ * @overwrite
17
+ * @method __calcDots
18
+ *
19
+ * 计算路径上的关键点:
20
+ * - 默认的坐标原点是 (0,0) 位置。
21
+ * - 这些点没有经过 transform 矩阵变换。
22
+ *
23
+ * @returns
24
+ */
25
+ protected __calcDots(): any;
26
+ /**
27
+ * @overwrite
28
+ * @method calcComponentParams
29
+ * - 计算组件最原始的宽高和位置,此时没有经过任何变换,也没有移动坐标原点。
30
+ * - 在计算组件的原始尺寸时还没有确定原点坐标,所以只能基于组件本地坐标系的左上角 (0,0) 点进行计算。
31
+ * - 此方法不能依赖原点位置和 transform 矩阵。
32
+ * - 此方法会在 render() 中调用,所以不需要在构造函数中调用。
33
+ * - 此方法中不能使用 setState() ,如果需要修改状态,直接赋值,如:this.state.width = 100;
34
+ * - 子类可以覆盖此方法,实现自己的计算逻辑。
35
+ * @returns
36
+ */
37
+ protected calcComponentParams(): {
38
+ width: any;
39
+ height: any;
40
+ };
41
+ /**
42
+ * @overwrite
43
+ * @method setState
44
+ * setState 仅仅修改参数,不会立即导致重新渲染,需要等待 FrameManager 调度,最小延迟时间约为 1/60=16.67 ms 。
45
+ *
46
+ * - 如果 setState 时指定了 radius 参数,则 width 会被重新计算,如果指定了 radius 参数则 height 会被重新计算。
47
+ * - 如果 setState 时仅仅指定 width 参数,则 radius 会被重新计算,如果仅仅指定了 height 参数,则 radius 会被重新计算。
48
+ * @param newState
49
+ */
50
+ setState(newState: any): void;
51
+ }
52
+ export default ICEIsogon;