all files / pdfviewer/annotation/ measure-annotation.js

5.34% Statements 61/1142
0.24% Branches 2/830
4.62% Functions 3/65
5.37% Lines 61/1136
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 19791×                     1×   1× 1× 1×   1×   1× 1× 1×               1×             1×                                                                                                                                                                                                                                                                                                                                                                                                                                                   1×                   1×                                                                                                                                                                         1×                                                                                                                                                                 1×                                                                                                                         1×                                     1×                                     1×                                     1×                                     1×                                         1×                         1×                       1×                                                                                                                                             1×                                                                                                                                                                                                                       1×                                                                           1×                                                                 1×     1×       1×     1×         1×                   1×                                                                                                                                   1×                           1×                   1×                                                                                               1×                                                                             1×                   1×     1×                                         1×     1×                                                                                                                                                                                                                                         1×             1×                     1×                                 1×                                         1×                                                       1×                 1×                                                                         1×                                 1×                                                                       1×       1×                                                           1×                                                                       1×                                                           1×                 1×                             1×                                                                                                                         1×                                                                                                                                           1×                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         1×   1×    
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
define(["require", "exports", "@syncfusion/ej2-inputs", "@syncfusion/ej2-base", "@syncfusion/ej2-popups", "@syncfusion/ej2-splitbuttons", "@syncfusion/ej2-drawings"], function (require, exports, ej2_inputs_1, ej2_base_1, ej2_popups_1, ej2_splitbuttons_1, ej2_drawings_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var MeasurementScaleRatio = (function () {
        function MeasurementScaleRatio() {
        }
        return MeasurementScaleRatio;
    }());
    exports.MeasurementScaleRatio = MeasurementScaleRatio;
    var MeasureAnnotation = (function () {
        function MeasureAnnotation(pdfviewer, pdfViewerBase) {
            this.measureShapeCount = 0;
            this.isAddAnnotationProgramatically = false;
            this.scaleRatioCollection = [];
            this.scaleRatioAddCollection = [];
            this.pdfViewer = pdfviewer;
            this.pdfViewerBase = pdfViewerBase;
        }
        Object.defineProperty(MeasureAnnotation.prototype, "pixelToPointFactor", {
            get: function () {
                return (72 / 96);
            },
            enumerable: true,
            configurable: true
        });
        MeasureAnnotation.prototype.renderMeasureShapeAnnotations = function (shapeAnnotations, pageNumber, isImportAction, isAnnotOrderAction) {
            if (shapeAnnotations) {
                if (shapeAnnotations.length >= 1) {
                    var measureAnnots = this.pdfViewer.annotation.getStoredAnnotations(pageNumber, shapeAnnotations, '_annotations_shape_measure');
                    if (!measureAnnots || isImportAction || isAnnotOrderAction) {
                        var _loop_1 = function (i) {
                            var annotation = shapeAnnotations[parseInt(i.toString(), 10)];
                            var annotationObject = null;
                            this_1.measureShapeCount = this_1.measureShapeCount + 1;
                            annotation.annotationAddMode = this_1.pdfViewer.annotationModule.
                                findAnnotationMode(annotation, pageNumber, annotation.AnnotType);
                            var isAnnotationRotated = void 0;
                            if (annotation.ShapeAnnotationType) {
                                if (isImportAction) {
                                    if (this_1.pdfViewerBase.isJsonImported) {
                                        annotation.Bounds = this_1.pdfViewerBase.
                                            importJsonForRotatedDocuments(annotation.Rotate, pageNumber, annotation.Bounds, annotation.AnnotationRotation);
                                        isAnnotationRotated = this_1.pdfViewerBase.isPageRotated;
                                    }
                                }
                                var vertexPoints = null;
                                if (annotation.VertexPoints) {
                                    vertexPoints = [];
                                    if (isImportAction && this_1.pdfViewerBase.isJsonImported) {
                                        vertexPoints = this_1.pdfViewerBase.
                                            calculateVertexPoints(annotation.Rotate, pageNumber, annotation.VertexPoints, annotation.AnnotationRotation);
                                    }
                                    else {
                                        for (var j = 0; j < annotation.VertexPoints.length; j++) {
                                            var x = annotation.VertexPoints[parseInt(j.toString(), 10)].X ?
                                                annotation.VertexPoints[parseInt(j.toString(), 10)].X :
                                                annotation.VertexPoints[parseInt(j.toString(), 10)].x;
                                            var y = annotation.VertexPoints[parseInt(j.toString(), 10)].Y ?
                                                annotation.VertexPoints[parseInt(j.toString(), 10)].Y :
                                                annotation.VertexPoints[parseInt(j.toString(), 10)].y;
                                            var point = { x: x, y: y };
                                            vertexPoints.push(point);
                                        }
                                    }
                                }
                                if (annotation.Bounds && annotation.EnableShapeLabel === true) {
                                    annotation.LabelBounds = this_1.pdfViewer.annotationModule.
                                        inputElementModule.calculateLabelBoundsFromLoadedDocument(annotation.Bounds);
                                    annotation.LabelBorderColor = annotation.LabelBorderColor ?
                                        annotation.LabelBorderColor : annotation.StrokeColor;
                                    annotation.FontColor = annotation.FontColor ? annotation.FontColor : annotation.StrokeColor;
                                    annotation.LabelFillColor = annotation.LabelFillColor ? annotation.LabelFillColor : annotation.FillColor;
                                    annotation.FontSize = annotation.FontSize ? annotation.FontSize : 16;
                                    annotation.LabelSettings = annotation.LabelSettings ? annotation.LabelSettings :
                                        this_1.pdfViewer.shapeLabelSettings;
                                }
                                annotation.AnnotationSettings = annotation.AnnotationSettings ? annotation.AnnotationSettings :
                                    this_1.pdfViewer.annotationModule.updateAnnotationSettings(annotation);
                                if (annotation.IsLocked) {
                                    annotation.AnnotationSettings.isLock = annotation.IsLocked;
                                }
                                annotation.allowedInteractions = annotation.AllowedInteractions ? annotation.AllowedInteractions :
                                    this_1.pdfViewer.annotationModule.updateAnnotationAllowedInteractions(annotation);
                                var isPrint = annotation.IsPrint;
                                var measureObject = {
                                    ratio: annotation.Calibrate.Ratio, x: this_1.getNumberFormatArray(annotation.Calibrate.X),
                                    distance: this_1.getNumberFormatArray(annotation.Calibrate.Distance),
                                    area: this_1.getNumberFormatArray(annotation.Calibrate.Area),
                                    angle: this_1.getNumberFormatArray(annotation.Calibrate.Angle),
                                    volume: this_1.getNumberFormatArray(annotation.Calibrate.Volume),
                                    targetUnitConversion: annotation.Calibrate.TargetUnitConversion
                                };
                                if (annotation.Calibrate.Depth) {
                                    measureObject.depth = annotation.Calibrate.Depth;
                                }
                                var left = annotation.Bounds.X ? annotation.Bounds.X : annotation.Bounds.x;
                                var top_1 = annotation.Bounds.Y ? annotation.Bounds.Y : annotation.Bounds.y;
                                var width = annotation.Bounds.Width ? annotation.Bounds.Width : annotation.Bounds.width;
                                var height = annotation.Bounds.Height ? annotation.Bounds.Height : annotation.Bounds.height;
                                annotationObject = {
                                    id: 'measure' + this_1.measureShapeCount, shapeAnnotationType: annotation.ShapeAnnotationType, author: annotation.Author, allowedInteractions: annotation.allowedInteractions, modifiedDate: annotation.ModifiedDate, subject: annotation.Subject,
                                    note: annotation.Note, strokeColor: annotation.StrokeColor, fillColor: annotation.FillColor,
                                    opacity: annotation.Opacity, thickness: annotation.Thickness,
                                    rectangleDifference: annotation.RectangleDifference,
                                    borderStyle: annotation.BorderStyle, borderDashArray: annotation.BorderDashArray,
                                    rotateAngle: annotation.RotateAngle, isCloudShape: annotation.IsCloudShape,
                                    cloudIntensity: annotation.CloudIntensity, vertexPoints: vertexPoints,
                                    lineHeadStart: annotation.LineHeadStart, lineHeadEnd: annotation.LineHeadEnd,
                                    isLocked: annotation.IsLocked, pageNumber: pageNumber,
                                    bounds: { left: left, top: top_1, width: width, height: height, right: annotation.Bounds.Right,
                                        bottom: annotation.Bounds.Bottom },
                                    caption: annotation.Caption, captionPosition: annotation.CaptionPosition, calibrate: measureObject,
                                    leaderLength: annotation.LeaderLength, leaderLineExtension: annotation.LeaderLineExtension,
                                    leaderLineOffset: annotation.LeaderLineOffset, indent: annotation.Indent,
                                    annotName: annotation.AnnotName, comments: this_1.pdfViewer.annotationModule.
                                        getAnnotationComments(annotation.Comments, annotation, annotation.Author),
                                    review: { state: annotation.State, stateModel: annotation.StateModel,
                                        modifiedDate: annotation.ModifiedDate, author: annotation.Author },
                                    labelContent: annotation.LabelContent, enableShapeLabel: annotation.EnableShapeLabel,
                                    labelFillColor: annotation.LabelFillColor,
                                    fontColor: annotation.FontColor, labelBorderColor: annotation.LabelBorderColor,
                                    fontSize: annotation.FontSize,
                                    labelBounds: annotation.LabelBounds, annotationSelectorSettings: this_1.getSettings(annotation),
                                    labelSettings: annotation.LabelSettings, annotationSettings: annotation.AnnotationSettings,
                                    customData: this_1.pdfViewer.annotation.getCustomData(annotation),
                                    isPrint: annotation.IsPrint, isCommentLock: annotation.IsCommentLock,
                                    isAnnotationRotated: isAnnotationRotated,
                                    originalName: annotation.OriginalName ? annotation.OriginalName : null
                                };
                                var vPoints = annotationObject.vertexPoints;
                                if (vertexPoints == null) {
                                    vPoints = [];
                                }
                                var annotationSelectorSettings = typeof (annotation.AnnotationSelectorSettings) === 'string' ? JSON.parse(annotation.AnnotationSelectorSettings) : annotation.AnnotationSelectorSettings;
                                if (ej2_base_1.isNullOrUndefined(annotation.AnnotationSelectorSettings)) {
                                    this_1.pdfViewerBase.annotationSelectorSettingLoad(annotation);
                                }
                                else {
                                    annotation.AnnotationSelectorSettings = annotationSelectorSettings;
                                }
                                annotation.allowedInteractions = annotation.AllowedInteractions ?
                                    annotation.AllowedInteractions : this_1.pdfViewer.annotationModule.
                                    updateAnnotationAllowedInteractions(annotation);
                                var annot_1 = {
                                    id: 'measure' + this_1.measureShapeCount, shapeAnnotationType: this_1.getShapeType(annotationObject), author: annotationObject.author, allowedInteractions: annotation.allowedInteractions, modifiedDate: annotationObject.modifiedDate,
                                    subject: annotationObject.subject, notes: annotationObject.note, fillColor: annotationObject.fillColor,
                                    strokeColor: annotationObject.strokeColor, opacity: annotationObject.opacity,
                                    thickness: annotationObject.thickness, borderStyle: annotationObject.borderStyle, borderDashArray: annotationObject.borderDashArray.toString(), rotateAngle: parseFloat(annotationObject.rotateAngle.split('Angle')[1]),
                                    isCloudShape: annotationObject.isCloudShape, cloudIntensity: annotationObject.cloudIntensity,
                                    taregetDecoraterShapes: this_1.pdfViewer.annotation.getArrowType(annotationObject.lineHeadEnd),
                                    sourceDecoraterShapes: this_1.pdfViewer.annotation.getArrowType(annotationObject.lineHeadStart),
                                    vertexPoints: vPoints, bounds: { x: annotationObject.bounds.left, y: annotationObject.bounds.top,
                                        width: annotationObject.bounds.width, height: annotationObject.bounds.height },
                                    leaderHeight: annotationObject.leaderLength, pageIndex: pageNumber,
                                    annotName: annotationObject.annotName, comments: annotationObject.comments,
                                    review: annotationObject.review,
                                    measureType: this_1.getMeasureType(annotationObject),
                                    labelContent: annotation.LabelContent, enableShapeLabel: annotation.EnableShapeLabel,
                                    labelFillColor: annotation.LabelFillColor,
                                    fontColor: annotation.FontColor, labelBorderColor: annotation.LabelBorderColor,
                                    fontSize: annotation.FontSize,
                                    labelBounds: annotation.LabelBounds, annotationSelectorSettings: annotation.AnnotationSelectorSettings,
                                    annotationSettings: annotationObject.annotationSettings, annotationAddMode: annotation.annotationAddMode,
                                    isPrint: isPrint, isCommentLock: annotationObject.isCommentLock, customData: annotationObject.customData
                                };
                                if (this_1.scaleRatioCollection) {
                                    var matchedScaleRatio = this_1.scaleRatioCollection.find(function (item) { return item.annotName === annot_1.annotName; });
                                    if (matchedScaleRatio && matchedScaleRatio.id === undefined) {
                                        matchedScaleRatio.id = annot_1.id;
                                    }
                                }
                                this_1.pdfViewer.annotation.storeAnnotations(pageNumber, annotationObject, '_annotations_shape_measure');
                                this_1.pdfViewer.add(annot_1);
                                if (this_1.isAddAnnotationProgramatically) {
                                    var settings = {
                                        opacity: annot_1.opacity, strokeColor: annot_1.strokeColor, thickness: annot_1.thickness,
                                        modifiedDate: annot_1.modifiedDate,
                                        width: annot_1.bounds.width, height: annot_1.bounds.height
                                    };
                                    this_1.pdfViewer.fireAnnotationAdd(annot_1.pageIndex, annot_1.annotName, annotation.ShapeAnnotationType, annot_1.bounds, settings);
                                }
                            }
                        };
                        var this_1 = this;
                        for (var i = 0; i < shapeAnnotations.length; i++) {
                            _loop_1(i);
                        }
                    }
                }
                else if (shapeAnnotations.shapeAnnotationType) {
                    var annotationObject = this.createAnnotationObject(shapeAnnotations);
                    this.updateScaleRatioCollection();
                    var measureSettings = this.pdfViewer.measurementSettings;
                    if (measureSettings.conversionUnit !== 'in' || measureSettings.displayUnit !== 'in' || measureSettings.scaleRatio !== 1) {
                        var ratioString = annotationObject.calibrate.ratio.split('=').map(function (ratioString) { return ratioString.trim(); });
                        var _a = ratioString[0].split(' '), srcValueStr = _a[0], unit = _a[1];
                        var _b = ratioString[1].split(' '), destValueStr = _b[0], displayUnit = _b[1];
                        var destValue = parseFloat(destValueStr);
                        var depthValue = measureSettings.depth ? measureSettings.depth : 96;
                        var srcValue = parseFloat(srcValueStr);
                        var scaleRatio = {
                            annotName: annotationObject.annotName,
                            displayUnit: displayUnit,
                            unit: unit,
                            ratio: destValue / srcValue,
                            destValue: destValue,
                            srcValue: srcValue,
                            volumeDepth: depthValue,
                            depthValue: depthValue,
                            ratioString: ratioString
                        };
                        this.scaleRatioCollection.push(scaleRatio);
                    }
                    else if (!ej2_base_1.isNullOrUndefined(this.measureRatioObject)) {
                        this.measureRatioObject['id'] = annotationObject.id;
                        this.measureRatioObject['annotName'] = annotationObject.annotName;
                        this.scaleRatioCollection.push(__assign({}, this.measureRatioObject));
                    }
                    else {
                        var srcValue = (this.sourceTextBox && this.sourceTextBox.value) ? this.sourceTextBox.value : 1;
                        var destValue = (this.destTextBox && this.destTextBox.value) ? this.destTextBox.value : 1;
                        this.measureRatioObject = {
                            id: annotationObject.id,
                            annotName: annotationObject.annotName,
                            displayUnit: this.displayUnit,
                            unit: this.unit,
                            depthValue: this.volumeDepth,
                            volumeDepth: this.volumeDepth,
                            ratioString: srcValue + ' ' + this.unit + ' = ' + destValue + ' ' + this.displayUnit,
                            ratio: destValue / srcValue
                        };
                        this.scaleRatioCollection.push(__assign({}, this.measureRatioObject));
                        this.scaleRatioAddCollection.push(__assign({}, this.measureRatioObject));
                    }
                    this.pdfViewer.annotationModule.isFormFieldShape = false;
                    this.pdfViewer.annotationModule.storeAnnotations(pageNumber, annotationObject, '_annotations_shape_measure');
                    if (shapeAnnotations) {
                        shapeAnnotations.customData = annotationObject.customData;
                    }
                    this.pdfViewer.annotationModule.triggerAnnotationAdd(shapeAnnotations);
                }
            }
        };
        MeasureAnnotation.prototype.getSettings = function (annotation) {
            var selector = this.pdfViewer.annotationSelectorSettings;
            if (annotation.AnnotationSelectorSettings) {
                selector = typeof (annotation.AnnotationSelectorSettings) === 'string' ? JSON.parse(annotation.AnnotationSelectorSettings) : annotation.AnnotationSelectorSettings;
            }
            else {
                selector = this.getSelector(annotation.Subject);
            }
            return selector;
        };
        MeasureAnnotation.prototype.setAnnotationType = function (type) {
            var author = 'Guest';
            var subject = '';
            var customData;
            this.updateMeasureproperties();
            this.pdfViewerBase.disableTextSelectionMode();
            switch (type) {
                case 'Distance': {
                    this.currentAnnotationMode = 'Distance';
                    var modifiedDateDist = this.pdfViewer.annotation.stickyNotesAnnotationModule.getDateAndTime();
                    author = (this.pdfViewer.annotationSettings.author !== 'Guest') ? this.pdfViewer.annotationSettings.author : this.pdfViewer.distanceSettings.author ? this.pdfViewer.distanceSettings.author : 'Guest';
                    subject = (this.pdfViewer.annotationSettings.subject !== '' && !ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSettings.subject)) ? this.pdfViewer.annotationSettings.subject : this.pdfViewer.distanceSettings.subject ? this.pdfViewer.distanceSettings.subject : 'Distance calculation';
                    customData = !ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSettings.customData) ?
                        this.pdfViewer.annotationSettings.customData : this.pdfViewer.distanceSettings.customData ?
                        this.pdfViewer.distanceSettings.customData : null;
                    this.pdfViewer.drawingObject = {
                        sourceDecoraterShapes: this.pdfViewer.annotation.getArrowType(this.distanceStartHead),
                        taregetDecoraterShapes: this.pdfViewer.annotation.getArrowType(this.distanceEndHead), measureType: 'Distance',
                        fillColor: this.distanceFillColor, notes: '', strokeColor: this.distanceStrokeColor, leaderHeight: this.leaderLength,
                        opacity: this.distanceOpacity, thickness: this.distanceThickness, borderDashArray: this.distanceDashArray.toString(),
                        shapeAnnotationType: 'Distance', author: author, subject: subject, isCommentLock: false, customData: customData
                    };
                    this.pdfViewer.tool = 'Distance';
                    break;
                }
                case 'Perimeter': {
                    this.currentAnnotationMode = 'Perimeter';
                    var modifiedDatePeri = this.pdfViewer.annotation.stickyNotesAnnotationModule.getDateAndTime();
                    author = (this.pdfViewer.annotationSettings.author !== 'Guest') ? this.pdfViewer.annotationSettings.author : this.pdfViewer.perimeterSettings.author ? this.pdfViewer.perimeterSettings.author : 'Guest';
                    subject = (this.pdfViewer.annotationSettings.subject !== '' && !ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSettings.subject)) ? this.pdfViewer.annotationSettings.subject : this.pdfViewer.perimeterSettings.subject ? this.pdfViewer.perimeterSettings.subject : 'Perimeter calculation';
                    this.pdfViewer.drawingObject = {
                        shapeAnnotationType: 'LineWidthArrowHead', fillColor: this.perimeterFillColor, notes: '', strokeColor: this.perimeterStrokeColor, opacity: this.perimeterOpacity,
                        thickness: this.perimeterThickness, sourceDecoraterShapes: this.pdfViewer.annotation.getArrowType(this.perimeterStartHead),
                        taregetDecoraterShapes: this.pdfViewer.annotation.getArrowType(this.perimeterEndHead), measureType: 'Perimeter', borderDashArray: this.perimeterDashArray.toString(),
                        author: author, subject: subject, isCommentLock: false, customData: customData
                    };
                    this.pdfViewer.tool = 'Perimeter';
                    break;
                }
                case 'Area': {
                    this.currentAnnotationMode = 'Area';
                    var modifiedDateArea = this.pdfViewer.annotation.stickyNotesAnnotationModule.getDateAndTime();
                    author = (this.pdfViewer.annotationSettings.author !== 'Guest') ? this.pdfViewer.annotationSettings.author : this.pdfViewer.areaSettings.author ? this.pdfViewer.areaSettings.author : 'Guest';
                    subject = (this.pdfViewer.annotationSettings.subject !== '' && !ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSettings.subject)) ? this.pdfViewer.annotationSettings.subject : this.pdfViewer.areaSettings.subject ? this.pdfViewer.areaSettings.subject : 'Area calculation';
                    this.pdfViewer.drawingObject = {
                        shapeAnnotationType: 'Polygon', fillColor: this.areaFillColor, notes: '', strokeColor: this.areaStrokeColor,
                        thickness: this.areaThickness, opacity: this.areaOpacity, measureType: 'Area',
                        modifiedDate: modifiedDateArea, borderStyle: '', borderDashArray: '0',
                        author: author, subject: subject, isCommentLock: false, customData: customData
                    };
                    this.pdfViewer.tool = 'Polygon';
                    break;
                }
                case 'Radius': {
                    this.currentAnnotationMode = 'Radius';
                    var modifiedDateRad = this.pdfViewer.annotation.stickyNotesAnnotationModule.getDateAndTime();
                    author = (this.pdfViewer.annotationSettings.author !== 'Guest') ? this.pdfViewer.annotationSettings.author : this.pdfViewer.radiusSettings.author ? this.pdfViewer.radiusSettings.author : 'Guest';
                    subject = (this.pdfViewer.annotationSettings.subject !== '' && !ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSettings.subject)) ? this.pdfViewer.annotationSettings.subject : this.pdfViewer.radiusSettings.subject ? this.pdfViewer.radiusSettings.subject : 'Radius calculation';
                    customData = !ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSettings.customData) ?
                        this.pdfViewer.annotationSettings.customData : this.pdfViewer.radiusSettings.customData ?
                        this.pdfViewer.radiusSettings.customData : null;
                    this.pdfViewer.drawingObject = {
                        shapeAnnotationType: 'Radius', fillColor: this.radiusFillColor, notes: '', strokeColor: this.radiusStrokeColor, opacity: this.radiusOpacity,
                        thickness: this.radiusThickness, measureType: 'Radius', modifiedDate: modifiedDateRad, borderStyle: '', borderDashArray: '0',
                        author: author, subject: subject, isCommentLock: false, customData: customData
                    };
                    this.pdfViewer.tool = 'DrawTool';
                    break;
                }
                case 'Volume': {
                    this.currentAnnotationMode = 'Volume';
                    var modifiedDateVol = this.pdfViewer.annotation.stickyNotesAnnotationModule.getDateAndTime();
                    author = (this.pdfViewer.annotationSettings.author !== 'Guest') ? this.pdfViewer.annotationSettings.author : this.pdfViewer.volumeSettings.author ? this.pdfViewer.volumeSettings.author : 'Guest';
                    subject = (this.pdfViewer.annotationSettings.subject !== '' && !ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSettings.subject)) ? this.pdfViewer.annotationSettings.subject : this.pdfViewer.volumeSettings.subject ? this.pdfViewer.volumeSettings.subject : 'Volume calculation';
                    this.pdfViewer.drawingObject = {
                        shapeAnnotationType: 'Polygon', notes: '', fillColor: this.volumeFillColor, strokeColor: this.volumeStrokeColor,
                        opacity: this.volumeOpacity, thickness: this.volumeThickness, measureType: 'Volume',
                        modifiedDate: modifiedDateVol, borderStyle: '', borderDashArray: '0',
                        author: author, subject: subject, isCommentLock: false, customData: customData
                    };
                    this.pdfViewer.tool = 'Polygon';
                    break;
                }
            }
        };
        MeasureAnnotation.prototype.updateMeasureproperties = function () {
            this.distanceFillColor = this.pdfViewer.distanceSettings.fillColor ? this.pdfViewer.distanceSettings.fillColor : '#ffffff00';
            this.distanceStrokeColor = this.pdfViewer.distanceSettings.strokeColor ? this.pdfViewer.distanceSettings.strokeColor : '#ff0000';
            this.distanceOpacity = this.pdfViewer.distanceSettings.opacity ? this.pdfViewer.distanceSettings.opacity : 1;
            this.distanceThickness = this.pdfViewer.distanceSettings.thickness ? this.pdfViewer.distanceSettings.thickness : 1;
            this.distanceDashArray = this.pdfViewer.distanceSettings.borderDashArray ? this.pdfViewer.distanceSettings.borderDashArray : 0;
            this.leaderLength = this.pdfViewer.distanceSettings.leaderLength != null ? this.pdfViewer.distanceSettings.leaderLength : 40;
            this.distanceStartHead = this.pdfViewer.distanceSettings.lineHeadStartStyle ? this.pdfViewer.distanceSettings.lineHeadStartStyle : 'Closed';
            this.distanceEndHead = this.pdfViewer.distanceSettings.lineHeadEndStyle ? this.pdfViewer.distanceSettings.lineHeadEndStyle : 'Closed';
            this.perimeterFillColor = this.pdfViewer.perimeterSettings.fillColor ? this.pdfViewer.perimeterSettings.fillColor : '#ffffff00';
            this.perimeterStrokeColor = this.pdfViewer.perimeterSettings.strokeColor ? this.pdfViewer.perimeterSettings.strokeColor : '#ff0000';
            this.perimeterOpacity = this.pdfViewer.perimeterSettings.opacity ? this.pdfViewer.perimeterSettings.opacity : 1;
            this.perimeterThickness = this.pdfViewer.perimeterSettings.thickness ? this.pdfViewer.perimeterSettings.thickness : 1;
            this.perimeterDashArray = this.pdfViewer.perimeterSettings.borderDashArray ? this.pdfViewer.perimeterSettings.borderDashArray : 0;
            this.perimeterStartHead = this.pdfViewer.perimeterSettings.lineHeadStartStyle ? this.pdfViewer.perimeterSettings.lineHeadStartStyle : 'Open';
            this.perimeterEndHead = this.pdfViewer.perimeterSettings.lineHeadEndStyle ? this.pdfViewer.perimeterSettings.lineHeadEndStyle : 'Open';
            this.areaFillColor = this.pdfViewer.areaSettings.fillColor ? this.pdfViewer.areaSettings.fillColor : '#ffffff00';
            this.areaStrokeColor = this.pdfViewer.areaSettings.strokeColor ? this.pdfViewer.areaSettings.strokeColor : '#ff0000';
            this.areaOpacity = this.pdfViewer.areaSettings.opacity ? this.pdfViewer.areaSettings.opacity : 1;
            this.areaThickness = this.pdfViewer.areaSettings.thickness ? this.pdfViewer.areaSettings.thickness : 1;
            this.radiusFillColor = this.pdfViewer.radiusSettings.fillColor ? this.pdfViewer.radiusSettings.fillColor : '#ffffff00';
            this.radiusStrokeColor = this.pdfViewer.radiusSettings.strokeColor ? this.pdfViewer.radiusSettings.strokeColor : '#ff0000';
            this.radiusOpacity = this.pdfViewer.radiusSettings.opacity ? this.pdfViewer.radiusSettings.opacity : 1;
            this.radiusThickness = this.pdfViewer.radiusSettings.thickness ? this.pdfViewer.radiusSettings.thickness : 1;
            this.volumeFillColor = this.pdfViewer.volumeSettings.fillColor ? this.pdfViewer.volumeSettings.fillColor : '#ffffff00';
            this.volumeStrokeColor = this.pdfViewer.volumeSettings.strokeColor ? this.pdfViewer.volumeSettings.strokeColor : '#ff0000';
            this.volumeOpacity = this.pdfViewer.volumeSettings.opacity ? this.pdfViewer.volumeSettings.opacity : 1;
            this.volumeThickness = this.pdfViewer.volumeSettings.thickness ? this.pdfViewer.volumeSettings.thickness : 1;
            var scaleRatioObject = this.scaleRatioAddCollection[this.scaleRatioAddCollection.length - 1];
            if (this.currentScaleRatio && this.currentScaleRatio.unit !== this.pdfViewer.measurementSettings.conversionUnit.toLowerCase()) {
                this.unit = this.currentScaleRatio.unit;
            }
            else if (this.pdfViewer.measurementSettings.conversionUnit.toLowerCase() !== 'in') {
                this.unit = this.pdfViewer.measurementSettings.conversionUnit.toLowerCase();
            }
            else if (scaleRatioObject) {
                this.unit = scaleRatioObject.unit;
            }
            else {
                this.unit = this.pdfViewer.measurementSettings.conversionUnit.toLowerCase();
            }
            if (this.currentScaleRatio && this.currentScaleRatio.displayUnit !==
                this.pdfViewer.measurementSettings.conversionUnit.toLowerCase()) {
                this.displayUnit = this.currentScaleRatio.displayUnit;
            }
            else if (this.pdfViewer.measurementSettings.displayUnit.toLowerCase() !== 'in') {
                this.displayUnit = this.pdfViewer.measurementSettings.displayUnit.toLowerCase();
            }
            else if (scaleRatioObject) {
                this.displayUnit = scaleRatioObject.displayUnit;
            }
            else {
                this.displayUnit = this.pdfViewer.measurementSettings.displayUnit.toLowerCase();
            }
            if (this.currentScaleRatio && this.currentScaleRatio.ratio !== this.pdfViewer.measurementSettings.scaleRatio) {
                this.ratio = this.currentScaleRatio.ratio;
            }
            else if (this.pdfViewer.measurementSettings.scaleRatio !== 1) {
                this.ratio = this.pdfViewer.measurementSettings.scaleRatio;
            }
            else if (scaleRatioObject) {
                this.ratio = scaleRatioObject.ratio;
            }
            else if (ej2_base_1.isNullOrUndefined(this.ratio) || this.ratio === this.pdfViewer.measurementSettings.scaleRatio) {
                this.ratio = this.pdfViewer.measurementSettings.scaleRatio;
            }
            if (this.currentScaleRatio && this.currentScaleRatio.volumeDepth !== this.pdfViewer.measurementSettings.depth) {
                this.volumeDepth = this.currentScaleRatio.volumeDepth;
            }
            else if (this.pdfViewer.measurementSettings.scaleRatio !== 1) {
                this.volumeDepth = this.pdfViewer.measurementSettings.depth;
            }
            else if (scaleRatioObject) {
                this.volumeDepth = scaleRatioObject.volumeDepth;
            }
            else {
                this.volumeDepth = this.pdfViewer.measurementSettings.depth ? this.pdfViewer.measurementSettings.depth : 96;
            }
            this.scaleRatioString = '1 ' + this.unit + ' = ' + this.ratio.toString() + ' ' + this.displayUnit;
            this.currentScaleRatio = null;
        };
        MeasureAnnotation.prototype.createAnnotationObject = function (annotationModel) {
            var bound;
            var labelBound;
            var annotationName = this.pdfViewer.annotation.createGUID();
            var commentsDivid = this.pdfViewer.annotation.stickyNotesAnnotationModule.addComments('shape_measure', (annotationModel.pageIndex + 1), annotationModel.measureType);
            if (commentsDivid) {
                document.getElementById(commentsDivid).id = annotationName;
            }
            annotationModel.annotName = annotationName;
            annotationModel.author = annotationModel && annotationModel.author != 'Guest' ? annotationModel.author : this.pdfViewer.annotationModule.updateAnnotationAuthor('measure', annotationModel.subject);
            this.pdfViewer.annotation.stickyNotesAnnotationModule.addTextToComments(annotationName, annotationModel.notes);
            if (annotationModel.wrapper.bounds) {
                bound = {
                    left: annotationModel.wrapper.bounds.x, top: annotationModel.wrapper.bounds.y,
                    height: annotationModel.wrapper.bounds.height, width: annotationModel.wrapper.bounds.width,
                    right: annotationModel.wrapper.bounds.right, bottom: annotationModel.wrapper.bounds.bottom
                };
                labelBound = this.pdfViewer.annotationModule.inputElementModule.calculateLabelBounds(annotationModel.wrapper.bounds);
            }
            else {
                bound = { left: 0, top: 0, height: 0, width: 0, right: 0, bottom: 0 };
                labelBound = { left: 0, top: 0, height: 0, width: 0, right: 0, bottom: 0 };
            }
            var borderDashArray = parseInt(annotationModel.borderDashArray, 10);
            borderDashArray = isNaN(borderDashArray) ? 0 : borderDashArray;
            var measure = { ratio: this.scaleRatioString, x: [this.createNumberFormat('x')], distance: [this.createNumberFormat('d')], area: [this.createNumberFormat('a')] };
            if (annotationModel.measureType === 'Volume') {
                measure.depth = this.volumeDepth;
            }
            var annotationSettings = this.pdfViewer.annotationModule.findAnnotationSettings(annotationModel, true);
            var allowedInteractions = this.pdfViewer.annotationModule.updateAnnotationAllowedInteractions(annotationModel);
            annotationModel.isPrint = annotationSettings.isPrint;
            var setting = this.pdfViewer.shapeLabelSettings;
            var labelSettings = { borderColor: annotationModel.strokeColor, fillColor: annotationModel.fillColor,
                fontColor: annotationModel.fontColor, fontSize: annotationModel.fontSize, labelContent: annotationModel.labelContent,
                labelHeight: setting.labelHeight, labelWidth: setting.labelMaxWidth, opacity: annotationModel.opacity
            };
            return {
                id: annotationModel.id, shapeAnnotationType: this.getShapeAnnotType(annotationModel.measureType),
                author: annotationModel.author, allowedInteractions: allowedInteractions,
                subject: annotationModel.subject, note: annotationModel.notes, strokeColor: annotationModel.strokeColor,
                fillColor: annotationModel.fillColor, opacity: annotationModel.opacity, thickness: annotationModel.thickness,
                borderStyle: annotationModel.borderStyle, borderDashArray: borderDashArray, bounds: bound,
                modifiedDate: this.pdfViewer.annotation.stickyNotesAnnotationModule.getDateAndTime(),
                rotateAngle: 'RotateAngle' + annotationModel.rotateAngle, isCloudShape: annotationModel.isCloudShape, cloudIntensity: annotationModel.cloudIntensity,
                vertexPoints: annotationModel.vertexPoints, lineHeadStart: this.pdfViewer.annotation.
                    getArrowTypeForCollection(annotationModel.sourceDecoraterShapes),
                lineHeadEnd: this.pdfViewer.annotation.getArrowTypeForCollection(annotationModel.taregetDecoraterShapes),
                rectangleDifference: [], isLocked: annotationSettings.isLock,
                leaderLength: annotationModel.leaderHeight, leaderLineExtension: 2, leaderLineOffset: 0, calibrate: measure, caption: true, captionPosition: 'Top',
                indent: this.getIndent(annotationModel.measureType), annotName: annotationName, comments: [], review: { state: '', stateModel: '', modifiedDate: this.pdfViewer.annotation.stickyNotesAnnotationModule.getDateAndTime(), author: annotationModel.author },
                labelContent: annotationModel.labelContent, enableShapeLabel: annotationModel.enableShapeLabel,
                labelFillColor: annotationModel.labelFillColor,
                labelBorderColor: annotationModel.labelBorderColor, fontColor: annotationModel.fontColor, fontSize: annotationModel.fontSize,
                labelBounds: labelBound, annotationSelectorSettings: this.getSelector(annotationModel.subject),
                labelSettings: labelSettings, annotationSettings: annotationSettings,
                customData: this.pdfViewer.annotation.getMeasureData(annotationModel.subject), isPrint: annotationModel.isPrint,
                isCommentLock: annotationModel.isCommentLock, isAnnotationRotated: false,
                pageNumber: annotationModel.pageIndex
            };
        };
        MeasureAnnotation.prototype.getSelector = function (type) {
            var selector = this.pdfViewer.annotationSelectorSettings;
            if ((type === 'Distance calculation') && this.pdfViewer.distanceSettings.annotationSelectorSettings) {
                selector = this.pdfViewer.distanceSettings.annotationSelectorSettings;
            }
            else if ((type === 'Perimeter calculation') && this.pdfViewer.perimeterSettings.annotationSelectorSettings) {
                selector = this.pdfViewer.perimeterSettings.annotationSelectorSettings;
            }
            else if ((type === 'Area calculation') && this.pdfViewer.areaSettings.annotationSelectorSettings) {
                selector = this.pdfViewer.areaSettings.annotationSelectorSettings;
            }
            else if ((type === 'Radius calculation') && this.pdfViewer.radiusSettings.annotationSelectorSettings) {
                selector = this.pdfViewer.radiusSettings.annotationSelectorSettings;
            }
            else if ((type === 'Volume calculation') && this.pdfViewer.volumeSettings.annotationSelectorSettings) {
                selector = this.pdfViewer.volumeSettings.annotationSelectorSettings;
            }
            return selector;
        };
        MeasureAnnotation.prototype.getShapeAnnotType = function (measureType) {
            var annotationType;
            switch (measureType) {
                case 'Distance':
                    annotationType = 'Line';
                    break;
                case 'Perimeter':
                    annotationType = 'Polyline';
                    break;
                case 'Area':
                case 'Volume':
                    annotationType = 'Polygon';
                    break;
                case 'Radius':
                    annotationType = 'Circle';
                    break;
            }
            return annotationType;
        };
        MeasureAnnotation.prototype.getShapeType = function (shape) {
            var shapeType;
            if (shape.shapeAnnotationType === 'Line') {
                shapeType = 'Distance';
            }
            else if (shape.shapeAnnotationType === 'Polyline') {
                shapeType = 'LineWidthArrowHead';
            }
            else if (shape.shapeAnnotationType === 'Polygon' && shape.indent === 'PolygonDimension') {
                shapeType = 'Polygon';
            }
            else if ((shape.shapeAnnotationType === 'Polygon' && shape.indent === 'PolygonRadius') || shape.shapeAnnotationType === 'Circle') {
                shapeType = 'Radius';
            }
            else if (shape.shapeAnnotationType === 'Polygon' && shape.indent === 'PolygonVolume') {
                shapeType = 'Polygon';
            }
            return shapeType;
        };
        MeasureAnnotation.prototype.getMeasureType = function (shape) {
            var measureType;
            if (shape.shapeAnnotationType === 'Line') {
                measureType = 'Distance';
            }
            else if (shape.shapeAnnotationType === 'Polyline') {
                measureType = 'Perimeter';
            }
            else if (shape.shapeAnnotationType === 'Polygon' && shape.indent === 'PolygonDimension') {
                measureType = 'Area';
            }
            else if ((shape.shapeAnnotationType === 'Polygon' && shape.indent === 'PolygonRadius') || shape.shapeAnnotationType === 'Circle') {
                measureType = 'Radius';
            }
            else if (shape.shapeAnnotationType === 'Polygon' && shape.indent === 'PolygonVolume') {
                measureType = 'Volume';
            }
            return measureType;
        };
        MeasureAnnotation.prototype.getIndent = function (measureType) {
            var indent;
            switch (measureType) {
                case 'Distance':
                    indent = 'LineDimension';
                    break;
                case 'Perimeter':
                    indent = 'PolyLineDimension';
                    break;
                case 'Area':
                    indent = 'PolygonDimension';
                    break;
                case 'Radius':
                    indent = 'PolygonRadius';
                    break;
                case 'Volume':
                    indent = 'PolygonVolume';
                    break;
            }
            return indent;
        };
        MeasureAnnotation.prototype.getNumberFormatArray = function (list) {
            var numberFormatArray = [];
            if (list) {
                for (var i = 0; i < list.length; i++) {
                    numberFormatArray[parseInt(i.toString(), 10)] = { unit: list[parseInt(i.toString(), 10)].Unit,
                        fractionalType: list[parseInt(i.toString(), 10)].FractionalType,
                        conversionFactor: list[parseInt(i.toString(), 10)].ConversionFactor,
                        denominator: list[parseInt(i.toString(), 10)].Denominator,
                        formatDenominator: list[parseInt(i.toString(), 10)].FormatDenominator };
                }
            }
            return numberFormatArray;
        };
        MeasureAnnotation.prototype.createNumberFormat = function (type) {
            var cFactor = 1;
            var unit = this.displayUnit;
            if (type === 'x') {
                cFactor = this.getFactor(this.unit);
            }
            if (type === 'a') {
                unit = 'sq ' + this.displayUnit;
            }
            var numberFormat = { unit: unit, fractionalType: 'D', conversionFactor: cFactor, denominator: 100, formatDenominator: false };
            return numberFormat;
        };
        MeasureAnnotation.prototype.saveMeasureShapeAnnotations = function () {
            var storeObject = this.pdfViewer.annotationsCollection.get(this.pdfViewerBase.documentId + '_annotations_shape_measure');
            var annotations = [];
            for (var j = 0; j < this.pdfViewerBase.pageCount; j++) {
                annotations[parseInt(j.toString(), 10)] = [];
            }
            if (storeObject && !this.pdfViewer.annotationSettings.skipDownload) {
                var annotationCollection = JSON.parse(JSON.stringify(storeObject));
                for (var i = 0; i < annotationCollection.length; i++) {
                    var newArray = [];
                    var pageAnnotationObject = annotationCollection[parseInt(i.toString(), 10)];
                    if (pageAnnotationObject) {
                        for (var z = 0; pageAnnotationObject.annotations.length > z; z++) {
                            this.pdfViewer.annotationModule.updateModifiedDate(pageAnnotationObject.annotations[parseInt(z.toString(), 10)]);
                            if (this.pdfViewerBase.isJsonExported) {
                                if (pageAnnotationObject.annotations[parseInt(z.toString(), 10)].isAnnotationRotated) {
                                    pageAnnotationObject.annotations[parseInt(z.toString(), 10)].bounds =
                                        this.pdfViewer.annotation.getBounds(pageAnnotationObject.
                                            annotations[parseInt(z.toString(), 10)].bounds, pageAnnotationObject.pageIndex);
                                    pageAnnotationObject.annotations[parseInt(z.toString(), 10)].vertexPoints =
                                        this.pdfViewer.annotation.getVertexPoints(pageAnnotationObject.
                                            annotations[parseInt(z.toString(), 10)].vertexPoints, pageAnnotationObject.pageIndex);
                                }
                                else {
                                    var pageDetails = this.pdfViewerBase.pageSize[pageAnnotationObject.pageIndex];
                                    if (pageDetails) {
                                        pageAnnotationObject.annotations[parseInt(z.toString(), 10)].annotationRotation = pageDetails.rotation;
                                    }
                                }
                            }
                            pageAnnotationObject.annotations[parseInt(z.toString(), 10)].bounds =
                                JSON.stringify(this.pdfViewer.annotation.
                                    getBounds(pageAnnotationObject.annotations[parseInt(z.toString(), 10)].bounds, pageAnnotationObject.pageIndex));
                            var strokeColorString = pageAnnotationObject.annotations[parseInt(z.toString(), 10)].strokeColor;
                            pageAnnotationObject.annotations[parseInt(z.toString(), 10)].strokeColor =
                                JSON.stringify(this.getRgbCode(strokeColorString));
                            var fillColorString = pageAnnotationObject.annotations[parseInt(z.toString(), 10)].fillColor;
                            pageAnnotationObject.annotations[parseInt(z.toString(), 10)].fillColor =
                                JSON.stringify(this.getRgbCode(fillColorString));
                            pageAnnotationObject.annotations[parseInt(z.toString(), 10)].vertexPoints =
                                JSON.stringify(this.pdfViewer.annotation.
                                    getVertexPoints(pageAnnotationObject.annotations[parseInt(z.toString(), 10)].vertexPoints, pageAnnotationObject.pageIndex));
                            if (pageAnnotationObject.annotations[parseInt(z.toString(), 10)].rectangleDifference !== null) {
                                pageAnnotationObject.annotations[parseInt(z.toString(), 10)].rectangleDifference =
                                    JSON.stringify(pageAnnotationObject.annotations[parseInt(z.toString(), 10)].rectangleDifference);
                            }
                            pageAnnotationObject.annotations[parseInt(z.toString(), 10)].calibrate =
                                this.getStringifiedMeasure(pageAnnotationObject.annotations[parseInt(z.toString(), 10)].calibrate);
                            if (pageAnnotationObject.annotations[parseInt(z.toString(), 10)].enableShapeLabel === true) {
                                pageAnnotationObject.annotations[parseInt(z.toString(), 10)].labelBounds =
                                    JSON.stringify(this.pdfViewer.annotationModule.inputElementModule.calculateLabelBounds(JSON.parse(pageAnnotationObject.annotations[parseInt(z.toString(), 10)].bounds), pageAnnotationObject.pageIndex));
                                var labelFillColorString = pageAnnotationObject.annotations[parseInt(z.toString(), 10)].labelFillColor;
                                pageAnnotationObject.annotations[parseInt(z.toString(), 10)].labelFillColor =
                                    JSON.stringify(this.getRgbCode(labelFillColorString));
                                var labelBorderColorString = pageAnnotationObject.annotations[parseInt(z.toString(), 10)].labelBorderColor;
                                pageAnnotationObject.annotations[parseInt(z.toString(), 10)].labelBorderColor =
                                    JSON.stringify(this.getRgbCode(labelBorderColorString));
                                pageAnnotationObject.annotations[parseInt(z.toString(), 10)].labelSettings.fillColor = labelFillColorString;
                                var fontColorString = pageAnnotationObject.annotations[parseInt(z.toString(), 10)].labelSettings.fontColor;
                                pageAnnotationObject.annotations[parseInt(z.toString(), 10)].fontColor =
                                    JSON.stringify(this.getRgbCode(fontColorString));
                            }
                        }
                        newArray = pageAnnotationObject.annotations;
                    }
                    annotations[pageAnnotationObject.pageIndex] = newArray;
                }
                annotationCollection = null;
            }
            return JSON.stringify(annotations);
        };
        MeasureAnnotation.prototype.createScaleRatioWindow = function () {
            var _this = this;
            if (!ej2_base_1.isBlazor()) {
                var elementID = this.pdfViewer.element.id;
                var dialogDiv = ej2_base_1.createElement('div', { id: elementID + '_scale_ratio_window', className: 'e-pv-scale-ratio-window' });
                this.pdfViewerBase.pageContainer.appendChild(dialogDiv);
                var contentElement = this.createRatioUI();
                this.scaleRatioDialog = new ej2_popups_1.Dialog({
                    showCloseIcon: true, closeOnEscape: false, isModal: true, header: this.pdfViewer.localeObj.getConstant('Scale Ratio'),
                    target: this.pdfViewer.element, content: contentElement, close: function () {
                        _this.sourceTextBox.destroy();
                        _this.convertUnit.destroy();
                        _this.destTextBox.destroy();
                        _this.dispUnit.destroy();
                        _this.scaleRatioDialog.destroy();
                        var dialogElement = _this.pdfViewerBase.getElement('_scale_ratio_window');
                        dialogElement.parentElement.removeChild(dialogElement);
                    }
                });
                if (!ej2_base_1.Browser.isDevice || this.pdfViewer.enableDesktopMode) {
                    this.scaleRatioDialog.buttons = [
                        { buttonModel: { content: this.pdfViewer.localeObj.getConstant('OK'), isPrimary: true }, click: this.onOkClicked.bind(this) },
                        { buttonModel: { content: this.pdfViewer.localeObj.getConstant('Cancel') }, click: this.onCancelClicked.bind(this) }
                    ];
                }
                else {
                    this.scaleRatioDialog.buttons = [
                        { buttonModel: { content: this.pdfViewer.localeObj.getConstant('Cancel') }, click: this.onCancelClicked.bind(this) },
                        { buttonModel: { content: this.pdfViewer.localeObj.getConstant('OK'), isPrimary: true }, click: this.onOkClicked.bind(this) }
                    ];
                }
                if (this.pdfViewer.enableRtl) {
                    this.scaleRatioDialog.enableRtl = true;
                }
                this.scaleRatioDialog.appendTo(dialogDiv);
                this.updateScaleRatioCollection();
                if (this.scaleRatioCollection.length === 1) {
                    var existing = this.scaleRatioCollection[0];
                    if (Object.keys(existing).length === 2 &&
                        Object.prototype.hasOwnProperty.call(existing, 'id') &&
                        Object.prototype.hasOwnProperty.call(existing, 'annotName')) {
                        Object.assign(existing, {
                            ratio: this.destTextBox.value / this.sourceTextBox.value,
                            unit: this.getContent(this.convertUnit.content),
                            displayUnit: this.getContent(this.dispUnit.content),
                            destValue: this.destTextBox.value,
                            srcValue: this.sourceTextBox.value,
                            volumeDepth: this.depthTextBox.value,
                            depthValue: this.depthTextBox.value,
                            ratioString: this.sourceTextBox.value + ' ' + this.unit + ' = ' + this.destTextBox.value + ' ' + this.displayUnit
                        });
                    }
                }
                if (this.pdfViewer.selectedItems.annotations[0] && this.scaleRatioAddCollection.length === 1 &&
                    this.scaleRatioAddCollection[0].displayUnit === 'in' && this.scaleRatioAddCollection[0].unit === 'in'
                    && this.scaleRatioAddCollection[0].destValue === 1 && this.scaleRatioAddCollection[0].srcValue === 1
                    && this.scaleRatioAddCollection[0].depthValue === 96) {
                    this.convertUnit.content = 'in';
                    this.dispUnit.content = 'in';
                    this.depthUnit.content = 'in';
                    this.destTextBox.value = 1;
                    this.depthTextBox.value = 96;
                    this.sourceTextBox.value = 1;
                }
                else if (this.pdfViewer.selectedItems.annotations[0]) {
                    var unit = void 0;
                    var displayUnit = void 0;
                    if (this.scaleRatioCollection.length > 0) {
                        for (var i = 0; i < this.scaleRatioCollection.length; i++) {
                            if (this.scaleRatioCollection[parseInt(i.toString(), 10)].annotName ===
                                this.pdfViewer.selectedItems.annotations[0].annotName) {
                                var measureRatioObject = this.scaleRatioCollection[parseInt(i.toString(), 10)];
                                unit = measureRatioObject.unit;
                                displayUnit = measureRatioObject.displayUnit;
                                this.convertUnit.content = this.createContent(this.pdfViewer.localeObj.getConstant(unit)).outerHTML;
                                this.dispUnit.content = this.createContent(this.pdfViewer.localeObj.getConstant(displayUnit)).outerHTML;
                                this.depthUnit.content = this.createContent(this.pdfViewer.localeObj.getConstant(displayUnit)).outerHTML;
                                this.destTextBox.value = measureRatioObject.destValue ? measureRatioObject.destValue : 1;
                                this.depthTextBox.value = measureRatioObject.depthValue;
                                this.sourceTextBox.value = measureRatioObject.srcValue ? measureRatioObject.srcValue : 1;
                                break;
                            }
                        }
                    }
                }
                else {
                    if (!ej2_base_1.isNullOrUndefined(this.measureRatioObject)) {
                        this.convertUnit.content = this.createContent(this.pdfViewer.localeObj.getConstant(this.measureRatioObject.unit ?
                            this.measureRatioObject.unit : this.unit)).outerHTML;
                        this.dispUnit.content = this.createContent(this.pdfViewer.localeObj.getConstant(this.measureRatioObject.displayUnit ?
                            this.measureRatioObject.displayUnit : this.displayUnit)).outerHTML;
                        this.depthUnit.content = this.createContent(this.pdfViewer.localeObj.getConstant(this.measureRatioObject.displayUnit ?
                            this.measureRatioObject.displayUnit : this.displayUnit)).outerHTML;
                        this.destTextBox.value = this.measureRatioObject.destValue ? this.measureRatioObject.destValue : 1;
                        this.depthTextBox.value = this.measureRatioObject.depthValue;
                        this.sourceTextBox.value = this.measureRatioObject.srcValue ? this.measureRatioObject.srcValue : 1;
                    }
                    else {
                        this.convertUnit.content = this.createContent(this.pdfViewer.localeObj.getConstant(this.unit)).outerHTML;
                        this.dispUnit.content = this.createContent(this.pdfViewer.localeObj.getConstant(this.displayUnit)).outerHTML;
                        this.depthUnit.content = this.createContent(this.pdfViewer.localeObj.getConstant(this.displayUnit)).outerHTML;
                    }
                }
            }
            else {
                this.pdfViewer._dotnetInstance.invokeMethodAsync('OpenScaleRatioDialog');
            }
        };
        MeasureAnnotation.prototype.updateScaleRatioCollection = function () {
            if (this.scaleRatioCollection.length === 0) {
                for (var i = 0; i < this.pdfViewer.annotationCollection.length; i++) {
                    var annotation = this.pdfViewer.annotationCollection[parseInt(i.toString(), 10)];
                    if (annotation.subject === 'Distance calculation' || annotation.subject === 'Perimeter calculation' || annotation.subject === 'Area calculation' || annotation.subject === 'Radius calculation' || annotation.subject === 'Volume calculation') {
                        var ratioString = annotation.calibrate.ratio.split('=').map(function (ratioString) { return ratioString.trim(); });
                        var _a = ratioString[0].split(' '), srcValueStr = _a[0], unit = _a[1];
                        var _b = ratioString[1].split(' '), destValueStr = _b[0], displayUnit = _b[1];
                        var destValue = parseFloat(destValueStr);
                        var depthValue = void 0;
                        var srcValue = parseFloat(srcValueStr);
                        if (this.pdfViewer.annotationCollection[parseInt(i.toString(), 10)].subject === 'Volume calculation') {
                            depthValue =
                                this.pdfViewer.annotationCollection[parseInt(i.toString(), 10)].calibrate.depth;
                        }
                        else {
                            depthValue = 96;
                        }
                        if (!ej2_base_1.isNullOrUndefined(this.sourceTextBox)) {
                            this.sourceTextBox.value = parseFloat(srcValueStr);
                        }
                        var scaleRatio = {
                            id: annotation.uniqueKey,
                            annotName: annotation.annotationId,
                            displayUnit: displayUnit,
                            unit: unit,
                            ratio: destValue / srcValue,
                            destValue: destValue,
                            srcValue: srcValue,
                            volumeDepth: depthValue,
                            depthValue: depthValue,
                            ratioString: ratioString
                        };
                        this.scaleRatioCollection.push(scaleRatio);
                    }
                }
            }
        };
        MeasureAnnotation.prototype.createRatioUI = function () {
            var element = ej2_base_1.createElement('div');
            var elementID = this.pdfViewer.element.id;
            var items = [{ text: this.pdfViewer.localeObj.getConstant('pt'), label: 'pt' }, { text: this.pdfViewer.localeObj.getConstant('in'), label: 'in' }, { text: this.pdfViewer.localeObj.getConstant('mm'), label: 'mm' }, { text: this.pdfViewer.localeObj.getConstant('cm'), label: 'cm' }, { text: this.pdfViewer.localeObj.getConstant('p'), label: 'p' }, { text: this.pdfViewer.localeObj.getConstant('ft'), label: 'ft' }, { text: this.pdfViewer.localeObj.getConstant('ft_in'), label: 'ft_in' }, { text: this.pdfViewer.localeObj.getConstant('m'), label: 'm' }];
            var labelText = ej2_base_1.createElement('div', { id: elementID + '_scale_ratio_label', className: 'e-pv-scale-ratio-text' });
            labelText.textContent = this.pdfViewer.localeObj.getConstant('Scale Ratio');
            element.appendChild(labelText);
            var sourceContainer = ej2_base_1.createElement('div', { id: elementID + '_scale_src_container' });
            element.appendChild(sourceContainer);
            var srcInputElement = this.createInputElement('input', 'e-pv-scale-ratio-src-input', elementID + '_src_input', sourceContainer);
            this.sourceTextBox = new ej2_inputs_1.NumericTextBox({ value: 1, format: '##', cssClass: 'e-pv-scale-ratio-src-input', min: 1, max: 100000 }, srcInputElement);
            var srcUnitElement = this.createInputElement('button', 'e-pv-scale-ratio-src-unit', elementID + '_src_unit', sourceContainer);
            this.convertUnit = new ej2_splitbuttons_1.DropDownButton({ items: items, cssClass: 'e-pv-scale-ratio-src-unit' }, srcUnitElement);
            this.convertUnit.select = this.convertUnitSelect.bind(this);
            var destinationContainer = ej2_base_1.createElement('div', { id: elementID + '_scale_dest_container' });
            var destInputElement = this.createInputElement('input', 'e-pv-scale-ratio-dest-input', elementID + '_dest_input', destinationContainer);
            this.destTextBox = new ej2_inputs_1.NumericTextBox({ value: 1, format: '##', cssClass: 'e-pv-scale-ratio-dest-input', min: 1, max: 100000 }, destInputElement);
            var destUnitElement = this.createInputElement('button', 'e-pv-scale-ratio-dest-unit', elementID + '_dest_unit', destinationContainer);
            this.dispUnit = new ej2_splitbuttons_1.DropDownButton({ items: items, cssClass: 'e-pv-scale-ratio-dest-unit' }, destUnitElement);
            this.dispUnit.select = this.dispUnitSelect.bind(this);
            element.appendChild(destinationContainer);
            var depthLabelText = ej2_base_1.createElement('div', { id: elementID + '_depth_label', className: 'e-pv-depth-text' });
            depthLabelText.textContent = this.pdfViewer.localeObj.getConstant('Depth');
            element.appendChild(depthLabelText);
            var depthContainer = ej2_base_1.createElement('div', { id: elementID + '_depth_container' });
            element.appendChild(depthContainer);
            var depthInputElement = this.createInputElement('input', 'e-pv-depth-input', elementID + '_depth_input', depthContainer);
            this.depthTextBox = new ej2_inputs_1.NumericTextBox({ value: this.volumeDepth, format: '##', cssClass: 'e-pv-depth-input', min: 1 }, depthInputElement);
            var depthUnitElement = this.createInputElement('button', 'e-pv-depth-unit', elementID + '_depth_unit', depthContainer);
            this.depthUnit = new ej2_splitbuttons_1.DropDownButton({ items: items, cssClass: 'e-pv-depth-unit' }, depthUnitElement);
            this.depthUnit.select = this.depthUnitSelect.bind(this);
            return element;
        };
        MeasureAnnotation.prototype.convertUnitSelect = function (args) {
            this.convertUnit.content = this.createContent(args.item.text).outerHTML;
        };
        MeasureAnnotation.prototype.dispUnitSelect = function (args) {
            this.dispUnit.content = this.createContent(args.item.text).outerHTML;
            this.depthUnit.content = this.createContent(args.item.text).outerHTML;
        };
        MeasureAnnotation.prototype.depthUnitSelect = function (args) {
            this.depthUnit.content = this.createContent(args.item.text).outerHTML;
        };
        MeasureAnnotation.prototype.createContent = function (text) {
            var divElement = ej2_base_1.createElement('div', { className: 'e-pv-scale-unit-content' });
            divElement.textContent = text;
            return divElement;
        };
        MeasureAnnotation.prototype.createInputElement = function (input, className, idString, parentElement) {
            var container = ej2_base_1.createElement('div', { id: idString + '_container', className: className + '-container' });
            var textBoxInput = ej2_base_1.createElement(input, { id: idString });
            if (input === 'input') {
                textBoxInput.type = 'text';
            }
            container.appendChild(textBoxInput);
            parentElement.appendChild(container);
            return textBoxInput;
        };
        MeasureAnnotation.prototype.onOkClicked = function () {
            var unit = this.getContent(this.convertUnit.content);
            var displayUnit = this.getContent(this.dispUnit.content);
            if (ej2_base_1.isBlazor()) {
                var unitElement = document.querySelector('#' + this.pdfViewer.element.id + '_src_unit');
                var displayElement = document.querySelector('#' + this.pdfViewer.element.id + '_dest_unit');
                var sourceTextBox = document.querySelector('#' + this.pdfViewer.element.id + '_ratio_input');
                var destTextBox = document.querySelector('#' + this.pdfViewer.element.id + '_dest_input');
                var depthTextBox = document.querySelector('#' + this.pdfViewer.element.id + '_depth_input');
                if (unitElement && displayElement && sourceTextBox && destTextBox && depthTextBox) {
                    this.unit = unitElement.value;
                    this.displayUnit = displayElement.value;
                    this.ratio = parseInt(destTextBox.value, 10) / parseInt(sourceTextBox.value, 10);
                    this.volumeDepth = parseInt(depthTextBox.value, 10);
                }
                this.scaleRatioString = parseInt(sourceTextBox.value, 10) + ' ' + this.unit + ' = ' + parseInt(destTextBox.value, 10) + ' ' + this.displayUnit;
                this.updateMeasureValues(this.scaleRatioString, this.displayUnit, this.unit, this.volumeDepth);
            }
            else if (this.pdfViewer.selectedItems.annotations[0]) {
                for (var i = 0; i < this.scaleRatioCollection.length; i++) {
                    if (this.scaleRatioCollection[parseInt(i.toString(), 10)].annotName ===
                        this.pdfViewer.selectedItems.annotations[0].annotName
                        && this.scaleRatioCollection[parseInt(i.toString(), 10)].displayUnit === this.getContent(this.dispUnit.content) &&
                        this.scaleRatioCollection[parseInt(i.toString(), 10)].unit === this.getContent(this.convertUnit.content) &&
                        this.scaleRatioCollection[parseInt(i.toString(), 10)].destValue === this.destTextBox.value &&
                        this.scaleRatioCollection[parseInt(i.toString(), 10)].srcValue === this.sourceTextBox.value &&
                        this.scaleRatioCollection[parseInt(i.toString(), 10)].volumeDepth === this.depthTextBox.value) {
                        var measureRatioObject = this.scaleRatioCollection[parseInt(i.toString(), 10)];
                        this.updateRatioValues(measureRatioObject.unit, measureRatioObject.displayUnit, measureRatioObject.ratio, measureRatioObject.volumeDepth, measureRatioObject.srcValue, measureRatioObject.destValue);
                    }
                    else if (this.scaleRatioCollection[parseInt(i.toString(), 10)].annotName ===
                        this.pdfViewer.selectedItems.annotations[0].annotName) {
                        var measureRatioObject = this.scaleRatioCollection[parseInt(i.toString(), 10)];
                        measureRatioObject.ratio = this.destTextBox.value / this.sourceTextBox.value;
                        measureRatioObject.unit = this.getContent(this.convertUnit.content);
                        measureRatioObject.displayUnit = this.getContent(this.dispUnit.content);
                        measureRatioObject.destValue = this.destTextBox.value;
                        measureRatioObject.srcValue = this.sourceTextBox.value;
                        measureRatioObject.volumeDepth = this.depthTextBox.value;
                        measureRatioObject.depthValue = this.depthTextBox.value;
                        measureRatioObject.ratioString = this.sourceTextBox.value + ' ' + measureRatioObject.unit + ' = ' + this.destTextBox.value + ' ' + measureRatioObject.displayUnit;
                        var volumeDepth = this.depthTextBox.value;
                        var scaleRatioString = this.sourceTextBox.value + ' ' + unit + ' = ' + this.destTextBox.value + ' ' + displayUnit;
                        this.scaleRatioDialog.hide();
                        var originalUnit = this.restoreUnit(this.convertUnit, unit);
                        var originalDisplayUnit = this.restoreUnit(this.dispUnit, displayUnit);
                        this.updateMeasureValues(scaleRatioString, originalDisplayUnit, originalUnit, volumeDepth);
                    }
                }
            }
            else {
                this.measureRatioObject = {
                    ratio: this.destTextBox.value / this.sourceTextBox.value,
                    unit: unit,
                    displayUnit: displayUnit,
                    destValue: this.destTextBox.value,
                    srcValue: this.sourceTextBox.value,
                    volumeDepth: this.depthTextBox.value,
                    depthValue: this.depthTextBox.value,
                    ratioString: this.sourceTextBox.value + ' ' + unit + ' = ' + this.destTextBox.value + ' ' + displayUnit
                };
                this.scaleRatioAddCollection.push(this.measureRatioObject);
                this.currentScaleRatio = this.measureRatioObject;
                this.updateRatioValues(this.measureRatioObject.unit, this.measureRatioObject.displayUnit, this.measureRatioObject.ratio, this.measureRatioObject.volumeDepth, this.measureRatioObject.srcValue, this.measureRatioObject.destValue);
            }
        };
        MeasureAnnotation.prototype.updateRatioValues = function (unit, displayUnit, ratio, volumeDepth, srcValue, destValue) {
            this.unit = unit;
            this.displayUnit = displayUnit;
            this.ratio = destValue / srcValue;
            this.destValue = destValue;
            this.srcValue = srcValue;
            this.volumeDepth = volumeDepth;
            this.depthValue = volumeDepth;
            this.scaleRatioString = srcValue + ' ' + unit + ' = ' + destValue + ' ' + displayUnit;
            this.scaleRatioDialog.hide();
            var originalUnit = this.restoreUnit(this.convertUnit, this.unit);
            var originalDisplayUnit = this.restoreUnit(this.dispUnit, this.displayUnit);
            this.updateMeasureValues(this.scaleRatioString, originalDisplayUnit, originalUnit, this.volumeDepth);
        };
        MeasureAnnotation.prototype.restoreUnit = function (dropdownObject, currentUnit) {
            var calibUnit;
            for (var i = 0; i < dropdownObject.items.length; i++) {
                var convertUnitItem = dropdownObject.items[parseInt(i.toString(), 10)];
                if (currentUnit === convertUnitItem.text) {
                    calibUnit = convertUnitItem.label;
                }
            }
            return calibUnit;
        };
        MeasureAnnotation.prototype.destroy = function () {
            this.currentAnnotationMode = null;
            this.distanceOpacity = null;
            this.perimeterOpacity = null;
            this.areaOpacity = null;
            this.radiusOpacity = null;
            this.volumeOpacity = null;
            this.distanceFillColor = null;
            this.perimeterFillColor = null;
            this.areaFillColor = null;
            this.radiusFillColor = null;
            this.volumeFillColor = null;
            this.distanceStrokeColor = null;
            this.perimeterStrokeColor = null;
            this.areaStrokeColor = null;
            this.radiusStrokeColor = null;
            this.volumeStrokeColor = null;
            this.distanceThickness = null;
            this.leaderLength = null;
            this.perimeterThickness = null;
            this.areaThickness = null;
            this.radiusThickness = null;
            this.volumeThickness = null;
            this.distanceDashArray = null;
            this.distanceStartHead = null;
            this.distanceEndHead = null;
            this.perimeterDashArray = null;
            this.perimeterStartHead = null;
            this.perimeterEndHead = null;
            this.unit = null;
            this.displayUnit = null;
            this.measureShapeCount = null;
            this.volumeDepth = null;
            this.isAddAnnotationProgramatically = null;
            this.ratio = null;
            this.srcValue = null;
            this.destValue = null;
            this.scaleRatioString = null;
            this.scaleRatioDialog = null;
            this.sourceTextBox = null;
            this.convertUnit = null;
            this.destTextBox = null;
            this.dispUnit = null;
            this.depthTextBox = null;
            this.depthUnit = null;
            this.scaleRatioCollection = null;
            this.scaleRatioAddCollection = null;
        };
        MeasureAnnotation.prototype.updateMeasureValues = function (ratio, displayUnit, conversionUnit, depth) {
            this.scaleRatioString = ratio;
            this.displayUnit = displayUnit;
            this.unit = conversionUnit;
            this.volumeDepth = depth;
            for (var i = 0; i < this.pdfViewerBase.pageCount; i++) {
                var pageAnnotations = this.getAnnotations(i, null);
                if (pageAnnotations) {
                    var _loop_2 = function (j) {
                        pageAnnotations = this_2.getAnnotations(i, null);
                        if (this_2.pdfViewer.selectedItems.annotations[0] && this_2.pdfViewer.selectedItems.annotations[0].id) {
                            var measureObject_1 = pageAnnotations[parseInt(j.toString(), 10)];
                            var matchedRatio = this_2.scaleRatioCollection.find(function (item) { return item.annotName === measureObject_1.annotName; });
                            if (pageAnnotations[parseInt(j.toString(), 10)].annotName ===
                                this_2.pdfViewer.selectedItems.annotations[0].annotName) {
                                if (!measureObject_1.annotationSettings.isLock && matchedRatio) {
                                    measureObject_1.calibrate.ratio = matchedRatio.ratioString;
                                    measureObject_1.calibrate.x[0].unit = matchedRatio.displayUnit;
                                    measureObject_1.calibrate.distance[0].unit = matchedRatio.displayUnit;
                                    measureObject_1.calibrate.area[0].unit = matchedRatio.displayUnit;
                                    measureObject_1.calibrate.x[0].conversionFactor = this_2.getFactor(conversionUnit);
                                    if (measureObject_1.indent === 'PolygonVolume') {
                                        measureObject_1.calibrate.depth = matchedRatio.volumeDepth;
                                    }
                                    pageAnnotations[parseInt(j.toString(), 10)] = measureObject_1;
                                    this_2.manageAnnotations(pageAnnotations, i);
                                    this_2.pdfViewer.annotation.updateCalibrateValues(this_2.getAnnotationBaseModel(measureObject_1.id));
                                }
                            }
                        }
                    };
                    var this_2 = this;
                    for (var j = 0; j < pageAnnotations.length; j++) {
                        _loop_2(j);
                    }
                }
                this.pdfViewer.annotation.renderAnnotations(i, null, null, null, null, false);
            }
        };
        MeasureAnnotation.prototype.getAnnotationBaseModel = function (id) {
            var annotationBase = null;
            for (var i = 0; i < this.pdfViewer.annotations.length; i++) {
                if (id === this.pdfViewer.annotations[parseInt(i.toString(), 10)].id) {
                    annotationBase = this.pdfViewer.annotations[parseInt(i.toString(), 10)];
                    break;
                }
            }
            return annotationBase;
        };
        MeasureAnnotation.prototype.getContent = function (unit) {
            return unit.split('</div>')[0].split('">')[1];
        };
        MeasureAnnotation.prototype.setConversion = function (value, currentAnnot) {
            var values;
            if (currentAnnot) {
                var pageIndex = currentAnnot.pageIndex;
                if (currentAnnot.id === 'diagram_helper') {
                    pageIndex = currentAnnot.pageIndex ? currentAnnot.pageIndex : this.pdfViewerBase.activeElements.activePageID;
                    currentAnnot = this.getCurrentObject(pageIndex, null, currentAnnot.annotName);
                }
                if (currentAnnot) {
                    values = this.getCurrentValues(currentAnnot.id, pageIndex);
                }
                else {
                    values = this.getCurrentValues();
                }
            }
            else {
                values = this.getCurrentValues();
            }
            var scaledValue = value * values.ratio;
            return this.convertPointToUnits(values.factor, scaledValue, values.unit);
        };
        MeasureAnnotation.prototype.onCancelClicked = function () {
            this.scaleRatioDialog.hide();
        };
        MeasureAnnotation.prototype.modifyInCollection = function (property, pageNumber, annotationBase, isNewlyAdded) {
            if (!ej2_base_1.isNullOrUndefined(annotationBase.formFieldAnnotationType) && annotationBase.formFieldAnnotationType !== '') {
                this.pdfViewer.annotationModule.isFormFieldShape = true;
            }
            else {
                this.pdfViewer.annotationModule.isFormFieldShape = false;
            }
            var currentAnnotObject = null;
            var isEdited = false;
            var pageAnnotations = this.getAnnotations(pageNumber, null);
            if (pageAnnotations != null && annotationBase) {
                for (var i = 0; i < pageAnnotations.length; i++) {
                    if (annotationBase.id === pageAnnotations[parseInt(i.toString(), 10)].id) {
                        if (property === 'bounds') {
                            this.pdfViewerBase.isBounds =
                                this.pdfViewerBase.boundsCalculation(pageAnnotations[parseInt(i.toString(), 10)].bounds, annotationBase.wrapper.bounds);
                            if (this.pdfViewerBase.isBounds) {
                                this.pdfViewer.annotationModule.stickyNotesAnnotationModule.updateAnnotationModifiedDate(annotationBase, true);
                                if (pageAnnotations[parseInt(i.toString(), 10)].shapeAnnotationType === 'Line' || pageAnnotations[parseInt(i.toString(), 10)].shapeAnnotationType === 'Polyline') {
                                    pageAnnotations[parseInt(i.toString(), 10)].vertexPoints = annotationBase.vertexPoints;
                                    pageAnnotations[parseInt(i.toString(), 10)].bounds =
                                        {
                                            left: annotationBase.bounds.x, top: annotationBase.bounds.y,
                                            width: annotationBase.bounds.width, height: annotationBase.bounds.height,
                                            right: annotationBase.bounds.right, bottom: annotationBase.bounds.bottom
                                        };
                                }
                                else if (pageAnnotations[parseInt(i.toString(), 10)].shapeAnnotationType === 'Polygon') {
                                    pageAnnotations[parseInt(i.toString(), 10)].vertexPoints = annotationBase.vertexPoints;
                                    pageAnnotations[parseInt(i.toString(), 10)].bounds =
                                        {
                                            left: annotationBase.bounds.x, top: annotationBase.bounds.y, width: annotationBase.bounds.width,
                                            height: annotationBase.bounds.height, right: annotationBase.bounds.right,
                                            bottom: annotationBase.bounds.bottom
                                        };
                                }
                                else {
                                    pageAnnotations[parseInt(i.toString(), 10)].bounds =
                                        {
                                            left: annotationBase.bounds.x, top: annotationBase.bounds.y, width: annotationBase.bounds.width,
                                            height: annotationBase.bounds.height, right: annotationBase.bounds.right,
                                            bottom: annotationBase.bounds.bottom
                                        };
                                }
                            }
                            if (pageAnnotations[parseInt(i.toString(), 10)].enableShapeLabel === true && annotationBase.wrapper) {
                                pageAnnotations[parseInt(i.toString(), 10)].labelBounds =
                                    this.pdfViewer.annotationModule.inputElementModule.calculateLabelBounds(annotationBase.wrapper.bounds);
                            }
                        }
                        else if (property === 'fill') {
                            pageAnnotations[parseInt(i.toString(), 10)].fillColor = annotationBase.wrapper.children[0].style.fill;
                            if (this.pdfViewer.enableShapeLabel) {
                                pageAnnotations[parseInt(i.toString(), 10)].labelFillColor = annotationBase.wrapper.children[0].style.fill;
                            }
                        }
                        else if (property === 'stroke') {
                            pageAnnotations[parseInt(i.toString(), 10)].strokeColor = annotationBase.wrapper.children[0].style.strokeColor;
                        }
                        else if (property === 'opacity') {
                            pageAnnotations[parseInt(i.toString(), 10)].opacity = annotationBase.wrapper.children[0].style.opacity;
                        }
                        else if (property === 'thickness') {
                            pageAnnotations[parseInt(i.toString(), 10)].thickness = annotationBase.wrapper.children[0].style.strokeWidth;
                        }
                        else if (property === 'dashArray') {
                            pageAnnotations[parseInt(i.toString(), 10)].borderDashArray =
                                annotationBase.wrapper.children[0].style.strokeDashArray;
                            pageAnnotations[parseInt(i.toString(), 10)].borderStyle = annotationBase.borderStyle;
                        }
                        else if (property === 'startArrow') {
                            pageAnnotations[parseInt(i.toString(), 10)].lineHeadStart =
                                this.pdfViewer.annotation.getArrowTypeForCollection(annotationBase.sourceDecoraterShapes);
                        }
                        else if (property === 'endArrow') {
                            pageAnnotations[parseInt(i.toString(), 10)].lineHeadEnd =
                                this.pdfViewer.annotation.getArrowTypeForCollection(annotationBase.taregetDecoraterShapes);
                        }
                        else if (property === 'leaderLength') {
                            pageAnnotations[parseInt(i.toString(), 10)].leaderLength = annotationBase.leaderHeight;
                        }
                        else if (property === 'notes') {
                            pageAnnotations[parseInt(i.toString(), 10)].note = annotationBase.notes;
                            if (pageAnnotations[parseInt(i.toString(), 10)].enableShapeLabel === true) {
                                isEdited = true;
                                pageAnnotations[parseInt(i.toString(), 10)].labelContent = annotationBase.notes;
                            }
                        }
                        else if (property === 'delete') {
                            currentAnnotObject = pageAnnotations.splice(i, 1)[0];
                            break;
                        }
                        else if (property === 'labelContent') {
                            pageAnnotations[parseInt(i.toString(), 10)].note = annotationBase.labelContent;
                            pageAnnotations[parseInt(i.toString(), 10)].labelContent = annotationBase.labelContent;
                            break;
                        }
                        else if (property === 'fontColor') {
                            pageAnnotations[parseInt(i.toString(), 10)].fontColor = annotationBase.fontColor;
                        }
                        else if (property === 'fontSize') {
                            pageAnnotations[parseInt(i.toString(), 10)].fontSize = annotationBase.fontSize;
                        }
                        if (this.pdfViewerBase.isBounds) {
                            pageAnnotations[parseInt(i.toString(), 10)].modifiedDate =
                                this.pdfViewer.annotation.stickyNotesAnnotationModule.getDateAndTime();
                        }
                        this.pdfViewer.annotationModule.storeAnnotationCollections(pageAnnotations[parseInt(i.toString(), 10)], pageNumber);
                    }
                }
                this.manageAnnotations(pageAnnotations, pageNumber);
            }
            if (!isNewlyAdded && isEdited) {
                this.pdfViewerBase.updateDocumentEditedProperty(true);
            }
            return currentAnnotObject;
        };
        MeasureAnnotation.prototype.addInCollection = function (pageNumber, annotationBase) {
            var pageAnnotations = this.getAnnotations(pageNumber, null);
            if (pageAnnotations) {
                pageAnnotations.push(annotationBase);
            }
            this.manageAnnotations(pageAnnotations, pageNumber);
        };
        MeasureAnnotation.prototype.manageAnnotations = function (pageAnnotations, pageNumber) {
            var storeObject = this.pdfViewer.annotationsCollection.get(this.pdfViewerBase.documentId + '_annotations_shape_measure');
            if (storeObject) {
                this.pdfViewer.annotationsCollection.delete(this.pdfViewerBase.documentId + '_annotations_shape_measure');
                var index = this.pdfViewer.annotationModule.getPageCollection(storeObject, pageNumber);
                if (index != null && storeObject[parseInt(index.toString(), 10)]) {
                    storeObject[parseInt(index.toString(), 10)].annotations = pageAnnotations;
                }
                this.pdfViewer.annotationsCollection.set(this.pdfViewerBase.documentId + '_annotations_shape_measure', storeObject);
            }
        };
        MeasureAnnotation.prototype.getAnnotations = function (pageIndex, shapeAnnotations) {
            var annotationCollection;
            var storeObject = this.pdfViewer.annotationsCollection.get(this.pdfViewerBase.documentId + '_annotations_shape_measure');
            if (storeObject) {
                var index = this.pdfViewer.annotationModule.getPageCollection(storeObject, pageIndex);
                if (index != null && storeObject[parseInt(index.toString(), 10)]) {
                    annotationCollection = storeObject[parseInt(index.toString(), 10)].annotations;
                }
                else {
                    annotationCollection = shapeAnnotations;
                }
            }
            else {
                annotationCollection = shapeAnnotations;
            }
            return annotationCollection;
        };
        MeasureAnnotation.prototype.getCurrentObject = function (pageNumber, id, annotName) {
            var currentAnnotObject = null;
            var pageAnnotations = this.getAnnotations(pageNumber, null);
            if (pageAnnotations != null) {
                for (var i = 0; i < pageAnnotations.length; i++) {
                    if (id) {
                        if (id === pageAnnotations[parseInt(i.toString(), 10)].id) {
                            currentAnnotObject = pageAnnotations[parseInt(i.toString(), 10)];
                            break;
                        }
                    }
                    else if (annotName) {
                        if (annotName === pageAnnotations[parseInt(i.toString(), 10)].annotName) {
                            currentAnnotObject = pageAnnotations[parseInt(i.toString(), 10)];
                            break;
                        }
                    }
                }
            }
            return currentAnnotObject;
        };
        MeasureAnnotation.prototype.getCurrentValues = function (id, pageNumber) {
            var ratio;
            var unit;
            var factor;
            var depth;
            if (id && !isNaN(pageNumber)) {
                var currentAnnotObject = this.getCurrentObject(pageNumber, id);
                if (currentAnnotObject) {
                    ratio = this.getCurrentRatio(currentAnnotObject.calibrate.ratio);
                    unit = currentAnnotObject.calibrate.x[0].unit;
                    factor = currentAnnotObject.calibrate.x[0].conversionFactor;
                    depth = currentAnnotObject.calibrate.depth;
                }
                else {
                    ratio = this.ratio;
                    unit = this.displayUnit;
                    factor = this.getFactor(this.unit);
                    depth = this.volumeDepth;
                }
            }
            else {
                ratio = this.ratio;
                unit = this.displayUnit;
                factor = this.getFactor(this.unit);
                depth = this.volumeDepth;
            }
            return { ratio: ratio, unit: unit, factor: factor, depth: depth };
        };
        MeasureAnnotation.prototype.getCurrentRatio = function (ratioString) {
            var stringArray = ratioString.split(' ');
            if (stringArray[3] === '=') {
                return parseFloat(stringArray[4]) / parseFloat(stringArray[0]);
            }
            else {
                return parseFloat(stringArray[3]) / parseFloat(stringArray[0]);
            }
        };
        MeasureAnnotation.prototype.calculateArea = function (points, id, pageNumber) {
            var values = this.getCurrentValues(id, pageNumber);
            var area = this.getArea(points, values.factor, values.unit) * values.ratio;
            if (values.unit === 'ft_in') {
                var calculateValue = Math.round(area * 100) / 100;
                if (calculateValue >= 12) {
                    calculateValue = (Math.round(calculateValue / 12 * 100) / 100).toString();
                    calculateValue = calculateValue.split('.');
                    if (calculateValue[1]) {
                        var inchValue = 0;
                        if (calculateValue[1].charAt(1)) {
                            inchValue = parseInt(calculateValue[1].charAt(0), 10) + '.' + parseInt(calculateValue[1].charAt(1), 10);
                            inchValue = Math.round(inchValue);
                        }
                        else {
                            inchValue = calculateValue[1];
                        }
                        if (!inchValue) {
                            return (calculateValue[0] + ' ' + this.pdfViewer.localeObj.getConstant('sq') + ' ' + this.pdfViewer.localeObj.getConstant('ft'));
                        }
                        else {
                            return (calculateValue[0] + ' ' + this.pdfViewer.localeObj.getConstant('sq') + ' ' + this.pdfViewer.localeObj.getConstant('ft') + ' ' + inchValue + ' ' + this.pdfViewer.localeObj.getConstant('in'));
                        }
                    }
                    else {
                        return (calculateValue[0] + ' ' + this.pdfViewer.localeObj.getConstant('sq') + ' ' + this.pdfViewer.localeObj.getConstant('ft'));
                    }
                }
                else {
                    return (Math.round(area * 100) / 100) + ' ' + this.pdfViewer.localeObj.getConstant('sq') + ' ' + this.pdfViewer.localeObj.getConstant('in');
                }
            }
            if (values.unit === 'm') {
                return ((area * 100) / 100) + ' ' + this.pdfViewer.localeObj.getConstant('sq') + ' ' + this.pdfViewer.localeObj.getConstant(values.unit);
            }
            return (Math.round(area * 100) / 100) + ' ' + this.pdfViewer.localeObj.getConstant('sq') + ' ' + this.pdfViewer.localeObj.getConstant(values.unit);
        };
        MeasureAnnotation.prototype.getArea = function (points, factor, unit) {
            var area = 0;
            var j = points.length - 1;
            for (var i = 0; i < points.length; i++) {
                area += (points[parseInt(j.toString(), 10)].x * this.pixelToPointFactor *
                    factor + points[parseInt(i.toString(), 10)].x * this.pixelToPointFactor * factor) *
                    (points[parseInt(j.toString(), 10)].y * this.pixelToPointFactor * factor - points[parseInt(i.toString(), 10)].y *
                        this.pixelToPointFactor * factor);
                j = i;
            }
            if (unit === 'ft_in') {
                return (Math.abs((area) * 2.0));
            }
            else {
                return (Math.abs((area) / 2.0));
            }
        };
        MeasureAnnotation.prototype.calculateVolume = function (points, id, pageNumber) {
            var values = this.getCurrentValues(id, pageNumber);
            var depth = values.depth ? values.depth : this.volumeDepth;
            var area = this.getArea(points, values.factor, values.unit);
            var volume = area * ((depth * this.convertUnitToPoint(values.unit)) * values.factor) * values.ratio;
            if (values.unit === 'ft_in') {
                var calculateValue = Math.round(volume * 100) / 100;
                if (calculateValue >= 12) {
                    calculateValue = (Math.round(calculateValue / 12 * 100) / 100).toString();
                    calculateValue = calculateValue.split('.');
                    if (calculateValue[1]) {
                        var inchValue = 0;
                        if (calculateValue[1].charAt(1)) {
                            inchValue = parseInt(calculateValue[1].charAt(0), 10) + '.' + parseInt(calculateValue[1].charAt(1), 10);
                            inchValue = Math.round(inchValue);
                        }
                        else {
                            inchValue = calculateValue[1];
                        }
                        if (!inchValue) {
                            return (calculateValue[0] + ' ' + this.pdfViewer.localeObj.getConstant('cu') + ' ' + this.pdfViewer.localeObj.getConstant('ft'));
                        }
                        else {
                            return (calculateValue[0] + ' ' + this.pdfViewer.localeObj.getConstant('cu') + ' ' + this.pdfViewer.localeObj.getConstant('ft') + ' ' + inchValue + ' ' + this.pdfViewer.localeObj.getConstant('in'));
                        }
                    }
                    else {
                        return (calculateValue[0] + ' ' + this.pdfViewer.localeObj.getConstant('cu') + ' ' + this.pdfViewer.localeObj.getConstant('ft'));
                    }
                }
                else {
                    return (Math.round(volume * 100) / 100) + ' ' + this.pdfViewer.localeObj.getConstant('cu') + ' ' + this.pdfViewer.localeObj.getConstant('in');
                }
            }
            return (Math.round(volume * 100) / 100) + ' ' + this.pdfViewer.localeObj.getConstant('cu') + ' ' + this.pdfViewer.localeObj.getConstant(values.unit);
        };
        MeasureAnnotation.prototype.calculatePerimeter = function (pdfAnnotationBase) {
            var perimeter = ej2_drawings_1.Point.getLengthFromListOfPoints(pdfAnnotationBase.vertexPoints);
            return this.setConversion(perimeter * this.pixelToPointFactor, pdfAnnotationBase);
        };
        MeasureAnnotation.prototype.getFactor = function (unit) {
            var factor;
            switch (unit) {
                case 'in':
                    factor = (1 / 72);
                    break;
                case 'cm':
                    factor = (1 / 28.346);
                    break;
                case 'mm':
                    factor = (1 / 2.835);
                    break;
                case 'pt':
                    factor = 1;
                    break;
                case 'p':
                    factor = 1 / 12;
                    break;
                case 'ft':
                    factor = 1 / 864;
                    break;
                case 'ft_in':
                    factor = 1 / 72;
                    break;
                case 'm':
                    factor = (1 / 2834.64567);
                    break;
            }
            return factor;
        };
        MeasureAnnotation.prototype.convertPointToUnits = function (factor, value, unit) {
            var convertedValue;
            if (unit === 'ft_in') {
                var calculateValue = Math.round((value * factor) * 100) / 100;
                if (calculateValue >= 12) {
                    calculateValue = (Math.round(calculateValue / 12 * 100) / 100).toString();
                    calculateValue = calculateValue.split('.');
                    if (calculateValue[1]) {
                        var inchValue = 0;
                        if (calculateValue[1].charAt(1)) {
                            inchValue = parseInt(calculateValue[1].charAt(0), 10) + '.' + parseInt(calculateValue[1].charAt(1), 10);
                            inchValue = Math.round(inchValue);
                        }
                        else {
                            inchValue = calculateValue[1];
                        }
                        if (!inchValue) {
                            convertedValue = calculateValue[0] + ' ' + this.pdfViewer.localeObj.getConstant('ft');
                        }
                        else {
                            convertedValue = calculateValue[0] + ' ' + this.pdfViewer.localeObj.getConstant('ft') + ' ' + inchValue + ' ' + this.pdfViewer.localeObj.getConstant('in');
                        }
                    }
                    else {
                        convertedValue = calculateValue[0] + ' ' + this.pdfViewer.localeObj.getConstant('ft');
                    }
                }
                else {
                    convertedValue = Math.round((value * factor) * 100) / 100 + ' ' + this.pdfViewer.localeObj.getConstant('in');
                }
            }
            else {
                convertedValue = Math.round((value * factor) * 100) / 100 + ' ' + this.pdfViewer.localeObj.getConstant(unit);
            }
            return convertedValue;
        };
        MeasureAnnotation.prototype.convertUnitToPoint = function (unit) {
            var factor;
            switch (unit) {
                case 'in':
                    factor = 72;
                    break;
                case 'cm':
                    factor = 28.346;
                    break;
                case 'mm':
                    factor = 2.835;
                    break;
                case 'pt':
                    factor = 1;
                    break;
                case 'p':
                    factor = 12;
                    break;
                case 'ft':
                    factor = 864;
                    break;
                case 'ft_in':
                    factor = 72;
                    break;
                case 'm':
                    factor = 2834.64567;
                    break;
            }
            return factor;
        };
        MeasureAnnotation.prototype.getStringifiedMeasure = function (measure) {
            if (!ej2_base_1.isNullOrUndefined(measure)) {
                measure.angle = JSON.stringify(measure.angle);
                measure.area = JSON.stringify(measure.area);
                measure.distance = JSON.stringify(measure.distance);
                measure.volume = JSON.stringify(measure.volume);
            }
            return JSON.stringify(measure);
        };
        MeasureAnnotation.prototype.getRgbCode = function (colorString) {
            if (!colorString.match(/#([a-z0-9]+)/gi) && !colorString.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/)) {
                colorString = this.pdfViewer.annotationModule.nameToHash(colorString);
            }
            var stringArray = colorString.split(',');
            if (ej2_base_1.isNullOrUndefined(stringArray[1])) {
                colorString = this.pdfViewer.annotationModule.getValue(colorString, 'rgba');
                stringArray = colorString.split(',');
            }
            var r = parseInt(stringArray[0].split('(')[1], 10);
            var g = parseInt(stringArray[1], 10);
            var b = parseInt(stringArray[2], 10);
            var a = parseInt(stringArray[3], 10);
            return { r: r, g: g, b: b, a: a };
        };
        MeasureAnnotation.prototype.saveImportedMeasureAnnotations = function (annotation, pageNumber) {
            var annotationObject = null;
            var vertexPoints = null;
            if (annotation.VertexPoints) {
                vertexPoints = [];
                for (var j = 0; j < annotation.VertexPoints.length; j++) {
                    var point = { x: annotation.VertexPoints[parseInt(j.toString(), 10)].X,
                        y: annotation.VertexPoints[parseInt(j.toString(), 10)].Y };
                    vertexPoints.push(point);
                }
            }
            var measureObject = {
                ratio: annotation.Calibrate.Ratio, x: this.getNumberFormatArray(annotation.Calibrate.X),
                distance: this.getNumberFormatArray(annotation.Calibrate.Distance),
                area: this.getNumberFormatArray(annotation.Calibrate.Area),
                angle: this.getNumberFormatArray(annotation.Calibrate.Angle),
                volume: this.getNumberFormatArray(annotation.Calibrate.Volume),
                targetUnitConversion: annotation.Calibrate.TargetUnitConversion
            };
            if (annotation.Calibrate.Depth) {
                measureObject.depth = annotation.Calibrate.Depth;
            }
            if (annotation.Bounds && annotation.EnableShapeLabel === true) {
                annotation.LabelBounds =
                    this.pdfViewer.annotationModule.inputElementModule.calculateLabelBoundsFromLoadedDocument(annotation.Bounds);
                annotation.LabelBorderColor = annotation.LabelBorderColor ? annotation.LabelBorderColor : annotation.StrokeColor;
                annotation.FontColor = annotation.FontColor ? annotation.FontColor : annotation.StrokeColor;
                annotation.LabelFillColor = annotation.LabelFillColor ? annotation.LabelFillColor : annotation.FillColor;
                annotation.FontSize = annotation.FontSize ? annotation.FontSize : 16;
                annotation.LabelSettings = annotation.LabelSettings ? annotation.LabelSettings : this.pdfViewer.shapeLabelSettings;
            }
            annotation.allowedInteractions = annotation.AllowedInteractions ?
                annotation.AllowedInteractions : this.pdfViewer.annotationModule.updateAnnotationAllowedInteractions(annotation);
            annotation.AnnotationSettings = annotation.AnnotationSettings ?
                annotation.AnnotationSettings : this.pdfViewer.annotationModule.updateAnnotationSettings(annotation);
            annotation.Author = this.pdfViewer.annotationModule.updateAnnotationAuthor('measure', annotation.Subject, annotation);
            annotationObject = {
                id: 'measure', shapeAnnotationType: annotation.ShapeAnnotationType, author: annotation.Author, allowedInteractions: annotation.allowedInteractions, modifiedDate: annotation.ModifiedDate, subject: annotation.Subject,
                note: annotation.Note, strokeColor: annotation.StrokeColor, fillColor: annotation.FillColor,
                opacity: annotation.Opacity, thickness: annotation.Thickness, rectangleDifference: annotation.RectangleDifference,
                borderStyle: annotation.BorderStyle, borderDashArray: annotation.BorderDashArray,
                rotateAngle: annotation.RotateAngle, isCloudShape: annotation.IsCloudShape,
                cloudIntensity: annotation.CloudIntensity, vertexPoints: vertexPoints,
                lineHeadStart: annotation.LineHeadStart, lineHeadEnd: annotation.LineHeadEnd, isLocked: annotation.IsLocked,
                bounds: { left: annotation.Bounds.X, top: annotation.Bounds.Y, width: annotation.Bounds.Width,
                    height: annotation.Bounds.Height, right: annotation.Bounds.Right, bottom: annotation.Bounds.Bottom },
                caption: annotation.Caption, captionPosition: annotation.CaptionPosition, calibrate: measureObject,
                leaderLength: annotation.LeaderLength, leaderLineExtension: annotation.LeaderLineExtension,
                leaderLineOffset: annotation.LeaderLineOffset, indent: annotation.Indent, annotName: annotation.AnnotName,
                comments: this.pdfViewer.annotationModule.getAnnotationComments(annotation.Comments, annotation, annotation.Author),
                review: { state: annotation.State, stateModel: annotation.StateModel, modifiedDate: annotation.ModifiedDate,
                    author: annotation.Author },
                labelContent: annotation.LabelContent, enableShapeLabel: annotation.EnableShapeLabel, labelFillColor: annotation.LabelFillColor,
                labelBorderColor: annotation.LabelBorderColor, fontColor: annotation.FontColor, fontSize: annotation.FontSize,
                labelBounds: annotation.LabelBounds, annotationSelectorSettings: this.getSettings(annotation),
                labelSettings: annotation.LabelSettings, annotationSettings: annotation.AnnotationSettings,
                customData: this.pdfViewer.annotation.getCustomData(annotation), isPrint: annotation.IsPrint,
                isCommentLock: annotation.IsCommentLock, isAnnotationRotated: false
            };
            this.pdfViewer.annotationModule.storeAnnotations(pageNumber, annotationObject, '_annotations_shape_measure');
        };
        MeasureAnnotation.prototype.updateMeasureAnnotationCollections = function (annotation, pageNumber) {
            var annotationObject = null;
            var vertexPoints = null;
            if (annotation.VertexPoints) {
                vertexPoints = [];
                for (var j = 0; j < annotation.VertexPoints.length; j++) {
                    var point = { x: annotation.VertexPoints[parseInt(j.toString(), 10)].X,
                        y: annotation.VertexPoints[parseInt(j.toString(), 10)].Y };
                    vertexPoints.push(point);
                }
            }
            var measureObject = {
                ratio: annotation.Calibrate.Ratio, x: this.getNumberFormatArray(annotation.Calibrate.X),
                distance: this.getNumberFormatArray(annotation.Calibrate.Distance),
                area: this.getNumberFormatArray(annotation.Calibrate.Area),
                angle: this.getNumberFormatArray(annotation.Calibrate.Angle), volume: this.getNumberFormatArray(annotation.Calibrate.Volume),
                targetUnitConversion: annotation.Calibrate.TargetUnitConversion
            };
            if (annotation.Calibrate.Depth) {
                measureObject.depth = annotation.Calibrate.Depth;
            }
            if (annotation.Bounds && annotation.EnableShapeLabel === true) {
                annotation.LabelBounds =
                    this.pdfViewer.annotationModule.inputElementModule.calculateLabelBoundsFromLoadedDocument(annotation.Bounds);
                annotation.LabelBorderColor = annotation.LabelBorderColor ? annotation.LabelBorderColor : annotation.StrokeColor;
                annotation.FontColor = annotation.FontColor ? annotation.FontColor : annotation.StrokeColor;
                annotation.LabelFillColor = annotation.LabelFillColor ? annotation.LabelFillColor : annotation.FillColor;
                annotation.FontSize = annotation.FontSize ? annotation.FontSize : 16;
                var settings = this.pdfViewer.shapeLabelSettings;
                var labelSettings = { borderColor: annotation.StrokeColor, fillColor: annotation.FillColor, fontColor: annotation.FontColor,
                    fontSize: annotation.FontSize, labelContent: annotation.LabelContent, labelHeight: settings.labelHeight,
                    labelWidth: settings.labelWidth, opacity: annotation.Opacity
                };
                annotation.LabelSettings = annotation.LabelSettings ? annotation.LabelSettings : labelSettings;
            }
            annotation.allowedInteractions = annotation.AllowedInteractions ?
                annotation.AllowedInteractions : this.pdfViewer.annotationModule.updateAnnotationAllowedInteractions(annotation);
            annotation.AnnotationSelectorSettings =
                annotation.AnnotationSelectorSettings ? annotation.AnnotationSelectorSettings :
                    this.pdfViewerBase.annotationSelectorSettingLoad(annotation);
            annotation.AnnotationSettings = annotation.AnnotationSettings ?
                annotation.AnnotationSettings : this.pdfViewer.annotationModule.updateAnnotationSettings(annotation);
            if (annotation.IsLocked) {
                annotation.AnnotationSettings.isLock = annotation.IsLocked;
            }
            annotationObject = {
                id: 'measure', shapeAnnotationType: annotation.ShapeAnnotationType, author: annotation.Author, allowedInteractions: annotation.allowedInteractions, modifiedDate: annotation.ModifiedDate, subject: annotation.Subject,
                note: annotation.Note, strokeColor: annotation.StrokeColor, fillColor: annotation.FillColor,
                opacity: annotation.Opacity, thickness: annotation.Thickness, rectangleDifference: annotation.RectangleDifference,
                borderStyle: annotation.BorderStyle, borderDashArray: annotation.BorderDashArray,
                rotateAngle: annotation.RotateAngle, isCloudShape: annotation.IsCloudShape,
                cloudIntensity: annotation.CloudIntensity, vertexPoints: vertexPoints, lineHeadStart: annotation.LineHeadStart,
                lineHeadEnd: annotation.LineHeadEnd, isLocked: annotation.IsLocked,
                bounds: { left: annotation.Bounds.X, top: annotation.Bounds.Y, width: annotation.Bounds.Width,
                    height: annotation.Bounds.Height, right: annotation.Bounds.Right, bottom: annotation.Bounds.Bottom },
                caption: annotation.Caption, captionPosition: annotation.CaptionPosition, calibrate: measureObject,
                leaderLength: annotation.LeaderLength, leaderLineExtension: annotation.LeaderLineExtension,
                leaderLineOffset: annotation.LeaderLineOffset, indent: annotation.Indent, annotationId: annotation.AnnotName,
                comments: this.pdfViewer.annotationModule.getAnnotationComments(annotation.Comments, annotation, annotation.Author),
                review: { state: annotation.State, stateModel: annotation.StateModel, modifiedDate: annotation.ModifiedDate,
                    author: annotation.Author },
                labelContent: annotation.LabelContent, enableShapeLabel: annotation.EnableShapeLabel, labelFillColor: annotation.LabelFillColor,
                labelBorderColor: annotation.LabelBorderColor, fontColor: annotation.FontColor, fontSize: annotation.FontSize,
                labelBounds: annotation.LabelBounds, pageNumber: pageNumber, annotationSelectorSettings: annotation.AnnotationSelectorSettings,
                labelSettings: annotation.labelSettings, annotationSettings: annotation.AnnotationSettings,
                customData: this.pdfViewer.annotation.getCustomData(annotation), isPrint: annotation.IsPrint,
                isCommentLock: annotation.IsCommentLock
            };
            return annotationObject;
        };
        MeasureAnnotation.prototype.updateAddAnnotationDetails = function (annotationType, annotationObject, offset) {
            if (!annotationObject) {
                annotationObject = { offset: { x: 10, y: 10 }, pageNumber: 0, width: undefined, height: undefined };
                offset = annotationObject.offset;
            }
            else if (!annotationObject.offset) {
                offset = { x: 10, y: 10 };
            }
            else {
                offset = annotationObject.offset;
            }
            var annotationSelectorSettings = null;
            var allowedInteractions = null;
            var annotationSettings = null;
            var measureAnnotationType = '';
            var shapeAnnotationType = '';
            var subject = '';
            var isArrow = false;
            var vertexPoints = [];
            var currentDateString = this.pdfViewer.annotation.stickyNotesAnnotationModule.getDateAndTime();
            var annotationName = this.pdfViewer.annotation.createGUID();
            if (annotationType === 'Distance') {
                annotationSelectorSettings = this.pdfViewer.lineSettings.annotationSelectorSettings;
                this.pdfViewerBase.updateSelectorSettings(annotationSelectorSettings);
                annotationSettings = this.pdfViewer.annotationModule.updateSettings(this.pdfViewer.lineSettings);
                annotationObject.author = annotationObject.author ? annotationObject.author : this.pdfViewer.annotationModule.updateAnnotationAuthor('measure', annotationType);
                allowedInteractions = this.pdfViewer.lineSettings.allowedInteractions ?
                    this.pdfViewer.lineSettings.allowedInteractions : this.pdfViewer.annotationSettings.allowedInteractions;
                measureAnnotationType = 'LineDimension';
                shapeAnnotationType = 'Line';
                subject = this.pdfViewer.lineSettings.subject !== '' ? this.pdfViewer.lineSettings.subject : this.pdfViewer.annotationSettings.subject !== '' ? this.pdfViewer.annotationSettings.subject : 'Distance calculation';
                isArrow = true;
                if (annotationObject.vertexPoints) {
                    vertexPoints = annotationObject.vertexPoints;
                    if (vertexPoints.length === 1) {
                        var createVertexPoint = {
                            x: vertexPoints[0].x + 100,
                            y: vertexPoints[0].y
                        };
                        vertexPoints.push(createVertexPoint);
                    }
                }
                else {
                    vertexPoints = [{ x: offset.x, y: offset.y }, { x: offset.x + 100, y: offset.y }];
                }
                annotationObject.width = annotationObject.width ? annotationObject.width : 1;
                annotationObject.height = annotationObject.height ? annotationObject.height : 1;
            }
            else if (annotationType === 'Perimeter') {
                annotationSelectorSettings = this.pdfViewer.arrowSettings.annotationSelectorSettings;
                this.pdfViewerBase.updateSelectorSettings(annotationSelectorSettings);
                annotationSettings = this.pdfViewer.annotationModule.updateSettings(this.pdfViewer.arrowSettings);
                annotationObject.author = annotationObject.author ? annotationObject.author : this.pdfViewer.annotationModule.updateAnnotationAuthor('measure', annotationType);
                allowedInteractions = this.pdfViewer.arrowSettings.allowedInteractions ?
                    this.pdfViewer.arrowSettings.allowedInteractions : this.pdfViewer.annotationSettings.allowedInteractions;
                measureAnnotationType = 'PolyLineDimension';
                shapeAnnotationType = 'Polyline';
                subject = this.pdfViewer.arrowSettings.subject !== '' ? this.pdfViewer.arrowSettings.subject : this.pdfViewer.annotationSettings.subject !== '' ? this.pdfViewer.annotationSettings.subject : 'Perimeter calculation';
                isArrow = true;
                if (annotationObject.vertexPoints) {
                    vertexPoints = annotationObject.vertexPoints;
                    if (vertexPoints.length === 1) {
                        var createVertexPoint = {
                            x: vertexPoints[0].x + 85,
                            y: vertexPoints[0].y
                        };
                        vertexPoints.push(createVertexPoint);
                        createVertexPoint = {
                            x: vertexPoints[0].x + 86,
                            y: vertexPoints[0].y + 62
                        };
                        vertexPoints.push(createVertexPoint);
                    }
                }
                else {
                    vertexPoints = [{ x: offset.x, y: offset.y },
                        { x: offset.x + 85, y: offset.y },
                        { x: offset.x + 86, y: offset.y + 62 }];
                }
                annotationObject.width = annotationObject.width ? annotationObject.width : 1;
                annotationObject.height = annotationObject.height ? annotationObject.height : 1;
            }
            else if (annotationType === 'Area') {
                annotationSelectorSettings = this.pdfViewer.rectangleSettings.annotationSelectorSettings;
                this.pdfViewerBase.updateSelectorSettings(annotationSelectorSettings);
                annotationSettings = this.pdfViewer.annotationModule.updateSettings(this.pdfViewer.rectangleSettings);
                annotationObject.author = annotationObject.author ? annotationObject.author : this.pdfViewer.annotationModule.updateAnnotationAuthor('measure', annotationType);
                allowedInteractions = this.pdfViewer.rectangleSettings.allowedInteractions ?
                    this.pdfViewer.rectangleSettings.allowedInteractions : this.pdfViewer.annotationSettings.allowedInteractions;
                measureAnnotationType = 'PolygonDimension';
                shapeAnnotationType = 'Polygon';
                subject = this.pdfViewer.rectangleSettings.subject !== '' ? this.pdfViewer.rectangleSettings.subject : this.pdfViewer.annotationSettings.subject !== '' ? this.pdfViewer.annotationSettings.subject : 'Area calculation';
                if (annotationObject.vertexPoints) {
                    vertexPoints = annotationObject.vertexPoints;
                    if (vertexPoints.length === 1) {
                        var createVertexPoint = {
                            x: vertexPoints[0].x + 88,
                            y: vertexPoints[0].y - 1
                        };
                        vertexPoints.push(createVertexPoint);
                        createVertexPoint = {
                            x: vertexPoints[0].x + 89,
                            y: vertexPoints[0].y + 53
                        };
                        vertexPoints.push(createVertexPoint);
                        vertexPoints.push(vertexPoints[0]);
                    }
                }
                else {
                    vertexPoints = [{ x: offset.x, y: offset.y },
                        { x: offset.x + 88, y: offset.y - 1 },
                        { x: offset.x + 89, y: offset.y + 53 },
                        { x: offset.x, y: offset.y }];
                }
                annotationObject.width = annotationObject.width ? annotationObject.width : 1;
                annotationObject.height = annotationObject.height ? annotationObject.height : 1;
            }
            else if (annotationType === 'Radius') {
                annotationSelectorSettings = this.pdfViewer.circleSettings.annotationSelectorSettings;
                this.pdfViewerBase.updateSelectorSettings(annotationSelectorSettings);
                annotationSettings = this.pdfViewer.annotationModule.updateSettings(this.pdfViewer.circleSettings);
                annotationObject.author = annotationObject.author ? annotationObject.author : this.pdfViewer.annotationModule.updateAnnotationAuthor('measure', annotationType);
                allowedInteractions = this.pdfViewer.circleSettings.allowedInteractions ?
                    this.pdfViewer.circleSettings.allowedInteractions : this.pdfViewer.annotationSettings.allowedInteractions;
                measureAnnotationType = 'PolygonRadius';
                shapeAnnotationType = 'Circle';
                subject = this.pdfViewer.circleSettings.subject !== '' ? this.pdfViewer.circleSettings.subject : this.pdfViewer.annotationSettings.subject !== '' ? this.pdfViewer.annotationSettings.subject : 'Radius calculation';
                annotationObject.width = annotationObject.width ? annotationObject.width : 100;
                annotationObject.height = annotationObject.height ? annotationObject.height : 100;
                vertexPoints = null;
            }
            else if (annotationType === 'Volume') {
                annotationSelectorSettings = this.pdfViewer.polygonSettings.annotationSelectorSettings;
                this.pdfViewerBase.updateSelectorSettings(annotationSelectorSettings);
                annotationSettings = this.pdfViewer.annotationModule.updateSettings(this.pdfViewer.polygonSettings);
                annotationObject.author = annotationObject.author ? annotationObject.author : this.pdfViewer.annotationModule.updateAnnotationAuthor('measure', annotationType);
                allowedInteractions = this.pdfViewer.polygonSettings.allowedInteractions ?
                    this.pdfViewer.polygonSettings.allowedInteractions : this.pdfViewer.annotationSettings.allowedInteractions;
                measureAnnotationType = 'PolygonVolume';
                shapeAnnotationType = 'Polygon';
                subject = this.pdfViewer.polygonSettings.subject !== '' ? this.pdfViewer.polygonSettings.subject : this.pdfViewer.annotationSettings.subject !== '' ? this.pdfViewer.annotationSettings.subject : 'Volume calculation';
                if (annotationObject.vertexPoints) {
                    vertexPoints = annotationObject.vertexPoints;
                    if (vertexPoints.length === 1) {
                        var createVertexPoint = {
                            x: vertexPoints[0].x,
                            y: vertexPoints[0].y + 109
                        };
                        vertexPoints.push(createVertexPoint);
                        createVertexPoint = {
                            x: vertexPoints[0].x + 120,
                            y: vertexPoints[0].y + 109
                        };
                        vertexPoints.push(createVertexPoint);
                        createVertexPoint = {
                            x: vertexPoints[0].x + 120,
                            y: vertexPoints[0].y - 1
                        };
                        vertexPoints.push(createVertexPoint);
                        vertexPoints.push(vertexPoints[0]);
                    }
                }
                else {
                    vertexPoints = [
                        { x: offset.x, y: offset.y },
                        { x: offset.x, y: offset.y + 109 },
                        { x: offset.x + 120, y: offset.y + 109 },
                        { x: offset.x + 120, y: offset.y - 1 },
                        { x: offset.x, y: offset.y }
                    ];
                }
                annotationObject.width = annotationObject.width ? annotationObject.width : 1;
                annotationObject.height = annotationObject.height ? annotationObject.height : 1;
            }
            annotationSettings.isLock = annotationObject.isLock ? annotationObject.isLock : annotationSettings.isLock;
            annotationSettings.minHeight = annotationObject.minHeight ? annotationObject.minHeight : annotationSettings.minHeight;
            annotationSettings.minWidth = annotationObject.minWidth ? annotationObject.minWidth : annotationSettings.minWidth;
            annotationSettings.maxWidth = annotationObject.maxWidth ? annotationObject.maxWidth : annotationSettings.maxWidth;
            annotationSettings.maxHeight = annotationObject.maxHeight ? annotationObject.maxHeight : annotationSettings.maxHeight;
            var convUnit = (this.pdfViewer.measurementSettings.conversionUnit
                ? this.pdfViewer.measurementSettings.conversionUnit.toLowerCase()
                : 'in');
            var dispUnit = this.pdfViewer.measurementSettings.displayUnit ?
                this.pdfViewer.measurementSettings.displayUnit.toLowerCase() : 'in';
            var scaleRatioVal = this.pdfViewer.measurementSettings.scaleRatio ?
                this.pdfViewer.measurementSettings.scaleRatio : 1;
            var depthVal = annotationObject.depth ? annotationObject.depth : this.pdfViewer.measurementSettings.depth
                ? this.pdfViewer.measurementSettings.depth : 96;
            var values = {
                depth: depthVal,
                factor: this.getFactor(convUnit),
                ratio: scaleRatioVal,
                unit: dispUnit
            };
            var notes = '';
            if (vertexPoints || annotationType === 'Radius' || annotationType === 'Volume') {
                if (annotationType === 'Distance' || annotationType === 'Perimeter' || annotationType === 'Radius') {
                    var length_1 = 0;
                    if (annotationType === 'Radius') {
                        length_1 = (annotationObject.width / 2) * this.pixelToPointFactor;
                    }
                    else {
                        for (var i = 0; i < vertexPoints.length - 1; i++) {
                            length_1 += Math.sqrt(Math.pow((vertexPoints[parseInt(i.toString(), 10)].x - vertexPoints[i + 1].x), 2)
                                + Math.pow((vertexPoints[parseInt(i.toString(), 10)].y - vertexPoints[i + 1].y), 2));
                        }
                        length_1 = length_1 * this.pixelToPointFactor;
                    }
                    var scaledValue = length_1 * values.ratio;
                    notes = this.convertPointToUnits(values.factor, scaledValue, values.unit);
                }
                else if (annotationType === 'Area' || annotationType === 'Volume') {
                    var area = 0;
                    var j = vertexPoints.length - 1;
                    for (var i = 0; i < vertexPoints.length; i++) {
                        area += (vertexPoints[parseInt(j.toString(), 10)].x * this.pixelToPointFactor *
                            values.factor + vertexPoints[parseInt(i.toString(), 10)].x * this.pixelToPointFactor *
                            values.factor) * (vertexPoints[parseInt(j.toString(), 10)].y * this.pixelToPointFactor *
                            values.factor - vertexPoints[parseInt(i.toString(), 10)].y * this.pixelToPointFactor * values.factor);
                        j = i;
                    }
                    area = (Math.abs((area) / 2.0));
                    if (annotationType === 'Volume') {
                        area = area * ((values.depth * this.convertUnitToPoint(values.unit)) * values.factor) * values.ratio;
                        notes = Math.round(area * 100) / 100 + this.pdfViewer.localeObj.getConstant('cu') + ' ' + this.pdfViewer.localeObj.getConstant(values.unit);
                    }
                    else {
                        notes = Math.round(area * 100) / 100 + this.pdfViewer.localeObj.getConstant('sq') + ' ' + this.pdfViewer.localeObj.getConstant(values.unit);
                    }
                }
            }
            if (vertexPoints) {
                vertexPoints = this.pdfViewer.annotation.getVertexPointsXY(vertexPoints);
            }
            var measureShapeAnnotation = [];
            var shape = {
                AllowedInteractions: annotationObject.allowedInteractions ? annotationObject.allowedInteractions : allowedInteractions,
                AnnotName: annotationName,
                AnnotType: 'shape_measure',
                AnnotationSelectorSettings: annotationObject.annotationSelectorSettings ?
                    annotationObject.annotationSelectorSettings : annotationSelectorSettings,
                AnnotationSettings: annotationSettings,
                Author: annotationObject.author ? annotationObject.author : 'Guest',
                BorderDashArray: annotationObject.borderDashArray ? annotationObject.borderDashArray : 0,
                BorderStyle: 'Solid',
                Bounds: { X: offset.x, Y: offset.y, Width: annotationObject.width, Height: annotationObject.height,
                    Left: offset.x, Top: offset.y, Location: { X: offset.x, Y: offset.y },
                    Size: { Height: annotationObject.height, IsEmpty: false, Width: annotationObject.width } },
                Calibrate: {
                    Area: [{ ConversionFactor: 1, Denominator: 100, FormatDenominator: false, FractionalType: 'D', Unit: 'sq ' + dispUnit }],
                    Depth: depthVal,
                    Distance: [{ ConversionFactor: 1, Denominator: 100, FormatDenominator: false, FractionalType: 'D', Unit: dispUnit }],
                    Ratio: '1 ' + convUnit + ' = ' + scaleRatioVal + ' ' + dispUnit,
                    TargetUnitConversion: 0,
                    Volume: null,
                    X: [{ ConversionFactor: this.getFactor(convUnit), Denominator: 100, FormatDenominator: false, FractionalType: 'D', Unit: dispUnit }]
                },
                Caption: true,
                CaptionPosition: 'Top',
                CloudIntensity: 0,
                Comments: null,
                CustomData: annotationObject.customData ? annotationObject.customData : null,
                CreatedDate: currentDateString,
                EnableShapeLabel: false,
                ExistingCustomData: null,
                FillColor: annotationObject.fillColor ? annotationObject.fillColor : '#ffffff00',
                FontColor: null,
                FontSize: 0,
                Indent: measureAnnotationType,
                IsCloudShape: false,
                IsCommentLock: false,
                IsLocked: annotationObject.isLock ? annotationObject.isLock : false,
                IsPrint: !ej2_base_1.isNullOrUndefined(annotationObject.isPrint) ? annotationObject.isPrint : true,
                LabelBorderColor: null,
                LabelBounds: { X: 0, Y: 0, Width: 0, Height: 0 },
                LabelContent: null,
                LabelFillColor: null,
                LabelSettings: null,
                LeaderLength: !ej2_base_1.isNullOrUndefined(annotationObject.leaderLength) ? annotationObject.leaderLength : 40,
                LeaderLineExtension: 0,
                LeaderLineOffset: 0,
                LineHeadStart: annotationObject.lineHeadStartStyle ? annotationObject.lineHeadStartStyle : isArrow ? 'ClosedArrow' : 'None',
                LineHeadEnd: annotationObject.lineHeadEndStyle ? annotationObject.lineHeadEndStyle : isArrow ? 'ClosedArrow' : 'None',
                ModifiedDate: '',
                Note: notes,
                Opacity: annotationObject.opacity ? annotationObject.opacity : 1,
                RectangleDifference: [],
                RotateAngle: 'RotateAngle0',
                ShapeAnnotationType: shapeAnnotationType,
                State: '',
                StateModel: '',
                StrokeColor: annotationObject.strokeColor ? annotationObject.strokeColor : '#ff0000',
                Subject: annotationObject.subject ? annotationObject.subject : subject,
                Thickness: annotationObject.thickness ? annotationObject.thickness : 1,
                VertexPoints: vertexPoints
            };
            var ratioString = shape.Calibrate.Ratio.split('=').map(function (ratioString) { return ratioString.trim(); });
            var _a = ratioString[0].split(' '), srcValueStr = _a[0], unit = _a[1];
            var _b = ratioString[1].split(' '), destValueStr = _b[0], displayUnit = _b[1];
            var destValue = parseFloat(destValueStr);
            var depthValue = depthVal;
            var srcValue = parseFloat(srcValueStr);
            var scaleRatio = {
                annotName: shape.AnnotName,
                displayUnit: displayUnit,
                unit: unit,
                ratio: destValue / srcValue,
                destValue: destValue,
                srcValue: srcValue,
                volumeDepth: depthValue,
                depthValue: depthValue,
                ratioString: ratioString
            };
            this.scaleRatioCollection.push(scaleRatio);
            measureShapeAnnotation[0] = shape;
            return { measureShapeAnnotation: measureShapeAnnotation };
        };
        return MeasureAnnotation;
    }());
    exports.MeasureAnnotation = MeasureAnnotation;
});