lost-sia 2.0.0-alpha0 → 2.0.0-alpha2

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 (87) hide show
  1. package/package.json +20 -3
  2. package/src/AnnoExampleViewer.jsx +61 -48
  3. package/src/AnnoLabelInput.jsx +94 -84
  4. package/src/AnnoToolBar.jsx +118 -97
  5. package/src/Annotation/AnnoBar.jsx +137 -131
  6. package/src/Annotation/Annotation.jsx +364 -328
  7. package/src/Annotation/Annotation.scss +24 -24
  8. package/src/Annotation/BBox.jsx +259 -251
  9. package/src/Annotation/Edge.jsx +79 -69
  10. package/src/Annotation/InfSelectionArea.jsx +56 -55
  11. package/src/Annotation/Line.jsx +60 -52
  12. package/src/Annotation/Node.jsx +242 -238
  13. package/src/Annotation/Point.jsx +175 -171
  14. package/src/Annotation/Polygon.jsx +337 -310
  15. package/src/Canvas.jsx +1910 -1720
  16. package/src/ImgBar.jsx +115 -107
  17. package/src/InfoBoxes/AnnoDetails.jsx +141 -141
  18. package/src/InfoBoxes/AnnoStats.jsx +90 -87
  19. package/src/InfoBoxes/InfoBox.jsx +63 -65
  20. package/src/InfoBoxes/InfoBoxArea.jsx +132 -130
  21. package/src/InfoBoxes/LabelInfo.jsx +103 -83
  22. package/src/LabelInput.jsx +204 -190
  23. package/src/Prompt.jsx +37 -38
  24. package/src/SIA.scss +8 -9
  25. package/src/SIAFilterButton.jsx +178 -169
  26. package/src/SIASettingButton.jsx +112 -107
  27. package/src/Sia.jsx +272 -285
  28. package/src/SiaPopup.jsx +13 -8
  29. package/src/ToolBar.jsx +394 -375
  30. package/src/Toolbar.css +8 -8
  31. package/src/ToolbarItem.jsx +28 -22
  32. package/src/filterTools.js +3 -3
  33. package/src/index.js +9 -11
  34. package/src/scss/_custom.scss +3 -0
  35. package/src/scss/_fixes.scss +6 -0
  36. package/src/scss/_layout.scss +6 -0
  37. package/src/scss/_variables.scss +4 -0
  38. package/src/scss/style-wrapper.scss +4 -0
  39. package/src/scss/style.scss +13 -0
  40. package/src/siaDummyData.js +241 -243
  41. package/src/stories/Button.jsx +54 -0
  42. package/src/stories/Button.stories.js +48 -0
  43. package/src/stories/Configure.mdx +369 -0
  44. package/src/stories/Header.jsx +69 -0
  45. package/src/stories/Header.stories.js +28 -0
  46. package/src/stories/Page.jsx +87 -0
  47. package/src/stories/Page.stories.js +28 -0
  48. package/src/stories/Sia.stories.jsx +61 -0
  49. package/src/stories/assets/accessibility.png +0 -0
  50. package/src/stories/assets/accessibility.svg +5 -0
  51. package/src/stories/assets/addon-library.png +0 -0
  52. package/src/stories/assets/assets.png +0 -0
  53. package/src/stories/assets/avif-test-image.avif +0 -0
  54. package/src/stories/assets/context.png +0 -0
  55. package/src/stories/assets/discord.svg +15 -0
  56. package/src/stories/assets/docs.png +0 -0
  57. package/src/stories/assets/figma-plugin.png +0 -0
  58. package/src/stories/assets/github.svg +3 -0
  59. package/src/stories/assets/share.png +0 -0
  60. package/src/stories/assets/styling.png +0 -0
  61. package/src/stories/assets/testing.png +0 -0
  62. package/src/stories/assets/theming.png +0 -0
  63. package/src/stories/assets/tutorials.svg +12 -0
  64. package/src/stories/assets/youtube.svg +4 -0
  65. package/src/stories/button.css +30 -0
  66. package/src/stories/header.css +32 -0
  67. package/src/stories/lost.js +54 -0
  68. package/src/stories/page.css +69 -0
  69. package/src/stories/siaDummyData.js +263 -0
  70. package/src/stories/store.js +18 -0
  71. package/src/types/annoStatus.js +4 -4
  72. package/src/types/canvasActions.js +51 -51
  73. package/src/types/cursorstyles.js +3 -3
  74. package/src/types/modes.js +8 -8
  75. package/src/types/notificationType.js +4 -4
  76. package/src/types/toolbarEvents.js +31 -31
  77. package/src/types/tools.js +9 -9
  78. package/src/utils/annoConversion.js +129 -99
  79. package/src/utils/colorlut.js +33 -32
  80. package/src/utils/constraints.js +76 -70
  81. package/src/utils/hist.js +52 -53
  82. package/src/utils/keyActions.js +96 -97
  83. package/src/utils/mouse.js +10 -10
  84. package/src/utils/siaIcons.jsx +106 -67
  85. package/src/utils/transform.js +259 -241
  86. package/src/utils/uiConfig.js +45 -45
  87. package/src/utils/windowViewport.js +26 -27
