-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSeparator.ts
53 lines (44 loc) · 1.78 KB
/
Separator.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
///<reference path="Point.ts"/>
/**
* Class that represents visual separator.
*
* @author Tomas Popela
* @author Lars Meyer
*/
class Separator {
public startPoint: number = 0;
public endPoint: number = 0;
public weight: number = 3;
public normalizedWeight: number = 0;
// names apply to horizontal separators
public leftUp: Point;
public rightDown: Point;
constructor(start: number, end: number);
constructor(start: number, end: number, weight: number);
constructor(leftUpX: number, leftUpY: number, rightDownX: number, rightDownY: number);
constructor(start?: number, end?: number, weight?: number, leftUpX?: number, leftUpY?: number, rightDownX?: number, rightDownY?: number) {
if (typeof start === 'undefined' || typeof end === 'undefined') {
if (!(typeof leftUpX === 'undefined' || typeof leftUpY === 'undefined' || typeof rightDownX === 'undefined' || typeof rightDownY === 'undefined')) {
this.leftUp = new Point(leftUpX, leftUpY);
this.rightDown = new Point(rightDownX, rightDownY);
this.startPoint = leftUpX;
this.endPoint = rightDownY;
}
} else {
this.startPoint = start;
this.endPoint = end;
}
if (!(typeof weight === 'undefined')) {
this.weight = weight;
}
}
public setLeftUp(leftUpX: number, leftUpY: number): void {
this.leftUp = new Point(leftUpX, leftUpY);
}
public setRightDown(rightDownX: number, rightDownY: number): void {
this.rightDown = new Point(rightDownX, rightDownY);
}
compareTo(otherSeparator: Separator): number {
return this.weight - otherSeparator.weight;
}
}