Class: ElementAdder
ElementAdder visitor for adding elements to tracks. Uses the visitor pattern to handle different element types and implements the Friend Class Pattern for explicit access control. Automatically calculates start and end times for elements based on existing track content.
Implements
ElementVisitor<Promise<boolean>>
Table of contents
Constructors
Methods
- visitVideoElement
- visitAudioElement
- visitImageElement
- visitTextElement
- visitCaptionElement
- visitIconElement
- visitCircleElement
- visitRectElement
- visitPlaceholderElement
- visitLineElement
- visitArrowElement
- visitEffectElement
Constructors
constructor
• new ElementAdder(track): ElementAdder
Creates a new ElementAdder instance for the specified track.
Parameters
| Name | Type | Description |
|---|---|---|
track | Track | The track to add elements to |
Returns
Example
const adder = new ElementAdder(track);
const success = await adder.visitVideoElement(videoElement);
Defined in
core/visitor/element-adder.ts:39
Methods
visitVideoElement
▸ visitVideoElement(element): Promise<boolean>
Adds a video element to the track. Updates video metadata and calculates appropriate start/end times based on existing track elements.
Parameters
| Name | Type | Description |
|---|---|---|
element | VideoElement | The video element to add |
Returns
Promise<boolean>
Promise resolving to true if element was added successfully
Example
const success = await adder.visitVideoElement(videoElement);
// success = true if element was added successfully
Implementation of
ElementVisitor.visitVideoElement
Defined in
core/visitor/element-adder.ts:58
visitAudioElement
▸ visitAudioElement(element): Promise<boolean>
Adds an audio element to the track. Updates audio metadata and calculates appropriate start/end times based on existing track elements.
Parameters
| Name | Type | Description |
|---|---|---|
element | AudioElement | The audio element to add |
Returns
Promise<boolean>
Promise resolving to true if element was added successfully
Example
const success = await adder.visitAudioElement(audioElement);
// success = true if element was added successfully
Implementation of
ElementVisitor.visitAudioElement
Defined in
core/visitor/element-adder.ts:88
visitImageElement
▸ visitImageElement(element): Promise<boolean>
Adds an image element to the track. Updates image metadata and calculates appropriate start/end times based on existing track elements.
Parameters
| Name | Type | Description |
|---|---|---|
element | ImageElement | The image element to add |
Returns
Promise<boolean>
Promise resolving to true if element was added successfully
Example
const success = await adder.visitImageElement(imageElement);
// success = true if element was added successfully
Implementation of
ElementVisitor.visitImageElement
Defined in
core/visitor/element-adder.ts:118
visitTextElement
▸ visitTextElement(element): Promise<boolean>
Adds a text element to the track. Calculates appropriate start/end times based on existing track elements.
Parameters
| Name | Type | Description |
|---|---|---|
element | TextElement | The text element to add |
Returns
Promise<boolean>
Promise resolving to true if element was added successfully
Example
const success = await adder.visitTextElement(textElement);
// success = true if element was added successfully
Implementation of
ElementVisitor.visitTextElement
Defined in
core/visitor/element-adder.ts:147
visitCaptionElement
▸ visitCaptionElement(element): Promise<boolean>
Adds a caption element to the track. Calculates appropriate start/end times based on existing track elements.
Parameters
| Name | Type | Description |
|---|---|---|
element | CaptionElement | The caption element to add |
Returns
Promise<boolean>
Promise resolving to true if element was added successfully
Example
const success = await adder.visitCaptionElement(captionElement);
// success = true if element was added successfully
Implementation of
ElementVisitor.visitCaptionElement
Defined in
core/visitor/element-adder.ts:175
visitIconElement
▸ visitIconElement(element): Promise<boolean>
Adds an icon element to the track. Calculates appropriate start/end times based on existing track elements.
Parameters
| Name | Type | Description |
|---|---|---|
element | IconElement | The icon element to add |
Returns
Promise<boolean>
Promise resolving to true if element was added successfully
Example
const success = await adder.visitIconElement(iconElement);
// success = true if element was added successfully
Implementation of
ElementVisitor.visitIconElement
Defined in
core/visitor/element-adder.ts:203
visitCircleElement
▸ visitCircleElement(element): Promise<boolean>
Adds a circle element to the track. Calculates appropriate start/end times based on existing track elements.
Parameters
| Name | Type | Description |
|---|---|---|
element | CircleElement | The circle element to add |
Returns
Promise<boolean>
Promise resolving to true if element was added successfully
Example
const success = await adder.visitCircleElement(circleElement);
// success = true if element was added successfully
Implementation of
ElementVisitor.visitCircleElement
Defined in
core/visitor/element-adder.ts:231
visitRectElement
▸ visitRectElement(element): Promise<boolean>
Adds a rectangle element to the track. Calculates appropriate start/end times based on existing track elements.
Parameters
| Name | Type | Description |
|---|---|---|
element | RectElement | The rectangle element to add |
Returns
Promise<boolean>
Promise resolving to true if element was added successfully
Example
const success = await adder.visitRectElement(rectElement);
// success = true if element was added successfully
Implementation of
ElementVisitor.visitRectElement
Defined in
core/visitor/element-adder.ts:259
visitPlaceholderElement
▸ visitPlaceholderElement(element): Promise<boolean>
Parameters
| Name | Type |
|---|---|
element | PlaceholderElement |
Returns
Promise<boolean>
Implementation of
ElementVisitor.visitPlaceholderElement
Defined in
core/visitor/element-adder.ts:274
visitLineElement
▸ visitLineElement(element): Promise<boolean>
Adds a line element to the track. Uses the same default duration semantics as other simple shapes.
Parameters
| Name | Type |
|---|---|
element | LineElement |
Returns
Promise<boolean>
Implementation of
ElementVisitor.visitLineElement
Defined in
core/visitor/element-adder.ts:293
visitArrowElement
▸ visitArrowElement(element): Promise<boolean>
Parameters
| Name | Type |
|---|---|
element | ArrowElement |
Returns
Promise<boolean>
Implementation of
ElementVisitor.visitArrowElement
Defined in
core/visitor/element-adder.ts:307
visitEffectElement
▸ visitEffectElement(element): Promise<boolean>
Adds an effect element to the track. For now, uses the same default duration semantics as other simple elements.
Parameters
| Name | Type |
|---|---|
element | EffectElement |
Returns
Promise<boolean>
Implementation of
ElementVisitor.visitEffectElement