lost-sia 2.0.1-alpha8 → 3.0.0

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 (280) hide show
  1. package/README.md +4 -0
  2. package/dist/Annotation/logic/Annotation.d.ts +17 -0
  3. package/dist/Annotation/logic/Annotation.js +1 -0
  4. package/dist/Annotation/ui/AnnotationComponent.d.ts +24 -0
  5. package/dist/Annotation/ui/AnnotationComponent.js +1 -0
  6. package/dist/Annotation/ui/atoms/AnnoBar.d.ts +15 -0
  7. package/dist/Annotation/ui/atoms/AnnoBar.js +1 -0
  8. package/dist/Annotation/ui/atoms/DaviIcon.d.ts +9 -0
  9. package/dist/Annotation/ui/atoms/DaviIcon.js +19 -0
  10. package/dist/Annotation/ui/atoms/Edge.d.ts +17 -0
  11. package/dist/Annotation/ui/atoms/Edge.js +1 -0
  12. package/dist/Annotation/ui/atoms/Node.d.ts +17 -0
  13. package/dist/Annotation/ui/atoms/Node.js +1 -0
  14. package/dist/Annotation/ui/atoms/PolygonArea.d.ts +16 -0
  15. package/dist/Annotation/ui/atoms/PolygonArea.js +1 -0
  16. package/dist/Annotation/ui/tools/BBox.d.ts +21 -0
  17. package/dist/Annotation/ui/tools/BBox.js +1 -0
  18. package/dist/Annotation/ui/tools/Line.d.ts +21 -0
  19. package/dist/Annotation/ui/tools/Line.js +1 -0
  20. package/dist/Annotation/ui/tools/Point.d.ts +16 -0
  21. package/dist/Annotation/ui/tools/Point.js +1 -0
  22. package/dist/Annotation/ui/tools/Polygon.d.ts +23 -0
  23. package/dist/Annotation/ui/tools/Polygon.js +1 -0
  24. package/dist/Canvas/Canvas.d.ts +31 -0
  25. package/dist/Canvas/Canvas.js +1 -0
  26. package/dist/Canvas/LabelInput.d.ts +11 -0
  27. package/dist/Canvas/LabelInput.js +1 -0
  28. package/dist/IconButton.d.ts +25 -0
  29. package/dist/IconButton.js +1 -0
  30. package/dist/Sia.d.ts +33 -0
  31. package/dist/Sia.js +1 -0
  32. package/dist/Toolbar/Toolbar.d.ts +21 -0
  33. package/dist/Toolbar/Toolbar.js +1 -0
  34. package/dist/Toolbar/ToolbarItems/AccessibilityTools.d.ts +7 -0
  35. package/dist/Toolbar/ToolbarItems/AccessibilityTools.js +1 -0
  36. package/dist/Toolbar/ToolbarItems/AnnoToolSelector.d.ts +11 -0
  37. package/dist/Toolbar/ToolbarItems/AnnoToolSelector.js +1 -0
  38. package/dist/Toolbar/ToolbarItems/ImageToolItems/ImageLabelInput.d.ts +11 -0
  39. package/dist/Toolbar/ToolbarItems/ImageToolItems/ImageLabelInput.js +1 -0
  40. package/dist/Toolbar/ToolbarItems/ImageToolItems/TagLabel.d.ts +11 -0
  41. package/dist/Toolbar/ToolbarItems/ImageToolItems/TagLabel.js +1 -0
  42. package/dist/Toolbar/ToolbarItems/ImageTools.d.ts +13 -0
  43. package/dist/Toolbar/ToolbarItems/ImageTools.js +1 -0
  44. package/dist/Toolbar/ToolbarItems/Instructions.d.ts +2 -0
  45. package/dist/Toolbar/ToolbarItems/Instructions.js +1 -0
  46. package/dist/Toolbar/ToolbarItems/InstructionsModal.d.ts +6 -0
  47. package/dist/Toolbar/ToolbarItems/InstructionsModal.js +1 -0
  48. package/dist/assets/SIA-BV1tYu3P.css +1 -0
  49. package/dist/assets/brand-icons-Cu_C0hZ4.svg +1008 -0
  50. package/dist/assets/brand-icons-F3SPCeH1.woff +0 -0
  51. package/dist/assets/brand-icons-XL9sxUpA.woff2 +0 -0
  52. package/dist/assets/brand-icons-sqJ2Pg7a.eot +0 -0
  53. package/dist/assets/brand-icons-ubhWoxly.ttf +0 -0
  54. package/dist/assets/flags-DOLqOU7Y.png +0 -0
  55. package/dist/assets/icons-BOCtAERH.woff +0 -0
  56. package/dist/assets/icons-CHzK1VD9.eot +0 -0
  57. package/dist/assets/icons-D29ZQHHw.ttf +0 -0
  58. package/dist/assets/icons-Du6TOHnR.woff2 +0 -0
  59. package/dist/assets/icons-RwhydX30.svg +1518 -0
  60. package/dist/assets/node_modules/semantic-ui-css/semantic.min-Bvulf91l.css +346 -0
  61. package/dist/assets/outline-icons-BfdLr8tr.svg +366 -0
  62. package/dist/assets/outline-icons-DD8jm0uy.ttf +0 -0
  63. package/dist/assets/outline-icons-DInHoiqI.woff2 +0 -0
  64. package/dist/assets/outline-icons-LX8adJ4n.eot +0 -0
  65. package/dist/assets/outline-icons-aQ88nltS.woff +0 -0
  66. package/dist/index.d.ts +5 -0
  67. package/dist/index.js +1 -0
  68. package/dist/models/AnnotationMode.d.ts +11 -0
  69. package/dist/models/AnnotationMode.js +1 -0
  70. package/dist/models/AnnotationStatus.d.ts +8 -0
  71. package/dist/models/AnnotationStatus.js +1 -0
  72. package/dist/models/AnnotationTool.d.ts +7 -0
  73. package/dist/models/AnnotationTool.js +1 -0
  74. package/dist/models/CanvasAction.d.ts +28 -0
  75. package/dist/models/CanvasAction.js +1 -0
  76. package/dist/models/Direction.d.ts +7 -0
  77. package/dist/models/Direction.js +1 -0
  78. package/dist/models/EditorModes.d.ts +11 -0
  79. package/dist/models/EditorModes.js +1 -0
  80. package/dist/models/KeyAction.d.ts +22 -0
  81. package/dist/models/KeyAction.js +1 -0
  82. package/dist/models/NotificationType.d.ts +7 -0
  83. package/dist/models/NotificationType.js +1 -0
  84. package/dist/models/index.d.ts +6 -0
  85. package/dist/models/index.js +1 -0
  86. package/dist/stories/AnnotationTools.stories.d.ts +40 -0
  87. package/dist/stories/Canvas/Canvas.stories.d.ts +50 -0
  88. package/dist/stories/Canvas/CanvasOffset.d.ts +13 -0
  89. package/dist/stories/Canvas/CanvasWithOffset.stories.d.ts +36 -0
  90. package/dist/stories/FilterDropdown.stories.d.ts +19 -0
  91. package/dist/stories/MinimalSia.stories.d.ts +66 -0
  92. package/dist/stories/SIA/DemoWrapper.d.ts +8 -0
  93. package/dist/stories/SIA/DemoWrapper.stories.d.ts +27 -0
  94. package/dist/stories/SIA/SIA.stories.d.ts +72 -0
  95. package/dist/stories/Toolbar/ImageTools/TagLabel.stories.d.ts +21 -0
  96. package/dist/stories/Toolbar/Instructions.stories.d.ts +11 -0
  97. package/dist/stories/Toolbar/Toolbar.stories.d.ts +37 -0
  98. package/dist/stories/exampleData/exampleAnnotations.d.ts +8 -0
  99. package/dist/stories/exampleData/exampleExternalAnnotations.d.ts +8 -0
  100. package/dist/stories/exampleData/exampleImage.d.ts +2 -0
  101. package/dist/stories/exampleData/exampleLabels.d.ts +6 -0
  102. package/dist/types.d.ts +57 -0
  103. package/dist/types.js +1 -0
  104. package/dist/utils/KeyMapper.d.ts +9 -0
  105. package/dist/utils/KeyMapper.js +1 -0
  106. package/dist/utils/TimeUtils.d.ts +4 -0
  107. package/dist/utils/TimeUtils.js +1 -0
  108. package/dist/utils/color.d.ts +2 -0
  109. package/dist/utils/color.js +1 -0
  110. package/dist/utils/index.d.ts +2 -0
  111. package/dist/utils/index.js +1 -0
  112. package/dist/utils/mouse.d.ts +6 -0
  113. package/dist/utils/mouse.js +1 -0
  114. package/dist/utils/siaIcons.js +12 -0
  115. package/dist/utils/transform.d.ts +28 -0
  116. package/dist/utils/transform.js +1 -0
  117. package/dist/utils/uiConfig.js +1 -0
  118. package/dist/utils/windowViewport.d.ts +22 -0
  119. package/dist/utils/windowViewport.js +1 -0
  120. package/package.json +19 -16
  121. package/src/AnnoExampleViewer.jsx +18 -18
  122. package/src/Annotation/logic/Annotation.ts +24 -26
  123. package/src/Annotation/ui/AnnotationComponent.tsx +115 -86
  124. package/src/Annotation/ui/atoms/AnnoBar.tsx +51 -53
  125. package/src/Annotation/ui/atoms/DaviIcon.tsx +12 -22
  126. package/src/Annotation/ui/atoms/Edge.tsx +25 -22
  127. package/src/Annotation/ui/atoms/Node.tsx +56 -50
  128. package/src/Annotation/ui/atoms/PolygonArea.tsx +30 -35
  129. package/src/Annotation/ui/tools/BBox.tsx +136 -150
  130. package/src/Annotation/ui/tools/Line.tsx +94 -91
  131. package/src/Annotation/ui/tools/Point.tsx +19 -17
  132. package/src/Annotation/ui/tools/Polygon.tsx +126 -95
  133. package/src/Canvas/Canvas.tsx +748 -594
  134. package/src/Canvas/LabelInput.tsx +68 -45
  135. package/src/IconButton.tsx +119 -0
  136. package/src/InfoBoxes/AnnoDetails.jsx +53 -53
  137. package/src/InfoBoxes/AnnoStats.jsx +41 -41
  138. package/src/InfoBoxes/InfoBox.jsx +16 -16
  139. package/src/InfoBoxes/InfoBoxArea.jsx +32 -34
  140. package/src/InfoBoxes/LabelInfo.jsx +30 -30
  141. package/src/SIASettingButton.jsx +25 -25
  142. package/src/Sia.tsx +484 -0
  143. package/src/Toolbar/Toolbar.tsx +38 -31
  144. package/src/Toolbar/ToolbarItems/AccessibilityTools.tsx +26 -46
  145. package/src/Toolbar/ToolbarItems/AnnoToolSelector.tsx +53 -46
  146. package/src/Toolbar/ToolbarItems/ImageToolItems/ImageLabelInput.tsx +127 -0
  147. package/src/Toolbar/ToolbarItems/ImageToolItems/TagLabel.tsx +29 -28
  148. package/src/Toolbar/ToolbarItems/ImageTools.tsx +43 -40
  149. package/src/Toolbar/ToolbarItems/Instructions.tsx +47 -50
  150. package/src/Toolbar/ToolbarItems/InstructionsModal.tsx +8 -8
  151. package/src/index.ts +9 -13
  152. package/src/models/{AnnotationMode.tsx → AnnotationMode.ts} +1 -1
  153. package/src/models/{AnnotationStatus.tsx → AnnotationStatus.ts} +1 -1
  154. package/src/models/{AnnotationTool.tsx → AnnotationTool.ts} +1 -1
  155. package/src/models/{CanvasAction.tsx → CanvasAction.ts} +1 -1
  156. package/src/models/{Direction.tsx → Direction.ts} +1 -1
  157. package/src/models/{EditorModes.tsx → EditorModes.ts} +1 -1
  158. package/src/models/{KeyAction.tsx → KeyAction.ts} +3 -1
  159. package/src/models/NotificationType.ts +8 -0
  160. package/src/models/index.ts +6 -7
  161. package/src/siaDummyData.js +71 -71
  162. package/src/stories/AnnotationTools.mdx +27 -0
  163. package/src/stories/AnnotationTools.stories.tsx +104 -0
  164. package/src/stories/Canvas/Canvas.stories.tsx +59 -113
  165. package/src/stories/Canvas/CanvasOffset.tsx +54 -38
  166. package/src/stories/Canvas/CanvasWithOffset.stories.tsx +42 -113
  167. package/src/stories/FilterDropdown.stories.ts +13 -11
  168. package/src/stories/MinimalSIA.mdx +20 -0
  169. package/src/stories/MinimalSia.stories.tsx +90 -0
  170. package/src/stories/SIA/DemoWrapper.stories.tsx +71 -0
  171. package/src/stories/SIA/DemoWrapper.tsx +55 -0
  172. package/src/stories/SIA/SIA.stories.tsx +79 -45
  173. package/src/stories/Toolbar/ImageTools/TagLabel.stories.tsx +11 -12
  174. package/src/stories/Toolbar/Instructions.stories.tsx +11 -11
  175. package/src/stories/Toolbar/Toolbar.stories.tsx +32 -47
  176. package/src/stories/Welcome.mdx +5 -0
  177. package/src/stories/development/CoordinateSystems.mdx +25 -0
  178. package/src/stories/exampleData/exampleAnnotations.ts +65 -0
  179. package/src/stories/exampleData/exampleExternalAnnotations.ts +115 -0
  180. package/src/stories/{siaDummyData2.ts → exampleData/exampleImage.ts} +3 -264
  181. package/src/stories/exampleData/exampleLabels.ts +146 -0
  182. package/src/stories/main.scss +6 -0
  183. package/src/styles/style.scss +1 -26
  184. package/src/types.ts +67 -0
  185. package/src/utils/KeyMapper.ts +76 -74
  186. package/src/utils/TimeUtils.ts +11 -0
  187. package/src/utils/color.ts +25 -25
  188. package/src/utils/hist.js +22 -22
  189. package/src/utils/index.ts +2 -3
  190. package/src/utils/mouse.ts +45 -0
  191. package/src/utils/siaIcons.jsx +5 -7
  192. package/src/utils/transform.ts +186 -0
  193. package/src/utils/uiConfig.js +19 -22
  194. package/src/utils/windowViewport.ts +34 -0
  195. package/src/AnnoLabelInput.jsx +0 -109
  196. package/src/AnnoToolBar.jsx +0 -153
  197. package/src/Annotation/AnnoBar.jsx +0 -154
  198. package/src/Annotation/Annotation.jsx +0 -395
  199. package/src/Annotation/Annotation.scss +0 -47
  200. package/src/Annotation/BBox.jsx +0 -299
  201. package/src/Annotation/Edge.jsx +0 -92
  202. package/src/Annotation/InfSelectionArea.jsx +0 -72
  203. package/src/Annotation/Line.jsx +0 -68
  204. package/src/Annotation/Node.jsx +0 -282
  205. package/src/Annotation/Point.jsx +0 -200
  206. package/src/Annotation/Polygon.jsx +0 -404
  207. package/src/Annotation/logic/AnnotationUtils.ts +0 -30
  208. package/src/Canvas.jsx +0 -2194
  209. package/src/ImgBar.jsx +0 -131
  210. package/src/LabelInput.jsx +0 -238
  211. package/src/Prompt.jsx +0 -45
  212. package/src/SIAFilterButton.jsx +0 -186
  213. package/src/Sia.jsx +0 -478
  214. package/src/Sia2.tsx +0 -392
  215. package/src/SiaPopup.jsx +0 -15
  216. package/src/ToolBar.jsx +0 -463
  217. package/src/Toolbar/NavigationButtons.tsx +0 -21
  218. package/src/Toolbar/ToolbarItem.jsx +0 -30
  219. package/src/Toolbar/ToolbarItems/ImageToolItems/ImageLabel.tsx +0 -62
  220. package/src/Toolbar.css +0 -13
  221. package/src/ToolbarItem.jsx +0 -31
  222. package/src/filterTools.js +0 -5
  223. package/src/models/AllowedTools.tsx +0 -9
  224. package/src/models/AnnotationSettings.tsx +0 -9
  225. package/src/models/ExternalAnnotation.ts +0 -15
  226. package/src/models/Label.tsx +0 -8
  227. package/src/models/UiConfig.tsx +0 -6
  228. package/src/stories/Button.jsx +0 -54
  229. package/src/stories/Button.stories.js +0 -48
  230. package/src/stories/Header.jsx +0 -69
  231. package/src/stories/Header.stories.js +0 -28
  232. package/src/stories/Page.jsx +0 -87
  233. package/src/stories/Page.stories.js +0 -28
  234. package/src/stories/SIA2/DemoWrapper.stories.tsx +0 -167
  235. package/src/stories/SIA2/DemoWrapper.tsx +0 -54
  236. package/src/stories/SIA2/Sia2.stories.tsx +0 -62
  237. package/src/stories/Toolbar/ImageTools/ImageLabel.stories.tsx +0 -32
  238. package/src/stories/assets/accessibility.png +0 -0
  239. package/src/stories/assets/accessibility.svg +0 -5
  240. package/src/stories/assets/addon-library.png +0 -0
  241. package/src/stories/assets/assets.png +0 -0
  242. package/src/stories/assets/avif-test-image.avif +0 -0
  243. package/src/stories/assets/context.png +0 -0
  244. package/src/stories/assets/discord.svg +0 -15
  245. package/src/stories/assets/docs.png +0 -0
  246. package/src/stories/assets/figma-plugin.png +0 -0
  247. package/src/stories/assets/github.svg +0 -3
  248. package/src/stories/assets/share.png +0 -0
  249. package/src/stories/assets/styling.png +0 -0
  250. package/src/stories/assets/testing.png +0 -0
  251. package/src/stories/assets/theming.png +0 -0
  252. package/src/stories/assets/tutorials.svg +0 -12
  253. package/src/stories/assets/youtube.svg +0 -4
  254. package/src/stories/button.css +0 -30
  255. package/src/stories/header.css +0 -32
  256. package/src/stories/lost.js +0 -54
  257. package/src/stories/page.css +0 -69
  258. package/src/stories/siaDummyData.js +0 -263
  259. package/src/stories/store.js +0 -18
  260. package/src/test.js +0 -7
  261. package/src/types/annoStatus.js +0 -4
  262. package/src/types/canvasActions.js +0 -58
  263. package/src/types/cursorstyles.js +0 -3
  264. package/src/types/modes.js +0 -9
  265. package/src/types/notificationType.js +0 -11
  266. package/src/types/toolbarEvents.js +0 -35
  267. package/src/types/tools.js +0 -17
  268. package/src/types.tsx +0 -11
  269. package/src/utils/annoConversion.js +0 -145
  270. package/src/utils/annoConversion2.ts +0 -145
  271. package/src/utils/colorlut.js +0 -68
  272. package/src/utils/constraints.js +0 -81
  273. package/src/utils/index.js +0 -1
  274. package/src/utils/keyActions.js +0 -113
  275. package/src/utils/mouse.js +0 -14
  276. package/src/utils/mouse2.ts +0 -35
  277. package/src/utils/transform.js +0 -336
  278. package/src/utils/transform2.ts +0 -343
  279. package/src/utils/windowViewport.js +0 -34
  280. package/src/utils/windowViewport2.ts +0 -50