@@ -1,358 +1,394 @@
1
- import React, { Component } from 'react'
2
-
3
- import AnnoBar from './AnnoBar'
4
- import Point from './Point'
5
- import BBox from './BBox'
6
- import Line from './Line'
7
- import Polygon from './Polygon'
8
- import * as modes from '../types/modes'
9
- import * as canvasActions from '../types/canvasActions'
10
- import * as annoStatus from '../types/annoStatus'
11
- import * as colorlut from '../utils/colorlut'
12
- import * as constraints from '../utils/constraints'
13
- import * as transform from '../utils/transform'
14
- import * as notificationType from '../types/notificationType'
1
+ import React, { Component } from "react";
2
+
3
+ import AnnoBar from "./AnnoBar";
4
+ import Point from "./Point";
5
+ import BBox from "./BBox";
6
+ import Line from "./Line";
7
+ import Polygon from "./Polygon";
8
+ import * as modes from "../types/modes";
9
+ import * as canvasActions from "../types/canvasActions";
10
+ import * as annoStatus from "../types/annoStatus";
11
+ import * as colorlut from "../utils/colorlut";
12
+ import * as constraints from "../utils/constraints";
13
+ import * as transform from "../utils/transform";
14
+ import * as notificationType from "../types/notificationType";
15
15
 
