123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- import { SPainter, SArrowStyleType } from "@persagy-web/draw/";
- import { SBasePolylineEdit } from "@persagy-web/edit";
- import { SGraphItem, SLineStyle } from "@persagy-web/graph/lib";
- import { Marker } from "./../types/Marker";
- import { SMouseEvent } from "@persagy-web/base/lib";
- export class SBaseArrow extends SBasePolylineEdit {
-
-
-
- _begin = SArrowStyleType.None;
- get begin(): SArrowStyleType {
- return this._begin;
- }
- set begin(v: SArrowStyleType) {
- this._begin = v;
- this.update();
- }
-
- _end = SArrowStyleType.None;
- get end(): SArrowStyleType {
- return this._end;
- }
- set end(v: SArrowStyleType) {
- this._end = v;
- this.update();
- }
-
- constructor(parent: SGraphItem | null, data: Marker) {
- super(parent, data);
- this.data = data;
-
- if (data && data.style) {
- this.begin = data.style.begin ? data.style.begin : SArrowStyleType.None;
- this.end = data.style.end ? data.style.end : SArrowStyleType.None
- }
- }
-
- onMouseDown(event: SMouseEvent): boolean {
- super.onMouseDown(event)
- return true;
- }
-
- drawBaseLine(painter: SPainter): void {
-
- 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(this.lineWidth),
- painter.toPx(this.lineWidth)
- ];
- }
- painter.pen.color = this.strokeColor;
- painter.drawArrowLine(this.pointList[0], this.pointList[1], {
- begin: this.begin,
- end: SArrowStyleType.None
- });
- painter.drawArrowLine(
- this.pointList[this.pointList.length - 2],
- this.pointList[this.pointList.length - 1],
- {
- begin: SArrowStyleType.None,
- end: this.end
- }
- );
- painter.drawPolyline(this.pointList);
- }
-
- toData(): any {
- if (!this.data) return;
- this.data.style.begin = this.begin;
- this.data.style.end = this.end;
- return super.toData();
- }
- }
|