src/lib/myScript/input/generic/components/characterInputComponent.ts
Char input component
constructor(obj: CharacterInputComponentParameters)
|
getAlternates |
getAlternates()
|
Get character input alternates
Returns:
CharacterInputComponentAlternate[]
|
setAlternates |
setAlternates(alternates: CharacterInputComponentAlternate[])
|
Set character input alternates
Parameters :
Returns:
void
|
addAlternate |
addAlternate(alternate: CharacterInputComponentAlternate)
|
Add a character input alternate
Parameters :
Returns:
void
|
getBoundingBox |
getBoundingBox()
|
Get input component bounding-box
Returns:
Rectangle
|
setBoundingBox |
setBoundingBox(boundingBox: Rectangle)
|
Set input component bounding-box
Parameters :
Returns:
void
|
alternates |
alternates: |
boundingBox |
boundingBox: |
import { AbstractComponent } from './abstractComponent';
import { CharacterInputComponentAlternate } from './characterInputComponentAlternate'
import { Rectangle } from '../../../common/generic/rectangle';
/**
* CharacterInputComponentParameters
*
* @export
* @interface CharacterInputComponentParameters
*/
export interface CharacterInputComponentParameters {
alternates?: Array<CharacterInputComponentAlternate>,
boundingBox?: Rectangle
}
/**
* Char input component
*
* @export
* @class CharacterInputComponent
* @extends {AbstractComponent}
*/
export class CharacterInputComponent extends AbstractComponent {
alternates: Array<CharacterInputComponentAlternate>;
boundingBox: Rectangle;
constructor(obj?: CharacterInputComponentParameters) {
super();
this.type = 'inputCharacter';
if (obj && obj.alternates) {
this.alternates = obj.alternates.map(
alternate => new CharacterInputComponentAlternate(alternate));
}
if (obj && obj.boundingBox) {
this.boundingBox = new Rectangle(obj.boundingBox);
}
}
/**
* Get character input alternates
*
* @method getAlternates
* @returns {CharacterInputComponentAlternate[]}
*/
getAlternates(): Array<CharacterInputComponentAlternate> {
return this.alternates;
};
/**
* Set character input alternates
*
* @method setAlternates
* @param {CharacterInputComponentAlternate[]} alternates
*/
setAlternates(alternates: Array<CharacterInputComponentAlternate>) {
this.alternates = alternates;
};
/**
* Add a character input alternate
*
* @method addAlternate
* @param {CharacterInputComponentAlternate} alternate
*/
addAlternate(alternate: CharacterInputComponentAlternate) {
this.alternates.push(alternate);
};
/**
* Get input component bounding-box
*
* @method getBoundingBox
* @returns {Rectangle}
*/
getBoundingBox(): Rectangle {
return this.boundingBox;
};
/**
* Set input component bounding-box
*
* @method setBoundingBox
* @param {Rectangle} boundingBox
*/
setBoundingBox(boundingBox: Rectangle) {
this.boundingBox = boundingBox;
};
}