import {BoxItem} from "./BoxItem"; import {properties, layout} from "./decorates"; import {TextItemLayout} from "./layout/TextItemLayout"; import {TextProperty} from "./properties/define"; import {JRTextElement} from "../jasper/JRTextElement"; import {HorizontalTextAlignEnum, VerticalTextAlignEnum, RotationEnum} from "../jasper/type/Enums"; import {Unit} from "../drawing/Unit"; @layout(new TextItemLayout()) @properties(TextProperty) export abstract class TextItem extends BoxItem implements JRTextElement { clone(){ const item = super.clone() as TextItem; item.value = this.value; item.setHorizontalTextAlign(this.getOwnHorizontalTextAlign()); item.setVerticalTextAlign(this.getOwnVerticalTextAlign()); item.setRotation(this.getOwnRotationValue()); item.style.copy(this.style); return item; } // --------- getter and setter get value():string { return this.getPropertyValue(TextProperty.text); } set value(value: string) { this.setPropertyValue(TextProperty.text, value); } //------- JRFont getOwnHorizontalTextAlign():HorizontalTextAlignEnum { return this.getPropertyValue(TextProperty.hAlign); } setHorizontalTextAlign(value:HorizontalTextAlignEnum):void { this.setPropertyValue(TextProperty.hAlign, value); } getOwnVerticalTextAlign():VerticalTextAlignEnum { return this.getPropertyValue(TextProperty.vAlign); } setVerticalTextAlign(value:VerticalTextAlignEnum):void { this.setPropertyValue(TextProperty.vAlign, value); } getOwnRotationValue():RotationEnum { return this.getPropertyValue(TextProperty.rotation); } setRotation(value:RotationEnum):void { this.setPropertyValue(TextProperty.rotation, value); } getOwnFontName():string { return this.style.font.fontFamily; } setFontName(value:string):void { this.style.font.fontFamily = value; } isOwnBold():boolean { return this.style.font.isBold; } setBold(value:boolean):void { this.style.font.isBold = value; } isOwnItalic():boolean { return this.style.font.isItalic; } setItalic(value:boolean):void { this.style.font.isItalic = value; } isOwnUnderline():boolean { return this.style.font.isUnderline; } setUnderline(value:boolean):void { this.style.font.isUnderline = value; } isOwnStrikeThrough():boolean { return this.style.font.isStrikeThrough; } setStrikeThrough(value:boolean):void { this.style.font.isStrikeThrough = value; } getOwnFontSize():number { return this.style.font.fontSize.pixels; } setFontSize(value:number):void { this.style.font.fontSize = Unit.pixel(value); } getOwnPdfFontName():string { return null; } getOwnPdfEncoding():string { return null; } isOwnPdfEmbedded():boolean { return null; } }