71
return a.startLineNumber - b.startLineNumber;
72
}
74
>
}
75
>
76
>
public setColorZone(colorZone: ColorZone): void {
77
>
this._colorZone = colorZone;
78
>
}
79
>
80
>
public getColorZones(): ColorZone | null {
81
return this._colorZone;
82
}
84
>
85
>
export class OverviewZoneManager {
86
>
87
>
private readonly _getVerticalOffsetForLine: (lineNumber: number) => number;
88
>
private _zones: OverviewRulerZone[];
89
>
private _colorZonesInvalid: boolean;
90
>
private _lineHeight: number;
91
>
private _domWidth: number;
92
>
private _domHeight: number;
93
>
private _outerHeight: number;
94
>
private _pixelRatio: number;
95
>
96
>
private _lastAssignedId: number;
97
>
private readonly _color2Id: { [color: string]: number };
98
>
private readonly _id2Color: string[];
99
>
100
>
constructor(getVerticalOffsetForLine: (lineNumber: number) => number) {
101
>
this._getVerticalOffsetForLine = getVerticalOffsetForLine;
102
>
this._zones = [];
103
>
this._colorZonesInvalid = false;
104
>
this._lineHeight = 0;
105
>
this._domWidth = 0;
106
>
this._domHeight = 0;
107
>
this._outerHeight = 0;
108
>
this._pixelRatio = 1;
109
>
110
>
this._lastAssignedId = 0;
111
>
this._color2Id = Object.create(null);
112
>
this._id2Color = [];
113
>
}
114
>
115
>
public getId2Color(): string[] {
116
return this._id2Color;
117
}
119
>
public setZones(newZones: OverviewRulerZone[]): void {
120
>
this._zones = newZones;
121
>
this._zones.sort(OverviewRulerZone.compare);
122
>
}
123
>
124
>
public setLineHeight(lineHeight: number): boolean {
125
>
if (this._lineHeight === lineHeight) {
126
return false;
127
}
129
>
this._colorZonesInvalid = true;
130
>
return true;
131
>
}
132
>
133
>
public setPixelRatio(pixelRatio: number): void {
134
>
this._pixelRatio = pixelRatio;
135
>
this._colorZonesInvalid = true;
136
>
}
137
>
138
>
public getDOMWidth(): number {
139
return this._domWidth;
140
}
142
>
public getCanvasWidth(): number {
143
return this._domWidth * this._pixelRatio;
144
}
146
>
public setDOMWidth(width: number): boolean {
147
>
if (this._domWidth === width) {
148
return false;
149
}
151
>
this._colorZonesInvalid = true;
152
>
return true;
153
>
}
154
>
155
>
public getDOMHeight(): number {
156
return this._domHeight;
157
}
159
>
public getCanvasHeight(): number {
160
>
return this._domHeight * this._pixelRatio;
161
>
}
162
>
163
>
public setDOMHeight(height: number): boolean {
164
>
if (this._domHeight === height) {
165
return false;
166
}
168
>
this._colorZonesInvalid = true;
169
>
return true;
170
>
}
171
>
172
>
public getOuterHeight(): number {
173
return this._outerHeight;
174
}
176
>
public setOuterHeight(outerHeight: number): boolean {
177
>
if (this._outerHeight === outerHeight) {
178
return false;
179
}
181
>
this._colorZonesInvalid = true;
182
>
return true;
183
>
}
184
>
185
>
public resolveColorZones(): ColorZone[] {
186
>
const colorZonesInvalid = this._colorZonesInvalid;
187
>
const lineHeight = Math.floor(this._lineHeight);
188
>
const totalHeight = Math.floor(this.getCanvasHeight());
189
>
const outerHeight = Math.floor(this._outerHeight);
190
>
const heightRatio = totalHeight / outerHeight;
191
>
const halfMinimumHeight = Math.floor(Constants.MINIMUM_HEIGHT * this._pixelRatio / 2);
192
>
193
>
const allColorZones: ColorZone[] = [];
194
>
for (let i = 0, len = this._zones.length; i < len; i++) {
195
>
const zone = this._zones[i];
196
>
197
>
if (!colorZonesInvalid) {
198
const colorZone = zone.getColorZones();
199
if (colorZone) {