import {CommonProperty, TextProperty, RectangleProperty, GraphProperty} from "../items/properties/define"; import {HorizontalTextAlignEnum} from "../items/properties/enums"; import {VerticalTextAlignEnum, LineStyleEnum} from "../configs/enums"; import {Font} from "../items/properties/classes/Font"; import {Unit} from "./Unit"; import {Stroke} from "../items/properties/classes/Stroke"; import {ReportItemBase} from "../items/ReportItemBase"; export class Style { private _reportItem: ReportItemBase; // 是否透明 // private _opaque: boolean = true; constructor(reportItem?:ReportItemBase) { this._reportItem = reportItem; } copy(source:Style) { this.backgroundColor = source.backgroundColor; this.opaque = source.opaque; this.color = source.color; this.hAlign = source.hAlign; this.vAlign = source.vAlign; this.font = source.font.clone(); this.radius = source.radius; this.strokeColor = source.strokeColor; this.strokeStyle = source.strokeStyle; this.strokeWidth = source.strokeWidth; } get opaque(): boolean{ return this._reportItem.getPropertyValue(CommonProperty.opaque); // return this._opaque; } set opaque(opaque: boolean){ // this._opaque = opaque; this._reportItem.setPropertyValue(CommonProperty.opaque, opaque); } get color():string { return this._reportItem.getPropertyValue(CommonProperty.foreColor); } set color(value: string) { this._reportItem.setPropertyValue(CommonProperty.foreColor, value); } get backgroundColor():string { return this._reportItem.getPropertyValue(CommonProperty.backColor); } set backgroundColor(value: string) { this._reportItem.setPropertyValue(CommonProperty.backColor, value); } get hAlign():HorizontalTextAlignEnum { return this._reportItem.getPropertyValue(TextProperty.hAlign); } set hAlign(value:HorizontalTextAlignEnum) { this._reportItem.setPropertyValue(TextProperty.hAlign, value); } get vAlign():VerticalTextAlignEnum { return this._reportItem.getPropertyValue(TextProperty.vAlign); } set vAlign(value:VerticalTextAlignEnum) { this._reportItem.setPropertyValue(TextProperty.vAlign, value); } get font():Font { return this._reportItem.getPropertyValue(TextProperty.font); } //noinspection JSAnnotator set font(value:Font) { if (typeof(value) === 'string' || typeof(value) === 'number') { const font = new Font(); font.fontSize = Unit.pixel(parseInt(value as any)); this._reportItem.setPropertyValue(TextProperty.font, font); } else if (value instanceof Font) { this._reportItem.setPropertyValue(TextProperty.font, value); } } get radius():number { return (this._reportItem.getPropertyValue(RectangleProperty.radius) as Unit).value; } set radius(value:number) { const unit = (this._reportItem.getPropertyValue(RectangleProperty.radius) as Unit); this._reportItem.setPropertyValue(RectangleProperty.radius, new Unit(value, unit.type)); } get strokeStyle(): LineStyleEnum{ return (this._reportItem.getPropertyValue(GraphProperty.stroke) as Stroke).style; } set strokeStyle(value:LineStyleEnum) { (this._reportItem.getPropertyValue(GraphProperty.stroke) as Stroke).style = value; } get strokeWidth() :Unit{ return (this._reportItem.getPropertyValue(GraphProperty.stroke) as Stroke).width; } set strokeWidth(value:Unit) { (this._reportItem.getPropertyValue(GraphProperty.stroke) as Stroke).width = value.clone(); } get strokeColor(): string{ return (this._reportItem.getPropertyValue(GraphProperty.stroke) as Stroke).color; } set strokeColor(value:string) { (this._reportItem.getPropertyValue(GraphProperty.stroke) as Stroke).color = value; } }