timeline-chart 0.3.0-next.f3add09.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -7
- package/lib/bigint-utils.d.ts +1 -0
- package/lib/bigint-utils.js +6 -0
- package/lib/bigint-utils.js.map +1 -1
- package/lib/components/time-graph-annotation.d.ts +9 -2
- package/lib/components/time-graph-annotation.js +15 -2
- package/lib/components/time-graph-annotation.js.map +1 -1
- package/lib/components/time-graph-arrow.d.ts +0 -1
- package/lib/components/time-graph-arrow.js +1 -5
- package/lib/components/time-graph-arrow.js.map +1 -1
- package/lib/components/time-graph-axis-scale.d.ts +4 -1
- package/lib/components/time-graph-axis-scale.js +41 -12
- package/lib/components/time-graph-axis-scale.js.map +1 -1
- package/lib/components/time-graph-component.d.ts +8 -7
- package/lib/components/time-graph-component.js +11 -1
- package/lib/components/time-graph-component.js.map +1 -1
- package/lib/components/time-graph-row.d.ts +33 -3
- package/lib/components/time-graph-row.js +42 -5
- package/lib/components/time-graph-row.js.map +1 -1
- package/lib/components/time-graph-state.d.ts +14 -2
- package/lib/components/time-graph-state.js +77 -37
- package/lib/components/time-graph-state.js.map +1 -1
- package/lib/layer/time-graph-axis.d.ts +2 -0
- package/lib/layer/time-graph-axis.js +4 -1
- package/lib/layer/time-graph-axis.js.map +1 -1
- package/lib/layer/time-graph-chart-arrows.d.ts +6 -2
- package/lib/layer/time-graph-chart-arrows.js +31 -12
- package/lib/layer/time-graph-chart-arrows.js.map +1 -1
- package/lib/layer/time-graph-chart-cursors.d.ts +3 -4
- package/lib/layer/time-graph-chart-cursors.js +34 -60
- package/lib/layer/time-graph-chart-cursors.js.map +1 -1
- package/lib/layer/time-graph-chart-grid.d.ts +1 -1
- package/lib/layer/time-graph-chart-grid.js +4 -2
- package/lib/layer/time-graph-chart-grid.js.map +1 -1
- package/lib/layer/time-graph-chart-layer.d.ts +2 -2
- package/lib/layer/time-graph-chart-layer.js +2 -2
- package/lib/layer/time-graph-chart-layer.js.map +1 -1
- package/lib/layer/time-graph-chart-selection-range.d.ts +2 -3
- package/lib/layer/time-graph-chart-selection-range.js +13 -10
- package/lib/layer/time-graph-chart-selection-range.js.map +1 -1
- package/lib/layer/time-graph-chart.d.ts +67 -22
- package/lib/layer/time-graph-chart.js +434 -171
- package/lib/layer/time-graph-chart.js.map +1 -1
- package/lib/layer/time-graph-layer.d.ts +2 -1
- package/lib/layer/time-graph-layer.js +14 -4
- package/lib/layer/time-graph-layer.js.map +1 -1
- package/lib/layer/time-graph-markers-chart-cursors.d.ts +5 -0
- package/lib/layer/time-graph-markers-chart-cursors.js +78 -0
- package/lib/layer/time-graph-markers-chart-cursors.js.map +1 -0
- package/lib/layer/time-graph-navigator.d.ts +1 -1
- package/lib/layer/time-graph-navigator.js +48 -10
- package/lib/layer/time-graph-navigator.js.map +1 -1
- package/lib/layer/time-graph-range-events-layer.d.ts +3 -3
- package/lib/layer/time-graph-range-events-layer.js +9 -9
- package/lib/layer/time-graph-range-events-layer.js.map +1 -1
- package/lib/layer/time-graph-vertical-scrollbar.d.ts +5 -0
- package/lib/layer/time-graph-vertical-scrollbar.js +65 -14
- package/lib/layer/time-graph-vertical-scrollbar.js.map +1 -1
- package/lib/layer/time-graph-viewport-layer.d.ts +19 -0
- package/lib/layer/time-graph-viewport-layer.js +70 -0
- package/lib/layer/time-graph-viewport-layer.js.map +1 -0
- package/lib/time-graph-container.d.ts +5 -2
- package/lib/time-graph-container.js +19 -0
- package/lib/time-graph-container.js.map +1 -1
- package/lib/time-graph-font-controller.d.ts +16 -5
- package/lib/time-graph-font-controller.js +48 -16
- package/lib/time-graph-font-controller.js.map +1 -1
- package/lib/time-graph-render-controller.d.ts +12 -0
- package/lib/time-graph-render-controller.js +57 -0
- package/lib/time-graph-render-controller.js.map +1 -0
- package/lib/time-graph-row-controller.d.ts +9 -2
- package/lib/time-graph-row-controller.js +41 -2
- package/lib/time-graph-row-controller.js.map +1 -1
- package/lib/time-graph-state-controller.d.ts +33 -6
- package/lib/time-graph-state-controller.js +121 -10
- package/lib/time-graph-state-controller.js.map +1 -1
- package/lib/time-graph-unit-controller.d.ts +14 -4
- package/lib/time-graph-unit-controller.js +27 -4
- package/lib/time-graph-unit-controller.js.map +1 -1
- package/package.json +20 -5
- package/src/bigint-utils.ts +7 -0
- package/src/components/time-graph-annotation.ts +18 -3
- package/src/components/time-graph-arrow.ts +1 -6
- package/src/components/time-graph-axis-scale.ts +51 -13
- package/src/components/time-graph-component.ts +14 -3
- package/src/components/time-graph-row.ts +50 -6
- package/src/components/time-graph-state.ts +84 -36
- package/src/layer/time-graph-axis.ts +7 -2
- package/src/layer/time-graph-chart-arrows.ts +33 -12
- package/src/layer/time-graph-chart-cursors.ts +39 -60
- package/src/layer/time-graph-chart-grid.ts +4 -2
- package/src/layer/time-graph-chart-layer.ts +4 -4
- package/src/layer/time-graph-chart-selection-range.ts +14 -12
- package/src/layer/time-graph-chart.ts +446 -205
- package/src/layer/time-graph-layer.ts +13 -4
- package/src/layer/time-graph-markers-chart-cursors.ts +66 -0
- package/src/layer/time-graph-navigator.ts +51 -13
- package/src/layer/time-graph-range-events-layer.ts +10 -10
- package/src/layer/time-graph-vertical-scrollbar.ts +68 -14
- package/src/layer/time-graph-viewport-layer.ts +57 -0
- package/src/time-graph-container.ts +25 -3
- package/src/time-graph-font-controller.ts +57 -16
- package/src/time-graph-render-controller.ts +65 -0
- package/src/time-graph-row-controller.ts +50 -7
- package/src/time-graph-state-controller.ts +128 -14
- package/src/time-graph-unit-controller.ts +38 -8
- package/jest.config.json +0 -26
- package/lib/components/__tests__/time-graph-arrow.test.d.ts +0 -1
- package/lib/components/__tests__/time-graph-arrow.test.js +0 -26
- package/lib/components/__tests__/time-graph-arrow.test.js.map +0 -1
- package/lib/components/__tests__/time-graph-axis-cursor.test.d.ts +0 -1
- package/lib/components/__tests__/time-graph-axis-cursor.test.js +0 -17
- package/lib/components/__tests__/time-graph-axis-cursor.test.js.map +0 -1
- package/lib/components/__tests__/time-graph-axis-scale.test.d.ts +0 -1
- package/lib/components/__tests__/time-graph-axis-scale.test.js +0 -33
- package/lib/components/__tests__/time-graph-axis-scale.test.js.map +0 -1
- package/src/components/__tests__/__snapshots__/time-graph-arrow.test.ts.snap +0 -1067
- package/src/components/__tests__/__snapshots__/time-graph-axis-cursor.test.ts.snap +0 -535
- package/src/components/__tests__/time-graph-arrow.test.ts +0 -26
- package/src/components/__tests__/time-graph-axis-cursor.test.ts +0 -17
- package/src/components/__tests__/time-graph-axis-scale.test.ts +0 -34
- package/tsconfig.json +0 -28
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TimeGraphRowController = void 0;
|
|
4
|
+
var time_graph_render_controller_1 = require("./time-graph-render-controller");
|
|
4
5
|
var TimeGraphRowController = /** @class */ (function () {
|
|
5
6
|
function TimeGraphRowController(rowHeight, _totalHeight) {
|
|
6
7
|
this.rowHeight = rowHeight;
|
|
7
8
|
this._totalHeight = _totalHeight;
|
|
9
|
+
this._selectedRow = undefined;
|
|
10
|
+
this._selectedRowIndex = -1;
|
|
8
11
|
this.selectedRowChangedHandlers = [];
|
|
9
12
|
this.verticalOffsetChangedHandlers = [];
|
|
10
13
|
this.totalHeightChangedHandlers = [];
|
|
@@ -13,24 +16,49 @@ var TimeGraphRowController = /** @class */ (function () {
|
|
|
13
16
|
TimeGraphRowController.prototype.handleVerticalOffsetChanged = function () {
|
|
14
17
|
var _this = this;
|
|
15
18
|
this.verticalOffsetChangedHandlers.forEach(function (h) { return h(_this._verticalOffset); });
|
|
19
|
+
this.startRender();
|
|
16
20
|
};
|
|
17
21
|
TimeGraphRowController.prototype.handleSelectedRowChanged = function () {
|
|
18
|
-
var
|
|
19
|
-
|
|
22
|
+
var selectedRow = this._selectedRow;
|
|
23
|
+
if (selectedRow) {
|
|
24
|
+
this.selectedRowChangedHandlers.forEach(function (h) { return h(selectedRow); });
|
|
25
|
+
}
|
|
20
26
|
};
|
|
21
27
|
TimeGraphRowController.prototype.handleTotalHeightChanged = function () {
|
|
22
28
|
var _this = this;
|
|
23
29
|
this.totalHeightChangedHandlers.forEach(function (h) { return h(_this._totalHeight); });
|
|
30
|
+
this.startRender();
|
|
31
|
+
};
|
|
32
|
+
TimeGraphRowController.prototype.startRender = function () {
|
|
33
|
+
time_graph_render_controller_1.RenderEvents.startRender();
|
|
24
34
|
};
|
|
25
35
|
TimeGraphRowController.prototype.onSelectedRowChangedHandler = function (handler) {
|
|
26
36
|
this.selectedRowChangedHandlers.push(handler);
|
|
27
37
|
};
|
|
38
|
+
TimeGraphRowController.prototype.removeSelectedRowChangedHandler = function (handler) {
|
|
39
|
+
var index = this.selectedRowChangedHandlers.indexOf(handler);
|
|
40
|
+
if (index > -1) {
|
|
41
|
+
this.selectedRowChangedHandlers.splice(index, 1);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
28
44
|
TimeGraphRowController.prototype.onVerticalOffsetChangedHandler = function (handler) {
|
|
29
45
|
this.verticalOffsetChangedHandlers.push(handler);
|
|
30
46
|
};
|
|
47
|
+
TimeGraphRowController.prototype.removeVerticalOffsetChangedHandler = function (handler) {
|
|
48
|
+
var index = this.verticalOffsetChangedHandlers.indexOf(handler);
|
|
49
|
+
if (index > -1) {
|
|
50
|
+
this.verticalOffsetChangedHandlers.splice(index, 1);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
31
53
|
TimeGraphRowController.prototype.onTotalHeightChangedHandler = function (handler) {
|
|
32
54
|
this.totalHeightChangedHandlers.push(handler);
|
|
33
55
|
};
|
|
56
|
+
TimeGraphRowController.prototype.removeTotalHeightChangedHandler = function (handler) {
|
|
57
|
+
var index = this.totalHeightChangedHandlers.indexOf(handler);
|
|
58
|
+
if (index > -1) {
|
|
59
|
+
this.totalHeightChangedHandlers.splice(index, 1);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
34
62
|
Object.defineProperty(TimeGraphRowController.prototype, "totalHeight", {
|
|
35
63
|
get: function () {
|
|
36
64
|
return this._totalHeight;
|
|
@@ -64,6 +92,17 @@ var TimeGraphRowController = /** @class */ (function () {
|
|
|
64
92
|
enumerable: false,
|
|
65
93
|
configurable: true
|
|
66
94
|
});
|
|
95
|
+
Object.defineProperty(TimeGraphRowController.prototype, "selectedRowIndex", {
|
|
96
|
+
get: function () {
|
|
97
|
+
return this._selectedRowIndex;
|
|
98
|
+
},
|
|
99
|
+
set: function (index) {
|
|
100
|
+
this._selectedRowIndex = index;
|
|
101
|
+
this.handleSelectedRowChanged();
|
|
102
|
+
},
|
|
103
|
+
enumerable: false,
|
|
104
|
+
configurable: true
|
|
105
|
+
});
|
|
67
106
|
return TimeGraphRowController;
|
|
68
107
|
}());
|
|
69
108
|
exports.TimeGraphRowController = TimeGraphRowController;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-graph-row-controller.js","sourceRoot":"","sources":["../src/time-graph-row-controller.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"time-graph-row-controller.js","sourceRoot":"","sources":["../src/time-graph-row-controller.ts"],"names":[],"mappings":";;;AACA,+EAA8D;AAE9D;IAQI,gCAAmB,SAAiB,EAAU,YAAoB;QAA/C,cAAS,GAAT,SAAS,CAAQ;QAAU,iBAAY,GAAZ,YAAY,CAAQ;QAP1D,iBAAY,GAAgD,SAAS,CAAC;QACtE,sBAAiB,GAAW,CAAC,CAAC,CAAC;QAE7B,+BAA0B,GAAuD,EAAE,CAAC;QACpF,kCAA6B,GAAyC,EAAE,CAAC;QACzE,+BAA0B,GAAsC,EAAE,CAAC;QAGzE,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC;IAC7B,CAAC;IAES,4DAA2B,GAArC;QAAA,iBAGC;QAFG,IAAI,CAAC,6BAA6B,CAAC,OAAO,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,KAAI,CAAC,eAAe,CAAC,EAAvB,CAAuB,CAAC,C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wDAAsB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TimelineChart } from "./time-graph-model";
|
|
1
2
|
import { TimeGraphUnitController } from "./time-graph-unit-controller";
|
|
2
3
|
export declare class TimeGraphStateController {
|
|
3
4
|
protected canvas: HTMLCanvasElement;
|
|
@@ -8,24 +9,32 @@ export declare class TimeGraphStateController {
|
|
|
8
9
|
};
|
|
9
10
|
snapped: boolean;
|
|
10
11
|
protected ratio: number;
|
|
12
|
+
private _unscaledCanvasWidth;
|
|
11
13
|
protected _canvasDisplayWidth: number;
|
|
12
14
|
protected _canvasDisplayHeight: number;
|
|
15
|
+
private _scaleFactor;
|
|
13
16
|
protected _zoomFactor: number;
|
|
14
17
|
protected _initialZoomFactor: number;
|
|
15
18
|
protected _positionOffset: {
|
|
16
19
|
x: number;
|
|
17
20
|
y: number;
|
|
18
21
|
};
|
|
19
|
-
protected
|
|
22
|
+
protected _worldRange: TimelineChart.TimeGraphRange;
|
|
23
|
+
protected _worldZoomFactor: number;
|
|
24
|
+
private _worldRenderedHandlers;
|
|
25
|
+
protected zoomChangedHandlers: ((zoomFactor: number) => void)[];
|
|
26
|
+
protected canvasWidthChangedHandlers: ((baseWidth: number) => void)[];
|
|
20
27
|
protected positionChangedHandlers: (() => void)[];
|
|
21
|
-
protected
|
|
28
|
+
protected scaleFactorChangedHandlers: ((newScaleFactor: number) => void)[];
|
|
22
29
|
constructor(canvas: HTMLCanvasElement, unitController: TimeGraphUnitController);
|
|
23
|
-
protected handleZoomChange(): void;
|
|
30
|
+
protected handleZoomChange(zoomFactor: number): void;
|
|
24
31
|
protected handlePositionChange(): void;
|
|
25
|
-
protected
|
|
26
|
-
onZoomChanged(handler: () => void): void;
|
|
32
|
+
protected handleScaleFactorChange(): void;
|
|
33
|
+
onZoomChanged(handler: (zoomFactor: number) => void): void;
|
|
27
34
|
onPositionChanged(handler: () => void): void;
|
|
28
|
-
|
|
35
|
+
onScaleFactorChange(handler: (newWidth: number) => void): void;
|
|
36
|
+
removeOnZoomChanged(handler: (zoomFactor: number) => void): void;
|
|
37
|
+
removeOnScaleFactorChanged(handler: (zoomFactor: number) => void): void;
|
|
29
38
|
/**
|
|
30
39
|
It is not the width of the canvas display buffer but of the canvas element in browser. Can be different depending on the display pixel ratio.
|
|
31
40
|
*/
|
|
@@ -37,6 +46,11 @@ export declare class TimeGraphStateController {
|
|
|
37
46
|
get canvasDisplayHeight(): number;
|
|
38
47
|
updateDisplayHeight(): void;
|
|
39
48
|
get initialZoomFactor(): number;
|
|
49
|
+
updateZoomFactor: () => void;
|
|
50
|
+
updateScaleFactor: (oldViewRange: TimelineChart.TimeGraphRange, newViewRange: TimelineChart.TimeGraphRange) => void;
|
|
51
|
+
resetScale(): void;
|
|
52
|
+
get scaleFactor(): number;
|
|
53
|
+
set scaleFactor(newScaleFactor: number);
|
|
40
54
|
get zoomFactor(): number;
|
|
41
55
|
get absoluteResolution(): number;
|
|
42
56
|
get positionOffset(): {
|
|
@@ -47,4 +61,17 @@ export declare class TimeGraphStateController {
|
|
|
47
61
|
x: number;
|
|
48
62
|
y: number;
|
|
49
63
|
});
|
|
64
|
+
computeWorldRangeFromViewRange(): {
|
|
65
|
+
start: bigint;
|
|
66
|
+
end: bigint;
|
|
67
|
+
};
|
|
68
|
+
get worldRange(): TimelineChart.TimeGraphRange;
|
|
69
|
+
set worldRange(newRange: TimelineChart.TimeGraphRange);
|
|
70
|
+
get worldZoomFactor(): number;
|
|
71
|
+
set worldZoomFactor(worldZoomFactor: number);
|
|
72
|
+
get worldRangeLength(): bigint;
|
|
73
|
+
onWorldRender: (handler: (worldRange: TimelineChart.TimeGraphRange) => void) => void;
|
|
74
|
+
handleOnWorldRender: () => void;
|
|
75
|
+
removeWorldRenderHandler: (handler: (worldRange: TimelineChart.TimeGraphRange) => void) => void;
|
|
76
|
+
removeHandlers(): void;
|
|
50
77
|
}
|
|
@@ -1,29 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TimeGraphStateController = void 0;
|
|
4
|
+
var bigint_utils_1 = require("./bigint-utils");
|
|
4
5
|
var TimeGraphStateController = /** @class */ (function () {
|
|
5
6
|
function TimeGraphStateController(canvas, unitController) {
|
|
7
|
+
var _this = this;
|
|
6
8
|
this.canvas = canvas;
|
|
7
9
|
this.unitController = unitController;
|
|
10
|
+
this._worldRange = { start: BigInt(0), end: BigInt(0) };
|
|
11
|
+
this._worldZoomFactor = 1;
|
|
12
|
+
this._worldRenderedHandlers = [];
|
|
13
|
+
this.zoomChangedHandlers = [];
|
|
14
|
+
this.canvasWidthChangedHandlers = [];
|
|
15
|
+
this.positionChangedHandlers = [];
|
|
16
|
+
this.scaleFactorChangedHandlers = [];
|
|
17
|
+
this.updateZoomFactor = function () {
|
|
18
|
+
var newZoom = _this.canvasDisplayWidth / Number(_this.unitController.viewRangeLength);
|
|
19
|
+
if (_this._zoomFactor !== newZoom) {
|
|
20
|
+
_this.handleZoomChange(_this._zoomFactor = newZoom);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
// Adjust the scale factor if the view range changes
|
|
24
|
+
this.updateScaleFactor = function (oldViewRange, newViewRange) {
|
|
25
|
+
var oldViewRangeLength = oldViewRange.end - oldViewRange.start;
|
|
26
|
+
var newViewRangeLength = newViewRange.end - newViewRange.start;
|
|
27
|
+
var newScaleFactor = Number(oldViewRangeLength) / Number(newViewRangeLength) * _this._scaleFactor;
|
|
28
|
+
_this.scaleFactor = newScaleFactor;
|
|
29
|
+
};
|
|
30
|
+
this.onWorldRender = function (handler) {
|
|
31
|
+
_this._worldRenderedHandlers.push(handler);
|
|
32
|
+
};
|
|
33
|
+
this.handleOnWorldRender = function () {
|
|
34
|
+
_this._worldRenderedHandlers.forEach(function (handler) { return handler(_this.worldRange); });
|
|
35
|
+
};
|
|
36
|
+
this.removeWorldRenderHandler = function (handler) {
|
|
37
|
+
var index = _this._worldRenderedHandlers.indexOf(handler);
|
|
38
|
+
if (index > -1) {
|
|
39
|
+
_this._worldRenderedHandlers.splice(index, 1);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
8
42
|
this.ratio = window.devicePixelRatio;
|
|
9
43
|
this._canvasDisplayWidth = this.canvas.width / this.ratio;
|
|
10
44
|
this._canvasDisplayHeight = this.canvas.height / this.ratio;
|
|
11
45
|
this._initialZoomFactor = this.zoomFactor;
|
|
12
46
|
this._positionOffset = { x: 0, y: 0 };
|
|
13
47
|
this.oldPositionOffset = { x: 0, y: 0 };
|
|
14
|
-
this.zoomChangedHandlers = [];
|
|
15
|
-
this.positionChangedHandlers = [];
|
|
16
|
-
this.canvasDisplayWidthChangedHandlers = [];
|
|
17
48
|
this.snapped = false;
|
|
49
|
+
this._unscaledCanvasWidth = this._canvasDisplayWidth;
|
|
50
|
+
this._scaleFactor = 1;
|
|
51
|
+
this.worldRange = this.computeWorldRangeFromViewRange();
|
|
52
|
+
this.unitController.onViewRangeChanged(this.updateZoomFactor);
|
|
53
|
+
this.unitController.onViewRangeChanged(this.updateScaleFactor);
|
|
18
54
|
}
|
|
19
|
-
TimeGraphStateController.prototype.handleZoomChange = function () {
|
|
20
|
-
this.zoomChangedHandlers.forEach(function (handler) { return handler(); });
|
|
55
|
+
TimeGraphStateController.prototype.handleZoomChange = function (zoomFactor) {
|
|
56
|
+
this.zoomChangedHandlers.forEach(function (handler) { return handler(zoomFactor); });
|
|
21
57
|
};
|
|
22
58
|
TimeGraphStateController.prototype.handlePositionChange = function () {
|
|
23
59
|
this.positionChangedHandlers.forEach(function (handler) { return handler(); });
|
|
24
60
|
};
|
|
25
|
-
TimeGraphStateController.prototype.
|
|
26
|
-
|
|
61
|
+
TimeGraphStateController.prototype.handleScaleFactorChange = function () {
|
|
62
|
+
var _this = this;
|
|
63
|
+
this.scaleFactorChangedHandlers.forEach(function (handler) { return handler(_this._scaleFactor); });
|
|
27
64
|
};
|
|
28
65
|
TimeGraphStateController.prototype.onZoomChanged = function (handler) {
|
|
29
66
|
this.zoomChangedHandlers.push(handler);
|
|
@@ -31,8 +68,20 @@ var TimeGraphStateController = /** @class */ (function () {
|
|
|
31
68
|
TimeGraphStateController.prototype.onPositionChanged = function (handler) {
|
|
32
69
|
this.positionChangedHandlers.push(handler);
|
|
33
70
|
};
|
|
34
|
-
TimeGraphStateController.prototype.
|
|
35
|
-
this.
|
|
71
|
+
TimeGraphStateController.prototype.onScaleFactorChange = function (handler) {
|
|
72
|
+
this.scaleFactorChangedHandlers.push(handler);
|
|
73
|
+
};
|
|
74
|
+
TimeGraphStateController.prototype.removeOnZoomChanged = function (handler) {
|
|
75
|
+
var index = this.zoomChangedHandlers.indexOf(handler);
|
|
76
|
+
if (index > -1) {
|
|
77
|
+
this.zoomChangedHandlers.splice(index, 1);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
TimeGraphStateController.prototype.removeOnScaleFactorChanged = function (handler) {
|
|
81
|
+
var index = this.scaleFactorChangedHandlers.indexOf(handler);
|
|
82
|
+
if (index > -1) {
|
|
83
|
+
this.scaleFactorChangedHandlers.splice(index, 1);
|
|
84
|
+
}
|
|
36
85
|
};
|
|
37
86
|
Object.defineProperty(TimeGraphStateController.prototype, "canvasDisplayWidth", {
|
|
38
87
|
/**
|
|
@@ -46,6 +95,8 @@ var TimeGraphStateController = /** @class */ (function () {
|
|
|
46
95
|
});
|
|
47
96
|
TimeGraphStateController.prototype.updateDisplayWidth = function () {
|
|
48
97
|
this._canvasDisplayWidth = this.canvas.width / this.ratio;
|
|
98
|
+
// Adjust the scale factor if the display canvas width changes
|
|
99
|
+
this.scaleFactor = this._canvasDisplayWidth / this._unscaledCanvasWidth;
|
|
49
100
|
};
|
|
50
101
|
Object.defineProperty(TimeGraphStateController.prototype, "canvasDisplayHeight", {
|
|
51
102
|
/**
|
|
@@ -67,9 +118,24 @@ var TimeGraphStateController = /** @class */ (function () {
|
|
|
67
118
|
enumerable: false,
|
|
68
119
|
configurable: true
|
|
69
120
|
});
|
|
121
|
+
TimeGraphStateController.prototype.resetScale = function () {
|
|
122
|
+
this._unscaledCanvasWidth = this._canvasDisplayWidth;
|
|
123
|
+
this.scaleFactor = 1;
|
|
124
|
+
};
|
|
125
|
+
Object.defineProperty(TimeGraphStateController.prototype, "scaleFactor", {
|
|
126
|
+
get: function () {
|
|
127
|
+
return this._scaleFactor;
|
|
128
|
+
},
|
|
129
|
+
set: function (newScaleFactor) {
|
|
130
|
+
this._scaleFactor = newScaleFactor;
|
|
131
|
+
this.handleScaleFactorChange();
|
|
132
|
+
},
|
|
133
|
+
enumerable: false,
|
|
134
|
+
configurable: true
|
|
135
|
+
});
|
|
70
136
|
Object.defineProperty(TimeGraphStateController.prototype, "zoomFactor", {
|
|
71
137
|
get: function () {
|
|
72
|
-
this.
|
|
138
|
+
this.updateZoomFactor();
|
|
73
139
|
return this._zoomFactor;
|
|
74
140
|
},
|
|
75
141
|
enumerable: false,
|
|
@@ -93,6 +159,51 @@ var TimeGraphStateController = /** @class */ (function () {
|
|
|
93
159
|
enumerable: false,
|
|
94
160
|
configurable: true
|
|
95
161
|
});
|
|
162
|
+
TimeGraphStateController.prototype.computeWorldRangeFromViewRange = function () {
|
|
163
|
+
var deltaV = this.unitController.viewRange.end - this.unitController.viewRange.start;
|
|
164
|
+
var start = this.unitController.viewRange.start - bigint_utils_1.BIMath.multiply(deltaV, this.unitController.worldRenderFactor);
|
|
165
|
+
var end = this.unitController.viewRange.end + bigint_utils_1.BIMath.multiply(deltaV, this.unitController.worldRenderFactor);
|
|
166
|
+
return { start: start, end: end };
|
|
167
|
+
};
|
|
168
|
+
Object.defineProperty(TimeGraphStateController.prototype, "worldRange", {
|
|
169
|
+
get: function () {
|
|
170
|
+
return this._worldRange;
|
|
171
|
+
},
|
|
172
|
+
set: function (newRange) {
|
|
173
|
+
if (newRange.end > newRange.start) {
|
|
174
|
+
this._worldRange = { start: newRange.start, end: newRange.end };
|
|
175
|
+
}
|
|
176
|
+
if (newRange.start < 0) {
|
|
177
|
+
this._worldRange.start = BigInt(0);
|
|
178
|
+
}
|
|
179
|
+
if (this._worldRange.end > this.unitController.absoluteRange) {
|
|
180
|
+
this._worldRange.end = this.unitController.absoluteRange;
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
enumerable: false,
|
|
184
|
+
configurable: true
|
|
185
|
+
});
|
|
186
|
+
Object.defineProperty(TimeGraphStateController.prototype, "worldZoomFactor", {
|
|
187
|
+
get: function () {
|
|
188
|
+
return this._worldZoomFactor;
|
|
189
|
+
},
|
|
190
|
+
set: function (worldZoomFactor) {
|
|
191
|
+
this._worldZoomFactor = worldZoomFactor;
|
|
192
|
+
},
|
|
193
|
+
enumerable: false,
|
|
194
|
+
configurable: true
|
|
195
|
+
});
|
|
196
|
+
Object.defineProperty(TimeGraphStateController.prototype, "worldRangeLength", {
|
|
197
|
+
get: function () {
|
|
198
|
+
return this._worldRange.end - this._worldRange.start;
|
|
199
|
+
},
|
|
200
|
+
enumerable: false,
|
|
201
|
+
configurable: true
|
|
202
|
+
});
|
|
203
|
+
TimeGraphStateController.prototype.removeHandlers = function () {
|
|
204
|
+
this.unitController.removeViewRangeChangedHandler(this.updateZoomFactor);
|
|
205
|
+
this.unitController.removeViewRangeChangedHandler(this.updateScaleFactor);
|
|
206
|
+
};
|
|
96
207
|
return TimeGraphStateController;
|
|
97
208
|
}());
|
|
98
209
|
exports.TimeGraphStateController = TimeGraphStateController;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-graph-state-controller.js","sourceRoot":"","sources":["../src/time-graph-state-controller.ts"],"names":[],"mappings":";;;AAEA;
|
|
1
|
+
{"version":3,"file":"time-graph-state-controller.js","sourceRoot":"","sources":["../src/time-graph-state-controller.ts"],"names":[],"mappings":";;;AAEA,+CAAwC;AAExC;IAgCI,kCAAsB,MAAyB,EAAY,cAAuC;QAAlG,iBAcC;QAdqB,WAAM,GAAN,MAAM,CAAmB;QAAY,mBAAc,GAAd,cAAc,CAAyB;QATxF,gBAAW,GAAiC,EA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AAa,CAAC;aAC5D;QACL,CAAC;;;OAZA;IAcD,sBAAI,qDAAe;aAAnB;YACI,OAAO,IAAI,CAAC,gBAAgB,CAAA;QAChC,CAAC;aAED,UAAoB,eAAuB;YACvC,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;QAC5C,CAAC;;;OAJA;IAMD,sBAAI,sDAAgB;aAApB;YACI,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;QACzD,CAAC;;;OAAA;IAiBD,iDAAc,GAAd;QACI,IAAI,CAAC,cAAc,CAAC,6BAA6B,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACzE,IAAI,CAAC,cAAc,CAAC,6BAA6B,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC9E,CAAC;IACL,+BAAC;AAAD,CAAC,AA1ND,IA0NC;AA1NY,4DAAwB"}
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { TimelineChart } from "./time-graph-model";
|
|
2
|
+
import { TimeGraphRenderController } from "./time-graph-render-controller";
|
|
2
3
|
export declare class TimeGraphUnitController {
|
|
3
4
|
absoluteRange: bigint;
|
|
4
|
-
protected viewRangeChangedHandlers: ((newRange: TimelineChart.TimeGraphRange) => void)[];
|
|
5
|
+
protected viewRangeChangedHandlers: ((oldRange: TimelineChart.TimeGraphRange, newRange: TimelineChart.TimeGraphRange) => void)[];
|
|
5
6
|
protected _viewRange: TimelineChart.TimeGraphRange;
|
|
7
|
+
/**
|
|
8
|
+
* This determines the world size.
|
|
9
|
+
* worldRenderFactor = 1 renders one extra viewRange to the left and right,
|
|
10
|
+
* so there are three viewRanges rendered.
|
|
11
|
+
*/
|
|
12
|
+
private _worldRenderFactor;
|
|
6
13
|
protected selectionRangeChangedHandlers: ((newRange?: TimelineChart.TimeGraphRange) => void)[];
|
|
7
14
|
protected _selectionRange?: TimelineChart.TimeGraphRange;
|
|
8
15
|
protected _offset: bigint;
|
|
16
|
+
protected _renderer: TimeGraphRenderController;
|
|
9
17
|
/**
|
|
10
18
|
* Create a string from the given number, which is shown in TimeAxis.
|
|
11
19
|
* Or return undefined to not show any text for that number.
|
|
@@ -13,10 +21,10 @@ export declare class TimeGraphUnitController {
|
|
|
13
21
|
numberTranslator?: (theNumber: bigint) => string | undefined;
|
|
14
22
|
scaleSteps?: number[];
|
|
15
23
|
constructor(absoluteRange: bigint, viewRange?: TimelineChart.TimeGraphRange);
|
|
16
|
-
protected handleViewRangeChange(): void;
|
|
24
|
+
protected handleViewRangeChange(oldRange: TimelineChart.TimeGraphRange): void;
|
|
17
25
|
protected handleSelectionRangeChange(): void;
|
|
18
|
-
onViewRangeChanged(handler: (viewRange: TimelineChart.TimeGraphRange) => void): void;
|
|
19
|
-
removeViewRangeChangedHandler(handler: (viewRange: TimelineChart.TimeGraphRange) => void): void;
|
|
26
|
+
onViewRangeChanged(handler: (oldRange: TimelineChart.TimeGraphRange, viewRange: TimelineChart.TimeGraphRange) => void): void;
|
|
27
|
+
removeViewRangeChangedHandler(handler: (oldRange: TimelineChart.TimeGraphRange, viewRange: TimelineChart.TimeGraphRange) => void): void;
|
|
20
28
|
onSelectionRangeChange(handler: (selectionRange: TimelineChart.TimeGraphRange) => void): void;
|
|
21
29
|
removeSelectionRangeChangedHandler(handler: (selectionRange: TimelineChart.TimeGraphRange) => void): void;
|
|
22
30
|
get viewRange(): TimelineChart.TimeGraphRange;
|
|
@@ -26,4 +34,6 @@ export declare class TimeGraphUnitController {
|
|
|
26
34
|
get viewRangeLength(): bigint;
|
|
27
35
|
get offset(): bigint;
|
|
28
36
|
set offset(offset: bigint);
|
|
37
|
+
get worldRenderFactor(): number;
|
|
38
|
+
set worldRenderFactor(n: number);
|
|
29
39
|
}
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TimeGraphUnitController = void 0;
|
|
4
|
+
var time_graph_render_controller_1 = require("./time-graph-render-controller");
|
|
4
5
|
var TimeGraphUnitController = /** @class */ (function () {
|
|
5
6
|
function TimeGraphUnitController(absoluteRange, viewRange) {
|
|
6
7
|
this.absoluteRange = absoluteRange;
|
|
8
|
+
/**
|
|
9
|
+
* This determines the world size.
|
|
10
|
+
* worldRenderFactor = 1 renders one extra viewRange to the left and right,
|
|
11
|
+
* so there are three viewRanges rendered.
|
|
12
|
+
*/
|
|
13
|
+
this._worldRenderFactor = 1;
|
|
7
14
|
this._offset = BigInt(0);
|
|
8
|
-
this.viewRangeChangedHandlers = [];
|
|
9
15
|
this._viewRange = viewRange || { start: BigInt(0), end: absoluteRange };
|
|
16
|
+
this.viewRangeChangedHandlers = [];
|
|
10
17
|
this.selectionRangeChangedHandlers = [];
|
|
18
|
+
this._renderer = new time_graph_render_controller_1.TimeGraphRenderController();
|
|
11
19
|
}
|
|
12
|
-
TimeGraphUnitController.prototype.handleViewRangeChange = function () {
|
|
20
|
+
TimeGraphUnitController.prototype.handleViewRangeChange = function (oldRange) {
|
|
13
21
|
var _this = this;
|
|
14
|
-
this.viewRangeChangedHandlers.forEach(function (handler) { return handler(_this._viewRange); });
|
|
22
|
+
this.viewRangeChangedHandlers.forEach(function (handler) { return handler(oldRange, _this._viewRange); });
|
|
15
23
|
};
|
|
16
24
|
TimeGraphUnitController.prototype.handleSelectionRangeChange = function () {
|
|
17
25
|
var _this = this;
|
|
@@ -40,6 +48,11 @@ var TimeGraphUnitController = /** @class */ (function () {
|
|
|
40
48
|
return this._viewRange;
|
|
41
49
|
},
|
|
42
50
|
set: function (newRange) {
|
|
51
|
+
// Making a deep copy
|
|
52
|
+
var oldRange = {
|
|
53
|
+
start: this._viewRange.start,
|
|
54
|
+
end: this._viewRange.end
|
|
55
|
+
};
|
|
43
56
|
if (newRange.end > newRange.start) {
|
|
44
57
|
this._viewRange = { start: newRange.start, end: newRange.end };
|
|
45
58
|
}
|
|
@@ -49,7 +62,7 @@ var TimeGraphUnitController = /** @class */ (function () {
|
|
|
49
62
|
if (this._viewRange.end > this.absoluteRange) {
|
|
50
63
|
this._viewRange.end = this.absoluteRange;
|
|
51
64
|
}
|
|
52
|
-
this.handleViewRangeChange();
|
|
65
|
+
this.handleViewRangeChange(oldRange);
|
|
53
66
|
},
|
|
54
67
|
enumerable: false,
|
|
55
68
|
configurable: true
|
|
@@ -82,6 +95,16 @@ var TimeGraphUnitController = /** @class */ (function () {
|
|
|
82
95
|
enumerable: false,
|
|
83
96
|
configurable: true
|
|
84
97
|
});
|
|
98
|
+
Object.defineProperty(TimeGraphUnitController.prototype, "worldRenderFactor", {
|
|
99
|
+
get: function () {
|
|
100
|
+
return this._worldRenderFactor;
|
|
101
|
+
},
|
|
102
|
+
set: function (n) {
|
|
103
|
+
this._worldRenderFactor = n;
|
|
104
|
+
},
|
|
105
|
+
enumerable: false,
|
|
106
|
+
configurable: true
|
|
107
|
+
});
|
|
85
108
|
return TimeGraphUnitController;
|
|
86
109
|
}());
|
|
87
110
|
exports.TimeGraphUnitController = TimeGraphUnitController;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-graph-unit-controller.js","sourceRoot":"","sources":["../src/time-graph-unit-controller.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"time-graph-unit-controller.js","sourceRoot":"","sources":["../src/time-graph-unit-controller.ts"],"names":[],"mappings":";;;AACA,+EAA2E;AAE3E;IA0BI,iCAAmB,aAAqB,EAAE,SAAwC;QAA/D,kBAAa,GAAb,aAAa,CAAQ;QApBxC;;;;WAIG;QACK,uBAAkB,GAAG,CAAC,CAAC;QAKrB,YAAO,GAAW,MAAM,CAAC,CAAC,CAAC,CAAC;QAWlC,IAAI,CAAC,UAAU,GAAG,SAAS,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC;QAExE,IAAI,CAAC,wBAAwB,GAAG,EAAE,CAAC;QACnC,IAAI,CAAC,6B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sDAAiB;aAArB;YACI,OAAO,IAAI,CAAC,kBAAkB,CAAC;QACnC,CAAC;aAED,UAAsB,CAAS;YAC3B,IAAI,CAAC,kBAAkB,GAAG,CAAC,CAAC;QAChC,CAAC;;;OAJA;IAML,8BAAC;AAAD,CAAC,AArHD,IAqHC;AArHY,0DAAuB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "timeline-chart",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "A time graph / gantt chart library for large data (e.g. traces)",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"gantt",
|
|
7
|
+
"timeline",
|
|
8
|
+
"tracing",
|
|
9
|
+
"trace"
|
|
10
|
+
],
|
|
4
11
|
"license": "MIT",
|
|
5
12
|
"scripts": {
|
|
6
13
|
"build": "tsc",
|
|
@@ -14,8 +21,7 @@
|
|
|
14
21
|
"glob": "^7.1.6",
|
|
15
22
|
"keyboard-key": "1.1.0",
|
|
16
23
|
"lodash.throttle": "^4.1.1",
|
|
17
|
-
"pixi.js-legacy": "^5.3.3"
|
|
18
|
-
"rimraf": "latest"
|
|
24
|
+
"pixi.js-legacy": "^5.3.3"
|
|
19
25
|
},
|
|
20
26
|
"devDependencies": {
|
|
21
27
|
"@types/enzyme": "^3.10.10",
|
|
@@ -25,7 +31,16 @@
|
|
|
25
31
|
"enzyme-adapter-react-16": "^1.15.6",
|
|
26
32
|
"jest": "^27.4.3",
|
|
27
33
|
"jest-canvas-mock": "^2.3.1",
|
|
28
|
-
"
|
|
34
|
+
"rimraf": "latest",
|
|
35
|
+
"ts-jest": "^29.0.0"
|
|
29
36
|
},
|
|
30
|
-
"
|
|
37
|
+
"homepage": "https://github.com/eclipse-cdt-cloud/timeline-chart",
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "https://github.com/eclipse-cdt-cloud/timeline-chart"
|
|
41
|
+
},
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/eclipse-cdt-cloud/timeline-chart/issues"
|
|
44
|
+
},
|
|
45
|
+
"gitHead": "d5bb0d550eae71f4e6f95735b242e7a3fc511457"
|
|
31
46
|
}
|
package/src/bigint-utils.ts
CHANGED
|
@@ -30,4 +30,11 @@ export class BIMath {
|
|
|
30
30
|
val = BIMath.round(val);
|
|
31
31
|
return val >= 0 ? val : -val;
|
|
32
32
|
};
|
|
33
|
+
|
|
34
|
+
static readonly multiply = (a: bigint | number, b: bigint | number): bigint => {
|
|
35
|
+
a = Number(a);
|
|
36
|
+
b = Number(b);
|
|
37
|
+
let c = a * b;
|
|
38
|
+
return BIMath.round(c);
|
|
39
|
+
}
|
|
33
40
|
};
|
|
@@ -32,14 +32,16 @@ export class TimeGraphAnnotationComponent extends TimeGraphComponent<TimelineCha
|
|
|
32
32
|
protected _options: TimeGraphAnnotationComponentOptions,
|
|
33
33
|
protected _style: TimeGraphAnnotationStyle = { color: 0, size: 7, symbol: 'cross', verticalAlign: 'middle' },
|
|
34
34
|
protected _row: TimeGraphRow,
|
|
35
|
-
|
|
35
|
+
protected scaleFactor: number,
|
|
36
|
+
displayObject?: PIXI.Graphics
|
|
37
|
+
) {
|
|
36
38
|
super(id, displayObject, model);
|
|
37
39
|
this._size = _style.size || 7;
|
|
38
40
|
// called to ensure consistency. Only the X component is used from options.
|
|
39
41
|
this.update(_options);
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
update(opts
|
|
44
|
+
update(opts?: TimeGraphAnnotationComponentOptions): void {
|
|
43
45
|
if (opts) {
|
|
44
46
|
this._options.position.x = opts.position.x;
|
|
45
47
|
this.updateYPosition();
|
|
@@ -63,7 +65,7 @@ export class TimeGraphAnnotationComponent extends TimeGraphComponent<TimelineCha
|
|
|
63
65
|
render(): void {
|
|
64
66
|
const { symbol } = this._style as TimeGraphAnnotationStyle;
|
|
65
67
|
const size = this._size;
|
|
66
|
-
const x = this._options.position.x;
|
|
68
|
+
const x = this._options.position.x * this.scaleFactor;
|
|
67
69
|
const y = this._options.position.y;
|
|
68
70
|
|
|
69
71
|
if (symbol === undefined || symbol == 'none') {
|
|
@@ -84,6 +86,19 @@ export class TimeGraphAnnotationComponent extends TimeGraphComponent<TimelineCha
|
|
|
84
86
|
} else {
|
|
85
87
|
this.drawPlus(x, y, size);
|
|
86
88
|
}
|
|
89
|
+
this._displayObject.scale.x = 1 / this.scaleFactor;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Scale only annotations labels that actually have object displayed.
|
|
94
|
+
*
|
|
95
|
+
* @param scaleFactor
|
|
96
|
+
*/
|
|
97
|
+
scaleAnnotation(scaleFactor: number) {
|
|
98
|
+
this.scaleFactor = scaleFactor;
|
|
99
|
+
if (this._displayObject && this._displayObject.scale) {
|
|
100
|
+
this.render();
|
|
101
|
+
}
|
|
87
102
|
}
|
|
88
103
|
|
|
89
104
|
private drawCircle(x: number, y: number, radius: number): void {
|
|
@@ -18,11 +18,7 @@ export class TimeGraphArrowComponent extends TimeGraphComponent<TimelineChart.Ti
|
|
|
18
18
|
super(id, undefined, model);
|
|
19
19
|
|
|
20
20
|
this.head = new PIXI.Graphics();
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
destroy() {
|
|
24
|
-
this.head.destroy();
|
|
25
|
-
super.destroy();
|
|
21
|
+
this._displayObject.addChild(this.head);
|
|
26
22
|
}
|
|
27
23
|
|
|
28
24
|
render(): void {
|
|
@@ -61,6 +57,5 @@ export class TimeGraphArrowComponent extends TimeGraphComponent<TimelineChart.Ti
|
|
|
61
57
|
this.head.position.y = end.y;
|
|
62
58
|
this.head.pivot = new PIXI.Point(end.x, end.y);
|
|
63
59
|
this.head.rotation = Math.atan2(end.y - start.y, end.x - start.x);
|
|
64
|
-
this._displayObject.addChild(this.head);
|
|
65
60
|
}
|
|
66
61
|
}
|