Skip to content

Commit 692b828

Browse files
update to internal commit 4989eea5
1 parent c9d20ea commit 692b828

File tree

6 files changed

+351
-19
lines changed

6 files changed

+351
-19
lines changed
Lines changed: 332 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,332 @@
1+
---
2+
layout: default-layout
3+
title: DrawingItem - Dynamsoft Camera Enhancer JavaScript API
4+
description: This page shows the DrawingItem definitions of Dynamsoft Camera Enhancer JavaScript SDK.
5+
keywords: camera enhancer, drawingitem, javascript, js
6+
needAutoGenerateSidebar: true
7+
needGenerateH3Content: true
8+
noTitleIndex: true
9+
breadcrumbText: DrawingItem
10+
permalink: /programming/javascript/api-reference/drawingitem.html
11+
---
12+
13+
# Class DrawingItem
14+
15+
The `DrawingItem` class specifies the foundational attributes and functionalities of a graphical element, including shapes, images, or textual sections, intended for rendering on a canvas. Functioning as an abstract class, it cannot be instantiated on its own. Instead, it serves as a blueprint for more specific subclasses, such as `QuadDrawingItem`, `TextDrawingItem`, and others, which inherit and tailor these properties and methods to suit diverse graphical requirements and contexts.
16+
17+
In this version, the subclasses include:
18+
19+
- [ImageDrawingItem](./imagedrawingitem.md)
20+
- [LineDrawingItem](./linedrawingitem.md)
21+
- [QuadDrawingItem](./quaddrawingitem.md)
22+
- [RectDrawingItem](./rectdrawingitem.md)
23+
- [TextDrawingItem](./textdrawingitem.md)
24+
25+
| Name | Description |
26+
| --------------------------------- | ------------------------------------------------------------------------------------------------------ |
27+
| [coordinateBase](#coordinatebase) | Returns or sets the coordinate system base. |
28+
| [drawingLayerId](#drawinglayerid) | Returns the numeric ID for the `DrawingLayer` this `DrawingItem` belongs to. |
29+
| [drawingStyleId](#drawingstyleid) | Returns or sets the numeric ID for the `DrawingStyle` that applies to this `DrawingItem`. |
30+
| [mediaType](#mediatype) | Returns an enumeration value which indicates the type of this `DrawingItem` (e.g., image, line, text). |
31+
| [getState()](#getstate) | Returns the current state of the `DrawingItem` |
32+
| [on()](#on) | Binds a listener for a specific event. `eventName`. |
33+
| [off()](#off) | Unbinds a listener for a specific event. |
34+
| [addNote()](#addnote) | Adds a `Note` object to this `DrawingItem`. |
35+
| [getNote()](#getnote) | Returns a `Note` object specified by its name, if it exists. |
36+
| [getNotes()](#getnotes) | Returns a collection of all existing `Note` objects on this `DrawingItem`. |
37+
| [hasNote()](#hasnote) | Checks if a `Note` object with the specified name exists. |
38+
| [updateNote()](#updatenote) | Updates the content of a specified `Note` object. |
39+
| [deleteNote()](#deletenote) | Deletes a `Note` object specified by its name. |
40+
| [clearNotes()](#clearnotes) | Deletes all `Note` objects on this `DrawingItem`. |
41+
42+
## coordinateBase
43+
44+
Returns or sets the coordinate system base with a string:
45+
46+
- "view" for viewport-based coordinates or
47+
- "image" for image-based coordinates.
48+
49+
```typescript
50+
coordinateBase: string;
51+
```
52+
53+
## drawingLayerId
54+
55+
Returns the numeric ID for the `DrawingLayer` this `DrawingItem` belongs to.
56+
57+
```typescript
58+
readonly drawingLayerId: number;
59+
```
60+
61+
## drawingStyleId
62+
63+
Returns or sets the numeric ID for the `DrawingStyle` that applies to this `DrawingItem`.
64+
65+
> Invoke [renderAll()](./drawinglayer.md#renderall) for the new `DrawingStyle` to take effect.
66+
67+
```typescript
68+
drawingStyleId?: number;
69+
```
70+
71+
## mediaType
72+
73+
Returns an enumeration value which indicates the type of this `DrawingItem` (e.g., image, line, text).
74+
75+
```typescript
76+
readonly mediaType: EnumDrawingItemMediaType;
77+
```
78+
79+
**See Also**
80+
81+
[EnumDrawingItemMediaType](./enum/enumdrawingitemmediatype.md)
82+
83+
## getState
84+
85+
Returns the current state of the `DrawingItem`.
86+
87+
```typescript
88+
getState(): EnumDrawingItemState;
89+
```
90+
91+
**Parameters**
92+
93+
None.
94+
95+
**Return Value**
96+
97+
The current state of the `DrawingItem`, of type `EnumDrawingItemState`.
98+
99+
**See Also**
100+
101+
[EnumDrawingItemState](./enum/enumdrawingitemstate.md)
102+
103+
## on
104+
105+
Binds a listener for a specific event.
106+
107+
```typescript
108+
on(eventName: string, listener: (event: DrawingItemEvent) => void): void;
109+
```
110+
111+
**Parameters**
112+
113+
`eventName`: specifies the event by its name. Allowed events are: `mousedown`, `mouseup`, `dblclick`, `mouseover` and `mouseout`.
114+
115+
`listener`: the event listener.
116+
117+
**Return Value**
118+
119+
None.
120+
121+
**See also**
122+
123+
[DrawingItemEvent](interface/drawingitemevent.md)
124+
125+
## off
126+
127+
Unbinds a listener for a specific event.
128+
129+
```typescript
130+
off(eventName: string, listener(event: DrawingItemEvent): void): void;
131+
```
132+
133+
**Parameters**
134+
135+
`eventName`: specifies the event by its name. Allowed events are: `mousedown`, `mouseup`, `dblclick`, `mouseover` and `mouseout`.
136+
137+
`listener`: the event listener.
138+
139+
**Return Value**
140+
141+
None.
142+
143+
**See also**
144+
145+
[DrawingItemEvent](interface/drawingitemevent.md)
146+
147+
## addNote
148+
149+
Adds a `Note` object to this `DrawingItem`.
150+
151+
```typescript
152+
addNote(note: Note, replace?: boolean): void;
153+
```
154+
155+
**Parameters**
156+
157+
`note`: specifies the `Note` object.
158+
159+
`replace`: [Optional] whether to replace an existing note if the notes share the same name.
160+
161+
**Return Value**
162+
163+
None.
164+
165+
**Code Snippet**
166+
167+
```js
168+
let item = new Dynamsoft.DCE.DrawingItem.RectDrawingItem({
169+
x: 100,
170+
y: 200,
171+
width: 300,
172+
height: 300,
173+
isMeasuredInPercentage: false
174+
});
175+
item.addNote(
176+
{
177+
name: "Description",
178+
content: {
179+
noteType: "Rectangle"
180+
}
181+
}, true
182+
);
183+
```
184+
185+
**See also**
186+
187+
[Note](interface/note.md)
188+
189+
## getNote
190+
191+
Returns a `Note` object specified by its name, if it exists.
192+
193+
```typescript
194+
getNote(name: string): Note;
195+
```
196+
197+
**Parameters**
198+
199+
`name`: specifies the name of the `Note` object.
200+
201+
**Return Value**
202+
203+
The corresponding `Note` object specified by its name, if it exists.
204+
205+
**Code Snippet**
206+
207+
```js
208+
item.getNote("Description");
209+
```
210+
211+
## getNotes
212+
213+
Returns a collection of all existing `Note` objects on this `DrawingItem`.
214+
215+
```typescript
216+
getNotes(): Array<Note>;
217+
```
218+
219+
**Code Snippet**
220+
221+
```js
222+
item.getNotes();
223+
```
224+
225+
**Parameters**
226+
227+
None.
228+
229+
**Return Value**
230+
231+
All existing `Note` objects on this `DrawingItem`.
232+
233+
**See Also**
234+
235+
[Note](./interface/note.md)
236+
237+
## hasNote
238+
239+
Checks if a `Note` object with the specified name exists.
240+
241+
```typescript
242+
hasNote(name: string): boolean;
243+
```
244+
245+
**Parameters**
246+
247+
`name`: specifies the name of the `Note` object.
248+
249+
**Return Value**
250+
251+
Boolean indicating whether the `Note` object exists.
252+
253+
**Code Snippet**
254+
255+
```js
256+
item.hasNote("Description");
257+
```
258+
259+
## updateNote
260+
261+
Updates the content of a specified `Note` object.
262+
263+
```typescript
264+
updateNote(name: string, content: any, mergeContent?: boolean): void;
265+
```
266+
267+
**Parameters**
268+
269+
`name`: specifies the name of the `Note` object.
270+
271+
`content`: specifies the new content, can be of any type.
272+
273+
`mergeContent`: [Optional] whether to merge the new content with the existing one.
274+
275+
**Return Value**
276+
277+
None.
278+
279+
**Code Snippet**
280+
281+
```js
282+
item.updateNote(
283+
"Description",
284+
{
285+
timeStamp: (new Date()).getTime()
286+
}, true
287+
);
288+
```
289+
290+
## deleteNote
291+
292+
Deletes a `Note` object specified by its name.
293+
294+
```typescript
295+
deleteNote(name: string): void;
296+
```
297+
298+
**Parameters**
299+
300+
`name`: specifies the name of the `Note` object.
301+
302+
**Return Value**
303+
304+
None.
305+
306+
**Code Snippet**
307+
308+
```js
309+
item.deleteNote("Description");
310+
```
311+
312+
## clearNotes
313+
314+
Deletes all `Note` objects on this `DrawingItem`.
315+
316+
```typescript
317+
clearNotes(): void;
318+
```
319+
320+
**Parameters**
321+
322+
None.
323+
324+
**Return Value**
325+
326+
None.
327+
328+
**Code Snippet**
329+
330+
```js
331+
item.clearNotes();
332+
```

programming/javascript/api-reference/drawingitem.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ None.
165165
**Code Snippet**
166166

167167
```js
168-
let item = new Dynamsoft.DCE.DrawingItem.RectDrawingItem({
168+
let item = new Dynamsoft.DCE.RectDrawingItem({
169169
x: 100,
170170
y: 200,
171171
width: 300,

0 commit comments

Comments
 (0)