Parcourir la source

Added first bunch of graphical files.
intermediate - not working.

Matthias il y a 9 ans
Parent
commit
ae7b741db4

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

@@ -0,0 +1,19 @@
+module PhonicScore.Common.DataObjects {
+    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 + "]";
+        }
+    }
+}

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

@@ -0,0 +1,23 @@
+module PhonicScore.Common.DataObjects {
+    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);
+        }
+    }
+}

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

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

+ 1 - 1
src/Common/Enums/osmdFontStyles.ts → src/Common/Enums/FontStyles.ts

@@ -1,4 +1,4 @@
-export enum OSMDFontStyles {
+export enum FontStyles {
     Regular = 0,
     Bold = 1,
     Italic = 2,

+ 1 - 1
src/Common/Enums/osmdFonts.ts → src/Common/Enums/Fonts.ts

@@ -1,4 +1,4 @@
-export enum OSMDFonts {
+export enum Fonts {
     TimesNewRoman,
     Kokila
 }

+ 1 - 1
src/Common/Enums/osmdTextAlignment.ts → src/Common/Enums/TextAlignment.ts

@@ -1,4 +1,4 @@
-export enum OSMDTextAlignment {
+export enum TextAlignment {
     LeftTop,
     LeftCenter,
     LeftBottom,

+ 513 - 0
src/MusicalScore/Graphical/BoundingBox.ts

@@ -0,0 +1,513 @@
+import {ArgumentOutOfRangeException} from "../Exceptions";
+import PointF_2D = PhonicScore.Common.DataObjects.PointF_2D;
+import SizeF_2D = PhonicScore.Common.DataObjects.SizeF_2D;
+import RectangleF_2D = PhonicScore.Common.DataObjects.RectangleF_2D;
+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;
+        }
+        public get DataObject(): Object {
+            return this.dataObject;
+        }
+        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 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 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);
+            }
+        }
+        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);
+            }
+            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);
+            }
+            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));
+        }
+        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");
+                }
+            }
+            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 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 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;
+                }
+            }
+            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 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.0f;
+            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");
+                }
+            }
+            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 null;
+        }
+        public getObjectsInRegion<T>(region: BoundingBox): IEnumerable<T> {
+            return getObjectsInRegion<T>(region, true);
+        }
+        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) });
+            }
+            else {
+                if (region.collisionDetection(this))
+                    return __init(new List<T>(), { __as__<T>(this.dataObject, T) });
+        }
+    }
+    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 {
+    Left = 0,
+
+    Right = 1,
+
+    Up = 2,
+
+    Down = 3
+}

+ 5 - 0
src/MusicalScore/Graphical/Clickable.ts

@@ -0,0 +1,5 @@
+module PhonicScore.MusicalScore.Graphical {
+    export class Clickable extends GraphicalObject {
+        public DataObject: Object;
+    }
+}

+ 110 - 0
src/MusicalScore/Graphical/DrawingEnums.ts

@@ -0,0 +1,110 @@
+export enum OutlineAndFillStyleEnum {
+    BaseWritingColor,
+
+    FollowingCursor,
+
+    AlternativeFollowingCursor,
+
+    PlaybackCursor,
+
+    Highlighted,
+
+    ErrorUnderlay,
+
+    Selected,
+
+    SelectionSymbol,
+
+    DebugColor1,
+
+    DebugColor2,
+
+    DebugColor3,
+
+    SplitScreenDivision,
+
+    GreyTransparentOverlay,
+
+    MarkedArea1,
+
+    MarkedArea2,
+
+    MarkedArea3,
+
+    MarkedArea4,
+
+    MarkedArea5,
+
+    MarkedArea6,
+
+    MarkedArea7,
+
+    MarkedArea8,
+
+    MarkedArea9,
+
+    MarkedArea10,
+
+    Comment1,
+
+    Comment2,
+
+    Comment3,
+
+    Comment4,
+
+    Comment5,
+
+    Comment6,
+
+    Comment7,
+
+    Comment8,
+
+    Comment9,
+
+    Comment10
+}
+export enum StyleSets {
+    MarkedArea,
+
+    Comment
+}
+export enum GraphicalLayers {
+    Background,
+
+    Highlight,
+
+    MeasureError,
+
+    SelectionSymbol,
+
+    Cursor,
+
+    PSI_Debug,
+
+    Notes,
+
+    Comment,
+
+    Debug_above
+}
+export enum NoteState {
+    Normal,
+
+    Selected,
+
+    Follow_Confirmed,
+
+    QFeedback_NotFound,
+
+    QFeedback_OK,
+
+    QFeedback_Perfect,
+
+    Debug1,
+
+    Debug2,
+
+    Debug3
+}

+ 1119 - 0
src/MusicalScore/Graphical/EngravingRules.ts