@@ -1,299 +0,0 @@
1
- import React, { Component } from "react";
2
- import "./Annotation.scss";
3
- import * as modes from "../types/modes";
4
- import * as transform from "../utils/transform";
5
- import * as canvasActions from "../types/canvasActions";
6
- import * as mouse from "../utils/mouse";
7
- import InfSelectionArea from "./InfSelectionArea";
8
- import Node from "./Node";
9
-
10
- class BBox extends Component {
11
- /*************
12
- * LIFECYCLE *
13
- **************/
14
- constructor(props) {
15
- super(props);
16
- this.state = {
17
- anno: undefined,
18
- };
19
- }
20
-
21
- componentDidMount(prevProps) {
22
- if (this.props.anno.mode === modes.CREATE) {
23
- const data = this.props.anno.data[0];
24
- const newAnno = {
25
- ...this.props.anno,
26
- data: [
27
- { x: data.x, y: data.y },
28
- { x: data.x + 1, y: data.y },
29
- { x: data.x + 1, y: data.y + 1 },
30
- { x: data.x, y: data.y + 1 },
31
- ],
32
- selectedNode: 2,
33
- };
34
- this.setState({
35
- anno: newAnno,
36
- });
37
- // this.performedAction(newAnno, canvasActions.ANNO_START_CREATING)
38
- } else {
39
- this.setState({ anno: { ...this.props.anno } });
40
- }
41
- }
42
-
43
- componentDidUpdate(prevProps) {
44
- if (prevProps.anno !== this.props.anno) {
45
- this.setState({ anno: { ...this.props.anno } });
46
- }
47
- }
48
-
49
- /*************
50
- * EVENTS *
51
- **************/
52
- onNodeMouseMove(e, idx) {
53
- switch (this.state.anno.mode) {
54
- case modes.CREATE:
55
- case modes.EDIT:
56
- const mousePos = mouse.getMousePosition(e, this.props.svg);
57
- const idxMinus = idx - 1 < 0 ? 3 : idx - 1;
58
- const idxPlus = idx + 1 > 3 ? 0 : idx + 1;
59
- let newAnnoData = [...this.state.anno.data];
60
- if (idx % 2 === 0) {
61
- newAnnoData[idxMinus].x = mousePos.x;
62
- newAnnoData[idx].x = mousePos.x;
63
- newAnnoData[idx].y = mousePos.y;
64
- newAnnoData[idxPlus].y = mousePos.y;
65
- } else {
66
- newAnnoData[idxMinus].y = mousePos.y;
67
- newAnnoData[idx].x = mousePos.x;
68
- newAnnoData[idx].y = mousePos.y;
69
- newAnnoData[idxPlus].x = mousePos.x;
70
- }
71
- this.setState({
72
- anno: {
73
- ...this.state.anno,
74
- data: newAnnoData,
75
- },
76
- });
77
- break;
78
- default:
79
- break;
80
- }
81
- }
82
-
83
- onNodeMouseDown(e, idx) {
84
- switch (this.state.anno.mode) {
85
- case modes.VIEW:
86
- if (e.button === 0) {
87
- this.requestModeChange(
88
- { ...this.state.anno, selectedNode: idx },
89
- modes.EDIT,
90
- );
91
- }
92
- break;
93
- default:
94
- break;
95
- }
96
- }
97
-
98
- onNodeMouseUp(e, idx) {
99
- switch (this.state.anno.mode) {
100
- case modes.EDIT:
101
- if (e.button === 0) {
102
- this.requestModeChange(this.state.anno, modes.VIEW);
103
- this.performedAction(this.state.anno, canvasActions.ANNO_EDITED);
104
- }
105
- break;
106
- case modes.CREATE:
107
- if (e.button === 2) {
108
- this.requestModeChange(this.state.anno, modes.VIEW);
109
- this.performedAction(this.state.anno, canvasActions.ANNO_CREATED);
110
- }
111
- break;
112
- default:
113
- break;
114
- }
115
- }
116
-
117
- handleNodeMouseLeave(e, idx) {
118
- switch (this.state.anno.mode) {
119
- //if mouse left Canvas in create mode, transit to VIEW mode
120
- case modes.CREATE:
121
- this.requestModeChange(this.state.anno, modes.VIEW);
122
- this.performedAction(this.state.anno, canvasActions.ANNO_CREATED);
123
- break;
124
- default:
125
- break;
126
- }
127
- }
128
-
129
- /**************
130
- * ANNO EVENTS *
131
- ***************/
132
- onMouseMove(e) {
133
- switch (this.state.anno.mode) {
134
- case modes.MOVE:
135
- this.move(
136
- e.movementX / this.props.svg.scale,
137
- e.movementY / this.props.svg.scale,
138
- );
139
- break;
140
- default:
141
- break;
142
- }
143
- }
144
-
145
- onMouseUp(e) {
146
- switch (this.state.anno.mode) {
147
- case modes.MOVE:
148
- if (e.button === 0) {
149
- this.requestModeChange(this.state.anno, modes.VIEW);
150
- this.performedAction(this.state.anno, canvasActions.ANNO_MOVED);
151
- }
152
- break;
153
- default:
154
- break;
155
- }
156
- }
157
-
158
- onMouseDown(e) {
159
- switch (this.state.anno.mode) {
160
- case modes.VIEW:
161
- if (e.button === 0) {
162
- if (this.props.isSelected) {
163
- this.requestModeChange(this.state.anno, modes.MOVE);
164
- }
165
- }
166
- break;
167
- default:
168
- break;
169
- }
170
- }
171
- /*************
172
- * LOGIC *
173
- **************/
174
- getResult() {
175
- return this.state.anno;
176
- }
177
-
178
- requestModeChange(anno, mode) {
179
- this.props.onModeChangeRequest(anno, mode);
180
- }
181
-
182
- performedAction(anno, pAction) {
183
- if (this.props.onAction) {
184
- this.props.onAction(anno, pAction);
185
- }
186
- }
187
-
188
- toPolygonStr(data) {
189
- return data
190
- .map((e) => {
191
- return `${e.x},${e.y}`;
192
- })
193
- .join(" ");
194
- }
195
-
196
- move(movementX, movementY) {
197
- this.setState({
198
- anno: {
199
- ...this.state.anno,
200
- data: transform.move(this.state.anno.data, movementX, movementY),
201
- },
202
- });
203
- }
204
-
205
- /*************
206
- * RENDERING *
207
- **************/
208
-
209
- renderPolygon() {
210
- switch (this.state.anno.mode) {
211
- default:
212
- return (
213
- <polygon
214
- points={this.toPolygonStr(this.state.anno.data)}
215
- fill="none"
216
- stroke="purple"
217
- style={this.props.style}
218
- className={this.props.className}
219
- onMouseDown={(e) => this.onMouseDown(e)}
220
- onMouseUp={(e) => this.onMouseUp(e)}
221
- />
222
- );
223
- }
224
- }
225
-
226
- renderNodes() {
227
- if (!this.props.isSelected) return null;
228
- switch (this.state.anno.mode) {
229
- case modes.MOVE:
230
- case modes.EDIT_LABEL:
231
- return null;
232
- case modes.EDIT:
233
- case modes.CREATE:
234
- return (
235
- <Node
236
- anno={this.state.anno.data}
237
- key={this.state.anno.selectedNode}
238
- idx={this.state.anno.selectedNode}
239
- style={this.props.style}
240
- className={this.props.className}
241
- isSelected={this.props.isSelected}
242
- mode={this.state.anno.mode}
243
- svg={this.props.svg}
244
- onMouseDown={(e, idx) => this.onNodeMouseDown(e, idx)}
245
- onMouseUp={(e, idx) => this.onNodeMouseUp(e, idx)}
246
- onMouseMove={(e, idx) => this.onNodeMouseMove(e, idx)}
247
- onMouseLeave={(e, idx) => this.handleNodeMouseLeave(e, idx)}
248
- />
249
- );
250
- default:
251
- return this.state.anno.data.map((e, idx) => {
252
- return (
253
- <Node
254
- anno={this.state.anno.data}
255
- idx={idx}
256
- key={idx}
257
- style={this.props.style}
258
- className={this.props.className}
259
- isSelected={this.props.isSelected}
260
- mode={this.state.anno.mode}
261
- svg={this.props.svg}
262
- onMouseDown={(e, idx) => this.onNodeMouseDown(e, idx)}
263
- onMouseUp={(e, idx) => this.onNodeMouseUp(e, idx)}
264
- onMouseLeave={(e, idx) => this.handleNodeMouseLeave(e, idx)}
265
- />
266
- );
267
- });
268
- }
269
- }
270
-
271
- renderInfSelectionArea() {
272
- switch (this.state.anno.mode) {
273
- case modes.MOVE:
274
- return <InfSelectionArea enable={true} svg={this.props.svg} />;
275
- default:
276
- return null;
277
- }
278
- }
279
-
280
- render() {
281
- if (this.state.anno) {
282
- return (
283
- <g
284
- onMouseMove={(e) => this.onMouseMove(e)}
285
- onMouseUp={(e) => this.onMouseUp(e)}
286
- onMouseDown={(e) => this.onMouseDown(e)}
287
- >
288
- {this.renderPolygon()}
289
- {this.renderNodes()}
290
- {this.renderInfSelectionArea()}
291
- </g>
292
- );
293
- } else {
294
- return null;
295
- }
296
- }
297
- }
298
-
299
- export default BBox;
@@ -1,92 +0,0 @@
1
- import React, { Component } from "react";
2
- import "./Annotation.scss";
3
-
4
- class Edge extends Component {
5
- constructor(props) {
6
- super(props);
7
- this.state = {
8
- haloCss: "node-halo-off",
9
- };
10
- }
11
-
12
- componentDidUpdate() {}
13
-
14
- onMouseOver(e) {
15
- if (this.props.isSelected) {
16
- this.setState({ haloCss: "node-halo-on" });
17
- }
18
- }
19
-
20
- onMouseLeave(e) {
21
- if (this.props.isSelected) {
22
- this.setState({ haloCss: "node-halo-off" });
23
- }
24
- }
25
-
26
- onMouseDown(e) {
27
- if (this.props.onMouseDown) {
28
- this.props.onMouseDown(e, this.props.idx);
29
- }
30
- }
31
-
32
- onMouseUp(e) {
33
- e.stopPropagation();
34
- }
35
-
36
- render() {
37
- let p1, p2;
38
- if (!this.props.closingEdge) {
39
- if (this.props.idx - 1 < 0) {
40
- return null;
41
- }
42
- if (this.props.idx > this.props.anno.length - 1) {
43
- return null;
44
- }
45
- p1 = this.props.anno[this.props.idx - 1];
46
- p2 = this.props.anno[this.props.idx];
47
- } else {
48
- if (this.props.idx === 0 && this.props.anno.length === 1) return null;
49
- p1 = this.props.anno[this.props.anno.length - 1];
50
- p2 = this.props.anno[0];
51
- }
52
- return (
53
- <g
54
- onMouseOver={(e) => {
55
- this.onMouseOver(e);
56
- }}
57
- onMouseLeave={(e) => {
58
- this.onMouseLeave(e);
59
- }}
60
- >
61
- <line
62
- x1={p1.x}
63
- y1={p1.y}
64
- x2={p2.x}
65
- y2={p2.y}
66
- stroke="black"
67
- // style={this.props.style}
68
- strokeWidth={this.props.style.strokeWidth * 3}
69
- className={this.state.haloCss}
70
- onMouseOver={(e) => {
71
- this.onMouseOver(e);
72
- }}
73
- onMouseDown={(e) => this.onMouseDown(e)}
74
- onMouseUp={(e) => this.onMouseUp(e)}
75
- />
76
- <line
77
- x1={p1.x}
78
- y1={p1.y}
79
- x2={p2.x}
80
- y2={p2.y}
81
- stroke="black"
82
- style={this.props.style}
83
- className={this.props.className}
84
- onMouseDown={(e) => this.onMouseDown(e)}
85
- onMouseUp={(e) => this.onMouseUp(e)}
86
- />
87
- </g>
88
- );
89
- }
90
- }
91
-
92
- export default Edge;
@@ -1,72 +0,0 @@
1
- import React, { Component } from "react";
2
-
3
- class InfSelectionArea extends Component {
4
- constructor(props) {
5
- super(props);
6
- this.state = {
7
- selAreaCss: "sel-area-off",
8
- };
9
- }
10
-
11
- componentDidMount() {
12
- if (this.props.enable) {
13
- this.enableSelArea();
14
- } else {
15
- this.disableSelArea();
16
- }
17
- }
18
-
19
- componentDidUpdate() {
20
- if (this.props.enable) {
21
- this.enableSelArea();
22
- } else {
23
- this.disableSelArea();
24
- }
25
- }
26
-
27
- onMouseMove(e) {
28
- if (this.props.onMouseMove) {
29
- this.props.onMouseMove(e);
30
- }
31
- }
32
-
33
- onMouseUp(e) {
34
- if (this.props.onMouseUp) {
35
- this.props.onMouseUp(e);
36
- }
37
- }
38
-
39
- enableSelArea() {
40
- if (this.state.selAreaCss !== "sel-area-on") {
41
- this.setState({ selAreaCss: "sel-area-on" });
42
- }
43
- }
44
-
45
- disableSelArea() {
46
- if (this.state.selAreaCss !== "sel-area-off") {
47
- this.setState({ selAreaCss: "sel-area-off" });
48
- }
49
- }
50
-
51
- /*************
52
- * RENDERING *
53
- **************/
54
- render() {
55
- return (
56
- <circle
57
- cx={this.props.svg.width / 2}
58
- cy={this.props.svg.height / 2}
59
- r={"100%"}
60
- className={this.state.selAreaCss}
61
- onMouseMove={(e) => {
62
- this.onMouseMove(e);
63
- }}
64
- onMouseUp={(e) => {
65
- this.onMouseUp(e);
66
- }}
67
- />
68
- );
69
- }
70
- }
71
-
72
- export default InfSelectionArea;
@@ -1,68 +0,0 @@
1
- import React from "react";
2
- import Polygon from "./Polygon";
3
- import Edge from "./Edge";
4
-
5
- import * as modes from "../types/modes";
6
-
7
- class Line extends Polygon {
8
- /*************
9
- * RENDERING *
10
- **************/
11
-
12
- renderEdges() {
13
- if (!this.props.isSelected) return null;
14
- switch (this.state.anno.mode) {
15
- case modes.VIEW:
16
- case modes.ADD:
17
- return this.state.anno.data.map((e, idx) => {
18
- return (
19
- <Edge
20
- anno={this.state.anno.data}
21
- idx={idx}
22
- key={idx}
23
- style={this.props.style}
24
- className={this.props.className}
25
- isSelected={this.props.isSelected}
26
- onMouseDown={(e, idx) => {
27
- this.onEdgeMouseDown(e, idx);
28
- }}
29
- />
30
- );
31
- });
32
- default:
33
- return null;
34
- }
35
- }
36
-
37
- renderPolyline() {
38
- return (
39
- <polyline
40
- points={this.toPolygonStr(this.state.anno.data)}
41
- fill="none"
42
- stroke="purple"
43
- style={{ ...this.props.style, fill: "none" }}
44
- className={this.props.className}
45
- />
46
- );
47
- }
48
- render() {
49
- if (this.state.anno) {
50
- return (
51
- <g
52
- onMouseMove={(e) => this.onMouseMove(e)}
53
- onMouseUp={(e) => this.onMouseUp(e)}
54
- onMouseDown={(e) => this.onMouseDown(e)}
55
- >
56
- {this.renderPolyline()}
57
- {this.renderEdges()}
58
- {this.renderNodes()}
59
- {this.renderInfSelectionArea()}
60
- </g>
61
- );
62
- } else {
63
- return <g></g>;
64
- }
65
- }
66
- }
67
-
68
- export default Line;