16
16
  class Annotation extends Component {
17
-
18
- constructor(props) {
19
- super(props)
20
- this.state = {
21
- // mode: modes.VIEW,
22
- selAreaCss: 'sel-area-off',
23
- visibility: 'visible',
24
- anno: undefined
25
- }
26
- this.myAnno = React.createRef()
27
-
28
- }
29
-
30
- componentWillMount() {
31
- this.setState({ anno: { ...this.props.data } })
17
+ constructor(props) {
18
+ super(props);
19
+ this.state = {
20
+ // mode: modes.VIEW,
21
+ selAreaCss: "sel-area-off",
22
+ visibility: "visible",
23
+ anno: undefined,
24
+ };
25
+ this.myAnno = React.createRef();
26
+ }
27
+
28
+ componentWillMount() {
29
+ this.setState({ anno: { ...this.props.data } });
30
+ }
31
+
32
+ componentDidUpdate(prevProps) {
33
+ if (prevProps.data !== this.props.data) {
34
+ this.setState({ anno: { ...this.props.data } });
32
35
  }
33
-
34
- componentDidUpdate(prevProps) {
35
- if (prevProps.data !== this.props.data) {
36
- this.setState({ anno: { ...this.props.data } })
37
- }
38
- if (prevProps.showSingleAnno !== this.props.showSingleAnno) {
39
- if (this.props.showSingleAnno === undefined) {
40
- this.setVisible(true)
41
- } else {
42
- if (this.props.showSingleAnno !== this.props.data.id) {
43
- this.setVisible(false)
44
- } else {
45
- this.setVisible(true)
46
- }
47
- }
48
- }
49
- if (this.props.showSingleAnno === undefined) {
50
- if (this.state.anno.visible !== undefined) {
51
- if (this.state.anno.visible) {
52
- this.setVisible(true)
53
- } else {
54
- this.setVisible(false)
55
- }
56
- }
36
+ if (prevProps.showSingleAnno !== this.props.showSingleAnno) {
37
+ if (this.props.showSingleAnno === undefined) {
38
+ this.setVisible(true);
39
+ } else {
40
+ if (this.props.showSingleAnno !== this.props.data.id) {
41
+ this.setVisible(false);
42
+ } else {
43
+ this.setVisible(true);
57
44
  }
58
-
59
- }
60
-
61
- /*************
62
- * EVENTS *
63
- **************/
64
- onClick(e) {
65
- e.stopPropagation()
66
- this.performedAction(this.state.anno, canvasActions.ANNO_SELECTED)
45
+ }
67
46
  }
68
-
69
- onMouseDown(e) {
70
- e.preventDefault()
71
- if (this.props.onMouseDown) {
72
- this.props.onMouseDown(e)
47
+ if (this.props.showSingleAnno === undefined) {
48
+ if (this.state.anno.visible !== undefined) {
49
+ if (this.state.anno.visible) {
50
+ this.setVisible(true);
51
+ } else {
52
+ this.setVisible(false);
73
53
  }
54
+ }
74
55
  }
75
-
76
- onContextMenu(e) {
77
- e.preventDefault()
78
- }
79
-
80
- handleModeChangeRequest(anno, mode) {
81
- this.setMode(anno, mode)
56
+ }
57
+
58
+ /*************
59
+ * EVENTS *
60
+ **************/
61
+ onClick(e) {
62
+ e.stopPropagation();
63
+ this.performedAction(this.state.anno, canvasActions.ANNO_SELECTED);
64
+ }
65
+
66
+ onMouseDown(e) {
67
+ e.preventDefault();
68
+ if (this.props.onMouseDown) {
69
+ this.props.onMouseDown(e);
82
70
  }
83
-
84
- /*************
85
- * LOGIC *
86
- *************/
87
-
88
- /**
89
- * Trigger callback when this annotation performed an action
90
- *
91
- * @param {String} pAction
92
- */
93
- performedAction(anno, pAction) {
94
-
95
- if (this.props.onAction) {
96
- this.props.onAction(anno, pAction)
97
- }
71
+ }
72
+
73
+ onContextMenu(e) {
74
+ e.preventDefault();
75
+ }
76
+
77
+ handleModeChangeRequest(anno, mode) {
78
+ this.setMode(anno, mode);
79
+ }
80
+
81
+ /*************
82
+ * LOGIC *
83
+ *************/
84
+
85
+ /**
86
+ * Trigger callback when this annotation performed an action
87
+ *
88
+ * @param {String} pAction
89
+ */
90
+ performedAction(anno, pAction) {
91
+ if (this.props.onAction) {
92
+ this.props.onAction(anno, pAction);
98
93
  }
94
+ }
99
95
 
100
-
101
- notify(messageObj) {
102
- if (this.props.onNotification) {
103
- this.props.onNotification(messageObj)
104
- }
96
+ notify(messageObj) {
97
+ if (this.props.onNotification) {
98
+ this.props.onNotification(messageObj);
105
99
  }
106
-
107
- /**
108
- * Handle a performed action from a specific annotation
109
- *
110
- * @param {list} annoData - Annotation data that define a box, line,
111
- * polygon, point
112
- * @param {string} pAction - The performed action
113
- * @param {int} selectedNode - The node of the annotation that
114
- * was selected
115
- */
116
- performedAnnoAction(anno, pAction) {
117
-
118
- switch (pAction) {
119
- case canvasActions.ANNO_CREATED_FINAL_NODE:
120
- case canvasActions.ANNO_EDITED:
121
- case canvasActions.ANNO_MOVED:
122
- case canvasActions.ANNO_CREATED:
123
- // Check if annoation is within image bounds
124
- const corrected = transform.correctAnnotation(anno.data, this.props.svg, this.props.imageOffset)
125
- let newAnno = { ...anno, data: corrected }
126
- const area = transform.getArea(corrected, this.props.svg, anno.type, this.props.image)
127
- if (area !== undefined) {
128
- if (area < this.props.canvasConfig.annos.minArea) {
129
- this.notify({
130
- title: "Annotation to small",
131
- message: 'Annotation area was ' + Math.round(area) + 'px but needs to be bigger than ' + this.props.canvasConfig.annos.minArea + ' px',
132
- type: notificationType.WARNING
133
- })
134
- // newAnno = {...newAnno, mode: modes.DELETED}
135
- this.setMode(newAnno, modes.DELETED)
136
- } else {
137
- this.performedAction(newAnno, pAction)
138
- }
139
- } else {
140
- this.performedAction(newAnno, pAction)
141
- }
142
- break
143
- default:
144
- this.performedAction(anno, pAction)
145
- break
100
+ }
101
+
102
+ /**
103
+ * Handle a performed action from a specific annotation
104
+ *
105
+ * @param {list} annoData - Annotation data that define a box, line,
106
+ * polygon, point
107
+ * @param {string} pAction - The performed action
108
+ * @param {int} selectedNode - The node of the annotation that
109
+ * was selected
110
+ */
111
+ performedAnnoAction(anno, pAction) {
112
+ switch (pAction) {
113
+ case canvasActions.ANNO_CREATED_FINAL_NODE:
114
+ case canvasActions.ANNO_EDITED:
115
+ case canvasActions.ANNO_MOVED:
116
+ case canvasActions.ANNO_CREATED:
117
+ // Check if annoation is within image bounds
118
+ const corrected = transform.correctAnnotation(
119
+ anno.data,
120
+ this.props.svg,
121
+ this.props.imageOffset,
122
+ );
123
+ let newAnno = { ...anno, data: corrected };
124
+ const area = transform.getArea(
125
+ corrected,
126
+ this.props.svg,
127
+ anno.type,
128
+ this.props.image,
129
+ );
130
+ if (area !== undefined) {
131
+ if (area < this.props.canvasConfig.annos.minArea) {
132
+ this.notify({
133
+ title: "Annotation to small",
134
+ message:
135
+ "Annotation area was " +
136
+ Math.round(area) +
137
+ "px but needs to be bigger than " +
138
+ this.props.canvasConfig.annos.minArea +
139
+ " px",
140
+ type: notificationType.WARNING,
141
+ });
142
+ // newAnno = {...newAnno, mode: modes.DELETED}
143
+ this.setMode(newAnno, modes.DELETED);
144
+ } else {
145
+ this.performedAction(newAnno, pAction);
146
+ }
147
+ } else {
148
+ this.performedAction(newAnno, pAction);
146
149
  }
150
+ break;
151
+ default:
152
+ this.performedAction(anno, pAction);
153
+ break;
147
154
  }
148
-
149
- setAnnoMode(anno, mode) {
150
- this.setState({
151
- anno: {
152
- ...anno,
153
- mode: mode
154
- }
155
- })
156
- }
157
-
158
- setMode(anno, mode) {
159
- if (anno.mode !== mode) {
160
- switch (mode) {
161
- case modes.EDIT_LABEL:
162
- if (constraints.allowedToLabel(
163
- this.props.allowedActions,
164
- anno
165
- )) {
166
- this.setAnnoMode(anno, mode)
167
- }
168
- break
169
- case modes.DELETED:
170
- // if(constraints.allowedToDelete(
171
- // this.props.allowedActions,
172
- // anno
173
- // )){
174
- this.setAnnoMode(anno, mode)
175
- const newAnno = {
176
- ...anno,
177
- // status: annoStatus.DELETED
178
- mode: mode.DELETED
179
- }
180
- // this.setState({
181
- // anno: newAnno
182
- // })
183
- this.performedAction(newAnno, canvasActions.ANNO_DELETED)
184
- // }
185
- break
186
- case modes.MOVE:
187
- this.setAnnoMode(anno, mode)
188
- this.performedAction(anno, canvasActions.ANNO_ENTER_MOVE_MODE)
189
- break
190
- case modes.EDIT:
191
- this.setAnnoMode(anno, mode)
192
- this.performedAction(anno, canvasActions.ANNO_ENTER_EDIT_MODE)
193
- break
194
- default:
195
- this.setAnnoMode(anno, mode)
196
- break
197
- }
198
- }
155
+ }
156
+
157
+ setAnnoMode(anno, mode) {
158
+ this.setState({
159
+ anno: {
160
+ ...anno,
161
+ mode: mode,
162
+ },
163
+ });
164
+ }
165
+
166
+ setMode(anno, mode) {
167
+ if (anno.mode !== mode) {
168
+ switch (mode) {
169
+ case modes.EDIT_LABEL:
170
+ if (constraints.allowedToLabel(this.props.allowedActions, anno)) {
171
+ this.setAnnoMode(anno, mode);
172
+ }
173
+ break;
174
+ case modes.DELETED:
175
+ // if(constraints.allowedToDelete(
176
+ // this.props.allowedActions,
177
+ // anno
178
+ // )){
179
+ this.setAnnoMode(anno, mode);
180
+ const newAnno = {
181
+ ...anno,
182
+ // status: annoStatus.DELETED
183
+ mode: mode.DELETED,
184
+ };
185
+ // this.setState({
186
+ // anno: newAnno
187
+ // })
188
+ this.performedAction(newAnno, canvasActions.ANNO_DELETED);
189
+ // }
190
+ break;
191
+ case modes.MOVE:
192
+ this.setAnnoMode(anno, mode);
193
+ this.performedAction(anno, canvasActions.ANNO_ENTER_MOVE_MODE);
194
+ break;
195
+ case modes.EDIT:
196
+ this.setAnnoMode(anno, mode);
197
+ this.performedAction(anno, canvasActions.ANNO_ENTER_EDIT_MODE);
198
+ break;
199
+ default:
200
+ this.setAnnoMode(anno, mode);
201
+ break;
202
+ }
199
203
  }
200
-
201
- setVisible(visible) {
202
- if (visible) {
203
- if (this.state.visibility !== 'visible') {
204
- this.setState({ visibility: 'visible' })
205
- }
206
- } else {
207
- if (this.state.visibility !== 'hidden') {
208
- this.setState({ visibility: 'hidden' })
209
- }
210
- }
204
+ }
205
+
206
+ setVisible(visible) {
207
+ if (visible) {
208
+ if (this.state.visibility !== "visible") {
209
+ this.setState({ visibility: "visible" });
210
+ }
211
+ } else {
212
+ if (this.state.visibility !== "hidden") {
213
+ this.setState({ visibility: "hidden" });
214
+ }
211
215
  }
216
+ }
212
217
 
213
- isSelected() {
214
- if (constraints.allowedToEdit(this.props.allowedActions, this.state.anno)) {
215
- return this.props.selectedAnno === this.props.data.id
216
- } else {
217
- return false
218
- }
218
+ isSelected() {
219
+ if (constraints.allowedToEdit(this.props.allowedActions, this.state.anno)) {
220
+ return this.props.selectedAnno === this.props.data.id;
221
+ } else {
222
+ return false;
219
223
  }
220
-
221
- getResult() {
222
- return {
223
- ...this.state.anno,
224
- data: this.myAnno.current.state.anno,
225
- createMode: this.myAnno.current.state.mode === modes.CREATE
226
- }
224
+ }
225
+
226
+ getResult() {
227
+ return {
228
+ ...this.state.anno,
229
+ data: this.myAnno.current.state.anno,
230
+ createMode: this.myAnno.current.state.mode === modes.CREATE,
231
+ };
232
+ }
233
+
234
+ getLabel(lblId) {
235
+ return this.props.possibleLabels.find((e) => {
236
+ return e.id === lblId;
237
+ });
238
+ }
239
+
240
+ getColor() {
241
+ if (this.state.anno.labelIds && this.state.anno.labelIds.length > 0) {
242
+ return this.getLabel(this.state.anno.labelIds[0]).color;
243
+ } else {
244
+ return colorlut.getDefaultColor();
227
245
  }
228
-
229
- getLabel(lblId) {
230
- return this.props.possibleLabels.find(e => {
231
- return e.id === lblId
232
- })
246
+ }
247
+
248
+ getStyle() {
249
+ const color = this.getColor();
250
+ if (this.isSelected()) {
251
+ return {
252
+ stroke: color,
253
+ fill: color,
254
+ strokeWidth: this.props.uiConfig.strokeWidth / this.props.svg.scale,
255
+ r: this.props.uiConfig.nodeRadius / this.props.svg.scale,
256
+ };
257
+ } else {
258
+ return {
259
+ stroke: color,
260
+ fill: color,
261
+ strokeWidth: this.props.uiConfig.strokeWidth / this.props.svg.scale,
262
+ r: this.props.uiConfig.nodeRadius / this.props.svg.scale,
263
+ };
233
264
  }
265
+ }
234
266
 
235
- getColor() {
236
- if (this.state.anno.labelIds && this.state.anno.labelIds.length > 0) {
237
- return this.getLabel(this.state.anno.labelIds[0]).color
238
- }
239
- else {
240
- return colorlut.getDefaultColor()
241
- }
267
+ getCssClass() {
268
+ if (this.isSelected()) {
269
+ return "selected";
270
+ } else {
271
+ return "not-selected";
242
272
  }
243
-
244
- getStyle() {
245
- const color = this.getColor()
246
- if (this.isSelected()) {
247
- return {
248
- stroke: color,
249
- fill: color,
250
- strokeWidth: this.props.uiConfig.strokeWidth / this.props.svg.scale,
251
- r: this.props.uiConfig.nodeRadius / this.props.svg.scale
252
-
273
+ }
274
+
275
+ /*************
276
+ * RENDERING *
277
+ **************/
278
+ renderAnno() {
279
+ const type = this.props.type;
280
+ // const allowedToEdit = constraints.allowedToEditBounds(
281
+ // this.props.allowedActions,
282
+ // this.state.anno
283
+ // )
284
+ switch (type) {
285
+ case "point":
286
+ return (
287
+ <Point
288
+ ref={this.myAnno}
289
+ anno={this.state.anno}
290
+ style={this.getStyle()}
291
+ className={this.getCssClass()}
292
+ isSelected={this.isSelected()}
293
+ svg={this.props.svg}
294
+ onModeChangeRequest={(anno, mode) =>
295
+ this.handleModeChangeRequest(anno, mode)
253
296
  }
254
- } else {
255
- return {
256
- stroke: color,
257
- fill: color,
258
- strokeWidth: this.props.uiConfig.strokeWidth / this.props.svg.scale,
259
- r: this.props.uiConfig.nodeRadius / this.props.svg.scale
297
+ onAction={(anno, pAction) =>
298
+ this.performedAnnoAction(anno, pAction)
260
299
  }
261
- }
262
- }
263
-
264
- getCssClass() {
265
- if (this.isSelected()) {
266
- return 'selected'
267
- } else {
268
- return 'not-selected'
269
- }
270
- }
271
-
272
- /*************
273
- * RENDERING *
274
- **************/
275
- renderAnno() {
276
- const type = this.props.type
277
- // const allowedToEdit = constraints.allowedToEditBounds(
278
- // this.props.allowedActions,
279
- // this.state.anno
280
- // )
281
- switch (type) {
282
- case 'point':
283
- return <Point ref={this.myAnno} anno={this.state.anno}
284
- style={this.getStyle()}
285
- className={this.getCssClass()}
286
- isSelected={this.isSelected()}
287
- svg={this.props.svg}
288
- onModeChangeRequest={(anno, mode) => this.handleModeChangeRequest(anno, mode)}
289
- onAction={(anno, pAction) => this.performedAnnoAction(anno, pAction)}
290
- />
291
- case 'bBox':
292
- return <BBox ref={this.myAnno} anno={this.state.anno}
293
- style={this.getStyle()}
294
- className={this.getCssClass()}
295
- onNodeClick={(e, idx) => this.onNodeClick(e, idx)}
296
- onNodeMouseDown={(e, idx) => this.onNodeMouseDown(e, idx)}
297
- isSelected={this.isSelected()}
298
- svg={this.props.svg}
299
- onModeChangeRequest={(anno, mode) => this.handleModeChangeRequest(anno, mode)}
300
- onAction={(anno, pAction) => this.performedAnnoAction(anno, pAction)}
301
- />
302
- case 'polygon':
303
- return <Polygon ref={this.myAnno} anno={this.state.anno}
304
- style={this.getStyle()}
305
- className={this.getCssClass()}
306
- onNodeClick={(e, idx) => this.onNodeClick(e, idx)}
307
- isSelected={this.isSelected()}
308
- svg={this.props.svg}
309
- onModeChangeRequest={(anno, mode) => this.handleModeChangeRequest(anno, mode)}
310
- onAction={(anno, pAction) => this.performedAnnoAction(anno, pAction)}
311
- />
312
- case 'line':
313
- return <Line ref={this.myAnno} anno={this.state.anno}
314
- style={this.getStyle()}
315
- className={this.getCssClass()}
316
- isSelected={this.isSelected()}
317
- svg={this.props.svg}
318
- onAction={(anno, pAction) => this.performedAnnoAction(anno, pAction)}
319
- onModeChangeRequest={(anno, mode) => this.handleModeChangeRequest(anno, mode)}
320
- />
321
- default:
322
- console.error("Wrong annoType for annotations: ",
323
- this.props.annoType)
324
- }
325
- }
326
-
327
- renderAnnoBar() {
328
- return <AnnoBar
300
+ />
301
+ );
302
+ case "bBox":
303
+ return (
304
+ <BBox
305
+ ref={this.myAnno}
329
306
  anno={this.state.anno}
330
- mode={this.state.anno.mode}
331
- possibleLabels={this.props.possibleLabels}
332
- onClick={e => this.onClick(e)}
333
307
  style={this.getStyle()}
308
+ className={this.getCssClass()}
309
+ onNodeClick={(e, idx) => this.onNodeClick(e, idx)}
310
+ onNodeMouseDown={(e, idx) => this.onNodeMouseDown(e, idx)}
311
+ isSelected={this.isSelected()}
334
312
  svg={this.props.svg}
335
- defaultLabel={this.props.defaultLabel}
336
- />
337
- }
338
- render() {
339
- if (!this.state.anno.data) return null
340
- if (!this.props.possibleLabels) return null
341
- if (this.state.anno.status === annoStatus.DELETED) return null
313
+ onModeChangeRequest={(anno, mode) =>
314
+ this.handleModeChangeRequest(anno, mode)
315
+ }
316
+ onAction={(anno, pAction) =>
317
+ this.performedAnnoAction(anno, pAction)
318
+ }
319
+ />
320
+ );
321
+ case "polygon":
342
322
  return (
343
- <g>
344
- <g visibility={this.state.visibility}
345
- onClick={e => this.onClick(e)}
346
- onMouseDown={e => this.onMouseDown(e)}
347
- onContextMenu={e => this.onContextMenu(e)}
348
- >
349
- {this.renderAnnoBar()}
350
- {this.renderAnno()}
351
-
352
- </g>
353
- </g>
354
- )
323
+ <Polygon
324
+ ref={this.myAnno}
325
+ anno={this.state.anno}
326
+ style={this.getStyle()}
327
+ className={this.getCssClass()}
328
+ onNodeClick={(e, idx) => this.onNodeClick(e, idx)}
329
+ isSelected={this.isSelected()}
330
+ svg={this.props.svg}
331
+ onModeChangeRequest={(anno, mode) =>
332
+ this.handleModeChangeRequest(anno, mode)
333
+ }
334
+ onAction={(anno, pAction) =>
335
+ this.performedAnnoAction(anno, pAction)
336
+ }
337
+ />
338
+ );
339
+ case "line":
340
+ return (
341
+ <Line
342
+ ref={this.myAnno}
343
+ anno={this.state.anno}
344
+ style={this.getStyle()}
345
+ className={this.getCssClass()}
346
+ isSelected={this.isSelected()}
347
+ svg={this.props.svg}
348
+ onAction={(anno, pAction) =>
349
+ this.performedAnnoAction(anno, pAction)
350
+ }
351
+ onModeChangeRequest={(anno, mode) =>
352
+ this.handleModeChangeRequest(anno, mode)
353
+ }
354
+ />
355
+ );
356
+ default:
357
+ console.error("Wrong annoType for annotations: ", this.props.annoType);
355
358
  }
359
+ }
360
+
361
+ renderAnnoBar() {
362
+ return (
363
+ <AnnoBar
364
+ anno={this.state.anno}
365
+ mode={this.state.anno.mode}
366
+ possibleLabels={this.props.possibleLabels}
367
+ onClick={(e) => this.onClick(e)}
368
+ style={this.getStyle()}
369
+ svg={this.props.svg}
370
+ defaultLabel={this.props.defaultLabel}
371
+ />
372
+ );
373
+ }
374
+ render() {
375
+ if (!this.state.anno.data) return null;
376
+ if (!this.props.possibleLabels) return null;
377
+ if (this.state.anno.status === annoStatus.DELETED) return null;
378
+ return (
379
+ <g>
380
+ <g
381
+ visibility={this.state.visibility}
382
+ onClick={(e) => this.onClick(e)}
383
+ onMouseDown={(e) => this.onMouseDown(e)}
384
+ onContextMenu={(e) => this.onContextMenu(e)}
385
+ >
386
+ {this.renderAnnoBar()}
387
+ {this.renderAnno()}
388
+ </g>
389
+ </g>
390
+ );
391
+ }
356
392
  }
357
393
 
358
- export default Annotation
394
+ export default Annotation;