@@ -0,0 +1,1119 @@
+module PhonicScore.MusicalScore.Graphical {
+    import PagePlacementEnum = PhonicScore.MusicalScore.Graphical.SheetData.PagePlacementEnum;
+    export class EngravingRules {
+        private static rules: EngravingRules;
+        private static unit: number = 1.0;
+        private samplingUnit: number;
+        private staccatoShorteningFactor: number;
+        private sheetTitleHeight: number;
+        private sheetSubtitleHeight: number;
+        private sheetMinimumDistanceBetweenTitleAndSubtitle: number;
+        private sheetComposerHeight: number;
+        private sheetAuthorHeight: number;
+        private pagePlacementEnum: PagePlacementEnum;
+        private pageHeight: number;
+        private pageTopMargin: number;
+        private pageBottomMargin: number;
+        private pageLeftMargin: number;
+        private pageRightMargin: number;
+        private titleTopDistance: number;
+        private titleBottomDistance: number;
+        private systemDistance: number;
+        private systemLeftMargin: number;
+        private systemRightMargin: number;
+        private firstSystemMargin: number;
+        private systemLabelsRightMargin: number;
+        private systemComposerDistance: number;
+        private instrumentLabelTextHeight: number;
+        private minimumAllowedDistanceBetweenSystems: number;
+        private lastSystemMaxScalingFactor: number;
+        private staffDistance: number;
+        private betweenStaffDistance: number;
+        private staffHeight: number;
+        private betweenStaffLinesDistance: number;
+        private beamWidth: number;
+        private beamSpaceWidth: number;
+        private beamForwardLength: number;
+        private clefLeftMargin: number;
+        private clefRightMargin: number;
+        private betweenKeySymbolsDistance: number;
+        private keyRightMargin: number;
+        private rhythmRightMargin: number;
+        private inStaffClefScalingFactor: number;
+        private distanceBetweenNaturalAndSymbolWhenCancelling: number;
+        private noteHelperLinesOffset: number;
+        private measureLeftMargin: number;
+        private measureRightMargin: number;
+        private distanceBetweenLastInstructionAndRepetitionBarline: number;
+        private arpeggioDistance: number;
+        private idealStemLength: number;
+        private stemNoteHeadBorderYOffset: number;
+        private stemWidth: number;
+        private stemMargin: number;
+        private stemMinLength: number;
+        private stemMaxLength: number;
+        private beamSlopeMaxAngle: number;
+        private stemMinAllowedDistanceBetweenNoteHeadAndBeamLine: number;
+        private graceNoteScalingFactor: number;
+        private graceNoteXOffset: number;
+        private wedgeOpeningLength: number;
+        private wedgeMeasureEndOpeningLength: number;
+        private wedgeMeasureBeginOpeningLength: number;
+        private wedgePlacementAboveY: number;
+        private wedgePlacementBelowY: number;
+        private wedgeHorizontalMargin: number;
+        private wedgeVerticalMargin: number;
+        private distanceOffsetBetweenTwoHorizontallyCrossedWedges: number;
+        private wedgeMinLength: number;
+        private distanceBetweenAdjacentDynamics: number;
+        private tempoChangeMeasureValitidy: number;
+        private tempoContinousFactor: number;
+        private staccatoScalingFactor: number;
+        private betweenDotsDistance: number;
+        private ornamentAccidentalScalingFactor: number;
+        private chordSymbolTextHeight: number;
+        private chordSymbolYOffset: number;
+        private fingeringLabelFontHeight: number;
+        private measureNumberLabelHeight: number;
+        private measureNumberLabelOffset: number;
+        private tupletNumberLabelHeight: number;
+        private tupletNumberYOffset: number;
+        private labelMarginBorderFactor: number;
+        private tupletVerticalLineLength: number;
+        private repetitionEndingLabelHeight: number;
+        private repetitionEndingLabelXOffset: number;
+        private repetitionEndingLabelYOffset: number;
+        private repetitionEndingLineYLowerOffset: number;
+        private repetitionEndingLineYUpperOffset: number;
+        private lyricsHeight: number;
+        private verticalBetweenLyricsDistance: number;
+        private betweenSyllabelMaximumDistance: number;
+        private minimumDistanceBetweenDashes: number;
+        private bezierCurveStepSize: number;
+        private tPower3: number[];
+        private oneMinusTPower3: number[];
+        private factorOne: number[];
+        private factorTwo: number[];
+        private tieGhostObjectWidth: number;
+        private tieYPositionOffsetFactor: number;
+        private minimumNeededXspaceForTieGhostObject: number;
+        private tieHeightMinimum: number;
+        private tieHeightMaximum: number;
+        private tieHeightInterpolationK: number;
+        private tieHeightInterpolationD: number;
+        private slurNoteHeadYOffset: number;
+        private slurStemXOffset: number;
+        private slurSlopeMaxAngle: number;
+        private slurTangentMinAngle: number;
+        private slurTangentMaxAngle: number;
+        private slursStartingAtSameStaffEntryYOffset: number;
+        private instantaniousTempoTextHeight: number;
+        private continuousDynamicTextHeight: number;
+        private moodTextHeight: number;
+        private unknownTextHeight: number;
+        private continuousTempoTextHeight: number;
+        private staffLineWidth: number;
+        private ledgerLineWidth: number;
+        private wedgeLineWidth: number;
+        private tupletLineWidth: number;
+        private lyricUnderscoreLineWidth: number;
+        private systemThinLineWidth: number;
+        private systemBoldLineWidth: number;
+        private systemRepetitionEndingLineWidth: number;
+        private systemDotWidth: number;
+        private distanceBetweenVerticalSystemLines: number;
+        private distanceBetweenDotAndLine: number;
+        private octaveShiftLineWidth: number;
+        private octaveShiftVerticalLineLength: number;
+        private graceLineWidth: number;
+        private minimumStaffLineDistance: number;
+        private minimumCrossedBeamDifferenceMargin: number;
+        private displacedNoteMargin: number;
+        private minNoteDistance: number;
+        private subMeasureXSpacingThreshold: number;
+        private measureDynamicsMaxScalingFactor: number;
+        private maxInstructionsConstValue: number;
+        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 durationDistanceDict: Dictionary<number, number> = new Dictionary<number, number>();
+        private durationScalingDistanceDict: Dictionary<number, number> = new Dictionary<number, number>();
+        constructor() {
+            this.samplingUnit = EngravingRules.unit * 3;
+            this.sheetTitleHeight = 4.0;
+            this.sheetSubtitleHeight = 2.0;
+            this.sheetMinimumDistanceBetweenTitleAndSubtitle = 1.0;
+            this.sheetComposerHeight = 2.0;
+            this.sheetAuthorHeight = 2.0;
+            this.pagePlacementEnum = PagePlacementEnum.Down;
+            this.pageHeight = 100000.0;
+            this.pageTopMargin = 5.0;
+            this.pageBottomMargin = 5.0;
+            this.pageLeftMargin = 5.0;
+            this.pageRightMargin = 5.0;
+            this.titleTopDistance = 9.0;
+            this.titleBottomDistance = 1.0;
+            this.staffDistance = 7.0;
+            this.betweenStaffDistance = 5.0;
+            this.staffHeight = 4.0;
+            this.betweenStaffLinesDistance = EngravingRules.unit;
+            this.systemDistance = 10.0;
+            this.systemLeftMargin = 0.0;
+            this.systemRightMargin = 0.0;
+            this.firstSystemMargin = 15.0;
+            this.systemLabelsRightMargin = 2.0;
+            this.systemComposerDistance = 2.0;
+            this.instrumentLabelTextHeight = 2;
+            this.minimumAllowedDistanceBetweenSystems = 3.0;
+            this.lastSystemMaxScalingFactor = 1.4;
+            this.beamWidth = EngravingRules.unit / 2.0;
+            this.beamSpaceWidth = EngravingRules.unit / 3.0;
+            this.beamForwardLength = 1.25 * EngravingRules.unit;
+            this.clefLeftMargin = 0.5;
+            this.clefRightMargin = 0.75;
+            this.betweenKeySymbolsDistance = 0.2;
+            this.keyRightMargin = 0.75;
+            this.rhythmRightMargin = 1.25;
+            this.inStaffClefScalingFactor = 0.8;
+            this.distanceBetweenNaturalAndSymbolWhenCancelling = 0.4;
+            this.noteHelperLinesOffset = 0.25;
+            this.measureLeftMargin = 0.7;
+            this.measureRightMargin = 0.0;
+            this.distanceBetweenLastInstructionAndRepetitionBarline = 1.0;
+            this.arpeggioDistance = 0.6;
+            this.staccatoShorteningFactor = 2;
+            this.idealStemLength = 3.0;
+            this.stemNoteHeadBorderYOffset = 0.2;
+            this.stemWidth = 0.13;
+            this.stemMargin = 0.2;
+            this.stemMinLength = 2.5;
+            this.stemMaxLength = 4.5;
+            this.beamSlopeMaxAngle = 10.0;
+            this.stemMinAllowedDistanceBetweenNoteHeadAndBeamLine = 1.0;
+            this.graceNoteScalingFactor = 0.6;
+            this.graceNoteXOffset = 0.2;
+            this.wedgeOpeningLength = 1.2;
+            this.wedgeMeasureEndOpeningLength = 0.75;
+            this.wedgeMeasureBeginOpeningLength = 0.75;
+            this.wedgePlacementAboveY = -1.5;
+            this.wedgePlacementBelowY = 1.5;
+            this.wedgeHorizontalMargin = 0.6;
+            this.wedgeVerticalMargin = 0.5;
+            this.distanceOffsetBetweenTwoHorizontallyCrossedWedges = 0.3;
+            this.wedgeMinLength = 2.0;
+            this.distanceBetweenAdjacentDynamics = 0.75;
+            this.tempoChangeMeasureValitidy = 4;
+            this.tempoContinousFactor = 0.7;
+            this.staccatoScalingFactor = 0.8;
+            this.betweenDotsDistance = 0.8;
+            this.ornamentAccidentalScalingFactor = 0.65;
+            this.chordSymbolTextHeight = 2.0;
+            this.fingeringLabelFontHeight = 1.7;
+            this.measureNumberLabelHeight = 1.5 * EngravingRules.unit;
+            this.measureNumberLabelOffset = 2;
+            this.tupletNumberLabelHeight = 1.5 * EngravingRules.unit;
+            this.tupletNumberYOffset = 0.5;
+            this.labelMarginBorderFactor = 0.1;
+            this.tupletVerticalLineLength = 0.5;
+            this.bezierCurveStepSize = 1000;
+            this.calculateCurveParametersArrays();
+            this.tieGhostObjectWidth = 0.75;
+            this.tieYPositionOffsetFactor = 0.3;
+            this.minimumNeededXspaceForTieGhostObject = 1.0;
+            this.tieHeightMinimum = 0.28;
+            this.tieHeightMaximum = 1.2;
+            this.tieHeightInterpolationK = 0.0288;
+            this.tieHeightInterpolationD = 0.136;
+            this.slurNoteHeadYOffset = 0.5;
+            this.slurStemXOffset = 0.3;
+            this.slurSlopeMaxAngle = 15.0;
+            this.slurTangentMinAngle = 30.0;
+            this.slurTangentMaxAngle = 80.0;
+            this.slursStartingAtSameStaffEntryYOffset = 0.8;
+            this.repetitionEndingLabelHeight = 2.0;
+            this.repetitionEndingLabelXOffset = 0.5;
+            this.repetitionEndingLabelYOffset = 0.3;
+            this.repetitionEndingLineYLowerOffset = 0.5;
+            this.repetitionEndingLineYUpperOffset = 0.3;
+            this.lyricsHeight = 2.0;
+            this.verticalBetweenLyricsDistance = 0.5;
+            this.betweenSyllabelMaximumDistance = 10.0;
+            this.minimumDistanceBetweenDashes = 5.0;
+            this.instantaniousTempoTextHeight = 2.3;
+            this.continuousDynamicTextHeight = 2.3;
+            this.moodTextHeight = 2.3;
+            this.unknownTextHeight = 2.0;
+            this.continuousTempoTextHeight = 2.3;
+            this.staffLineWidth = 0.12;
+            this.ledgerLineWidth = 0.12;
+            this.wedgeLineWidth = 0.12;
+            this.tupletLineWidth = 0.12;
+            this.lyricUnderscoreLineWidth = 0.12;
+            this.systemThinLineWidth = 0.12;
+            this.systemBoldLineWidth = EngravingRules.unit / 2.0;
+            this.systemRepetitionEndingLineWidth = 0.12;
+            this.systemDotWidth = EngravingRules.unit / 5.0;
+            this.distanceBetweenVerticalSystemLines = 0.35;
+            this.distanceBetweenDotAndLine = 0.7;
+            this.octaveShiftLineWidth = 0.12;
+            this.octaveShiftVerticalLineLength = EngravingRules.unit;
+            this.graceLineWidth = this.staffLineWidth * this.GraceNoteScalingFactor;
+            this.minimumStaffLineDistance = 1.0;
+            this.minimumCrossedBeamDifferenceMargin = 0.0001;
+            this.displacedNoteMargin = 0.1;
+            this.minNoteDistance = 2.0;
+            this.subMeasureXSpacingThreshold = 35;
+            this.measureDynamicsMaxScalingFactor = 2.5;
+            this.populateDictionaries();
+            try {
+                this.maxInstructionsConstValue = this.ClefLeftMargin + this.ClefRightMargin + this.KeyRightMargin + this.RhythmRightMargin;
+                if (FontInfo.Info != null) {
+                    this.maxInstructionsConstValue += FontInfo.Info.getBoundingBox(MusicSymbol.G_CLEF).Width + FontInfo.Info.getBoundingBox(MusicSymbol.FOUR).Width + 7 * FontInfo.Info.getBoundingBox(MusicSymbol.SHARP).Width;
+                }
+            }
+            catch (ex) {
+                Logger.DefaultLogger.LogError(PhonicScore.Common.Enums.LogLevel.NORMAL, "EngravingRules()", ex);
+            }
+
+        }
+        public static get Rules(): EngravingRules {
+            return EngravingRules.rules != null ? EngravingRules.rules : (EngravingRules.rules = new EngravingRules());
+        }
+        public get SamplingUnit(): number {
+            return this.samplingUnit;
+        }
+        public get SheetTitleHeight(): number {
+            return this.sheetTitleHeight;
+        }
+        public set SheetTitleHeight(value: number) {
+            this.sheetTitleHeight = value;
+        }
+        public get SheetSubtitleHeight(): number {
+            return this.sheetSubtitleHeight;
+        }
+        public set SheetSubtitleHeight(value: number) {
+            this.sheetSubtitleHeight = value;
+        }
+        public get SheetMinimumDistanceBetweenTitleAndSubtitle(): number {
+            return this.sheetMinimumDistanceBetweenTitleAndSubtitle;
+        }
+        public set SheetMinimumDistanceBetweenTitleAndSubtitle(value: number) {
+            this.sheetMinimumDistanceBetweenTitleAndSubtitle = value;
+        }
+        public get SheetComposerHeight(): number {
+            return this.sheetComposerHeight;
+        }
+        public set SheetComposerHeight(value: number) {
+            this.sheetComposerHeight = value;
+        }
+        public get SheetAuthorHeight(): number {
+            return this.sheetAuthorHeight;
+        }
+        public set SheetAuthorHeight(value: number) {
+            this.sheetAuthorHeight = value;
+        }
+        public get PagePlacement(): PagePlacementEnum {
+            return this.pagePlacementEnum;
+        }
+        public set PagePlacement(value: PagePlacementEnum) {
+            this.pagePlacementEnum = value;
+        }
+        public get PageHeight(): number {
+            return this.pageHeight;
+        }
+        public set PageHeight(value: number) {
+            this.pageHeight = value;
+        }
+        public get PageTopMargin(): number {
+            return this.pageTopMargin;
+        }
+        public set PageTopMargin(value: number) {
+            this.pageTopMargin = value;
+        }
+        public get PageBottomMargin(): number {
+            return this.pageBottomMargin;
+        }
+        public set PageBottomMargin(value: number) {
+            this.pageBottomMargin = value;
+        }
+        public get PageLeftMargin(): number {
+            return this.pageLeftMargin;
+        }
+        public set PageLeftMargin(value: number) {
+            this.pageLeftMargin = value;
+        }
+        public get PageRightMargin(): number {
+            return this.pageRightMargin;
+        }
+        public set PageRightMargin(value: number) {
+            this.pageRightMargin = value;
+        }
+        public get TitleTopDistance(): number {
+            return this.titleTopDistance;
+        }
+        public set TitleTopDistance(value: number) {
+            this.titleTopDistance = value;
+        }
+        public get TitleBottomDistance(): number {
+            return this.titleBottomDistance;
+        }
+        public set TitleBottomDistance(value: number) {
+            this.titleBottomDistance = value;
+        }
+        public get SystemComposerDistance(): number {
+            return this.systemComposerDistance;
+        }
+        public set SystemComposerDistance(value: number) {
+            this.systemComposerDistance = value;
+        }
+        public get InstrumentLabelTextHeight(): number {
+            return this.instrumentLabelTextHeight;
+        }
+        public set InstrumentLabelTextHeight(value: number) {
+            this.instrumentLabelTextHeight = value;
+        }
+        public get SystemDistance(): number {
+            return this.systemDistance;
+        }
+        public set SystemDistance(value: number) {
+            this.systemDistance = value;
+        }
+        public get SystemLeftMargin(): number {
+            return this.systemLeftMargin;
+        }
+        public set SystemLeftMargin(value: number) {
+            this.systemLeftMargin = value;
+        }
+        public get SystemRightMargin(): number {
+            return this.systemRightMargin;
+        }
+        public set SystemRightMargin(value: number) {
+            this.systemRightMargin = value;
+        }
+        public get FirstSystemMargin(): number {
+            return this.firstSystemMargin;
+        }
+        public set FirstSystemMargin(value: number) {
+            this.firstSystemMargin = value;
+        }
+        public get SystemLabelsRightMargin(): number {
+            return this.systemLabelsRightMargin;
+        }
+        public get MinimumAllowedDistanceBetweenSystems(): number {
+            return this.minimumAllowedDistanceBetweenSystems;
+        }
+        public set MinimumAllowedDistanceBetweenSystems(value: number) {
+            this.minimumAllowedDistanceBetweenSystems = value;
+        }
+        public get LastSystemMaxScalingFactor(): number {
+            return this.lastSystemMaxScalingFactor;
+        }
+        public set LastSystemMaxScalingFactor(value: number) {
+            this.lastSystemMaxScalingFactor = value;
+        }
+        public get StaffDistance(): number {
+            return this.staffDistance;
+        }
+        public set StaffDistance(value: number) {
+            this.staffDistance = value;
+        }
+        public get BetweenStaffDistance(): number {
+            return this.betweenStaffDistance;
+        }
+        public set BetweenStaffDistance(value: number) {
+            this.betweenStaffDistance = value;
+        }
+        public get StaffHeight(): number {
+            return this.staffHeight;
+        }
+        public set StaffHeight(value: number) {
+            this.staffHeight = value;
+        }
+        public get BetweenStaffLinesDistance(): number {
+            return this.betweenStaffLinesDistance;
+        }
+        public set BetweenStaffLinesDistance(value: number) {
+            this.betweenStaffLinesDistance = value;
+        }
+        public get BeamWidth(): number {
+            return this.beamWidth;
+        }
+        public set BeamWidth(value: number) {
+            this.beamWidth = value;
+        }
+        public get BeamSpaceWidth(): number {
+            return this.beamSpaceWidth;
+        }
+        public set BeamSpaceWidth(value: number) {
+            this.beamSpaceWidth = value;
+        }
+        public get BeamForwardLength(): number {
+            return this.beamForwardLength;
+        }
+        public set BeamForwardLength(value: number) {
+            this.beamForwardLength = value;
+        }
+        public get BetweenKeySymbolsDistance(): number {
+            return this.betweenKeySymbolsDistance;
+        }
+        public set BetweenKeySymbolsDistance(value: number) {
+            this.betweenKeySymbolsDistance = value;
+        }
+        public get ClefLeftMargin(): number {
+            return this.clefLeftMargin;
+        }
+        public set ClefLeftMargin(value: number) {
+            this.clefLeftMargin = value;
+        }
+        public get ClefRightMargin(): number {
+            return this.clefRightMargin;
+        }
+        public set ClefRightMargin(value: number) {
+            this.clefRightMargin = value;
+        }
+        public get KeyRightMargin(): number {
+            return this.keyRightMargin;
+        }
+        public set KeyRightMargin(value: number) {
+            this.keyRightMargin = value;
+        }
+        public get RhythmRightMargin(): number {
+            return this.rhythmRightMargin;
+        }
+        public set RhythmRightMargin(value: number) {
+            this.rhythmRightMargin = value;
+        }
+        public get InStaffClefScalingFactor(): number {
+            return this.inStaffClefScalingFactor;
+        }
+        public set InStaffClefScalingFactor(value: number) {
+            this.inStaffClefScalingFactor = value;
+        }
+        public get DistanceBetweenNaturalAndSymbolWhenCancelling(): number {
+            return this.distanceBetweenNaturalAndSymbolWhenCancelling;
+        }
+        public set DistanceBetweenNaturalAndSymbolWhenCancelling(value: number) {
+            this.distanceBetweenNaturalAndSymbolWhenCancelling = value;
+        }
+        public get NoteHelperLinesOffset(): number {
+            return this.noteHelperLinesOffset;
+        }
+        public set NoteHelperLinesOffset(value: number) {
+            this.noteHelperLinesOffset = value;
+        }
+        public get MeasureLeftMargin(): number {
+            return this.measureLeftMargin;
+        }
+        public set MeasureLeftMargin(value: number) {
+            this.measureLeftMargin = value;
+        }
+        public get MeasureRightMargin(): number {
+            return this.measureRightMargin;
+        }
+        public set MeasureRightMargin(value: number) {
+            this.measureRightMargin = value;
+        }
+        public get DistanceBetweenLastInstructionAndRepetitionBarline(): number {
+            return this.distanceBetweenLastInstructionAndRepetitionBarline;
+        }
+        public set DistanceBetweenLastInstructionAndRepetitionBarline(value: number) {
+            this.distanceBetweenLastInstructionAndRepetitionBarline = value;
+        }
+        public get ArpeggioDistance(): number {
+            return this.arpeggioDistance;
+        }
+        public set ArpeggioDistance(value: number) {
+            this.arpeggioDistance = value;
+        }
+        public get StaccatoShorteningFactor(): number {
+            return this.staccatoShorteningFactor;
+        }
+        public set StaccatoShorteningFactor(value: number) {
+            this.staccatoShorteningFactor = value;
+        }
+        public get IdealStemLength(): number {
+            return this.idealStemLength;
+        }
+        public set IdealStemLength(value: number) {
+            this.idealStemLength = value;
+        }
+        public get StemNoteHeadBorderYOffset(): number {
+            return this.stemNoteHeadBorderYOffset;
+        }
+        public set StemNoteHeadBorderYOffset(value: number) {
+            this.stemNoteHeadBorderYOffset = value;
+        }
+        public get StemWidth(): number {
+            return this.stemWidth;
+        }
+        public set StemWidth(value: number) {
+            this.stemWidth = value;
+        }
+        public get StemMargin(): number {
+            return this.stemMargin;
+        }
+        public set StemMargin(value: number) {
+            this.stemMargin = value;
+        }
+        public get StemMinLength(): number {
+            return this.stemMinLength;
+        }
+        public set StemMinLength(value: number) {
+            this.stemMinLength = value;
+        }
+        public get StemMaxLength(): number {
+            return this.stemMaxLength;
+        }
+        public set StemMaxLength(value: number) {
+            this.stemMaxLength = value;
+        }
+        public get BeamSlopeMaxAngle(): number {
+            return this.beamSlopeMaxAngle;
+        }
+        public set BeamSlopeMaxAngle(value: number) {
+            this.beamSlopeMaxAngle = value;
+        }
+        public get StemMinAllowedDistanceBetweenNoteHeadAndBeamLine(): number {
+            return this.stemMinAllowedDistanceBetweenNoteHeadAndBeamLine;
+        }
+        public set StemMinAllowedDistanceBetweenNoteHeadAndBeamLine(value: number) {
+            this.stemMinAllowedDistanceBetweenNoteHeadAndBeamLine = value;
+        }
+        public get GraceNoteScalingFactor(): number {
+            return this.graceNoteScalingFactor;
+        }
+        public set GraceNoteScalingFactor(value: number) {
+            this.graceNoteScalingFactor = value;
+        }
+        public get GraceNoteXOffset(): number {
+            return this.graceNoteXOffset;
+        }
+        public set GraceNoteXOffset(value: number) {
+            this.graceNoteXOffset = value;
+        }
+        public get WedgeOpeningLength(): number {
+            return this.wedgeOpeningLength;
+        }
+        public set WedgeOpeningLength(value: number) {
+            this.wedgeOpeningLength = value;
+        }
+        public get WedgeMeasureEndOpeningLength(): number {
+            return this.wedgeMeasureEndOpeningLength;
+        }
+        public set WedgeMeasureEndOpeningLength(value: number) {
+            this.wedgeMeasureEndOpeningLength = value;
+        }
+        public get WedgeMeasureBeginOpeningLength(): number {
+            return this.wedgeMeasureBeginOpeningLength;
+        }
+        public set WedgeMeasureBeginOpeningLength(value: number) {
+            this.wedgeMeasureBeginOpeningLength = value;
+        }
+        public get WedgePlacementAboveY(): number {
+            return this.wedgePlacementAboveY;
+        }
+        public set WedgePlacementAboveY(value: number) {
+            this.wedgePlacementAboveY = value;
+        }
+        public get WedgePlacementBelowY(): number {
+            return this.wedgePlacementBelowY;
+        }
+        public set WedgePlacementBelowY(value: number) {
+            this.wedgePlacementBelowY = value;
+        }
+        public get WedgeHorizontalMargin(): number {
+            return this.wedgeHorizontalMargin;
+        }
+        public set WedgeHorizontalMargin(value: number) {
+            this.wedgeHorizontalMargin = value;
+        }
+        public get WedgeVerticalMargin(): number {
+            return this.wedgeVerticalMargin;
+        }
+        public set WedgeVerticalMargin(value: number) {
+            this.wedgeVerticalMargin = value;
+        }
+        public get DistanceOffsetBetweenTwoHorizontallyCrossedWedges(): number {
+            return this.distanceOffsetBetweenTwoHorizontallyCrossedWedges;
+        }
+        public set DistanceOffsetBetweenTwoHorizontallyCrossedWedges(value: number) {
+            this.distanceOffsetBetweenTwoHorizontallyCrossedWedges = value;
+        }
+        public get WedgeMinLength(): number {
+            return this.wedgeMinLength;
+        }
+        public set WedgeMinLength(value: number) {
+            this.wedgeMinLength = value;
+        }
+        public get DistanceBetweenAdjacentDynamics(): number {
+            return this.distanceBetweenAdjacentDynamics;
+        }
+        public set DistanceBetweenAdjacentDynamics(value: number) {
+            this.distanceBetweenAdjacentDynamics = value;
+        }
+        public get TempoChangeMeasureValitidy(): number {
+            return this.tempoChangeMeasureValitidy;
+        }
+        public set TempoChangeMeasureValitidy(value: number) {
+            this.tempoChangeMeasureValitidy = value;
+        }
+        public get TempoContinousFactor(): number {
+            return this.tempoContinousFactor;
+        }
+        public set TempoContinousFactor(value: number) {
+            this.tempoContinousFactor = value;
+        }
+        public get StaccatoScalingFactor(): number {
+            return this.staccatoScalingFactor;
+        }
+        public set StaccatoScalingFactor(value: number) {
+            this.staccatoScalingFactor = value;
+        }
+        public get BetweenDotsDistance(): number {
+            return this.betweenDotsDistance;
+        }
+        public set BetweenDotsDistance(value: number) {
+            this.betweenDotsDistance = value;
+        }
+        public get OrnamentAccidentalScalingFactor(): number {
+            return this.ornamentAccidentalScalingFactor;
+        }
+        public set OrnamentAccidentalScalingFactor(value: number) {
+            this.ornamentAccidentalScalingFactor = value;
+        }
+        public get ChordSymbolTextHeight(): number {
+            return this.chordSymbolTextHeight;
+        }
+        public set ChordSymbolTextHeight(value: number) {
+            this.chordSymbolTextHeight = value;
+        }
+        public get FingeringLabelFontHeight(): number {
+            return this.fingeringLabelFontHeight;
+        }
+        public set FingeringLabelFontHeight(value: number) {
+            this.fingeringLabelFontHeight = value;
+        }
+        public get MeasureNumberLabelHeight(): number {
+            return this.measureNumberLabelHeight;
+        }
+        public set MeasureNumberLabelHeight(value: number) {
+            this.measureNumberLabelHeight = value;
+        }
+        public get MeasureNumberLabelOffset(): number {
+            return this.measureNumberLabelOffset;
+        }
+        public set MeasureNumberLabelOffset(value: number) {
+            this.measureNumberLabelOffset = value;
+        }
+        public get TupletNumberLabelHeight(): number {
+            return this.tupletNumberLabelHeight;
+        }
+        public set TupletNumberLabelHeight(value: number) {
+            this.tupletNumberLabelHeight = value;
+        }
+        public get TupletNumberYOffset(): number {
+            return this.tupletNumberYOffset;
+        }
+        public set TupletNumberYOffset(value: number) {
+            this.tupletNumberYOffset = value;
+        }
+        public get LabelMarginBorderFactor(): number {
+            return this.labelMarginBorderFactor;
+        }
+        public set LabelMarginBorderFactor(value: number) {
+            this.labelMarginBorderFactor = value;
+        }
+        public get TupletVerticalLineLength(): number {
+            return this.tupletVerticalLineLength;
+        }
+        public set TupletVerticalLineLength(value: number) {
+            this.tupletVerticalLineLength = value;
+        }
+        public get RepetitionEndingLabelHeight(): number {
+            return this.repetitionEndingLabelHeight;
+        }
+        public set RepetitionEndingLabelHeight(value: number) {
+            this.repetitionEndingLabelHeight = value;
+        }
+        public get RepetitionEndingLabelXOffset(): number {
+            return this.repetitionEndingLabelXOffset;
+        }
+        public set RepetitionEndingLabelXOffset(value: number) {
+            this.repetitionEndingLabelXOffset = value;
+        }
+        public get RepetitionEndingLabelYOffset(): number {
+            return this.repetitionEndingLabelYOffset;
+        }
+        public set RepetitionEndingLabelYOffset(value: number) {
+            this.repetitionEndingLabelYOffset = value;
+        }
+        public get RepetitionEndingLineYLowerOffset(): number {
+            return this.repetitionEndingLineYLowerOffset;
+        }
+        public set RepetitionEndingLineYLowerOffset(value: number) {
+            this.repetitionEndingLineYLowerOffset = value;
+        }
+        public get RepetitionEndingLineYUpperOffset(): number {
+            return this.repetitionEndingLineYUpperOffset;
+        }
+        public set RepetitionEndingLineYUpperOffset(value: number) {
+            this.repetitionEndingLineYUpperOffset = value;
+        }
+        public get LyricsHeight(): number {
+            return this.lyricsHeight;
+        }
+        public set LyricsHeight(value: number) {
+            this.lyricsHeight = value;
+        }
+        public get VerticalBetweenLyricsDistance(): number {
+            return this.verticalBetweenLyricsDistance;
+        }
+        public set VerticalBetweenLyricsDistance(value: number) {
+            this.verticalBetweenLyricsDistance = value;
+        }
+        public get BetweenSyllabelMaximumDistance(): number {
+            return this.betweenSyllabelMaximumDistance;
+        }
+        public set BetweenSyllabelMaximumDistance(value: number) {
+            this.betweenSyllabelMaximumDistance = value;
+        }
+        public get MinimumDistanceBetweenDashes(): number {
+            return this.minimumDistanceBetweenDashes;
+        }
+        public set MinimumDistanceBetweenDashes(value: number) {
+            this.minimumDistanceBetweenDashes = value;
+        }
+        public get BezierCurveStepSize(): number {
+            return this.bezierCurveStepSize;
+        }
+        public set BezierCurveStepSize(value: number) {
+            this.bezierCurveStepSize = value;
+        }
+        public get TPow3(): number[] {
+            return this.tPower3;
+        }
+        public set TPow3(value: number[]) {
+            this.tPower3 = value;
+        }
+        public get OneMinusTPow3(): number[] {
+            return this.oneMinusTPower3;
+        }
+        public set OneMinusTPow3(value: number[]) {
+            this.oneMinusTPower3 = value;
+        }
+        public get BezierFactorOne(): number[] {
+            return this.factorOne;
+        }
+        public set BezierFactorOne(value: number[]) {
+            this.factorOne = value;
+        }
+        public get BezierFactorTwo(): number[] {
+            return this.factorTwo;
+        }
+        public set BezierFactorTwo(value: number[]) {
+            this.factorTwo = value;
+        }
+        public get TieGhostObjectWidth(): number {
+            return this.tieGhostObjectWidth;
+        }
+        public set TieGhostObjectWidth(value: number) {
+            this.tieGhostObjectWidth = value;
+        }
+        public get TieYPositionOffsetFactor(): number {
+            return this.tieYPositionOffsetFactor;
+        }
+        public set TieYPositionOffsetFactor(value: number) {
+            this.tieYPositionOffsetFactor = value;
+        }
+        public get MinimumNeededXspaceForTieGhostObject(): number {
+            return this.minimumNeededXspaceForTieGhostObject;
+        }
+        public set MinimumNeededXspaceForTieGhostObject(value: number) {
+            this.minimumNeededXspaceForTieGhostObject = value;
+        }
+        public get TieHeightMinimum(): number {
+            return this.tieHeightMinimum;
+        }
+        public set TieHeightMinimum(value: number) {
+            this.tieHeightMinimum = value;
+        }
+        public get TieHeightMaximum(): number {
+            return this.tieHeightMaximum;
+        }
+        public set TieHeightMaximum(value: number) {
+            this.tieHeightMaximum = value;
+        }
+        public get TieHeightInterpolationK(): number {
+            return this.tieHeightInterpolationK;
+        }
+        public set TieHeightInterpolationK(value: number) {
+            this.tieHeightInterpolationK = value;
+        }
+        public get TieHeightInterpolationD(): number {
+            return this.tieHeightInterpolationD;
+        }
+        public set TieHeightInterpolationD(value: number) {
+            this.tieHeightInterpolationD = value;
+        }
+        public get SlurNoteHeadYOffset(): number {
+            return this.slurNoteHeadYOffset;
+        }
+        public set SlurNoteHeadYOffset(value: number) {
+            this.slurNoteHeadYOffset = value;
+        }
+        public get SlurStemXOffset(): number {
+            return this.slurStemXOffset;
+        }
+        public set SlurStemXOffset(value: number) {
+            this.slurStemXOffset = value;
+        }
+        public get SlurSlopeMaxAngle(): number {
+            return this.slurSlopeMaxAngle;
+        }
+        public set SlurSlopeMaxAngle(value: number) {
+            this.slurSlopeMaxAngle = value;
+        }
+        public get SlurTangentMinAngle(): number {
+            return this.slurTangentMinAngle;
+        }
+        public set SlurTangentMinAngle(value: number) {
+            this.slurTangentMinAngle = value;
+        }
+        public get SlurTangentMaxAngle(): number {
+            return this.slurTangentMaxAngle;
+        }
+        public set SlurTangentMaxAngle(value: number) {
+            this.slurTangentMaxAngle = value;
+        }
+        public get SlursStartingAtSameStaffEntryYOffset(): number {
+            return this.slursStartingAtSameStaffEntryYOffset;
+        }
+        public set SlursStartingAtSameStaffEntryYOffset(value: number) {
+            this.slursStartingAtSameStaffEntryYOffset = value;
+        }
+        public get InstantaniousTempoTextHeight(): number {
+            return this.instantaniousTempoTextHeight;
+        }
+        public set InstantaniousTempoTextHeight(value: number) {
+            this.instantaniousTempoTextHeight = value;
+        }
+        public get ContinuousDynamicTextHeight(): number {
+            return this.continuousDynamicTextHeight;
+        }
+        public set ContinuousDynamicTextHeight(value: number) {
+            this.continuousDynamicTextHeight = value;
+        }
+        public get MoodTextHeight(): number {
+            return this.moodTextHeight;
+        }
+        public set MoodTextHeight(value: number) {
+            this.moodTextHeight = value;
+        }
+        public get ContinuousTempoTextHeight(): number {
+            return this.continuousTempoTextHeight;
+        }
+        public set ContinuousTempoTextHeight(value: number) {
+            this.continuousTempoTextHeight = value;
+        }
+        public get UnknownTextHeight(): number {
+            return this.unknownTextHeight;
+        }
+        public set UnknownTextHeight(value: number) {
+            this.unknownTextHeight = value;
+        }
+        public get StaffLineWidth(): number {
+            return this.staffLineWidth;
+        }
+        public set StaffLineWidth(value: number) {
+            this.staffLineWidth = value;
+        }
+        public get LedgerLineWidth(): number {
+            return this.ledgerLineWidth;
+        }
+        public set LedgerLineWidth(value: number) {
+            this.ledgerLineWidth = value;
+        }
+        public get WedgeLineWidth(): number {
+            return this.wedgeLineWidth;
+        }
+        public set WedgeLineWidth(value: number) {
+            this.wedgeLineWidth = value;
+        }
+        public get TupletLineWidth(): number {
+            return this.tupletLineWidth;
+        }
+        public set TupletLineWidth(value: number) {
+            this.tupletLineWidth = value;
+        }
+        public get LyricUnderscoreLineWidth(): number {
+            return this.lyricUnderscoreLineWidth;
+        }
+        public set LyricUnderscoreLineWidth(value: number) {
+            this.lyricUnderscoreLineWidth = value;
+        }
+        public get SystemThinLineWidth(): number {
+            return this.systemThinLineWidth;
+        }
+        public set SystemThinLineWidth(value: number) {
+            this.systemThinLineWidth = value;
+        }
+        public get SystemBoldLineWidth(): number {
+            return this.systemBoldLineWidth;
+        }
+        public set SystemBoldLineWidth(value: number) {
+            this.systemBoldLineWidth = value;
+        }
+        public get SystemRepetitionEndingLineWidth(): number {
+            return this.systemRepetitionEndingLineWidth;
+        }
+        public set SystemRepetitionEndingLineWidth(value: number) {
+            this.systemRepetitionEndingLineWidth = value;
+        }
+        public get SystemDotWidth(): number {
+            return this.systemDotWidth;
+        }
+        public set SystemDotWidth(value: number) {
+            this.systemDotWidth = value;
+        }
+        public get DistanceBetweenVerticalSystemLines(): number {
+            return this.distanceBetweenVerticalSystemLines;
+        }
+        public set DistanceBetweenVerticalSystemLines(value: number) {
+            this.distanceBetweenVerticalSystemLines = value;
+        }
+        public get DistanceBetweenDotAndLine(): number {
+            return this.distanceBetweenDotAndLine;
+        }
+        public set DistanceBetweenDotAndLine(value: number) {
+            this.distanceBetweenDotAndLine = value;
+        }
+        public get OctaveShiftLineWidth(): number {
+            return this.octaveShiftLineWidth;
+        }
+        public set OctaveShiftLineWidth(value: number) {
+            this.octaveShiftLineWidth = value;
+        }
+        public get OctaveShiftVerticalLineLength(): number {
+            return this.octaveShiftVerticalLineLength;
+        }
+        public set OctaveShiftVerticalLineLength(value: number) {
+            this.octaveShiftVerticalLineLength = value;
+        }
+        public get GraceLineWidth(): number {
+            return this.graceLineWidth;
+        }
+        public set GraceLineWidth(value: number) {
+            this.graceLineWidth = value;
+        }
+        public get MinimumStaffLineDistance(): number {
+            return this.minimumStaffLineDistance;
+        }
+        public set MinimumStaffLineDistance(value: number) {
+            this.minimumStaffLineDistance = value;
+        }
+        public get MinimumCrossedBeamDifferenceMargin(): number {
+            return this.minimumCrossedBeamDifferenceMargin;
+        }
+        public set MinimumCrossedBeamDifferenceMargin(value: number) {
+            this.minimumCrossedBeamDifferenceMargin = value;
+        }
+        public get DisplacedNoteMargin(): number {
+            return this.displacedNoteMargin;
+        }
+        public set DisplacedNoteMargin(value: number) {
+            this.displacedNoteMargin = value;
+        }
+        public get MinNoteDistance(): number {
+            return this.minNoteDistance;
+        }
+        public set MinNoteDistance(value: number) {
+            this.minNoteDistance = value;
+        }
+        public get SubMeasureXSpacingThreshold(): number {
+            return this.subMeasureXSpacingThreshold;
+        }
+        public set SubMeasureXSpacingThreshold(value: number) {
+            this.subMeasureXSpacingThreshold = value;
+        }
+        public get MeasureDynamicsMaxScalingFactor(): number {
+            return this.measureDynamicsMaxScalingFactor;
+        }
+        public set MeasureDynamicsMaxScalingFactor(value: number) {
+            this.measureDynamicsMaxScalingFactor = value;
+        }
+        public get MaxInstructionsConstValue(): number {
+            return this.maxInstructionsConstValue;
+        }
+        public set MaxInstructionsConstValue(value: number) {
+            this.maxInstructionsConstValue = value;
+        }
+        public get NoteDistances(): number[] {
+            return this.noteDistances;
+        }
+        public set NoteDistances(value: number[]) {
+            this.noteDistances = value;
+        }
+        public get NoteDistancesScalingFactors(): number[] {
+            return this.noteDistancesScalingFactors;
+        }
+        public set NoteDistancesScalingFactors(value: number[]) {
+            this.noteDistancesScalingFactors = value;
+        }
+        public get DurationDistanceDict(): Dictionary<number, number> {
+            return this.durationDistanceDict;
+        }
+        public get DurationScalingDistanceDict(): Dictionary<number, number> {
+            return this.durationScalingDistanceDict;
+        }
+        private populateDictionaries(): void {
+            for (var i: number = 0; i < this.noteDistances.length; i++) {
+                switch (i) {
+                    case 0:
+                        this.durationDistanceDict.Add(0.015625, this.noteDistances[i]);
+                        this.durationScalingDistanceDict.Add(0.015625, this.noteDistancesScalingFactors[i]);
+                        break;
+                    case 1:
+                        this.durationDistanceDict.Add(0.03125, this.noteDistances[i]);
+                        this.durationScalingDistanceDict.Add(0.03125, this.noteDistancesScalingFactors[i]);
+                        break;
+                    case 2:
+                        this.durationDistanceDict.Add(0.0625, this.noteDistances[i]);
+                        this.durationScalingDistanceDict.Add(0.0625, this.noteDistancesScalingFactors[i]);
+                        break;
+                    case 3:
+                        this.durationDistanceDict.Add(0.125, this.noteDistances[i]);
+                        this.durationScalingDistanceDict.Add(0.125, this.noteDistancesScalingFactors[i]);
+                        break;
+                    case 4:
+                        this.durationDistanceDict.Add(0.25, this.noteDistances[i]);
+                        this.durationScalingDistanceDict.Add(0.25, this.noteDistancesScalingFactors[i]);
+                        break;
+                    case 5:
+                        this.durationDistanceDict.Add(0.5, this.noteDistances[i]);
+                        this.durationScalingDistanceDict.Add(0.5, this.noteDistancesScalingFactors[i]);
+                        break;
+                    case 6:
+                        this.durationDistanceDict.Add(1.0, this.noteDistances[i]);
+                        this.durationScalingDistanceDict.Add(1.0, this.noteDistancesScalingFactors[i]);
+                        break;
+                    case 7:
+                        this.durationDistanceDict.Add(2.0, this.noteDistances[i]);
+                        this.durationScalingDistanceDict.Add(2.0, this.noteDistancesScalingFactors[i]);
+                        break;
+                }
+            }
+        }
+        private calculateCurveParametersArrays(): void {
+            this.tPower3 = new Array(this.bezierCurveStepSize);
+            this.oneMinusTPower3 = new Array(this.bezierCurveStepSize);
+            this.factorOne = 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);
+            }
+        }
+    }
+}

+ 92 - 0
src/MusicalScore/Graphical/GraphicalLabel.ts

@@ -0,0 +1,92 @@
+import {Label} from "../Label";
+import {TextAlignment} from "../../Common/Enums/TextAlignment";
+module PhonicScore.MusicalScore.Graphical.Primitives {
+    export class GraphicalLabel extends Clickable {
+        private label: Label;
+        constructor(label: Label, textHeight: number, alignment: TextAlignment) {
+            this.label = label;
+            this.boundingBox = new BoundingBox(this);
+            this.label.FontHeight = textHeight;
+            this.label.TextAlignment = alignment;
+        }
+        constructor(label: Label, textHeight: number, alignment: TextAlignment, parent: BoundingBox) {
+            this.label = label;
+            this.boundingBox = new BoundingBox(parent, this);
+            this.label.FontHeight = textHeight;
+            this.label.TextAlignment = alignment;
+        }
+        public get Label(): Label {
+            return this.label;
+        }
+        public setLabelPositionAndShapeBorders(): void {
+            if (this.Label.Text.Trim().Equals(String.Empty))
+                return
+            var 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 = PositionAndShape;
+            switch (this.Label.TextAlignment) {
+                case TextAlignment.CenterBottom:
+                    psi.BorderTop = -height;
+                    psi.BorderLeft = -width / 2;
+                    psi.BorderBottom = 0;
+                    psi.BorderRight = width / 2;
+                    break;
+                case TextAlignment.CenterCenter:
+                    psi.BorderTop = -height / 2;
+                    psi.BorderLeft = -width / 2;
+                    psi.BorderBottom = height / 2;
+                    psi.BorderRight = width / 2;
+                    break;
+                case TextAlignment.CenterTop:
+                    psi.BorderTop = 0;
+                    psi.BorderLeft = -width / 2;
+                    psi.BorderBottom = height;
+                    psi.BorderRight = width / 2;
+                    break;
+                case TextAlignment.LeftBottom:
+                    psi.BorderTop = -height;
+                    psi.BorderLeft = 0;
+                    psi.BorderBottom = 0;
+                    psi.BorderRight = width;
+                    break;
+                case TextAlignment.LeftCenter:
+                    psi.BorderTop = -height / 2;
+                    psi.BorderLeft = 0;
+                    psi.BorderBottom = height / 2;
+                    psi.BorderRight = width;
+                    break;
+                case TextAlignment.LeftTop:
+                    psi.BorderTop = 0;
+                    psi.BorderLeft = 0;
+                    psi.BorderBottom = height;
+                    psi.BorderRight = width;
+                    break;
+                case TextAlignment.RightBottom:
+                    psi.BorderTop = -height;
+                    psi.BorderLeft = -width;
+                    psi.BorderBottom = 0;
+                    psi.BorderRight = 0;
+                    break;
+                case TextAlignment.RightCenter:
+                    psi.BorderTop = -height / 2;
+                    psi.BorderLeft = -width;
+                    psi.BorderBottom = height / 2;
+                    psi.BorderRight = 0;
+                    break;
+                case TextAlignment.RightTop:
+                    psi.BorderTop = 0;
+                    psi.BorderLeft = -width;
+                    psi.BorderBottom = height;
+                    psi.BorderRight = 0;
+                    break;
+            }
+            psi.BorderMarginTop = psi.BorderTop - height * labelMarginBorderFactor;
+            psi.BorderMarginLeft = psi.BorderLeft - height * labelMarginBorderFactor;
+            psi.BorderMarginBottom = psi.BorderBottom + height * labelMarginBorderFactor;
+            psi.BorderMarginRight = psi.BorderRight + height * labelMarginBorderFactor;
+        }
+    }
+}

+ 32 - 0
src/MusicalScore/Graphical/GraphicalLine.ts

@@ -0,0 +1,32 @@
+import PointF_2D = PhonicScore.Common.DataObjects.PointF_2D;
+import {OutlineAndFillStyleEnum} from "./DrawingEnums";
+export class GraphicalLine {
+    private start: PointF_2D;
+    private end: PointF_2D;
+    private width: number;
+    constructor(start: PointF_2D, end: PointF_2D, width: number = 0, styleEnum: OutlineAndFillStyleEnum = OutlineAndFillStyleEnum.BaseWritingColor) {
+        this.start = start;
+        this.end = end;
+        this.width = width;
+        this.StyleId = <number>styleEnum;
+    }
+    public StyleId: number;
+    public get Start(): PointF_2D {
+        return this.start;
+    }
+    public set Start(value: PointF_2D) {
+        this.start = value;
+    }
+    public get End(): PointF_2D {
+        return this.end;
+    }
+    public set End(value: PointF_2D) {
+        this.end = value;
+    }
+    public get Width(): number {
+        return this.width;
+    }
+    public set Width(value: number) {
+        this.width = value;
+    }
+}

+ 57 - 0
src/MusicalScore/Graphical/GraphicalMusicPage.ts

@@ -0,0 +1,57 @@
+import {BoundingBox} from "./BoundingBox";
+module PhonicScore.MusicalScore.Graphical.SheetData {
+    import GraphicalLabel = PhonicScore.MusicalScore.Graphical.Primitives.GraphicalLabel;
+    import PointF_2D = PhonicScore.Common.DataObjects.PointF_2D;
+    export class GraphicalMusicPage extends GraphicalObject {
+        private musicSystems: List<MusicSystem> = new List<MusicSystem>();
+        private labels: List<GraphicalLabel> = new List<GraphicalLabel>();
+        private parent: GraphicalMusicSheet;
+        constructor(parent: GraphicalMusicSheet) {
+            this.parent = parent;
+            this.boundingBox = new BoundingBox(null, this);
+        }
+        public get MusicSystems(): List<MusicSystem> {
+            return this.musicSystems;
+        }
+        public set MusicSystems(value: List<MusicSystem>) {
+            this.musicSystems = value;
+        }
+        public get Labels(): List<GraphicalLabel> {
+            return this.labels;
+        }
+        public set Labels(value: List<GraphicalLabel>) {
+            this.labels = value;
+        }
+        public get Parent(): GraphicalMusicSheet {
+            return this.parent;
+        }
+        public set Parent(value: GraphicalMusicSheet) {
+            this.parent = value;
+        }
+        public setMusicPageAbsolutePosition(pageIndex: number, rules: EngravingRules): PointF_2D {
+            if (rules.PagePlacement == PagePlacementEnum.Down)
+                return new PointF_2D(0.0f, pageIndex * rules.PageHeight);
+            else if (rules.PagePlacement == PagePlacementEnum.Right)
+                return new PointF_2D(pageIndex * this.parent.ParentMusicSheet.PageWidth, 0.0f);
+            else {
+                if (pageIndex % 2 == 0) {
+                    if (pageIndex == 0)
+                        return new PointF_2D(0.0f, pageIndex * rules.PageHeight);
+                    else return new PointF_2D(0.0f, (pageIndex - 1) * rules.PageHeight);
+                }
+                else {
+                    if (pageIndex == 1)
+                        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);
+                }
+            }
+        }
+    }
+    export enum PagePlacementEnum {
+        Down,
+
+        Right,
+
+        RightDown
+    }
+}

+ 31 - 0
src/MusicalScore/Graphical/GraphicalNote.ts

@@ -0,0 +1,31 @@
+import {Note} from "../VoiceData/Note";
+import {Fraction} from "../../Common/DataObjects/fraction";
+import {KeyInstruction} from "../VoiceData/Instructions/KeyInstruction";
+import {ClefInstruction} from "../VoiceData/Instructions/ClefInstruction";
+import {OctaveEnum} from "../VoiceData/Expressions/ContinuousExpressions/octaveShift";
+import {Pitch} from "../../Common/DataObjects/pitch";
+module PhonicScore.MusicalScore.Graphical.SheetData {
+    export class GraphicalNote extends GraphicalObject {
+        constructor(note: Note, parent: GraphicalStaffEntry) {
+            this.SourceNote = note;
+            this.ParentStaffEntry = parent;
+        }
+        public SourceNote: Note;
+        public GraphicalNoteLength: Fraction;
+        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))
+                    return graphicalNotes;
+            }
+            return null;
+        }
+        public Transpose(keyInstruction: KeyInstruction, activeClef: ClefInstruction, halfTones: number, octaveEnum: OctaveEnum): Pitch {
+            var transposedPitch: Pitch = this.SourceNote.Pitch;
+            if (MusicSheetCalculator.TransposeCalculator != null)
+                transposedPitch = MusicSheetCalculator.TransposeCalculator.TransposePitch(this.SourceNote.Pitch, keyInstruction, halfTones);
+            return transposedPitch;
+        }
+    }
+}

