-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ankush Tyagi <ankush.tyagi@ericsson.com>
- Loading branch information
1 parent
dab8c9e
commit bd7f984
Showing
10 changed files
with
201 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,24 @@ | ||
import { TimeGraphComponent, TimeGraphStyledRect } from "./time-graph-component"; | ||
|
||
export class TimeGraphRectangle extends TimeGraphComponent { | ||
constructor(protected opts: TimeGraphStyledRect){ | ||
protected _options: TimeGraphStyledRect; | ||
|
||
constructor(protected opts: TimeGraphStyledRect) { | ||
super('rect'); | ||
this._options = opts; | ||
} | ||
|
||
get rectOptions(): TimeGraphStyledRect { | ||
return this._options as TimeGraphStyledRect; | ||
update(opts?: TimeGraphStyledRect): void { | ||
|
||
if (opts) { | ||
this._options.width = opts.width; | ||
this._options.height = opts.height; | ||
this._options.position = opts.position; | ||
} | ||
super.update(); | ||
} | ||
|
||
render(): void { | ||
this.rect(this._options as TimeGraphStyledRect); | ||
this.rect(this._options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { TimeGraphRectangle } from "../components/time-graph-rectangle"; | ||
import { TimelineChart } from "../time-graph-model"; | ||
import { TimeGraphChartProviders } from "./time-graph-chart"; | ||
import { TimeGraphLayer } from "./time-graph-layer"; | ||
|
||
export class TimeGraphRangeEventsLayer extends TimeGraphLayer { | ||
protected rangeEvents: Map<TimelineChart.TimeGraphAnnotation, TimeGraphRectangle>; | ||
protected providers: TimeGraphChartProviders; | ||
|
||
private _viewRangeUpdateHandler: { (): void; (viewRange: TimelineChart.TimeGraphRange): void; (viewRange: TimelineChart.TimeGraphRange): void; }; | ||
private _updateHandler: { (): void; (selectionRange: TimelineChart.TimeGraphRange): void; (selectionRange: TimelineChart.TimeGraphRange): void; }; | ||
|
||
constructor(id: string, providers: TimeGraphChartProviders) { | ||
super(id); | ||
this.providers = providers; | ||
} | ||
|
||
protected afterAddToContainer() { | ||
this._updateHandler = (): void => this.update(); | ||
this.unitController.onViewRangeChanged(this._updateHandler); | ||
} | ||
|
||
protected addRangeEvent(rangeEvent: TimelineChart.TimeGraphAnnotation) { | ||
const start = this.getPixels(rangeEvent.range.start - this.unitController.viewRange.start); | ||
const end = this.getPixels(rangeEvent.range.end - this.unitController.viewRange.start); | ||
const width = end - start; | ||
const elementStyle = this.providers.rowAnnotationStyleProvider ? this.providers.rowAnnotationStyleProvider(rangeEvent) : undefined; | ||
const rangeEventComponent = new TimeGraphRectangle({ | ||
color: (elementStyle && elementStyle.color) || 0xFF0000, | ||
opacity: (elementStyle && elementStyle.opacity) || 0.2, | ||
position: { | ||
x: start, | ||
y: 0 | ||
}, | ||
height: this.stateController.canvasDisplayHeight, | ||
width | ||
}); | ||
this.rangeEvents.set(rangeEvent, rangeEventComponent); | ||
this.addChild(rangeEventComponent); | ||
} | ||
|
||
addRangeEvents(rangeEvents: TimelineChart.TimeGraphAnnotation[]): void { | ||
if (!this.stateController) { | ||
throw ('Add the TimeGraphRangeEventsLayer to a container before adding range events.'); | ||
} | ||
if (this.rangeEvents) { | ||
this.removeChildren(); | ||
} | ||
this.rangeEvents = new Map(); | ||
rangeEvents.forEach(range => { | ||
this.addRangeEvent(range); | ||
}) | ||
} | ||
|
||
update(): void { | ||
if (this.rangeEvents) { | ||
for (const range of this.rangeEvents.keys()) { | ||
this.updateRangeEvent(range); | ||
} | ||
} | ||
} | ||
|
||
protected updateRangeEvent(rangeEvent: TimelineChart.TimeGraphAnnotation) { | ||
const rangeEventComponent = this.rangeEvents.get(rangeEvent); | ||
const start = this.getPixels(rangeEvent.range.start - this.unitController.viewRange.start); | ||
const end = this.getPixels(rangeEvent.range.end - this.unitController.viewRange.start); | ||
const width = end - start; | ||
if (rangeEventComponent) { | ||
rangeEventComponent.update({ | ||
position: { | ||
x: start, | ||
y: 0 | ||
}, | ||
height: this.stateController.canvasDisplayHeight, | ||
width | ||
}); | ||
} | ||
} | ||
|
||
destroy(): void { | ||
if (this.unitController) { | ||
this.unitController.removeViewRangeChangedHandler(this._viewRangeUpdateHandler); | ||
this.unitController.removeSelectionRangeChangedHandler(this._updateHandler); | ||
} | ||
super.destroy(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters