123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- import { SColor, SPainter, SPoint } from '@persagy-web/draw/lib';
- import { SGraphItem } from '@persagy-web/graph/lib';
- import { SLineStyle } from '../../edit/enums/SLineStyle';
- export class SBaseObjectRelation extends SGraphItem {
-
- startPoint: SPoint | null = null;
-
- endPoint: SPoint | null = null;
-
- private _strokeColor: SColor = SColor.Black;
- get strokeColor(): SColor {
- return this._strokeColor;
- }
- set strokeColor(v: SColor) {
- this._strokeColor = v;
- this.update();
- }
-
- private _lineStyle: SLineStyle = SLineStyle.Solid;
- get lineStyle(): SLineStyle {
- return this._lineStyle;
- }
- set lineStyle(v: SLineStyle) {
- this._lineStyle = v;
- this.update();
- }
-
- private _lineWidth: number = 1;
- get lineWidth(): number {
- return this._lineWidth;
- }
- set lineWidth(v: number) {
- this._lineWidth = v;
- this.update();
- }
-
- onDraw(painter: SPainter): void {
- if (this.startPoint && this.endPoint) {
- painter.pen.lineWidth = painter.toPx(this.lineWidth);
- painter.pen.color = this.strokeColor;
- if (this.lineStyle == SLineStyle.Dashed) {
- painter.pen.lineDash = [
- painter.toPx(this.lineWidth * 3),
- painter.toPx(this.lineWidth * 7)
- ];
- } else if (this.lineStyle == SLineStyle.Dotted) {
- painter.pen.lineDash = [
- painter.toPx(2 * this.lineWidth),
- painter.toPx(2 * this.lineWidth)
- ];
- }
- painter.drawLine(this.startPoint, this.endPoint);
- }
- }
- }
|