+ 12 - 0
src/MusicalScore/Graphical/GraphicalObject.ts

@@ -0,0 +1,12 @@
+import {BoundingBox} from "./BoundingBox";
+module PhonicScore.MusicalScore.Graphical {
+    export class GraphicalObject {
+        protected boundingBox: BoundingBox;
+        public get PositionAndShape(): BoundingBox {
+            return this.boundingBox;
+        }
+        public set PositionAndShape(value: BoundingBox) {
+            this.boundingBox = value;
+        }
+    }
+}

+ 243 - 0
src/MusicalScore/Graphical/MusicSystem.ts

@@ -0,0 +1,243 @@
+import {StaffLine} from "./StaffLine";
+import {Instrument} from "../Instrument";
+import {BoundingBox} from "./BoundingBox";
+import {Fraction} from "../../Common/DataObjects/fraction";
+import {SourceMeasure} from "../VoiceData/SourceMeasure";
+import {InstrumentalGroup} from "../InstrumentalGroup";
+import {TextAlignment} from "../../Common/Enums/TextAlignment";
+module PhonicScore.MusicalScore.Graphical.SheetData {
+    export class MusicSystem extends GraphicalObject {
+        public NeedsToBeRedrawn: boolean = true;
+        protected parent: GraphicalMusicPage;
+        protected id: number;
+        protected staffLines: List<StaffLine> = new List<StaffLine>();
+        protected graphicalMeasures: List<List<StaffMeasure>> = new List<List<StaffMeasure>>();
+        protected labels: Dictionary<GraphicalLabel, Instrument> = new Dictionary<GraphicalLabel, Instrument>();
+        protected measureNumberLabels: List<GraphicalLabel> = new List<GraphicalLabel>();
+        protected maxLabelLength: number;
+        protected objectsToRedraw: List<Tuple<List<Object>, Object>> = new List<Tuple<List<Object>, Object>>();
+        constructor(parent: GraphicalMusicPage, id: number) {
+            this.parent = parent;
+            this.id = id;
+            this.boundingBox = new BoundingBox(parent.PositionAndShape, this);
+            this.maxLabelLength = 0.0f;
+        }
+        public get Parent(): GraphicalMusicPage {
+            return this.parent;
+        }
+        public set Parent(value: GraphicalMusicPage) {
+            this.parent = value;
+        }
+        public get StaffLines(): List<StaffLine> {
+            return this.staffLines;
+        }
+        public get GraphicalMeasures(): List<List<StaffMeasure>> {
+            return this.graphicalMeasures;
+        }
+        public get MeasureNumberLabels(): List<GraphicalLabel> {
+            return this.measureNumberLabels;
+        }
+        public get Labels(): List<GraphicalLabel> {
+            return this.labels.Keys.ToList();
+        }
+        public get ObjectsToRedraw(): List<Tuple<List<Object>, Object>> {
+            return this.objectsToRedraw;
+        }
+        public get Id(): number {
+            return this.id;
+        }
+        public createSystemLeftVerticalLineObject(lineWidth: number, systemLabelsRightMargin: number): void { throw new Error('not implemented'); }
+        public createVerticalLineForMeasure(position: number, lineType: SystemLinesEnum, lineWidth: number,
+            index: number): void { throw new Error('not implemented'); }
+        public setYPositionsToVerticalLineObjectsAndCreateLines(rules: EngravingRules): void { throw new Error('not implemented'); }
+        public calculateBorders(rules: EngravingRules): void {
+
+        }
+        public alignBeginInstructions(): void {
+
+        }
+        public GetLeftBorderAbsoluteXPosition(): number {
+            return this.StaffLines[0].PositionAndShape.AbsolutePosition.X + this.StaffLines[0].Measures[0].BeginInstructionsWidth;
+        }
+        public GetRightBorderAbsoluteXPosition(): number {
+            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];
+                graphicalMeasure.ParentMusicSystem = this;
+            }
+            this.graphicalMeasures.Add(graphicalMeasures);
+        }
+        public GetSystemsFirstTimeStamp(): Fraction {
+            return this.graphicalMeasures[0][0].ParentSourceMeasure.AbsoluteTimestamp;
+        }
+        public GetSystemsLastTimeStamp(): Fraction {
+            var m: SourceMeasure = this.graphicalMeasures[this.graphicalMeasures.Count - 1][0].ParentSourceMeasure;
+            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])
+                            firstStaffLine = staffLine;
+                        if (staffLine.ParentStaff == instrument.Staves[instrument.Staves.Count - 1])
+                            lastStaffLine = staffLine;
+                    }
+                    if (firstStaffLine != null && lastStaffLine != null) {
+                        var rightUpper: PointF_2D = new PointF_2D(firstStaffLine.PositionAndShape.RelativePosition.X,
+                            firstStaffLine.PositionAndShape.RelativePosition.Y);
+                        var rightLower: PointF_2D = new PointF_2D(lastStaffLine.PositionAndShape.RelativePosition.X,
+                            lastStaffLine.PositionAndShape.RelativePosition.Y + staffHeight);
+                        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)
+                    continue;
+                var instrument1: Instrument = this.findFirstVisibleInstrumentInInstrumentalGroup(instrumentGroup);
+                var instrument2: Instrument = this.findLastVisibleInstrumentInInstrumentalGroup(instrumentGroup);
+                if (instrument1 == null || instrument2 == null)
+                    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])
+                        firstStaffLine = staffLine;
+                    if (staffLine.ParentStaff == instrument2.Staves.Last())
+                        lastStaffLine = staffLine;
+                }
+                if (firstStaffLine != null && lastStaffLine != null) {
+                    var rightUpper: PointF_2D = new PointF_2D(firstStaffLine.PositionAndShape.RelativePosition.X,
+                        firstStaffLine.PositionAndShape.RelativePosition.Y);
+                    var rightLower: PointF_2D = new PointF_2D(lastStaffLine.PositionAndShape.RelativePosition.X,
+                        lastStaffLine.PositionAndShape.RelativePosition.Y + staffHeight);
+                    this.createGroupBracket(rightUpper, rightLower, staffHeight, recursionDepth);
+                }
+                if (instrumentGroup.InstrumentalGroups.Count < 1)
+                    continue;
+                createGroupBrackets(instrumentGroup.InstrumentalGroups, staffHeight, recursionDepth + 1);
+            }
+        }
+        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);
+                    graphicalLabel.setLabelPositionAndShapeBorders();
+                    this.labels.Add(graphicalLabel, instrument);
+                    this.boundingBox.ChildElements.Add(graphicalLabel.PositionAndShape);
+                    graphicalLabel.PositionAndShape.RelativePosition = new PointF_2D(0.0, 0.0);
+                }
+                this.maxLabelLength = 0.0f;
+                var labels: GraphicalLabel[] = this.labels.Keys.ToArray();
+                for (var idx: number = 0, len = labels.length; idx < len; ++idx) {
+                    var label: GraphicalLabel = labels[idx];
+                    if (label.PositionAndShape.Size.Width > this.maxLabelLength)
+                        this.maxLabelLength = label.PositionAndShape.Size.Width;
+                }
+                this.updateMusicSystemStaffLineXPosition(systemLabelsRightMargin);
+            }
+        }
+        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)
+                                    break;
+                                ypositionSum += staffLine.PositionAndShape.RelativePosition.Y;
+                                staffCounter++;
+                            }
+                            break;
+                        }
+                    }
+                    if (staffCounter > 0)
+                        entry.Key.PositionAndShape.RelativePosition = new PointF_2D(0.0, ypositionSum / staffCounter + 2.0);
+                }
+            }
+        }
+        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)
+                            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)
+                            second = true;
+                    }
+                }
+            }
+            if (first && second)
+                return true;
+            return false;
+        }
+        protected calcInstrumentsBracketsWidth(): number { throw new Error('not implemented'); }
+        protected createInstrumentBracket(rightUpper: PointF_2D, rightLower: PointF_2D): void { throw new Error('not implemented'); }
+        protected createGroupBracket(rightUpper: PointF_2D, rightLower: PointF_2D, staffHeight: number,
+            recursionDepth: number): void { throw new Error('not implemented'); }
+        private findFirstVisibleInstrumentInInstrumentalGroup(instrumentalGroup: InstrumentalGroup): Instrument {
+            for (var idx: number = 0, len = instrumentalGroup.InstrumentalGroups.Count; idx < len; ++idx) {
+                var groupOrInstrument: InstrumentalGroup = instrumentalGroup.InstrumentalGroups[idx];
+                if (groupOrInstrument instanceof Instrument) {
+                    if ((<Instrument>groupOrInstrument).Visible == true)
+                        return <Instrument>groupOrInstrument;
+                    continue;
+                }
+                return this.findFirstVisibleInstrumentInInstrumentalGroup(groupOrInstrument);
+            }
+            return null;
+        }
+        private findLastVisibleInstrumentInInstrumentalGroup(instrumentalGroup: InstrumentalGroup): Instrument {
+            var groupOrInstrument: InstrumentalGroup;
+            for (var i: number = instrumentalGroup.InstrumentalGroups.Count - 1; i >= 0; i--) {
+                groupOrInstrument = instrumentalGroup.InstrumentalGroups[i];
+                if (groupOrInstrument instanceof Instrument) {
+                    if ((<Instrument>groupOrInstrument).Visible == true)
+                        return <Instrument>groupOrInstrument;
+                    continue;
+                }
+                return this.findLastVisibleInstrumentInInstrumentalGroup(groupOrInstrument);
+            }
+            return null;
+        }
+        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;
+                relative.X = this.maxLabelLength + systemLabelsRightMargin;
+                staffLine.PositionAndShape.RelativePosition = relative;
+                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);
+                    staffLine.StaffLines[i].End = lineEnd;
+                }
+            }
+        }
+    }
+}

