Browse Source

Applying replacements (1)

Andrea Condoluci 9 years ago
parent
commit
8db785101e

+ 19 - 0
src/Common/DataObjects/PointF2D.ts

@@ -0,0 +1,19 @@
+export class PointF2D {
+    public x: number;
+    public y: number;
+
+    constructor(x: number = 0, y: number = 0) {
+        this.x = x;
+        this.y = y;
+    }
+
+    public static get Empty(): PointF2D {
+        return new PointF2D();
+    }
+    public static pointsAreEqual(p1: PointF2D, p2: PointF2D): boolean {
+        return (p1.x === p2.x && p1.y === p2.y);
+    }
+    public ToString(): string {
+        return "[" + this.x + ", " + this.y + "]";
+    }
+}

+ 0 - 17
src/Common/DataObjects/PointF_2D.ts

@@ -1,17 +0,0 @@
-export class PointF_2D {
-    public X: number;
-    public Y: number;
-    constructor(x: number = 0, y: number = 0) {
-        this.X = x;
-        this.Y = y;
-    }
-    public static get Empty(): PointF_2D {
-        return new PointF_2D();
-    }
-    public static pointsAreEqual(p1: PointF_2D, p2: PointF_2D): boolean {
-        return (p1.X == p2.X && p1.Y == p2.Y);
-    }
-    public ToString(): string {
-        return "[" + this.X + ", " + this.Y + "]";
-    }
-}

+ 26 - 0
src/Common/DataObjects/RectangleF2D.ts

@@ -0,0 +1,26 @@
+import {SizeF2D} from "./SizeF2D";
+import {PointF2D} from "./PointF2D";
+
+export class RectangleF2D {
+    public x: number;
+    public y: number;
+    public width: number;
+    public height: number;
+
+    constructor(x: number, y: number, width: number, height: number) {
+        this.x = x;
+        this.y = y;
+        this.width = width;
+        this.height = height;
+    }
+
+    public static createFromLocationAndSize(location: PointF2D, size: SizeF2D): RectangleF2D {
+        return new RectangleF2D(location.x, location.y, size.width, size.height);
+    }
+    public get Location(): PointF2D {
+        return new PointF2D(this.x, this.y);
+    }
+    public get Size(): SizeF2D {
+        return new SizeF2D(this.width, this.height);
+    }
+}

+ 0 - 23
src/Common/DataObjects/RectangleF_2D.ts

@@ -1,23 +0,0 @@
-import {SizeF_2D} from "./SizeF_2D";
-import {PointF_2D} from "./PointF_2D";
-export class RectangleF_2D {
-    public X: number;
-    public Y: number;
-    public Width: number;
-    public Height: number;
-    constructor(x: number, y: number, width: number, height: number) {
-        this.X = x;
-        this.Y = y;
-        this.Width = width;
-        this.Height = height;
-    }
-    public static createFromLocationAndSize(location: PointF_2D, size: SizeF_2D): RectangleF_2D {
-        return new RectangleF_2D(location.X, location.Y, size.Width, size.Height);
-    }
-    public get Location(): PointF_2D {
-        return new PointF_2D(this.X, this.Y);
-    }
-    public get Size(): SizeF_2D {
-        return new SizeF_2D(this.Width, this.Height);
-    }
-}

+ 9 - 0
src/Common/DataObjects/SizeF2D.ts

@@ -0,0 +1,9 @@
+export class SizeF2D {
+    public width: number;
+    public height: number;
+
+    constructor(width: number = 0, height: number = 0) {
+        this.width = width;
+        this.height = height;
+    }
+}

+ 0 - 8
src/Common/DataObjects/SizeF_2D.ts

@@ -1,8 +0,0 @@
-export class SizeF_2D {
-    public Width: number;
-    public Height: number;
-    constructor(width: number = 0, height: number = 0) {
-        this.Width = width;
-        this.Height = height;
-    }
-}

+ 14 - 14
src/Common/DataObjects/fraction.ts

@@ -25,13 +25,13 @@ export class Fraction {
     }
     }
 
 
     public static plus (f1: Fraction, f2: Fraction): Fraction {
     public static plus (f1: Fraction, f2: Fraction): Fraction {
-        let sum: Fraction = Fraction.CreateFractionFromFraction(f1);
+        let sum: Fraction = f1.clone();
         sum.Add(f2);
         sum.Add(f2);
         return sum;
         return sum;
     }
     }
 
 
     public static minus(f1: Fraction , f2: Fraction): Fraction {
     public static minus(f1: Fraction , f2: Fraction): Fraction {
-        let sum: Fraction = Fraction.CreateFractionFromFraction(f1);
+        let sum: Fraction = f1.clone();
         sum.Sub(f2);
         sum.Sub(f2);
         return sum;
         return sum;
     }
     }
@@ -172,7 +172,7 @@ export class Fraction {
     //public Equals(f: Fraction): boolean {
     //public Equals(f: Fraction): boolean {
     //    if (ReferenceEquals(this, f))
     //    if (ReferenceEquals(this, f))
     //        return true;
     //        return true;
-    //    if (ReferenceEquals(f, null))
+    //    if (ReferenceEquals(f, undefined))
     //        return false;
     //        return false;
     //    return <number>this.numerator * f.denominator === <number>f.numerator * this.denominator;
     //    return <number>this.numerator * f.denominator === <number>f.numerator * this.denominator;
     //}
     //}
@@ -301,16 +301,16 @@ export class Fraction {
     //}
     //}
     //
     //
     //// operator overload ==
     //// operator overload ==
-    //public static bool operator == (Fraction f1, Fraction f2)
+    //public static bool operator === (Fraction f1, Fraction f2)
     //{
     //{
     //    // code enhanced for performance
     //    // code enhanced for performance
-    //    // System.Object.ReferenceEquals(f1, null) is better than if (f1 == null)
+    //    // System.Object.ReferenceEquals(f1, undefined) is better than if (f1 === undefined)
     //    // and comparisons between booleans are quick
     //    // and comparisons between booleans are quick
-    //    bool f1IsNull = System.Object.ReferenceEquals(f1, null);
-    //    bool f2IsNull = System.Object.ReferenceEquals(f2, null);
+    //    bool f1IsNull = System.Object.ReferenceEquals(f1, undefined);
+    //    bool f2IsNull = System.Object.ReferenceEquals(f2, undefined);
     //
     //
-    //    // method returns true when both are null, false when only the first is null, otherwise the result of equals
-    //    if (f1IsNull != f2IsNull)
+    //    // method returns true when both are undefined, false when only the first is undefined, otherwise the result of equals
+    //    if (f1IsNull !== f2IsNull)
     //        return false;
     //        return false;
     //
     //
     //    if (f1IsNull /*&& f2IsNull*/)
     //    if (f1IsNull /*&& f2IsNull*/)
@@ -320,9 +320,9 @@ export class Fraction {
     //}
     //}
     //
     //
     //// operator overload !=
     //// operator overload !=
-    //public static bool operator != (Fraction f1, Fraction f2)
+    //public static bool operator !== (Fraction f1, Fraction f2)
     //{
     //{
-    //    return (!(f1 == f2));
+    //    return (!(f1 === f2));
     //}
     //}
     //
     //
     //// operator overload >=
     //// operator overload >=
@@ -344,8 +344,8 @@ export class Fraction {
     //
     //
     //public static Fraction operator / (Fraction f1, Fraction f2)
     //public static Fraction operator / (Fraction f1, Fraction f2)
     //{
     //{
-    //    var res = new Fraction(f1.Numerator*f2.Denominator, f1.Denominator*f2.Numerator);
-    //    return res.Denominator == 0 ? new Fraction(0, 1) : res;
+    //    let res = new Fraction(f1.Numerator*f2.Denominator, f1.Denominator*f2.Numerator);
+    //    return res.Denominator === 0 ? new Fraction(0, 1) : res;
     //}
     //}
     //
     //
     //public static Fraction operator * (Fraction f1, Fraction f2)
     //public static Fraction operator * (Fraction f1, Fraction f2)
@@ -355,7 +355,7 @@ export class Fraction {
     //
     //
     //public static Fraction operator % (Fraction f1, Fraction f2)
     //public static Fraction operator % (Fraction f1, Fraction f2)
     //{
     //{
-    //    var a = f1/f2;
+    //    let a = f1/f2;
     //    return new Fraction(a.Numerator%a.Denominator, a.Denominator)*f2;
     //    return new Fraction(a.Numerator%a.Denominator, a.Denominator)*f2;
     //}
     //}
     //
     //

+ 2 - 1
src/MusicalScore/Graphical/AbstractGraphicalInstruction.ts

@@ -1,5 +1,6 @@
 import {GraphicalStaffEntry} from "./GraphicalStaffEntry";
 import {GraphicalStaffEntry} from "./GraphicalStaffEntry";
 import {GraphicalObject} from "./GraphicalObject";
 import {GraphicalObject} from "./GraphicalObject";
+
 export class AbstractGraphicalInstruction extends GraphicalObject {
 export class AbstractGraphicalInstruction extends GraphicalObject {
     protected parent: GraphicalStaffEntry;
     protected parent: GraphicalStaffEntry;
     constructor(parent: GraphicalStaffEntry) {
     constructor(parent: GraphicalStaffEntry) {
@@ -11,4 +12,4 @@ export class AbstractGraphicalInstruction extends GraphicalObject {
     public set Parent(value: GraphicalStaffEntry) {
     public set Parent(value: GraphicalStaffEntry) {
         this.parent = value;
         this.parent = value;
     }
     }
-}
+}

+ 535 - 474
src/MusicalScore/Graphical/BoundingBox.ts

@@ -1,513 +1,574 @@
 import {ArgumentOutOfRangeException} from "../Exceptions";
 import {ArgumentOutOfRangeException} from "../Exceptions";
-import {PointF_2D} from "../../Common/DataObjects/PointF_2D";
-import {SizeF_2D} from "../../Common/DataObjects/SizeF_2D";
-import {RectangleF_2D} from "../../Common/DataObjects/RectangleF_2D";
+import {PointF2D} from "../../Common/DataObjects/PointF2D";
+import {SizeF2D} from "../../Common/DataObjects/SizeF2D";
+import {RectangleF2D} from "../../Common/DataObjects/RectangleF2D";
+
 export class BoundingBox {
 export class BoundingBox {
-        protected isSymbol: boolean = false;
-        protected relativePositionHasBeenSet: boolean;
-        protected xBordersHaveBeenSet: boolean;
-        protected yBordersHaveBeenSet: boolean;
-        protected absolutePosition: PointF_2D = new PointF_2D();
-        protected relativePosition: PointF_2D = new PointF_2D();
-        protected size: SizeF_2D = new SizeF_2D();
-        protected marginSize: SizeF_2D;
-        protected upperLeftCorner: PointF_2D;
-        protected upperLeftMarginCorner: PointF_2D;
-        protected borderLeft: number;
-        protected borderRight: number;
-        protected borderTop: number;
-        protected borderBottom: number;
-        protected borderMarginLeft: number;
-        protected borderMarginRight: number;
-        protected borderMarginTop: number;
-        protected borderMarginBottom: number;
-        protected boundingRectangle: RectangleF_2D;
-        protected boundingMarginRectangle: RectangleF_2D;
-        protected childElements: List<BoundingBox> = new List<BoundingBox>();
-        protected parent: BoundingBox;
-        protected dataObject: Object;
-        constructor(dataObject: Object) {
-            this.dataObject = dataObject;
-            this.xBordersHaveBeenSet = false;
-            this.yBordersHaveBeenSet = false;
-        }
-        constructor(parent: BoundingBox, dataObject: Object) {
-            this(dataObject);
-            this.parent = parent;
-        }
-        public get RelativePositionHasBeenSet(): boolean {
-            return this.relativePositionHasBeenSet;
-        }
-        public get XBordersHaveBeenSet(): boolean {
-            return this.xBordersHaveBeenSet;
-        }
-        public set XBordersHaveBeenSet(value: boolean) {
-            this.xBordersHaveBeenSet = value;
-        }
-        public get YBordersHaveBeenSet(): boolean {
-            return this.yBordersHaveBeenSet;
-        }
-        public set YBordersHaveBeenSet(value: boolean) {
-            this.yBordersHaveBeenSet = value;
-        }
-        public get AbsolutePosition(): PointF_2D {
-            return this.absolutePosition;
-        }
-        public set AbsolutePosition(value: PointF_2D) {
-            this.absolutePosition = value;
-        }
-        public get RelativePosition(): PointF_2D {
-            return this.relativePosition;
-        }
-        public set RelativePosition(value: PointF_2D) {
-            this.relativePosition = value;
-            this.relativePositionHasBeenSet = true;
-        }
-        public get Size(): SizeF_2D {
-            return this.size;
-        }
-        public set Size(value: SizeF_2D) {
-            this.size = value;
-        }
-        public get MarginSize(): SizeF_2D {
-            return this.marginSize;
-        }
-        public get UpperLeftCorner(): PointF_2D {
-            return this.upperLeftCorner;
-        }
-        public get UpperLeftMarginCorner(): PointF_2D {
-            return this.upperLeftMarginCorner;
-        }
-        public get BorderLeft(): number {
-            return this.borderLeft;
-        }
-        public set BorderLeft(value: number) {
-            this.borderLeft = value;
-            this.calculateRectangle();
-        }
-        public get BorderRight(): number {
-            return this.borderRight;
-        }
-        public set BorderRight(value: number) {
-            this.borderRight = value;
-            this.calculateRectangle();
-        }
-        public get BorderTop(): number {
-            return this.borderTop;
-        }
-        public set BorderTop(value: number) {
-            this.borderTop = value;
-            this.calculateRectangle();
-        }
-        public get BorderBottom(): number {
-            return this.borderBottom;
-        }
-        public set BorderBottom(value: number) {
-            this.borderBottom = value;
-            this.calculateRectangle();
-        }
-        public get BorderMarginLeft(): number {
-            return this.borderMarginLeft;
-        }
-        public set BorderMarginLeft(value: number) {
-            this.borderMarginLeft = value;
-            this.calculateMarginRectangle();
-        }
-        public get BorderMarginRight(): number {
-            return this.borderMarginRight;
-        }
-        public set BorderMarginRight(value: number) {
-            this.borderMarginRight = value;
-            this.calculateMarginRectangle();
-        }
-        public get BorderMarginTop(): number {
-            return this.borderMarginTop;
-        }
-        public set BorderMarginTop(value: number) {
-            this.borderMarginTop = value;
-            this.calculateMarginRectangle();
-        }
-        public get BorderMarginBottom(): number {
-            return this.borderMarginBottom;
-        }
-        public set BorderMarginBottom(value: number) {
-            this.borderMarginBottom = value;
-            this.calculateMarginRectangle();
-        }
-        public get BoundingRectangle(): RectangleF_2D {
-            return this.boundingRectangle;
-        }
-        public get BoundingMarginRectangle(): RectangleF_2D {
-            return this.boundingMarginRectangle;
-        }
-        public get ChildElements(): List<BoundingBox> {
-            return this.childElements;
-        }
-        public set ChildElements(value: List<BoundingBox>) {
-            this.childElements = value;
-        }
-        public get Parent(): BoundingBox {
-            return this.parent;
-        }
-        public set Parent(value: BoundingBox) {
-            this.parent = value;
+    protected isSymbol: boolean = false;
+    protected relativePositionHasBeenSet: boolean;
+    protected xBordersHaveBeenSet: boolean;
+    protected yBordersHaveBeenSet: boolean;
+    protected absolutePosition: PointF2D = new PointF2D();
+    protected relativePosition: PointF2D = new PointF2D();
+    protected size: SizeF2D = new SizeF2D();
+    protected marginSize: SizeF2D;
+    protected upperLeftCorner: PointF2D;
+    protected upperLeftMarginCorner: PointF2D;
+    protected borderLeft: number;
+    protected borderRight: number;
+    protected borderTop: number;
+    protected borderBottom: number;
+    protected borderMarginLeft: number;
+    protected borderMarginRight: number;
+    protected borderMarginTop: number;
+    protected borderMarginBottom: number;
+    protected boundingRectangle: RectangleF2D;
+    protected boundingMarginRectangle: RectangleF2D;
+    protected childElements: BoundingBox[] = [];
+    protected parent: BoundingBox;
+    protected dataObject: Object;
+
+    constructor(dataObject: Object) {
+        this.dataObject = dataObject;
+        this.xBordersHaveBeenSet = false;
+        this.yBordersHaveBeenSet = false;
+    }
+
+    constructor(parent: BoundingBox, dataObject: Object) {
+        this(dataObject);
+        this.parent = parent;
+    }
+
+    public get RelativePositionHasBeenSet(): boolean {
+        return this.relativePositionHasBeenSet;
+    }
+
+    public get XBordersHaveBeenSet(): boolean {
+        return this.xBordersHaveBeenSet;
+    }
+
+    public set XBordersHaveBeenSet(value: boolean) {
+        this.xBordersHaveBeenSet = value;
+    }
+
+    public get YBordersHaveBeenSet(): boolean {
+        return this.yBordersHaveBeenSet;
+    }
+
+    public set YBordersHaveBeenSet(value: boolean) {
+        this.yBordersHaveBeenSet = value;
+    }
+
+    public get AbsolutePosition(): PointF2D {
+        return this.absolutePosition;
+    }
+
+    public set AbsolutePosition(value: PointF2D) {
+        this.absolutePosition = value;
+    }
+
+    public get RelativePosition(): PointF2D {
+        return this.relativePosition;
+    }
+
+    public set RelativePosition(value: PointF2D) {
+        this.relativePosition = value;
+        this.relativePositionHasBeenSet = true;
+    }
+
+    public get Size(): SizeF2D {
+        return this.size;
+    }
+
+    public set Size(value: SizeF2D) {
+        this.size = value;
+    }
+
+    public get MarginSize(): SizeF2D {
+        return this.marginSize;
+    }
+
+    public get UpperLeftCorner(): PointF2D {
+        return this.upperLeftCorner;
+    }
+
+    public get UpperLeftMarginCorner(): PointF2D {
+        return this.upperLeftMarginCorner;
+    }
+
+    public get BorderLeft(): number {
+        return this.borderLeft;
+    }
+
+    public set BorderLeft(value: number) {
+        this.borderLeft = value;
+        this.calculateRectangle();
+    }
+
+    public get BorderRight(): number {
+        return this.borderRight;
+    }
+
+    public set BorderRight(value: number) {
+        this.borderRight = value;
+        this.calculateRectangle();
+    }
+
+    public get BorderTop(): number {
+        return this.borderTop;
+    }
+
+    public set BorderTop(value: number) {
+        this.borderTop = value;
+        this.calculateRectangle();
+    }
+
+    public get BorderBottom(): number {
+        return this.borderBottom;
+    }
+
+    public set BorderBottom(value: number) {
+        this.borderBottom = value;
+        this.calculateRectangle();
+    }
+
+    public get BorderMarginLeft(): number {
+        return this.borderMarginLeft;
+    }
+
+    public set BorderMarginLeft(value: number) {
+        this.borderMarginLeft = value;
+        this.calculateMarginRectangle();
+    }
+
+    public get BorderMarginRight(): number {
+        return this.borderMarginRight;
+    }
+
+    public set BorderMarginRight(value: number) {
+        this.borderMarginRight = value;
+        this.calculateMarginRectangle();
+    }
+
+    public get BorderMarginTop(): number {
+        return this.borderMarginTop;
+    }
+
+    public set BorderMarginTop(value: number) {
+        this.borderMarginTop = value;
+        this.calculateMarginRectangle();
+    }
+
+    public get BorderMarginBottom(): number {
+        return this.borderMarginBottom;
+    }
+
+    public set BorderMarginBottom(value: number) {
+        this.borderMarginBottom = value;
+        this.calculateMarginRectangle();
+    }
+
+    public get BoundingRectangle(): RectangleF2D {
+        return this.boundingRectangle;
+    }
+
+    public get BoundingMarginRectangle(): RectangleF2D {
+        return this.boundingMarginRectangle;
+    }
+
+    public get ChildElements(): BoundingBox[] {
+        return this.childElements;
+    }
+
+    public set ChildElements(value: BoundingBox[]) {
+        this.childElements = value;
+    }
+
+    public get Parent(): BoundingBox {
+        return this.parent;
+    }
+
+    public set Parent(value: BoundingBox) {
+        this.parent = value;
+    }
+
+    public get DataObject(): Object {
+        return this.dataObject;
+    }
+
+    public setAbsolutePositionFromParent(): void {
+        if (this.parent !== undefined) {
+            this.absolutePosition.x = this.parent.AbsolutePosition.x + this.relativePosition.x;
+            this.absolutePosition.y = this.parent.AbsolutePosition.y + this.relativePosition.y;
+        } else {
+            this.absolutePosition = this.relativePosition;
         }
         }
-        public get DataObject(): Object {
-            return this.dataObject;
+    }
+
+    public calculateAbsolutePositionsRecursiveWithoutTopelement(): void {
+        this.absolutePosition.x = 0.0;
+        this.absolutePosition.y = 0.0;
+        for (let idx: number = 0, len: number = this.ChildElements.length; idx < len; ++idx) {
+            let child: BoundingBox = this.ChildElements[idx];
+            child.calculateAbsolutePositionsRecursive(this.absolutePosition.x, this.absolutePosition.y);
         }
         }
-        public setAbsolutePositionFromParent(): void {
-            if (this.parent != null) {
-                this.absolutePosition.X = this.parent.AbsolutePosition.X + this.relativePosition.X;
-                this.absolutePosition.Y = this.parent.AbsolutePosition.Y + this.relativePosition.Y;
-            }
-            else {
-                this.absolutePosition = this.relativePosition;
-            }
+    }
+
+    public calculateAbsolutePositionsRecursive(x: number, y: number): void {
+        this.absolutePosition.x = this.relativePosition.x + x;
+        this.absolutePosition.y = this.relativePosition.y + y;
+        for (let idx: number = 0, len: number = this.ChildElements.length; idx < len; ++idx) {
+            let child: BoundingBox = this.ChildElements[idx];
+            child.calculateAbsolutePositionsRecursive(this.absolutePosition.x, this.absolutePosition.y);
         }
         }
-        public calculateAbsolutePositionsRecursiveWithoutTopelement(): void {
-            this.absolutePosition.X = 0.0;
-            this.absolutePosition.Y = 0.0;
-            for (var idx: number = 0, len = this.ChildElements.Count; idx < len; ++idx) {
-                var child: BoundingBox = this.ChildElements[idx];
-                child.calculateAbsolutePositionsRecursive(this.absolutePosition.X, this.absolutePosition.Y);
+    }
+
+    public calculateBoundingBox(): void {
+        if (this.childElements.length === 0) {
+            return;
+        }
+        for (let idx: number = 0, len: number = this.ChildElements.length; idx < len; ++idx) {
+            let childElement: BoundingBox = this.ChildElements[idx];
+            childElement.calculateBoundingBox();
+        }
+        let minLeft: number = Number.MAX_VALUE;
+        let maxRight: number = Number.MIN_VALUE;
+        let minTop: number = Number.MAX_VALUE;
+        let maxBottom: number = Number.MIN_VALUE;
+        let minMarginLeft: number = Number.MAX_VALUE;
+        let maxMarginRight: number = Number.MIN_VALUE;
+        let minMarginTop: number = Number.MAX_VALUE;
+        let maxMarginBottom: number = Number.MIN_VALUE;
+        if (this.isSymbol) {
+            minLeft = this.borderLeft;
+            maxRight = this.borderRight;
+            minTop = this.borderTop;
+            maxBottom = this.borderBottom;
+            minMarginLeft = this.borderMarginLeft;
+            maxMarginRight = this.borderMarginRight;
+            minMarginTop = this.borderMarginTop;
+            maxMarginBottom = this.borderMarginBottom;
+        }
+        for (let idx: number = 0, len: number = this.ChildElements.length; idx < len; ++idx) {
+            let childElement: BoundingBox = this.ChildElements[idx];
+            minLeft = Math.min(minLeft, childElement.relativePosition.x + childElement.borderLeft);
+            maxRight = Math.max(maxRight, childElement.relativePosition.x + childElement.borderRight);
+            minTop = Math.min(minTop, childElement.relativePosition.y + childElement.borderTop);
+            maxBottom = Math.max(maxBottom, childElement.relativePosition.y + childElement.borderBottom);
+            minMarginLeft = Math.min(minMarginLeft, childElement.relativePosition.x + childElement.borderMarginLeft);
+            maxMarginRight = Math.max(maxMarginRight,
+                childElement.relativePosition.x + childElement.borderMarginRight);
+            minMarginTop = Math.min(minMarginTop, childElement.relativePosition.y + childElement.borderMarginTop);
+            maxMarginBottom = Math.max(maxMarginBottom,
+                childElement.relativePosition.y + childElement.borderMarginBottom);
+        }
+        this.borderLeft = minLeft;
+        this.borderRight = maxRight;
+        this.borderTop = minTop;
+        this.borderBottom = maxBottom;
+        this.borderMarginLeft = minMarginLeft;
+        this.borderMarginRight = maxMarginRight;
+        this.borderMarginTop = minMarginTop;
+        this.borderMarginBottom = maxMarginBottom;
+        this.calculateRectangle();
+        this.calculateMarginRectangle();
+        this.xBordersHaveBeenSet = true;
+        this.yBordersHaveBeenSet = true;
+    }
+
+    public calculateTopBottomBorders(): void {
+        if (this.childElements.length === 0) {
+            return;
+        }
+        for (let idx: number = 0, len: number = this.ChildElements.length; idx < len; ++idx) {
+            let childElement: BoundingBox = this.ChildElements[idx];
+            childElement.calculateTopBottomBorders();
+        }
+        let minTop: number = Number.MAX_VALUE;
+        let maxBottom: number = Number.MIN_VALUE;
+        let minMarginTop: number = Number.MAX_VALUE;
+        let maxMarginBottom: number = Number.MIN_VALUE;
+        if (this.yBordersHaveBeenSet) {
+            minTop = this.borderTop;
+            maxBottom = this.borderBottom;
+            minMarginTop = this.borderMarginTop;
+            maxMarginBottom = this.borderMarginBottom;
+        }
+        for (let idx: number = 0, len: number = this.ChildElements.length; idx < len; ++idx) {
+            let childElement: BoundingBox = this.ChildElements[idx];
+            minTop = Math.min(minTop, childElement.relativePosition.y + childElement.borderTop);
+            maxBottom = Math.max(maxBottom, childElement.relativePosition.y + childElement.borderBottom);
+            minMarginTop = Math.min(minMarginTop, childElement.relativePosition.y + childElement.borderMarginTop);
+            maxMarginBottom = Math.max(maxMarginBottom,
+                childElement.relativePosition.y + childElement.borderMarginBottom);
+        }
+        this.borderTop = minTop;
+        this.borderBottom = maxBottom;
+        this.borderMarginTop = minMarginTop;
+        this.borderMarginBottom = maxMarginBottom;
+        this.calculateRectangle();
+        this.calculateMarginRectangle();
+    }
+
+    public computeNonOverlappingPositionWithMargin(placementPsi: BoundingBox, direction: ColDirEnum): void {
+        this.computeNonOverlappingPositionWithMargin(placementPsi, direction, new PointF2D(0.0, 0.0));
+    }
+
+    public computeNonOverlappingPositionWithMargin(placementPsi: BoundingBox, direction: ColDirEnum, position: PointF2D): void {
+        this.RelativePosition = new PointF2D(position.x, position.y);
+        this.setAbsolutePositionFromParent();
+        let currentPosition: number = 0.0;
+        let hasBeenMoved: boolean = false;
+        do {
+            switch (direction) {
+                case ColDirEnum.Left:
+                case ColDirEnum.Right:
+                    currentPosition = this.relativePosition.x;
+                    placementPsi.calculateMarginPositionAlongDirection(this, direction);
+                    hasBeenMoved = Math.abs(currentPosition - this.relativePosition.x) > 0.001;
+                    break;
+                case ColDirEnum.Up:
+                case ColDirEnum.Down:
+                    currentPosition = this.relativePosition.y;
+                    placementPsi.calculateMarginPositionAlongDirection(this, direction);
+                    hasBeenMoved = Math.abs(currentPosition - this.relativePosition.y) > 0.001;
+                    break;
+                default:
+                    throw new ArgumentOutOfRangeException("direction");
             }
             }
         }
         }
-        public calculateAbsolutePositionsRecursive(x: number, y: number): void {
-            this.absolutePosition.X = this.relativePosition.X + x;
-            this.absolutePosition.Y = this.relativePosition.Y + y;
-            for (var idx: number = 0, len = this.ChildElements.Count; idx < len; ++idx) {
-                var child: BoundingBox = this.ChildElements[idx];
-                child.calculateAbsolutePositionsRecursive(this.absolutePosition.X, this.absolutePosition.Y);
-            }
+        while (hasBeenMoved);
+    }
+
+    public collisionDetection(psi: BoundingBox): boolean {
+        let overlapWidth: number = Math.min(this.AbsolutePosition.x + this.borderRight, psi.absolutePosition.x + psi.borderRight) - Math.max(this.AbsolutePosition.x + this.borderLeft, psi.absolutePosition.x + psi.borderLeft);
+        let overlapHeight: number = Math.min(this.AbsolutePosition.y + this.borderBottom, psi.absolutePosition.y + psi.borderBottom) - Math.max(this.AbsolutePosition.y + this.borderTop, psi.absolutePosition.y + psi.borderTop);
+        if (overlapWidth > 0 && overlapHeight > 0) {
+            return true;
         }
         }
-        public calculateBoundingBox(): void {
-            if (this.childElements.Count == 0)
-                return
-            for (var idx: number = 0, len = this.ChildElements.Count; idx < len; ++idx) {
-                var childElement: BoundingBox = this.ChildElements[idx];
-                childElement.calculateBoundingBox();
-            }
-            var minLeft: number = number.MaxValue;
-            var maxRight: number = number.MinValue;
-            var minTop: number = number.MaxValue;
-            var maxBottom: number = number.MinValue;
-            var minMarginLeft: number = number.MaxValue;
-            var maxMarginRight: number = number.MinValue;
-            var minMarginTop: number = number.MaxValue;
-            var maxMarginBottom: number = number.MinValue;
-            if (this.isSymbol) {
-                minLeft = this.borderLeft;
-                maxRight = this.borderRight;
-                minTop = this.borderTop;
-                maxBottom = this.borderBottom;
-                minMarginLeft = this.borderMarginLeft;
-                maxMarginRight = this.borderMarginRight;
-                minMarginTop = this.borderMarginTop;
-                maxMarginBottom = this.borderMarginBottom;
-            }
-            for (var idx: number = 0, len = this.ChildElements.Count; idx < len; ++idx) {
-                var childElement: BoundingBox = this.ChildElements[idx];
-                minLeft = Math.Min(minLeft, childElement.relativePosition.X + childElement.borderLeft);
-                maxRight = Math.Max(maxRight, childElement.relativePosition.X + childElement.borderRight);
-                minTop = Math.Min(minTop, childElement.relativePosition.Y + childElement.borderTop);
-                maxBottom = Math.Max(maxBottom, childElement.relativePosition.Y + childElement.borderBottom);
-                minMarginLeft = Math.Min(minMarginLeft, childElement.relativePosition.X + childElement.borderMarginLeft);
-                maxMarginRight = Math.Max(maxMarginRight,
-                    childElement.relativePosition.X + childElement.borderMarginRight);
-                minMarginTop = Math.Min(minMarginTop, childElement.relativePosition.Y + childElement.borderMarginTop);
-                maxMarginBottom = Math.Max(maxMarginBottom,
-                    childElement.relativePosition.Y + childElement.borderMarginBottom);
+        return false;
+    }
+
+    public liesInsideBorders(psi: BoundingBox): boolean {
+        let leftBorderInside: boolean = (this.AbsolutePosition.x + this.borderLeft) <= (psi.absolutePosition.x + psi.borderLeft) && (psi.absolutePosition.x + psi.borderLeft) <= (this.AbsolutePosition.x + this.borderRight);
+        let rightBorderInside: boolean = (this.AbsolutePosition.x + this.borderLeft) <= (psi.absolutePosition.x + psi.borderRight) && (psi.absolutePosition.x + psi.borderRight) <= (this.AbsolutePosition.x + this.borderRight);
+        if (leftBorderInside && rightBorderInside) {
+            let topBorderInside: boolean = (this.AbsolutePosition.y + this.borderTop) <= (psi.absolutePosition.y + psi.borderTop) && (psi.absolutePosition.y + psi.borderTop) <= (this.AbsolutePosition.y + this.borderBottom);
+            let bottomBorderInside: boolean = (this.AbsolutePosition.y + this.borderTop) <= (psi.absolutePosition.y + psi.borderBottom) && (psi.absolutePosition.y + psi.borderBottom) <= (this.AbsolutePosition.y + this.borderBottom);
+            if (topBorderInside && bottomBorderInside) {
+                return true;
             }
             }
-            this.borderLeft = minLeft;
-            this.borderRight = maxRight;
-            this.borderTop = minTop;
-            this.borderBottom = maxBottom;
-            this.borderMarginLeft = minMarginLeft;
-            this.borderMarginRight = maxMarginRight;
-            this.borderMarginTop = minMarginTop;
-            this.borderMarginBottom = maxMarginBottom;
-            this.calculateRectangle();
-            this.calculateMarginRectangle();
-            this.xBordersHaveBeenSet = true;
-            this.yBordersHaveBeenSet = true;
         }
         }
-        public calculateTopBottomBorders(): void {
-            if (this.childElements.Count == 0)
-                return
-            for (var idx: number = 0, len = this.ChildElements.Count; idx < len; ++idx) {
-                var childElement: BoundingBox = this.ChildElements[idx];
-                childElement.calculateTopBottomBorders();
-            }
-            var minTop: number = number.MaxValue;
-            var maxBottom: number = number.MinValue;
-            var minMarginTop: number = number.MaxValue;
-            var maxMarginBottom: number = number.MinValue;
-            if (this.yBordersHaveBeenSet) {
-                minTop = this.borderTop;
-                maxBottom = this.borderBottom;
-                minMarginTop = this.borderMarginTop;
-                maxMarginBottom = this.borderMarginBottom;
-            }
-            for (var idx: number = 0, len = this.ChildElements.Count; idx < len; ++idx) {
-                var childElement: BoundingBox = this.ChildElements[idx];
-                minTop = Math.Min(minTop, childElement.relativePosition.Y + childElement.borderTop);
-                maxBottom = Math.Max(maxBottom, childElement.relativePosition.Y + childElement.borderBottom);
-                minMarginTop = Math.Min(minMarginTop, childElement.relativePosition.Y + childElement.borderMarginTop);
-                maxMarginBottom = Math.Max(maxMarginBottom,
-                    childElement.relativePosition.Y + childElement.borderMarginBottom);
+        return false;
+    }
+
+    public liesInsideBorders(psi: BoundingBox, leftBorderInside: boolean, rightBorderInside: boolean,
+                             topBorderInside: boolean, bottomBorderInside: boolean): boolean {
+        leftBorderInside = (this.AbsolutePosition.x + this.borderLeft) <= (psi.absolutePosition.x + psi.borderLeft) && (psi.absolutePosition.x + psi.borderLeft) <= (this.AbsolutePosition.x + this.borderRight);
+        rightBorderInside = (this.AbsolutePosition.x + this.borderLeft) <= (psi.absolutePosition.x + psi.borderRight) && (psi.absolutePosition.x + psi.borderRight) <= (this.AbsolutePosition.x + this.borderRight);
+        topBorderInside = (this.AbsolutePosition.y + this.borderTop) <= (psi.absolutePosition.y + psi.borderTop) && (psi.absolutePosition.y + psi.borderTop) <= (this.AbsolutePosition.y + this.borderBottom);
+        bottomBorderInside = (this.AbsolutePosition.y + this.borderTop) <= (psi.absolutePosition.y + psi.borderBottom) && (psi.absolutePosition.y + psi.borderBottom) <= (this.AbsolutePosition.y + this.borderBottom);
+        return topBorderInside && bottomBorderInside && leftBorderInside && rightBorderInside;
+    }
+
+    public liesInsideBorders(position: PointF2D): boolean {
+        let xInside: boolean = (this.AbsolutePosition.x + this.borderLeft) <= position.x && position.x <= (this.AbsolutePosition.x + this.borderRight);
+        if (xInside) {
+            let yInside: boolean = (this.AbsolutePosition.y + this.borderTop) <= position.y && position.y <= (this.AbsolutePosition.y + this.borderBottom);
+            if (yInside) {
+                return true;
             }
             }
-            this.borderTop = minTop;
-            this.borderBottom = maxBottom;
-            this.borderMarginTop = minMarginTop;
-            this.borderMarginBottom = maxMarginBottom;
-            this.calculateRectangle();
-            this.calculateMarginRectangle();
         }
         }
-        public computeNonOverlappingPositionWithMargin(placementPsi: BoundingBox, direction: ColDirEnum): void {
-            this.computeNonOverlappingPositionWithMargin(placementPsi, direction, new PointF_2D(0.0, 0.0));
+        return false;
+    }
+
+    public marginCollisionDetection(psi: BoundingBox): boolean {
+        let overlapWidth: number = Math.min(this.AbsolutePosition.x + this.borderMarginRight, psi.absolutePosition.x + psi.borderMarginRight) - Math.max(this.AbsolutePosition.x + this.borderMarginLeft, psi.absolutePosition.x + psi.borderMarginLeft);
+        let overlapHeight: number = Math.min(this.AbsolutePosition.y + this.borderMarginBottom, psi.absolutePosition.y + psi.borderMarginBottom) - Math.max(this.AbsolutePosition.y + this.borderMarginTop, psi.absolutePosition.y + psi.borderMarginTop);
+        if (overlapWidth > 0 && overlapHeight > 0) {
+            return true;
         }
         }
-        public computeNonOverlappingPositionWithMargin(placementPsi: BoundingBox, direction: ColDirEnum, position: PointF_2D): void {
-            this.RelativePosition = new PointF_2D(position.X, position.Y);
-            this.setAbsolutePositionFromParent();
-            var currentPosition: number = 0.0;
-            var hasBeenMoved: boolean = false;
-            do {
-                switch (direction) {
-                    case ColDirEnum.Left:
-                    case ColDirEnum.Right:
-                        currentPosition = this.relativePosition.X;
-                        placementPsi.calculateMarginPositionAlongDirection(this, direction);
-                        hasBeenMoved = Math.Abs(currentPosition - this.relativePosition.X) > 0.001;
-                        break;
-                    case ColDirEnum.Up:
-                    case ColDirEnum.Down:
-                        currentPosition = this.relativePosition.Y;
-                        placementPsi.calculateMarginPositionAlongDirection(this, direction);
-                        hasBeenMoved = Math.Abs(currentPosition - this.relativePosition.Y) > 0.001;
-                        break;
-                    default:
-                        throw new ArgumentOutOfRangeException("direction");
-                }
+        return false;
+    }
+
+    public liesInsideMargins(psi: BoundingBox): boolean {
+        let leftMarginInside: boolean = (this.AbsolutePosition.x + this.borderMarginLeft) <= (psi.absolutePosition.x + psi.borderMarginLeft) && (psi.absolutePosition.x + psi.borderMarginLeft) <= (this.AbsolutePosition.x + this.borderMarginRight);
+        let rightMarginInside: boolean = (this.AbsolutePosition.x + this.borderMarginLeft) <= (psi.absolutePosition.x + psi.borderMarginRight) && (psi.absolutePosition.x + psi.borderMarginRight) <= (this.AbsolutePosition.x + this.borderMarginRight);
+        if (leftMarginInside && rightMarginInside) {
+            let topMarginInside: boolean = (this.AbsolutePosition.y + this.borderMarginTop) <= (psi.absolutePosition.y + psi.borderMarginTop) && (psi.absolutePosition.y + psi.borderMarginTop) <= (this.AbsolutePosition.y + this.borderMarginBottom);
+            let bottomMarginInside: boolean = (this.AbsolutePosition.y + this.borderMarginTop) <= (psi.absolutePosition.y + psi.borderMarginBottom) && (psi.absolutePosition.y + psi.borderMarginBottom) <= (this.AbsolutePosition.y + this.borderMarginBottom);
+            if (topMarginInside && bottomMarginInside) {
+                return true;
             }
             }
-            while (hasBeenMoved);
         }
         }
-        public collisionDetection(psi: BoundingBox): boolean {
-            var overlapWidth: number = Math.Min(this.AbsolutePosition.X + this.borderRight, psi.absolutePosition.X + psi.borderRight) - Math.Max(this.AbsolutePosition.X + this.borderLeft, psi.absolutePosition.X + psi.borderLeft);
-            var overlapHeight: number = Math.Min(this.AbsolutePosition.Y + this.borderBottom, psi.absolutePosition.Y + psi.borderBottom) - Math.Max(this.AbsolutePosition.Y + this.borderTop, psi.absolutePosition.Y + psi.borderTop);
-            if (overlapWidth > 0 && overlapHeight > 0)
+        return false;
+    }
+
+    public liesInsideMargins(position: PointF2D): boolean {
+        let xInside: boolean = (this.AbsolutePosition.x + this.borderMarginLeft) <= position.x && position.x <= (this.AbsolutePosition.x + this.borderMarginRight);
+        if (xInside) {
+            let yInside: boolean = (this.AbsolutePosition.y + this.borderMarginTop) <= position.y && position.y <= (this.AbsolutePosition.y + this.borderMarginBottom);
+            if (yInside) {
                 return true;
                 return true;
-            return false;
-        }
-        public liesInsideBorders(psi: BoundingBox): boolean {
-            var leftBorderInside: boolean = (this.AbsolutePosition.X + this.borderLeft) <= (psi.absolutePosition.X + psi.borderLeft) && (psi.absolutePosition.X + psi.borderLeft) <= (this.AbsolutePosition.X + this.borderRight);
-            var rightBorderInside: boolean = (this.AbsolutePosition.X + this.borderLeft) <= (psi.absolutePosition.X + psi.borderRight) && (psi.absolutePosition.X + psi.borderRight) <= (this.AbsolutePosition.X + this.borderRight);
-            if (leftBorderInside && rightBorderInside) {
-                var topBorderInside: boolean = (this.AbsolutePosition.Y + this.borderTop) <= (psi.absolutePosition.Y + psi.borderTop) && (psi.absolutePosition.Y + psi.borderTop) <= (this.AbsolutePosition.Y + this.borderBottom);
-                var bottomBorderInside: boolean = (this.AbsolutePosition.Y + this.borderTop) <= (psi.absolutePosition.Y + psi.borderBottom) && (psi.absolutePosition.Y + psi.borderBottom) <= (this.AbsolutePosition.Y + this.borderBottom);
-                if (topBorderInside && bottomBorderInside) {
-                    return true;
-                }
             }
             }
-            return false;
         }
         }
-        public liesInsideBorders(psi: BoundingBox, leftBorderInside: boolean, rightBorderInside: boolean,
-            topBorderInside: boolean, bottomBorderInside: boolean): boolean {
-            leftBorderInside = (this.AbsolutePosition.X + this.borderLeft) <= (psi.absolutePosition.X + psi.borderLeft) && (psi.absolutePosition.X + psi.borderLeft) <= (this.AbsolutePosition.X + this.borderRight);
-            rightBorderInside = (this.AbsolutePosition.X + this.borderLeft) <= (psi.absolutePosition.X + psi.borderRight) && (psi.absolutePosition.X + psi.borderRight) <= (this.AbsolutePosition.X + this.borderRight);
-            topBorderInside = (this.AbsolutePosition.Y + this.borderTop) <= (psi.absolutePosition.Y + psi.borderTop) && (psi.absolutePosition.Y + psi.borderTop) <= (this.AbsolutePosition.Y + this.borderBottom);
-            bottomBorderInside = (this.AbsolutePosition.Y + this.borderTop) <= (psi.absolutePosition.Y + psi.borderBottom) && (psi.absolutePosition.Y + psi.borderBottom) <= (this.AbsolutePosition.Y + this.borderBottom);
-            return topBorderInside && bottomBorderInside && leftBorderInside && rightBorderInside;
-        }
-        public liesInsideBorders(position: PointF_2D): boolean {
-            var xInside: boolean = (this.AbsolutePosition.X + this.borderLeft) <= position.X && position.X <= (this.AbsolutePosition.X + this.borderRight);
-            if (xInside) {
-                var yInside: boolean = (this.AbsolutePosition.Y + this.borderTop) <= position.Y && position.Y <= (this.AbsolutePosition.Y + this.borderBottom);
-                if (yInside) {
-                    return true;
-                }
+        return false;
+    }
+
+    public computeNonOverlappingPosition(placementPsi: BoundingBox, direction: ColDirEnum, margin: number): void {
+        this.computeNonOverlappingPosition(placementPsi, direction, new PointF2D(0.0, 0.0));
+    }
+
+    public computeNonOverlappingPosition(placementPsi: BoundingBox, direction: ColDirEnum, position: PointF2D): void {
+        this.RelativePosition = new PointF2D(position.x, position.y);
+        this.setAbsolutePositionFromParent();
+        let currentPosition: number = 0.0;
+        let hasBeenMoved: boolean = false;
+        do {
+            switch (direction) {
+                case ColDirEnum.Left:
+                case ColDirEnum.Right:
+                    currentPosition = this.relativePosition.x;
+                    placementPsi.calculatePositionAlongDirection(this, direction);
+                    hasBeenMoved = Math.abs(currentPosition - this.relativePosition.x) > 0.0001;
+                    break;
+                case ColDirEnum.Up:
+                case ColDirEnum.Down:
+                    currentPosition = this.relativePosition.y;
+                    placementPsi.calculatePositionAlongDirection(this, direction);
+                    hasBeenMoved = Math.abs(currentPosition - this.relativePosition.y) > 0.0001;
+                    break;
+                default:
+                    throw new ArgumentOutOfRangeException("direction");
             }
             }
-            return false;
         }
         }
-        public marginCollisionDetection(psi: BoundingBox): boolean {
-            var overlapWidth: number = Math.Min(this.AbsolutePosition.X + this.borderMarginRight, psi.absolutePosition.X + psi.borderMarginRight) - Math.Max(this.AbsolutePosition.X + this.borderMarginLeft, psi.absolutePosition.X + psi.borderMarginLeft);
-            var overlapHeight: number = Math.Min(this.AbsolutePosition.Y + this.borderMarginBottom, psi.absolutePosition.Y + psi.borderMarginBottom) - Math.Max(this.AbsolutePosition.Y + this.borderMarginTop, psi.absolutePosition.Y + psi.borderMarginTop);
-            if (overlapWidth > 0 && overlapHeight > 0)
-                return true;
-            return false;
-        }
-        public liesInsideMargins(psi: BoundingBox): boolean {
-            var leftMarginInside: boolean = (this.AbsolutePosition.X + this.borderMarginLeft) <= (psi.absolutePosition.X + psi.borderMarginLeft) && (psi.absolutePosition.X + psi.borderMarginLeft) <= (this.AbsolutePosition.X + this.borderMarginRight);
-            var rightMarginInside: boolean = (this.AbsolutePosition.X + this.borderMarginLeft) <= (psi.absolutePosition.X + psi.borderMarginRight) && (psi.absolutePosition.X + psi.borderMarginRight) <= (this.AbsolutePosition.X + this.borderMarginRight);
-            if (leftMarginInside && rightMarginInside) {
-                var topMarginInside: boolean = (this.AbsolutePosition.Y + this.borderMarginTop) <= (psi.absolutePosition.Y + psi.borderMarginTop) && (psi.absolutePosition.Y + psi.borderMarginTop) <= (this.AbsolutePosition.Y + this.borderMarginBottom);
-                var bottomMarginInside: boolean = (this.AbsolutePosition.Y + this.borderMarginTop) <= (psi.absolutePosition.Y + psi.borderMarginBottom) && (psi.absolutePosition.Y + psi.borderMarginBottom) <= (this.AbsolutePosition.Y + this.borderMarginBottom);
-                if (topMarginInside && bottomMarginInside) {
-                    return true;
-                }
+        while (hasBeenMoved);
+    }
+
+    public getClickedObjectOfType<T>(clickPosition: PointF2D): T {
+        let obj: Object = this.dataObject;
+        if (this.liesInsideBorders(clickPosition) && (obj instanceof T)) {
+            return (obj as T);
+        }
+        for (let idx: number = 0, len: number = this.childElements.length; idx < len; ++idx) {
+            let psi: BoundingBox = this.childElements[idx];
+            let innerObject: Object = psi.getClickedObjectOfType<T>(clickPosition);
+            if (innerObject !== undefined) {
+                return (innerObject as T);
             }
             }
-            return false;
         }
         }
-        public liesInsideMargins(position: PointF_2D): boolean {
-            var xInside: boolean = (this.AbsolutePosition.X + this.borderMarginLeft) <= position.X && position.X <= (this.AbsolutePosition.X + this.borderMarginRight);
-            if (xInside) {
-                var yInside: boolean = (this.AbsolutePosition.Y + this.borderMarginTop) <= position.Y && position.Y <= (this.AbsolutePosition.Y + this.borderMarginBottom);
-                if (yInside) {
-                    return true;
+        return undefined;
+    }
+
+    public getObjectsInRegion<T>(region: BoundingBox): T[] {
+        return this.getObjectsInRegion<T>(region, true);
+    }
+
+    public getObjectsInRegion<T>(region: BoundingBox, liesInside: boolean): T[] {
+        if (this.dataObject instanceof T) {
+            if (liesInside) {
+                if (region.liesInsideBorders(this)) {
+                    return [this.dataObject as T];
                 }
                 }
-            }
-            return false;
-        }
-        public computeNonOverlappingPosition(placementPsi: BoundingBox, direction: ColDirEnum, margin: number): void {
-            this.computeNonOverlappingPosition(placementPsi, direction, new PointF_2D(0.0, 0.0));
-        }
-        public computeNonOverlappingPosition(placementPsi: BoundingBox, direction: ColDirEnum, position: PointF_2D): void {
-            this.RelativePosition = new PointF_2D(position.X, position.Y);
-            this.setAbsolutePositionFromParent();
-            var currentPosition: number = 0.0;
-            var hasBeenMoved: boolean = false;
-            do {
-                switch (direction) {
-                    case ColDirEnum.Left:
-                    case ColDirEnum.Right:
-                        currentPosition = this.relativePosition.X;
-                        placementPsi.calculatePositionAlongDirection(this, direction);
-                        hasBeenMoved = Math.Abs(currentPosition - this.relativePosition.X) > 0.0001;
-                        break;
-                    case ColDirEnum.Up:
-                    case ColDirEnum.Down:
-                        currentPosition = this.relativePosition.Y;
-                        placementPsi.calculatePositionAlongDirection(this, direction);
-                        hasBeenMoved = Math.Abs(currentPosition - this.relativePosition.Y) > 0.0001;
-                        break;
-                    default:
-                        throw new ArgumentOutOfRangeException("direction");
+            } else {
+                if (region.collisionDetection(this)) {
+                    return [this.dataObject as T];
                 }
                 }
             }
             }
-            while (hasBeenMoved);
         }
         }
-        public getClickedObjectOfType<T>(clickPosition: PointF_2D): T {
-            var obj: Object = this.dataObject;
-            if (this.liesInsideBorders(clickPosition) && (obj instanceof T))
-                return __as__<T>(obj, T);
-            for (var idx: number = 0, len = this.childElements.Count; idx < len; ++idx) {
-                var psi: BoundingBox = this.childElements[idx];
-                var innerObject: Object = psi.getClickedObjectOfType<T>(clickPosition);
-                if (innerObject != null)
-                    return __as__<T>(innerObject, T);
+        return this.childElements.SelectMany(psi => psi.getObjectsInRegion<T>(region, liesInside));
+    }
+
+    protected calculateRectangle(): void {
+        this.upperLeftCorner = new PointF2D(this.borderLeft, this.borderTop);
+        this.size = new SizeF2D(this.borderRight - this.borderLeft, this.borderBottom - this.borderTop);
+        this.boundingRectangle = new RectangleF2D(this.upperLeftCorner, this.size);
+    }
+
+    protected calculateMarginRectangle(): void {
+        this.upperLeftMarginCorner = new PointF2D(this.borderMarginLeft, this.borderMarginTop);
+        this.marginSize = new SizeF2D(this.borderMarginRight - this.borderMarginLeft, this.borderMarginBottom - this.borderMarginTop);
+        this.boundingMarginRectangle = new RectangleF2D(this.upperLeftMarginCorner, this.marginSize);
+    }
+
+    private calculateMarginPositionAlongDirection(toBePlaced: BoundingBox, direction: ColDirEnum): void {
+        if (this === toBePlaced) {
+            return;
+        }
+        if (this.isSymbol && this.marginCollisionDetection(toBePlaced)) {
+            let shiftDistance: number = 0;
+            switch (direction) {
+                case ColDirEnum.Left:
+                    shiftDistance = (this.absolutePosition.x + this.borderMarginLeft) - (toBePlaced.absolutePosition.x + toBePlaced.borderMarginRight);
+                    toBePlaced.relativePosition.x += shiftDistance;
+                    toBePlaced.absolutePosition.x += shiftDistance;
+                    return;
+                case ColDirEnum.Right:
+                    shiftDistance = (this.absolutePosition.x + this.borderMarginRight) - (toBePlaced.absolutePosition.x + toBePlaced.borderMarginLeft);
+                    toBePlaced.relativePosition.x += shiftDistance;
+                    toBePlaced.absolutePosition.x += shiftDistance;
+                    return;
+                case ColDirEnum.Up:
+                    shiftDistance = (this.absolutePosition.y + this.borderMarginTop) - (toBePlaced.absolutePosition.y + toBePlaced.borderMarginBottom);
+                    toBePlaced.relativePosition.y += shiftDistance;
+                    toBePlaced.absolutePosition.y += shiftDistance;
+                    return;
+                case ColDirEnum.Down:
+                    shiftDistance = (this.absolutePosition.y + this.borderMarginBottom) - (toBePlaced.absolutePosition.y + toBePlaced.borderMarginTop);
+                    toBePlaced.relativePosition.y += shiftDistance;
+                    toBePlaced.absolutePosition.y += shiftDistance;
+                    return;
+                default:
+                    throw new ArgumentOutOfRangeException("direction");
             }
             }
-            return null;
         }
         }
-        public getObjectsInRegion<T>(region: BoundingBox): IEnumerable<T> {
-            return this.getObjectsInRegion<T>(region, true);
+        for (let idx: number = 0, len: number = this.ChildElements.length; idx < len; ++idx) {
+            let childElement: BoundingBox = this.ChildElements[idx];
+            childElement.calculateMarginPositionAlongDirection(toBePlaced, direction);
         }
         }
-        public getObjectsInRegion<T>(region: BoundingBox, liesInside: boolean): IEnumerable<T> {
-            if (this.dataObject instanceof T) {
-                if (liesInside) {
-                    if (region.liesInsideBorders(this))
-                        return __init(new List<T>(), { __as__<T>(this.dataObject, T) });
+    }
+
+    private calculatePositionAlongDirection(toBePlaced: BoundingBox, direction: ColDirEnum): void {
+        if (this === toBePlaced) {
+            return;
+        }
+        if (this.isSymbol && this.collisionDetection(toBePlaced)) {
+            let shiftDistance: number;
+            switch (direction) {
+                case ColDirEnum.Left:
+                    shiftDistance = (this.absolutePosition.x + this.borderLeft) - (toBePlaced.absolutePosition.x + toBePlaced.borderRight);
+                    toBePlaced.relativePosition.x += shiftDistance;
+                    toBePlaced.absolutePosition.x += shiftDistance;
+                    return;
+                case ColDirEnum.Right:
+                    shiftDistance = (this.absolutePosition.x + this.borderRight) - (toBePlaced.absolutePosition.x + toBePlaced.borderLeft);
+                    toBePlaced.relativePosition.x += shiftDistance;
+                    toBePlaced.absolutePosition.x += shiftDistance;
+                    return;
+                case ColDirEnum.Up:
+                    shiftDistance = (this.absolutePosition.y + this.borderTop) - (toBePlaced.absolutePosition.y + toBePlaced.borderBottom);
+                    toBePlaced.relativePosition.y += shiftDistance;
+                    toBePlaced.absolutePosition.y += shiftDistance;
+                    return;
+                case ColDirEnum.Down:
+                    shiftDistance = (this.absolutePosition.y + this.borderBottom) - (toBePlaced.absolutePosition.y + toBePlaced.borderTop);
+                    toBePlaced.relativePosition.y += shiftDistance;
+                    toBePlaced.absolutePosition.y += shiftDistance;
+                    return;
+                default:
+                    throw new ArgumentOutOfRangeException("direction");
             }
             }
-            else {
-                if (region.collisionDetection(this))
-                    return __init(new List<T>(), { __as__<T>(this.dataObject, T) });
+        }
+        for (let idx: number = 0, len: number = this.ChildElements.length; idx < len; ++idx) {
+            let childElement: BoundingBox = this.ChildElements[idx];
+            childElement.calculatePositionAlongDirection(toBePlaced, direction);
         }
         }
     }
     }
-    return this.childElements.SelectMany(psi => psi.getObjectsInRegion<T>(region, liesInside));
-}
-protected calculateRectangle(): void
-    {
-        this.upperLeftCorner = new PointF_2D(this.borderLeft, this.borderTop);
-        this.size = new SizeF_2D(this.borderRight - this.borderLeft, this.borderBottom - this.borderTop);
-        this.boundingRectangle = new RectangleF_2D(this.upperLeftCorner, this.size);
-    }
-protected calculateMarginRectangle(): void
-    {
-        this.upperLeftMarginCorner = new PointF_2D(this.borderMarginLeft, this.borderMarginTop);
-        this.marginSize = new SizeF_2D(this.borderMarginRight - this.borderMarginLeft, this.borderMarginBottom - this.borderMarginTop);
-        this.boundingMarginRectangle = new RectangleF_2D(this.upperLeftMarginCorner, this.marginSize);
-    }
-private calculateMarginPositionAlongDirection(toBePlaced:BoundingBox, direction:ColDirEnum): void
-    {
-        if(this == toBePlaced)
- {
-    return
-}
-if (this.isSymbol && this.marginCollisionDetection(toBePlaced)) {
-    var shiftDistance: number = 0;
-    switch (direction) {
-        case ColDirEnum.Left:
-            shiftDistance = (this.absolutePosition.X + this.borderMarginLeft) - (toBePlaced.absolutePosition.X + toBePlaced.borderMarginRight);
-            toBePlaced.relativePosition.X += shiftDistance;
-            toBePlaced.absolutePosition.X += shiftDistance;
-            return
-        case ColDirEnum.Right:
-            shiftDistance = (this.absolutePosition.X + this.borderMarginRight) - (toBePlaced.absolutePosition.X + toBePlaced.borderMarginLeft);
-            toBePlaced.relativePosition.X += shiftDistance;
-            toBePlaced.absolutePosition.X += shiftDistance;
-            return
-        case ColDirEnum.Up:
-            shiftDistance = (this.absolutePosition.Y + this.borderMarginTop) - (toBePlaced.absolutePosition.Y + toBePlaced.borderMarginBottom);
-            toBePlaced.relativePosition.Y += shiftDistance;
-            toBePlaced.absolutePosition.Y += shiftDistance;
-            return
-        case ColDirEnum.Down:
-            shiftDistance = (this.absolutePosition.Y + this.borderMarginBottom) - (toBePlaced.absolutePosition.Y + toBePlaced.borderMarginTop);
-            toBePlaced.relativePosition.Y += shiftDistance;
-            toBePlaced.absolutePosition.Y += shiftDistance;
-            return
-        default:
-            throw new ArgumentOutOfRangeException("direction");
-    }
-}
-for (var idx: number = 0, len = this.ChildElements.Count; idx < len; ++idx) {
-    var childElement: BoundingBox = this.ChildElements[idx];
-    childElement.calculateMarginPositionAlongDirection(toBePlaced, direction);
-}
-}
-private calculatePositionAlongDirection(toBePlaced:BoundingBox, direction:ColDirEnum): void
-    {
-        if(this == toBePlaced)
- {
-    return
-}
-if (this.isSymbol && this.collisionDetection(toBePlaced)) {
-    var shiftDistance: number;
-    switch (direction) {
-        case ColDirEnum.Left:
-            shiftDistance = (this.absolutePosition.X + this.borderLeft) - (toBePlaced.absolutePosition.X + toBePlaced.borderRight);
-            toBePlaced.relativePosition.X += shiftDistance;
-            toBePlaced.absolutePosition.X += shiftDistance;
-            return
-        case ColDirEnum.Right:
-            shiftDistance = (this.absolutePosition.X + this.borderRight) - (toBePlaced.absolutePosition.X + toBePlaced.borderLeft);
-            toBePlaced.relativePosition.X += shiftDistance;
-            toBePlaced.absolutePosition.X += shiftDistance;
-            return
-        case ColDirEnum.Up:
-            shiftDistance = (this.absolutePosition.Y + this.borderTop) - (toBePlaced.absolutePosition.Y + toBePlaced.borderBottom);
-            toBePlaced.relativePosition.Y += shiftDistance;
-            toBePlaced.absolutePosition.Y += shiftDistance;
-            return
-        case ColDirEnum.Down:
-            shiftDistance = (this.absolutePosition.Y + this.borderBottom) - (toBePlaced.absolutePosition.Y + toBePlaced.borderTop);
-            toBePlaced.relativePosition.Y += shiftDistance;
-            toBePlaced.absolutePosition.Y += shiftDistance;
-            return
-        default:
-            throw new ArgumentOutOfRangeException("direction");
-    }
-}
-for (var idx: number = 0, len = this.ChildElements.Count; idx < len; ++idx) {
-    var childElement: BoundingBox = this.ChildElements[idx];
-    childElement.calculatePositionAlongDirection(toBePlaced, direction);
 }
 }
-}
-                }
+
 export enum ColDirEnum {
 export enum ColDirEnum {
     Left = 0,
     Left = 0,
-
     Right = 1,
     Right = 1,
-
     Up = 2,
     Up = 2,
-
     Down = 3
     Down = 3
 }
 }

+ 30 - 30
src/MusicalScore/Graphical/EngravingRules.ts

@@ -136,8 +136,8 @@ export class EngravingRules {
     private maxInstructionsConstValue: number;
     private maxInstructionsConstValue: number;
     private noteDistances: number[] = [1.0,1.0,1.3,1.6,2.0,2.5,3.0,4.0];
     private noteDistances: number[] = [1.0,1.0,1.3,1.6,2.0,2.5,3.0,4.0];
     private noteDistancesScalingFactors: number[] = [1.0,2.0,4.0,8.0,16.0,32.0,64.0,128.0];
     private noteDistancesScalingFactors: number[] = [1.0,2.0,4.0,8.0,16.0,32.0,64.0,128.0];
-    private durationDistanceDict: Dictionary<number, number> = new Dictionary<number, number>();
-    private durationScalingDistanceDict: Dictionary<number, number> = new Dictionary<number, number>();
+    private durationDistanceDict: {[_: number]: number; } = {};
+    private durationScalingDistanceDict: {[_: number]: number; } = {};
     constructor() {
     constructor() {
         this.samplingUnit = EngravingRules.unit * 3;
         this.samplingUnit = EngravingRules.unit * 3;
         this.sheetTitleHeight = 4.0;
         this.sheetTitleHeight = 4.0;
@@ -267,17 +267,17 @@ export class EngravingRules {
         this.populateDictionaries();
         this.populateDictionaries();
         try {
         try {
             this.maxInstructionsConstValue = this.ClefLeftMargin + this.ClefRightMargin + this.KeyRightMargin + this.RhythmRightMargin;
             this.maxInstructionsConstValue = this.ClefLeftMargin + this.ClefRightMargin + this.KeyRightMargin + this.RhythmRightMargin;
-            if (FontInfo.Info != null) {
+            if (FontInfo.Info !== undefined) {
                 this.maxInstructionsConstValue += FontInfo.Info.getBoundingBox(MusicSymbol.G_CLEF).Width + FontInfo.Info.getBoundingBox(MusicSymbol.FOUR).Width + 7 * FontInfo.Info.getBoundingBox(MusicSymbol.SHARP).Width;
                 this.maxInstructionsConstValue += FontInfo.Info.getBoundingBox(MusicSymbol.G_CLEF).Width + FontInfo.Info.getBoundingBox(MusicSymbol.FOUR).Width + 7 * FontInfo.Info.getBoundingBox(MusicSymbol.SHARP).Width;
             }
             }
         }
         }
         catch (ex) {
         catch (ex) {
-            Logger.DefaultLogger.LogError(PhonicScore.Common.Enums.LogLevel.NORMAL, "EngravingRules()", ex);
+            Logging.log("EngravingRules()", ex);
         }
         }
 
 
     }
     }
     public static get Rules(): EngravingRules {
     public static get Rules(): EngravingRules {
-        return EngravingRules.rules != null ? EngravingRules.rules : (EngravingRules.rules = new EngravingRules());
+        return EngravingRules.rules !== undefined ? EngravingRules.rules : (EngravingRules.rules = new EngravingRules());
     }
     }
     public get SamplingUnit(): number {
     public get SamplingUnit(): number {
         return this.samplingUnit;
         return this.samplingUnit;
@@ -1059,46 +1059,46 @@ export class EngravingRules {
     public set NoteDistancesScalingFactors(value: number[]) {
     public set NoteDistancesScalingFactors(value: number[]) {
         this.noteDistancesScalingFactors = value;
         this.noteDistancesScalingFactors = value;
     }
     }
-    public get DurationDistanceDict(): Dictionary<number, number> {
+    public get DurationDistanceDict(): {[_: number]: number; } {
         return this.durationDistanceDict;
         return this.durationDistanceDict;
     }
     }
-    public get DurationScalingDistanceDict(): Dictionary<number, number> {
+    public get DurationScalingDistanceDict(): {[_: number]: number; } {
         return this.durationScalingDistanceDict;
         return this.durationScalingDistanceDict;
     }
     }
     private populateDictionaries(): void {
     private populateDictionaries(): void {
-        for (var i: number = 0; i < this.noteDistances.length; i++) {
+        for (let i: number = 0; i < this.noteDistances.length; i++) {
             switch (i) {
             switch (i) {
                 case 0:
                 case 0:
-                    this.durationDistanceDict.Add(0.015625, this.noteDistances[i]);
-                    this.durationScalingDistanceDict.Add(0.015625, this.noteDistancesScalingFactors[i]);
+                    this.durationDistanceDict.push(0.015625, this.noteDistances[i]);
+                    this.durationScalingDistanceDict.push(0.015625, this.noteDistancesScalingFactors[i]);
                     break;
                     break;
                 case 1:
                 case 1:
-                    this.durationDistanceDict.Add(0.03125, this.noteDistances[i]);
-                    this.durationScalingDistanceDict.Add(0.03125, this.noteDistancesScalingFactors[i]);
+                    this.durationDistanceDict.push(0.03125, this.noteDistances[i]);
+                    this.durationScalingDistanceDict.push(0.03125, this.noteDistancesScalingFactors[i]);
                     break;
                     break;
                 case 2:
                 case 2:
-                    this.durationDistanceDict.Add(0.0625, this.noteDistances[i]);
-                    this.durationScalingDistanceDict.Add(0.0625, this.noteDistancesScalingFactors[i]);
+                    this.durationDistanceDict.push(0.0625, this.noteDistances[i]);
+                    this.durationScalingDistanceDict.push(0.0625, this.noteDistancesScalingFactors[i]);
                     break;
                     break;
                 case 3:
                 case 3:
-                    this.durationDistanceDict.Add(0.125, this.noteDistances[i]);
-                    this.durationScalingDistanceDict.Add(0.125, this.noteDistancesScalingFactors[i]);
+                    this.durationDistanceDict.push(0.125, this.noteDistances[i]);
+                    this.durationScalingDistanceDict.push(0.125, this.noteDistancesScalingFactors[i]);
                     break;
                     break;
                 case 4:
                 case 4:
-                    this.durationDistanceDict.Add(0.25, this.noteDistances[i]);
-                    this.durationScalingDistanceDict.Add(0.25, this.noteDistancesScalingFactors[i]);
+                    this.durationDistanceDict.push(0.25, this.noteDistances[i]);
+                    this.durationScalingDistanceDict.push(0.25, this.noteDistancesScalingFactors[i]);
                     break;
                     break;
                 case 5:
                 case 5:
-                    this.durationDistanceDict.Add(0.5, this.noteDistances[i]);
-                    this.durationScalingDistanceDict.Add(0.5, this.noteDistancesScalingFactors[i]);
+                    this.durationDistanceDict.push(0.5, this.noteDistances[i]);
+                    this.durationScalingDistanceDict.push(0.5, this.noteDistancesScalingFactors[i]);
                     break;
                     break;
                 case 6:
                 case 6:
-                    this.durationDistanceDict.Add(1.0, this.noteDistances[i]);
-                    this.durationScalingDistanceDict.Add(1.0, this.noteDistancesScalingFactors[i]);
+                    this.durationDistanceDict.push(1.0, this.noteDistances[i]);
+                    this.durationScalingDistanceDict.push(1.0, this.noteDistancesScalingFactors[i]);
                     break;
                     break;
                 case 7:
                 case 7:
-                    this.durationDistanceDict.Add(2.0, this.noteDistances[i]);
-                    this.durationScalingDistanceDict.Add(2.0, this.noteDistancesScalingFactors[i]);
+                    this.durationDistanceDict.push(2.0, this.noteDistances[i]);
+                    this.durationScalingDistanceDict.push(2.0, this.noteDistancesScalingFactors[i]);
                     break;
                     break;
             }
             }
         }
         }
@@ -1108,12 +1108,12 @@ export class EngravingRules {
         this.oneMinusTPower3 = new Array(this.bezierCurveStepSize);
         this.oneMinusTPower3 = new Array(this.bezierCurveStepSize);
         this.factorOne = new Array(this.bezierCurveStepSize);
         this.factorOne = new Array(this.bezierCurveStepSize);
         this.factorTwo = new Array(this.bezierCurveStepSize);
         this.factorTwo = new Array(this.bezierCurveStepSize);
-        for (var i: number = 0; i < this.bezierCurveStepSize; i++) {
-            var t: number = <number>i / this.bezierCurveStepSize;
-            this.tPower3[i] = Math.Pow(t, 3);
-            this.oneMinusTPower3[i] = Math.Pow((1 - t), 3);
-            this.factorOne[i] = 3 * Math.Pow((1 - t), 2) * t;
-            this.factorTwo[i] = 3 * (1 - t) * Math.Pow(t, 2);
+        for (let i: number = 0; i < this.bezierCurveStepSize; i++) {
+            let t: number = <number>i / this.bezierCurveStepSize;
+            this.tPower3[i] = Math.pow(t, 3);
+            this.oneMinusTPower3[i] = Math.pow((1 - t), 3);
+            this.factorOne[i] = 3 * Math.pow((1 - t), 2) * t;
+            this.factorTwo[i] = 3 * (1 - t) * Math.pow(t, 2);
         }
         }
     }
     }
 }
 }

+ 214 - 214
src/MusicalScore/Graphical/FontInfo.ts

@@ -19,7 +19,7 @@ export class FontInfo {
             return this.symbolMapping[symbol];
             return this.symbolMapping[symbol];
         }
         }
         catch (ex) {
         catch (ex) {
-            Logger.DefaultLogger.LogError(LogLevel.DEBUG, "FontInfo.getSymbolInfo", ex);
+            Logging.debug("FontInfo.getSymbolInfo", ex);
             return new SymbolInfo();
             return new SymbolInfo();
         }
         }
 
 
@@ -29,32 +29,32 @@ export class FontInfo {
             return this.symbolMapping[symbol].boundingBox;
             return this.symbolMapping[symbol].boundingBox;
         }
         }
         catch (ex) {
         catch (ex) {
-            Logger.DefaultLogger.LogError(LogLevel.DEBUG, "FontInfo.getBoundingBox", ex);
+            Logging.debug("FontInfo.getBoundingBox", ex);
             return new SizeF_2D();
             return new SizeF_2D();
         }
         }
 
 
     }
     }
     public addBoundingBox(symbol: MusicSymbol, boundingBox: SizeF_2D): void {
     public addBoundingBox(symbol: MusicSymbol, boundingBox: SizeF_2D): void {
-        var si: SymbolInfo = this.symbolMapping[symbol];
+        let si: SymbolInfo = this.symbolMapping[symbol];
         si.boundingBox = boundingBox;
         si.boundingBox = boundingBox;
         this.symbolMapping.Remove(symbol);
         this.symbolMapping.Remove(symbol);
-        this.symbolMapping.Add(symbol, si);
+        this.symbolMapping.push(symbol, si);
     }
     }
     public getCenterDistance(symbol: SymbolInfo): SizeF_2D {
     public getCenterDistance(symbol: SymbolInfo): SizeF_2D {
-        var symbolBox: SizeF_2D = symbol.boundingBox;
-        var symbolCenter: PointF_2D = symbol.center;
-        var centerDistance: SizeF_2D = new SizeF_2D(symbolBox.Width * symbolCenter.X, symbolBox.Height * symbolCenter.Y);
+        let symbolBox: SizeF_2D = symbol.boundingBox;
+        let symbolCenter: PointF_2D = symbol.center;
+        let centerDistance: SizeF_2D = new SizeF_2D(symbolBox.Width * symbolCenter.X, symbolBox.Height * symbolCenter.Y);
         return centerDistance;
         return centerDistance;
     }
     }
     public fillPSI(psi: BoundingBox, symbol: MusicSymbol): void {
     public fillPSI(psi: BoundingBox, symbol: MusicSymbol): void {
-        this.fillPSI(psi, symbol, 1.0f);
+        this.fillPSI(psi, symbol, 1.0);
     }
     }
     public fillPSI(psi: BoundingBox, symbol: MusicSymbol, scaleFactor: number): void {
     public fillPSI(psi: BoundingBox, symbol: MusicSymbol, scaleFactor: number): void {
-        var symbolInfo: SymbolInfo = this.symbolMapping[symbol];
-        var symbolBox: SizeF_2D = symbolInfo.boundingBox;
-        var symbolCenter: PointF_2D = symbolInfo.center;
-        var centerDistance: SizeF_2D = new SizeF_2D(symbolBox.Width * symbolCenter.X, symbolBox.Height * symbolCenter.Y);
-        var symbolMargins: SymbolMargins = symbolInfo.margins;
+        let symbolInfo: SymbolInfo = this.symbolMapping[symbol];
+        let symbolBox: SizeF_2D = symbolInfo.boundingBox;
+        let symbolCenter: PointF_2D = symbolInfo.center;
+        let centerDistance: SizeF_2D = new SizeF_2D(symbolBox.Width * symbolCenter.X, symbolBox.Height * symbolCenter.Y);
+        let symbolMargins: SymbolMargins = symbolInfo.margins;
         psi.BorderLeft = -centerDistance.Width * scaleFactor;
         psi.BorderLeft = -centerDistance.Width * scaleFactor;
         psi.BorderRight = (symbolBox.Width - centerDistance.Width) * scaleFactor;
         psi.BorderRight = (symbolBox.Width - centerDistance.Width) * scaleFactor;
         psi.BorderTop = -centerDistance.Height * scaleFactor;
         psi.BorderTop = -centerDistance.Height * scaleFactor;
@@ -69,8 +69,8 @@ export class FontInfo {
             return this.symbolMapping[symbol].symbol;
             return this.symbolMapping[symbol].symbol;
         }
         }
         catch (ex) {
         catch (ex) {
-            Logger.DefaultLogger.LogError(LogLevel.DEBUG, "FontInfo.getString", ex);
-            return null;
+            Logging.debug("FontInfo.getString", ex);
+            return undefined;
         }
         }
 
 
     }
     }
@@ -79,215 +79,215 @@ export class FontInfo {
             return this.symbolMapping[symbol].scaleFactor;
             return this.symbolMapping[symbol].scaleFactor;
         }
         }
         catch (ex) {
         catch (ex) {
-            Logger.DefaultLogger.LogError(LogLevel.DEBUG, "FontInfo.getScaleFactor", ex);
+            Logging.debug("FontInfo.getScaleFactor", ex);
             return -1F;
             return -1F;
         }
         }
 
 
     }
     }
     private createSymbols(): void {
     private createSymbols(): void {
-        var scaleVector: number[] = 1,1, 3, 3, 3,
+        let scaleVector: number[] = 1,1, 3, 3, 3,
             3, 3, 3, 3,
             3, 3, 3, 3,
-            3, 1, 1, 7f,
-                3.5f, 4, 1, 1,
-                    2.0f, 3.4f,
-                        0.6f, 0.6f, 3, 2,
+            3, 1, 1, 7,
+                3.5, 4, 1, 1,
+                    2.0, 3.4,
+                        0.6, 0.6, 3, 2,
                             3, 4, 5,
                             3, 4, 5,
-                            2.2f, 2.55f, 2.5f, 2.2f, 1,
+                            2.2, 2.55, 2.5, 2.2, 1,
                                 2, 2, 2, 2,
                                 2, 2, 2, 2,
                                 2, 2, 2, 2,
                                 2, 2, 2, 2,
-                                2, 2, 0.4f,
+                                2, 2, 0.4,
                                     1, 1,
                                     1, 1,
-                                    1, 0.2f, 1, 1.5f, 1.5f,
-                                        0.75f * 2,
-                                            0.75f * 3,
-                                                0.75f * (1 + 1865.0f / 2680.0f),
-        0.75f * (1 + 1865.0f / 2680.0f),
-        0.75f * (1 + 1865.0f / 2680.0f),
-        0.75f * (1 + 1865.0f / 2680.0f),
-        2.7f, 3.0f,
-            2, 7.987f, 7.987f, 7.987f, 7.987f,
-                4.228f, 4.228f, 4.228f, 4.228f,
-                    1.25f, 0.75f, 1.05f, 0.85f, 1.05f,
-                        1.1f, 2, 1.9f,
-                            1.2f, 1.2f, 1.35f, 1.2f, 1.2f,
-                                1, 1.7f, 1.8f,
-                                    1.09f, 0.77f,
-                                        3.0f;
-        var centerVector: PointF_2D[] = new PointF_2D(0.5f, 0.5f),
-        new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.0f, 1.0f),
-            new PointF_2D(0.0f, 0.0f),
-            new PointF_2D(0.0f, 1.0f),
-            new PointF_2D(0.0f, 0.0f),
-            new PointF_2D(0.0f, 1.0f),
-            new PointF_2D(0.0f, 0.0f),
-            new PointF_2D(0.0f, 1.0f),
-            new PointF_2D(0.0f, 0.0f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(500.0f / 940.0f, 1660.0f / 2675.0f),
-            new PointF_2D(500.0f / 1830.0f, 760.0f / 2680.0f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(400.0f / 925.0f, 1210.0f / 2680.0f),
-            new PointF_2D(400.0f / 1500.0f, 360.0f / 2680.0f),
-            new PointF_2D(480.0f / 1190.0f, 260.0f / 2680.0f),
-            new PointF_2D(510.0f / 1040.0f, 190.0f / 2680.0f),
-            new PointF_2D(535.0f / 960.0f, 160.0f / 2680.0f),
-            new PointF_2D(400.0f / 990.0f, 1960.0f / 2680.0f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(785.0f / 1570.0f, 1960.0f / 2680.0f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.0f, 0.0f),
-            new PointF_2D(0.0f, 0.0f),
-            new PointF_2D(0.0f, 0.0f),
-            new PointF_2D(0.0f, 0.0f),
-            new PointF_2D(0.0f, 0.0f),
-            new PointF_2D(0.0f, 0.0f),
-            new PointF_2D(0.0f, 0.0f),
-            new PointF_2D(0.0f, 0.0f),
-            new PointF_2D(0.0f, 0.0f),
-            new PointF_2D(0.0f, 0.0f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(2880.0f / 5760.0f, 2250.0f / 2680.0f),
-            new PointF_2D(2850.0f / 5700.0f, 1810.0f / 2680.0f),
-            new PointF_2D(450.0f / 900.0f, 1560.0f / 2680.0f),
-            new PointF_2D(5250.0f / 10500.0f, 1340.0f / 2680.0f),
-            new PointF_2D(1787.0f / 3574.0f, 1340.0f / 2680.0f),
-            new PointF_2D(872.0f / 1744.0f, 1340.0f / 2680.0f),
-            new PointF_2D(872.0f / 1744.0f, 1340.0f / 2680.0f),
-            new PointF_2D(1500.0f / 3000.0f, 1865.0f / 2680.0f),
-            new PointF_2D(1100.0f / 2200.0f, 1865.0f / 2680.0f),
-            new PointF_2D(1000.0f / 2000.0f, 2680.0f / 2680.0f),
-            new PointF_2D(1250.0f / 2500.0f, 2680.0f / 2680.0f),
-            new PointF_2D(2330.0f / 4660.0f, 2680.0f / 2680.0f),
-            new PointF_2D(1430.0f / 2860.0f, 2680.0f / 2680.0f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.63f, 0.5448f),
-            new PointF_2D(0.63f, 0.667f),
-            new PointF_2D(0.63f, 0.5448f),
-            new PointF_2D(0.63f, 0.667f),
-            new PointF_2D(0.2f, 0.224f),
-            new PointF_2D(0.2f, 0.4067f),
-            new PointF_2D(0.2f, 0.224f),
-            new PointF_2D(0.2f, 0.4067f),
-            new PointF_2D(0.5f, 0.653f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.52f, 0.925f),
-            new PointF_2D(0.5f, 1f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.5f, 0.634f),
-            new PointF_2D(0.5f, 0.5f),
-            new PointF_2D(0.5f, 0.5f);
-        var marginVector: SymbolMargins[] = new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-        new SymbolMargins(0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f),
-            new SymbolMargins(0.05f, 0.05f, 0.05f, 0.05f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.05f, 0.05f),
-            new SymbolMargins(0.1f, 0.1f, 0.05f, 0.05f),
-            new SymbolMargins(0.1f, 0.1f, 0.05f, 0.05f),
-            new SymbolMargins(0.05f, 0.05f, 0.05f, 0.05f),
-            new SymbolMargins(0.1f, 0.1f),
-            new SymbolMargins(0.2f, 0.2f),
-            new SymbolMargins(0.2f, 0.2f),
-            new SymbolMargins(0.2f, 0.2f),
-            new SymbolMargins(0.2f, 0.2f),
-            new SymbolMargins(0.2f, 0.2f),
-            new SymbolMargins(0.2f, 0.2f),
-            new SymbolMargins(0.2f, 0.2f),
-            new SymbolMargins(0.2f, 0.2f),
-            new SymbolMargins(0.2f, 0.2f),
-            new SymbolMargins(0.2f, 0.2f),
-            new SymbolMargins(0.7f, 0.7f, 0.7f, 0.7f),
-            new SymbolMargins(0.2f, 0.2f, 0.3f, 0.3f),
-            new SymbolMargins(0.2f, 0.2f, 0.3f, 0.3f),
-            new SymbolMargins(0.1f, 0.1f, 0.2f, 0.2f),
-            new SymbolMargins(0.1f, 0.1f, 1.0f, 1.0f),
-            new SymbolMargins(0.1f, 0.1f, 0.2f, 0.2f),
-            new SymbolMargins(0.3f, 0.3f, 0.2f, 0.2f),
-            new SymbolMargins(0.3f, 0.3f, 0.2f, 0.2f),
-            new SymbolMargins(0.0f, 0.0f, 0.2f, 0.2f),
-            new SymbolMargins(0.0f, 0.0f, 0.2f, 0.2f),
-            new SymbolMargins(0.0f, 0.0f, 0.2f, 0.2f),
-            new SymbolMargins(0.0f, 0.0f, 0.2f, 0.2f),
-            new SymbolMargins(0.0f, 0.0f, 0.2f, 0.2f),
-            new SymbolMargins(0.0f, 0.0f, 0.2f, 0.2f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.05f, 0.05f, 0.05f, 0.05f),
-            new SymbolMargins(0.05f, 0.05f, 0.05f, 0.05f),
-            new SymbolMargins(0.05f, 0.05f, 0.05f, 0.05f),
-            new SymbolMargins(0.05f, 0.05f, 0.05f, 0.05f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f),
-            new SymbolMargins(0.1f, 0.1f, 0.1f, 0.1f);
-        var values: Array = Enum.GetValues(/*typeof*/MusicSymbol);
-        var i: number = 0;
-        for (var c: string = <string>0x21; c <<string>0x21 + values.Length; c++) {
-            var si: SymbolInfo = new SymbolInfo(c.ToString(), i, scaleVector[i], centerVector[i], marginVector[i]);
-            this.symbolMapping.Add(<MusicSymbol>values.GetValue(i), si);
+                                    1, 0.2, 1, 1.5, 1.5,
+                                        0.75 * 2,
+                                            0.75 * 3,
+                                                0.75 * (1 + 1865.0 / 2680.0),
+        0.75 * (1 + 1865.0 / 2680.0),
+        0.75 * (1 + 1865.0 / 2680.0),
+        0.75 * (1 + 1865.0 / 2680.0),
+        2.7, 3.0,
+            2, 7.987, 7.987, 7.987, 7.987,
+                4.228, 4.228, 4.228, 4.228,
+                    1.25, 0.75, 1.05, 0.85, 1.05,
+                        1.1, 2, 1.9,
+                            1.2, 1.2, 1.35, 1.2, 1.2,
+                                1, 1.7, 1.8,
+                                    1.09, 0.77,
+                                        3.0;
+        let centerVector: PointF_2D[] = new PointF_2D(0.5, 0.5),
+        new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.0, 1.0),
+            new PointF_2D(0.0, 0.0),
+            new PointF_2D(0.0, 1.0),
+            new PointF_2D(0.0, 0.0),
+            new PointF_2D(0.0, 1.0),
+            new PointF_2D(0.0, 0.0),
+            new PointF_2D(0.0, 1.0),
+            new PointF_2D(0.0, 0.0),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(500.0 / 940.0, 1660.0 / 2675.0),
+            new PointF_2D(500.0 / 1830.0, 760.0 / 2680.0),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(400.0 / 925.0, 1210.0 / 2680.0),
+            new PointF_2D(400.0 / 1500.0, 360.0 / 2680.0),
+            new PointF_2D(480.0 / 1190.0, 260.0 / 2680.0),
+            new PointF_2D(510.0 / 1040.0, 190.0 / 2680.0),
+            new PointF_2D(535.0 / 960.0, 160.0 / 2680.0),
+            new PointF_2D(400.0 / 990.0, 1960.0 / 2680.0),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(785.0 / 1570.0, 1960.0 / 2680.0),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.0, 0.0),
+            new PointF_2D(0.0, 0.0),
+            new PointF_2D(0.0, 0.0),
+            new PointF_2D(0.0, 0.0),
+            new PointF_2D(0.0, 0.0),
+            new PointF_2D(0.0, 0.0),
+            new PointF_2D(0.0, 0.0),
+            new PointF_2D(0.0, 0.0),
+            new PointF_2D(0.0, 0.0),
+            new PointF_2D(0.0, 0.0),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(2880.0 / 5760.0, 2250.0 / 2680.0),
+            new PointF_2D(2850.0 / 5700.0, 1810.0 / 2680.0),
+            new PointF_2D(450.0 / 900.0, 1560.0 / 2680.0),
+            new PointF_2D(5250.0 / 10500.0, 1340.0 / 2680.0),
+            new PointF_2D(1787.0 / 3574.0, 1340.0 / 2680.0),
+            new PointF_2D(872.0 / 1744.0, 1340.0 / 2680.0),
+            new PointF_2D(872.0 / 1744.0, 1340.0 / 2680.0),
+            new PointF_2D(1500.0 / 3000.0, 1865.0 / 2680.0),
+            new PointF_2D(1100.0 / 2200.0, 1865.0 / 2680.0),
+            new PointF_2D(1000.0 / 2000.0, 2680.0 / 2680.0),
+            new PointF_2D(1250.0 / 2500.0, 2680.0 / 2680.0),
+            new PointF_2D(2330.0 / 4660.0, 2680.0 / 2680.0),
+            new PointF_2D(1430.0 / 2860.0, 2680.0 / 2680.0),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.63, 0.5448),
+            new PointF_2D(0.63, 0.667),
+            new PointF_2D(0.63, 0.5448),
+            new PointF_2D(0.63, 0.667),
+            new PointF_2D(0.2, 0.224),
+            new PointF_2D(0.2, 0.4067),
+            new PointF_2D(0.2, 0.224),
+            new PointF_2D(0.2, 0.4067),
+            new PointF_2D(0.5, 0.653),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.52, 0.925),
+            new PointF_2D(0.5, 1),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.5, 0.634),
+            new PointF_2D(0.5, 0.5),
+            new PointF_2D(0.5, 0.5);
+        let marginVector: SymbolMargins[] = new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+        new SymbolMargins(0.1, 0.1),
+            new SymbolMargins(0.1, 0.1),
+            new SymbolMargins(0.1, 0.1),
+            new SymbolMargins(0.1, 0.1),
+            new SymbolMargins(0.1, 0.1),
+            new SymbolMargins(0.1, 0.1),
+            new SymbolMargins(0.1, 0.1),
+            new SymbolMargins(0.1, 0.1),
+            new SymbolMargins(0.1, 0.1),
+            new SymbolMargins(0.1, 0.1),
+            new SymbolMargins(0.1, 0.1),
+            new SymbolMargins(0.05, 0.05, 0.05, 0.05),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1),
+            new SymbolMargins(0.1, 0.1),
+            new SymbolMargins(0.1, 0.1),
+            new SymbolMargins(0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.05, 0.05),
+            new SymbolMargins(0.1, 0.1, 0.05, 0.05),
+            new SymbolMargins(0.1, 0.1, 0.05, 0.05),
+            new SymbolMargins(0.05, 0.05, 0.05, 0.05),
+            new SymbolMargins(0.1, 0.1),
+            new SymbolMargins(0.2, 0.2),
+            new SymbolMargins(0.2, 0.2),
+            new SymbolMargins(0.2, 0.2),
+            new SymbolMargins(0.2, 0.2),
+            new SymbolMargins(0.2, 0.2),
+            new SymbolMargins(0.2, 0.2),
+            new SymbolMargins(0.2, 0.2),
+            new SymbolMargins(0.2, 0.2),
+            new SymbolMargins(0.2, 0.2),
+            new SymbolMargins(0.2, 0.2),
+            new SymbolMargins(0.7, 0.7, 0.7, 0.7),
+            new SymbolMargins(0.2, 0.2, 0.3, 0.3),
+            new SymbolMargins(0.2, 0.2, 0.3, 0.3),
+            new SymbolMargins(0.1, 0.1, 0.2, 0.2),
+            new SymbolMargins(0.1, 0.1, 1.0, 1.0),
+            new SymbolMargins(0.1, 0.1, 0.2, 0.2),
+            new SymbolMargins(0.3, 0.3, 0.2, 0.2),
+            new SymbolMargins(0.3, 0.3, 0.2, 0.2),
+            new SymbolMargins(0.0, 0.0, 0.2, 0.2),
+            new SymbolMargins(0.0, 0.0, 0.2, 0.2),
+            new SymbolMargins(0.0, 0.0, 0.2, 0.2),
+            new SymbolMargins(0.0, 0.0, 0.2, 0.2),
+            new SymbolMargins(0.0, 0.0, 0.2, 0.2),
+            new SymbolMargins(0.0, 0.0, 0.2, 0.2),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.05, 0.05, 0.05, 0.05),
+            new SymbolMargins(0.05, 0.05, 0.05, 0.05),
+            new SymbolMargins(0.05, 0.05, 0.05, 0.05),
+            new SymbolMargins(0.05, 0.05, 0.05, 0.05),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1),
+            new SymbolMargins(0.1, 0.1, 0.1, 0.1);
+        let values: Array = Enum.GetValues(/*typeof*/MusicSymbol);
+        let i: number = 0;
+        for (let c: string = <string>0x21; c <<string>0x21 + values.Length; c++) {
+            let si: SymbolInfo = new SymbolInfo(c.ToString(), i, scaleVector[i], centerVector[i], marginVector[i]);
+            this.symbolMapping.push(<MusicSymbol>values.GetValue(i), si);
             i++;
             i++;
         }
         }
     }
     }

+ 2 - 2
src/MusicalScore/Graphical/GraphicalChordSymbolContainer.ts

@@ -20,9 +20,9 @@ export class GraphicalChordSymbolContainer extends GraphicalObject {
         return this.graphicalLabel;
         return this.graphicalLabel;
     }
     }
     private calculateLabel(textHeight: number, transposeHalftones: number): void {
     private calculateLabel(textHeight: number, transposeHalftones: number): void {
-        var text: string = ChordSymbolContainer.calculateChordText(this.chordSymbolContainer, transposeHalftones);
+        let text: string = ChordSymbolContainer.calculateChordText(this.chordSymbolContainer, transposeHalftones);
         this.graphicalLabel = new GraphicalLabel(new Label(text), textHeight, TextAlignment.CenterBottom, this.boundingBox);
         this.graphicalLabel = new GraphicalLabel(new Label(text), textHeight, TextAlignment.CenterBottom, this.boundingBox);
         this.graphicalLabel.PositionAndShape.RelativePosition = new PointF_2D(0.0, 0.0);
         this.graphicalLabel.PositionAndShape.RelativePosition = new PointF_2D(0.0, 0.0);
-        this.boundingBox.ChildElements.Add(this.graphicalLabel.PositionAndShape);
+        this.boundingBox.ChildElements.push(this.graphicalLabel.PositionAndShape);
     }
     }
 }
 }

+ 7 - 7
src/MusicalScore/Graphical/GraphicalLabel.ts

@@ -22,14 +22,14 @@ export class GraphicalLabel extends Clickable {
         return this.label;
         return this.label;
     }
     }
     public setLabelPositionAndShapeBorders(): void {
     public setLabelPositionAndShapeBorders(): void {
-        if (this.Label.Text.Trim().Equals(String.Empty))
-            return
-        var labelMarginBorderFactor: number = EngravingRules.Rules.LabelMarginBorderFactor;
+        if (this.Label.Text.Trim().Equals(""))
+            return;
+        let labelMarginBorderFactor: number = EngravingRules.Rules.LabelMarginBorderFactor;
 
 
-        var widthToHeightRatio: number = MusicSheetCalculator.TextMeasurer.computeTextWidthToHeightRatio(this.Label.Text, this.Label.Font, this.Label.FontStyle);
-        var height: number = this.Label.FontHeight;
-        var width: number = height * widthToHeightRatio;
-        var psi: BoundingBox = this.PositionAndShape;
+        let widthToHeightRatio: number = MusicSheetCalculator.TextMeasurer.computeTextWidthToHeightRatio(this.Label.Text, this.Label.Font, this.Label.FontStyle);
+        let height: number = this.Label.FontHeight;
+        let width: number = height * widthToHeightRatio;
+        let psi: BoundingBox = this.PositionAndShape;
         switch (this.Label.TextAlignment) {
         switch (this.Label.TextAlignment) {
             case TextAlignment.CenterBottom:
             case TextAlignment.CenterBottom:
                 psi.BorderTop = -height;
                 psi.BorderTop = -height;

+ 7 - 7
src/MusicalScore/Graphical/GraphicalLyricWord.ts

@@ -2,7 +2,7 @@
 import {GraphicalLyricEntry} from "./GraphicalLyricEntry";
 import {GraphicalLyricEntry} from "./GraphicalLyricEntry";
 export class GraphicalLyricWord {
 export class GraphicalLyricWord {
     private lyricWord: LyricWord;
     private lyricWord: LyricWord;
-    private graphicalLyricsEntries: List<GraphicalLyricEntry> = new List<GraphicalLyricEntry>();
+    private graphicalLyricsEntries: GraphicalLyricEntry[] = [];
     constructor(lyricWord: LyricWord) {
     constructor(lyricWord: LyricWord) {
         this.lyricWord = lyricWord;
         this.lyricWord = lyricWord;
         this.initialize();
         this.initialize();
@@ -10,20 +10,20 @@ export class GraphicalLyricWord {
     public get GetLyricWord(): LyricWord {
     public get GetLyricWord(): LyricWord {
         return this.lyricWord;
         return this.lyricWord;
     }
     }
-    public get GraphicalLyricsEntries(): List<GraphicalLyricEntry> {
+    public get GraphicalLyricsEntries(): GraphicalLyricEntry[] {
         return this.graphicalLyricsEntries;
         return this.graphicalLyricsEntries;
     }
     }
-    public set GraphicalLyricsEntries(value: List<GraphicalLyricEntry>) {
+    public set GraphicalLyricsEntries(value: GraphicalLyricEntry[]) {
         this.graphicalLyricsEntries = value;
         this.graphicalLyricsEntries = value;
     }
     }
     public isFilled(): boolean {
     public isFilled(): boolean {
-        for (var i: number = 0; i < this.graphicalLyricsEntries.Count; i++)
-            if (this.graphicalLyricsEntries[i] == null)
+        for (let i: number = 0; i < this.graphicalLyricsEntries.length; i++)
+            if (this.graphicalLyricsEntries[i] === undefined)
                 return false;
                 return false;
         return true;
         return true;
     }
     }
     private initialize(): void {
     private initialize(): void {
-        for (var i: number = 0; i < this.lyricWord.Syllables.Count; i++)
-            this.graphicalLyricsEntries.Add(null);
+        for (let i: number = 0; i < this.lyricWord.Syllables.length; i++)
+            this.graphicalLyricsEntries.push(undefined);
     }
     }
 }
 }

+ 13 - 14
src/MusicalScore/Graphical/GraphicalMusicPage.ts

@@ -6,23 +6,23 @@ import {EngravingRules} from "./EngravingRules";
 import {PointF_2D} from "../../Common/DataObjects/PointF_2D";
 import {PointF_2D} from "../../Common/DataObjects/PointF_2D";
 import {GraphicalMusicSheet} from "./GraphicalMusicSheet";
 import {GraphicalMusicSheet} from "./GraphicalMusicSheet";
 export class GraphicalMusicPage extends GraphicalObject {
 export class GraphicalMusicPage extends GraphicalObject {
-    private musicSystems: List<MusicSystem> = new List<MusicSystem>();
-    private labels: List<GraphicalLabel> = new List<GraphicalLabel>();
+    private musicSystems: MusicSystem[] = [];
+    private labels: GraphicalLabel[] = [];
     private parent: GraphicalMusicSheet;
     private parent: GraphicalMusicSheet;
     constructor(parent: GraphicalMusicSheet) {
     constructor(parent: GraphicalMusicSheet) {
         this.parent = parent;
         this.parent = parent;
-        this.boundingBox = new BoundingBox(null, this);
+        this.boundingBox = new BoundingBox(undefined, this);
     }
     }
-    public get MusicSystems(): List<MusicSystem> {
+    public get MusicSystems(): MusicSystem[] {
         return this.musicSystems;
         return this.musicSystems;
     }
     }
-    public set MusicSystems(value: List<MusicSystem>) {
+    public set MusicSystems(value: MusicSystem[]) {
         this.musicSystems = value;
         this.musicSystems = value;
     }
     }
-    public get Labels(): List<GraphicalLabel> {
+    public get Labels(): GraphicalLabel[] {
         return this.labels;
         return this.labels;
     }
     }
-    public set Labels(value: List<GraphicalLabel>) {
+    public set Labels(value: GraphicalLabel[]) {
         this.labels = value;
         this.labels = value;
     }
     }
     public get Parent(): GraphicalMusicSheet {
     public get Parent(): GraphicalMusicSheet {
@@ -32,18 +32,17 @@ export class GraphicalMusicPage extends GraphicalObject {
         this.parent = value;
         this.parent = value;
     }
     }
     public setMusicPageAbsolutePosition(pageIndex: number, rules: EngravingRules): PointF_2D {
     public setMusicPageAbsolutePosition(pageIndex: number, rules: EngravingRules): PointF_2D {
-        if (rules.PagePlacement == PagePlacementEnum.Down)
+        if (rules.PagePlacement === PagePlacementEnum.Down)
             return new PointF_2D(0.0, pageIndex * rules.PageHeight);
             return new PointF_2D(0.0, pageIndex * rules.PageHeight);
-        else if (rules.PagePlacement == PagePlacementEnum.Right)
+        else if (rules.PagePlacement === PagePlacementEnum.Right)
             return new PointF_2D(pageIndex * this.parent.ParentMusicSheet.PageWidth, 0.0);
             return new PointF_2D(pageIndex * this.parent.ParentMusicSheet.PageWidth, 0.0);
         else {
         else {
-            if (pageIndex % 2 == 0) {
-                if (pageIndex == 0)
+            if (pageIndex % 2 === 0) {
+                if (pageIndex === 0)
                     return new PointF_2D(0.0, pageIndex * rules.PageHeight);
                     return new PointF_2D(0.0, pageIndex * rules.PageHeight);
                 else return new PointF_2D(0.0, (pageIndex - 1) * rules.PageHeight);
                 else return new PointF_2D(0.0, (pageIndex - 1) * rules.PageHeight);
-            }
-            else {
-                if (pageIndex == 1)
+            } else {
+                if (pageIndex === 1)
                     return new PointF_2D(this.parent.ParentMusicSheet.PageWidth, (pageIndex - 1) * rules.PageHeight);
                     return new PointF_2D(this.parent.ParentMusicSheet.PageWidth, (pageIndex - 1) * rules.PageHeight);
                 else return new PointF_2D(this.parent.ParentMusicSheet.PageWidth, (pageIndex - 2) * rules.PageHeight);
                 else return new PointF_2D(this.parent.ParentMusicSheet.PageWidth, (pageIndex - 2) * rules.PageHeight);
             }
             }

+ 292 - 310
src/MusicalScore/Graphical/GraphicalMusicSheet.ts

@@ -23,22 +23,22 @@ import {MusicSheetCalculator} from "./MusicSheetCalculator";
 export class GraphicalMusicSheet {
 export class GraphicalMusicSheet {
     constructor(musicSheet: MusicSheet, calculator: MusicSheetCalculator) {
     constructor(musicSheet: MusicSheet, calculator: MusicSheetCalculator) {
         this.musicSheet = musicSheet;
         this.musicSheet = musicSheet;
-        this.numberOfStaves = this.musicSheet.Staves.Count;
+        this.numberOfStaves = this.musicSheet.Staves.length;
         this.calculator = calculator;
         this.calculator = calculator;
-        this.SourceToGraphicalMeasureLinks = new Dictionary<SourceMeasure, List<StaffMeasure>>();
+        this.SourceToGraphicalMeasureLinks = new Dictionary<SourceMeasure, StaffMeasure[]>();
         this.calculator.initialize(this);
         this.calculator.initialize(this);
     }
     }
     private musicSheet: MusicSheet;
     private musicSheet: MusicSheet;
     private fontInfo: FontInfo = this.FontInfo.Info;
     private fontInfo: FontInfo = this.FontInfo.Info;
     private calculator: MusicSheetCalculator;
     private calculator: MusicSheetCalculator;
-    private musicPages: List<GraphicalMusicPage> = new List<GraphicalMusicPage>();
-    private measureList: List<List<StaffMeasure>> = new List<List<StaffMeasure>>();
-    private verticalGraphicalStaffEntryContainers: List<VerticalGraphicalStaffEntryContainer> = new List<VerticalGraphicalStaffEntryContainer>();
+    private musicPages: GraphicalMusicPage[] = [];
+    private measureList: StaffMeasure[][] = [];
+    private verticalGraphicalStaffEntryContainers: VerticalGraphicalStaffEntryContainer[] = [];
     private title: GraphicalLabel;
     private title: GraphicalLabel;
     private subtitle: GraphicalLabel;
     private subtitle: GraphicalLabel;
     private composer: GraphicalLabel;
     private composer: GraphicalLabel;
     private lyricist: GraphicalLabel;
     private lyricist: GraphicalLabel;
-    private scoreFollowingLines: List<GraphicalLine> = new List<GraphicalLine>();
+    private scoreFollowingLines: GraphicalLine[] = [];
     private maxAllowedSystemWidth: number;
     private maxAllowedSystemWidth: number;
     private systemImages: Dictionary<MusicSystem, SystemImageProperties> = new Dictionary<MusicSystem, SystemImageProperties>();
     private systemImages: Dictionary<MusicSystem, SystemImageProperties> = new Dictionary<MusicSystem, SystemImageProperties>();
     private numberOfStaves: number;
     private numberOfStaves: number;
@@ -49,25 +49,25 @@ export class GraphicalMusicSheet {
     public get GetCalculator(): MusicSheetCalculator {
     public get GetCalculator(): MusicSheetCalculator {
         return this.calculator;
         return this.calculator;
     }
     }
-    public get MusicPages(): List<GraphicalMusicPage> {
+    public get MusicPages(): GraphicalMusicPage[] {
         return this.musicPages;
         return this.musicPages;
     }
     }
-    public set MusicPages(value: List<GraphicalMusicPage>) {
+    public set MusicPages(value: GraphicalMusicPage[]) {
         this.musicPages = value;
         this.musicPages = value;
     }
     }
     public get FontInfo(): FontInfo {
     public get FontInfo(): FontInfo {
         return this.fontInfo;
         return this.fontInfo;
     }
     }
-    public get MeasureList(): List<List<StaffMeasure>> {
+    public get MeasureList(): StaffMeasure[][] {
         return this.measureList;
         return this.measureList;
     }
     }
-    public set MeasureList(value: List<List<StaffMeasure>>) {
+    public set MeasureList(value: StaffMeasure[][]) {
         this.measureList = value;
         this.measureList = value;
     }
     }
-    public get VerticalGraphicalStaffEntryContainers(): List<VerticalGraphicalStaffEntryContainer> {
+    public get VerticalGraphicalStaffEntryContainers(): VerticalGraphicalStaffEntryContainer[] {
         return this.verticalGraphicalStaffEntryContainers;
         return this.verticalGraphicalStaffEntryContainers;
     }
     }
-    public set VerticalGraphicalStaffEntryContainers(value: List<VerticalGraphicalStaffEntryContainer>) {
+    public set VerticalGraphicalStaffEntryContainers(value: VerticalGraphicalStaffEntryContainer[]) {
         this.verticalGraphicalStaffEntryContainers = value;
         this.verticalGraphicalStaffEntryContainers = value;
     }
     }
     public get Title(): GraphicalLabel {
     public get Title(): GraphicalLabel {
@@ -94,7 +94,7 @@ export class GraphicalMusicSheet {
     public set Lyricist(value: GraphicalLabel) {
     public set Lyricist(value: GraphicalLabel) {
         this.lyricist = value;
         this.lyricist = value;
     }
     }
-    public get ScoreFollowingLines(): List<GraphicalLine> {
+    public get ScoreFollowingLines(): GraphicalLine[] {
         return this.scoreFollowingLines;
         return this.scoreFollowingLines;
     }
     }
     public get MaxAllowedSystemWidth(): number {
     public get MaxAllowedSystemWidth(): number {
@@ -106,7 +106,7 @@ export class GraphicalMusicSheet {
     public get SystemImages(): Dictionary<MusicSystem, SystemImageProperties> {
     public get SystemImages(): Dictionary<MusicSystem, SystemImageProperties> {
         return this.systemImages;
         return this.systemImages;
     }
     }
-    public SourceToGraphicalMeasureLinks: Dictionary<SourceMeasure, List<StaffMeasure>>;
+    public SourceToGraphicalMeasureLinks: Dictionary<SourceMeasure, StaffMeasure[]>;
     public get NumberOfStaves(): number {
     public get NumberOfStaves(): number {
         return this.numberOfStaves;
         return this.numberOfStaves;
     }
     }
@@ -117,16 +117,16 @@ export class GraphicalMusicSheet {
         this.leadSheet = value;
         this.leadSheet = value;
     }
     }
     public static transformRelativeToAbsolutePosition(graphicalMusicSheet: GraphicalMusicSheet): void {
     public static transformRelativeToAbsolutePosition(graphicalMusicSheet: GraphicalMusicSheet): void {
-        for (var i: number = 0; i < graphicalMusicSheet.MusicPages.Count; i++) {
-            var pageAbsolute: PointF_2D = graphicalMusicSheet.MusicPages[i].setMusicPageAbsolutePosition(i, graphicalMusicSheet.ParentMusicSheet.Rules);
-            var page: GraphicalMusicPage = graphicalMusicSheet.MusicPages[i];
+        for (let i: number = 0; i < graphicalMusicSheet.MusicPages.length; i++) {
+            let pageAbsolute: PointF_2D = graphicalMusicSheet.MusicPages[i].setMusicPageAbsolutePosition(i, graphicalMusicSheet.ParentMusicSheet.Rules);
+            let page: GraphicalMusicPage = graphicalMusicSheet.MusicPages[i];
             page.PositionAndShape.calculateAbsolutePositionsRecursive(pageAbsolute.X, pageAbsolute.Y);
             page.PositionAndShape.calculateAbsolutePositionsRecursive(pageAbsolute.X, pageAbsolute.Y);
         }
         }
     }
     }
     public Initialize(): void {
     public Initialize(): void {
-        this.verticalGraphicalStaffEntryContainers.Clear();
-        this.musicPages.Clear();
-        this.measureList.Clear();
+        this.verticalGraphicalStaffEntryContainers = [];
+        this.musicPages = [];
+        this.measureList = [];
     }
     }
     public reCalculate(): void {
     public reCalculate(): void {
         this.calculator.calculate();
         this.calculator.calculate();
@@ -135,88 +135,87 @@ export class GraphicalMusicSheet {
         this.calculator.prepareGraphicalMusicSheet();
         this.calculator.prepareGraphicalMusicSheet();
     }
     }
     public EnforceRedrawOfMusicSystems(): void {
     public EnforceRedrawOfMusicSystems(): void {
-        for (var idx: number = 0, len = this.musicPages.Count; idx < len; ++idx) {
-            var graphicalMusicPage: GraphicalMusicPage = this.musicPages[idx];
-            for (var idx2: number = 0, len2 = graphicalMusicPage.MusicSystems.Count; idx2 < len2; ++idx2) {
-                var musicSystem: MusicSystem = graphicalMusicPage.MusicSystems[idx2];
+        for (let idx: number = 0, len: number = this.musicPages.length; idx < len; ++idx) {
+            let graphicalMusicPage: GraphicalMusicPage = this.musicPages[idx];
+            for (let idx2: number = 0, len2: number = graphicalMusicPage.MusicSystems.length; idx2 < len2; ++idx2) {
+                let musicSystem: MusicSystem = graphicalMusicPage.MusicSystems[idx2];
                 musicSystem.NeedsToBeRedrawn = true;
                 musicSystem.NeedsToBeRedrawn = true;
             }
             }
         }
         }
     }
     }
     public getClickedObject<T>(positionOnMusicSheet: PointF_2D): T {
     public getClickedObject<T>(positionOnMusicSheet: PointF_2D): T {
-        for (var idx: number = 0, len = this.MusicPages.Count; idx < len; ++idx) {
-            var graphicalMusicPage: GraphicalMusicPage = this.MusicPages[idx];
+        for (let idx: number = 0, len: number = this.MusicPages.length; idx < len; ++idx) {
+            let graphicalMusicPage: GraphicalMusicPage = this.MusicPages[idx];
             return graphicalMusicPage.PositionAndShape.getClickedObjectOfType<T>(positionOnMusicSheet);
             return graphicalMusicPage.PositionAndShape.getClickedObjectOfType<T>(positionOnMusicSheet);
         }
         }
-        return null;
+        return undefined;
     }
     }
     public findGraphicalStaffEntryFromMeasureList(staffIndex: number, measureIndex: number,
     public findGraphicalStaffEntryFromMeasureList(staffIndex: number, measureIndex: number,
         sourceStaffEntry: SourceStaffEntry): GraphicalStaffEntry {
         sourceStaffEntry: SourceStaffEntry): GraphicalStaffEntry {
-        for (var i: number = measureIndex; i < this.measureList.Count; i++) {
-            var graphicalMeasure: StaffMeasure = this.measureList[i][staffIndex];
-            for (var idx: number = 0, len = graphicalMeasure.StaffEntries.Count; idx < len; ++idx) {
-                var graphicalStaffEntry: GraphicalStaffEntry = graphicalMeasure.StaffEntries[idx];
-                if (graphicalStaffEntry.SourceStaffEntry == sourceStaffEntry)
+        for (let i: number = measureIndex; i < this.measureList.length; i++) {
+            let graphicalMeasure: StaffMeasure = this.measureList[i][staffIndex];
+            for (let idx: number = 0, len: number = graphicalMeasure.StaffEntries.length; idx < len; ++idx) {
+                let graphicalStaffEntry: GraphicalStaffEntry = graphicalMeasure.StaffEntries[idx];
+                if (graphicalStaffEntry.SourceStaffEntry === sourceStaffEntry)
                     return graphicalStaffEntry;
                     return graphicalStaffEntry;
             }
             }
         }
         }
-        return null;
+        return undefined;
     }
     }
     public findNextGraphicalStaffEntry(staffIndex: number, measureIndex: number,
     public findNextGraphicalStaffEntry(staffIndex: number, measureIndex: number,
         graphicalStaffEntry: GraphicalStaffEntry): GraphicalStaffEntry {
         graphicalStaffEntry: GraphicalStaffEntry): GraphicalStaffEntry {
-        var graphicalMeasure: StaffMeasure = graphicalStaffEntry.ParentMeasure;
-        var graphicalStaffEntryIndex: number = graphicalMeasure.StaffEntries.IndexOf(graphicalStaffEntry);
-        if (graphicalStaffEntryIndex < graphicalMeasure.StaffEntries.Count - 1) {
+        let graphicalMeasure: StaffMeasure = graphicalStaffEntry.ParentMeasure;
+        let graphicalStaffEntryIndex: number = graphicalMeasure.StaffEntries.indexOf(graphicalStaffEntry);
+        if (graphicalStaffEntryIndex < graphicalMeasure.StaffEntries.length - 1) {
             return graphicalMeasure.StaffEntries[graphicalStaffEntryIndex + 1];
             return graphicalMeasure.StaffEntries[graphicalStaffEntryIndex + 1];
-        }
-        else if (measureIndex < this.measureList.Count - 1) {
-            var nextMeasure: StaffMeasure = this.measureList[measureIndex + 1][staffIndex];
-            if (nextMeasure.StaffEntries.Count > 0)
+        } else if (measureIndex < this.measureList.length - 1) {
+            let nextMeasure: StaffMeasure = this.measureList[measureIndex + 1][staffIndex];
+            if (nextMeasure.StaffEntries.length > 0)
                 return nextMeasure.StaffEntries[0];
                 return nextMeasure.StaffEntries[0];
         }
         }
-        return null;
+        return undefined;
     }
     }
-    public getFirstVisibleMeasuresListFromIndeces(start: number, end: number): List<StaffMeasure> {
-        var graphicalMeasures: List<StaffMeasure> = new List<StaffMeasure>();
-        var numberOfStaves: number = this.measureList[0].Count;
-        for (var i: number = start; i <= end; i++)
-            for (var j: number = 0; j < numberOfStaves; j++)
+    public getFirstVisibleMeasuresListFromIndeces(start: number, end: number): StaffMeasure[] {
+        let graphicalMeasures: StaffMeasure[] = [];
+        let numberOfStaves: number = this.measureList[0].length;
+        for (let i: number = start; i <= end; i++)
+            for (let j: number = 0; j < numberOfStaves; j++)
                 if (this.measureList[i][j].isVisible()) {
                 if (this.measureList[i][j].isVisible()) {
-                    graphicalMeasures.Add(this.measureList[i][j]);
+                    graphicalMeasures.push(this.measureList[i][j]);
                     break;
                     break;
                 }
                 }
         return graphicalMeasures;
         return graphicalMeasures;
     }
     }
-    public orderMeasuresByStaffLine(measures: List<StaffMeasure>): List<List<StaffMeasure>> {
-        var orderedMeasures: List<List<StaffMeasure>> = new List<List<StaffMeasure>>();
-        var mList: List<StaffMeasure> = new List<StaffMeasure>();
-        orderedMeasures.Add(mList);
-        for (var i: number = 0; i < measures.Count; i++) {
-            if (i == 0)
-                mList.Add(measures[0]);
+    public orderMeasuresByStaffLine(measures: StaffMeasure[]): StaffMeasure[][] {
+        let orderedMeasures: StaffMeasure[][] = [];
+        let mList: StaffMeasure[] = [];
+        orderedMeasures.push(mList);
+        for (let i: number = 0; i < measures.length; i++) {
+            if (i === 0)
+                mList.push(measures[0]);
             else {
             else {
-                if (measures[i].ParentStaffLine == measures[i - 1].ParentStaffLine)
-                    mList.Add(measures[i]);
+                if (measures[i].ParentStaffLine === measures[i - 1].ParentStaffLine)
+                    mList.push(measures[i]);
                 else {
                 else {
-                    if (!orderedMeasures.Contains(mList))
-                        orderedMeasures.Add(mList);
-                    mList = new List<StaffMeasure>();
-                    orderedMeasures.Add(mList);
-                    mList.Add(measures[i]);
+                    if (!orderedMeasures.indexOf(mList) !== -1)
+                        orderedMeasures.push(mList);
+                    mList = [];
+                    orderedMeasures.push(mList);
+                    mList.push(measures[i]);
                 }
                 }
             }
             }
         }
         }
         return orderedMeasures;
         return orderedMeasures;
     }
     }
-    public initializeActiveClefs(): List<ClefInstruction> {
-        var activeClefs: List<ClefInstruction> = new List<ClefInstruction>();
-        var firstSourceMeasure: SourceMeasure = this.musicSheet.getFirstSourceMeasure();
-        if (firstSourceMeasure != null) {
-            for (var i: number = 0; i < firstSourceMeasure.CompleteNumberOfStaves; i++) {
-                for (var idx: number = 0, len = firstSourceMeasure.FirstInstructionsStaffEntries[i].Instructions.Count; idx < len; ++idx) {
-                    var abstractNotationInstruction: AbstractNotationInstruction = firstSourceMeasure.FirstInstructionsStaffEntries[i].Instructions[idx];
+    public initializeActiveClefs(): ClefInstruction[] {
+        let activeClefs: ClefInstruction[] = [];
+        let firstSourceMeasure: SourceMeasure = this.musicSheet.getFirstSourceMeasure();
+        if (firstSourceMeasure !== undefined) {
+            for (let i: number = 0; i < firstSourceMeasure.CompleteNumberOfStaves; i++) {
+                for (let idx: number = 0, len: number = firstSourceMeasure.FirstInstructionsStaffEntries[i].Instructions.length; idx < len; ++idx) {
+                    let abstractNotationInstruction: AbstractNotationInstruction = firstSourceMeasure.FirstInstructionsStaffEntries[i].Instructions[idx];
                     if (abstractNotationInstruction instanceof ClefInstruction) {
                     if (abstractNotationInstruction instanceof ClefInstruction) {
-                        activeClefs.Add(<ClefInstruction>abstractNotationInstruction);
+                        activeClefs.push(<ClefInstruction>abstractNotationInstruction);
                     }
                     }
                 }
                 }
             }
             }
@@ -224,107 +223,102 @@ export class GraphicalMusicSheet {
         return activeClefs;
         return activeClefs;
     }
     }
     public GetMainKey(): KeyInstruction {
     public GetMainKey(): KeyInstruction {
-        var firstSourceMeasure: SourceMeasure = this.musicSheet.getFirstSourceMeasure();
-        if (firstSourceMeasure != null) {
-            for (var i: number = 0; i < firstSourceMeasure.CompleteNumberOfStaves; i++) {
-                for (var idx: number = 0, len = firstSourceMeasure.FirstInstructionsStaffEntries[i].Instructions.Count; idx < len; ++idx) {
-                    var abstractNotationInstruction: AbstractNotationInstruction = firstSourceMeasure.FirstInstructionsStaffEntries[i].Instructions[idx];
+        let firstSourceMeasure: SourceMeasure = this.musicSheet.getFirstSourceMeasure();
+        if (firstSourceMeasure !== undefined) {
+            for (let i: number = 0; i < firstSourceMeasure.CompleteNumberOfStaves; i++) {
+                for (let idx: number = 0, len: number = firstSourceMeasure.FirstInstructionsStaffEntries[i].Instructions.length; idx < len; ++idx) {
+                    let abstractNotationInstruction: AbstractNotationInstruction = firstSourceMeasure.FirstInstructionsStaffEntries[i].Instructions[idx];
                     if (abstractNotationInstruction instanceof KeyInstruction) {
                     if (abstractNotationInstruction instanceof KeyInstruction) {
                         return <KeyInstruction>abstractNotationInstruction;
                         return <KeyInstruction>abstractNotationInstruction;
                     }
                     }
                 }
                 }
             }
             }
         }
         }
-        return null;
+        return undefined;
     }
     }
     public getOrCreateVerticalContainer(timestamp: Fraction): VerticalGraphicalStaffEntryContainer {
     public getOrCreateVerticalContainer(timestamp: Fraction): VerticalGraphicalStaffEntryContainer {
-        if (this.verticalGraphicalStaffEntryContainers.Count == 0 || timestamp > this.verticalGraphicalStaffEntryContainers.Last().AbsoluteTimestamp) {
-            var verticalGraphicalStaffEntryContainer: VerticalGraphicalStaffEntryContainer = new VerticalGraphicalStaffEntryContainer(this.numberOfStaves, timestamp);
-            this.verticalGraphicalStaffEntryContainers.Add(verticalGraphicalStaffEntryContainer);
+        if (this.verticalGraphicalStaffEntryContainers.length === 0 || timestamp > this.verticalGraphicalStaffEntryContainers.Last().AbsoluteTimestamp) {
+            let verticalGraphicalStaffEntryContainer: VerticalGraphicalStaffEntryContainer = new VerticalGraphicalStaffEntryContainer(this.numberOfStaves, timestamp);
+            this.verticalGraphicalStaffEntryContainers.push(verticalGraphicalStaffEntryContainer);
             return verticalGraphicalStaffEntryContainer;
             return verticalGraphicalStaffEntryContainer;
         }
         }
-        var i: number;
+        let i: number;
         for (; i >= 0; i--) {
         for (; i >= 0; i--) {
             if (this.verticalGraphicalStaffEntryContainers[i].AbsoluteTimestamp < timestamp) {
             if (this.verticalGraphicalStaffEntryContainers[i].AbsoluteTimestamp < timestamp) {
-                var verticalGraphicalStaffEntryContainer: VerticalGraphicalStaffEntryContainer = new VerticalGraphicalStaffEntryContainer(this.numberOfStaves, timestamp);
-                this.verticalGraphicalStaffEntryContainers.Insert(i + 1, verticalGraphicalStaffEntryContainer);
+                let verticalGraphicalStaffEntryContainer: VerticalGraphicalStaffEntryContainer = new VerticalGraphicalStaffEntryContainer(this.numberOfStaves, timestamp);
+                this.verticalGraphicalStaffEntryContainers.splice(i + 1, 0, verticalGraphicalStaffEntryContainer);
                 return verticalGraphicalStaffEntryContainer;
                 return verticalGraphicalStaffEntryContainer;
             }
             }
-            if (this.verticalGraphicalStaffEntryContainers[i].AbsoluteTimestamp == timestamp)
+            if (this.verticalGraphicalStaffEntryContainers[i].AbsoluteTimestamp === timestamp)
                 return this.verticalGraphicalStaffEntryContainers[i];
                 return this.verticalGraphicalStaffEntryContainers[i];
         }
         }
-        return null;
+        return undefined;
     }
     }
     public GetVerticalContainerFromTimestamp(timestamp: Fraction, startIndex: number): VerticalGraphicalStaffEntryContainer {
     public GetVerticalContainerFromTimestamp(timestamp: Fraction, startIndex: number): VerticalGraphicalStaffEntryContainer {
-        var index: number = this.verticalGraphicalStaffEntryContainers.BinarySearch(startIndex,
-            this.verticalGraphicalStaffEntryContainers.Count - startIndex,
+        let index: number = this.verticalGraphicalStaffEntryContainers.BinarySearch(startIndex,
+            this.verticalGraphicalStaffEntryContainers.length - startIndex,
             new VerticalGraphicalStaffEntryContainer(0,
             new VerticalGraphicalStaffEntryContainer(0,
                 timestamp),
                 timestamp),
             new VerticalGraphicalStaffEntryContainer.VgseContainerTimestampComparer());
             new VerticalGraphicalStaffEntryContainer.VgseContainerTimestampComparer());
         if (index >= 0)
         if (index >= 0)
             return this.verticalGraphicalStaffEntryContainers[index];
             return this.verticalGraphicalStaffEntryContainers[index];
-        return null;
+        return undefined;
     }
     }
     public GetVerticalContainerFromTimestamp(timestamp: Fraction): VerticalGraphicalStaffEntryContainer {
     public GetVerticalContainerFromTimestamp(timestamp: Fraction): VerticalGraphicalStaffEntryContainer {
-        var index: number = this.verticalGraphicalStaffEntryContainers.BinarySearch(new VerticalGraphicalStaffEntryContainer(0, timestamp),
+        let index: number = this.verticalGraphicalStaffEntryContainers.BinarySearch(new VerticalGraphicalStaffEntryContainer(0, timestamp),
             new VerticalGraphicalStaffEntryContainer.VgseContainerTimestampComparer());
             new VerticalGraphicalStaffEntryContainer.VgseContainerTimestampComparer());
         if (index >= 0)
         if (index >= 0)
             return this.verticalGraphicalStaffEntryContainers[index];
             return this.verticalGraphicalStaffEntryContainers[index];
-        return null;
+        return undefined;
     }
     }
     public GetInterpolatedIndexInVerticalContainers(musicTimestamp: Fraction): number {
     public GetInterpolatedIndexInVerticalContainers(musicTimestamp: Fraction): number {
-        var containers: List<VerticalGraphicalStaffEntryContainer> = this.verticalGraphicalStaffEntryContainers;
-        var leftIndex: number = 0;
-        var rightIndex: number = containers.Count - 1;
-        var foundIndex: number;
-        var leftTS: Fraction = null;
-        var rightTS: Fraction = null;
+        let containers: VerticalGraphicalStaffEntryContainer[] = this.verticalGraphicalStaffEntryContainers;
+        let leftIndex: number = 0;
+        let rightIndex: number = containers.length - 1;
+        let foundIndex: number;
+        let leftTS: Fraction = undefined;
+        let rightTS: Fraction = undefined;
         if (musicTimestamp <= containers.Last().AbsoluteTimestamp) {
         if (musicTimestamp <= containers.Last().AbsoluteTimestamp) {
             while (rightIndex - leftIndex > 1) {
             while (rightIndex - leftIndex > 1) {
-                var middleIndex: number = (rightIndex + leftIndex) / 2;
-                if (containers[leftIndex].AbsoluteTimestamp == musicTimestamp) {
+                let middleIndex: number = (rightIndex + leftIndex) / 2;
+                if (containers[leftIndex].AbsoluteTimestamp === musicTimestamp) {
                     rightIndex = leftIndex;
                     rightIndex = leftIndex;
                     break;
                     break;
-                }
-                else if (containers[rightIndex].AbsoluteTimestamp == musicTimestamp) {
+                } else if (containers[rightIndex].AbsoluteTimestamp === musicTimestamp) {
                     leftIndex = rightIndex;
                     leftIndex = rightIndex;
                     break;
                     break;
-                }
-                else if (containers[middleIndex].AbsoluteTimestamp == musicTimestamp) {
-                    return this.verticalGraphicalStaffEntryContainers.IndexOf(containers[middleIndex]);
-                }
-                else if (containers[middleIndex].AbsoluteTimestamp > musicTimestamp) {
+                } else if (containers[middleIndex].AbsoluteTimestamp === musicTimestamp) {
+                    return this.verticalGraphicalStaffEntryContainers.indexOf(containers[middleIndex]);
+                } else if (containers[middleIndex].AbsoluteTimestamp > musicTimestamp) {
                     rightIndex = middleIndex;
                     rightIndex = middleIndex;
-                }
-                else {
+                } else {
                     leftIndex = middleIndex;
                     leftIndex = middleIndex;
                 }
                 }
             }
             }
-            if (leftIndex == rightIndex)
-                return this.verticalGraphicalStaffEntryContainers.IndexOf(containers[leftIndex]);
+            if (leftIndex === rightIndex)
+                return this.verticalGraphicalStaffEntryContainers.indexOf(containers[leftIndex]);
             leftTS = containers[leftIndex].AbsoluteTimestamp;
             leftTS = containers[leftIndex].AbsoluteTimestamp;
             rightTS = containers[rightIndex].AbsoluteTimestamp;
             rightTS = containers[rightIndex].AbsoluteTimestamp;
-        }
-        else {
+        } else {
             leftTS = containers.Last().AbsoluteTimestamp;
             leftTS = containers.Last().AbsoluteTimestamp;
-            rightTS = new Fraction(getLongestStaffEntryDuration(containers.Count - 1) + leftTS);
-            rightIndex = containers.Count;
+            rightTS = new Fraction(getLongestStaffEntryDuration(containers.length - 1) + leftTS);
+            rightIndex = containers.length;
         }
         }
-        var diff: number = rightTS.RealValue - leftTS.RealValue;
-        var diffTS: number = rightTS.RealValue - musicTimestamp.RealValue;
+        let diff: number = rightTS.RealValue - leftTS.RealValue;
+        let diffTS: number = rightTS.RealValue - musicTimestamp.RealValue;
         foundIndex = rightIndex - (diffTS / diff);
         foundIndex = rightIndex - (diffTS / diff);
-        return Math.Min(foundIndex, this.verticalGraphicalStaffEntryContainers.Count);
+        return Math.min(foundIndex, this.verticalGraphicalStaffEntryContainers.length);
     }
     }
     private getLongestStaffEntryDuration(index: number): Fraction {
     private getLongestStaffEntryDuration(index: number): Fraction {
-        var maxLength: Fraction = new Fraction(0, 1);
-        for (var idx: number = 0, len = this.verticalGraphicalStaffEntryContainers[index].StaffEntries.Count; idx < len; ++idx) {
-            var graphicalStaffEntry: GraphicalStaffEntry = this.verticalGraphicalStaffEntryContainers[index].StaffEntries[idx];
-            if (graphicalStaffEntry == null)
+        let maxLength: Fraction = new Fraction(0, 1);
+        for (let idx: number = 0, len: number = this.verticalGraphicalStaffEntryContainers[index].StaffEntries.length; idx < len; ++idx) {
+            let graphicalStaffEntry: GraphicalStaffEntry = this.verticalGraphicalStaffEntryContainers[index].StaffEntries[idx];
+            if (graphicalStaffEntry === undefined)
                 continue;
                 continue;
-            for (var idx2: number = 0, len2 = graphicalStaffEntry.Notes.Count; idx2 < len2; ++idx2) {
-                var graphicalNotes: List<GraphicalNote> = graphicalStaffEntry.Notes[idx2];
-                for (var idx3: number = 0, len3 = graphicalNotes.Count; idx3 < len3; ++idx3) {
-                    var note: GraphicalNote = graphicalNotes[idx3];
+            for (let idx2: number = 0, len2: number = graphicalStaffEntry.Notes.length; idx2 < len2; ++idx2) {
+                let graphicalNotes: GraphicalNote[] = graphicalStaffEntry.Notes[idx2];
+                for (let idx3: number = 0, len3: number = graphicalNotes.length; idx3 < len3; ++idx3) {
+                    let note: GraphicalNote = graphicalNotes[idx3];
                     if (note.GraphicalNoteLength > maxLength)
                     if (note.GraphicalNoteLength > maxLength)
                         maxLength = note.GraphicalNoteLength;
                         maxLength = note.GraphicalNoteLength;
                 }
                 }
@@ -332,37 +326,37 @@ export class GraphicalMusicSheet {
         }
         }
         return maxLength;
         return maxLength;
     }
     }
-    public getVisibleStavesIndecesFromSourceMeasure(visibleMeasures: List<StaffMeasure>): List<number> {
-        var visibleInstruments: List<Instrument> = new List<Instrument>();
-        var visibleStavesIndeces: List<number> = new List<number>();
-        for (var idx: number = 0, len = visibleMeasures.Count; idx < len; ++idx) {
-            var graphicalMeasure: StaffMeasure = visibleMeasures[idx];
-            var instrument: Instrument = graphicalMeasure.ParentStaff.ParentInstrument;
-            if (!visibleInstruments.Contains(instrument))
-                visibleInstruments.Add(instrument);
-        }
-        for (var idx: number = 0, len = visibleInstruments.Count; idx < len; ++idx) {
-            var instrument: Instrument = visibleInstruments[idx];
-            var index: number = this.musicSheet.GetGlobalStaffIndexOfFirstStaff(instrument);
-            for (var j: number = 0; j < instrument.Staves.Count; j++)
-                visibleStavesIndeces.Add(index + j);
+    public getVisibleStavesIndecesFromSourceMeasure(visibleMeasures: StaffMeasure[]): number[] {
+        let visibleInstruments: Instrument[] = [];
+        let visibleStavesIndeces: number[] = [];
+        for (let idx: number = 0, len: number = visibleMeasures.length; idx < len; ++idx) {
+            let graphicalMeasure: StaffMeasure = visibleMeasures[idx];
+            let instrument: Instrument = graphicalMeasure.ParentStaff.ParentInstrument;
+            if (!visibleInstruments.indexOf(instrument) !== -1)
+                visibleInstruments.push(instrument);
+        }
+        for (let idx: number = 0, len: number = visibleInstruments.length; idx < len; ++idx) {
+            let instrument: Instrument = visibleInstruments[idx];
+            let index: number = this.musicSheet.GetGlobalStaffIndexOfFirstStaff(instrument);
+            for (let j: number = 0; j < instrument.Staves.length; j++)
+                visibleStavesIndeces.push(index + j);
         }
         }
         return visibleStavesIndeces;
         return visibleStavesIndeces;
     }
     }
     public getGraphicalMeasureFromSourceMeasureAndIndex(sourceMeasure: SourceMeasure, index: number): StaffMeasure {
     public getGraphicalMeasureFromSourceMeasureAndIndex(sourceMeasure: SourceMeasure, index: number): StaffMeasure {
-        for (var i: number = 0; i < this.measureList.Count; i++) {
-            if (this.measureList[i][0].ParentSourceMeasure == sourceMeasure)
+        for (let i: number = 0; i < this.measureList.length; i++) {
+            if (this.measureList[i][0].ParentSourceMeasure === sourceMeasure)
                 return this.measureList[i][index];
                 return this.measureList[i][index];
         }
         }
-        return null;
+        return undefined;
     }
     }
     public getMeasureIndex(graphicalMeasure: StaffMeasure, measureIndex: number, inListIndex: number): boolean {
     public getMeasureIndex(graphicalMeasure: StaffMeasure, measureIndex: number, inListIndex: number): boolean {
         measureIndex = 0;
         measureIndex = 0;
         inListIndex = 0;
         inListIndex = 0;
-        for (; measureIndex < this.measureList.Count; measureIndex++) {
-            for (var idx: number = 0, len = this.measureList[measureIndex].Count; idx < len; ++idx) {
-                var measure: StaffMeasure = this.measureList[measureIndex][idx];
-                if (measure == graphicalMeasure)
+        for (; measureIndex < this.measureList.length; measureIndex++) {
+            for (let idx: number = 0, len: number = this.measureList[measureIndex].length; idx < len; ++idx) {
+                let measure: StaffMeasure = this.measureList[measureIndex][idx];
+                if (measure === graphicalMeasure)
                     return true;
                     return true;
             }
             }
         }
         }
@@ -372,130 +366,127 @@ export class GraphicalMusicSheet {
         return this.getMeasureIndex(entry.ParentMeasure, measureIndex, inListIndex);
         return this.getMeasureIndex(entry.ParentMeasure, measureIndex, inListIndex);
     }
     }
     public GetNearesNote(clickPosition: PointF_2D, maxClickDist: PointF_2D): GraphicalNote {
     public GetNearesNote(clickPosition: PointF_2D, maxClickDist: PointF_2D): GraphicalNote {
-        var initialSearchArea: number = 10;
-        var foundNotes: List<GraphicalNote> = new List<GraphicalNote>();
-        var region: BoundingBox = new BoundingBox(null);
+        let initialSearchArea: number = 10;
+        let foundNotes: GraphicalNote[] = [];
+        let region: BoundingBox = new BoundingBox(undefined);
         region.BorderLeft = clickPosition.X - initialSearchArea;
         region.BorderLeft = clickPosition.X - initialSearchArea;
         region.BorderTop = clickPosition.Y - initialSearchArea;
         region.BorderTop = clickPosition.Y - initialSearchArea;
         region.BorderRight = clickPosition.X + initialSearchArea;
         region.BorderRight = clickPosition.X + initialSearchArea;
         region.BorderBottom = clickPosition.Y + initialSearchArea;
         region.BorderBottom = clickPosition.Y + initialSearchArea;
         region.AbsolutePosition = new PointF_2D(0, 0);
         region.AbsolutePosition = new PointF_2D(0, 0);
-        for (var idx: number = 0, len = this.MusicPages.Count; idx < len; ++idx) {
-            var graphicalMusicPage: GraphicalMusicPage = this.MusicPages[idx];
-            var entries: IEnumerable<GraphicalNote> = graphicalMusicPage.PositionAndShape.getObjectsInRegion<GraphicalNote>(region);
-            var entriesArr: GraphicalNote[] = __as__<GraphicalNote[]>(entries, GraphicalNote[]) ?? entries.ToArray();
-            if (entries == null) {
+        for (let idx: number = 0, len: number = this.MusicPages.length; idx < len; ++idx) {
+            let graphicalMusicPage: GraphicalMusicPage = this.MusicPages[idx];
+            let entries: GraphicalNote[] = graphicalMusicPage.PositionAndShape.getObjectsInRegion<GraphicalNote>(region);
+            let entriesArr: GraphicalNote[] = __as__<GraphicalNote[]>(entries, GraphicalNote[]) ?? entries;
+            if (entries === undefined) {
                 continue;
                 continue;
-            }
-            else {
-                for (var idx2: number = 0, len2 = entriesArr.length; idx2 < len2; ++idx2) {
-                    var note: GraphicalNote = entriesArr[idx2];
-                    if (Math.Abs(note.PositionAndShape.AbsolutePosition.X - clickPosition.X) < maxClickDist.X && Math.Abs(note.PositionAndShape.AbsolutePosition.Y - clickPosition.Y) < maxClickDist.Y)
-                        foundNotes.Add(note);
+            } else {
+                for (let idx2: number = 0, len2: number = entriesArr.length; idx2 < len2; ++idx2) {
+                    let note: GraphicalNote = entriesArr[idx2];
+                    if (Math.abs(note.PositionAndShape.AbsolutePosition.X - clickPosition.X) < maxClickDist.X && Math.abs(note.PositionAndShape.AbsolutePosition.Y - clickPosition.Y) < maxClickDist.Y)
+                        foundNotes.push(note);
                 }
                 }
             }
             }
         }
         }
-        var closest: GraphicalNote = null;
-        for (var idx: number = 0, len = foundNotes.Count; idx < len; ++idx) {
-            var note: GraphicalNote = foundNotes[idx];
-            if (closest == null)
+        let closest: GraphicalNote = undefined;
+        for (let idx: number = 0, len: number = foundNotes.length; idx < len; ++idx) {
+            let note: GraphicalNote = foundNotes[idx];
+            if (closest === undefined)
                 closest = note;
                 closest = note;
             else {
             else {
-                if (note.ParentStaffEntry.RelInMeasureTimestamp == null)
+                if (note.ParentStaffEntry.RelInMeasureTimestamp === undefined)
                     continue;
                     continue;
-                var deltaNew: number = this.CalculateDistance(note.PositionAndShape.AbsolutePosition, clickPosition);
-                var deltaOld: number = this.CalculateDistance(closest.PositionAndShape.AbsolutePosition, clickPosition);
+                let deltaNew: number = this.CalculateDistance(note.PositionAndShape.AbsolutePosition, clickPosition);
+                let deltaOld: number = this.CalculateDistance(closest.PositionAndShape.AbsolutePosition, clickPosition);
                 if (deltaNew < deltaOld)
                 if (deltaNew < deltaOld)
                     closest = note;
                     closest = note;
             }
             }
         }
         }
-        if (closest != null)
+        if (closest !== undefined)
             return closest;
             return closest;
-        return null;
+        return undefined;
     }
     }
     public GetClickableLabel(clickPosition: PointF_2D): GraphicalLabel {
     public GetClickableLabel(clickPosition: PointF_2D): GraphicalLabel {
-        var initialSearchAreaX: number = 4;
-        var initialSearchAreaY: number = 4;
-        var region: BoundingBox = new BoundingBox(null);
+        let initialSearchAreaX: number = 4;
+        let initialSearchAreaY: number = 4;
+        let region: BoundingBox = new BoundingBox(undefined);
         region.BorderLeft = clickPosition.X - initialSearchAreaX;
         region.BorderLeft = clickPosition.X - initialSearchAreaX;
         region.BorderTop = clickPosition.Y - initialSearchAreaY;
         region.BorderTop = clickPosition.Y - initialSearchAreaY;
         region.BorderRight = clickPosition.X + initialSearchAreaX;
         region.BorderRight = clickPosition.X + initialSearchAreaX;
         region.BorderBottom = clickPosition.Y + initialSearchAreaY;
         region.BorderBottom = clickPosition.Y + initialSearchAreaY;
         region.AbsolutePosition = new PointF_2D(0, 0);
         region.AbsolutePosition = new PointF_2D(0, 0);
-        for (var idx: number = 0, len = this.MusicPages.Count; idx < len; ++idx) {
-            var graphicalMusicPage: GraphicalMusicPage = this.MusicPages[idx];
-            var entries: GraphicalLabel[] = graphicalMusicPage.PositionAndShape.getObjectsInRegion<GraphicalLabel>(region).ToArray();
-            if (entries.length != 1) {
+        for (let idx: number = 0, len: number = this.MusicPages.length; idx < len; ++idx) {
+            let graphicalMusicPage: GraphicalMusicPage = this.MusicPages[idx];
+            let entries: GraphicalLabel[] = graphicalMusicPage.PositionAndShape.getObjectsInRegion<GraphicalLabel>(region);
+            if (entries.length !== 1) {
                 continue;
                 continue;
-            }
-            else {
-                for (var idx2: number = 0, len2 = entries.length; idx2 < len2; ++idx2) {
-                    var clickedLabel: GraphicalLabel = entries[idx2];
+            } else {
+                for (let idx2: number = 0, len2: number = entries.length; idx2 < len2; ++idx2) {
+                    let clickedLabel: GraphicalLabel = entries[idx2];
                     return clickedLabel;
                     return clickedLabel;
                 }
                 }
             }
             }
         }
         }
-        return null;
+        return undefined;
     }
     }
     public GetNearestStaffEntry(clickPosition: PointF_2D): GraphicalStaffEntry {
     public GetNearestStaffEntry(clickPosition: PointF_2D): GraphicalStaffEntry {
-        var initialSearchArea: number = 10;
-        var foundEntries: List<GraphicalStaffEntry> = new List<GraphicalStaffEntry>();
-        var region: BoundingBox = new BoundingBox(null);
+        let initialSearchArea: number = 10;
+        let foundEntries: GraphicalStaffEntry[] = [];
+        let region: BoundingBox = new BoundingBox(undefined);
         region.BorderLeft = clickPosition.X - initialSearchArea;
         region.BorderLeft = clickPosition.X - initialSearchArea;
         region.BorderTop = clickPosition.Y - initialSearchArea;
         region.BorderTop = clickPosition.Y - initialSearchArea;
         region.BorderRight = clickPosition.X + initialSearchArea;
         region.BorderRight = clickPosition.X + initialSearchArea;
         region.BorderBottom = clickPosition.Y + initialSearchArea;
         region.BorderBottom = clickPosition.Y + initialSearchArea;
         region.AbsolutePosition = new PointF_2D(0, 0);
         region.AbsolutePosition = new PointF_2D(0, 0);
-        for (var idx: number = 0, len = this.MusicPages.Count; idx < len; ++idx) {
-            var graphicalMusicPage: GraphicalMusicPage = this.MusicPages[idx];
-            var entries: GraphicalStaffEntry[] = graphicalMusicPage.PositionAndShape.getObjectsInRegion<GraphicalStaffEntry>(region, false).ToArray();
-            if (entries == null || entries.Count() == 0) {
+        for (let idx: number = 0, len: number = this.MusicPages.length; idx < len; ++idx) {
+            let graphicalMusicPage: GraphicalMusicPage = this.MusicPages[idx];
+            let entries: GraphicalStaffEntry[] = graphicalMusicPage.PositionAndShape.getObjectsInRegion<GraphicalStaffEntry>(region, false);
+            if (entries === undefined || entries.length() === 0) {
                 continue;
                 continue;
-            }
-            else {
-                for (var idx2: number = 0, len2 = entries.Count(); idx2 < len2; ++idx2) {
-                    var gse: GraphicalStaffEntry = entries[idx2];
-                    foundEntries.Add(gse);
+            } else {
+                for (let idx2: number = 0, len2: number = entries.length(); idx2 < len2; ++idx2) {
+                    let gse: GraphicalStaffEntry = entries[idx2];
+                    foundEntries.push(gse);
                 }
                 }
             }
             }
         }
         }
-        var closest: GraphicalStaffEntry = null;
-        for (var idx: number = 0, len = foundEntries.Count; idx < len; ++idx) {
-            var gse: GraphicalStaffEntry = foundEntries[idx];
-            if (closest == null)
+        let closest: GraphicalStaffEntry = undefined;
+        for (let idx: number = 0, len: number = foundEntries.length; idx < len; ++idx) {
+            let gse: GraphicalStaffEntry = foundEntries[idx];
+            if (closest === undefined)
                 closest = gse;
                 closest = gse;
             else {
             else {
-                if (gse.RelInMeasureTimestamp == null)
+                if (gse.RelInMeasureTimestamp === undefined)
                     continue;
                     continue;
-                var deltaNew: number = this.CalculateDistance(gse.PositionAndShape.AbsolutePosition, clickPosition);
-                var deltaOld: number = this.CalculateDistance(closest.PositionAndShape.AbsolutePosition, clickPosition);
+                let deltaNew: number = this.CalculateDistance(gse.PositionAndShape.AbsolutePosition, clickPosition);
+                let deltaOld: number = this.CalculateDistance(closest.PositionAndShape.AbsolutePosition, clickPosition);
                 if (deltaNew < deltaOld)
                 if (deltaNew < deltaOld)
                     closest = gse;
                     closest = gse;
             }
             }
         }
         }
-        if (closest != null)
+        if (closest !== undefined)
             return closest;
             return closest;
-        return null;
+        return undefined;
     }
     }
     public GetPossibleCommentAnchor(clickPosition: PointF_2D): SourceStaffEntry {
     public GetPossibleCommentAnchor(clickPosition: PointF_2D): SourceStaffEntry {
-        var entry: GraphicalStaffEntry = this.GetNearestStaffEntry(clickPosition);
-        if (entry == null)
-            return null;
+        let entry: GraphicalStaffEntry = this.GetNearestStaffEntry(clickPosition);
+        if (entry === undefined)
+            return undefined;
         return entry.SourceStaffEntry;
         return entry.SourceStaffEntry;
     }
     }
     public getClickedObjectOfType<T>(positionOnMusicSheet: PointF_2D): T {
     public getClickedObjectOfType<T>(positionOnMusicSheet: PointF_2D): T {
-        for (var idx: number = 0, len = this.musicPages.Count; idx < len; ++idx) {
-            var page: GraphicalMusicPage = this.musicPages[idx];
-            var o: Object = page.PositionAndShape.getClickedObjectOfType<T>(positionOnMusicSheet);
-            if (o != null)
-                return __as__<T>(o, T);
+        for (let idx: number = 0, len: number = this.musicPages.length; idx < len; ++idx) {
+            let page: GraphicalMusicPage = this.musicPages[idx];
+            let o: Object = page.PositionAndShape.getClickedObjectOfType<T>(positionOnMusicSheet);
+            if (o !== undefined)
+                return (o as T);
         }
         }
-        return null;
+        return undefined;
     }
     }
     public tryGetTimestampFromPosition(positionOnMusicSheet: PointF_2D): Fraction {
     public tryGetTimestampFromPosition(positionOnMusicSheet: PointF_2D): Fraction {
-        var entry: GraphicalStaffEntry = this.getClickedObjectOfType<GraphicalStaffEntry>(positionOnMusicSheet);
-        if (entry == null)
-            return null;
+        let entry: GraphicalStaffEntry = this.getClickedObjectOfType<GraphicalStaffEntry>(positionOnMusicSheet);
+        if (entry === undefined)
+            return undefined;
         return entry.getAbsoluteTimestamp();
         return entry.getAbsoluteTimestamp();
     }
     }
     public tryGetClickableLabel(positionOnMusicSheet: PointF_2D): GraphicalLabel {
     public tryGetClickableLabel(positionOnMusicSheet: PointF_2D): GraphicalLabel {
@@ -507,13 +498,13 @@ export class GraphicalMusicSheet {
                 "positionOnMusicSheet: " + positionOnMusicSheet, ex);
                 "positionOnMusicSheet: " + positionOnMusicSheet, ex);
         }
         }
 
 
-        return null;
+        return undefined;
     }
     }
     public tryGetTimeStampFromPosition(positionOnMusicSheet: PointF_2D): Fraction {
     public tryGetTimeStampFromPosition(positionOnMusicSheet: PointF_2D): Fraction {
         try {
         try {
-            var entry: GraphicalStaffEntry = this.GetNearestStaffEntry(positionOnMusicSheet);
-            if (entry == null)
-                return null;
+            let entry: GraphicalStaffEntry = this.GetNearestStaffEntry(positionOnMusicSheet);
+            if (entry === undefined)
+                return undefined;
             return entry.getAbsoluteTimestamp();
             return entry.getAbsoluteTimestamp();
         }
         }
         catch (ex) {
         catch (ex) {
@@ -521,27 +512,26 @@ export class GraphicalMusicSheet {
                 "positionOnMusicSheet: " + positionOnMusicSheet, ex);
                 "positionOnMusicSheet: " + positionOnMusicSheet, ex);
         }
         }
 
 
-        return null;
+        return undefined;
     }
     }
     private CalculateDistance(pt1: PointF_2D, pt2: PointF_2D): number {
     private CalculateDistance(pt1: PointF_2D, pt2: PointF_2D): number {
-        var deltaX: number = pt1.X - pt2.X;
-        var deltaY: number = pt1.Y - pt2.Y;
+        let deltaX: number = pt1.X - pt2.X;
+        let deltaY: number = pt1.Y - pt2.Y;
         return (deltaX * deltaX) + (deltaY * deltaY);
         return (deltaX * deltaX) + (deltaY * deltaY);
     }
     }
     public getStaffEntry(index: number): GraphicalStaffEntry {
     public getStaffEntry(index: number): GraphicalStaffEntry {
         return this.getStaffEntry(this.VerticalGraphicalStaffEntryContainers[index]);
         return this.getStaffEntry(this.VerticalGraphicalStaffEntryContainers[index]);
     }
     }
     public getStaffEntry(container: VerticalGraphicalStaffEntryContainer): GraphicalStaffEntry {
     public getStaffEntry(container: VerticalGraphicalStaffEntryContainer): GraphicalStaffEntry {
-        var staffEntry: GraphicalStaffEntry = null;
+        let staffEntry: GraphicalStaffEntry = undefined;
         try {
         try {
-            for (var idx: number = 0, len = container.StaffEntries.Count; idx < len; ++idx) {
-                var entry: GraphicalStaffEntry = container.StaffEntries[idx];
-                if (entry == null || !entry.SourceStaffEntry.ParentStaff.ParentInstrument.Visible)
+            for (let idx: number = 0, len: number = container.StaffEntries.length; idx < len; ++idx) {
+                let entry: GraphicalStaffEntry = container.StaffEntries[idx];
+                if (entry === undefined || !entry.SourceStaffEntry.ParentStaff.ParentInstrument.Visible)
                     continue;
                     continue;
-                if (staffEntry == null) {
+                if (staffEntry === undefined) {
                     staffEntry = entry;
                     staffEntry = entry;
-                }
-                else if (entry.PositionAndShape != null && staffEntry.PositionAndShape != null) {
+                } else if (entry.PositionAndShape !== undefined && staffEntry.PositionAndShape !== undefined) {
                     if (staffEntry.PositionAndShape.RelativePosition.X > entry.PositionAndShape.RelativePosition.X)
                     if (staffEntry.PositionAndShape.RelativePosition.X > entry.PositionAndShape.RelativePosition.X)
                         staffEntry = entry;
                         staffEntry = entry;
                 }
                 }
@@ -554,171 +544,163 @@ export class GraphicalMusicSheet {
         return staffEntry;
         return staffEntry;
     }
     }
     public GetPreviousVisibleContainerIndex(index: number): number {
     public GetPreviousVisibleContainerIndex(index: number): number {
-        for (var i: number = index - 1; i >= 0; i--) {
-            var entries: List<GraphicalStaffEntry> = this.verticalGraphicalStaffEntryContainers[i].StaffEntries;
-            for (var idx: number = 0, len = entries.Count; idx < len; ++idx) {
-                var entry: GraphicalStaffEntry = entries[idx];
-                if (entry != null && entry.SourceStaffEntry.ParentStaff.ParentInstrument.Visible)
+        for (let i: number = index - 1; i >= 0; i--) {
+            let entries: GraphicalStaffEntry[] = this.verticalGraphicalStaffEntryContainers[i].StaffEntries;
+            for (let idx: number = 0, len: number = entries.length; idx < len; ++idx) {
+                let entry: GraphicalStaffEntry = entries[idx];
+                if (entry !== undefined && entry.SourceStaffEntry.ParentStaff.ParentInstrument.Visible)
                     return i;
                     return i;
             }
             }
         }
         }
         return -1;
         return -1;
     }
     }
     public GetNextVisibleContainerIndex(index: number): number {
     public GetNextVisibleContainerIndex(index: number): number {
-        for (var i: number = index + 1; i < this.verticalGraphicalStaffEntryContainers.Count; ++i) {
-            var entries: List<GraphicalStaffEntry> = this.verticalGraphicalStaffEntryContainers[i].StaffEntries;
-            for (var idx: number = 0, len = entries.Count; idx < len; ++idx) {
-                var entry: GraphicalStaffEntry = entries[idx];
-                if (entry != null && entry.SourceStaffEntry.ParentStaff.ParentInstrument.Visible)
+        for (let i: number = index + 1; i < this.verticalGraphicalStaffEntryContainers.length; ++i) {
+            let entries: GraphicalStaffEntry[] = this.verticalGraphicalStaffEntryContainers[i].StaffEntries;
+            for (let idx: number = 0, len: number = entries.length; idx < len; ++idx) {
+                let entry: GraphicalStaffEntry = entries[idx];
+                if (entry !== undefined && entry.SourceStaffEntry.ParentStaff.ParentInstrument.Visible)
                     return i;
                     return i;
             }
             }
         }
         }
         return -1;
         return -1;
     }
     }
     public findClosestLeftStaffEntry(fractionalIndex: number, searchOnlyVisibleEntries: boolean): GraphicalStaffEntry {
     public findClosestLeftStaffEntry(fractionalIndex: number, searchOnlyVisibleEntries: boolean): GraphicalStaffEntry {
-        var foundEntry: GraphicalStaffEntry = null;
-        var leftIndex: number = <number>Math.Floor(fractionalIndex);
-        leftIndex = Math.Min(this.VerticalGraphicalStaffEntryContainers.Count - 1, leftIndex);
-        for (var i: number = leftIndex; i >= 0; i--) {
+        let foundEntry: GraphicalStaffEntry = undefined;
+        let leftIndex: number = <number>Math.floor(fractionalIndex);
+        leftIndex = Math.min(this.VerticalGraphicalStaffEntryContainers.length - 1, leftIndex);
+        for (let i: number = leftIndex; i >= 0; i--) {
             foundEntry = this.getStaffEntry(i);
             foundEntry = this.getStaffEntry(i);
-            if (foundEntry != null) {
+            if (foundEntry !== undefined) {
                 if (searchOnlyVisibleEntries) {
                 if (searchOnlyVisibleEntries) {
                     if (foundEntry.SourceStaffEntry.ParentStaff.ParentInstrument.Visible)
                     if (foundEntry.SourceStaffEntry.ParentStaff.ParentInstrument.Visible)
                         return foundEntry;
                         return foundEntry;
-                }
-                else return foundEntry;
+                } else return foundEntry;
             }
             }
         }
         }
-        return null;
+        return undefined;
     }
     }
     public findClosestRightStaffEntry(fractionalIndex: number, returnOnlyVisibleEntries: boolean): GraphicalStaffEntry {
     public findClosestRightStaffEntry(fractionalIndex: number, returnOnlyVisibleEntries: boolean): GraphicalStaffEntry {
-        var foundEntry: GraphicalStaffEntry = null;
-        var rightIndex: number = <number>Math.Max(0, Math.Ceiling(fractionalIndex));
-        for (var i: number = rightIndex; i < this.VerticalGraphicalStaffEntryContainers.Count; i++) {
+        let foundEntry: GraphicalStaffEntry = undefined;
+        let rightIndex: number = <number>Math.max(0, Math.ceiling(fractionalIndex));
+        for (let i: number = rightIndex; i < this.VerticalGraphicalStaffEntryContainers.length; i++) {
             foundEntry = this.getStaffEntry(i);
             foundEntry = this.getStaffEntry(i);
-            if (foundEntry != null) {
+            if (foundEntry !== undefined) {
                 if (returnOnlyVisibleEntries) {
                 if (returnOnlyVisibleEntries) {
                     if (foundEntry.SourceStaffEntry.ParentStaff.ParentInstrument.Visible)
                     if (foundEntry.SourceStaffEntry.ParentStaff.ParentInstrument.Visible)
                         return foundEntry;
                         return foundEntry;
-                }
-                else return foundEntry;
+                } else return foundEntry;
             }
             }
         }
         }
-        return null;
+        return undefined;
     }
     }
     public calculateXPositionFromTimestamp(timeStamp: Fraction, currentMusicSystem: MusicSystem): number {
     public calculateXPositionFromTimestamp(timeStamp: Fraction, currentMusicSystem: MusicSystem): number {
-        var fractionalIndex: number = this.GetInterpolatedIndexInVerticalContainers(timeStamp);
-        var previousStaffEntry: GraphicalStaffEntry = this.findClosestLeftStaffEntry(fractionalIndex, true);
-        var nextStaffEntry: GraphicalStaffEntry = this.findClosestRightStaffEntry(fractionalIndex, true);
-        var currentTimeStamp: number = timeStamp.RealValue;
-        if (previousStaffEntry == null && nextStaffEntry == null) {
-            currentMusicSystem = null;
+        let fractionalIndex: number = this.GetInterpolatedIndexInVerticalContainers(timeStamp);
+        let previousStaffEntry: GraphicalStaffEntry = this.findClosestLeftStaffEntry(fractionalIndex, true);
+        let nextStaffEntry: GraphicalStaffEntry = this.findClosestRightStaffEntry(fractionalIndex, true);
+        let currentTimeStamp: number = timeStamp.RealValue;
+        if (previousStaffEntry === undefined && nextStaffEntry === undefined) {
+            currentMusicSystem = undefined;
             return 0;
             return 0;
         }
         }
-        var previousStaffEntryMusicSystem: MusicSystem = null;
-        if (previousStaffEntry != null) {
+        let previousStaffEntryMusicSystem: MusicSystem = undefined;
+        if (previousStaffEntry !== undefined) {
             previousStaffEntryMusicSystem = previousStaffEntry.ParentMeasure.ParentStaffLine.ParentMusicSystem;
             previousStaffEntryMusicSystem = previousStaffEntry.ParentMeasure.ParentStaffLine.ParentMusicSystem;
-        }
-        else {
+        } else {
             previousStaffEntryMusicSystem = nextStaffEntry.ParentMeasure.ParentStaffLine.ParentMusicSystem;
             previousStaffEntryMusicSystem = nextStaffEntry.ParentMeasure.ParentStaffLine.ParentMusicSystem;
         }
         }
-        var nextStaffEntryMusicSystem: MusicSystem = null;
-        if (nextStaffEntry != null) {
+        let nextStaffEntryMusicSystem: MusicSystem = undefined;
+        if (nextStaffEntry !== undefined) {
             nextStaffEntryMusicSystem = nextStaffEntry.ParentMeasure.ParentStaffLine.ParentMusicSystem;
             nextStaffEntryMusicSystem = nextStaffEntry.ParentMeasure.ParentStaffLine.ParentMusicSystem;
-        }
-        else {
+        } else {
             nextStaffEntryMusicSystem = previousStaffEntry.ParentMeasure.ParentStaffLine.ParentMusicSystem;
             nextStaffEntryMusicSystem = previousStaffEntry.ParentMeasure.ParentStaffLine.ParentMusicSystem;
         }
         }
-        if (previousStaffEntryMusicSystem == nextStaffEntryMusicSystem) {
+        if (previousStaffEntryMusicSystem === nextStaffEntryMusicSystem) {
             currentMusicSystem = previousStaffEntryMusicSystem;
             currentMusicSystem = previousStaffEntryMusicSystem;
-            var fraction: number;
-            var previousStaffEntryPositionX: number;
-            var nextStaffEntryPositionX: number;
-            if (previousStaffEntry == null) {
+            let fraction: number;
+            let previousStaffEntryPositionX: number;
+            let nextStaffEntryPositionX: number;
+            if (previousStaffEntry === undefined) {
                 previousStaffEntryPositionX = nextStaffEntryPositionX = nextStaffEntry.PositionAndShape.AbsolutePosition.X;
                 previousStaffEntryPositionX = nextStaffEntryPositionX = nextStaffEntry.PositionAndShape.AbsolutePosition.X;
                 fraction = 0;
                 fraction = 0;
-            }
-            else if (nextStaffEntry == null) {
+            } else if (nextStaffEntry === undefined) {
                 previousStaffEntryPositionX = previousStaffEntry.PositionAndShape.AbsolutePosition.X;
                 previousStaffEntryPositionX = previousStaffEntry.PositionAndShape.AbsolutePosition.X;
                 nextStaffEntryPositionX = currentMusicSystem.GetRightBorderAbsoluteXPosition();
                 nextStaffEntryPositionX = currentMusicSystem.GetRightBorderAbsoluteXPosition();
                 fraction = (currentTimeStamp - previousStaffEntry.getAbsoluteTimestamp().RealValue) / ((previousStaffEntry.ParentMeasure.ParentSourceMeasure.AbsoluteTimestamp + previousStaffEntry.ParentMeasure.ParentSourceMeasure.Duration).RealValue - previousStaffEntry.getAbsoluteTimestamp().RealValue);
                 fraction = (currentTimeStamp - previousStaffEntry.getAbsoluteTimestamp().RealValue) / ((previousStaffEntry.ParentMeasure.ParentSourceMeasure.AbsoluteTimestamp + previousStaffEntry.ParentMeasure.ParentSourceMeasure.Duration).RealValue - previousStaffEntry.getAbsoluteTimestamp().RealValue);
-            }
-            else {
+            } else {
                 previousStaffEntryPositionX = previousStaffEntry.PositionAndShape.AbsolutePosition.X;
                 previousStaffEntryPositionX = previousStaffEntry.PositionAndShape.AbsolutePosition.X;
                 nextStaffEntryPositionX = nextStaffEntry.PositionAndShape.AbsolutePosition.X;
                 nextStaffEntryPositionX = nextStaffEntry.PositionAndShape.AbsolutePosition.X;
-                if (previousStaffEntry == nextStaffEntry)
+                if (previousStaffEntry === nextStaffEntry)
                     fraction = 0;
                     fraction = 0;
                 else fraction = (currentTimeStamp - previousStaffEntry.getAbsoluteTimestamp().RealValue) / (nextStaffEntry.getAbsoluteTimestamp().RealValue - previousStaffEntry.getAbsoluteTimestamp().RealValue);
                 else fraction = (currentTimeStamp - previousStaffEntry.getAbsoluteTimestamp().RealValue) / (nextStaffEntry.getAbsoluteTimestamp().RealValue - previousStaffEntry.getAbsoluteTimestamp().RealValue);
             }
             }
-            fraction = Math.Min(1, Math.Max(0, fraction));
-            var interpolatedXPosition: number = previousStaffEntryPositionX + fraction * (nextStaffEntryPositionX - previousStaffEntryPositionX);
+            fraction = Math.min(1, Math.max(0, fraction));
+            let interpolatedXPosition: number = previousStaffEntryPositionX + fraction * (nextStaffEntryPositionX - previousStaffEntryPositionX);
             return interpolatedXPosition;
             return interpolatedXPosition;
-        }
-        else {
-            var nextSystemLeftBorderTimeStamp: number = nextStaffEntry.ParentMeasure.ParentSourceMeasure.AbsoluteTimestamp.RealValue;
-            var fraction: number;
-            var interpolatedXPosition: number;
+        } else {
+            let nextSystemLeftBorderTimeStamp: number = nextStaffEntry.ParentMeasure.ParentSourceMeasure.AbsoluteTimestamp.RealValue;
+            let fraction: number;
+            let interpolatedXPosition: number;
             if (currentTimeStamp < nextSystemLeftBorderTimeStamp) {
             if (currentTimeStamp < nextSystemLeftBorderTimeStamp) {
                 currentMusicSystem = previousStaffEntryMusicSystem;
                 currentMusicSystem = previousStaffEntryMusicSystem;
-                var previousStaffEntryPositionX: number = previousStaffEntry.PositionAndShape.AbsolutePosition.X;
-                var previousSystemRightBorderX: number = currentMusicSystem.GetRightBorderAbsoluteXPosition();
+                let previousStaffEntryPositionX: number = previousStaffEntry.PositionAndShape.AbsolutePosition.X;
+                let previousSystemRightBorderX: number = currentMusicSystem.GetRightBorderAbsoluteXPosition();
                 fraction = (currentTimeStamp - previousStaffEntry.getAbsoluteTimestamp().RealValue) / (nextSystemLeftBorderTimeStamp - previousStaffEntry.getAbsoluteTimestamp().RealValue);
                 fraction = (currentTimeStamp - previousStaffEntry.getAbsoluteTimestamp().RealValue) / (nextSystemLeftBorderTimeStamp - previousStaffEntry.getAbsoluteTimestamp().RealValue);
-                fraction = Math.Min(1, Math.Max(0, fraction));
+                fraction = Math.min(1, Math.max(0, fraction));
                 interpolatedXPosition = previousStaffEntryPositionX + fraction * (previousSystemRightBorderX - previousStaffEntryPositionX);
                 interpolatedXPosition = previousStaffEntryPositionX + fraction * (previousSystemRightBorderX - previousStaffEntryPositionX);
-            }
-            else {
+            } else {
                 currentMusicSystem = nextStaffEntryMusicSystem;
                 currentMusicSystem = nextStaffEntryMusicSystem;
-                var nextStaffEntryPositionX: number = nextStaffEntry.PositionAndShape.AbsolutePosition.X;
-                var nextSystemLeftBorderX: number = currentMusicSystem.GetLeftBorderAbsoluteXPosition();
+                let nextStaffEntryPositionX: number = nextStaffEntry.PositionAndShape.AbsolutePosition.X;
+                let nextSystemLeftBorderX: number = currentMusicSystem.GetLeftBorderAbsoluteXPosition();
                 fraction = (currentTimeStamp - nextSystemLeftBorderTimeStamp) / (nextStaffEntry.getAbsoluteTimestamp().RealValue - nextSystemLeftBorderTimeStamp);
                 fraction = (currentTimeStamp - nextSystemLeftBorderTimeStamp) / (nextStaffEntry.getAbsoluteTimestamp().RealValue - nextSystemLeftBorderTimeStamp);
-                fraction = Math.Min(1, Math.Max(0, fraction));
+                fraction = Math.min(1, Math.max(0, fraction));
                 interpolatedXPosition = nextSystemLeftBorderX + fraction * (nextStaffEntryPositionX - nextSystemLeftBorderX);
                 interpolatedXPosition = nextSystemLeftBorderX + fraction * (nextStaffEntryPositionX - nextSystemLeftBorderX);
             }
             }
             return interpolatedXPosition;
             return interpolatedXPosition;
         }
         }
     }
     }
     public GetNumberOfVisibleInstruments(): number {
     public GetNumberOfVisibleInstruments(): number {
-        var visibleInstrumentCount: number = 0;
-        for (var idx: number = 0, len = this.musicSheet.Instruments.Count; idx < len; ++idx) {
-            var instrument: Instrument = this.musicSheet.Instruments[idx];
-            if (instrument.Visible == true)
+        let visibleInstrumentCount: number = 0;
+        for (let idx: number = 0, len: number = this.musicSheet.Instruments.length; idx < len; ++idx) {
+            let instrument: Instrument = this.musicSheet.Instruments[idx];
+            if (instrument.Visible === true)
                 visibleInstrumentCount++;
                 visibleInstrumentCount++;
         }
         }
         return visibleInstrumentCount;
         return visibleInstrumentCount;
     }
     }
     public GetNumberOfFollowedInstruments(): number {
     public GetNumberOfFollowedInstruments(): number {
-        var followedInstrumentCount: number = 0;
-        for (var idx: number = 0, len = this.musicSheet.Instruments.Count; idx < len; ++idx) {
-            var instrument: Instrument = this.musicSheet.Instruments[idx];
-            if (instrument.Following == true)
+        let followedInstrumentCount: number = 0;
+        for (let idx: number = 0, len: number = this.musicSheet.Instruments.length; idx < len; ++idx) {
+            let instrument: Instrument = this.musicSheet.Instruments[idx];
+            if (instrument.Following === true)
                 followedInstrumentCount++;
                 followedInstrumentCount++;
         }
         }
         return followedInstrumentCount;
         return followedInstrumentCount;
     }
     }
-    public GetGraphicalFromSourceMeasure(sourceMeasure: SourceMeasure): List<StaffMeasure> {
+    public GetGraphicalFromSourceMeasure(sourceMeasure: SourceMeasure): StaffMeasure[] {
         return this.SourceToGraphicalMeasureLinks[sourceMeasure];
         return this.SourceToGraphicalMeasureLinks[sourceMeasure];
     }
     }
     public GetGraphicalFromSourceStaffEntry(sourceStaffEntry: SourceStaffEntry): GraphicalStaffEntry {
     public GetGraphicalFromSourceStaffEntry(sourceStaffEntry: SourceStaffEntry): GraphicalStaffEntry {
-        var graphicalMeasure: StaffMeasure = this.SourceToGraphicalMeasureLinks[sourceStaffEntry.VerticalContainerParent.ParentMeasure][sourceStaffEntry.ParentStaff.IdInMusicSheet];
+        let graphicalMeasure: StaffMeasure = this.SourceToGraphicalMeasureLinks[sourceStaffEntry.VerticalContainerParent.ParentMeasure][sourceStaffEntry.ParentStaff.IdInMusicSheet];
         return graphicalMeasure.findGraphicalStaffEntryFromTimestamp(sourceStaffEntry.Timestamp);
         return graphicalMeasure.findGraphicalStaffEntryFromTimestamp(sourceStaffEntry.Timestamp);
     }
     }
-    public GetGraphicalFromSourceStaffEntry(voiceEntries: List<VoiceEntry>): GraphicalStaffEntry {
-        if (voiceEntries.Count == 0)
-            return null;
-        var sse: SourceStaffEntry = voiceEntries[0].ParentSourceStaffEntry;
-        var graphicalMeasure: StaffMeasure = this.SourceToGraphicalMeasureLinks[sse.VerticalContainerParent.ParentMeasure][sse.ParentStaff.IdInMusicSheet];
+    public GetGraphicalFromSourceStaffEntry(voiceEntries: VoiceEntry[]): GraphicalStaffEntry {
+        if (voiceEntries.length === 0)
+            return undefined;
+        let sse: SourceStaffEntry = voiceEntries[0].ParentSourceStaffEntry;
+        let graphicalMeasure: StaffMeasure = this.SourceToGraphicalMeasureLinks[sse.VerticalContainerParent.ParentMeasure][sse.ParentStaff.IdInMusicSheet];
         return graphicalMeasure.findGraphicalStaffEntryFromTimestamp(sse.Timestamp);
         return graphicalMeasure.findGraphicalStaffEntryFromTimestamp(sse.Timestamp);
     }
     }
     public GetGraphicalNoteFromSourceNote(note: Note, containingGse: GraphicalStaffEntry): GraphicalNote {
     public GetGraphicalNoteFromSourceNote(note: Note, containingGse: GraphicalStaffEntry): GraphicalNote {
-        for (var idx: number = 0, len = containingGse.Notes.Count; idx < len; ++idx) {
-            var graphicalNotes: List<GraphicalNote> = containingGse.Notes[idx];
-            for (var idx2: number = 0, len2 = graphicalNotes.Count; idx2 < len2; ++idx2) {
-                var graphicalNote: GraphicalNote = graphicalNotes[idx2];
-                if (graphicalNote.SourceNote == note)
+        for (let idx: number = 0, len: number = containingGse.Notes.length; idx < len; ++idx) {
+            let graphicalNotes: GraphicalNote[] = containingGse.Notes[idx];
+            for (let idx2: number = 0, len2: number = graphicalNotes.length; idx2 < len2; ++idx2) {
+                let graphicalNote: GraphicalNote = graphicalNotes[idx2];
+                if (graphicalNote.SourceNote === note)
                     return graphicalNote;
                     return graphicalNote;
             }
             }
         }
         }
-        return null;
+        return undefined;
     }
     }
 }
 }
 export class SystemImageProperties {
 export class SystemImageProperties {

+ 7 - 7
src/MusicalScore/Graphical/GraphicalNote.ts

@@ -15,17 +15,17 @@ export class GraphicalNote extends GraphicalObject {
     public SourceNote: Note;
     public SourceNote: Note;
     public GraphicalNoteLength: Fraction;
     public GraphicalNoteLength: Fraction;
     public ParentStaffEntry: GraphicalStaffEntry;
     public ParentStaffEntry: GraphicalStaffEntry;
-    public get ParentList(): List<GraphicalNote> {
-        for (var idx: number = 0, len = this.ParentStaffEntry.Notes.Count; idx < len; ++idx) {
-            var graphicalNotes: List<GraphicalNote> = this.ParentStaffEntry.Notes[idx];
-            if (graphicalNotes.Contains(this))
+    public get ParentList(): GraphicalNote[] {
+        for (let idx: number = 0, len: number = this.ParentStaffEntry.Notes.length; idx < len; ++idx) {
+            let graphicalNotes: GraphicalNote[] = this.ParentStaffEntry.Notes[idx];
+            if (graphicalNotes.indexOf(this) !== -1)
                 return graphicalNotes;
                 return graphicalNotes;
         }
         }
-        return null;
+        return undefined;
     }
     }
     public Transpose(keyInstruction: KeyInstruction, activeClef: ClefInstruction, halfTones: number, octaveEnum: OctaveEnum): Pitch {
     public Transpose(keyInstruction: KeyInstruction, activeClef: ClefInstruction, halfTones: number, octaveEnum: OctaveEnum): Pitch {
-        var transposedPitch: Pitch = this.SourceNote.Pitch;
-        if (MusicSheetCalculator.TransposeCalculator != null)
+        let transposedPitch: Pitch = this.SourceNote.Pitch;
+        if (MusicSheetCalculator.TransposeCalculator !== undefined)
             transposedPitch = MusicSheetCalculator.TransposeCalculator.TransposePitch(this.SourceNote.Pitch, keyInstruction, halfTones);
             transposedPitch = MusicSheetCalculator.TransposeCalculator.TransposePitch(this.SourceNote.Pitch, keyInstruction, halfTones);
         return transposedPitch;
         return transposedPitch;
     }
     }

+ 117 - 120
src/MusicalScore/Graphical/GraphicalStaffEntry.ts

@@ -16,22 +16,21 @@ import {GraphicalLyricEntry} from "./GraphicalLyricEntry";
 import {AbstractGraphicalInstruction} from "./AbstractGraphicalInstruction";
 import {AbstractGraphicalInstruction} from "./AbstractGraphicalInstruction";
 import {GraphicalStaffEntryLink} from "./GraphicalStaffEntryLink";
 import {GraphicalStaffEntryLink} from "./GraphicalStaffEntryLink";
 export class GraphicalStaffEntry extends GraphicalObject {
 export class GraphicalStaffEntry extends GraphicalObject {
-    private graphicalInstructions: List<AbstractGraphicalInstruction> = new List<AbstractGraphicalInstruction>();
-    private graphicalTies: List<GraphicalTie> = new List<GraphicalTie>();
-    private lyricsEntries: List<GraphicalLyricEntry> = new List<GraphicalLyricEntry>();
-    constructor(parentMeasure: StaffMeasure, sourceStaffEntry: SourceStaffEntry = null, staffEntryParent: GraphicalStaffEntry = null) {
+    private graphicalInstructions: AbstractGraphicalInstruction[] = [];
+    private graphicalTies: GraphicalTie[] = [];
+    private lyricsEntries: GraphicalLyricEntry[] = [];
+    constructor(parentMeasure: StaffMeasure, sourceStaffEntry: SourceStaffEntry = undefined, staffEntryParent: GraphicalStaffEntry = undefined) {
         this.ParentMeasure = parentMeasure;
         this.ParentMeasure = parentMeasure;
-        this.Notes = new List<List<GraphicalNote>>();
-        this.GraceStaffEntriesBefore = new List<GraphicalStaffEntry>();
-        this.GraceStaffEntriesAfter = new List<GraphicalStaffEntry>();
+        this.Notes = [];
+        this.GraceStaffEntriesBefore = [];
+        this.GraceStaffEntriesAfter = [];
         this.SourceStaffEntry = sourceStaffEntry;
         this.SourceStaffEntry = sourceStaffEntry;
-        if (staffEntryParent != null) {
+        if (staffEntryParent !== undefined) {
             this.StaffEntryParent = staffEntryParent;
             this.StaffEntryParent = staffEntryParent;
             this.ParentVerticalContainer = staffEntryParent.ParentVerticalContainer;
             this.ParentVerticalContainer = staffEntryParent.ParentVerticalContainer;
             this.PositionAndShape = new BoundingBox(staffEntryParent.PositionAndShape, this);
             this.PositionAndShape = new BoundingBox(staffEntryParent.PositionAndShape, this);
-        }
-        else this.PositionAndShape = new BoundingBox(parentMeasure.PositionAndShape, this);
-        if (sourceStaffEntry != null)
+        } else this.PositionAndShape = new BoundingBox(parentMeasure.PositionAndShape, this);
+        if (sourceStaffEntry !== undefined)
             this.RelInMeasureTimestamp = sourceStaffEntry.Timestamp;
             this.RelInMeasureTimestamp = sourceStaffEntry.Timestamp;
     }
     }
     public GraphicalChordContainer: GraphicalChordSymbolContainer;
     public GraphicalChordContainer: GraphicalChordSymbolContainer;
@@ -39,140 +38,140 @@ export class GraphicalStaffEntry extends GraphicalObject {
     public RelInMeasureTimestamp: Fraction;
     public RelInMeasureTimestamp: Fraction;
     public SourceStaffEntry: SourceStaffEntry;
     public SourceStaffEntry: SourceStaffEntry;
     public ParentMeasure: StaffMeasure;
     public ParentMeasure: StaffMeasure;
-    public Notes: List<List<GraphicalNote>>;
-    public GraceStaffEntriesBefore: List<GraphicalStaffEntry>;
-    public GraceStaffEntriesAfter: List<GraphicalStaffEntry>;
+    public Notes: GraphicalNote[][];
+    public GraceStaffEntriesBefore: GraphicalStaffEntry[];
+    public GraceStaffEntriesAfter: GraphicalStaffEntry[];
     public StaffEntryParent: GraphicalStaffEntry;
     public StaffEntryParent: GraphicalStaffEntry;
     public ParentVerticalContainer: VerticalGraphicalStaffEntryContainer;
     public ParentVerticalContainer: VerticalGraphicalStaffEntryContainer;
-    public get GraphicalInstructions(): List<AbstractGraphicalInstruction> {
+    public get GraphicalInstructions(): AbstractGraphicalInstruction[] {
         return this.graphicalInstructions;
         return this.graphicalInstructions;
     }
     }
-    public get GraphicalTies(): List<GraphicalTie> {
+    public get GraphicalTies(): GraphicalTie[] {
         return this.graphicalTies;
         return this.graphicalTies;
     }
     }
-    public get LyricsEntries(): List<GraphicalLyricEntry> {
+    public get LyricsEntries(): GraphicalLyricEntry[] {
         return this.lyricsEntries;
         return this.lyricsEntries;
     }
     }
     public getAbsoluteTimestamp(): Fraction {
     public getAbsoluteTimestamp(): Fraction {
-        var result: Fraction = Fraction.CreateFractionFromFraction(this.ParentMeasure.ParentSourceMeasure.AbsoluteTimestamp);
-        if (this.RelInMeasureTimestamp != null)
+        let result: Fraction = Fraction.CreateFractionFromFraction(this.ParentMeasure.ParentSourceMeasure.AbsoluteTimestamp);
+        if (this.RelInMeasureTimestamp !== undefined)
             result += this.RelInMeasureTimestamp;
             result += this.RelInMeasureTimestamp;
         return result;
         return result;
     }
     }
     public findEndTieGraphicalNoteFromNote(tieNote: Note): GraphicalNote {
     public findEndTieGraphicalNoteFromNote(tieNote: Note): GraphicalNote {
-        for (var idx: number = 0, len = this.Notes.Count; idx < len; ++idx) {
-            var graphicalNotes: List<GraphicalNote> = this.Notes[idx];
-            for (var idx2: number = 0, len2 = graphicalNotes.Count; idx2 < len2; ++idx2) {
-                var graphicalNote: GraphicalNote = graphicalNotes[idx2];
-                var note: Note = graphicalNote.SourceNote;
-                if (note.Pitch != null && note.Pitch.FundamentalNote == tieNote.Pitch.FundamentalNote && note.Pitch.Octave == tieNote.Pitch.Octave && note.getAbsoluteTimestamp() == tieNote.getAbsoluteTimestamp())
+        for (let idx: number = 0, len: number = this.Notes.length; idx < len; ++idx) {
+            let graphicalNotes: GraphicalNote[] = this.Notes[idx];
+            for (let idx2: number = 0, len2: number = graphicalNotes.length; idx2 < len2; ++idx2) {
+                let graphicalNote: GraphicalNote = graphicalNotes[idx2];
+                let note: Note = graphicalNote.SourceNote;
+                if (note.Pitch !== undefined && note.Pitch.FundamentalNote === tieNote.Pitch.FundamentalNote && note.Pitch.Octave === tieNote.Pitch.Octave && note.getAbsoluteTimestamp() === tieNote.getAbsoluteTimestamp())
                     return graphicalNote;
                     return graphicalNote;
             }
             }
         }
         }
-        return null;
+        return undefined;
     }
     }
     public findEndTieGraphicalNoteFromNoteWithStartingSlur(tieNote: Note, slur: Slur): GraphicalNote {
     public findEndTieGraphicalNoteFromNoteWithStartingSlur(tieNote: Note, slur: Slur): GraphicalNote {
-        for (var idx: number = 0, len = this.Notes.Count; idx < len; ++idx) {
-            var graphicalNotes: List<GraphicalNote> = this.Notes[idx];
-            for (var idx2: number = 0, len2 = graphicalNotes.Count; idx2 < len2; ++idx2) {
-                var graphicalNote: GraphicalNote = graphicalNotes[idx2];
-                var note: Note = graphicalNote.SourceNote;
-                if (note.NoteTie != null && note.NoteSlurs.Contains(slur))
+        for (let idx: number = 0, len: number = this.Notes.length; idx < len; ++idx) {
+            let graphicalNotes: GraphicalNote[] = this.Notes[idx];
+            for (let idx2: number = 0, len2: number = graphicalNotes.length; idx2 < len2; ++idx2) {
+                let graphicalNote: GraphicalNote = graphicalNotes[idx2];
+                let note: Note = graphicalNote.SourceNote;
+                if (note.NoteTie !== undefined && note.NoteSlurs.indexOf(slur) !== -1)
                     return graphicalNote;
                     return graphicalNote;
             }
             }
         }
         }
-        return null;
+        return undefined;
     }
     }
     public findEndTieGraphicalNoteFromNoteWithEndingSlur(tieNote: Note): GraphicalNote {
     public findEndTieGraphicalNoteFromNoteWithEndingSlur(tieNote: Note): GraphicalNote {
-        for (var idx: number = 0, len = this.Notes.Count; idx < len; ++idx) {
-            var graphicalNotes: List<GraphicalNote> = this.Notes[idx];
-            for (var idx2: number = 0, len2 = graphicalNotes.Count; idx2 < len2; ++idx2) {
-                var graphicalNote: GraphicalNote = graphicalNotes[idx2];
-                var note: Note = graphicalNote.SourceNote;
-                if (note.Pitch != null && note.Pitch.FundamentalNote == tieNote.Pitch.FundamentalNote && note.Pitch.Octave == tieNote.Pitch.Octave && this.getAbsoluteTimestamp() == tieNote.getAbsoluteTimestamp())
+        for (let idx: number = 0, len: number = this.Notes.length; idx < len; ++idx) {
+            let graphicalNotes: GraphicalNote[] = this.Notes[idx];
+            for (let idx2: number = 0, len2: number = graphicalNotes.length; idx2 < len2; ++idx2) {
+                let graphicalNote: GraphicalNote = graphicalNotes[idx2];
+                let note: Note = graphicalNote.SourceNote;
+                if (note.Pitch !== undefined && note.Pitch.FundamentalNote === tieNote.Pitch.FundamentalNote && note.Pitch.Octave === tieNote.Pitch.Octave && this.getAbsoluteTimestamp() === tieNote.getAbsoluteTimestamp())
                     return graphicalNote;
                     return graphicalNote;
             }
             }
         }
         }
-        return null;
+        return undefined;
     }
     }
     public findGraphicalNoteFromGraceNote(graceNote: Note): GraphicalNote {
     public findGraphicalNoteFromGraceNote(graceNote: Note): GraphicalNote {
-        for (var idx: number = 0, len = this.Notes.Count; idx < len; ++idx) {
-            var graphicalNotes: List<GraphicalNote> = this.Notes[idx];
-            for (var idx2: number = 0, len2 = graphicalNotes.Count; idx2 < len2; ++idx2) {
-                var graphicalNote: GraphicalNote = graphicalNotes[idx2];
-                if (graphicalNote.SourceNote == graceNote)
+        for (let idx: number = 0, len: number = this.Notes.length; idx < len; ++idx) {
+            let graphicalNotes: GraphicalNote[] = this.Notes[idx];
+            for (let idx2: number = 0, len2: number = graphicalNotes.length; idx2 < len2; ++idx2) {
+                let graphicalNote: GraphicalNote = graphicalNotes[idx2];
+                if (graphicalNote.SourceNote === graceNote)
                     return graphicalNote;
                     return graphicalNote;
             }
             }
         }
         }
-        return null;
+        return undefined;
     }
     }
     public findGraphicalNoteFromNote(baseNote: Note): GraphicalNote {
     public findGraphicalNoteFromNote(baseNote: Note): GraphicalNote {
-        for (var idx: number = 0, len = this.Notes.Count; idx < len; ++idx) {
-            var graphicalNotes: List<GraphicalNote> = this.Notes[idx];
-            for (var idx2: number = 0, len2 = graphicalNotes.Count; idx2 < len2; ++idx2) {
-                var graphicalNote: GraphicalNote = graphicalNotes[idx2];
-                if (graphicalNote.SourceNote == baseNote && this.getAbsoluteTimestamp() == baseNote.getAbsoluteTimestamp())
+        for (let idx: number = 0, len: number = this.Notes.length; idx < len; ++idx) {
+            let graphicalNotes: GraphicalNote[] = this.Notes[idx];
+            for (let idx2: number = 0, len2: number = graphicalNotes.length; idx2 < len2; ++idx2) {
+                let graphicalNote: GraphicalNote = graphicalNotes[idx2];
+                if (graphicalNote.SourceNote === baseNote && this.getAbsoluteTimestamp() === baseNote.getAbsoluteTimestamp())
                     return graphicalNote;
                     return graphicalNote;
             }
             }
         }
         }
-        return null;
+        return undefined;
     }
     }
     public getGraphicalNoteDurationFromVoice(voice: Voice): Fraction {
     public getGraphicalNoteDurationFromVoice(voice: Voice): Fraction {
-        for (var idx: number = 0, len = this.Notes.Count; idx < len; ++idx) {
-            var graphicalNotes: List<GraphicalNote> = this.Notes[idx];
-            if (graphicalNotes[0].SourceNote.ParentVoiceEntry.ParentVoice == voice)
+        for (let idx: number = 0, len: number = this.Notes.length; idx < len; ++idx) {
+            let graphicalNotes: GraphicalNote[] = this.Notes[idx];
+            if (graphicalNotes[0].SourceNote.ParentVoiceEntry.ParentVoice === voice)
                 return graphicalNotes[0].GraphicalNoteLength;
                 return graphicalNotes[0].GraphicalNoteLength;
         }
         }
         return new Fraction(0, 1);
         return new Fraction(0, 1);
     }
     }
-    public findLinkedNotes(notLinkedNotes: List<GraphicalNote>): void {
-        if (this.SourceStaffEntry != null && this.SourceStaffEntry.Link != null) {
-            for (var idx: number = 0, len = this.Notes.Count; idx < len; ++idx) {
-                var graphicalNotes: List<GraphicalNote> = this.Notes[idx];
-                for (var idx2: number = 0, len2 = graphicalNotes.Count; idx2 < len2; ++idx2) {
-                    var graphicalNote: GraphicalNote = graphicalNotes[idx2];
-                    if (graphicalNote.ParentStaffEntry == this)
-                        notLinkedNotes.Add(graphicalNote);
+    public findLinkedNotes(notLinkedNotes: GraphicalNote[]): void {
+        if (this.SourceStaffEntry !== undefined && this.SourceStaffEntry.Link !== undefined) {
+            for (let idx: number = 0, len: number = this.Notes.length; idx < len; ++idx) {
+                let graphicalNotes: GraphicalNote[] = this.Notes[idx];
+                for (let idx2: number = 0, len2: number = graphicalNotes.length; idx2 < len2; ++idx2) {
+                    let graphicalNote: GraphicalNote = graphicalNotes[idx2];
+                    if (graphicalNote.ParentStaffEntry === this)
+                        notLinkedNotes.push(graphicalNote);
                 }
                 }
             }
             }
         }
         }
     }
     }
-    public findVoiceEntryGraphicalNotes(voiceEntry: VoiceEntry): List<GraphicalNote> {
-        for (var idx: number = 0, len = this.Notes.Count; idx < len; ++idx) {
-            var graphicalNotes: List<GraphicalNote> = this.Notes[idx];
-            for (var idx2: number = 0, len2 = graphicalNotes.Count; idx2 < len2; ++idx2) {
-                var graphicalNote: GraphicalNote = graphicalNotes[idx2];
-                if (graphicalNote.SourceNote.ParentVoiceEntry == voiceEntry)
+    public findVoiceEntryGraphicalNotes(voiceEntry: VoiceEntry): GraphicalNote[] {
+        for (let idx: number = 0, len: number = this.Notes.length; idx < len; ++idx) {
+            let graphicalNotes: GraphicalNote[] = this.Notes[idx];
+            for (let idx2: number = 0, len2: number = graphicalNotes.length; idx2 < len2; ++idx2) {
+                let graphicalNote: GraphicalNote = graphicalNotes[idx2];
+                if (graphicalNote.SourceNote.ParentVoiceEntry === voiceEntry)
                     return graphicalNotes;
                     return graphicalNotes;
             }
             }
         }
         }
-        return null;
+        return undefined;
     }
     }
     public isVoiceEntryPartOfLinkedVoiceEntry(voiceEntry: VoiceEntry): boolean {
     public isVoiceEntryPartOfLinkedVoiceEntry(voiceEntry: VoiceEntry): boolean {
-        if (this.SourceStaffEntry.Link != null) {
-            for (var idx: number = 0, len = this.SourceStaffEntry.Link.LinkStaffEntries.Count; idx < len; ++idx) {
-                var sEntry: SourceStaffEntry = this.SourceStaffEntry.Link.LinkStaffEntries[idx];
-                if (sEntry.VoiceEntries.Contains(voiceEntry) && sEntry != this.SourceStaffEntry)
+        if (this.SourceStaffEntry.Link !== undefined) {
+            for (let idx: number = 0, len: number = this.SourceStaffEntry.Link.LinkStaffEntries.length; idx < len; ++idx) {
+                let sEntry: SourceStaffEntry = this.SourceStaffEntry.Link.LinkStaffEntries[idx];
+                if (sEntry.VoiceEntries.indexOf(voiceEntry) !== -1 && sEntry !== this.SourceStaffEntry)
                     return true;
                     return true;
             }
             }
         }
         }
         return false;
         return false;
     }
     }
     public getMainVoice(): Voice {
     public getMainVoice(): Voice {
-        for (var idx: number = 0, len = this.SourceStaffEntry.VoiceEntries.Count; idx < len; ++idx) {
-            var voiceEntry: VoiceEntry = this.SourceStaffEntry.VoiceEntries[idx];
-            if (voiceEntry.ParentVoice.GetType() != /*typeof*/LinkedVoice)
+        for (let idx: number = 0, len: number = this.SourceStaffEntry.VoiceEntries.length; idx < len; ++idx) {
+            let voiceEntry: VoiceEntry = this.SourceStaffEntry.VoiceEntries[idx];
+            if (voiceEntry.ParentVoice.GetType() !== /*typeof*/LinkedVoice)
                 return voiceEntry.ParentVoice;
                 return voiceEntry.ParentVoice;
         }
         }
         return this.Notes[0][0].SourceNote.ParentVoiceEntry.ParentVoice;
         return this.Notes[0][0].SourceNote.ParentVoiceEntry.ParentVoice;
     }
     }
     public findStaffEntryMinNoteLength(): Fraction {
     public findStaffEntryMinNoteLength(): Fraction {
-        var minLength: Fraction = new Fraction(Int32.MaxValue, 1);
-        for (var idx: number = 0, len = this.Notes.Count; idx < len; ++idx) {
-            var graphicalNotes: List<GraphicalNote> = this.Notes[idx];
-            for (var idx2: number = 0, len2 = graphicalNotes.Count; idx2 < len2; ++idx2) {
-                var graphicalNote: GraphicalNote = graphicalNotes[idx2];
-                var calNoteLen: Fraction = graphicalNote.GraphicalNoteLength;
+        let minLength: Fraction = new Fraction(Number.MAX_VALUE, 1);
+        for (let idx: number = 0, len: number = this.Notes.length; idx < len; ++idx) {
+            let graphicalNotes: GraphicalNote[] = this.Notes[idx];
+            for (let idx2: number = 0, len2: number = graphicalNotes.length; idx2 < len2; ++idx2) {
+                let graphicalNote: GraphicalNote = graphicalNotes[idx2];
+                let calNoteLen: Fraction = graphicalNote.GraphicalNoteLength;
                 if (calNoteLen < minLength && calNoteLen.Numerator > 0)
                 if (calNoteLen < minLength && calNoteLen.Numerator > 0)
                     minLength = calNoteLen;
                     minLength = calNoteLen;
             }
             }
@@ -180,67 +179,65 @@ export class GraphicalStaffEntry extends GraphicalObject {
         return minLength;
         return minLength;
     }
     }
     public findStaffEntryMaxNoteLength(): Fraction {
     public findStaffEntryMaxNoteLength(): Fraction {
-        var maxLength: Fraction = new Fraction(0, 1);
-        for (var idx: number = 0, len = this.Notes.Count; idx < len; ++idx) {
-            var graphicalNotes: List<GraphicalNote> = this.Notes[idx];
-            for (var idx2: number = 0, len2 = graphicalNotes.Count; idx2 < len2; ++idx2) {
-                var graphicalNote: GraphicalNote = graphicalNotes[idx2];
-                var calNoteLen: Fraction = graphicalNote.GraphicalNoteLength;
+        let maxLength: Fraction = new Fraction(0, 1);
+        for (let idx: number = 0, len: number = this.Notes.length; idx < len; ++idx) {
+            let graphicalNotes: GraphicalNote[] = this.Notes[idx];
+            for (let idx2: number = 0, len2: number = graphicalNotes.length; idx2 < len2; ++idx2) {
+                let graphicalNote: GraphicalNote = graphicalNotes[idx2];
+                let calNoteLen: Fraction = graphicalNote.GraphicalNoteLength;
                 if (calNoteLen > maxLength && calNoteLen.Numerator > 0)
                 if (calNoteLen > maxLength && calNoteLen.Numerator > 0)
                     maxLength = calNoteLen;
                     maxLength = calNoteLen;
             }
             }
         }
         }
         return maxLength;
         return maxLength;
     }
     }
-    public findOrCreateGraphicalNotesListFromVoiceEntry(voiceEntry: VoiceEntry): List<GraphicalNote> {
-        var graphicalNotes: List<GraphicalNote>;
-        if (this.Notes.Count == 0) {
-            graphicalNotes = new List<GraphicalNote>();
-            this.Notes.Add(graphicalNotes);
-        }
-        else {
-            for (var i: number = 0; i < this.Notes.Count; i++) {
-                if (this.Notes[i][0].SourceNote.ParentVoiceEntry.ParentVoice == voiceEntry.ParentVoice)
+    public findOrCreateGraphicalNotesListFromVoiceEntry(voiceEntry: VoiceEntry): GraphicalNote[] {
+        let graphicalNotes: GraphicalNote[];
+        if (this.Notes.length === 0) {
+            graphicalNotes = [];
+            this.Notes.push(graphicalNotes);
+        } else {
+            for (let i: number = 0; i < this.Notes.length; i++) {
+                if (this.Notes[i][0].SourceNote.ParentVoiceEntry.ParentVoice === voiceEntry.ParentVoice)
                     return this.Notes[i];
                     return this.Notes[i];
             }
             }
-            graphicalNotes = new List<GraphicalNote>();
-            this.Notes.Add(graphicalNotes);
+            graphicalNotes = [];
+            this.Notes.push(graphicalNotes);
         }
         }
         return graphicalNotes;
         return graphicalNotes;
     }
     }
-    public findOrCreateGraphicalNotesListFromGraphicalNote(graphicalNote: GraphicalNote): List<GraphicalNote> {
-        var graphicalNotes: List<GraphicalNote>;
-        var tieStartSourceStaffEntry: SourceStaffEntry = graphicalNote.SourceNote.ParentStaffEntry;
-        if (this.SourceStaffEntry != tieStartSourceStaffEntry)
+    public findOrCreateGraphicalNotesListFromGraphicalNote(graphicalNote: GraphicalNote): GraphicalNote[] {
+        let graphicalNotes: GraphicalNote[];
+        let tieStartSourceStaffEntry: SourceStaffEntry = graphicalNote.SourceNote.ParentStaffEntry;
+        if (this.SourceStaffEntry !== tieStartSourceStaffEntry)
             graphicalNotes = this.findOrCreateGraphicalNotesListFromVoiceEntry(graphicalNote.SourceNote.ParentVoiceEntry);
             graphicalNotes = this.findOrCreateGraphicalNotesListFromVoiceEntry(graphicalNote.SourceNote.ParentVoiceEntry);
         else {
         else {
-            if (this.Notes.Count == 0) {
-                graphicalNotes = new List<GraphicalNote>();
-                this.Notes.Add(graphicalNotes);
-            }
-            else {
-                for (var i: number = 0; i < this.Notes.Count; i++) {
-                    if (this.Notes[i][0].SourceNote.ParentVoiceEntry.ParentVoice == graphicalNote.SourceNote.ParentVoiceEntry.ParentVoice) {
+            if (this.Notes.length === 0) {
+                graphicalNotes = [];
+                this.Notes.push(graphicalNotes);
+            } else {
+                for (let i: number = 0; i < this.Notes.length; i++) {
+                    if (this.Notes[i][0].SourceNote.ParentVoiceEntry.ParentVoice === graphicalNote.SourceNote.ParentVoiceEntry.ParentVoice) {
                         return this.Notes[i];
                         return this.Notes[i];
                     }
                     }
                 }
                 }
-                graphicalNotes = new List<GraphicalNote>();
-                this.Notes.Add(graphicalNotes);
+                graphicalNotes = [];
+                this.Notes.push(graphicalNotes);
             }
             }
         }
         }
         return graphicalNotes;
         return graphicalNotes;
     }
     }
-    public addGraphicalNoteToListAtCorrectYPosition(graphicalNotes: List<GraphicalNote>, graphicalNote: GraphicalNote): void {
-        if (graphicalNotes.Count == 0 || graphicalNote.PositionAndShape.RelativePosition.Y < graphicalNotes.Last().PositionAndShape.RelativePosition.Y)
-            graphicalNotes.Add(graphicalNote);
+    public addGraphicalNoteToListAtCorrectYPosition(graphicalNotes: GraphicalNote[], graphicalNote: GraphicalNote): void {
+        if (graphicalNotes.length === 0 || graphicalNote.PositionAndShape.RelativePosition.Y < graphicalNotes.Last().PositionAndShape.RelativePosition.Y)
+            graphicalNotes.push(graphicalNote);
         else {
         else {
-            for (var i: number = graphicalNotes.Count - 1; i >= 0; i--) {
+            for (let i: number = graphicalNotes.length - 1; i >= 0; i--) {
                 if (graphicalNotes[i].PositionAndShape.RelativePosition.Y > graphicalNote.PositionAndShape.RelativePosition.Y) {
                 if (graphicalNotes[i].PositionAndShape.RelativePosition.Y > graphicalNote.PositionAndShape.RelativePosition.Y) {
-                    graphicalNotes.Insert(i + 1, graphicalNote);
+                    graphicalNotes.splice(i + 1, 0, graphicalNote);
                     break;
                     break;
                 }
                 }
-                if (i == 0) {
-                    graphicalNotes.Insert(0, graphicalNote);
+                if (i === 0) {
+                    graphicalNotes.splice(0, 0, graphicalNote);
                     break;
                     break;
                 }
                 }
             }
             }

+ 19 - 19
src/MusicalScore/Graphical/GraphicalStaffEntryLink.ts

@@ -3,7 +3,7 @@ import {GraphicalStaffEntry} from "./GraphicalStaffEntry";
 import {GraphicalNote} from "./GraphicalNote";
 import {GraphicalNote} from "./GraphicalNote";
 export class GraphicalStaffEntryLink {
 export class GraphicalStaffEntryLink {
     private staffEntryLink: StaffEntryLink;
     private staffEntryLink: StaffEntryLink;
-    private graphicalLinkedStaffEntries: List<GraphicalStaffEntry> = new List<GraphicalStaffEntry>();
+    private graphicalLinkedStaffEntries: GraphicalStaffEntry[] = [];
     constructor(staffEntryLink: StaffEntryLink) {
     constructor(staffEntryLink: StaffEntryLink) {
         this.staffEntryLink = staffEntryLink;
         this.staffEntryLink = staffEntryLink;
         this.initialize();
         this.initialize();
@@ -11,40 +11,40 @@ export class GraphicalStaffEntryLink {
     public get GetStaffEntryLink(): StaffEntryLink {
     public get GetStaffEntryLink(): StaffEntryLink {
         return this.staffEntryLink;
         return this.staffEntryLink;
     }
     }
-    public get GraphicalLinkedStaffEntries(): List<GraphicalStaffEntry> {
+    public get GraphicalLinkedStaffEntries(): GraphicalStaffEntry[] {
         return this.graphicalLinkedStaffEntries;
         return this.graphicalLinkedStaffEntries;
     }
     }
-    public set GraphicalLinkedStaffEntries(value: List<GraphicalStaffEntry>) {
+    public set GraphicalLinkedStaffEntries(value: GraphicalStaffEntry[]) {
         this.graphicalLinkedStaffEntries = value;
         this.graphicalLinkedStaffEntries = value;
     }
     }
     public isFilled(): boolean {
     public isFilled(): boolean {
-        for (var i: number = 0; i < this.graphicalLinkedStaffEntries.Count; i++) {
-            if (this.graphicalLinkedStaffEntries[i] == null)
+        for (let i: number = 0; i < this.graphicalLinkedStaffEntries.length; i++) {
+            if (this.graphicalLinkedStaffEntries[i] === undefined)
                 return false;
                 return false;
         }
         }
         return true;
         return true;
     }
     }
-    public getLinkedStaffEntriesGraphicalNotes(graphicalStaffEntry: GraphicalStaffEntry): List<GraphicalNote> {
-        if (this.graphicalLinkedStaffEntries.Contains(graphicalStaffEntry)) {
-            var notes: List<GraphicalNote> = new List<GraphicalNote>();
-            for (var idx: number = 0, len = this.graphicalLinkedStaffEntries.Count; idx < len; ++idx) {
-                var graphicalLinkedStaffEntry: GraphicalStaffEntry = this.graphicalLinkedStaffEntries[idx];
-                for (var idx2: number = 0, len2 = graphicalLinkedStaffEntry.Notes.Count; idx2 < len2; ++idx2) {
-                    var graphicalNotes: List<GraphicalNote> = graphicalLinkedStaffEntry.Notes[idx2];
-                    for (var idx3: number = 0, len3 = graphicalNotes.Count; idx3 < len3; ++idx3) {
-                        var graphicalNote: GraphicalNote = graphicalNotes[idx3];
-                        if (graphicalNote.SourceNote.ParentStaffEntry.Link != null && graphicalNote.SourceNote.ParentVoiceEntry == this.staffEntryLink.GetVoiceEntry)
-                            notes.Add(graphicalNote);
+    public getLinkedStaffEntriesGraphicalNotes(graphicalStaffEntry: GraphicalStaffEntry): GraphicalNote[] {
+        if (this.graphicalLinkedStaffEntries.indexOf(graphicalStaffEntry) !== -1) {
+            let notes: GraphicalNote[] = [];
+            for (let idx: number = 0, len: number = this.graphicalLinkedStaffEntries.length; idx < len; ++idx) {
+                let graphicalLinkedStaffEntry: GraphicalStaffEntry = this.graphicalLinkedStaffEntries[idx];
+                for (let idx2: number = 0, len2: number = graphicalLinkedStaffEntry.Notes.length; idx2 < len2; ++idx2) {
+                    let graphicalNotes: GraphicalNote[] = graphicalLinkedStaffEntry.Notes[idx2];
+                    for (let idx3: number = 0, len3: number = graphicalNotes.length; idx3 < len3; ++idx3) {
+                        let graphicalNote: GraphicalNote = graphicalNotes[idx3];
+                        if (graphicalNote.SourceNote.ParentStaffEntry.Link !== undefined && graphicalNote.SourceNote.ParentVoiceEntry === this.staffEntryLink.GetVoiceEntry)
+                            notes.push(graphicalNote);
                     }
                     }
                 }
                 }
             }
             }
             return notes;
             return notes;
         }
         }
-        return null;
+        return undefined;
     }
     }
     private initialize(): void {
     private initialize(): void {
-        for (var idx: number = 0, len = this.staffEntryLink.LinkStaffEntries.Count; idx < len; ++idx) {
-            this.graphicalLinkedStaffEntries.Add(null);
+        for (let idx: number = 0, len: number = this.staffEntryLink.LinkStaffEntries.length; idx < len; ++idx) {
+            this.graphicalLinkedStaffEntries.push(undefined);
         }
         }
     }
     }
 }
 }

+ 1 - 1
src/MusicalScore/Graphical/GraphicalTie.ts

@@ -4,7 +4,7 @@ export class GraphicalTie {
     private tie: Tie;
     private tie: Tie;
     private startNote: GraphicalNote;
     private startNote: GraphicalNote;
     private endNote: GraphicalNote;
     private endNote: GraphicalNote;
-    constructor(tie: Tie, start: GraphicalNote = null, end: GraphicalNote = null) {
+    constructor(tie: Tie, start: GraphicalNote = undefined, end: GraphicalNote = undefined) {
         this.tie = tie;
         this.tie = tie;
         this.startNote = start;
         this.startNote = start;
         this.endNote = end;
         this.endNote = end;

File diff suppressed because it is too large
+ 346 - 351
src/MusicalScore/Graphical/MusicSheetCalculator.ts


+ 89 - 89
src/MusicalScore/Graphical/MusicSystem.ts

@@ -16,12 +16,12 @@ export class MusicSystem extends GraphicalObject {
     public NeedsToBeRedrawn: boolean = true;
     public NeedsToBeRedrawn: boolean = true;
     protected parent: GraphicalMusicPage;
     protected parent: GraphicalMusicPage;
     protected id: number;
     protected id: number;
-    protected staffLines: List<StaffLine> = new List<StaffLine>();
-    protected graphicalMeasures: List<List<StaffMeasure>> = new List<List<StaffMeasure>>();
+    protected staffLines: StaffLine[] = [];
+    protected graphicalMeasures: StaffMeasure[][] = [];
     protected labels: Dictionary<GraphicalLabel, Instrument> = new Dictionary<GraphicalLabel, Instrument>();
     protected labels: Dictionary<GraphicalLabel, Instrument> = new Dictionary<GraphicalLabel, Instrument>();
-    protected measureNumberLabels: List<GraphicalLabel> = new List<GraphicalLabel>();
+    protected measureNumberLabels: GraphicalLabel[] = [];
     protected maxLabelLength: number;
     protected maxLabelLength: number;
-    protected objectsToRedraw: List<Tuple<List<Object>, Object>> = new List<Tuple<List<Object>, Object>>();
+    protected objectsToRedraw: List<Tuple<Object[], Object>> = new List<Tuple<Object[], Object>>();
     constructor(parent: GraphicalMusicPage, id: number) {
     constructor(parent: GraphicalMusicPage, id: number) {
         this.parent = parent;
         this.parent = parent;
         this.id = id;
         this.id = id;
@@ -34,19 +34,19 @@ export class MusicSystem extends GraphicalObject {
     public set Parent(value: GraphicalMusicPage) {
     public set Parent(value: GraphicalMusicPage) {
         this.parent = value;
         this.parent = value;
     }
     }
-    public get StaffLines(): List<StaffLine> {
+    public get StaffLines(): StaffLine[] {
         return this.staffLines;
         return this.staffLines;
     }
     }
-    public get GraphicalMeasures(): List<List<StaffMeasure>> {
+    public get GraphicalMeasures(): StaffMeasure[][] {
         return this.graphicalMeasures;
         return this.graphicalMeasures;
     }
     }
-    public get MeasureNumberLabels(): List<GraphicalLabel> {
+    public get MeasureNumberLabels(): GraphicalLabel[] {
         return this.measureNumberLabels;
         return this.measureNumberLabels;
     }
     }
-    public get Labels(): List<GraphicalLabel> {
+    public get Labels(): GraphicalLabel[] {
         return this.labels.Keys.ToList();
         return this.labels.Keys.ToList();
     }
     }
-    public get ObjectsToRedraw(): List<Tuple<List<Object>, Object>> {
+    public get ObjectsToRedraw(): List<Tuple<Object[], Object>> {
         return this.objectsToRedraw;
         return this.objectsToRedraw;
     }
     }
     public get Id(): number {
     public get Id(): number {
@@ -68,86 +68,86 @@ export class MusicSystem extends GraphicalObject {
     public GetRightBorderAbsoluteXPosition(): number {
     public GetRightBorderAbsoluteXPosition(): number {
         return this.StaffLines[0].PositionAndShape.AbsolutePosition.X + this.StaffLines[0].StaffLines[0].End.X;
         return this.StaffLines[0].PositionAndShape.AbsolutePosition.X + this.StaffLines[0].StaffLines[0].End.X;
     }
     }
-    public AddStaffMeasures(graphicalMeasures: List<StaffMeasure>): void {
-        for (var idx: number = 0, len = graphicalMeasures.Count; idx < len; ++idx) {
-            var graphicalMeasure: StaffMeasure = graphicalMeasures[idx];
+    public AddStaffMeasures(graphicalMeasures: StaffMeasure[]): void {
+        for (let idx: number = 0, len: number = graphicalMeasures.length; idx < len; ++idx) {
+            let graphicalMeasure: StaffMeasure = graphicalMeasures[idx];
             graphicalMeasure.ParentMusicSystem = this;
             graphicalMeasure.ParentMusicSystem = this;
         }
         }
-        this.graphicalMeasures.Add(graphicalMeasures);
+        this.graphicalMeasures.push(graphicalMeasures);
     }
     }
     public GetSystemsFirstTimeStamp(): Fraction {
     public GetSystemsFirstTimeStamp(): Fraction {
         return this.graphicalMeasures[0][0].ParentSourceMeasure.AbsoluteTimestamp;
         return this.graphicalMeasures[0][0].ParentSourceMeasure.AbsoluteTimestamp;
     }
     }
     public GetSystemsLastTimeStamp(): Fraction {
     public GetSystemsLastTimeStamp(): Fraction {
-        var m: SourceMeasure = this.graphicalMeasures[this.graphicalMeasures.Count - 1][0].ParentSourceMeasure;
+        let m: SourceMeasure = this.graphicalMeasures[this.graphicalMeasures.length - 1][0].ParentSourceMeasure;
         return m.AbsoluteTimestamp + m.Duration;
         return m.AbsoluteTimestamp + m.Duration;
     }
     }
-    public createInstrumentBrackets(instruments: List<Instrument>, staffHeight: number): void {
-        for (var idx: number = 0, len = instruments.Count; idx < len; ++idx) {
-            var instrument: Instrument = instruments[idx];
-            if (instrument.Staves.Count > 1) {
-                var firstStaffLine: StaffLine = null, lastStaffLine = null;
-                for (var idx2: number = 0, len2 = this.staffLines.Count; idx2 < len2; ++idx2) {
-                    var staffLine: StaffLine = this.staffLines[idx2];
-                    if (staffLine.ParentStaff == instrument.Staves[0])
+    public createInstrumentBrackets(instruments: Instrument[], staffHeight: number): void {
+        for (let idx: number = 0, len: number = instruments.length; idx < len; ++idx) {
+            let instrument: Instrument = instruments[idx];
+            if (instrument.Staves.length > 1) {
+                let firstStaffLine: StaffLine = undefined, lastStaffLine = undefined;
+                for (let idx2: number = 0, len2: number = this.staffLines.length; idx2 < len2; ++idx2) {
+                    let staffLine: StaffLine = this.staffLines[idx2];
+                    if (staffLine.ParentStaff === instrument.Staves[0])
                         firstStaffLine = staffLine;
                         firstStaffLine = staffLine;
-                    if (staffLine.ParentStaff == instrument.Staves[instrument.Staves.Count - 1])
+                    if (staffLine.ParentStaff === instrument.Staves[instrument.Staves.length - 1])
                         lastStaffLine = staffLine;
                         lastStaffLine = staffLine;
                 }
                 }
-                if (firstStaffLine != null && lastStaffLine != null) {
-                    var rightUpper: PointF_2D = new PointF_2D(firstStaffLine.PositionAndShape.RelativePosition.X,
+                if (firstStaffLine !== undefined && lastStaffLine !== undefined) {
+                    let rightUpper: PointF_2D = new PointF_2D(firstStaffLine.PositionAndShape.RelativePosition.X,
                         firstStaffLine.PositionAndShape.RelativePosition.Y);
                         firstStaffLine.PositionAndShape.RelativePosition.Y);
-                    var rightLower: PointF_2D = new PointF_2D(lastStaffLine.PositionAndShape.RelativePosition.X,
+                    let rightLower: PointF_2D = new PointF_2D(lastStaffLine.PositionAndShape.RelativePosition.X,
                         lastStaffLine.PositionAndShape.RelativePosition.Y + staffHeight);
                         lastStaffLine.PositionAndShape.RelativePosition.Y + staffHeight);
                     this.createInstrumentBracket(rightUpper, rightLower);
                     this.createInstrumentBracket(rightUpper, rightLower);
                 }
                 }
             }
             }
         }
         }
     }
     }
-    public createGroupBrackets(instrumentGroups: List<InstrumentalGroup>, staffHeight: number, recursionDepth: number): void {
-        for (var idx: number = 0, len = instrumentGroups.Count; idx < len; ++idx) {
-            var instrumentGroup: InstrumentalGroup = instrumentGroups[idx];
-            if (instrumentGroup.InstrumentalGroups.Count < 1)
+    public createGroupBrackets(instrumentGroups: InstrumentalGroup[], staffHeight: number, recursionDepth: number): void {
+        for (let idx: number = 0, len: number = instrumentGroups.length; idx < len; ++idx) {
+            let instrumentGroup: InstrumentalGroup = instrumentGroups[idx];
+            if (instrumentGroup.InstrumentalGroups.length < 1)
                 continue;
                 continue;
-            var instrument1: Instrument = this.findFirstVisibleInstrumentInInstrumentalGroup(instrumentGroup);
-            var instrument2: Instrument = this.findLastVisibleInstrumentInInstrumentalGroup(instrumentGroup);
-            if (instrument1 == null || instrument2 == null)
+            let instrument1: Instrument = this.findFirstVisibleInstrumentInInstrumentalGroup(instrumentGroup);
+            let instrument2: Instrument = this.findLastVisibleInstrumentInInstrumentalGroup(instrumentGroup);
+            if (instrument1 === undefined || instrument2 === undefined)
                 continue;
                 continue;
-            var firstStaffLine: StaffLine = null, lastStaffLine = null;
-            for (var idx2: number = 0, len2 = this.staffLines.Count; idx2 < len2; ++idx2) {
-                var staffLine: StaffLine = this.staffLines[idx2];
-                if (staffLine.ParentStaff == instrument1.Staves[0])
+            let firstStaffLine: StaffLine = undefined, lastStaffLine = undefined;
+            for (let idx2: number = 0, len2: number = this.staffLines.length; idx2 < len2; ++idx2) {
+                let staffLine: StaffLine = this.staffLines[idx2];
+                if (staffLine.ParentStaff === instrument1.Staves[0])
                     firstStaffLine = staffLine;
                     firstStaffLine = staffLine;
-                if (staffLine.ParentStaff == instrument2.Staves.Last())
+                if (staffLine.ParentStaff === instrument2.Staves.Last())
                     lastStaffLine = staffLine;
                     lastStaffLine = staffLine;
             }
             }
-            if (firstStaffLine != null && lastStaffLine != null) {
-                var rightUpper: PointF_2D = new PointF_2D(firstStaffLine.PositionAndShape.RelativePosition.X,
+            if (firstStaffLine !== undefined && lastStaffLine !== undefined) {
+                let rightUpper: PointF_2D = new PointF_2D(firstStaffLine.PositionAndShape.RelativePosition.X,
                     firstStaffLine.PositionAndShape.RelativePosition.Y);
                     firstStaffLine.PositionAndShape.RelativePosition.Y);
-                var rightLower: PointF_2D = new PointF_2D(lastStaffLine.PositionAndShape.RelativePosition.X,
+                let rightLower: PointF_2D = new PointF_2D(lastStaffLine.PositionAndShape.RelativePosition.X,
                     lastStaffLine.PositionAndShape.RelativePosition.Y + staffHeight);
                     lastStaffLine.PositionAndShape.RelativePosition.Y + staffHeight);
                 this.createGroupBracket(rightUpper, rightLower, staffHeight, recursionDepth);
                 this.createGroupBracket(rightUpper, rightLower, staffHeight, recursionDepth);
             }
             }
-            if (instrumentGroup.InstrumentalGroups.Count < 1)
+            if (instrumentGroup.InstrumentalGroups.length < 1)
                 continue;
                 continue;
             this.createGroupBrackets(instrumentGroup.InstrumentalGroups, staffHeight, recursionDepth + 1);
             this.createGroupBrackets(instrumentGroup.InstrumentalGroups, staffHeight, recursionDepth + 1);
         }
         }
     }
     }
     public createMusicSystemLabel(instrumentLabelTextHeight: number, systemLabelsRightMargin: number, labelMarginBorderFactor: number): void {
     public createMusicSystemLabel(instrumentLabelTextHeight: number, systemLabelsRightMargin: number, labelMarginBorderFactor: number): void {
-        if (this.parent == this.parent.Parent.MusicPages[0] && this == this.parent.MusicSystems[0]) {
-            var instruments: Instrument[] = this.parent.Parent.ParentMusicSheet.Instruments.Where(i => i.Voices.Count > 0 && i.Voices[0].Visible).ToArray();
-            for (var idx: number = 0, len = instruments.length; idx < len; ++idx) {
-                var instrument: Instrument = instruments[idx];
-                var graphicalLabel: GraphicalLabel = new GraphicalLabel(instrument.NameLabel, instrumentLabelTextHeight, TextAlignment.LeftCenter, this.boundingBox);
+        if (this.parent === this.parent.Parent.MusicPages[0] && this === this.parent.MusicSystems[0]) {
+            let instruments: Instrument[] = this.parent.Parent.ParentMusicSheet.Instruments.Where(i => i.Voices.length > 0 && i.Voices[0].Visible);
+            for (let idx: number = 0, len: number = instruments.length; idx < len; ++idx) {
+                let instrument: Instrument = instruments[idx];
+                let graphicalLabel: GraphicalLabel = new GraphicalLabel(instrument.NameLabel, instrumentLabelTextHeight, TextAlignment.LeftCenter, this.boundingBox);
                 graphicalLabel.setLabelPositionAndShapeBorders();
                 graphicalLabel.setLabelPositionAndShapeBorders();
-                this.labels.Add(graphicalLabel, instrument);
-                this.boundingBox.ChildElements.Add(graphicalLabel.PositionAndShape);
+                this.labels.push(graphicalLabel, instrument);
+                this.boundingBox.ChildElements.push(graphicalLabel.PositionAndShape);
                 graphicalLabel.PositionAndShape.RelativePosition = new PointF_2D(0.0, 0.0);
                 graphicalLabel.PositionAndShape.RelativePosition = new PointF_2D(0.0, 0.0);
             }
             }
             this.maxLabelLength = 0.0;
             this.maxLabelLength = 0.0;
-            var labels: GraphicalLabel[] = this.labels.Keys.ToArray();
-            for (var idx: number = 0, len = labels.length; idx < len; ++idx) {
-                var label: GraphicalLabel = labels[idx];
+            let labels: GraphicalLabel[] = this.labels.Keys;
+            for (let idx: number = 0, len: number = labels.length; idx < len; ++idx) {
+                let label: GraphicalLabel = labels[idx];
                 if (label.PositionAndShape.Size.Width > this.maxLabelLength)
                 if (label.PositionAndShape.Size.Width > this.maxLabelLength)
                     this.maxLabelLength = label.PositionAndShape.Size.Width;
                     this.maxLabelLength = label.PositionAndShape.Size.Width;
             }
             }
@@ -155,17 +155,17 @@ export class MusicSystem extends GraphicalObject {
         }
         }
     }
     }
     public setMusicSystemLabelsYPosition(): void {
     public setMusicSystemLabelsYPosition(): void {
-        if (this.parent == this.parent.Parent.MusicPages[0] && this == this.parent.MusicSystems[0]) {
-            var labels: KeyValuePair<GraphicalLabel, Instrument>[] = this.labels.ToArray();
-            for (var idx: number = 0, len = labels.length; idx < len; ++idx) {
-                var entry: KeyValuePair<GraphicalLabel, Instrument> = labels[idx];
-                var ypositionSum: number = 0;
-                var staffCounter: number = 0;
-                for (var i: number = 0; i < this.staffLines.Count; i++) {
-                    if (this.staffLines[i].ParentStaff.ParentInstrument == entry.Value) {
-                        for (var j: number = i; j < this.staffLines.Count; j++) {
-                            var staffLine: StaffLine = this.staffLines[j];
-                            if (staffLine.ParentStaff.ParentInstrument != entry.Value)
+        if (this.parent === this.parent.Parent.MusicPages[0] && this === this.parent.MusicSystems[0]) {
+            let labels: KeyValuePair<GraphicalLabel, Instrument>[] = this.labels;
+            for (let idx: number = 0, len: number = labels.length; idx < len; ++idx) {
+                let entry: KeyValuePair<GraphicalLabel, Instrument> = labels[idx];
+                let ypositionSum: number = 0;
+                let staffCounter: number = 0;
+                for (let i: number = 0; i < this.staffLines.length; i++) {
+                    if (this.staffLines[i].ParentStaff.ParentInstrument === entry.Value) {
+                        for (let j: number = i; j < this.staffLines.length; j++) {
+                            let staffLine: StaffLine = this.staffLines[j];
+                            if (staffLine.ParentStaff.ParentInstrument !== entry.Value)
                                 break;
                                 break;
                             ypositionSum += staffLine.PositionAndShape.RelativePosition.Y;
                             ypositionSum += staffLine.PositionAndShape.RelativePosition.Y;
                             staffCounter++;
                             staffCounter++;
@@ -179,22 +179,22 @@ export class MusicSystem extends GraphicalObject {
         }
         }
     }
     }
     public checkStaffEntriesForStaffEntryLink(): boolean {
     public checkStaffEntriesForStaffEntryLink(): boolean {
-        var first: boolean = false;
-        var second: boolean = false;
-        for (var i: number = 0; i < this.staffLines.Count - 1; i++) {
-            for (var idx: number = 0, len = this.staffLines[i].Measures.Count; idx < len; ++idx) {
-                var measure: StaffMeasure = this.staffLines[i].Measures[idx];
-                for (var idx2: number = 0, len2 = measure.StaffEntries.Count; idx2 < len2; ++idx2) {
-                    var staffEntry: GraphicalStaffEntry = measure.StaffEntries[idx2];
-                    if (staffEntry.SourceStaffEntry.Link != null)
+        let first: boolean = false;
+        let second: boolean = false;
+        for (let i: number = 0; i < this.staffLines.length - 1; i++) {
+            for (let idx: number = 0, len: number = this.staffLines[i].Measures.length; idx < len; ++idx) {
+                let measure: StaffMeasure = this.staffLines[i].Measures[idx];
+                for (let idx2: number = 0, len2: number = measure.StaffEntries.length; idx2 < len2; ++idx2) {
+                    let staffEntry: GraphicalStaffEntry = measure.StaffEntries[idx2];
+                    if (staffEntry.SourceStaffEntry.Link !== undefined)
                         first = true;
                         first = true;
                 }
                 }
             }
             }
-            for (var idx: number = 0, len = this.staffLines[i + 1].Measures.Count; idx < len; ++idx) {
-                var measure: StaffMeasure = this.staffLines[i + 1].Measures[idx];
-                for (var idx2: number = 0, len2 = measure.StaffEntries.Count; idx2 < len2; ++idx2) {
-                    var staffEntry: GraphicalStaffEntry = measure.StaffEntries[idx2];
-                    if (staffEntry.SourceStaffEntry.Link != null)
+            for (let idx: number = 0, len: number = this.staffLines[i + 1].Measures.length; idx < len; ++idx) {
+                let measure: StaffMeasure = this.staffLines[i + 1].Measures[idx];
+                for (let idx2: number = 0, len2: number = measure.StaffEntries.length; idx2 < len2; ++idx2) {
+                    let staffEntry: GraphicalStaffEntry = measure.StaffEntries[idx2];
+                    if (staffEntry.SourceStaffEntry.Link !== undefined)
                         second = true;
                         second = true;
                 }
                 }
             }
             }
@@ -208,39 +208,39 @@ export class MusicSystem extends GraphicalObject {
     protected createGroupBracket(rightUpper: PointF_2D, rightLower: PointF_2D, staffHeight: number,
     protected createGroupBracket(rightUpper: PointF_2D, rightLower: PointF_2D, staffHeight: number,
         recursionDepth: number): void { throw new Error('not implemented'); }
         recursionDepth: number): void { throw new Error('not implemented'); }
     private findFirstVisibleInstrumentInInstrumentalGroup(instrumentalGroup: InstrumentalGroup): Instrument {
     private findFirstVisibleInstrumentInInstrumentalGroup(instrumentalGroup: InstrumentalGroup): Instrument {
-        for (var idx: number = 0, len = instrumentalGroup.InstrumentalGroups.Count; idx < len; ++idx) {
-            var groupOrInstrument: InstrumentalGroup = instrumentalGroup.InstrumentalGroups[idx];
+        for (let idx: number = 0, len: number = instrumentalGroup.InstrumentalGroups.length; idx < len; ++idx) {
+            let groupOrInstrument: InstrumentalGroup = instrumentalGroup.InstrumentalGroups[idx];
             if (groupOrInstrument instanceof Instrument) {
             if (groupOrInstrument instanceof Instrument) {
-                if ((<Instrument>groupOrInstrument).Visible == true)
+                if ((<Instrument>groupOrInstrument).Visible === true)
                     return <Instrument>groupOrInstrument;
                     return <Instrument>groupOrInstrument;
                 continue;
                 continue;
             }
             }
             return this.findFirstVisibleInstrumentInInstrumentalGroup(groupOrInstrument);
             return this.findFirstVisibleInstrumentInInstrumentalGroup(groupOrInstrument);
         }
         }
-        return null;
+        return undefined;
     }
     }
     private findLastVisibleInstrumentInInstrumentalGroup(instrumentalGroup: InstrumentalGroup): Instrument {
     private findLastVisibleInstrumentInInstrumentalGroup(instrumentalGroup: InstrumentalGroup): Instrument {
-        var groupOrInstrument: InstrumentalGroup;
-        for (var i: number = instrumentalGroup.InstrumentalGroups.Count - 1; i >= 0; i--) {
+        let groupOrInstrument: InstrumentalGroup;
+        for (let i: number = instrumentalGroup.InstrumentalGroups.length - 1; i >= 0; i--) {
             groupOrInstrument = instrumentalGroup.InstrumentalGroups[i];
             groupOrInstrument = instrumentalGroup.InstrumentalGroups[i];
             if (groupOrInstrument instanceof Instrument) {
             if (groupOrInstrument instanceof Instrument) {
-                if ((<Instrument>groupOrInstrument).Visible == true)
+                if ((<Instrument>groupOrInstrument).Visible === true)
                     return <Instrument>groupOrInstrument;
                     return <Instrument>groupOrInstrument;
                 continue;
                 continue;
             }
             }
             return this.findLastVisibleInstrumentInInstrumentalGroup(groupOrInstrument);
             return this.findLastVisibleInstrumentInInstrumentalGroup(groupOrInstrument);
         }
         }
-        return null;
+        return undefined;
     }
     }
     private updateMusicSystemStaffLineXPosition(systemLabelsRightMargin: number): void {
     private updateMusicSystemStaffLineXPosition(systemLabelsRightMargin: number): void {
-        for (var idx: number = 0, len = this.StaffLines.Count; idx < len; ++idx) {
-            var staffLine: StaffLine = this.StaffLines[idx];
-            var relative: PointF_2D = staffLine.PositionAndShape.RelativePosition;
+        for (let idx: number = 0, len: number = this.StaffLines.length; idx < len; ++idx) {
+            let staffLine: StaffLine = this.StaffLines[idx];
+            let relative: PointF_2D = staffLine.PositionAndShape.RelativePosition;
             relative.X = this.maxLabelLength + systemLabelsRightMargin;
             relative.X = this.maxLabelLength + systemLabelsRightMargin;
             staffLine.PositionAndShape.RelativePosition = relative;
             staffLine.PositionAndShape.RelativePosition = relative;
             staffLine.PositionAndShape.BorderRight = this.boundingBox.Size.Width - this.maxLabelLength - systemLabelsRightMargin;
             staffLine.PositionAndShape.BorderRight = this.boundingBox.Size.Width - this.maxLabelLength - systemLabelsRightMargin;
-            for (var i: number = 0; i < staffLine.StaffLines.Length; i++) {
-                var lineEnd: PointF_2D = new PointF_2D(staffLine.PositionAndShape.Size.Width, staffLine.StaffLines[i].End.Y);
+            for (let i: number = 0; i < staffLine.StaffLines.Length; i++) {
+                let lineEnd: PointF_2D = new PointF_2D(staffLine.PositionAndShape.Size.Width, staffLine.StaffLines[i].End.Y);
                 staffLine.StaffLines[i].End = lineEnd;
                 staffLine.StaffLines[i].End = lineEnd;
             }
             }
         }
         }

+ 271 - 279
src/MusicalScore/Graphical/MusicSystemBuilder.ts

@@ -17,7 +17,7 @@ import {SourceStaffEntry} from "../VoiceData/SourceStaffEntry";
 import {AbstractNotationInstruction} from "../VoiceData/Instructions/AbstractNotationInstruction";
 import {AbstractNotationInstruction} from "../VoiceData/Instructions/AbstractNotationInstruction";
 import {SystemLinesEnum} from "./SystemLinesEnum";
 import {SystemLinesEnum} from "./SystemLinesEnum";
 export class MusicSystemBuilder {
 export class MusicSystemBuilder {
-    private measureList: List<List<StaffMeasure>>;
+    private measureList: StaffMeasure[][];
     private graphicalMusicSheet: GraphicalMusicSheet;
     private graphicalMusicSheet: GraphicalMusicSheet;
     private currentMusicPage: GraphicalMusicPage;
     private currentMusicPage: GraphicalMusicPage;
     private currentPageHeight: number;
     private currentPageHeight: number;
@@ -32,7 +32,7 @@ export class MusicSystemBuilder {
     private globalSystemIndex: number = 0;
     private globalSystemIndex: number = 0;
     private leadSheet: boolean = false;
     private leadSheet: boolean = false;
     private symbolFactory: IGraphicalSymbolFactory;
     private symbolFactory: IGraphicalSymbolFactory;
-    public initialize(graphicalMusicSheet: GraphicalMusicSheet, measureList: List<List<StaffMeasure>>,
+    public initialize(graphicalMusicSheet: GraphicalMusicSheet, measureList: StaffMeasure[][],
         numberOfStaffLines: number, symbolFactory: IGraphicalSymbolFactory): void {
         numberOfStaffLines: number, symbolFactory: IGraphicalSymbolFactory): void {
         this.leadSheet = graphicalMusicSheet.LeadSheet;
         this.leadSheet = graphicalMusicSheet.LeadSheet;
         this.graphicalMusicSheet = graphicalMusicSheet;
         this.graphicalMusicSheet = graphicalMusicSheet;
@@ -40,7 +40,7 @@ export class MusicSystemBuilder {
         this.measureList = measureList;
         this.measureList = measureList;
         this.symbolFactory = symbolFactory;
         this.symbolFactory = symbolFactory;
         this.currentMusicPage = this.createMusicPage();
         this.currentMusicPage = this.createMusicPage();
-        this.currentPageHeight = 0.0f;
+        this.currentPageHeight = 0.0;
         this.numberOfVisibleStaffLines = numberOfStaffLines;
         this.numberOfVisibleStaffLines = numberOfStaffLines;
         this.activeRhythm = new Array(this.numberOfVisibleStaffLines);
         this.activeRhythm = new Array(this.numberOfVisibleStaffLines);
         this.activeKeys = new Array(this.numberOfVisibleStaffLines);
         this.activeKeys = new Array(this.numberOfVisibleStaffLines);
@@ -48,8 +48,8 @@ export class MusicSystemBuilder {
         initializeActiveInstructions(this.measureList[0]);
         initializeActiveInstructions(this.measureList[0]);
     }
     }
     public buildMusicSystems(): void {
     public buildMusicSystems(): void {
-        var previousMeasureEndsSystem: boolean = false;
-        var systemMaxWidth: number = this.getFullPageSystemWidth();
+        let previousMeasureEndsSystem: boolean = false;
+        let systemMaxWidth: number = this.getFullPageSystemWidth();
         this.measureListIndex = 0;
         this.measureListIndex = 0;
         this.currentSystemParams = new SystemBuildParameters();
         this.currentSystemParams = new SystemBuildParameters();
         this.currentSystemParams.currentSystem = this.initMusicSystem();
         this.currentSystemParams.currentSystem = this.initMusicSystem();
@@ -58,53 +58,52 @@ export class MusicSystemBuilder {
             this.rules.SystemLabelsRightMargin,
             this.rules.SystemLabelsRightMargin,
             this.rules.LabelMarginBorderFactor);
             this.rules.LabelMarginBorderFactor);
         this.currentPageHeight += this.currentSystemParams.currentSystem.PositionAndShape.RelativePosition.Y;
         this.currentPageHeight += this.currentSystemParams.currentSystem.PositionAndShape.RelativePosition.Y;
-        var numberOfMeasures: number = this.measureList.Count(m => m.Any());
+        let numberOfMeasures: number = this.measureList.length(m => m.Any());
         while (this.measureListIndex < numberOfMeasures) {
         while (this.measureListIndex < numberOfMeasures) {
-            var staffMeasures: List<StaffMeasure> = this.measureList[this.measureListIndex];
-            for (var idx: number = 0, len = staffMeasures.Count; idx < len; ++idx)
+            let staffMeasures: StaffMeasure[] = this.measureList[this.measureListIndex];
+            for (let idx: number = 0, len: number = staffMeasures.length; idx < len; ++idx)
                 staffMeasures[idx].ResetLayout();
                 staffMeasures[idx].ResetLayout();
-            var sourceMeasure: SourceMeasure = staffMeasures[0].ParentSourceMeasure;
-            var sourceMeasureEndsSystem: boolean = sourceMeasure.BreakSystemAfter;
-            var isSystemStartMeasure: boolean = this.currentSystemParams.IsSystemStartMeasure();
-            var isFirstSourceMeasure: boolean = sourceMeasure == this.graphicalMusicSheet.ParentMusicSheet.getFirstSourceMeasure();
-            var currentMeasureBeginInstructionsWidth: number = this.rules.MeasureLeftMargin;
-            var currentMeasureEndInstructionsWidth: number = 0;
-            var measureStartLine: SystemLinesEnum = this.getMeasureStartLine();
+            let sourceMeasure: SourceMeasure = staffMeasures[0].ParentSourceMeasure;
+            let sourceMeasureEndsSystem: boolean = sourceMeasure.BreakSystemAfter;
+            let isSystemStartMeasure: boolean = this.currentSystemParams.IsSystemStartMeasure();
+            let isFirstSourceMeasure: boolean = sourceMeasure === this.graphicalMusicSheet.ParentMusicSheet.getFirstSourceMeasure();
+            let currentMeasureBeginInstructionsWidth: number = this.rules.MeasureLeftMargin;
+            let currentMeasureEndInstructionsWidth: number = 0;
+            let measureStartLine: SystemLinesEnum = this.getMeasureStartLine();
             currentMeasureBeginInstructionsWidth += getLineWidth(staffMeasures[0], measureStartLine, isSystemStartMeasure);
             currentMeasureBeginInstructionsWidth += getLineWidth(staffMeasures[0], measureStartLine, isSystemStartMeasure);
             if (!this.leadSheet) {
             if (!this.leadSheet) {
                 currentMeasureBeginInstructionsWidth += this.addBeginInstructions(staffMeasures, isSystemStartMeasure, isFirstSourceMeasure);
                 currentMeasureBeginInstructionsWidth += this.addBeginInstructions(staffMeasures, isSystemStartMeasure, isFirstSourceMeasure);
                 currentMeasureEndInstructionsWidth += this.addEndInstructions(staffMeasures);
                 currentMeasureEndInstructionsWidth += this.addEndInstructions(staffMeasures);
             }
             }
-            var currentMeasureVarWidth: number = 0;
-            for (var i: number = 0; i < this.numberOfVisibleStaffLines; i++)
-                currentMeasureVarWidth = Math.Max(currentMeasureVarWidth, staffMeasures[i].MinimumStaffEntriesWidth);
-            var measureEndLine: SystemLinesEnum = this.getMeasureEndLine();
+            let currentMeasureVarWidth: number = 0;
+            for (let i: number = 0; i < this.numberOfVisibleStaffLines; i++)
+                currentMeasureVarWidth = Math.max(currentMeasureVarWidth, staffMeasures[i].MinimumStaffEntriesWidth);
+            let measureEndLine: SystemLinesEnum = this.getMeasureEndLine();
             currentMeasureEndInstructionsWidth += getLineWidth(staffMeasures[0], measureEndLine, isSystemStartMeasure);
             currentMeasureEndInstructionsWidth += getLineWidth(staffMeasures[0], measureEndLine, isSystemStartMeasure);
-            var nextMeasureBeginInstructionWidth: number = this.rules.MeasureLeftMargin;
-            if (this.measureListIndex + 1 < this.measureList.Count) {
-                var nextStaffMeasures: List<StaffMeasure> = this.measureList[this.measureListIndex + 1];
-                var nextSourceMeasure: SourceMeasure = nextStaffMeasures[0].ParentSourceMeasure;
+            let nextMeasureBeginInstructionWidth: number = this.rules.MeasureLeftMargin;
+            if (this.measureListIndex + 1 < this.measureList.length) {
+                let nextStaffMeasures: StaffMeasure[] = this.measureList[this.measureListIndex + 1];
+                let nextSourceMeasure: SourceMeasure = nextStaffMeasures[0].ParentSourceMeasure;
                 if (nextSourceMeasure.hasBeginInstructions()) {
                 if (nextSourceMeasure.hasBeginInstructions()) {
                     nextMeasureBeginInstructionWidth += this.addBeginInstructions(nextStaffMeasures, false, false);
                     nextMeasureBeginInstructionWidth += this.addBeginInstructions(nextStaffMeasures, false, false);
                 }
                 }
             }
             }
-            var totalMeasureWidth: number = currentMeasureBeginInstructionsWidth + currentMeasureEndInstructionsWidth + currentMeasureVarWidth;
-            var measureFitsInSystem: boolean = this.currentSystemParams.currentWidth + totalMeasureWidth + nextMeasureBeginInstructionWidth < systemMaxWidth;
+            let totalMeasureWidth: number = currentMeasureBeginInstructionsWidth + currentMeasureEndInstructionsWidth + currentMeasureVarWidth;
+            let measureFitsInSystem: boolean = this.currentSystemParams.currentWidth + totalMeasureWidth + nextMeasureBeginInstructionWidth < systemMaxWidth;
             if (isSystemStartMeasure || measureFitsInSystem) {
             if (isSystemStartMeasure || measureFitsInSystem) {
                 this.addMeasureToSystem(staffMeasures, measureStartLine, measureEndLine, totalMeasureWidth, currentMeasureBeginInstructionsWidth, currentMeasureVarWidth, currentMeasureEndInstructionsWidth);
                 this.addMeasureToSystem(staffMeasures, measureStartLine, measureEndLine, totalMeasureWidth, currentMeasureBeginInstructionsWidth, currentMeasureVarWidth, currentMeasureEndInstructionsWidth);
                 this.updateActiveClefs(sourceMeasure, staffMeasures);
                 this.updateActiveClefs(sourceMeasure, staffMeasures);
                 this.measureListIndex++;
                 this.measureListIndex++;
-            }
-            else {
+            } else {
                 this.finalizeCurrentAndCreateNewSystem(staffMeasures, previousMeasureEndsSystem);
                 this.finalizeCurrentAndCreateNewSystem(staffMeasures, previousMeasureEndsSystem);
             }
             }
             previousMeasureEndsSystem = sourceMeasureEndsSystem;
             previousMeasureEndsSystem = sourceMeasureEndsSystem;
         }
         }
-        finalizeCurrentAndCreateNewSystem(this.measureList[this.measureList.Count - 1], true);
+        finalizeCurrentAndCreateNewSystem(this.measureList[this.measureList.length - 1], true);
     }
     }
-    private setMeasureWidth(staffMeasures: List<StaffMeasure>, width: number, beginInstrWidth: number, endInstrWidth: number): void {
-        for (var idx: number = 0, len = staffMeasures.Count; idx < len; ++idx) {
-            var measure: StaffMeasure = staffMeasures[idx];
+    private setMeasureWidth(staffMeasures: StaffMeasure[], width: number, beginInstrWidth: number, endInstrWidth: number): void {
+        for (let idx: number = 0, len: number = staffMeasures.length; idx < len; ++idx) {
+            let measure: StaffMeasure = staffMeasures[idx];
             measure.SetWidth(width);
             measure.SetWidth(width);
             if (beginInstrWidth > 0)
             if (beginInstrWidth > 0)
                 measure.BeginInstructionsWidth = beginInstrWidth;
                 measure.BeginInstructionsWidth = beginInstrWidth;
@@ -112,7 +111,7 @@ export class MusicSystemBuilder {
                 measure.EndInstructionsWidth = endInstrWidth;
                 measure.EndInstructionsWidth = endInstrWidth;
         }
         }
     }
     }
-    private finalizeCurrentAndCreateNewSystem(measures: List<StaffMeasure>, isPartEndingSystem: boolean = false): void {
+    private finalizeCurrentAndCreateNewSystem(measures: StaffMeasure[], isPartEndingSystem: boolean = false): void {
         this.adaptRepetitionLineWithIfNeeded();
         this.adaptRepetitionLineWithIfNeeded();
         if (!isPartEndingSystem) {
         if (!isPartEndingSystem) {
             this.checkAndCreateExtraInstructionMeasure(measures);
             this.checkAndCreateExtraInstructionMeasure(measures);
@@ -124,36 +123,35 @@ export class MusicSystemBuilder {
                 this.currentMusicPage = this.createMusicPage();
                 this.currentMusicPage = this.createMusicPage();
                 this.currentPageHeight = this.rules.PageTopMargin + this.rules.TitleTopDistance;
                 this.currentPageHeight = this.rules.PageTopMargin + this.rules.TitleTopDistance;
             }
             }
-        }
-        else {
+        } else {
             this.currentMusicPage = this.createMusicPage();
             this.currentMusicPage = this.createMusicPage();
             this.currentPageHeight = this.rules.PageTopMargin + this.rules.TitleTopDistance;
             this.currentPageHeight = this.rules.PageTopMargin + this.rules.TitleTopDistance;
         }
         }
         this.currentSystemParams = new SystemBuildParameters();
         this.currentSystemParams = new SystemBuildParameters();
-        if (this.measureListIndex < this.measureList.Count) {
+        if (this.measureListIndex < this.measureList.length) {
             this.currentSystemParams.currentSystem = this.initMusicSystem();
             this.currentSystemParams.currentSystem = this.initMusicSystem();
             this.layoutSystemStaves();
             this.layoutSystemStaves();
         }
         }
     }
     }
     private adaptRepetitionLineWithIfNeeded(): void {
     private adaptRepetitionLineWithIfNeeded(): void {
-        var systemMeasures: List<MeasureBuildParameters> = this.currentSystemParams.systemMeasures;
-        if (systemMeasures.Count >= 1) {
-            var measures: List<StaffMeasure> = this.currentSystemParams.currentSystem.GraphicalMeasures[this.currentSystemParams.currentSystem.GraphicalMeasures.Count - 1];
-            var measureParams: MeasureBuildParameters = systemMeasures[systemMeasures.Count - 1];
-            var diff: number = 0.0f;
-            if (measureParams.endLine == SystemLinesEnum.DotsBoldBoldDots) {
+        let systemMeasures: MeasureBuildParameters[] = this.currentSystemParams.systemMeasures;
+        if (systemMeasures.length >= 1) {
+            let measures: StaffMeasure[] = this.currentSystemParams.currentSystem.GraphicalMeasures[this.currentSystemParams.currentSystem.GraphicalMeasures.length - 1];
+            let measureParams: MeasureBuildParameters = systemMeasures[systemMeasures.length - 1];
+            let diff: number = 0.0;
+            if (measureParams.endLine === SystemLinesEnum.DotsBoldBoldDots) {
                 measureParams.endLine = SystemLinesEnum.DotsThinBold;
                 measureParams.endLine = SystemLinesEnum.DotsThinBold;
                 diff = measures[0].GetLineWidth(SystemLinesEnum.DotsBoldBoldDots) / 2 - measures[0].GetLineWidth(SystemLinesEnum.DotsThinBold);
                 diff = measures[0].GetLineWidth(SystemLinesEnum.DotsBoldBoldDots) / 2 - measures[0].GetLineWidth(SystemLinesEnum.DotsThinBold);
             }
             }
             this.currentSystemParams.currentSystemFixWidth -= diff;
             this.currentSystemParams.currentSystemFixWidth -= diff;
-            for (var idx: number = 0, len = measures.Count; idx < len; ++idx) {
-                var measure: StaffMeasure = measures[idx];
+            for (let idx: number = 0, len: number = measures.length; idx < len; ++idx) {
+                let measure: StaffMeasure = measures[idx];
                 measure.EndInstructionsWidth -= diff;
                 measure.EndInstructionsWidth -= diff;
             }
             }
         }
         }
     }
     }
-    private addMeasureToSystem(staffMeasures: List<StaffMeasure>, measureStartLine: SystemLinesEnum, measureEndLine: SystemLinesEnum, totalMeasureWidth: number, currentMeasureBeginInstructionsWidth: number, currentVarWidth: number, currentMeasureEndInstructionsWidth: number): void {
-        this.currentSystemParams.systemMeasures.Add(__init(new MeasureBuildParameters(), { beginLine: measureStartLine, endLine: measureEndLine }));
+    private addMeasureToSystem(staffMeasures: StaffMeasure[], measureStartLine: SystemLinesEnum, measureEndLine: SystemLinesEnum, totalMeasureWidth: number, currentMeasureBeginInstructionsWidth: number, currentVarWidth: number, currentMeasureEndInstructionsWidth: number): void {
+        this.currentSystemParams.systemMeasures.push(__init(new MeasureBuildParameters(), { beginLine: measureStartLine, endLine: measureEndLine }));
         this.setMeasureWidth(staffMeasures, totalMeasureWidth, currentMeasureBeginInstructionsWidth,
         this.setMeasureWidth(staffMeasures, totalMeasureWidth, currentMeasureBeginInstructionsWidth,
             currentMeasureEndInstructionsWidth);
             currentMeasureEndInstructionsWidth);
         this.addStaveMeasuresToSystem(staffMeasures);
         this.addStaveMeasuresToSystem(staffMeasures);
@@ -163,63 +161,62 @@ export class MusicSystemBuilder {
         this.currentSystemParams.systemMeasureIndex++;
         this.currentSystemParams.systemMeasureIndex++;
     }
     }
     private createMusicPage(): GraphicalMusicPage {
     private createMusicPage(): GraphicalMusicPage {
-        var page: GraphicalMusicPage = new GraphicalMusicPage(this.graphicalMusicSheet);
-        this.graphicalMusicSheet.MusicPages.Add(page);
-        page.PositionAndShape.BorderLeft = 0.0f;
+        let page: GraphicalMusicPage = new GraphicalMusicPage(this.graphicalMusicSheet);
+        this.graphicalMusicSheet.MusicPages.push(page);
+        page.PositionAndShape.BorderLeft = 0.0;
         page.PositionAndShape.BorderRight = this.graphicalMusicSheet.ParentMusicSheet.PageWidth;
         page.PositionAndShape.BorderRight = this.graphicalMusicSheet.ParentMusicSheet.PageWidth;
-        page.PositionAndShape.BorderTop = 0.0f;
+        page.PositionAndShape.BorderTop = 0.0;
         page.PositionAndShape.BorderBottom = this.rules.PageHeight;
         page.PositionAndShape.BorderBottom = this.rules.PageHeight;
-        page.PositionAndShape.RelativePosition = new PointF_2D(0.0f, 0.0f);
+        page.PositionAndShape.RelativePosition = new PointF_2D(0.0, 0.0);
         return page;
         return page;
     }
     }
     private initMusicSystem(): MusicSystem {
     private initMusicSystem(): MusicSystem {
-        var musicSystem: MusicSystem = this.symbolFactory.createMusicSystem(this.currentMusicPage, this.globalSystemIndex++);
-        this.currentMusicPage.MusicSystems.Add(musicSystem);
-        var boundingBox: BoundingBox = musicSystem.PositionAndShape;
-        this.currentMusicPage.PositionAndShape.ChildElements.Add(boundingBox);
+        let musicSystem: MusicSystem = this.symbolFactory.createMusicSystem(this.currentMusicPage, this.globalSystemIndex++);
+        this.currentMusicPage.MusicSystems.push(musicSystem);
+        let boundingBox: BoundingBox = musicSystem.PositionAndShape;
+        this.currentMusicPage.PositionAndShape.ChildElements.push(boundingBox);
         return musicSystem;
         return musicSystem;
     }
     }
     private getFullPageSystemWidth(): number {
     private getFullPageSystemWidth(): number {
         return this.currentMusicPage.PositionAndShape.Size.Width - this.rules.PageLeftMargin - this.rules.PageRightMargin - this.rules.SystemLeftMargin - this.rules.SystemRightMargin;
         return this.currentMusicPage.PositionAndShape.Size.Width - this.rules.PageLeftMargin - this.rules.PageRightMargin - this.rules.SystemLeftMargin - this.rules.SystemRightMargin;
     }
     }
     private layoutSystemStaves(): void {
     private layoutSystemStaves(): void {
-        var systemWidth: number = this.getFullPageSystemWidth();
-        var musicSystem: MusicSystem = this.currentSystemParams.currentSystem;
-        var boundingBox: BoundingBox = musicSystem.PositionAndShape;
-        boundingBox.BorderLeft = 0.0f;
+        let systemWidth: number = this.getFullPageSystemWidth();
+        let musicSystem: MusicSystem = this.currentSystemParams.currentSystem;
+        let boundingBox: BoundingBox = musicSystem.PositionAndShape;
+        boundingBox.BorderLeft = 0.0;
         boundingBox.BorderRight = systemWidth;
         boundingBox.BorderRight = systemWidth;
-        boundingBox.BorderTop = 0.0f;
-        var staffList: List<Staff> = new List<Staff>();
-        var musicSheet: MusicSheet = this.graphicalMusicSheet.ParentMusicSheet;
-        var instruments: Instrument[] = musicSheet.Instruments.Where(i => i.Voices.Count > 0 && i.Voices[0].Visible).ToArray();
-        for (var idx: number = 0, len = instruments.length; idx < len; ++idx) {
-            var instrument: Instrument = instruments[idx];
-            for (var idx2: number = 0, len2 = instrument.Staves.Count; idx2 < len2; ++idx2) {
-                var staff: Staff = instrument.Staves[idx2];
-                staffList.Add(staff);
+        boundingBox.BorderTop = 0.0;
+        let staffList: Staff[] = [];
+        let musicSheet: MusicSheet = this.graphicalMusicSheet.ParentMusicSheet;
+        let instruments: Instrument[] = musicSheet.Instruments.Where(i => i.Voices.length > 0 && i.Voices[0].Visible);
+        for (let idx: number = 0, len: number = instruments.length; idx < len; ++idx) {
+            let instrument: Instrument = instruments[idx];
+            for (let idx2: number = 0, len2: number = instrument.Staves.length; idx2 < len2; ++idx2) {
+                let staff: Staff = instrument.Staves[idx2];
+                staffList.push(staff);
             }
             }
         }
         }
-        var multiLyrics: boolean = false;
+        let multiLyrics: boolean = false;
         if (this.leadSheet) {
         if (this.leadSheet) {
-            for (var idx: number = 0, len = staffList.Count; idx < len; ++idx) {
-                var staff: Staff = staffList[idx];
-                if (staff.ParentInstrument.LyricVersesNumbers.Count > 1) {
+            for (let idx: number = 0, len: number = staffList.length; idx < len; ++idx) {
+                let staff: Staff = staffList[idx];
+                if (staff.ParentInstrument.LyricVersesNumbers.length > 1) {
                     multiLyrics = true;
                     multiLyrics = true;
                     break;
                     break;
                 }
                 }
             }
             }
         }
         }
-        var yOffsetSum: number = 0;
-        for (var i: number = 0; i < staffList.Count; i++) {
+        let yOffsetSum: number = 0;
+        for (let i: number = 0; i < staffList.length; i++) {
             this.addStaffLineToMusicSystem(musicSystem, yOffsetSum, staffList[i]);
             this.addStaffLineToMusicSystem(musicSystem, yOffsetSum, staffList[i]);
             yOffsetSum += this.rules.StaffHeight;
             yOffsetSum += this.rules.StaffHeight;
-            if (i + 1 < staffList.Count) {
-                var yOffset: number = 0;
+            if (i + 1 < staffList.length) {
+                let yOffset: number = 0;
                 if (this.leadSheet && !multiLyrics) {
                 if (this.leadSheet && !multiLyrics) {
-                    yOffset = 2.5f;
-                }
-                else {
-                    if (staffList[i].ParentInstrument == staffList[i + 1].ParentInstrument)
+                    yOffset = 2.5;
+                } else {
+                    if (staffList[i].ParentInstrument === staffList[i + 1].ParentInstrument)
                         yOffset = this.rules.BetweenStaffDistance;
                         yOffset = this.rules.BetweenStaffDistance;
                     else yOffset = this.rules.StaffDistance;
                     else yOffset = this.rules.StaffDistance;
                 }
                 }
@@ -229,28 +226,28 @@ export class MusicSystemBuilder {
         boundingBox.BorderBottom = yOffsetSum;
         boundingBox.BorderBottom = yOffsetSum;
     }
     }
     private addStaffLineToMusicSystem(musicSystem: MusicSystem, relativeYPosition: number, staff: Staff): void {
     private addStaffLineToMusicSystem(musicSystem: MusicSystem, relativeYPosition: number, staff: Staff): void {
-        if (musicSystem != null) {
-            var staffLine: StaffLine = this.symbolFactory.createStaffLine(musicSystem, staff);
-            musicSystem.StaffLines.Add(staffLine);
-            var boundingBox: BoundingBox = staffLine.PositionAndShape;
-            musicSystem.PositionAndShape.ChildElements.Add(boundingBox);
-            var relativePosition: PointF_2D = new PointF_2D();
-            if (musicSystem.Parent.MusicSystems[0] == musicSystem && musicSystem.Parent == musicSystem.Parent.Parent.MusicPages[0])
+        if (musicSystem !== undefined) {
+            let staffLine: StaffLine = this.symbolFactory.createStaffLine(musicSystem, staff);
+            musicSystem.StaffLines.push(staffLine);
+            let boundingBox: BoundingBox = staffLine.PositionAndShape;
+            musicSystem.PositionAndShape.ChildElements.push(boundingBox);
+            let relativePosition: PointF_2D = new PointF_2D();
+            if (musicSystem.Parent.MusicSystems[0] === musicSystem && musicSystem.Parent === musicSystem.Parent.Parent.MusicPages[0])
                 relativePosition.X = this.rules.FirstSystemMargin;
                 relativePosition.X = this.rules.FirstSystemMargin;
-            else relativePosition.X = 0.0f;
+            else relativePosition.X = 0.0;
             relativePosition.Y = relativeYPosition;
             relativePosition.Y = relativeYPosition;
             boundingBox.RelativePosition = relativePosition;
             boundingBox.RelativePosition = relativePosition;
-            if (musicSystem.Parent.MusicSystems[0] == musicSystem && musicSystem.Parent == musicSystem.Parent.Parent.MusicPages[0])
+            if (musicSystem.Parent.MusicSystems[0] === musicSystem && musicSystem.Parent === musicSystem.Parent.Parent.MusicPages[0])
                 boundingBox.BorderRight = musicSystem.PositionAndShape.Size.Width - this.rules.FirstSystemMargin;
                 boundingBox.BorderRight = musicSystem.PositionAndShape.Size.Width - this.rules.FirstSystemMargin;
             else boundingBox.BorderRight = musicSystem.PositionAndShape.Size.Width;
             else boundingBox.BorderRight = musicSystem.PositionAndShape.Size.Width;
-            boundingBox.BorderLeft = 0.0f;
-            boundingBox.BorderTop = 0.0f;
+            boundingBox.BorderLeft = 0.0;
+            boundingBox.BorderTop = 0.0;
             boundingBox.BorderBottom = this.rules.StaffHeight;
             boundingBox.BorderBottom = this.rules.StaffHeight;
-            for (var i: number = 0; i < 5; i++) {
-                var start: PointF_2D = new PointF_2D();
-                start.X = 0.0f;
+            for (let i: number = 0; i < 5; i++) {
+                let start: PointF_2D = new PointF_2D();
+                start.X = 0.0;
                 start.Y = i * this.rules.StaffHeight / 4;
                 start.Y = i * this.rules.StaffHeight / 4;
-                var end: PointF_2D = new PointF_2D();
+                let end: PointF_2D = new PointF_2D();
                 end.X = staffLine.PositionAndShape.Size.Width;
                 end.X = staffLine.PositionAndShape.Size.Width;
                 end.Y = i * this.rules.StaffHeight / 4;
                 end.Y = i * this.rules.StaffHeight / 4;
                 if (this.leadSheet)
                 if (this.leadSheet)
@@ -259,15 +256,15 @@ export class MusicSystemBuilder {
             }
             }
         }
         }
     }
     }
-    private initializeActiveInstructions(measureList: List<StaffMeasure>): void {
-        var firstSourceMeasure: SourceMeasure = this.graphicalMusicSheet.ParentMusicSheet.getFirstSourceMeasure();
-        if (firstSourceMeasure != null) {
-            this.visibleStaffIndices = this.graphicalMusicSheet.getVisibleStavesIndecesFromSourceMeasure(measureList).ToArray();
-            for (var i: number = 0, len = this.visibleStaffIndices.length; i < len; i++) {
-                var staffIndex: number = this.visibleStaffIndices[i];
-                var graphicalMeasure: StaffMeasure = this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(firstSourceMeasure, staffIndex);
+    private initializeActiveInstructions(measureList: StaffMeasure[]): void {
+        let firstSourceMeasure: SourceMeasure = this.graphicalMusicSheet.ParentMusicSheet.getFirstSourceMeasure();
+        if (firstSourceMeasure !== undefined) {
+            this.visibleStaffIndices = this.graphicalMusicSheet.getVisibleStavesIndecesFromSourceMeasure(measureList);
+            for (let i: number = 0, len: number = this.visibleStaffIndices.length; i < len; i++) {
+                let staffIndex: number = this.visibleStaffIndices[i];
+                let graphicalMeasure: StaffMeasure = this.graphicalMusicSheet.getGraphicalMeasureFromSourceMeasureAndIndex(firstSourceMeasure, staffIndex);
                 this.activeClefs[i] = <ClefInstruction>firstSourceMeasure.FirstInstructionsStaffEntries[staffIndex].Instructions[0];
                 this.activeClefs[i] = <ClefInstruction>firstSourceMeasure.FirstInstructionsStaffEntries[staffIndex].Instructions[0];
-                var keyInstruction: KeyInstruction = new KeyInstruction(<KeyInstruction>firstSourceMeasure.FirstInstructionsStaffEntries[staffIndex].Instructions[1]);
+                let keyInstruction: KeyInstruction = new KeyInstruction(<KeyInstruction>firstSourceMeasure.FirstInstructionsStaffEntries[staffIndex].Instructions[1]);
                 keyInstruction = this.transposeKeyInstruction(keyInstruction, graphicalMeasure);
                 keyInstruction = this.transposeKeyInstruction(keyInstruction, graphicalMeasure);
                 this.activeKeys[i] = keyInstruction;
                 this.activeKeys[i] = keyInstruction;
                 this.activeRhythm[i] = <RhythmInstruction>firstSourceMeasure.FirstInstructionsStaffEntries[staffIndex].Instructions[2];
                 this.activeRhythm[i] = <RhythmInstruction>firstSourceMeasure.FirstInstructionsStaffEntries[staffIndex].Instructions[2];
@@ -275,91 +272,88 @@ export class MusicSystemBuilder {
         }
         }
     }
     }
     private transposeKeyInstruction(keyInstruction: KeyInstruction, graphicalMeasure: StaffMeasure): KeyInstruction {
     private transposeKeyInstruction(keyInstruction: KeyInstruction, graphicalMeasure: StaffMeasure): KeyInstruction {
-        if (this.graphicalMusicSheet.ParentMusicSheet.Transpose != 0 && graphicalMeasure.ParentStaff.ParentInstrument.MidiInstrumentId != Common.Enums.MidiInstrument.Percussion && MusicSheetCalculator.TransposeCalculator != null)
+        if (this.graphicalMusicSheet.ParentMusicSheet.Transpose !== 0 && graphicalMeasure.ParentStaff.ParentInstrument.MidiInstrumentId !== Common.Enums.MidiInstrument.Percussion && MusicSheetCalculator.TransposeCalculator !== undefined)
             MusicSheetCalculator.TransposeCalculator.TransposeKey(keyInstruction,
             MusicSheetCalculator.TransposeCalculator.TransposeKey(keyInstruction,
                 this.graphicalMusicSheet.ParentMusicSheet.Transpose);
                 this.graphicalMusicSheet.ParentMusicSheet.Transpose);
         return keyInstruction;
         return keyInstruction;
     }
     }
-    private addBeginInstructions(measures: List<StaffMeasure>, isSystemFirstMeasure: boolean, isFirstSourceMeasure: boolean): number {
-        var measureCount: number = measures.Count;
-        if (measureCount == 0)
+    private addBeginInstructions(measures: StaffMeasure[], isSystemFirstMeasure: boolean, isFirstSourceMeasure: boolean): number {
+        let measureCount: number = measures.length;
+        if (measureCount === 0)
             return 0;
             return 0;
-        var totalBeginInstructionLengthX: number = 0.0f;
-        var sourceMeasure: SourceMeasure = measures[0].ParentSourceMeasure;
-        for (var idx: number = 0; idx < measureCount; ++idx) {
-            var measure: StaffMeasure = measures[idx];
-            var staffIndex: number = this.visibleStaffIndices[idx];
-            var beginInstructionsStaffEntry: SourceStaffEntry = sourceMeasure.FirstInstructionsStaffEntries[staffIndex];
-            var beginInstructionLengthX: number = this.AddInstructionsAtMeasureBegin(beginInstructionsStaffEntry, measure,
+        let totalBeginInstructionLengthX: number = 0.0;
+        let sourceMeasure: SourceMeasure = measures[0].ParentSourceMeasure;
+        for (let idx: number = 0; idx < measureCount; ++idx) {
+            let measure: StaffMeasure = measures[idx];
+            let staffIndex: number = this.visibleStaffIndices[idx];
+            let beginInstructionsStaffEntry: SourceStaffEntry = sourceMeasure.FirstInstructionsStaffEntries[staffIndex];
+            let beginInstructionLengthX: number = this.AddInstructionsAtMeasureBegin(beginInstructionsStaffEntry, measure,
                 idx, isFirstSourceMeasure,
                 idx, isFirstSourceMeasure,
                 isSystemFirstMeasure);
                 isSystemFirstMeasure);
-            totalBeginInstructionLengthX = Math.Max(totalBeginInstructionLengthX, beginInstructionLengthX);
+            totalBeginInstructionLengthX = Math.max(totalBeginInstructionLengthX, beginInstructionLengthX);
         }
         }
         return totalBeginInstructionLengthX;
         return totalBeginInstructionLengthX;
     }
     }
-    private addEndInstructions(measures: List<StaffMeasure>): number {
-        var measureCount: number = measures.Count;
-        if (measureCount == 0)
+    private addEndInstructions(measures: StaffMeasure[]): number {
+        let measureCount: number = measures.length;
+        if (measureCount === 0)
             return 0;
             return 0;
-        var totalEndInstructionLengthX: number = 0.5f;
-        var sourceMeasure: SourceMeasure = measures[0].ParentSourceMeasure;
-        for (var idx: number = 0; idx < measureCount; idx++) {
-            var measure: StaffMeasure = measures[idx];
-            var staffIndex: number = this.visibleStaffIndices[idx];
-            var endInstructionsStaffEntry: SourceStaffEntry = sourceMeasure.LastInstructionsStaffEntries[staffIndex];
-            var endInstructionLengthX: number = this.addInstructionsAtMeasureEnd(endInstructionsStaffEntry, measure);
-            totalEndInstructionLengthX = Math.Max(totalEndInstructionLengthX, endInstructionLengthX);
+        let totalEndInstructionLengthX: number = 0.5;
+        let sourceMeasure: SourceMeasure = measures[0].ParentSourceMeasure;
+        for (let idx: number = 0; idx < measureCount; idx++) {
+            let measure: StaffMeasure = measures[idx];
+            let staffIndex: number = this.visibleStaffIndices[idx];
+            let endInstructionsStaffEntry: SourceStaffEntry = sourceMeasure.LastInstructionsStaffEntries[staffIndex];
+            let endInstructionLengthX: number = this.addInstructionsAtMeasureEnd(endInstructionsStaffEntry, measure);
+            totalEndInstructionLengthX = Math.max(totalEndInstructionLengthX, endInstructionLengthX);
         }
         }
         return totalEndInstructionLengthX;
         return totalEndInstructionLengthX;
     }
     }
     private AddInstructionsAtMeasureBegin(firstEntry: SourceStaffEntry, measure: StaffMeasure,
     private AddInstructionsAtMeasureBegin(firstEntry: SourceStaffEntry, measure: StaffMeasure,
         visibleStaffIdx: number, isFirstSourceMeasure: boolean, isSystemStartMeasure: boolean): number {
         visibleStaffIdx: number, isFirstSourceMeasure: boolean, isSystemStartMeasure: boolean): number {
-        var instructionsLengthX: number = 0;
-        var currentClef: ClefInstruction = null;
-        var currentKey: KeyInstruction = null;
-        var currentRhythm: RhythmInstruction = null;
-        if (firstEntry != null) {
-            for (var idx: number = 0, len = firstEntry.Instructions.Count; idx < len; ++idx) {
-                var abstractNotationInstruction: AbstractNotationInstruction = firstEntry.Instructions[idx];
+        let instructionsLengthX: number = 0;
+        let currentClef: ClefInstruction = undefined;
+        let currentKey: KeyInstruction = undefined;
+        let currentRhythm: RhythmInstruction = undefined;
+        if (firstEntry !== undefined) {
+            for (let idx: number = 0, len: number = firstEntry.Instructions.length; idx < len; ++idx) {
+                let abstractNotationInstruction: AbstractNotationInstruction = firstEntry.Instructions[idx];
                 if (abstractNotationInstruction instanceof ClefInstruction) {
                 if (abstractNotationInstruction instanceof ClefInstruction) {
                     currentClef = <ClefInstruction>abstractNotationInstruction;
                     currentClef = <ClefInstruction>abstractNotationInstruction;
-                }
-                else if (abstractNotationInstruction instanceof KeyInstruction) {
+                } else if (abstractNotationInstruction instanceof KeyInstruction) {
                     currentKey = <KeyInstruction>abstractNotationInstruction;
                     currentKey = <KeyInstruction>abstractNotationInstruction;
-                }
-                else if (abstractNotationInstruction instanceof RhythmInstruction) {
+                } else if (abstractNotationInstruction instanceof RhythmInstruction) {
                     currentRhythm = <RhythmInstruction>abstractNotationInstruction;
                     currentRhythm = <RhythmInstruction>abstractNotationInstruction;
                 }
                 }
             }
             }
         }
         }
         if (isSystemStartMeasure) {
         if (isSystemStartMeasure) {
-            if (currentClef == null) {
+            if (currentClef === undefined) {
                 currentClef = this.activeClefs[visibleStaffIdx];
                 currentClef = this.activeClefs[visibleStaffIdx];
             }
             }
-            if (currentKey == null) {
+            if (currentKey === undefined) {
                 currentKey = this.activeKeys[visibleStaffIdx];
                 currentKey = this.activeKeys[visibleStaffIdx];
             }
             }
-            if (isFirstSourceMeasure && currentRhythm == null) {
+            if (isFirstSourceMeasure && currentRhythm === undefined) {
                 currentRhythm = this.activeRhythm[visibleStaffIdx];
                 currentRhythm = this.activeRhythm[visibleStaffIdx];
             }
             }
         }
         }
-        var clefAdded: boolean = false;
-        var keyAdded: boolean = false;
-        var rhythmAdded: boolean = false;
-        if (currentClef != null) {
+        let clefAdded: boolean = false;
+        let keyAdded: boolean = false;
+        let rhythmAdded: boolean = false;
+        if (currentClef !== undefined) {
             measure.AddClefAtBegin(currentClef);
             measure.AddClefAtBegin(currentClef);
             clefAdded = true;
             clefAdded = true;
-        }
-        else {
+        } else {
             currentClef = this.activeClefs[visibleStaffIdx];
             currentClef = this.activeClefs[visibleStaffIdx];
         }
         }
-        if (currentKey != null) {
+        if (currentKey !== undefined) {
             currentKey = this.transposeKeyInstruction(currentKey, measure);
             currentKey = this.transposeKeyInstruction(currentKey, measure);
-            var previousKey: KeyInstruction = isSystemStartMeasure ? null : this.activeKeys[visibleStaffIdx];
+            let previousKey: KeyInstruction = isSystemStartMeasure ? undefined : this.activeKeys[visibleStaffIdx];
             measure.AddKeyAtBegin(currentKey, previousKey, currentClef);
             measure.AddKeyAtBegin(currentKey, previousKey, currentClef);
             keyAdded = true;
             keyAdded = true;
         }
         }
-        if (currentRhythm != null) {
+        if (currentRhythm !== undefined) {
             measure.AddRhythmAtBegin(currentRhythm);
             measure.AddRhythmAtBegin(currentRhythm);
             rhythmAdded = true;
             rhythmAdded = true;
         }
         }
@@ -371,52 +365,50 @@ export class MusicSystemBuilder {
         return instructionsLengthX;
         return instructionsLengthX;
     }
     }
     private addInstructionsAtMeasureEnd(lastEntry: SourceStaffEntry, measure: StaffMeasure): number {
     private addInstructionsAtMeasureEnd(lastEntry: SourceStaffEntry, measure: StaffMeasure): number {
-        if (lastEntry == null || lastEntry.Instructions == null || lastEntry.Instructions.Count == 0)
+        if (lastEntry === undefined || lastEntry.Instructions === undefined || lastEntry.Instructions.length === 0)
             return 0;
             return 0;
-        for (var idx: number = 0, len = lastEntry.Instructions.Count; idx < len; ++idx) {
-            var abstractNotationInstruction: AbstractNotationInstruction = lastEntry.Instructions[idx];
+        for (let idx: number = 0, len: number = lastEntry.Instructions.length; idx < len; ++idx) {
+            let abstractNotationInstruction: AbstractNotationInstruction = lastEntry.Instructions[idx];
             if (abstractNotationInstruction instanceof ClefInstruction) {
             if (abstractNotationInstruction instanceof ClefInstruction) {
-                var activeClef: ClefInstruction = <ClefInstruction>abstractNotationInstruction;
+                let activeClef: ClefInstruction = <ClefInstruction>abstractNotationInstruction;
                 measure.AddClefAtEnd(activeClef);
                 measure.AddClefAtEnd(activeClef);
             }
             }
         }
         }
         return this.rules.MeasureRightMargin + measure.EndInstructionsWidth;
         return this.rules.MeasureRightMargin + measure.EndInstructionsWidth;
     }
     }
-    private updateActiveClefs(measure: SourceMeasure, staffMeasures: List<StaffMeasure>): void {
-        for (var visStaffIdx: number = 0, len = staffMeasures.Count; visStaffIdx < len; visStaffIdx++) {
-            var staffIndex: number = this.visibleStaffIndices[visStaffIdx];
-            var firstEntry: SourceStaffEntry = measure.FirstInstructionsStaffEntries[staffIndex];
-            if (firstEntry != null) {
-                for (var idx: number = 0, len2 = firstEntry.Instructions.Count; idx < len2; ++idx) {
-                    var abstractNotationInstruction: AbstractNotationInstruction = firstEntry.Instructions[idx];
+    private updateActiveClefs(measure: SourceMeasure, staffMeasures: StaffMeasure[]): void {
+        for (let visStaffIdx: number = 0, len: number = staffMeasures.length; visStaffIdx < len; visStaffIdx++) {
+            let staffIndex: number = this.visibleStaffIndices[visStaffIdx];
+            let firstEntry: SourceStaffEntry = measure.FirstInstructionsStaffEntries[staffIndex];
+            if (firstEntry !== undefined) {
+                for (let idx: number = 0, len2: number = firstEntry.Instructions.length; idx < len2; ++idx) {
+                    let abstractNotationInstruction: AbstractNotationInstruction = firstEntry.Instructions[idx];
                     if (abstractNotationInstruction instanceof ClefInstruction) {
                     if (abstractNotationInstruction instanceof ClefInstruction) {
                         this.activeClefs[visStaffIdx] = <ClefInstruction>abstractNotationInstruction;
                         this.activeClefs[visStaffIdx] = <ClefInstruction>abstractNotationInstruction;
-                    }
-                    else if (abstractNotationInstruction instanceof KeyInstruction) {
+                    } else if (abstractNotationInstruction instanceof KeyInstruction) {
                         this.activeKeys[visStaffIdx] = <KeyInstruction>abstractNotationInstruction;
                         this.activeKeys[visStaffIdx] = <KeyInstruction>abstractNotationInstruction;
-                    }
-                    else if (abstractNotationInstruction instanceof RhythmInstruction) {
+                    } else if (abstractNotationInstruction instanceof RhythmInstruction) {
                         this.activeRhythm[visStaffIdx] = <RhythmInstruction>abstractNotationInstruction;
                         this.activeRhythm[visStaffIdx] = <RhythmInstruction>abstractNotationInstruction;
                     }
                     }
                 }
                 }
             }
             }
-            var entries: List<SourceStaffEntry> = measure.getEntriesPerStaff(staffIndex);
-            for (var idx: number = 0, len2 = entries.Count; idx < len2; ++idx) {
-                var staffEntry: SourceStaffEntry = entries[idx];
-                if (staffEntry.Instructions != null) {
-                    for (var idx2: number = 0, len3 = staffEntry.Instructions.Count; idx2 < len3; ++idx2) {
-                        var abstractNotationInstruction: AbstractNotationInstruction = staffEntry.Instructions[idx2];
+            let entries: SourceStaffEntry[] = measure.getEntriesPerStaff(staffIndex);
+            for (let idx: number = 0, len2: number = entries.length; idx < len2; ++idx) {
+                let staffEntry: SourceStaffEntry = entries[idx];
+                if (staffEntry.Instructions !== undefined) {
+                    for (let idx2: number = 0, len3: number = staffEntry.Instructions.length; idx2 < len3; ++idx2) {
+                        let abstractNotationInstruction: AbstractNotationInstruction = staffEntry.Instructions[idx2];
                         if (abstractNotationInstruction instanceof ClefInstruction) {
                         if (abstractNotationInstruction instanceof ClefInstruction) {
                             this.activeClefs[visStaffIdx] = <ClefInstruction>abstractNotationInstruction;
                             this.activeClefs[visStaffIdx] = <ClefInstruction>abstractNotationInstruction;
                         }
                         }
                     }
                     }
                 }
                 }
             }
             }
-            var lastEntry: SourceStaffEntry = measure.LastInstructionsStaffEntries[staffIndex];
-            if (lastEntry != null) {
-                var instructions: List<AbstractNotationInstruction> = lastEntry.Instructions;
-                for (var idx: number = 0, len3 = instructions.Count; idx < len3; ++idx) {
-                    var abstractNotationInstruction: AbstractNotationInstruction = instructions[idx];
+            let lastEntry: SourceStaffEntry = measure.LastInstructionsStaffEntries[staffIndex];
+            if (lastEntry !== undefined) {
+                let instructions: AbstractNotationInstruction[] = lastEntry.Instructions;
+                for (let idx: number = 0, len3: number = instructions.length; idx < len3; ++idx) {
+                    let abstractNotationInstruction: AbstractNotationInstruction = instructions[idx];
                     if (abstractNotationInstruction instanceof ClefInstruction) {
                     if (abstractNotationInstruction instanceof ClefInstruction) {
                         this.activeClefs[visStaffIdx] = <ClefInstruction>abstractNotationInstruction;
                         this.activeClefs[visStaffIdx] = <ClefInstruction>abstractNotationInstruction;
                     }
                     }
@@ -424,80 +416,80 @@ export class MusicSystemBuilder {
             }
             }
         }
         }
     }
     }
-    private checkAndCreateExtraInstructionMeasure(measures: List<StaffMeasure>): void {
-        var firstStaffEntries: List<SourceStaffEntry> = measures[0].ParentSourceMeasure.FirstInstructionsStaffEntries;
-        var visibleInstructionEntries: List<SourceStaffEntry> = new List<SourceStaffEntry>();
-        for (var idx: number = 0, len = measures.Count; idx < len; ++idx) {
-            var measure: StaffMeasure = measures[idx];
-            visibleInstructionEntries.Add(firstStaffEntries[measure.ParentStaff.IdInMusicSheet]);
+    private checkAndCreateExtraInstructionMeasure(measures: StaffMeasure[]): void {
+        let firstStaffEntries: SourceStaffEntry[] = measures[0].ParentSourceMeasure.FirstInstructionsStaffEntries;
+        let visibleInstructionEntries: SourceStaffEntry[] = [];
+        for (let idx: number = 0, len: number = measures.length; idx < len; ++idx) {
+            let measure: StaffMeasure = measures[idx];
+            visibleInstructionEntries.push(firstStaffEntries[measure.ParentStaff.IdInMusicSheet]);
         }
         }
-        var maxMeasureWidth: number = 0;
-        for (var visStaffIdx: number = 0, len = visibleInstructionEntries.Count; visStaffIdx < len; ++visStaffIdx) {
-            var sse: SourceStaffEntry = visibleInstructionEntries[visStaffIdx];
-            if (sse == null)
+        let maxMeasureWidth: number = 0;
+        for (let visStaffIdx: number = 0, len: number = visibleInstructionEntries.length; visStaffIdx < len; ++visStaffIdx) {
+            let sse: SourceStaffEntry = visibleInstructionEntries[visStaffIdx];
+            if (sse === undefined)
                 continue;
                 continue;
-            var instructions: List<AbstractNotationInstruction> = sse.Instructions;
-            var keyInstruction: KeyInstruction = null;
-            var rhythmInstruction: RhythmInstruction = null;
-            for (var idx2: number = 0, len2 = instructions.Count; idx2 < len2; ++idx2) {
-                var instruction: AbstractNotationInstruction = instructions[idx2];
-                if (instruction instanceof KeyInstruction && (<KeyInstruction>instruction).Key != this.activeKeys[visStaffIdx].Key)
+            let instructions: AbstractNotationInstruction[] = sse.Instructions;
+            let keyInstruction: KeyInstruction = undefined;
+            let rhythmInstruction: RhythmInstruction = undefined;
+            for (let idx2: number = 0, len2: number = instructions.length; idx2 < len2; ++idx2) {
+                let instruction: AbstractNotationInstruction = instructions[idx2];
+                if (instruction instanceof KeyInstruction && (<KeyInstruction>instruction).Key !== this.activeKeys[visStaffIdx].Key)
                     keyInstruction = <KeyInstruction>instruction;
                     keyInstruction = <KeyInstruction>instruction;
-                if (instruction instanceof RhythmInstruction && (<RhythmInstruction>instruction) != this.activeRhythm[visStaffIdx])
+                if (instruction instanceof RhythmInstruction && (<RhythmInstruction>instruction) !== this.activeRhythm[visStaffIdx])
                     rhythmInstruction = <RhythmInstruction>instruction;
                     rhythmInstruction = <RhythmInstruction>instruction;
             }
             }
-            if (keyInstruction != null || rhythmInstruction != null) {
-                var measureWidth: number = this.addExtraInstructionMeasure(visStaffIdx, keyInstruction, rhythmInstruction);
-                maxMeasureWidth = Math.Max(maxMeasureWidth, measureWidth);
+            if (keyInstruction !== undefined || rhythmInstruction !== undefined) {
+                let measureWidth: number = this.addExtraInstructionMeasure(visStaffIdx, keyInstruction, rhythmInstruction);
+                maxMeasureWidth = Math.max(maxMeasureWidth, measureWidth);
             }
             }
         }
         }
         if (maxMeasureWidth > 0) {
         if (maxMeasureWidth > 0) {
-            this.currentSystemParams.systemMeasures.Add(__init(new MeasureBuildParameters(), { beginLine: SystemLinesEnum.None, endLine: SystemLinesEnum.None }));
+            this.currentSystemParams.systemMeasures.push(__init(new MeasureBuildParameters(), { beginLine: SystemLinesEnum.None, endLine: SystemLinesEnum.None }));
             this.currentSystemParams.currentWidth += maxMeasureWidth;
             this.currentSystemParams.currentWidth += maxMeasureWidth;
             this.currentSystemParams.currentSystemFixWidth += maxMeasureWidth;
             this.currentSystemParams.currentSystemFixWidth += maxMeasureWidth;
         }
         }
     }
     }
     private addExtraInstructionMeasure(visStaffIdx: number, keyInstruction: KeyInstruction, rhythmInstruction: RhythmInstruction): number {
     private addExtraInstructionMeasure(visStaffIdx: number, keyInstruction: KeyInstruction, rhythmInstruction: RhythmInstruction): number {
-        var currentSystem: MusicSystem = this.currentSystemParams.currentSystem;
-        var measures: List<StaffMeasure> = new List<StaffMeasure>();
-        var measure: StaffMeasure = this.symbolFactory.createExtraStaffMeasure(currentSystem.StaffLines[visStaffIdx]);
-        measures.Add(measure);
-        if (keyInstruction != null) {
+        let currentSystem: MusicSystem = this.currentSystemParams.currentSystem;
+        let measures: StaffMeasure[] = [];
+        let measure: StaffMeasure = this.symbolFactory.createExtraStaffMeasure(currentSystem.StaffLines[visStaffIdx]);
+        measures.push(measure);
+        if (keyInstruction !== undefined) {
             measure.AddKeyAtBegin(keyInstruction, this.activeKeys[visStaffIdx], this.activeClefs[visStaffIdx]);
             measure.AddKeyAtBegin(keyInstruction, this.activeKeys[visStaffIdx], this.activeClefs[visStaffIdx]);
         }
         }
-        if (rhythmInstruction != null) {
+        if (rhythmInstruction !== undefined) {
             measure.AddRhythmAtBegin(rhythmInstruction);
             measure.AddRhythmAtBegin(rhythmInstruction);
         }
         }
-        measure.PositionAndShape.BorderLeft = 0.0f;
-        measure.PositionAndShape.BorderTop = 0.0f;
+        measure.PositionAndShape.BorderLeft = 0.0;
+        measure.PositionAndShape.BorderTop = 0.0;
         measure.PositionAndShape.BorderBottom = this.rules.StaffHeight;
         measure.PositionAndShape.BorderBottom = this.rules.StaffHeight;
-        var width: number = this.rules.MeasureLeftMargin + measure.BeginInstructionsWidth + this.rules.MeasureRightMargin;
+        let width: number = this.rules.MeasureLeftMargin + measure.BeginInstructionsWidth + this.rules.MeasureRightMargin;
         measure.PositionAndShape.BorderRight = width;
         measure.PositionAndShape.BorderRight = width;
-        currentSystem.StaffLines[visStaffIdx].Measures.Add(measure);
+        currentSystem.StaffLines[visStaffIdx].Measures.push(measure);
         measure.ParentStaffLine = currentSystem.StaffLines[visStaffIdx];
         measure.ParentStaffLine = currentSystem.StaffLines[visStaffIdx];
-        currentSystem.StaffLines[visStaffIdx].PositionAndShape.ChildElements.Add(measure.PositionAndShape);
+        currentSystem.StaffLines[visStaffIdx].PositionAndShape.ChildElements.push(measure.PositionAndShape);
         return width;
         return width;
     }
     }
-    private addStaveMeasuresToSystem(staffMeasures: List<StaffMeasure>): void {
-        if (staffMeasures[0] != null) {
-            var gmeasures: List<StaffMeasure> = new List<StaffMeasure>();
-            for (var i: number = 0; i < staffMeasures.Count; i++)
-                gmeasures.Add(staffMeasures[i]);
-            var currentSystem: MusicSystem = this.currentSystemParams.currentSystem;
-            for (var visStaffIdx: number = 0; visStaffIdx < this.numberOfVisibleStaffLines; visStaffIdx++) {
-                var measure: StaffMeasure = gmeasures[visStaffIdx];
-                currentSystem.StaffLines[visStaffIdx].Measures.Add(measure);
+    private addStaveMeasuresToSystem(staffMeasures: StaffMeasure[]): void {
+        if (staffMeasures[0] !== undefined) {
+            let gmeasures: StaffMeasure[] = [];
+            for (let i: number = 0; i < staffMeasures.length; i++)
+                gmeasures.push(staffMeasures[i]);
+            let currentSystem: MusicSystem = this.currentSystemParams.currentSystem;
+            for (let visStaffIdx: number = 0; visStaffIdx < this.numberOfVisibleStaffLines; visStaffIdx++) {
+                let measure: StaffMeasure = gmeasures[visStaffIdx];
+                currentSystem.StaffLines[visStaffIdx].Measures.push(measure);
                 measure.ParentStaffLine = currentSystem.StaffLines[visStaffIdx];
                 measure.ParentStaffLine = currentSystem.StaffLines[visStaffIdx];
-                currentSystem.StaffLines[visStaffIdx].PositionAndShape.ChildElements.Add(measure.PositionAndShape);
+                currentSystem.StaffLines[visStaffIdx].PositionAndShape.ChildElements.push(measure.PositionAndShape);
             }
             }
             currentSystem.AddStaffMeasures(gmeasures);
             currentSystem.AddStaffMeasures(gmeasures);
         }
         }
     }
     }
     private getMeasureStartLine(): SystemLinesEnum {
     private getMeasureStartLine(): SystemLinesEnum {
-        var thisMeasureBeginsLineRep: boolean = this.thisMeasureBeginsLineRepetition();
+        let thisMeasureBeginsLineRep: boolean = this.thisMeasureBeginsLineRepetition();
         if (thisMeasureBeginsLineRep) {
         if (thisMeasureBeginsLineRep) {
-            var isSystemStartMeasure: boolean = this.currentSystemParams.IsSystemStartMeasure();
-            var isGlobalFirstMeasure: boolean = this.measureListIndex == 0;
+            let isSystemStartMeasure: boolean = this.currentSystemParams.IsSystemStartMeasure();
+            let isGlobalFirstMeasure: boolean = this.measureListIndex === 0;
             if (this.previousMeasureEndsLineRepetition() && !isSystemStartMeasure) {
             if (this.previousMeasureEndsLineRepetition() && !isSystemStartMeasure) {
                 return SystemLinesEnum.DotsBoldBoldDots;
                 return SystemLinesEnum.DotsBoldBoldDots;
             }
             }
@@ -513,7 +505,7 @@ export class MusicSystemBuilder {
         if (this.thisMeasureEndsLineRepetition()) {
         if (this.thisMeasureEndsLineRepetition()) {
             return SystemLinesEnum.DotsThinBold;
             return SystemLinesEnum.DotsThinBold;
         }
         }
-        if (this.measureListIndex == this.measureList.Count - 1 || this.measureList[this.measureListIndex][0].ParentSourceMeasure.EndsPiece) {
+        if (this.measureListIndex === this.measureList.length - 1 || this.measureList[this.measureListIndex][0].ParentSourceMeasure.EndsPiece) {
             return SystemLinesEnum.ThinBold;
             return SystemLinesEnum.ThinBold;
         }
         }
         if (this.nextMeasureHasKeyInstructionChange() || this.thisMeasureEndsWordRepetition() || this.nextMeasureBeginsWordRepetition()) {
         if (this.nextMeasureHasKeyInstructionChange() || this.thisMeasureEndsWordRepetition() || this.nextMeasureBeginsWordRepetition()) {
@@ -522,114 +514,114 @@ export class MusicSystemBuilder {
         return SystemLinesEnum.SingleThin;
         return SystemLinesEnum.SingleThin;
     }
     }
     private getLineWidth(measure: StaffMeasure, systemLineEnum: SystemLinesEnum, isSystemStartMeasure: boolean): number {
     private getLineWidth(measure: StaffMeasure, systemLineEnum: SystemLinesEnum, isSystemStartMeasure: boolean): number {
-        var width: number = measure.GetLineWidth(systemLineEnum);
-        if (systemLineEnum == SystemLinesEnum.DotsBoldBoldDots) {
+        let width: number = measure.GetLineWidth(systemLineEnum);
+        if (systemLineEnum === SystemLinesEnum.DotsBoldBoldDots) {
             width /= 2;
             width /= 2;
         }
         }
-        if (isSystemStartMeasure && systemLineEnum == SystemLinesEnum.BoldThinDots) {
+        if (isSystemStartMeasure && systemLineEnum === SystemLinesEnum.BoldThinDots) {
             width += this.rules.DistanceBetweenLastInstructionAndRepetitionBarline;
             width += this.rules.DistanceBetweenLastInstructionAndRepetitionBarline;
         }
         }
         return width;
         return width;
     }
     }
     private previousMeasureEndsLineRepetition(): boolean {
     private previousMeasureEndsLineRepetition(): boolean {
-        if (this.measureListIndex == 0)
+        if (this.measureListIndex === 0)
             return false;
             return false;
-        for (var idx: number = 0, len = this.measureList[this.measureListIndex - 1].Count; idx < len; ++idx) {
-            var measure: StaffMeasure = this.measureList[this.measureListIndex - 1][idx];
+        for (let idx: number = 0, len: number = this.measureList[this.measureListIndex - 1].length; idx < len; ++idx) {
+            let measure: StaffMeasure = this.measureList[this.measureListIndex - 1][idx];
             if (measure.endsWithLineRepetition())
             if (measure.endsWithLineRepetition())
                 return true;
                 return true;
         }
         }
         return false;
         return false;
     }
     }
     private thisMeasureBeginsLineRepetition(): boolean {
     private thisMeasureBeginsLineRepetition(): boolean {
-        for (var idx: number = 0, len = this.measureList[this.measureListIndex].Count; idx < len; ++idx) {
-            var measure: StaffMeasure = this.measureList[this.measureListIndex][idx];
+        for (let idx: number = 0, len: number = this.measureList[this.measureListIndex].length; idx < len; ++idx) {
+            let measure: StaffMeasure = this.measureList[this.measureListIndex][idx];
             if (measure.beginsWithLineRepetition())
             if (measure.beginsWithLineRepetition())
                 return true;
                 return true;
         }
         }
         return false;
         return false;
     }
     }
     private nextMeasureBeginsLineRepetition(): boolean {
     private nextMeasureBeginsLineRepetition(): boolean {
-        var nextMeasureIndex: number = this.measureListIndex + 1;
-        if (nextMeasureIndex >= this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.Count)
+        let nextMeasureIndex: number = this.measureListIndex + 1;
+        if (nextMeasureIndex >= this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length)
             return false;
             return false;
-        for (var idx: number = 0, len = this.measureList[nextMeasureIndex].Count; idx < len; ++idx) {
-            var measure: StaffMeasure = this.measureList[nextMeasureIndex][idx];
+        for (let idx: number = 0, len: number = this.measureList[nextMeasureIndex].length; idx < len; ++idx) {
+            let measure: StaffMeasure = this.measureList[nextMeasureIndex][idx];
             if (measure.beginsWithLineRepetition())
             if (measure.beginsWithLineRepetition())
                 return true;
                 return true;
         }
         }
         return false;
         return false;
     }
     }
     private thisMeasureEndsLineRepetition(): boolean {
     private thisMeasureEndsLineRepetition(): boolean {
-        for (var idx: number = 0, len = this.measureList[this.measureListIndex].Count; idx < len; ++idx) {
-            var measure: StaffMeasure = this.measureList[this.measureListIndex][idx];
+        for (let idx: number = 0, len: number = this.measureList[this.measureListIndex].length; idx < len; ++idx) {
+            let measure: StaffMeasure = this.measureList[this.measureListIndex][idx];
             if (measure.endsWithLineRepetition())
             if (measure.endsWithLineRepetition())
                 return true;
                 return true;
         }
         }
         return false;
         return false;
     }
     }
     private nextMeasureBeginsWordRepetition(): boolean {
     private nextMeasureBeginsWordRepetition(): boolean {
-        var nextMeasureIndex: number = this.measureListIndex + 1;
-        if (nextMeasureIndex >= this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.Count)
+        let nextMeasureIndex: number = this.measureListIndex + 1;
+        if (nextMeasureIndex >= this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length)
             return false;
             return false;
-        for (var idx: number = 0, len = this.measureList[nextMeasureIndex].Count; idx < len; ++idx) {
-            var measure: StaffMeasure = this.measureList[nextMeasureIndex][idx];
+        for (let idx: number = 0, len: number = this.measureList[nextMeasureIndex].length; idx < len; ++idx) {
+            let measure: StaffMeasure = this.measureList[nextMeasureIndex][idx];
             if (measure.beginsWithWordRepetition())
             if (measure.beginsWithWordRepetition())
                 return true;
                 return true;
         }
         }
         return false;
         return false;
     }
     }
     private thisMeasureEndsWordRepetition(): boolean {
     private thisMeasureEndsWordRepetition(): boolean {
-        for (var idx: number = 0, len = this.measureList[this.measureListIndex].Count; idx < len; ++idx) {
-            var measure: StaffMeasure = this.measureList[this.measureListIndex][idx];
+        for (let idx: number = 0, len: number = this.measureList[this.measureListIndex].length; idx < len; ++idx) {
+            let measure: StaffMeasure = this.measureList[this.measureListIndex][idx];
             if (measure.endsWithWordRepetition())
             if (measure.endsWithWordRepetition())
                 return true;
                 return true;
         }
         }
         return false;
         return false;
     }
     }
     private nextMeasureHasKeyInstructionChange(): boolean {
     private nextMeasureHasKeyInstructionChange(): boolean {
-        return this.getNextMeasureKeyInstruction() != null;
+        return this.getNextMeasureKeyInstruction() !== undefined;
     }
     }
     private getNextMeasureKeyInstruction(): KeyInstruction {
     private getNextMeasureKeyInstruction(): KeyInstruction {
-        if (this.measureListIndex < this.measureList.Count - 1) {
-            for (var visIndex: number = 0; visIndex < this.measureList[this.measureListIndex].Count; visIndex++) {
-                var sourceMeasure: SourceMeasure = this.measureList[this.measureListIndex + 1][visIndex].ParentSourceMeasure;
-                if (sourceMeasure == null)
-                    return null;
+        if (this.measureListIndex < this.measureList.length - 1) {
+            for (let visIndex: number = 0; visIndex < this.measureList[this.measureListIndex].length; visIndex++) {
+                let sourceMeasure: SourceMeasure = this.measureList[this.measureListIndex + 1][visIndex].ParentSourceMeasure;
+                if (sourceMeasure === undefined)
+                    return undefined;
                 return sourceMeasure.getKeyInstruction(this.visibleStaffIndices[visIndex]);
                 return sourceMeasure.getKeyInstruction(this.visibleStaffIndices[visIndex]);
             }
             }
         }
         }
-        return null;
+        return undefined;
     }
     }
     private calculateXScalingFactor(systemFixWidth: number, systemVarWidth: number): number {
     private calculateXScalingFactor(systemFixWidth: number, systemVarWidth: number): number {
-        if (Math.Abs(systemVarWidth - 0) < 0.00001f || Math.Abs(systemFixWidth - 0) < 0.00001f)
-        return 1.0f;
-        var systemEndX: number;
-        var currentSystem: MusicSystem = this.currentSystemParams.currentSystem;
+        if (Math.abs(systemVarWidth - 0) < 0.00001 || Math.abs(systemFixWidth - 0) < 0.00001)
+        return 1.0;
+        let systemEndX: number;
+        let currentSystem: MusicSystem = this.currentSystemParams.currentSystem;
         systemEndX = currentSystem.StaffLines[0].PositionAndShape.Size.Width;
         systemEndX = currentSystem.StaffLines[0].PositionAndShape.Size.Width;
-        var scalingFactor: number = (systemEndX - systemFixWidth) / systemVarWidth;
+        let scalingFactor: number = (systemEndX - systemFixWidth) / systemVarWidth;
         return scalingFactor;
         return scalingFactor;
     }
     }
     private stretchMusicSystem(isPartEndingSystem: boolean): void {
     private stretchMusicSystem(isPartEndingSystem: boolean): void {
-        var scalingFactor: number = this.calculateXScalingFactor(this.currentSystemParams.currentSystemFixWidth, this.currentSystemParams.currentSystemVarWidth);
+        let scalingFactor: number = this.calculateXScalingFactor(this.currentSystemParams.currentSystemFixWidth, this.currentSystemParams.currentSystemVarWidth);
         if (isPartEndingSystem)
         if (isPartEndingSystem)
-            scalingFactor = Math.Min(scalingFactor, this.rules.LastSystemMaxScalingFactor);
-        var currentSystem: MusicSystem = this.currentSystemParams.currentSystem;
-        for (var visStaffIdx: number = 0, len = currentSystem.StaffLines.Count; visStaffIdx < len; ++visStaffIdx) {
-            var staffLine: StaffLine = currentSystem.StaffLines[visStaffIdx];
-            var currentXPosition: number = 0.0f;
-            for (var i: number = 0; i < staffLine.Measures.Count; i++) {
-                var measure: StaffMeasure = staffLine.Measures[i];
+            scalingFactor = Math.min(scalingFactor, this.rules.LastSystemMaxScalingFactor);
+        let currentSystem: MusicSystem = this.currentSystemParams.currentSystem;
+        for (let visStaffIdx: number = 0, len: number = currentSystem.StaffLines.length; visStaffIdx < len; ++visStaffIdx) {
+            let staffLine: StaffLine = currentSystem.StaffLines[visStaffIdx];
+            let currentXPosition: number = 0.0;
+            for (let i: number = 0; i < staffLine.Measures.length; i++) {
+                let measure: StaffMeasure = staffLine.Measures[i];
                 measure.SetPositionInStaffline(currentXPosition);
                 measure.SetPositionInStaffline(currentXPosition);
                 measure.SetWidth(measure.BeginInstructionsWidth + measure.MinimumStaffEntriesWidth * scalingFactor + measure.EndInstructionsWidth);
                 measure.SetWidth(measure.BeginInstructionsWidth + measure.MinimumStaffEntriesWidth * scalingFactor + measure.EndInstructionsWidth);
-                if (i < this.currentSystemParams.systemMeasures.Count) {
-                    var startLine: SystemLinesEnum = this.currentSystemParams.systemMeasures[i].beginLine;
-                    var lineWidth: number = measure.GetLineWidth(SystemLinesEnum.BoldThinDots);
+                if (i < this.currentSystemParams.systemMeasures.length) {
+                    let startLine: SystemLinesEnum = this.currentSystemParams.systemMeasures[i].beginLine;
+                    let lineWidth: number = measure.GetLineWidth(SystemLinesEnum.BoldThinDots);
                     switch (startLine) {
                     switch (startLine) {
                         case SystemLinesEnum.BoldThinDots:
                         case SystemLinesEnum.BoldThinDots:
                             {
                             {
-                                var xPosition: number = currentXPosition;
-                                if (i == 0) {
+                                let xPosition: number = currentXPosition;
+                                if (i === 0) {
                                     xPosition = currentXPosition + measure.BeginInstructionsWidth - lineWidth;
                                     xPosition = currentXPosition + measure.BeginInstructionsWidth - lineWidth;
                                 }
                                 }
                                 currentSystem.createVerticalLineForMeasure(xPosition, SystemLinesEnum.BoldThinDots, lineWidth, visStaffIdx);
                                 currentSystem.createVerticalLineForMeasure(xPosition, SystemLinesEnum.BoldThinDots, lineWidth, visStaffIdx);
@@ -639,15 +631,15 @@ export class MusicSystemBuilder {
                 }
                 }
                 measure.StaffEntriesScaleFactor = scalingFactor;
                 measure.StaffEntriesScaleFactor = scalingFactor;
                 measure.LayoutSymbols();
                 measure.LayoutSymbols();
-                var nextMeasureHasRepStartLine: boolean = i + 1 < this.currentSystemParams.systemMeasures.Count && this.currentSystemParams.systemMeasures[i + 1].beginLine == SystemLinesEnum.BoldThinDots;
+                let nextMeasureHasRepStartLine: boolean = i + 1 < this.currentSystemParams.systemMeasures.length && this.currentSystemParams.systemMeasures[i + 1].beginLine === SystemLinesEnum.BoldThinDots;
                 if (!nextMeasureHasRepStartLine) {
                 if (!nextMeasureHasRepStartLine) {
-                    var endLine: SystemLinesEnum = SystemLinesEnum.SingleThin;
-                    if (i < this.currentSystemParams.systemMeasures.Count) {
+                    let endLine: SystemLinesEnum = SystemLinesEnum.SingleThin;
+                    if (i < this.currentSystemParams.systemMeasures.length) {
                         endLine = this.currentSystemParams.systemMeasures[i].endLine;
                         endLine = this.currentSystemParams.systemMeasures[i].endLine;
                     }
                     }
-                    var lineWidth: number = measure.GetLineWidth(endLine);
-                    var xPos: number = measure.PositionAndShape.RelativePosition.X + measure.PositionAndShape.BorderRight - lineWidth;
-                    if (endLine == SystemLinesEnum.DotsBoldBoldDots)
+                    let lineWidth: number = measure.GetLineWidth(endLine);
+                    let xPos: number = measure.PositionAndShape.RelativePosition.X + measure.PositionAndShape.BorderRight - lineWidth;
+                    if (endLine === SystemLinesEnum.DotsBoldBoldDots)
                         xPos -= lineWidth / 2;
                         xPos -= lineWidth / 2;
                     currentSystem.createVerticalLineForMeasure(xPos, endLine, lineWidth, visStaffIdx);
                     currentSystem.createVerticalLineForMeasure(xPos, endLine, lineWidth, visStaffIdx);
                 }
                 }
@@ -658,13 +650,13 @@ export class MusicSystemBuilder {
             this.decreaseMusicSystemBorders();
             this.decreaseMusicSystemBorders();
     }
     }
     private decreaseMusicSystemBorders(): void {
     private decreaseMusicSystemBorders(): void {
-        var currentSystem: MusicSystem = this.currentSystemParams.currentSystem;
-        var width: number = currentSystem.StaffLines[0].Measures.Last().PositionAndShape.RelativePosition.X + currentSystem.StaffLines[0].Measures.Last().PositionAndShape.Size.Width;
-        for (var idx: number = 0, len = currentSystem.StaffLines.Count; idx < len; ++idx) {
-            var staffLine: StaffLine = currentSystem.StaffLines[idx];
+        let currentSystem: MusicSystem = this.currentSystemParams.currentSystem;
+        let width: number = currentSystem.StaffLines[0].Measures.Last().PositionAndShape.RelativePosition.X + currentSystem.StaffLines[0].Measures.Last().PositionAndShape.Size.Width;
+        for (let idx: number = 0, len: number = currentSystem.StaffLines.length; idx < len; ++idx) {
+            let staffLine: StaffLine = currentSystem.StaffLines[idx];
             staffLine.PositionAndShape.BorderRight = width;
             staffLine.PositionAndShape.BorderRight = width;
-            for (var idx2: number = 0, len2 = staffLine.StaffLines.Length; idx2 < len2; ++idx2) {
-                var graphicalLine: GraphicalLine = staffLine.StaffLines[idx2];
+            for (let idx2: number = 0, len2: number = staffLine.StaffLines.Length; idx2 < len2; ++idx2) {
+                let graphicalLine: GraphicalLine = staffLine.StaffLines[idx2];
                 graphicalLine.End = new PointF_2D(width, graphicalLine.End.Y);
                 graphicalLine.End = new PointF_2D(width, graphicalLine.End.Y);
             }
             }
         }
         }
@@ -673,14 +665,14 @@ export class MusicSystemBuilder {
 }
 }
 export class SystemBuildParameters {
 export class SystemBuildParameters {
     public currentSystem: MusicSystem;
     public currentSystem: MusicSystem;
-    public systemMeasures: List<MeasureBuildParameters> = new List<MeasureBuildParameters>();
+    public systemMeasures: MeasureBuildParameters[] = [];
     public systemMeasureIndex: number = 0;
     public systemMeasureIndex: number = 0;
     public currentWidth: number = 0;
     public currentWidth: number = 0;
     public currentSystemFixWidth: number = 0;
     public currentSystemFixWidth: number = 0;
     public currentSystemVarWidth: number = 0;
     public currentSystemVarWidth: number = 0;
     public MaxLabelLength: number = 0;
     public MaxLabelLength: number = 0;
     public IsSystemStartMeasure(): boolean {
     public IsSystemStartMeasure(): boolean {
-        return this.systemMeasureIndex == 0;
+        return this.systemMeasureIndex === 0;
     }
     }
 }
 }
 
 

+ 13 - 13
src/MusicalScore/Graphical/StaffLine.ts

@@ -7,7 +7,7 @@ import {GraphicalObject} from "./GraphicalObject";
 import {StaffMeasure} from "./StaffMeasure";
 import {StaffMeasure} from "./StaffMeasure";
 import {MusicSystem} from "./MusicSystem";
 import {MusicSystem} from "./MusicSystem";
 export class StaffLine extends GraphicalObject {
 export class StaffLine extends GraphicalObject {
-    protected measures: List<StaffMeasure> = new List<StaffMeasure>();
+    protected measures: StaffMeasure[] = [];
     protected staffLines: GraphicalLine[] = new Array(5);
     protected staffLines: GraphicalLine[] = new Array(5);
     protected parentMusicSystem: MusicSystem;
     protected parentMusicSystem: MusicSystem;
     protected parentStaff: Staff;
     protected parentStaff: Staff;
@@ -18,10 +18,10 @@ export class StaffLine extends GraphicalObject {
         this.parentStaff = parentStaff;
         this.parentStaff = parentStaff;
         this.boundingBox = new BoundingBox(parentSystem.PositionAndShape, this);
         this.boundingBox = new BoundingBox(parentSystem.PositionAndShape, this);
     }
     }
-    public get Measures(): List<StaffMeasure> {
+    public get Measures(): StaffMeasure[] {
         return this.measures;
         return this.measures;
     }
     }
-    public set Measures(value: List<StaffMeasure>) {
+    public set Measures(value: StaffMeasure[]) {
         this.measures = value;
         this.measures = value;
     }
     }
     public get StaffLines(): GraphicalLine[] {
     public get StaffLines(): GraphicalLine[] {
@@ -55,21 +55,21 @@ export class StaffLine extends GraphicalObject {
         this.bottomLine = value;
         this.bottomLine = value;
     }
     }
     public isPartOfMultiStaffInstrument(): boolean {
     public isPartOfMultiStaffInstrument(): boolean {
-        var instrument: Instrument = this.parentStaff.ParentInstrument;
-        if (instrument.Staves.Count > 1)
+        let instrument: Instrument = this.parentStaff.ParentInstrument;
+        if (instrument.Staves.length > 1)
             return true;
             return true;
         return false;
         return false;
     }
     }
     public findClosestStaffEntry(xPosition: number): GraphicalStaffEntry {
     public findClosestStaffEntry(xPosition: number): GraphicalStaffEntry {
-        var closestStaffentry: GraphicalStaffEntry = null;
-        var difference: number = number.MaxValue;
-        for (var idx: number = 0, len = this.Measures.Count; idx < len; ++idx) {
-            var graphicalMeasure: StaffMeasure = this.Measures[idx];
-            for (var idx2: number = 0, len2 = graphicalMeasure.StaffEntries.Count; idx2 < len2; ++idx2) {
-                var graphicalStaffEntry: GraphicalStaffEntry = graphicalMeasure.StaffEntries[idx2];
-                if (Math.Abs(graphicalStaffEntry.PositionAndShape.RelativePosition.X - xPosition + graphicalMeasure.PositionAndShape.RelativePosition.X) < 5.0)
+        let closestStaffentry: GraphicalStaffEntry = undefined;
+        let difference: number = Number.MAX_VALUE;
+        for (let idx: number = 0, len: number = this.Measures.length; idx < len; ++idx) {
+            let graphicalMeasure: StaffMeasure = this.Measures[idx];
+            for (let idx2: number = 0, len2: number = graphicalMeasure.StaffEntries.length; idx2 < len2; ++idx2) {
+                let graphicalStaffEntry: GraphicalStaffEntry = graphicalMeasure.StaffEntries[idx2];
+                if (Math.abs(graphicalStaffEntry.PositionAndShape.RelativePosition.X - xPosition + graphicalMeasure.PositionAndShape.RelativePosition.X) < 5.0)
                 {
                 {
-                    difference = Math.Abs(graphicalStaffEntry.PositionAndShape.RelativePosition.X - xPosition + graphicalMeasure.PositionAndShape.RelativePosition.X);
+                    difference = Math.abs(graphicalStaffEntry.PositionAndShape.RelativePosition.X - xPosition + graphicalMeasure.PositionAndShape.RelativePosition.X);
                     closestStaffentry = graphicalStaffEntry;
                     closestStaffentry = graphicalStaffEntry;
                 }
                 }
             }
             }

+ 62 - 62
src/MusicalScore/Graphical/StaffMeasure.ts

@@ -20,17 +20,17 @@ export class StaffMeasure extends GraphicalObject {
     constructor(staff: Staff, parentSourceMeasure: SourceMeasure) {
     constructor(staff: Staff, parentSourceMeasure: SourceMeasure) {
         this.staff = staff;
         this.staff = staff;
         this.ParentSourceMeasure = parentSourceMeasure;
         this.ParentSourceMeasure = parentSourceMeasure;
-        this.StaffEntries = new List<GraphicalStaffEntry>();
-        if (this.ParentSourceMeasure != null)
+        this.StaffEntries = [];
+        if (this.ParentSourceMeasure !== undefined)
             this.measureNumber = this.ParentSourceMeasure.MeasureNumber;
             this.measureNumber = this.ParentSourceMeasure.MeasureNumber;
     }
     }
     constructor(staffLine: StaffLine) {
     constructor(staffLine: StaffLine) {
         this.parentStaffLine = staffLine;
         this.parentStaffLine = staffLine;
         this.staff = staffLine.ParentStaff;
         this.staff = staffLine.ParentStaff;
-        this.StaffEntries = new List<GraphicalStaffEntry>();
+        this.StaffEntries = [];
     }
     }
     public ParentSourceMeasure: SourceMeasure;
     public ParentSourceMeasure: SourceMeasure;
-    public StaffEntries: List<GraphicalStaffEntry>;
+    public StaffEntries: GraphicalStaffEntry[];
     public ParentMusicSystem: MusicSystem;
     public ParentMusicSystem: MusicSystem;
     public BeginInstructionsWidth: number;
     public BeginInstructionsWidth: number;
     public MinimumStaffEntriesWidth: number;
     public MinimumStaffEntriesWidth: number;
@@ -60,7 +60,7 @@ export class StaffMeasure extends GraphicalObject {
     }
     }
     public set ParentStaffLine(value: StaffLine) {
     public set ParentStaffLine(value: StaffLine) {
         this.parentStaffLine = value;
         this.parentStaffLine = value;
-        if (this.parentStaffLine != null)
+        if (this.parentStaffLine !== undefined)
             this.PositionAndShape.Parent = this.parentStaffLine.PositionAndShape;
             this.PositionAndShape.Parent = this.parentStaffLine.PositionAndShape;
     }
     }
     public ResetLayout(): void { throw new Error('not implemented'); }
     public ResetLayout(): void { throw new Error('not implemented'); }
@@ -73,42 +73,42 @@ export class StaffMeasure extends GraphicalObject {
     public SetWidth(width: number): void { throw new Error('not implemented'); }
     public SetWidth(width: number): void { throw new Error('not implemented'); }
     public LayoutSymbols(): void { throw new Error('not implemented'); }
     public LayoutSymbols(): void { throw new Error('not implemented'); }
     public findGraphicalStaffEntryFromTimestamp(relativeTimestamp: Fraction): GraphicalStaffEntry {
     public findGraphicalStaffEntryFromTimestamp(relativeTimestamp: Fraction): GraphicalStaffEntry {
-        for (var idx: number = 0, len = this.StaffEntries.Count; idx < len; ++idx) {
-            var graphicalStaffEntry: GraphicalStaffEntry = this.StaffEntries[idx];
-            if (graphicalStaffEntry.RelInMeasureTimestamp == relativeTimestamp)
+        for (let idx: number = 0, len: number = this.StaffEntries.length; idx < len; ++idx) {
+            let graphicalStaffEntry: GraphicalStaffEntry = this.StaffEntries[idx];
+            if (graphicalStaffEntry.RelInMeasureTimestamp === relativeTimestamp)
                 return graphicalStaffEntry;
                 return graphicalStaffEntry;
         }
         }
-        return null;
+        return undefined;
     }
     }
     public findGraphicalStaffEntryFromVerticalContainerTimestamp(absoluteTimestamp: Fraction): GraphicalStaffEntry {
     public findGraphicalStaffEntryFromVerticalContainerTimestamp(absoluteTimestamp: Fraction): GraphicalStaffEntry {
-        for (var idx: number = 0, len = this.StaffEntries.Count; idx < len; ++idx) {
-            var graphicalStaffEntry: GraphicalStaffEntry = this.StaffEntries[idx];
-            if (graphicalStaffEntry.SourceStaffEntry.VerticalContainerParent.getAbsoluteTimestamp() == absoluteTimestamp)
+        for (let idx: number = 0, len: number = this.StaffEntries.length; idx < len; ++idx) {
+            let graphicalStaffEntry: GraphicalStaffEntry = this.StaffEntries[idx];
+            if (graphicalStaffEntry.SourceStaffEntry.VerticalContainerParent.getAbsoluteTimestamp() === absoluteTimestamp)
                 return graphicalStaffEntry;
                 return graphicalStaffEntry;
         }
         }
-        return null;
+        return undefined;
     }
     }
     public hasSameDurationWithSourceMeasureParent(): boolean {
     public hasSameDurationWithSourceMeasureParent(): boolean {
-        var duration: Fraction = new Fraction(0, 1);
-        for (var idx: number = 0, len = this.StaffEntries.Count; idx < len; ++idx) {
-            var graphicalStaffEntry: GraphicalStaffEntry = this.StaffEntries[idx];
-            duration.Add(graphicalStaffEntry.findStaffEntryMinNoteLength());
+        let duration: Fraction = new Fraction(0, 1);
+        for (let idx: number = 0, len: number = this.StaffEntries.length; idx < len; ++idx) {
+            let graphicalStaffEntry: GraphicalStaffEntry = this.StaffEntries[idx];
+            duration.push(graphicalStaffEntry.findStaffEntryMinNoteLength());
         }
         }
-        return duration == this.ParentSourceMeasure.Duration;
+        return duration === this.ParentSourceMeasure.Duration;
     }
     }
     public hasMultipleVoices(): boolean {
     public hasMultipleVoices(): boolean {
-        if (this.StaffEntries.Count == 0)
+        if (this.StaffEntries.length === 0)
             return false;
             return false;
-        var voices: List<Voice> = new List<Voice>();
-        for (var idx: number = 0, len = this.StaffEntries.Count; idx < len; ++idx) {
-            var staffEntry: GraphicalStaffEntry = this.StaffEntries[idx];
-            for (var idx2: number = 0, len2 = staffEntry.SourceStaffEntry.VoiceEntries.Count; idx2 < len2; ++idx2) {
-                var voiceEntry: VoiceEntry = staffEntry.SourceStaffEntry.VoiceEntries[idx2];
-                if (!voices.Contains(voiceEntry.ParentVoice))
-                    voices.Add(voiceEntry.ParentVoice);
+        let voices: Voice[] = [];
+        for (let idx: number = 0, len: number = this.StaffEntries.length; idx < len; ++idx) {
+            let staffEntry: GraphicalStaffEntry = this.StaffEntries[idx];
+            for (let idx2: number = 0, len2: number = staffEntry.SourceStaffEntry.VoiceEntries.length; idx2 < len2; ++idx2) {
+                let voiceEntry: VoiceEntry = staffEntry.SourceStaffEntry.VoiceEntries[idx2];
+                if (!voices.indexOf(voiceEntry.ParentVoice) !== -1)
+                    voices.push(voiceEntry.ParentVoice);
             }
             }
         }
         }
-        if (voices.Count > 1)
+        if (voices.length > 1)
             return true;
             return true;
         return false;
         return false;
     }
     }
@@ -116,25 +116,25 @@ export class StaffMeasure extends GraphicalObject {
         return this.ParentStaff.ParentInstrument.Visible;
         return this.ParentStaff.ParentInstrument.Visible;
     }
     }
     public getGraphicalMeasureDurationFromStaffEntries(): Fraction {
     public getGraphicalMeasureDurationFromStaffEntries(): Fraction {
-        var duration: Fraction = new Fraction(0, 1);
-        var voices: List<Voice> = new List<Voice>();
-        for (var idx: number = 0, len = this.StaffEntries.Count; idx < len; ++idx) {
-            var graphicalStaffEntry: GraphicalStaffEntry = this.StaffEntries[idx];
-            for (var idx2: number = 0, len2 = graphicalStaffEntry.SourceStaffEntry.VoiceEntries.Count; idx2 < len2; ++idx2) {
-                var voiceEntry: VoiceEntry = graphicalStaffEntry.SourceStaffEntry.VoiceEntries[idx2];
-                if (!voices.Contains(voiceEntry.ParentVoice))
-                    voices.Add(voiceEntry.ParentVoice);
+        let duration: Fraction = new Fraction(0, 1);
+        let voices: Voice[] = [];
+        for (let idx: number = 0, len: number = this.StaffEntries.length; idx < len; ++idx) {
+            let graphicalStaffEntry: GraphicalStaffEntry = this.StaffEntries[idx];
+            for (let idx2: number = 0, len2: number = graphicalStaffEntry.SourceStaffEntry.VoiceEntries.length; idx2 < len2; ++idx2) {
+                let voiceEntry: VoiceEntry = graphicalStaffEntry.SourceStaffEntry.VoiceEntries[idx2];
+                if (!voices.indexOf(voiceEntry.ParentVoice) !== -1)
+                    voices.push(voiceEntry.ParentVoice);
             }
             }
         }
         }
-        for (var idx: number = 0, len = voices.Count; idx < len; ++idx) {
-            var voice: Voice = voices[idx];
-            var voiceDuration: Fraction = new Fraction(0, 1);
-            for (var idx2: number = 0, len2 = this.StaffEntries.Count; idx2 < len2; ++idx2) {
-                var graphicalStaffEntry: GraphicalStaffEntry = this.StaffEntries[idx2];
-                for (var idx3: number = 0, len3 = graphicalStaffEntry.Notes.Count; idx3 < len3; ++idx3) {
-                    var graphicalNotes: List<GraphicalNote> = graphicalStaffEntry.Notes[idx3];
-                    if (graphicalNotes.Count > 0 && graphicalNotes[0].SourceNote.ParentVoiceEntry.ParentVoice == voice)
-                        voiceDuration.Add(graphicalNotes[0].GraphicalNoteLength);
+        for (let idx: number = 0, len: number = voices.length; idx < len; ++idx) {
+            let voice: Voice = voices[idx];
+            let voiceDuration: Fraction = new Fraction(0, 1);
+            for (let idx2: number = 0, len2: number = this.StaffEntries.length; idx2 < len2; ++idx2) {
+                let graphicalStaffEntry: GraphicalStaffEntry = this.StaffEntries[idx2];
+                for (let idx3: number = 0, len3: number = graphicalStaffEntry.Notes.length; idx3 < len3; ++idx3) {
+                    let graphicalNotes: GraphicalNote[] = graphicalStaffEntry.Notes[idx3];
+                    if (graphicalNotes.length > 0 && graphicalNotes[0].SourceNote.ParentVoiceEntry.ParentVoice === voice)
+                        voiceDuration.push(graphicalNotes[0].GraphicalNoteLength);
                 }
                 }
             }
             }
             if (voiceDuration > duration)
             if (voiceDuration > duration)
@@ -143,47 +143,47 @@ export class StaffMeasure extends GraphicalObject {
         return duration;
         return duration;
     }
     }
     public addGraphicalStaffEntry(graphicalStaffEntry: GraphicalStaffEntry): void {
     public addGraphicalStaffEntry(graphicalStaffEntry: GraphicalStaffEntry): void {
-        this.StaffEntries.Add(graphicalStaffEntry);
-        this.PositionAndShape.ChildElements.Add(graphicalStaffEntry.PositionAndShape);
+        this.StaffEntries.push(graphicalStaffEntry);
+        this.PositionAndShape.ChildElements.push(graphicalStaffEntry.PositionAndShape);
     }
     }
     public addGraphicalStaffEntryAtTimestamp(staffEntry: GraphicalStaffEntry): void {
     public addGraphicalStaffEntryAtTimestamp(staffEntry: GraphicalStaffEntry): void {
-        if (staffEntry != null) {
-            if (this.StaffEntries.Count == 0 || this.StaffEntries[this.StaffEntries.Count - 1].RelInMeasureTimestamp < staffEntry.RelInMeasureTimestamp)
-                this.StaffEntries.Add(staffEntry);
+        if (staffEntry !== undefined) {
+            if (this.StaffEntries.length === 0 || this.StaffEntries[this.StaffEntries.length - 1].RelInMeasureTimestamp < staffEntry.RelInMeasureTimestamp)
+                this.StaffEntries.push(staffEntry);
             else {
             else {
-                for (var i: number = this.StaffEntries.Count - 1; i >= 0; i--) {
+                for (let i: number = this.StaffEntries.length - 1; i >= 0; i--) {
                     if (this.StaffEntries[i].RelInMeasureTimestamp < staffEntry.RelInMeasureTimestamp) {
                     if (this.StaffEntries[i].RelInMeasureTimestamp < staffEntry.RelInMeasureTimestamp) {
-                        this.StaffEntries.Insert(i + 1, staffEntry);
+                        this.StaffEntries.splice(i + 1, 0, staffEntry);
                         break;
                         break;
                     }
                     }
-                    if (i == 0)
-                        this.StaffEntries.Insert(i, staffEntry);
+                    if (i === 0)
+                        this.StaffEntries.splice(i, 0, staffEntry);
                 }
                 }
             }
             }
-            this.PositionAndShape.ChildElements.Add(staffEntry.PositionAndShape);
+            this.PositionAndShape.ChildElements.push(staffEntry.PositionAndShape);
         }
         }
     }
     }
     public beginsWithLineRepetition(): boolean {
     public beginsWithLineRepetition(): boolean {
-        var sourceMeasure: SourceMeasure = this.ParentSourceMeasure;
-        if (sourceMeasure == null)
+        let sourceMeasure: SourceMeasure = this.ParentSourceMeasure;
+        if (sourceMeasure === undefined)
             return false;
             return false;
         return sourceMeasure.beginsWithLineRepetition();
         return sourceMeasure.beginsWithLineRepetition();
     }
     }
     public endsWithLineRepetition(): boolean {
     public endsWithLineRepetition(): boolean {
-        var sourceMeasure: SourceMeasure = this.ParentSourceMeasure;
-        if (sourceMeasure == null)
+        let sourceMeasure: SourceMeasure = this.ParentSourceMeasure;
+        if (sourceMeasure === undefined)
             return false;
             return false;
         return sourceMeasure.endsWithLineRepetition();
         return sourceMeasure.endsWithLineRepetition();
     }
     }
     public beginsWithWordRepetition(): boolean {
     public beginsWithWordRepetition(): boolean {
-        var sourceMeasure: SourceMeasure = this.ParentSourceMeasure;
-        if (sourceMeasure == null)
+        let sourceMeasure: SourceMeasure = this.ParentSourceMeasure;
+        if (sourceMeasure === undefined)
             return false;
             return false;
         return sourceMeasure.beginsWithWordRepetition();
         return sourceMeasure.beginsWithWordRepetition();
     }
     }
     public endsWithWordRepetition(): boolean {
     public endsWithWordRepetition(): boolean {
-        var sourceMeasure: SourceMeasure = this.ParentSourceMeasure;
-        if (sourceMeasure == null)
+        let sourceMeasure: SourceMeasure = this.ParentSourceMeasure;
+        if (sourceMeasure === undefined)
             return false;
             return false;
         return sourceMeasure.endsWithWordRepetition();
         return sourceMeasure.endsWithWordRepetition();
     }
     }

+ 9 - 9
src/MusicalScore/Graphical/VerticalGraphicalStaffEntryContainer.ts

@@ -3,11 +3,11 @@ import {GraphicalStaffEntry} from "./GraphicalStaffEntry";
 export class VerticalGraphicalStaffEntryContainer {
 export class VerticalGraphicalStaffEntryContainer {
     private index: number;
     private index: number;
     private absoluteTimestamp: Fraction;
     private absoluteTimestamp: Fraction;
-    private staffEntries: List<GraphicalStaffEntry> = new List<GraphicalStaffEntry>();
+    private staffEntries: GraphicalStaffEntry[] = [];
     constructor(numberOfEntries: number, absoluteTimestamp: Fraction) {
     constructor(numberOfEntries: number, absoluteTimestamp: Fraction) {
         this.absoluteTimestamp = absoluteTimestamp;
         this.absoluteTimestamp = absoluteTimestamp;
-        for (var i: number = 0; i < numberOfEntries; i++)
-            this.staffEntries.Add(null);
+        for (let i: number = 0; i < numberOfEntries; i++)
+            this.staffEntries.push(undefined);
     }
     }
     public RelativeInMeasureTimestamp: Fraction;
     public RelativeInMeasureTimestamp: Fraction;
     public get Index(): number {
     public get Index(): number {
@@ -22,19 +22,19 @@ export class VerticalGraphicalStaffEntryContainer {
     public set AbsoluteTimestamp(value: Fraction) {
     public set AbsoluteTimestamp(value: Fraction) {
         this.absoluteTimestamp = value;
         this.absoluteTimestamp = value;
     }
     }
-    public get StaffEntries(): List<GraphicalStaffEntry> {
+    public get StaffEntries(): GraphicalStaffEntry[] {
         return this.staffEntries;
         return this.staffEntries;
     }
     }
-    public set StaffEntries(value: List<GraphicalStaffEntry>) {
+    public set StaffEntries(value: GraphicalStaffEntry[]) {
         this.staffEntries = value;
         this.staffEntries = value;
     }
     }
     public getFirstNonNullStaffEntry(): GraphicalStaffEntry {
     public getFirstNonNullStaffEntry(): GraphicalStaffEntry {
-        for (var idx: number = 0, len = this.staffEntries.Count; idx < len; ++idx) {
-            var graphicalStaffEntry: GraphicalStaffEntry = this.staffEntries[idx];
-            if (graphicalStaffEntry != null)
+        for (let idx: number = 0, len: number = this.staffEntries.length; idx < len; ++idx) {
+            let graphicalStaffEntry: GraphicalStaffEntry = this.staffEntries[idx];
+            if (graphicalStaffEntry !== undefined)
                 return graphicalStaffEntry;
                 return graphicalStaffEntry;
         }
         }
-        return null;
+        return undefined;
     }
     }
 }
 }
 export module VerticalGraphicalStaffEntryContainer {
 export module VerticalGraphicalStaffEntryContainer {

Some files were not shown because too many files changed in this diff