+ 1 - 0
src/MusicalScore/Graphical/OctaveShiftParams.ts

@@ -0,0 +1 @@
+

+ 78 - 0
src/MusicalScore/Graphical/StaffLine.ts

@@ -0,0 +1,78 @@
+import {Staff} from "../VoiceData/Staff";
+import {BoundingBox} from "./BoundingBox";
+import {Instrument} from "../Instrument";
+import GraphicalObject = PhonicScore.MusicalScore.Graphical.GraphicalObject;
+import StaffMeasure = PhonicScore.MusicalScore.Graphical.SheetData.StaffMeasure;
+import MusicSystem = PhonicScore.MusicalScore.Graphical.SheetData.MusicSystem;
+import {GraphicalLine} from "./GraphicalLine";
+export class StaffLine extends GraphicalObject {
+    protected measures: List<StaffMeasure> = new List<StaffMeasure>();
+    protected staffLines: GraphicalLine[] = new Array(5);
+    protected parentMusicSystem: MusicSystem;
+    protected parentStaff: Staff;
+    protected skyLine: number[];
+    protected bottomLine: number[];
+    constructor(parentSystem: MusicSystem, parentStaff: Staff) {
+        this.parentMusicSystem = parentSystem;
+        this.parentStaff = parentStaff;
+        this.boundingBox = new BoundingBox(parentSystem.PositionAndShape, this);
+    }
+    public get Measures(): List<StaffMeasure> {
+        return this.measures;
+    }
+    public set Measures(value: List<StaffMeasure>) {
+        this.measures = value;
+    }
+    public get StaffLines(): GraphicalLine[] {
+        return this.staffLines;
+    }
+    public set StaffLines(value: GraphicalLine[]) {
+        this.staffLines = value;
+    }
+    public get ParentMusicSystem(): MusicSystem {
+        return this.parentMusicSystem;
+    }
+    public set ParentMusicSystem(value: MusicSystem) {
+        this.parentMusicSystem = value;
+    }
+    public get ParentStaff(): Staff {
+        return this.parentStaff;
+    }
+    public set ParentStaff(value: Staff) {
+        this.parentStaff = value;
+    }
+    public get SkyLine(): number[] {
+        return this.skyLine;
+    }
+    public set SkyLine(value: number[]) {
+        this.skyLine = value;
+    }
+    public get BottomLine(): number[] {
+        return this.bottomLine;
+    }
+    public set BottomLine(value: number[]) {
+        this.bottomLine = value;
+    }
+    public isPartOfMultiStaffInstrument(): boolean {
+        var instrument: Instrument = this.parentStaff.ParentInstrument;
+        if (instrument.Staves.Count > 1)
+            return true;
+        return false;
+    }
+    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.0f)
+                {
+                    difference = Math.Abs(graphicalStaffEntry.PositionAndShape.RelativePosition.X - xPosition + graphicalMeasure.PositionAndShape.RelativePosition.X);
+                    closestStaffentry = graphicalStaffEntry;
+                }
+            }
+        }
+        return closestStaffentry;
+    }
+}

+ 179 - 0
src/MusicalScore/Graphical/StaffMeasure.ts

@@ -0,0 +1,179 @@
+module PhonicScore.MusicalScore.Graphical.SheetData {
+    export class StaffMeasure extends GraphicalObject {
+        protected firstInstructionStaffEntry: GraphicalStaffEntry;
+        protected lastInstructionStaffEntry: GraphicalStaffEntry;
+        private staff: Staff;
+        private measureNumber: number = -1;
+        private parentStaffLine: StaffLine;
+        constructor(staff: Staff, parentSourceMeasure: SourceMeasure) {
+            this.staff = staff;
+            this.ParentSourceMeasure = parentSourceMeasure;
+            this.StaffEntries = new List<GraphicalStaffEntry>();
+            if (this.ParentSourceMeasure != null)
+                this.measureNumber = this.ParentSourceMeasure.MeasureNumber;
+        }
+        constructor(staffLine: StaffLine) {
+            this.parentStaffLine = staffLine;
+            this.staff = staffLine.ParentStaff;
+            this.StaffEntries = new List<GraphicalStaffEntry>();
+        }
+        public ParentSourceMeasure: SourceMeasure;
+        public StaffEntries: List<GraphicalStaffEntry>;
+        public ParentMusicSystem: MusicSystem;
+        public BeginInstructionsWidth: number;
+        public MinimumStaffEntriesWidth: number;
+        public StaffEntriesScaleFactor: number;
+        public EndInstructionsWidth: number;
+        public hasError: boolean;
+        public get ParentStaff(): Staff {
+            return this.staff;
+        }
+        public get MeasureNumber(): number {
+            return this.measureNumber;
+        }
+        public get FirstInstructionStaffEntry(): GraphicalStaffEntry {
+            return this.firstInstructionStaffEntry;
+        }
+        public set FirstInstructionStaffEntry(value: GraphicalStaffEntry) {
+            this.firstInstructionStaffEntry = value;
+        }
+        public get LastInstructionStaffEntry(): GraphicalStaffEntry {
+            return this.lastInstructionStaffEntry;
+        }
+        public set LastInstructionStaffEntry(value: GraphicalStaffEntry) {
+            this.lastInstructionStaffEntry = value;
+        }
+        public get ParentStaffLine(): StaffLine {
+            return this.parentStaffLine;
+        }
+        public set ParentStaffLine(value: StaffLine) {
+            this.parentStaffLine = value;
+            if (this.parentStaffLine != null)
+                PositionAndShape.Parent = this.parentStaffLine.PositionAndShape;
+        }
+        public ResetLayout(): void { throw new Error('not implemented'); }
+        public GetLineWidth(line: SystemLinesEnum): number { throw new Error('not implemented'); }
+        public AddClefAtBegin(clef: ClefInstruction): void { throw new Error('not implemented'); }
+        public AddKeyAtBegin(currentKey: KeyInstruction, previousKey: KeyInstruction, currentClef: ClefInstruction): void { throw new Error('not implemented'); }
+        public AddRhythmAtBegin(rhythm: RhythmInstruction): void { throw new Error('not implemented'); }
+        public AddClefAtEnd(clef: ClefInstruction): void { throw new Error('not implemented'); }
+        public SetPositionInStaffline(xPos: 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 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)
+                    return graphicalStaffEntry;
+            }
+            return null;
+        }
+        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)
+                    return graphicalStaffEntry;
+            }
+            return null;
+        }
+        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());
+            }
+            return duration == this.ParentSourceMeasure.Duration;
+        }
+        public hasMultipleVoices(): boolean {
+            if (this.StaffEntries.Count == 0)
+                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);
+                }
+            }
+            if (voices.Count > 1)
+                return true;
+            return false;
+        }
+        public isVisible(): boolean {
+            return this.ParentStaff.ParentInstrument.Visible;
+        }
+        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);
+                }
+            }
+            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);
+                    }
+                }
+                if (voiceDuration > duration)
+                    duration = new Fraction(voiceDuration);
+            }
+            return duration;
+        }
+        public addGraphicalStaffEntry(graphicalStaffEntry: GraphicalStaffEntry): void {
+            this.StaffEntries.Add(graphicalStaffEntry);
+            PositionAndShape.ChildElements.Add(graphicalStaffEntry.PositionAndShape);
+        }
+        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);
+                else {
+                    for (var i: number = this.StaffEntries.Count - 1; i >= 0; i--) {
+                        if (this.StaffEntries[i].RelInMeasureTimestamp < staffEntry.RelInMeasureTimestamp) {
+                            this.StaffEntries.Insert(i + 1, staffEntry);
+                            break;
+                        }
+                        if (i == 0)
+                            this.StaffEntries.Insert(i, staffEntry);
+                    }
+                }
+                PositionAndShape.ChildElements.Add(staffEntry.PositionAndShape);
+            }
+        }
+        public beginsWithLineRepetition(): boolean {
+            var sourceMeasure: SourceMeasure = this.ParentSourceMeasure;
+            if (sourceMeasure == null)
+                return false;
+            return sourceMeasure.beginsWithLineRepetition();
+        }
+        public endsWithLineRepetition(): boolean {
+            var sourceMeasure: SourceMeasure = this.ParentSourceMeasure;
+            if (sourceMeasure == null)
+                return false;
+            return sourceMeasure.endsWithLineRepetition();
+        }
+        public beginsWithWordRepetition(): boolean {
+            var sourceMeasure: SourceMeasure = this.ParentSourceMeasure;
+            if (sourceMeasure == null)
+                return false;
+            return sourceMeasure.beginsWithWordRepetition();
+        }
+        public endsWithWordRepetition(): boolean {
+            var sourceMeasure: SourceMeasure = this.ParentSourceMeasure;
+            if (sourceMeasure == null)
+                return false;
+            return sourceMeasure.endsWithWordRepetition();
+        }
+    }
+}

+ 46 - 0
src/MusicalScore/Graphical/VerticalGraphicalStaffEntryContainer.ts

@@ -0,0 +1,46 @@
+import {Fraction} from "../../Common/DataObjects/fraction";
+export class VerticalGraphicalStaffEntryContainer {
+    private index: number;
+    private absoluteTimestamp: Fraction;
+    private staffEntries: List<GraphicalStaffEntry> = new List<GraphicalStaffEntry>();
+    constructor(numberOfEntries: number, absoluteTimestamp: Fraction) {
+        this.absoluteTimestamp = absoluteTimestamp;
+        for (var i: number = 0; i < numberOfEntries; i++)
+            this.staffEntries.Add(null);
+    }
+    public RelativeInMeasureTimestamp: Fraction;
+    public get Index(): number {
+        return this.index;
+    }
+    public set Index(value: number) {
+        this.index = value;
+    }
+    public get AbsoluteTimestamp(): Fraction {
+        return this.absoluteTimestamp;
+    }
+    public set AbsoluteTimestamp(value: Fraction) {
+        this.absoluteTimestamp = value;
+    }
+    public get StaffEntries(): List<GraphicalStaffEntry> {
+        return this.staffEntries;
+    }
+    public set StaffEntries(value: List<GraphicalStaffEntry>) {
+        this.staffEntries = value;
+    }
+    public getFirstNonNullStaffEntry(): GraphicalStaffEntry {
+        for (var idx: number = 0, len = this.staffEntries.Count; idx < len; ++idx) {
+            var graphicalStaffEntry: GraphicalStaffEntry = this.staffEntries[idx];
+            if (graphicalStaffEntry != null)
+                return graphicalStaffEntry;
+        }
+        return null;
+    }
+}
+export module VerticalGraphicalStaffEntryContainer {
+    export class VgseContainerTimestampComparer implements IComparer<VerticalGraphicalStaffEntryContainer>
+    {
+        public Compare(x: VerticalGraphicalStaffEntryContainer, y: VerticalGraphicalStaffEntryContainer): number {
+            return Comparer.Default.Compare(x.AbsoluteTimestamp.RealValue, y.AbsoluteTimestamp.RealValue);
+        }
+    }
+}

+ 13 - 13
src/MusicalScore/Label.ts

@@ -1,11 +1,11 @@
-import {OSMDTextAlignment} from "../Common/Enums/osmdTextAlignment";
+import {TextAlignment} from "../Common/Enums/TextAlignment";
 import {OSMDColor} from "../Common/DataObjects/osmdColor";
-import {OSMDFonts} from "../Common/Enums/osmdFonts";
-import {OSMDFontStyles} from "../Common/Enums/osmdFontStyles";
+import {Fonts} from "../Common/Enums/Fonts";
+import {FontStyles} from "../Common/Enums/FontStyles";
 
 export class Label {
     // FIXME contructor
-    constructor(arg1: string/*|FontInfo.MusicFontSymbol*/, alignment?: OSMDTextAlignment) {
+    constructor(arg1: string/*|FontInfo.MusicFontSymbol*/, alignment?: TextAlignment) {
       //if (arg1 instanceof string) {
       this.text = <string>arg1;
       //} else if (arg1 instanceof FontInfo.MusicFontSymbol) {
@@ -20,9 +20,9 @@ export class Label {
 
     private text: string; // FIXME:
     private color: OSMDColor = OSMDColor.Black;
-    private font: OSMDFonts = OSMDFonts.TimesNewRoman;
-    private fontStyle: OSMDFontStyles = OSMDFontStyles.Regular;
-    private textAlignment: OSMDTextAlignment = OSMDTextAlignment.LeftBottom;
+    private font: Fonts = Fonts.TimesNewRoman;
+    private fontStyle: FontStyles = FontStyles.Regular;
+    private textAlignment: TextAlignment = TextAlignment.LeftBottom;
     private fontHeight: number = 2;
 
     public get Text(): string {
@@ -37,16 +37,16 @@ export class Label {
     public set Color(value: OSMDColor) {
         this.color = value;
     }
-    public get Font(): OSMDFonts {
+    public get Font(): Fonts {
         return this.font;
     }
-    public set Font(value: OSMDFonts) {
+    public set Font(value: Fonts) {
         this.font = value;
     }
-    public get FontStyle(): OSMDFontStyles {
+    public get FontStyle(): FontStyles {
         return this.fontStyle;
     }
-    public set FontStyle(value: OSMDFontStyles) {
+    public set FontStyle(value: FontStyles) {
         this.fontStyle = value;
     }
     public get FontHeight(): number {
@@ -55,10 +55,10 @@ export class Label {
     public set FontHeight(value: number) {
         this.fontHeight = value;
     }
-    public get TextAlignment(): OSMDTextAlignment {
+    public get TextAlignment(): TextAlignment {
         return this.textAlignment;
     }
-    public set TextAlignment(value: OSMDTextAlignment) {
+    public set TextAlignment(value: TextAlignment) {
         this.textAlignment = value;
     }
     public ToString(): string {

+ 5 - 5
src/MusicalScore/VoiceData/Expressions/multiTempoExpression.ts

@@ -2,7 +2,7 @@ import {Fraction} from "../../../Common/DataObjects/fraction";
 import {SourceMeasure} from "../SourceMeasure";
 import {InstantaniousTempoExpression} from "./instantaniousTempoExpression";
 import {PlacementEnum} from "./abstractExpression";
-import {OSMDFontStyles} from "../../../Common/Enums/osmdFontStyles";
+import {FontStyles} from "../../../Common/Enums/FontStyles";
 import {AbstractTempoExpression} from "./abstractTempoExpression";
 import {ContinuousTempoExpression} from "./ContinuousExpressions/continuousTempoExpression";
 
@@ -57,12 +57,12 @@ export class MultiTempoExpression /*implements IComparable<MultiTempoExpression>
         }
         return placement;
     }
-    public getFontstyleOfFirstEntry(): OSMDFontStyles {
-        let fontStyle: OSMDFontStyles = OSMDFontStyles.Regular;
+    public getFontstyleOfFirstEntry(): FontStyles {
+        let fontStyle: FontStyles = FontStyles.Regular;
         if (this.expressions[0].expression instanceof InstantaniousTempoExpression) {
-            fontStyle = OSMDFontStyles.Bold;
+            fontStyle = FontStyles.Bold;
         } else if (this.expressions[0].expression instanceof ContinuousTempoExpression) {
-            fontStyle = OSMDFontStyles.Italic;
+            fontStyle = FontStyles.Italic;
         }
         return fontStyle;
     }

+ 5 - 5
src/MusicalScore/VoiceData/Expressions/unknownExpression.ts

@@ -1,24 +1,24 @@
 import {PlacementEnum, AbstractExpression} from "./abstractExpression";
-import {OSMDTextAlignment} from "../../../Common/Enums/osmdTextAlignment";
+import {TextAlignment} from "../../../Common/Enums/TextAlignment";
 
 export class UnknownExpression extends AbstractExpression {
     //constructor(label: string, placementEnum: PlacementEnum, staffNumber: number) {
     //    this(label, placementEnum, OSMDTextAlignment.LeftBottom, staffNumber);
     //
     //}
-    constructor(label: string, placementEnum: PlacementEnum, textAlignment: OSMDTextAlignment, staffNumber: number) {
+    constructor(label: string, placementEnum: PlacementEnum, textAlignment: TextAlignment, staffNumber: number) {
         super();
         this.label = label;
         this.placement = placementEnum;
         this.staffNumber = staffNumber;
         if (textAlignment === undefined) {
-            textAlignment = OSMDTextAlignment.LeftBottom;
+            textAlignment = TextAlignment.LeftBottom;
         }
         this.textAlignment = textAlignment;
     }
     private label: string;
     private placement: PlacementEnum;
-    private textAlignment: OSMDTextAlignment;
+    private textAlignment: TextAlignment;
     private staffNumber: number;
 
     public get Label(): string {
@@ -36,7 +36,7 @@ export class UnknownExpression extends AbstractExpression {
     public set StaffNumber(value: number) {
         this.staffNumber = value;
     }
-    public get TextAlignment(): OSMDTextAlignment {
+    public get TextAlignment(): TextAlignment {
         return this.textAlignment;
     }
 }