File size: 117,750 Bytes
bc20498 |
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 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 |
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["layoutBase"] = factory();
else
root["layoutBase"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 26);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
function LayoutConstants() {}
/**
* Layout Quality: 0:draft, 1:default, 2:proof
*/
LayoutConstants.QUALITY = 1;
/**
* Default parameters
*/
LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED = false;
LayoutConstants.DEFAULT_INCREMENTAL = false;
LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT = true;
LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT = false;
LayoutConstants.DEFAULT_ANIMATION_PERIOD = 50;
LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES = false;
// -----------------------------------------------------------------------------
// Section: General other constants
// -----------------------------------------------------------------------------
/*
* Margins of a graph to be applied on bouding rectangle of its contents. We
* assume margins on all four sides to be uniform.
*/
LayoutConstants.DEFAULT_GRAPH_MARGIN = 15;
/*
* Whether to consider labels in node dimensions or not
*/
LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = false;
/*
* Default dimension of a non-compound node.
*/
LayoutConstants.SIMPLE_NODE_SIZE = 40;
/*
* Default dimension of a non-compound node.
*/
LayoutConstants.SIMPLE_NODE_HALF_SIZE = LayoutConstants.SIMPLE_NODE_SIZE / 2;
/*
* Empty compound node size. When a compound node is empty, its both
* dimensions should be of this value.
*/
LayoutConstants.EMPTY_COMPOUND_NODE_SIZE = 40;
/*
* Minimum length that an edge should take during layout
*/
LayoutConstants.MIN_EDGE_LENGTH = 1;
/*
* World boundaries that layout operates on
*/
LayoutConstants.WORLD_BOUNDARY = 1000000;
/*
* World boundaries that random positioning can be performed with
*/
LayoutConstants.INITIAL_WORLD_BOUNDARY = LayoutConstants.WORLD_BOUNDARY / 1000;
/*
* Coordinates of the world center
*/
LayoutConstants.WORLD_CENTER_X = 1200;
LayoutConstants.WORLD_CENTER_Y = 900;
module.exports = LayoutConstants;
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var LGraphObject = __webpack_require__(2);
var IGeometry = __webpack_require__(8);
var IMath = __webpack_require__(9);
function LEdge(source, target, vEdge) {
LGraphObject.call(this, vEdge);
this.isOverlapingSourceAndTarget = false;
this.vGraphObject = vEdge;
this.bendpoints = [];
this.source = source;
this.target = target;
}
LEdge.prototype = Object.create(LGraphObject.prototype);
for (var prop in LGraphObject) {
LEdge[prop] = LGraphObject[prop];
}
LEdge.prototype.getSource = function () {
return this.source;
};
LEdge.prototype.getTarget = function () {
return this.target;
};
LEdge.prototype.isInterGraph = function () {
return this.isInterGraph;
};
LEdge.prototype.getLength = function () {
return this.length;
};
LEdge.prototype.isOverlapingSourceAndTarget = function () {
return this.isOverlapingSourceAndTarget;
};
LEdge.prototype.getBendpoints = function () {
return this.bendpoints;
};
LEdge.prototype.getLca = function () {
return this.lca;
};
LEdge.prototype.getSourceInLca = function () {
return this.sourceInLca;
};
LEdge.prototype.getTargetInLca = function () {
return this.targetInLca;
};
LEdge.prototype.getOtherEnd = function (node) {
if (this.source === node) {
return this.target;
} else if (this.target === node) {
return this.source;
} else {
throw "Node is not incident with this edge";
}
};
LEdge.prototype.getOtherEndInGraph = function (node, graph) {
var otherEnd = this.getOtherEnd(node);
var root = graph.getGraphManager().getRoot();
while (true) {
if (otherEnd.getOwner() == graph) {
return otherEnd;
}
if (otherEnd.getOwner() == root) {
break;
}
otherEnd = otherEnd.getOwner().getParent();
}
return null;
};
LEdge.prototype.updateLength = function () {
var clipPointCoordinates = new Array(4);
this.isOverlapingSourceAndTarget = IGeometry.getIntersection(this.target.getRect(), this.source.getRect(), clipPointCoordinates);
if (!this.isOverlapingSourceAndTarget) {
this.lengthX = clipPointCoordinates[0] - clipPointCoordinates[2];
this.lengthY = clipPointCoordinates[1] - clipPointCoordinates[3];
if (Math.abs(this.lengthX) < 1.0) {
this.lengthX = IMath.sign(this.lengthX);
}
if (Math.abs(this.lengthY) < 1.0) {
this.lengthY = IMath.sign(this.lengthY);
}
this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY);
}
};
LEdge.prototype.updateLengthSimple = function () {
this.lengthX = this.target.getCenterX() - this.source.getCenterX();
this.lengthY = this.target.getCenterY() - this.source.getCenterY();
if (Math.abs(this.lengthX) < 1.0) {
this.lengthX = IMath.sign(this.lengthX);
}
if (Math.abs(this.lengthY) < 1.0) {
this.lengthY = IMath.sign(this.lengthY);
}
this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY);
};
module.exports = LEdge;
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
function LGraphObject(vGraphObject) {
this.vGraphObject = vGraphObject;
}
module.exports = LGraphObject;
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var LGraphObject = __webpack_require__(2);
var Integer = __webpack_require__(10);
var RectangleD = __webpack_require__(13);
var LayoutConstants = __webpack_require__(0);
var RandomSeed = __webpack_require__(16);
var PointD = __webpack_require__(4);
function LNode(gm, loc, size, vNode) {
//Alternative constructor 1 : LNode(LGraphManager gm, Point loc, Dimension size, Object vNode)
if (size == null && vNode == null) {
vNode = loc;
}
LGraphObject.call(this, vNode);
//Alternative constructor 2 : LNode(Layout layout, Object vNode)
if (gm.graphManager != null) gm = gm.graphManager;
this.estimatedSize = Integer.MIN_VALUE;
this.inclusionTreeDepth = Integer.MAX_VALUE;
this.vGraphObject = vNode;
this.edges = [];
this.graphManager = gm;
if (size != null && loc != null) this.rect = new RectangleD(loc.x, loc.y, size.width, size.height);else this.rect = new RectangleD();
}
LNode.prototype = Object.create(LGraphObject.prototype);
for (var prop in LGraphObject) {
LNode[prop] = LGraphObject[prop];
}
LNode.prototype.getEdges = function () {
return this.edges;
};
LNode.prototype.getChild = function () {
return this.child;
};
LNode.prototype.getOwner = function () {
// if (this.owner != null) {
// if (!(this.owner == null || this.owner.getNodes().indexOf(this) > -1)) {
// throw "assert failed";
// }
// }
return this.owner;
};
LNode.prototype.getWidth = function () {
return this.rect.width;
};
LNode.prototype.setWidth = function (width) {
this.rect.width = width;
};
LNode.prototype.getHeight = function () {
return this.rect.height;
};
LNode.prototype.setHeight = function (height) {
this.rect.height = height;
};
LNode.prototype.getCenterX = function () {
return this.rect.x + this.rect.width / 2;
};
LNode.prototype.getCenterY = function () {
return this.rect.y + this.rect.height / 2;
};
LNode.prototype.getCenter = function () {
return new PointD(this.rect.x + this.rect.width / 2, this.rect.y + this.rect.height / 2);
};
LNode.prototype.getLocation = function () {
return new PointD(this.rect.x, this.rect.y);
};
LNode.prototype.getRect = function () {
return this.rect;
};
LNode.prototype.getDiagonal = function () {
return Math.sqrt(this.rect.width * this.rect.width + this.rect.height * this.rect.height);
};
/**
* This method returns half the diagonal length of this node.
*/
LNode.prototype.getHalfTheDiagonal = function () {
return Math.sqrt(this.rect.height * this.rect.height + this.rect.width * this.rect.width) / 2;
};
LNode.prototype.setRect = function (upperLeft, dimension) {
this.rect.x = upperLeft.x;
this.rect.y = upperLeft.y;
this.rect.width = dimension.width;
this.rect.height = dimension.height;
};
LNode.prototype.setCenter = function (cx, cy) {
this.rect.x = cx - this.rect.width / 2;
this.rect.y = cy - this.rect.height / 2;
};
LNode.prototype.setLocation = function (x, y) {
this.rect.x = x;
this.rect.y = y;
};
LNode.prototype.moveBy = function (dx, dy) {
this.rect.x += dx;
this.rect.y += dy;
};
LNode.prototype.getEdgeListToNode = function (to) {
var edgeList = [];
var edge;
var self = this;
self.edges.forEach(function (edge) {
if (edge.target == to) {
if (edge.source != self) throw "Incorrect edge source!";
edgeList.push(edge);
}
});
return edgeList;
};
LNode.prototype.getEdgesBetween = function (other) {
var edgeList = [];
var edge;
var self = this;
self.edges.forEach(function (edge) {
if (!(edge.source == self || edge.target == self)) throw "Incorrect edge source and/or target";
if (edge.target == other || edge.source == other) {
edgeList.push(edge);
}
});
return edgeList;
};
LNode.prototype.getNeighborsList = function () {
var neighbors = new Set();
var self = this;
self.edges.forEach(function (edge) {
if (edge.source == self) {
neighbors.add(edge.target);
} else {
if (edge.target != self) {
throw "Incorrect incidency!";
}
neighbors.add(edge.source);
}
});
return neighbors;
};
LNode.prototype.withChildren = function () {
var withNeighborsList = new Set();
var childNode;
var children;
withNeighborsList.add(this);
if (this.child != null) {
var nodes = this.child.getNodes();
for (var i = 0; i < nodes.length; i++) {
childNode = nodes[i];
children = childNode.withChildren();
children.forEach(function (node) {
withNeighborsList.add(node);
});
}
}
return withNeighborsList;
};
LNode.prototype.getNoOfChildren = function () {
var noOfChildren = 0;
var childNode;
if (this.child == null) {
noOfChildren = 1;
} else {
var nodes = this.child.getNodes();
for (var i = 0; i < nodes.length; i++) {
childNode = nodes[i];
noOfChildren += childNode.getNoOfChildren();
}
}
if (noOfChildren == 0) {
noOfChildren = 1;
}
return noOfChildren;
};
LNode.prototype.getEstimatedSize = function () {
if (this.estimatedSize == Integer.MIN_VALUE) {
throw "assert failed";
}
return this.estimatedSize;
};
LNode.prototype.calcEstimatedSize = function () {
if (this.child == null) {
return this.estimatedSize = (this.rect.width + this.rect.height) / 2;
} else {
this.estimatedSize = this.child.calcEstimatedSize();
this.rect.width = this.estimatedSize;
this.rect.height = this.estimatedSize;
return this.estimatedSize;
}
};
LNode.prototype.scatter = function () {
var randomCenterX;
var randomCenterY;
var minX = -LayoutConstants.INITIAL_WORLD_BOUNDARY;
var maxX = LayoutConstants.INITIAL_WORLD_BOUNDARY;
randomCenterX = LayoutConstants.WORLD_CENTER_X + RandomSeed.nextDouble() * (maxX - minX) + minX;
var minY = -LayoutConstants.INITIAL_WORLD_BOUNDARY;
var maxY = LayoutConstants.INITIAL_WORLD_BOUNDARY;
randomCenterY = LayoutConstants.WORLD_CENTER_Y + RandomSeed.nextDouble() * (maxY - minY) + minY;
this.rect.x = randomCenterX;
this.rect.y = randomCenterY;
};
LNode.prototype.updateBounds = function () {
if (this.getChild() == null) {
throw "assert failed";
}
if (this.getChild().getNodes().length != 0) {
// wrap the children nodes by re-arranging the boundaries
var childGraph = this.getChild();
childGraph.updateBounds(true);
this.rect.x = childGraph.getLeft();
this.rect.y = childGraph.getTop();
this.setWidth(childGraph.getRight() - childGraph.getLeft());
this.setHeight(childGraph.getBottom() - childGraph.getTop());
// Update compound bounds considering its label properties
if (LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS) {
var width = childGraph.getRight() - childGraph.getLeft();
var height = childGraph.getBottom() - childGraph.getTop();
if (this.labelWidth > width) {
this.rect.x -= (this.labelWidth - width) / 2;
this.setWidth(this.labelWidth);
}
if (this.labelHeight > height) {
if (this.labelPos == "center") {
this.rect.y -= (this.labelHeight - height) / 2;
} else if (this.labelPos == "top") {
this.rect.y -= this.labelHeight - height;
}
this.setHeight(this.labelHeight);
}
}
}
};
LNode.prototype.getInclusionTreeDepth = function () {
if (this.inclusionTreeDepth == Integer.MAX_VALUE) {
throw "assert failed";
}
return this.inclusionTreeDepth;
};
LNode.prototype.transform = function (trans) {
var left = this.rect.x;
if (left > LayoutConstants.WORLD_BOUNDARY) {
left = LayoutConstants.WORLD_BOUNDARY;
} else if (left < -LayoutConstants.WORLD_BOUNDARY) {
left = -LayoutConstants.WORLD_BOUNDARY;
}
var top = this.rect.y;
if (top > LayoutConstants.WORLD_BOUNDARY) {
top = LayoutConstants.WORLD_BOUNDARY;
} else if (top < -LayoutConstants.WORLD_BOUNDARY) {
top = -LayoutConstants.WORLD_BOUNDARY;
}
var leftTop = new PointD(left, top);
var vLeftTop = trans.inverseTransformPoint(leftTop);
this.setLocation(vLeftTop.x, vLeftTop.y);
};
LNode.prototype.getLeft = function () {
return this.rect.x;
};
LNode.prototype.getRight = function () {
return this.rect.x + this.rect.width;
};
LNode.prototype.getTop = function () {
return this.rect.y;
};
LNode.prototype.getBottom = function () {
return this.rect.y + this.rect.height;
};
LNode.prototype.getParent = function () {
if (this.owner == null) {
return null;
}
return this.owner.getParent();
};
module.exports = LNode;
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
function PointD(x, y) {
if (x == null && y == null) {
this.x = 0;
this.y = 0;
} else {
this.x = x;
this.y = y;
}
}
PointD.prototype.getX = function () {
return this.x;
};
PointD.prototype.getY = function () {
return this.y;
};
PointD.prototype.setX = function (x) {
this.x = x;
};
PointD.prototype.setY = function (y) {
this.y = y;
};
PointD.prototype.getDifference = function (pt) {
return new DimensionD(this.x - pt.x, this.y - pt.y);
};
PointD.prototype.getCopy = function () {
return new PointD(this.x, this.y);
};
PointD.prototype.translate = function (dim) {
this.x += dim.width;
this.y += dim.height;
return this;
};
module.exports = PointD;
/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var LGraphObject = __webpack_require__(2);
var Integer = __webpack_require__(10);
var LayoutConstants = __webpack_require__(0);
var LGraphManager = __webpack_require__(6);
var LNode = __webpack_require__(3);
var LEdge = __webpack_require__(1);
var RectangleD = __webpack_require__(13);
var Point = __webpack_require__(12);
var LinkedList = __webpack_require__(11);
function LGraph(parent, obj2, vGraph) {
LGraphObject.call(this, vGraph);
this.estimatedSize = Integer.MIN_VALUE;
this.margin = LayoutConstants.DEFAULT_GRAPH_MARGIN;
this.edges = [];
this.nodes = [];
this.isConnected = false;
this.parent = parent;
if (obj2 != null && obj2 instanceof LGraphManager) {
this.graphManager = obj2;
} else if (obj2 != null && obj2 instanceof Layout) {
this.graphManager = obj2.graphManager;
}
}
LGraph.prototype = Object.create(LGraphObject.prototype);
for (var prop in LGraphObject) {
LGraph[prop] = LGraphObject[prop];
}
LGraph.prototype.getNodes = function () {
return this.nodes;
};
LGraph.prototype.getEdges = function () {
return this.edges;
};
LGraph.prototype.getGraphManager = function () {
return this.graphManager;
};
LGraph.prototype.getParent = function () {
return this.parent;
};
LGraph.prototype.getLeft = function () {
return this.left;
};
LGraph.prototype.getRight = function () {
return this.right;
};
LGraph.prototype.getTop = function () {
return this.top;
};
LGraph.prototype.getBottom = function () {
return this.bottom;
};
LGraph.prototype.isConnected = function () {
return this.isConnected;
};
LGraph.prototype.add = function (obj1, sourceNode, targetNode) {
if (sourceNode == null && targetNode == null) {
var newNode = obj1;
if (this.graphManager == null) {
throw "Graph has no graph mgr!";
}
if (this.getNodes().indexOf(newNode) > -1) {
throw "Node already in graph!";
}
newNode.owner = this;
this.getNodes().push(newNode);
return newNode;
} else {
var newEdge = obj1;
if (!(this.getNodes().indexOf(sourceNode) > -1 && this.getNodes().indexOf(targetNode) > -1)) {
throw "Source or target not in graph!";
}
if (!(sourceNode.owner == targetNode.owner && sourceNode.owner == this)) {
throw "Both owners must be this graph!";
}
if (sourceNode.owner != targetNode.owner) {
return null;
}
// set source and target
newEdge.source = sourceNode;
newEdge.target = targetNode;
// set as intra-graph edge
newEdge.isInterGraph = false;
// add to graph edge list
this.getEdges().push(newEdge);
// add to incidency lists
sourceNode.edges.push(newEdge);
if (targetNode != sourceNode) {
targetNode.edges.push(newEdge);
}
return newEdge;
}
};
LGraph.prototype.remove = function (obj) {
var node = obj;
if (obj instanceof LNode) {
if (node == null) {
throw "Node is null!";
}
if (!(node.owner != null && node.owner == this)) {
throw "Owner graph is invalid!";
}
if (this.graphManager == null) {
throw "Owner graph manager is invalid!";
}
// remove incident edges first (make a copy to do it safely)
var edgesToBeRemoved = node.edges.slice();
var edge;
var s = edgesToBeRemoved.length;
for (var i = 0; i < s; i++) {
edge = edgesToBeRemoved[i];
if (edge.isInterGraph) {
this.graphManager.remove(edge);
} else {
edge.source.owner.remove(edge);
}
}
// now the node itself
var index = this.nodes.indexOf(node);
if (index == -1) {
throw "Node not in owner node list!";
}
this.nodes.splice(index, 1);
} else if (obj instanceof LEdge) {
var edge = obj;
if (edge == null) {
throw "Edge is null!";
}
if (!(edge.source != null && edge.target != null)) {
throw "Source and/or target is null!";
}
if (!(edge.source.owner != null && edge.target.owner != null && edge.source.owner == this && edge.target.owner == this)) {
throw "Source and/or target owner is invalid!";
}
var sourceIndex = edge.source.edges.indexOf(edge);
var targetIndex = edge.target.edges.indexOf(edge);
if (!(sourceIndex > -1 && targetIndex > -1)) {
throw "Source and/or target doesn't know this edge!";
}
edge.source.edges.splice(sourceIndex, 1);
if (edge.target != edge.source) {
edge.target.edges.splice(targetIndex, 1);
}
var index = edge.source.owner.getEdges().indexOf(edge);
if (index == -1) {
throw "Not in owner's edge list!";
}
edge.source.owner.getEdges().splice(index, 1);
}
};
LGraph.prototype.updateLeftTop = function () {
var top = Integer.MAX_VALUE;
var left = Integer.MAX_VALUE;
var nodeTop;
var nodeLeft;
var margin;
var nodes = this.getNodes();
var s = nodes.length;
for (var i = 0; i < s; i++) {
var lNode = nodes[i];
nodeTop = lNode.getTop();
nodeLeft = lNode.getLeft();
if (top > nodeTop) {
top = nodeTop;
}
if (left > nodeLeft) {
left = nodeLeft;
}
}
// Do we have any nodes in this graph?
if (top == Integer.MAX_VALUE) {
return null;
}
if (nodes[0].getParent().paddingLeft != undefined) {
margin = nodes[0].getParent().paddingLeft;
} else {
margin = this.margin;
}
this.left = left - margin;
this.top = top - margin;
// Apply the margins and return the result
return new Point(this.left, this.top);
};
LGraph.prototype.updateBounds = function (recursive) {
// calculate bounds
var left = Integer.MAX_VALUE;
var right = -Integer.MAX_VALUE;
var top = Integer.MAX_VALUE;
var bottom = -Integer.MAX_VALUE;
var nodeLeft;
var nodeRight;
var nodeTop;
var nodeBottom;
var margin;
var nodes = this.nodes;
var s = nodes.length;
for (var i = 0; i < s; i++) {
var lNode = nodes[i];
if (recursive && lNode.child != null) {
lNode.updateBounds();
}
nodeLeft = lNode.getLeft();
nodeRight = lNode.getRight();
nodeTop = lNode.getTop();
nodeBottom = lNode.getBottom();
if (left > nodeLeft) {
left = nodeLeft;
}
if (right < nodeRight) {
right = nodeRight;
}
if (top > nodeTop) {
top = nodeTop;
}
if (bottom < nodeBottom) {
bottom = nodeBottom;
}
}
var boundingRect = new RectangleD(left, top, right - left, bottom - top);
if (left == Integer.MAX_VALUE) {
this.left = this.parent.getLeft();
this.right = this.parent.getRight();
this.top = this.parent.getTop();
this.bottom = this.parent.getBottom();
}
if (nodes[0].getParent().paddingLeft != undefined) {
margin = nodes[0].getParent().paddingLeft;
} else {
margin = this.margin;
}
this.left = boundingRect.x - margin;
this.right = boundingRect.x + boundingRect.width + margin;
this.top = boundingRect.y - margin;
this.bottom = boundingRect.y + boundingRect.height + margin;
};
LGraph.calculateBounds = function (nodes) {
var left = Integer.MAX_VALUE;
var right = -Integer.MAX_VALUE;
var top = Integer.MAX_VALUE;
var bottom = -Integer.MAX_VALUE;
var nodeLeft;
var nodeRight;
var nodeTop;
var nodeBottom;
var s = nodes.length;
for (var i = 0; i < s; i++) {
var lNode = nodes[i];
nodeLeft = lNode.getLeft();
nodeRight = lNode.getRight();
nodeTop = lNode.getTop();
nodeBottom = lNode.getBottom();
if (left > nodeLeft) {
left = nodeLeft;
}
if (right < nodeRight) {
right = nodeRight;
}
if (top > nodeTop) {
top = nodeTop;
}
if (bottom < nodeBottom) {
bottom = nodeBottom;
}
}
var boundingRect = new RectangleD(left, top, right - left, bottom - top);
return boundingRect;
};
LGraph.prototype.getInclusionTreeDepth = function () {
if (this == this.graphManager.getRoot()) {
return 1;
} else {
return this.parent.getInclusionTreeDepth();
}
};
LGraph.prototype.getEstimatedSize = function () {
if (this.estimatedSize == Integer.MIN_VALUE) {
throw "assert failed";
}
return this.estimatedSize;
};
LGraph.prototype.calcEstimatedSize = function () {
var size = 0;
var nodes = this.nodes;
var s = nodes.length;
for (var i = 0; i < s; i++) {
var lNode = nodes[i];
size += lNode.calcEstimatedSize();
}
if (size == 0) {
this.estimatedSize = LayoutConstants.EMPTY_COMPOUND_NODE_SIZE;
} else {
this.estimatedSize = size / Math.sqrt(this.nodes.length);
}
return this.estimatedSize;
};
LGraph.prototype.updateConnected = function () {
var self = this;
if (this.nodes.length == 0) {
this.isConnected = true;
return;
}
var queue = new LinkedList();
var visited = new Set();
var currentNode = this.nodes[0];
var neighborEdges;
var currentNeighbor;
var childrenOfNode = currentNode.withChildren();
childrenOfNode.forEach(function (node) {
queue.push(node);
visited.add(node);
});
while (queue.length !== 0) {
currentNode = queue.shift();
// Traverse all neighbors of this node
neighborEdges = currentNode.getEdges();
var size = neighborEdges.length;
for (var i = 0; i < size; i++) {
var neighborEdge = neighborEdges[i];
currentNeighbor = neighborEdge.getOtherEndInGraph(currentNode, this);
// Add unvisited neighbors to the list to visit
if (currentNeighbor != null && !visited.has(currentNeighbor)) {
var childrenOfNeighbor = currentNeighbor.withChildren();
childrenOfNeighbor.forEach(function (node) {
queue.push(node);
visited.add(node);
});
}
}
}
this.isConnected = false;
if (visited.size >= this.nodes.length) {
var noOfVisitedInThisGraph = 0;
visited.forEach(function (visitedNode) {
if (visitedNode.owner == self) {
noOfVisitedInThisGraph++;
}
});
if (noOfVisitedInThisGraph == this.nodes.length) {
this.isConnected = true;
}
}
};
module.exports = LGraph;
/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var LGraph;
var LEdge = __webpack_require__(1);
function LGraphManager(layout) {
LGraph = __webpack_require__(5); // It may be better to initilize this out of this function but it gives an error (Right-hand side of 'instanceof' is not callable) now.
this.layout = layout;
this.graphs = [];
this.edges = [];
}
LGraphManager.prototype.addRoot = function () {
var ngraph = this.layout.newGraph();
var nnode = this.layout.newNode(null);
var root = this.add(ngraph, nnode);
this.setRootGraph(root);
return this.rootGraph;
};
LGraphManager.prototype.add = function (newGraph, parentNode, newEdge, sourceNode, targetNode) {
//there are just 2 parameters are passed then it adds an LGraph else it adds an LEdge
if (newEdge == null && sourceNode == null && targetNode == null) {
if (newGraph == null) {
throw "Graph is null!";
}
if (parentNode == null) {
throw "Parent node is null!";
}
if (this.graphs.indexOf(newGraph) > -1) {
throw "Graph already in this graph mgr!";
}
this.graphs.push(newGraph);
if (newGraph.parent != null) {
throw "Already has a parent!";
}
if (parentNode.child != null) {
throw "Already has a child!";
}
newGraph.parent = parentNode;
parentNode.child = newGraph;
return newGraph;
} else {
//change the order of the parameters
targetNode = newEdge;
sourceNode = parentNode;
newEdge = newGraph;
var sourceGraph = sourceNode.getOwner();
var targetGraph = targetNode.getOwner();
if (!(sourceGraph != null && sourceGraph.getGraphManager() == this)) {
throw "Source not in this graph mgr!";
}
if (!(targetGraph != null && targetGraph.getGraphManager() == this)) {
throw "Target not in this graph mgr!";
}
if (sourceGraph == targetGraph) {
newEdge.isInterGraph = false;
return sourceGraph.add(newEdge, sourceNode, targetNode);
} else {
newEdge.isInterGraph = true;
// set source and target
newEdge.source = sourceNode;
newEdge.target = targetNode;
// add edge to inter-graph edge list
if (this.edges.indexOf(newEdge) > -1) {
throw "Edge already in inter-graph edge list!";
}
this.edges.push(newEdge);
// add edge to source and target incidency lists
if (!(newEdge.source != null && newEdge.target != null)) {
throw "Edge source and/or target is null!";
}
if (!(newEdge.source.edges.indexOf(newEdge) == -1 && newEdge.target.edges.indexOf(newEdge) == -1)) {
throw "Edge already in source and/or target incidency list!";
}
newEdge.source.edges.push(newEdge);
newEdge.target.edges.push(newEdge);
return newEdge;
}
}
};
LGraphManager.prototype.remove = function (lObj) {
if (lObj instanceof LGraph) {
var graph = lObj;
if (graph.getGraphManager() != this) {
throw "Graph not in this graph mgr";
}
if (!(graph == this.rootGraph || graph.parent != null && graph.parent.graphManager == this)) {
throw "Invalid parent node!";
}
// first the edges (make a copy to do it safely)
var edgesToBeRemoved = [];
edgesToBeRemoved = edgesToBeRemoved.concat(graph.getEdges());
var edge;
var s = edgesToBeRemoved.length;
for (var i = 0; i < s; i++) {
edge = edgesToBeRemoved[i];
graph.remove(edge);
}
// then the nodes (make a copy to do it safely)
var nodesToBeRemoved = [];
nodesToBeRemoved = nodesToBeRemoved.concat(graph.getNodes());
var node;
s = nodesToBeRemoved.length;
for (var i = 0; i < s; i++) {
node = nodesToBeRemoved[i];
graph.remove(node);
}
// check if graph is the root
if (graph == this.rootGraph) {
this.setRootGraph(null);
}
// now remove the graph itself
var index = this.graphs.indexOf(graph);
this.graphs.splice(index, 1);
// also reset the parent of the graph
graph.parent = null;
} else if (lObj instanceof LEdge) {
edge = lObj;
if (edge == null) {
throw "Edge is null!";
}
if (!edge.isInterGraph) {
throw "Not an inter-graph edge!";
}
if (!(edge.source != null && edge.target != null)) {
throw "Source and/or target is null!";
}
// remove edge from source and target nodes' incidency lists
if (!(edge.source.edges.indexOf(edge) != -1 && edge.target.edges.indexOf(edge) != -1)) {
throw "Source and/or target doesn't know this edge!";
}
var index = edge.source.edges.indexOf(edge);
edge.source.edges.splice(index, 1);
index = edge.target.edges.indexOf(edge);
edge.target.edges.splice(index, 1);
// remove edge from owner graph manager's inter-graph edge list
if (!(edge.source.owner != null && edge.source.owner.getGraphManager() != null)) {
throw "Edge owner graph or owner graph manager is null!";
}
if (edge.source.owner.getGraphManager().edges.indexOf(edge) == -1) {
throw "Not in owner graph manager's edge list!";
}
var index = edge.source.owner.getGraphManager().edges.indexOf(edge);
edge.source.owner.getGraphManager().edges.splice(index, 1);
}
};
LGraphManager.prototype.updateBounds = function () {
this.rootGraph.updateBounds(true);
};
LGraphManager.prototype.getGraphs = function () {
return this.graphs;
};
LGraphManager.prototype.getAllNodes = function () {
if (this.allNodes == null) {
var nodeList = [];
var graphs = this.getGraphs();
var s = graphs.length;
for (var i = 0; i < s; i++) {
nodeList = nodeList.concat(graphs[i].getNodes());
}
this.allNodes = nodeList;
}
return this.allNodes;
};
LGraphManager.prototype.resetAllNodes = function () {
this.allNodes = null;
};
LGraphManager.prototype.resetAllEdges = function () {
this.allEdges = null;
};
LGraphManager.prototype.resetAllNodesToApplyGravitation = function () {
this.allNodesToApplyGravitation = null;
};
LGraphManager.prototype.getAllEdges = function () {
if (this.allEdges == null) {
var edgeList = [];
var graphs = this.getGraphs();
var s = graphs.length;
for (var i = 0; i < graphs.length; i++) {
edgeList = edgeList.concat(graphs[i].getEdges());
}
edgeList = edgeList.concat(this.edges);
this.allEdges = edgeList;
}
return this.allEdges;
};
LGraphManager.prototype.getAllNodesToApplyGravitation = function () {
return this.allNodesToApplyGravitation;
};
LGraphManager.prototype.setAllNodesToApplyGravitation = function (nodeList) {
if (this.allNodesToApplyGravitation != null) {
throw "assert failed";
}
this.allNodesToApplyGravitation = nodeList;
};
LGraphManager.prototype.getRoot = function () {
return this.rootGraph;
};
LGraphManager.prototype.setRootGraph = function (graph) {
if (graph.getGraphManager() != this) {
throw "Root not in this graph mgr!";
}
this.rootGraph = graph;
// root graph must have a root node associated with it for convenience
if (graph.parent == null) {
graph.parent = this.layout.newNode("Root node");
}
};
LGraphManager.prototype.getLayout = function () {
return this.layout;
};
LGraphManager.prototype.isOneAncestorOfOther = function (firstNode, secondNode) {
if (!(firstNode != null && secondNode != null)) {
throw "assert failed";
}
if (firstNode == secondNode) {
return true;
}
// Is second node an ancestor of the first one?
var ownerGraph = firstNode.getOwner();
var parentNode;
do {
parentNode = ownerGraph.getParent();
if (parentNode == null) {
break;
}
if (parentNode == secondNode) {
return true;
}
ownerGraph = parentNode.getOwner();
if (ownerGraph == null) {
break;
}
} while (true);
// Is first node an ancestor of the second one?
ownerGraph = secondNode.getOwner();
do {
parentNode = ownerGraph.getParent();
if (parentNode == null) {
break;
}
if (parentNode == firstNode) {
return true;
}
ownerGraph = parentNode.getOwner();
if (ownerGraph == null) {
break;
}
} while (true);
return false;
};
LGraphManager.prototype.calcLowestCommonAncestors = function () {
var edge;
var sourceNode;
var targetNode;
var sourceAncestorGraph;
var targetAncestorGraph;
var edges = this.getAllEdges();
var s = edges.length;
for (var i = 0; i < s; i++) {
edge = edges[i];
sourceNode = edge.source;
targetNode = edge.target;
edge.lca = null;
edge.sourceInLca = sourceNode;
edge.targetInLca = targetNode;
if (sourceNode == targetNode) {
edge.lca = sourceNode.getOwner();
continue;
}
sourceAncestorGraph = sourceNode.getOwner();
while (edge.lca == null) {
edge.targetInLca = targetNode;
targetAncestorGraph = targetNode.getOwner();
while (edge.lca == null) {
if (targetAncestorGraph == sourceAncestorGraph) {
edge.lca = targetAncestorGraph;
break;
}
if (targetAncestorGraph == this.rootGraph) {
break;
}
if (edge.lca != null) {
throw "assert failed";
}
edge.targetInLca = targetAncestorGraph.getParent();
targetAncestorGraph = edge.targetInLca.getOwner();
}
if (sourceAncestorGraph == this.rootGraph) {
break;
}
if (edge.lca == null) {
edge.sourceInLca = sourceAncestorGraph.getParent();
sourceAncestorGraph = edge.sourceInLca.getOwner();
}
}
if (edge.lca == null) {
throw "assert failed";
}
}
};
LGraphManager.prototype.calcLowestCommonAncestor = function (firstNode, secondNode) {
if (firstNode == secondNode) {
return firstNode.getOwner();
}
var firstOwnerGraph = firstNode.getOwner();
do {
if (firstOwnerGraph == null) {
break;
}
var secondOwnerGraph = secondNode.getOwner();
do {
if (secondOwnerGraph == null) {
break;
}
if (secondOwnerGraph == firstOwnerGraph) {
return secondOwnerGraph;
}
secondOwnerGraph = secondOwnerGraph.getParent().getOwner();
} while (true);
firstOwnerGraph = firstOwnerGraph.getParent().getOwner();
} while (true);
return firstOwnerGraph;
};
LGraphManager.prototype.calcInclusionTreeDepths = function (graph, depth) {
if (graph == null && depth == null) {
graph = this.rootGraph;
depth = 1;
}
var node;
var nodes = graph.getNodes();
var s = nodes.length;
for (var i = 0; i < s; i++) {
node = nodes[i];
node.inclusionTreeDepth = depth;
if (node.child != null) {
this.calcInclusionTreeDepths(node.child, depth + 1);
}
}
};
LGraphManager.prototype.includesInvalidEdge = function () {
var edge;
var s = this.edges.length;
for (var i = 0; i < s; i++) {
edge = this.edges[i];
if (this.isOneAncestorOfOther(edge.source, edge.target)) {
return true;
}
}
return false;
};
module.exports = LGraphManager;
/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var LayoutConstants = __webpack_require__(0);
function FDLayoutConstants() {}
//FDLayoutConstants inherits static props in LayoutConstants
for (var prop in LayoutConstants) {
FDLayoutConstants[prop] = LayoutConstants[prop];
}
FDLayoutConstants.MAX_ITERATIONS = 2500;
FDLayoutConstants.DEFAULT_EDGE_LENGTH = 50;
FDLayoutConstants.DEFAULT_SPRING_STRENGTH = 0.45;
FDLayoutConstants.DEFAULT_REPULSION_STRENGTH = 4500.0;
FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH = 0.4;
FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH = 1.0;
FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR = 3.8;
FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = 1.5;
FDLayoutConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION = true;
FDLayoutConstants.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION = true;
FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL = 0.3;
FDLayoutConstants.COOLING_ADAPTATION_FACTOR = 0.33;
FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT = 1000;
FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT = 5000;
FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL = 100.0;
FDLayoutConstants.MAX_NODE_DISPLACEMENT = FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL * 3;
FDLayoutConstants.MIN_REPULSION_DIST = FDLayoutConstants.DEFAULT_EDGE_LENGTH / 10.0;
FDLayoutConstants.CONVERGENCE_CHECK_PERIOD = 100;
FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = 0.1;
FDLayoutConstants.MIN_EDGE_LENGTH = 1;
FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD = 10;
module.exports = FDLayoutConstants;
/***/ }),
/* 8 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* This class maintains a list of static geometry related utility methods.
*
*
* Copyright: i-Vis Research Group, Bilkent University, 2007 - present
*/
var Point = __webpack_require__(12);
function IGeometry() {}
/**
* This method calculates *half* the amount in x and y directions of the two
* input rectangles needed to separate them keeping their respective
* positioning, and returns the result in the input array. An input
* separation buffer added to the amount in both directions. We assume that
* the two rectangles do intersect.
*/
IGeometry.calcSeparationAmount = function (rectA, rectB, overlapAmount, separationBuffer) {
if (!rectA.intersects(rectB)) {
throw "assert failed";
}
var directions = new Array(2);
this.decideDirectionsForOverlappingNodes(rectA, rectB, directions);
overlapAmount[0] = Math.min(rectA.getRight(), rectB.getRight()) - Math.max(rectA.x, rectB.x);
overlapAmount[1] = Math.min(rectA.getBottom(), rectB.getBottom()) - Math.max(rectA.y, rectB.y);
// update the overlapping amounts for the following cases:
if (rectA.getX() <= rectB.getX() && rectA.getRight() >= rectB.getRight()) {
/* Case x.1:
*
* rectA
* | |
* | _________ |
* | | | |
* |________|_______|______|
* | |
* | |
* rectB
*/
overlapAmount[0] += Math.min(rectB.getX() - rectA.getX(), rectA.getRight() - rectB.getRight());
} else if (rectB.getX() <= rectA.getX() && rectB.getRight() >= rectA.getRight()) {
/* Case x.2:
*
* rectB
* | |
* | _________ |
* | | | |
* |________|_______|______|
* | |
* | |
* rectA
*/
overlapAmount[0] += Math.min(rectA.getX() - rectB.getX(), rectB.getRight() - rectA.getRight());
}
if (rectA.getY() <= rectB.getY() && rectA.getBottom() >= rectB.getBottom()) {
/* Case y.1:
* ________ rectA
* |
* |
* ______|____ rectB
* | |
* | |
* ______|____|
* |
* |
* |________
*
*/
overlapAmount[1] += Math.min(rectB.getY() - rectA.getY(), rectA.getBottom() - rectB.getBottom());
} else if (rectB.getY() <= rectA.getY() && rectB.getBottom() >= rectA.getBottom()) {
/* Case y.2:
* ________ rectB
* |
* |
* ______|____ rectA
* | |
* | |
* ______|____|
* |
* |
* |________
*
*/
overlapAmount[1] += Math.min(rectA.getY() - rectB.getY(), rectB.getBottom() - rectA.getBottom());
}
// find slope of the line passes two centers
var slope = Math.abs((rectB.getCenterY() - rectA.getCenterY()) / (rectB.getCenterX() - rectA.getCenterX()));
// if centers are overlapped
if (rectB.getCenterY() === rectA.getCenterY() && rectB.getCenterX() === rectA.getCenterX()) {
// assume the slope is 1 (45 degree)
slope = 1.0;
}
var moveByY = slope * overlapAmount[0];
var moveByX = overlapAmount[1] / slope;
if (overlapAmount[0] < moveByX) {
moveByX = overlapAmount[0];
} else {
moveByY = overlapAmount[1];
}
// return half the amount so that if each rectangle is moved by these
// amounts in opposite directions, overlap will be resolved
overlapAmount[0] = -1 * directions[0] * (moveByX / 2 + separationBuffer);
overlapAmount[1] = -1 * directions[1] * (moveByY / 2 + separationBuffer);
};
/**
* This method decides the separation direction of overlapping nodes
*
* if directions[0] = -1, then rectA goes left
* if directions[0] = 1, then rectA goes right
* if directions[1] = -1, then rectA goes up
* if directions[1] = 1, then rectA goes down
*/
IGeometry.decideDirectionsForOverlappingNodes = function (rectA, rectB, directions) {
if (rectA.getCenterX() < rectB.getCenterX()) {
directions[0] = -1;
} else {
directions[0] = 1;
}
if (rectA.getCenterY() < rectB.getCenterY()) {
directions[1] = -1;
} else {
directions[1] = 1;
}
};
/**
* This method calculates the intersection (clipping) points of the two
* input rectangles with line segment defined by the centers of these two
* rectangles. The clipping points are saved in the input double array and
* whether or not the two rectangles overlap is returned.
*/
IGeometry.getIntersection2 = function (rectA, rectB, result) {
//result[0-1] will contain clipPoint of rectA, result[2-3] will contain clipPoint of rectB
var p1x = rectA.getCenterX();
var p1y = rectA.getCenterY();
var p2x = rectB.getCenterX();
var p2y = rectB.getCenterY();
//if two rectangles intersect, then clipping points are centers
if (rectA.intersects(rectB)) {
result[0] = p1x;
result[1] = p1y;
result[2] = p2x;
result[3] = p2y;
return true;
}
//variables for rectA
var topLeftAx = rectA.getX();
var topLeftAy = rectA.getY();
var topRightAx = rectA.getRight();
var bottomLeftAx = rectA.getX();
var bottomLeftAy = rectA.getBottom();
var bottomRightAx = rectA.getRight();
var halfWidthA = rectA.getWidthHalf();
var halfHeightA = rectA.getHeightHalf();
//variables for rectB
var topLeftBx = rectB.getX();
var topLeftBy = rectB.getY();
var topRightBx = rectB.getRight();
var bottomLeftBx = rectB.getX();
var bottomLeftBy = rectB.getBottom();
var bottomRightBx = rectB.getRight();
var halfWidthB = rectB.getWidthHalf();
var halfHeightB = rectB.getHeightHalf();
//flag whether clipping points are found
var clipPointAFound = false;
var clipPointBFound = false;
// line is vertical
if (p1x === p2x) {
if (p1y > p2y) {
result[0] = p1x;
result[1] = topLeftAy;
result[2] = p2x;
result[3] = bottomLeftBy;
return false;
} else if (p1y < p2y) {
result[0] = p1x;
result[1] = bottomLeftAy;
result[2] = p2x;
result[3] = topLeftBy;
return false;
} else {
//not line, return null;
}
}
// line is horizontal
else if (p1y === p2y) {
if (p1x > p2x) {
result[0] = topLeftAx;
result[1] = p1y;
result[2] = topRightBx;
result[3] = p2y;
return false;
} else if (p1x < p2x) {
result[0] = topRightAx;
result[1] = p1y;
result[2] = topLeftBx;
result[3] = p2y;
return false;
} else {
//not valid line, return null;
}
} else {
//slopes of rectA's and rectB's diagonals
var slopeA = rectA.height / rectA.width;
var slopeB = rectB.height / rectB.width;
//slope of line between center of rectA and center of rectB
var slopePrime = (p2y - p1y) / (p2x - p1x);
var cardinalDirectionA = void 0;
var cardinalDirectionB = void 0;
var tempPointAx = void 0;
var tempPointAy = void 0;
var tempPointBx = void 0;
var tempPointBy = void 0;
//determine whether clipping point is the corner of nodeA
if (-slopeA === slopePrime) {
if (p1x > p2x) {
result[0] = bottomLeftAx;
result[1] = bottomLeftAy;
clipPointAFound = true;
} else {
result[0] = topRightAx;
result[1] = topLeftAy;
clipPointAFound = true;
}
} else if (slopeA === slopePrime) {
if (p1x > p2x) {
result[0] = topLeftAx;
result[1] = topLeftAy;
clipPointAFound = true;
} else {
result[0] = bottomRightAx;
result[1] = bottomLeftAy;
clipPointAFound = true;
}
}
//determine whether clipping point is the corner of nodeB
if (-slopeB === slopePrime) {
if (p2x > p1x) {
result[2] = bottomLeftBx;
result[3] = bottomLeftBy;
clipPointBFound = true;
} else {
result[2] = topRightBx;
result[3] = topLeftBy;
clipPointBFound = true;
}
} else if (slopeB === slopePrime) {
if (p2x > p1x) {
result[2] = topLeftBx;
result[3] = topLeftBy;
clipPointBFound = true;
} else {
result[2] = bottomRightBx;
result[3] = bottomLeftBy;
clipPointBFound = true;
}
}
//if both clipping points are corners
if (clipPointAFound && clipPointBFound) {
return false;
}
//determine Cardinal Direction of rectangles
if (p1x > p2x) {
if (p1y > p2y) {
cardinalDirectionA = this.getCardinalDirection(slopeA, slopePrime, 4);
cardinalDirectionB = this.getCardinalDirection(slopeB, slopePrime, 2);
} else {
cardinalDirectionA = this.getCardinalDirection(-slopeA, slopePrime, 3);
cardinalDirectionB = this.getCardinalDirection(-slopeB, slopePrime, 1);
}
} else {
if (p1y > p2y) {
cardinalDirectionA = this.getCardinalDirection(-slopeA, slopePrime, 1);
cardinalDirectionB = this.getCardinalDirection(-slopeB, slopePrime, 3);
} else {
cardinalDirectionA = this.getCardinalDirection(slopeA, slopePrime, 2);
cardinalDirectionB = this.getCardinalDirection(slopeB, slopePrime, 4);
}
}
//calculate clipping Point if it is not found before
if (!clipPointAFound) {
switch (cardinalDirectionA) {
case 1:
tempPointAy = topLeftAy;
tempPointAx = p1x + -halfHeightA / slopePrime;
result[0] = tempPointAx;
result[1] = tempPointAy;
break;
case 2:
tempPointAx = bottomRightAx;
tempPointAy = p1y + halfWidthA * slopePrime;
result[0] = tempPointAx;
result[1] = tempPointAy;
break;
case 3:
tempPointAy = bottomLeftAy;
tempPointAx = p1x + halfHeightA / slopePrime;
result[0] = tempPointAx;
result[1] = tempPointAy;
break;
case 4:
tempPointAx = bottomLeftAx;
tempPointAy = p1y + -halfWidthA * slopePrime;
result[0] = tempPointAx;
result[1] = tempPointAy;
break;
}
}
if (!clipPointBFound) {
switch (cardinalDirectionB) {
case 1:
tempPointBy = topLeftBy;
tempPointBx = p2x + -halfHeightB / slopePrime;
result[2] = tempPointBx;
result[3] = tempPointBy;
break;
case 2:
tempPointBx = bottomRightBx;
tempPointBy = p2y + halfWidthB * slopePrime;
result[2] = tempPointBx;
result[3] = tempPointBy;
break;
case 3:
tempPointBy = bottomLeftBy;
tempPointBx = p2x + halfHeightB / slopePrime;
result[2] = tempPointBx;
result[3] = tempPointBy;
break;
case 4:
tempPointBx = bottomLeftBx;
tempPointBy = p2y + -halfWidthB * slopePrime;
result[2] = tempPointBx;
result[3] = tempPointBy;
break;
}
}
}
return false;
};
/**
* This method returns in which cardinal direction does input point stays
* 1: North
* 2: East
* 3: South
* 4: West
*/
IGeometry.getCardinalDirection = function (slope, slopePrime, line) {
if (slope > slopePrime) {
return line;
} else {
return 1 + line % 4;
}
};
/**
* This method calculates the intersection of the two lines defined by
* point pairs (s1,s2) and (f1,f2).
*/
IGeometry.getIntersection = function (s1, s2, f1, f2) {
if (f2 == null) {
return this.getIntersection2(s1, s2, f1);
}
var x1 = s1.x;
var y1 = s1.y;
var x2 = s2.x;
var y2 = s2.y;
var x3 = f1.x;
var y3 = f1.y;
var x4 = f2.x;
var y4 = f2.y;
var x = void 0,
y = void 0; // intersection point
var a1 = void 0,
a2 = void 0,
b1 = void 0,
b2 = void 0,
c1 = void 0,
c2 = void 0; // coefficients of line eqns.
var denom = void 0;
a1 = y2 - y1;
b1 = x1 - x2;
c1 = x2 * y1 - x1 * y2; // { a1*x + b1*y + c1 = 0 is line 1 }
a2 = y4 - y3;
b2 = x3 - x4;
c2 = x4 * y3 - x3 * y4; // { a2*x + b2*y + c2 = 0 is line 2 }
denom = a1 * b2 - a2 * b1;
if (denom === 0) {
return null;
}
x = (b1 * c2 - b2 * c1) / denom;
y = (a2 * c1 - a1 * c2) / denom;
return new Point(x, y);
};
/**
* This method finds and returns the angle of the vector from the + x-axis
* in clockwise direction (compatible w/ Java coordinate system!).
*/
IGeometry.angleOfVector = function (Cx, Cy, Nx, Ny) {
var C_angle = void 0;
if (Cx !== Nx) {
C_angle = Math.atan((Ny - Cy) / (Nx - Cx));
if (Nx < Cx) {
C_angle += Math.PI;
} else if (Ny < Cy) {
C_angle += this.TWO_PI;
}
} else if (Ny < Cy) {
C_angle = this.ONE_AND_HALF_PI; // 270 degrees
} else {
C_angle = this.HALF_PI; // 90 degrees
}
return C_angle;
};
/**
* This method checks whether the given two line segments (one with point
* p1 and p2, the other with point p3 and p4) intersect at a point other
* than these points.
*/
IGeometry.doIntersect = function (p1, p2, p3, p4) {
var a = p1.x;
var b = p1.y;
var c = p2.x;
var d = p2.y;
var p = p3.x;
var q = p3.y;
var r = p4.x;
var s = p4.y;
var det = (c - a) * (s - q) - (r - p) * (d - b);
if (det === 0) {
return false;
} else {
var lambda = ((s - q) * (r - a) + (p - r) * (s - b)) / det;
var gamma = ((b - d) * (r - a) + (c - a) * (s - b)) / det;
return 0 < lambda && lambda < 1 && 0 < gamma && gamma < 1;
}
};
// -----------------------------------------------------------------------------
// Section: Class Constants
// -----------------------------------------------------------------------------
/**
* Some useful pre-calculated constants
*/
IGeometry.HALF_PI = 0.5 * Math.PI;
IGeometry.ONE_AND_HALF_PI = 1.5 * Math.PI;
IGeometry.TWO_PI = 2.0 * Math.PI;
IGeometry.THREE_PI = 3.0 * Math.PI;
module.exports = IGeometry;
/***/ }),
/* 9 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
function IMath() {}
/**
* This method returns the sign of the input value.
*/
IMath.sign = function (value) {
if (value > 0) {
return 1;
} else if (value < 0) {
return -1;
} else {
return 0;
}
};
IMath.floor = function (value) {
return value < 0 ? Math.ceil(value) : Math.floor(value);
};
IMath.ceil = function (value) {
return value < 0 ? Math.floor(value) : Math.ceil(value);
};
module.exports = IMath;
/***/ }),
/* 10 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
function Integer() {}
Integer.MAX_VALUE = 2147483647;
Integer.MIN_VALUE = -2147483648;
module.exports = Integer;
/***/ }),
/* 11 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var nodeFrom = function nodeFrom(value) {
return { value: value, next: null, prev: null };
};
var add = function add(prev, node, next, list) {
if (prev !== null) {
prev.next = node;
} else {
list.head = node;
}
if (next !== null) {
next.prev = node;
} else {
list.tail = node;
}
node.prev = prev;
node.next = next;
list.length++;
return node;
};
var _remove = function _remove(node, list) {
var prev = node.prev,
next = node.next;
if (prev !== null) {
prev.next = next;
} else {
list.head = next;
}
if (next !== null) {
next.prev = prev;
} else {
list.tail = prev;
}
node.prev = node.next = null;
list.length--;
return node;
};
var LinkedList = function () {
function LinkedList(vals) {
var _this = this;
_classCallCheck(this, LinkedList);
this.length = 0;
this.head = null;
this.tail = null;
if (vals != null) {
vals.forEach(function (v) {
return _this.push(v);
});
}
}
_createClass(LinkedList, [{
key: "size",
value: function size() {
return this.length;
}
}, {
key: "insertBefore",
value: function insertBefore(val, otherNode) {
return add(otherNode.prev, nodeFrom(val), otherNode, this);
}
}, {
key: "insertAfter",
value: function insertAfter(val, otherNode) {
return add(otherNode, nodeFrom(val), otherNode.next, this);
}
}, {
key: "insertNodeBefore",
value: function insertNodeBefore(newNode, otherNode) {
return add(otherNode.prev, newNode, otherNode, this);
}
}, {
key: "insertNodeAfter",
value: function insertNodeAfter(newNode, otherNode) {
return add(otherNode, newNode, otherNode.next, this);
}
}, {
key: "push",
value: function push(val) {
return add(this.tail, nodeFrom(val), null, this);
}
}, {
key: "unshift",
value: function unshift(val) {
return add(null, nodeFrom(val), this.head, this);
}
}, {
key: "remove",
value: function remove(node) {
return _remove(node, this);
}
}, {
key: "pop",
value: function pop() {
return _remove(this.tail, this).value;
}
}, {
key: "popNode",
value: function popNode() {
return _remove(this.tail, this);
}
}, {
key: "shift",
value: function shift() {
return _remove(this.head, this).value;
}
}, {
key: "shiftNode",
value: function shiftNode() {
return _remove(this.head, this);
}
}, {
key: "get_object_at",
value: function get_object_at(index) {
if (index <= this.length()) {
var i = 1;
var current = this.head;
while (i < index) {
current = current.next;
i++;
}
return current.value;
}
}
}, {
key: "set_object_at",
value: function set_object_at(index, value) {
if (index <= this.length()) {
var i = 1;
var current = this.head;
while (i < index) {
current = current.next;
i++;
}
current.value = value;
}
}
}]);
return LinkedList;
}();
module.exports = LinkedList;
/***/ }),
/* 12 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/*
*This class is the javascript implementation of the Point.java class in jdk
*/
function Point(x, y, p) {
this.x = null;
this.y = null;
if (x == null && y == null && p == null) {
this.x = 0;
this.y = 0;
} else if (typeof x == 'number' && typeof y == 'number' && p == null) {
this.x = x;
this.y = y;
} else if (x.constructor.name == 'Point' && y == null && p == null) {
p = x;
this.x = p.x;
this.y = p.y;
}
}
Point.prototype.getX = function () {
return this.x;
};
Point.prototype.getY = function () {
return this.y;
};
Point.prototype.getLocation = function () {
return new Point(this.x, this.y);
};
Point.prototype.setLocation = function (x, y, p) {
if (x.constructor.name == 'Point' && y == null && p == null) {
p = x;
this.setLocation(p.x, p.y);
} else if (typeof x == 'number' && typeof y == 'number' && p == null) {
//if both parameters are integer just move (x,y) location
if (parseInt(x) == x && parseInt(y) == y) {
this.move(x, y);
} else {
this.x = Math.floor(x + 0.5);
this.y = Math.floor(y + 0.5);
}
}
};
Point.prototype.move = function (x, y) {
this.x = x;
this.y = y;
};
Point.prototype.translate = function (dx, dy) {
this.x += dx;
this.y += dy;
};
Point.prototype.equals = function (obj) {
if (obj.constructor.name == "Point") {
var pt = obj;
return this.x == pt.x && this.y == pt.y;
}
return this == obj;
};
Point.prototype.toString = function () {
return new Point().constructor.name + "[x=" + this.x + ",y=" + this.y + "]";
};
module.exports = Point;
/***/ }),
/* 13 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
function RectangleD(x, y, width, height) {
this.x = 0;
this.y = 0;
this.width = 0;
this.height = 0;
if (x != null && y != null && width != null && height != null) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
}
RectangleD.prototype.getX = function () {
return this.x;
};
RectangleD.prototype.setX = function (x) {
this.x = x;
};
RectangleD.prototype.getY = function () {
return this.y;
};
RectangleD.prototype.setY = function (y) {
this.y = y;
};
RectangleD.prototype.getWidth = function () {
return this.width;
};
RectangleD.prototype.setWidth = function (width) {
this.width = width;
};
RectangleD.prototype.getHeight = function () {
return this.height;
};
RectangleD.prototype.setHeight = function (height) {
this.height = height;
};
RectangleD.prototype.getRight = function () {
return this.x + this.width;
};
RectangleD.prototype.getBottom = function () {
return this.y + this.height;
};
RectangleD.prototype.intersects = function (a) {
if (this.getRight() < a.x) {
return false;
}
if (this.getBottom() < a.y) {
return false;
}
if (a.getRight() < this.x) {
return false;
}
if (a.getBottom() < this.y) {
return false;
}
return true;
};
RectangleD.prototype.getCenterX = function () {
return this.x + this.width / 2;
};
RectangleD.prototype.getMinX = function () {
return this.getX();
};
RectangleD.prototype.getMaxX = function () {
return this.getX() + this.width;
};
RectangleD.prototype.getCenterY = function () {
return this.y + this.height / 2;
};
RectangleD.prototype.getMinY = function () {
return this.getY();
};
RectangleD.prototype.getMaxY = function () {
return this.getY() + this.height;
};
RectangleD.prototype.getWidthHalf = function () {
return this.width / 2;
};
RectangleD.prototype.getHeightHalf = function () {
return this.height / 2;
};
module.exports = RectangleD;
/***/ }),
/* 14 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
function UniqueIDGeneretor() {}
UniqueIDGeneretor.lastID = 0;
UniqueIDGeneretor.createID = function (obj) {
if (UniqueIDGeneretor.isPrimitive(obj)) {
return obj;
}
if (obj.uniqueID != null) {
return obj.uniqueID;
}
obj.uniqueID = UniqueIDGeneretor.getString();
UniqueIDGeneretor.lastID++;
return obj.uniqueID;
};
UniqueIDGeneretor.getString = function (id) {
if (id == null) id = UniqueIDGeneretor.lastID;
return "Object#" + id + "";
};
UniqueIDGeneretor.isPrimitive = function (arg) {
var type = typeof arg === "undefined" ? "undefined" : _typeof(arg);
return arg == null || type != "object" && type != "function";
};
module.exports = UniqueIDGeneretor;
/***/ }),
/* 15 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
var LayoutConstants = __webpack_require__(0);
var LGraphManager = __webpack_require__(6);
var LNode = __webpack_require__(3);
var LEdge = __webpack_require__(1);
var LGraph = __webpack_require__(5);
var PointD = __webpack_require__(4);
var Transform = __webpack_require__(17);
var Emitter = __webpack_require__(27);
function Layout(isRemoteUse) {
Emitter.call(this);
//Layout Quality: 0:draft, 1:default, 2:proof
this.layoutQuality = LayoutConstants.QUALITY;
//Whether layout should create bendpoints as needed or not
this.createBendsAsNeeded = LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED;
//Whether layout should be incremental or not
this.incremental = LayoutConstants.DEFAULT_INCREMENTAL;
//Whether we animate from before to after layout node positions
this.animationOnLayout = LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT;
//Whether we animate the layout process or not
this.animationDuringLayout = LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT;
//Number iterations that should be done between two successive animations
this.animationPeriod = LayoutConstants.DEFAULT_ANIMATION_PERIOD;
/**
* Whether or not leaf nodes (non-compound nodes) are of uniform sizes. When
* they are, both spring and repulsion forces between two leaf nodes can be
* calculated without the expensive clipping point calculations, resulting
* in major speed-up.
*/
this.uniformLeafNodeSizes = LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES;
/**
* This is used for creation of bendpoints by using dummy nodes and edges.
* Maps an LEdge to its dummy bendpoint path.
*/
this.edgeToDummyNodes = new Map();
this.graphManager = new LGraphManager(this);
this.isLayoutFinished = false;
this.isSubLayout = false;
this.isRemoteUse = false;
if (isRemoteUse != null) {
this.isRemoteUse = isRemoteUse;
}
}
Layout.RANDOM_SEED = 1;
Layout.prototype = Object.create(Emitter.prototype);
Layout.prototype.getGraphManager = function () {
return this.graphManager;
};
Layout.prototype.getAllNodes = function () {
return this.graphManager.getAllNodes();
};
Layout.prototype.getAllEdges = function () {
return this.graphManager.getAllEdges();
};
Layout.prototype.getAllNodesToApplyGravitation = function () {
return this.graphManager.getAllNodesToApplyGravitation();
};
Layout.prototype.newGraphManager = function () {
var gm = new LGraphManager(this);
this.graphManager = gm;
return gm;
};
Layout.prototype.newGraph = function (vGraph) {
return new LGraph(null, this.graphManager, vGraph);
};
Layout.prototype.newNode = function (vNode) {
return new LNode(this.graphManager, vNode);
};
Layout.prototype.newEdge = function (vEdge) {
return new LEdge(null, null, vEdge);
};
Layout.prototype.checkLayoutSuccess = function () {
return this.graphManager.getRoot() == null || this.graphManager.getRoot().getNodes().length == 0 || this.graphManager.includesInvalidEdge();
};
Layout.prototype.runLayout = function () {
this.isLayoutFinished = false;
if (this.tilingPreLayout) {
this.tilingPreLayout();
}
this.initParameters();
var isLayoutSuccessfull;
if (this.checkLayoutSuccess()) {
isLayoutSuccessfull = false;
} else {
isLayoutSuccessfull = this.layout();
}
if (LayoutConstants.ANIMATE === 'during') {
// If this is a 'during' layout animation. Layout is not finished yet.
// We need to perform these in index.js when layout is really finished.
return false;
}
if (isLayoutSuccessfull) {
if (!this.isSubLayout) {
this.doPostLayout();
}
}
if (this.tilingPostLayout) {
this.tilingPostLayout();
}
this.isLayoutFinished = true;
return isLayoutSuccessfull;
};
/**
* This method performs the operations required after layout.
*/
Layout.prototype.doPostLayout = function () {
//assert !isSubLayout : "Should not be called on sub-layout!";
// Propagate geometric changes to v-level objects
if (!this.incremental) {
this.transform();
}
this.update();
};
/**
* This method updates the geometry of the target graph according to
* calculated layout.
*/
Layout.prototype.update2 = function () {
// update bend points
if (this.createBendsAsNeeded) {
this.createBendpointsFromDummyNodes();
// reset all edges, since the topology has changed
this.graphManager.resetAllEdges();
}
// perform edge, node and root updates if layout is not called
// remotely
if (!this.isRemoteUse) {
// update all edges
var edge;
var allEdges = this.graphManager.getAllEdges();
for (var i = 0; i < allEdges.length; i++) {
edge = allEdges[i];
// this.update(edge);
}
// recursively update nodes
var node;
var nodes = this.graphManager.getRoot().getNodes();
for (var i = 0; i < nodes.length; i++) {
node = nodes[i];
// this.update(node);
}
// update root graph
this.update(this.graphManager.getRoot());
}
};
Layout.prototype.update = function (obj) {
if (obj == null) {
this.update2();
} else if (obj instanceof LNode) {
var node = obj;
if (node.getChild() != null) {
// since node is compound, recursively update child nodes
var nodes = node.getChild().getNodes();
for (var i = 0; i < nodes.length; i++) {
update(nodes[i]);
}
}
// if the l-level node is associated with a v-level graph object,
// then it is assumed that the v-level node implements the
// interface Updatable.
if (node.vGraphObject != null) {
// cast to Updatable without any type check
var vNode = node.vGraphObject;
// call the update method of the interface
vNode.update(node);
}
} else if (obj instanceof LEdge) {
var edge = obj;
// if the l-level edge is associated with a v-level graph object,
// then it is assumed that the v-level edge implements the
// interface Updatable.
if (edge.vGraphObject != null) {
// cast to Updatable without any type check
var vEdge = edge.vGraphObject;
// call the update method of the interface
vEdge.update(edge);
}
} else if (obj instanceof LGraph) {
var graph = obj;
// if the l-level graph is associated with a v-level graph object,
// then it is assumed that the v-level object implements the
// interface Updatable.
if (graph.vGraphObject != null) {
// cast to Updatable without any type check
var vGraph = graph.vGraphObject;
// call the update method of the interface
vGraph.update(graph);
}
}
};
/**
* This method is used to set all layout parameters to default values
* determined at compile time.
*/
Layout.prototype.initParameters = function () {
if (!this.isSubLayout) {
this.layoutQuality = LayoutConstants.QUALITY;
this.animationDuringLayout = LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT;
this.animationPeriod = LayoutConstants.DEFAULT_ANIMATION_PERIOD;
this.animationOnLayout = LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT;
this.incremental = LayoutConstants.DEFAULT_INCREMENTAL;
this.createBendsAsNeeded = LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED;
this.uniformLeafNodeSizes = LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES;
}
if (this.animationDuringLayout) {
this.animationOnLayout = false;
}
};
Layout.prototype.transform = function (newLeftTop) {
if (newLeftTop == undefined) {
this.transform(new PointD(0, 0));
} else {
// create a transformation object (from Eclipse to layout). When an
// inverse transform is applied, we get upper-left coordinate of the
// drawing or the root graph at given input coordinate (some margins
// already included in calculation of left-top).
var trans = new Transform();
var leftTop = this.graphManager.getRoot().updateLeftTop();
if (leftTop != null) {
trans.setWorldOrgX(newLeftTop.x);
trans.setWorldOrgY(newLeftTop.y);
trans.setDeviceOrgX(leftTop.x);
trans.setDeviceOrgY(leftTop.y);
var nodes = this.getAllNodes();
var node;
for (var i = 0; i < nodes.length; i++) {
node = nodes[i];
node.transform(trans);
}
}
}
};
Layout.prototype.positionNodesRandomly = function (graph) {
if (graph == undefined) {
//assert !this.incremental;
this.positionNodesRandomly(this.getGraphManager().getRoot());
this.getGraphManager().getRoot().updateBounds(true);
} else {
var lNode;
var childGraph;
var nodes = graph.getNodes();
for (var i = 0; i < nodes.length; i++) {
lNode = nodes[i];
childGraph = lNode.getChild();
if (childGraph == null) {
lNode.scatter();
} else if (childGraph.getNodes().length == 0) {
lNode.scatter();
} else {
this.positionNodesRandomly(childGraph);
lNode.updateBounds();
}
}
}
};
/**
* This method returns a list of trees where each tree is represented as a
* list of l-nodes. The method returns a list of size 0 when:
* - The graph is not flat or
* - One of the component(s) of the graph is not a tree.
*/
Layout.prototype.getFlatForest = function () {
var flatForest = [];
var isForest = true;
// Quick reference for all nodes in the graph manager associated with
// this layout. The list should not be changed.
var allNodes = this.graphManager.getRoot().getNodes();
// First be sure that the graph is flat
var isFlat = true;
for (var i = 0; i < allNodes.length; i++) {
if (allNodes[i].getChild() != null) {
isFlat = false;
}
}
// Return empty forest if the graph is not flat.
if (!isFlat) {
return flatForest;
}
// Run BFS for each component of the graph.
var visited = new Set();
var toBeVisited = [];
var parents = new Map();
var unProcessedNodes = [];
unProcessedNodes = unProcessedNodes.concat(allNodes);
// Each iteration of this loop finds a component of the graph and
// decides whether it is a tree or not. If it is a tree, adds it to the
// forest and continued with the next component.
while (unProcessedNodes.length > 0 && isForest) {
toBeVisited.push(unProcessedNodes[0]);
// Start the BFS. Each iteration of this loop visits a node in a
// BFS manner.
while (toBeVisited.length > 0 && isForest) {
//pool operation
var currentNode = toBeVisited[0];
toBeVisited.splice(0, 1);
visited.add(currentNode);
// Traverse all neighbors of this node
var neighborEdges = currentNode.getEdges();
for (var i = 0; i < neighborEdges.length; i++) {
var currentNeighbor = neighborEdges[i].getOtherEnd(currentNode);
// If BFS is not growing from this neighbor.
if (parents.get(currentNode) != currentNeighbor) {
// We haven't previously visited this neighbor.
if (!visited.has(currentNeighbor)) {
toBeVisited.push(currentNeighbor);
parents.set(currentNeighbor, currentNode);
}
// Since we have previously visited this neighbor and
// this neighbor is not parent of currentNode, given
// graph contains a component that is not tree, hence
// it is not a forest.
else {
isForest = false;
break;
}
}
}
}
// The graph contains a component that is not a tree. Empty
// previously found trees. The method will end.
if (!isForest) {
flatForest = [];
}
// Save currently visited nodes as a tree in our forest. Reset
// visited and parents lists. Continue with the next component of
// the graph, if any.
else {
var temp = [].concat(_toConsumableArray(visited));
flatForest.push(temp);
//flatForest = flatForest.concat(temp);
//unProcessedNodes.removeAll(visited);
for (var i = 0; i < temp.length; i++) {
var value = temp[i];
var index = unProcessedNodes.indexOf(value);
if (index > -1) {
unProcessedNodes.splice(index, 1);
}
}
visited = new Set();
parents = new Map();
}
}
return flatForest;
};
/**
* This method creates dummy nodes (an l-level node with minimal dimensions)
* for the given edge (one per bendpoint). The existing l-level structure
* is updated accordingly.
*/
Layout.prototype.createDummyNodesForBendpoints = function (edge) {
var dummyNodes = [];
var prev = edge.source;
var graph = this.graphManager.calcLowestCommonAncestor(edge.source, edge.target);
for (var i = 0; i < edge.bendpoints.length; i++) {
// create new dummy node
var dummyNode = this.newNode(null);
dummyNode.setRect(new Point(0, 0), new Dimension(1, 1));
graph.add(dummyNode);
// create new dummy edge between prev and dummy node
var dummyEdge = this.newEdge(null);
this.graphManager.add(dummyEdge, prev, dummyNode);
dummyNodes.add(dummyNode);
prev = dummyNode;
}
var dummyEdge = this.newEdge(null);
this.graphManager.add(dummyEdge, prev, edge.target);
this.edgeToDummyNodes.set(edge, dummyNodes);
// remove real edge from graph manager if it is inter-graph
if (edge.isInterGraph()) {
this.graphManager.remove(edge);
}
// else, remove the edge from the current graph
else {
graph.remove(edge);
}
return dummyNodes;
};
/**
* This method creates bendpoints for edges from the dummy nodes
* at l-level.
*/
Layout.prototype.createBendpointsFromDummyNodes = function () {
var edges = [];
edges = edges.concat(this.graphManager.getAllEdges());
edges = [].concat(_toConsumableArray(this.edgeToDummyNodes.keys())).concat(edges);
for (var k = 0; k < edges.length; k++) {
var lEdge = edges[k];
if (lEdge.bendpoints.length > 0) {
var path = this.edgeToDummyNodes.get(lEdge);
for (var i = 0; i < path.length; i++) {
var dummyNode = path[i];
var p = new PointD(dummyNode.getCenterX(), dummyNode.getCenterY());
// update bendpoint's location according to dummy node
var ebp = lEdge.bendpoints.get(i);
ebp.x = p.x;
ebp.y = p.y;
// remove the dummy node, dummy edges incident with this
// dummy node is also removed (within the remove method)
dummyNode.getOwner().remove(dummyNode);
}
// add the real edge to graph
this.graphManager.add(lEdge, lEdge.source, lEdge.target);
}
}
};
Layout.transform = function (sliderValue, defaultValue, minDiv, maxMul) {
if (minDiv != undefined && maxMul != undefined) {
var value = defaultValue;
if (sliderValue <= 50) {
var minValue = defaultValue / minDiv;
value -= (defaultValue - minValue) / 50 * (50 - sliderValue);
} else {
var maxValue = defaultValue * maxMul;
value += (maxValue - defaultValue) / 50 * (sliderValue - 50);
}
return value;
} else {
var a, b;
if (sliderValue <= 50) {
a = 9.0 * defaultValue / 500.0;
b = defaultValue / 10.0;
} else {
a = 9.0 * defaultValue / 50.0;
b = -8 * defaultValue;
}
return a * sliderValue + b;
}
};
/**
* This method finds and returns the center of the given nodes, assuming
* that the given nodes form a tree in themselves.
*/
Layout.findCenterOfTree = function (nodes) {
var list = [];
list = list.concat(nodes);
var removedNodes = [];
var remainingDegrees = new Map();
var foundCenter = false;
var centerNode = null;
if (list.length == 1 || list.length == 2) {
foundCenter = true;
centerNode = list[0];
}
for (var i = 0; i < list.length; i++) {
var node = list[i];
var degree = node.getNeighborsList().size;
remainingDegrees.set(node, node.getNeighborsList().size);
if (degree == 1) {
removedNodes.push(node);
}
}
var tempList = [];
tempList = tempList.concat(removedNodes);
while (!foundCenter) {
var tempList2 = [];
tempList2 = tempList2.concat(tempList);
tempList = [];
for (var i = 0; i < list.length; i++) {
var node = list[i];
var index = list.indexOf(node);
if (index >= 0) {
list.splice(index, 1);
}
var neighbours = node.getNeighborsList();
neighbours.forEach(function (neighbour) {
if (removedNodes.indexOf(neighbour) < 0) {
var otherDegree = remainingDegrees.get(neighbour);
var newDegree = otherDegree - 1;
if (newDegree == 1) {
tempList.push(neighbour);
}
remainingDegrees.set(neighbour, newDegree);
}
});
}
removedNodes = removedNodes.concat(tempList);
if (list.length == 1 || list.length == 2) {
foundCenter = true;
centerNode = list[0];
}
}
return centerNode;
};
/**
* During the coarsening process, this layout may be referenced by two graph managers
* this setter function grants access to change the currently being used graph manager
*/
Layout.prototype.setGraphManager = function (gm) {
this.graphManager = gm;
};
module.exports = Layout;
/***/ }),
/* 16 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
function RandomSeed() {}
// adapted from: https://stackoverflow.com/a/19303725
RandomSeed.seed = 1;
RandomSeed.x = 0;
RandomSeed.nextDouble = function () {
RandomSeed.x = Math.sin(RandomSeed.seed++) * 10000;
return RandomSeed.x - Math.floor(RandomSeed.x);
};
module.exports = RandomSeed;
/***/ }),
/* 17 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var PointD = __webpack_require__(4);
function Transform(x, y) {
this.lworldOrgX = 0.0;
this.lworldOrgY = 0.0;
this.ldeviceOrgX = 0.0;
this.ldeviceOrgY = 0.0;
this.lworldExtX = 1.0;
this.lworldExtY = 1.0;
this.ldeviceExtX = 1.0;
this.ldeviceExtY = 1.0;
}
Transform.prototype.getWorldOrgX = function () {
return this.lworldOrgX;
};
Transform.prototype.setWorldOrgX = function (wox) {
this.lworldOrgX = wox;
};
Transform.prototype.getWorldOrgY = function () {
return this.lworldOrgY;
};
Transform.prototype.setWorldOrgY = function (woy) {
this.lworldOrgY = woy;
};
Transform.prototype.getWorldExtX = function () {
return this.lworldExtX;
};
Transform.prototype.setWorldExtX = function (wex) {
this.lworldExtX = wex;
};
Transform.prototype.getWorldExtY = function () {
return this.lworldExtY;
};
Transform.prototype.setWorldExtY = function (wey) {
this.lworldExtY = wey;
};
/* Device related */
Transform.prototype.getDeviceOrgX = function () {
return this.ldeviceOrgX;
};
Transform.prototype.setDeviceOrgX = function (dox) {
this.ldeviceOrgX = dox;
};
Transform.prototype.getDeviceOrgY = function () {
return this.ldeviceOrgY;
};
Transform.prototype.setDeviceOrgY = function (doy) {
this.ldeviceOrgY = doy;
};
Transform.prototype.getDeviceExtX = function () {
return this.ldeviceExtX;
};
Transform.prototype.setDeviceExtX = function (dex) {
this.ldeviceExtX = dex;
};
Transform.prototype.getDeviceExtY = function () {
return this.ldeviceExtY;
};
Transform.prototype.setDeviceExtY = function (dey) {
this.ldeviceExtY = dey;
};
Transform.prototype.transformX = function (x) {
var xDevice = 0.0;
var worldExtX = this.lworldExtX;
if (worldExtX != 0.0) {
xDevice = this.ldeviceOrgX + (x - this.lworldOrgX) * this.ldeviceExtX / worldExtX;
}
return xDevice;
};
Transform.prototype.transformY = function (y) {
var yDevice = 0.0;
var worldExtY = this.lworldExtY;
if (worldExtY != 0.0) {
yDevice = this.ldeviceOrgY + (y - this.lworldOrgY) * this.ldeviceExtY / worldExtY;
}
return yDevice;
};
Transform.prototype.inverseTransformX = function (x) {
var xWorld = 0.0;
var deviceExtX = this.ldeviceExtX;
if (deviceExtX != 0.0) {
xWorld = this.lworldOrgX + (x - this.ldeviceOrgX) * this.lworldExtX / deviceExtX;
}
return xWorld;
};
Transform.prototype.inverseTransformY = function (y) {
var yWorld = 0.0;
var deviceExtY = this.ldeviceExtY;
if (deviceExtY != 0.0) {
yWorld = this.lworldOrgY + (y - this.ldeviceOrgY) * this.lworldExtY / deviceExtY;
}
return yWorld;
};
Transform.prototype.inverseTransformPoint = function (inPoint) {
var outPoint = new PointD(this.inverseTransformX(inPoint.x), this.inverseTransformY(inPoint.y));
return outPoint;
};
module.exports = Transform;
/***/ }),
/* 18 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
var Layout = __webpack_require__(15);
var FDLayoutConstants = __webpack_require__(7);
var LayoutConstants = __webpack_require__(0);
var IGeometry = __webpack_require__(8);
var IMath = __webpack_require__(9);
function FDLayout() {
Layout.call(this);
this.useSmartIdealEdgeLengthCalculation = FDLayoutConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION;
this.idealEdgeLength = FDLayoutConstants.DEFAULT_EDGE_LENGTH;
this.springConstant = FDLayoutConstants.DEFAULT_SPRING_STRENGTH;
this.repulsionConstant = FDLayoutConstants.DEFAULT_REPULSION_STRENGTH;
this.gravityConstant = FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH;
this.compoundGravityConstant = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH;
this.gravityRangeFactor = FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR;
this.compoundGravityRangeFactor = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR;
this.displacementThresholdPerNode = 3.0 * FDLayoutConstants.DEFAULT_EDGE_LENGTH / 100;
this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL;
this.initialCoolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL;
this.totalDisplacement = 0.0;
this.oldTotalDisplacement = 0.0;
this.maxIterations = FDLayoutConstants.MAX_ITERATIONS;
}
FDLayout.prototype = Object.create(Layout.prototype);
for (var prop in Layout) {
FDLayout[prop] = Layout[prop];
}
FDLayout.prototype.initParameters = function () {
Layout.prototype.initParameters.call(this, arguments);
this.totalIterations = 0;
this.notAnimatedIterations = 0;
this.useFRGridVariant = FDLayoutConstants.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION;
this.grid = [];
};
FDLayout.prototype.calcIdealEdgeLengths = function () {
var edge;
var lcaDepth;
var source;
var target;
var sizeOfSourceInLca;
var sizeOfTargetInLca;
var allEdges = this.getGraphManager().getAllEdges();
for (var i = 0; i < allEdges.length; i++) {
edge = allEdges[i];
edge.idealLength = this.idealEdgeLength;
if (edge.isInterGraph) {
source = edge.getSource();
target = edge.getTarget();
sizeOfSourceInLca = edge.getSourceInLca().getEstimatedSize();
sizeOfTargetInLca = edge.getTargetInLca().getEstimatedSize();
if (this.useSmartIdealEdgeLengthCalculation) {
edge.idealLength += sizeOfSourceInLca + sizeOfTargetInLca - 2 * LayoutConstants.SIMPLE_NODE_SIZE;
}
lcaDepth = edge.getLca().getInclusionTreeDepth();
edge.idealLength += FDLayoutConstants.DEFAULT_EDGE_LENGTH * FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR * (source.getInclusionTreeDepth() + target.getInclusionTreeDepth() - 2 * lcaDepth);
}
}
};
FDLayout.prototype.initSpringEmbedder = function () {
var s = this.getAllNodes().length;
if (this.incremental) {
if (s > FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) {
this.coolingFactor = Math.max(this.coolingFactor * FDLayoutConstants.COOLING_ADAPTATION_FACTOR, this.coolingFactor - (s - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) / (FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) * this.coolingFactor * (1 - FDLayoutConstants.COOLING_ADAPTATION_FACTOR));
}
this.maxNodeDisplacement = FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL;
} else {
if (s > FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) {
this.coolingFactor = Math.max(FDLayoutConstants.COOLING_ADAPTATION_FACTOR, 1.0 - (s - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) / (FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) * (1 - FDLayoutConstants.COOLING_ADAPTATION_FACTOR));
} else {
this.coolingFactor = 1.0;
}
this.initialCoolingFactor = this.coolingFactor;
this.maxNodeDisplacement = FDLayoutConstants.MAX_NODE_DISPLACEMENT;
}
this.maxIterations = Math.max(this.getAllNodes().length * 5, this.maxIterations);
this.totalDisplacementThreshold = this.displacementThresholdPerNode * this.getAllNodes().length;
this.repulsionRange = this.calcRepulsionRange();
};
FDLayout.prototype.calcSpringForces = function () {
var lEdges = this.getAllEdges();
var edge;
for (var i = 0; i < lEdges.length; i++) {
edge = lEdges[i];
this.calcSpringForce(edge, edge.idealLength);
}
};
FDLayout.prototype.calcRepulsionForces = function () {
var gridUpdateAllowed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
var forceToNodeSurroundingUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var i, j;
var nodeA, nodeB;
var lNodes = this.getAllNodes();
var processedNodeSet;
if (this.useFRGridVariant) {
if (this.totalIterations % FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD == 1 && gridUpdateAllowed) {
this.updateGrid();
}
processedNodeSet = new Set();
// calculate repulsion forces between each nodes and its surrounding
for (i = 0; i < lNodes.length; i++) {
nodeA = lNodes[i];
this.calculateRepulsionForceOfANode(nodeA, processedNodeSet, gridUpdateAllowed, forceToNodeSurroundingUpdate);
processedNodeSet.add(nodeA);
}
} else {
for (i = 0; i < lNodes.length; i++) {
nodeA = lNodes[i];
for (j = i + 1; j < lNodes.length; j++) {
nodeB = lNodes[j];
// If both nodes are not members of the same graph, skip.
if (nodeA.getOwner() != nodeB.getOwner()) {
continue;
}
this.calcRepulsionForce(nodeA, nodeB);
}
}
}
};
FDLayout.prototype.calcGravitationalForces = function () {
var node;
var lNodes = this.getAllNodesToApplyGravitation();
for (var i = 0; i < lNodes.length; i++) {
node = lNodes[i];
this.calcGravitationalForce(node);
}
};
FDLayout.prototype.moveNodes = function () {
var lNodes = this.getAllNodes();
var node;
for (var i = 0; i < lNodes.length; i++) {
node = lNodes[i];
node.move();
}
};
FDLayout.prototype.calcSpringForce = function (edge, idealLength) {
var sourceNode = edge.getSource();
var targetNode = edge.getTarget();
var length;
var springForce;
var springForceX;
var springForceY;
// Update edge length
if (this.uniformLeafNodeSizes && sourceNode.getChild() == null && targetNode.getChild() == null) {
edge.updateLengthSimple();
} else {
edge.updateLength();
if (edge.isOverlapingSourceAndTarget) {
return;
}
}
length = edge.getLength();
if (length == 0) return;
// Calculate spring forces
springForce = this.springConstant * (length - idealLength);
// Project force onto x and y axes
springForceX = springForce * (edge.lengthX / length);
springForceY = springForce * (edge.lengthY / length);
// Apply forces on the end nodes
sourceNode.springForceX += springForceX;
sourceNode.springForceY += springForceY;
targetNode.springForceX -= springForceX;
targetNode.springForceY -= springForceY;
};
FDLayout.prototype.calcRepulsionForce = function (nodeA, nodeB) {
var rectA = nodeA.getRect();
var rectB = nodeB.getRect();
var overlapAmount = new Array(2);
var clipPoints = new Array(4);
var distanceX;
var distanceY;
var distanceSquared;
var distance;
var repulsionForce;
var repulsionForceX;
var repulsionForceY;
if (rectA.intersects(rectB)) // two nodes overlap
{
// calculate separation amount in x and y directions
IGeometry.calcSeparationAmount(rectA, rectB, overlapAmount, FDLayoutConstants.DEFAULT_EDGE_LENGTH / 2.0);
repulsionForceX = 2 * overlapAmount[0];
repulsionForceY = 2 * overlapAmount[1];
var childrenConstant = nodeA.noOfChildren * nodeB.noOfChildren / (nodeA.noOfChildren + nodeB.noOfChildren);
// Apply forces on the two nodes
nodeA.repulsionForceX -= childrenConstant * repulsionForceX;
nodeA.repulsionForceY -= childrenConstant * repulsionForceY;
nodeB.repulsionForceX += childrenConstant * repulsionForceX;
nodeB.repulsionForceY += childrenConstant * repulsionForceY;
} else // no overlap
{
// calculate distance
if (this.uniformLeafNodeSizes && nodeA.getChild() == null && nodeB.getChild() == null) // simply base repulsion on distance of node centers
{
distanceX = rectB.getCenterX() - rectA.getCenterX();
distanceY = rectB.getCenterY() - rectA.getCenterY();
} else // use clipping points
{
IGeometry.getIntersection(rectA, rectB, clipPoints);
distanceX = clipPoints[2] - clipPoints[0];
distanceY = clipPoints[3] - clipPoints[1];
}
// No repulsion range. FR grid variant should take care of this.
if (Math.abs(distanceX) < FDLayoutConstants.MIN_REPULSION_DIST) {
distanceX = IMath.sign(distanceX) * FDLayoutConstants.MIN_REPULSION_DIST;
}
if (Math.abs(distanceY) < FDLayoutConstants.MIN_REPULSION_DIST) {
distanceY = IMath.sign(distanceY) * FDLayoutConstants.MIN_REPULSION_DIST;
}
distanceSquared = distanceX * distanceX + distanceY * distanceY;
distance = Math.sqrt(distanceSquared);
repulsionForce = this.repulsionConstant * nodeA.noOfChildren * nodeB.noOfChildren / distanceSquared;
// Project force onto x and y axes
repulsionForceX = repulsionForce * distanceX / distance;
repulsionForceY = repulsionForce * distanceY / distance;
// Apply forces on the two nodes
nodeA.repulsionForceX -= repulsionForceX;
nodeA.repulsionForceY -= repulsionForceY;
nodeB.repulsionForceX += repulsionForceX;
nodeB.repulsionForceY += repulsionForceY;
}
};
FDLayout.prototype.calcGravitationalForce = function (node) {
var ownerGraph;
var ownerCenterX;
var ownerCenterY;
var distanceX;
var distanceY;
var absDistanceX;
var absDistanceY;
var estimatedSize;
ownerGraph = node.getOwner();
ownerCenterX = (ownerGraph.getRight() + ownerGraph.getLeft()) / 2;
ownerCenterY = (ownerGraph.getTop() + ownerGraph.getBottom()) / 2;
distanceX = node.getCenterX() - ownerCenterX;
distanceY = node.getCenterY() - ownerCenterY;
absDistanceX = Math.abs(distanceX) + node.getWidth() / 2;
absDistanceY = Math.abs(distanceY) + node.getHeight() / 2;
if (node.getOwner() == this.graphManager.getRoot()) // in the root graph
{
estimatedSize = ownerGraph.getEstimatedSize() * this.gravityRangeFactor;
if (absDistanceX > estimatedSize || absDistanceY > estimatedSize) {
node.gravitationForceX = -this.gravityConstant * distanceX;
node.gravitationForceY = -this.gravityConstant * distanceY;
}
} else // inside a compound
{
estimatedSize = ownerGraph.getEstimatedSize() * this.compoundGravityRangeFactor;
if (absDistanceX > estimatedSize || absDistanceY > estimatedSize) {
node.gravitationForceX = -this.gravityConstant * distanceX * this.compoundGravityConstant;
node.gravitationForceY = -this.gravityConstant * distanceY * this.compoundGravityConstant;
}
}
};
FDLayout.prototype.isConverged = function () {
var converged;
var oscilating = false;
if (this.totalIterations > this.maxIterations / 3) {
oscilating = Math.abs(this.totalDisplacement - this.oldTotalDisplacement) < 2;
}
converged = this.totalDisplacement < this.totalDisplacementThreshold;
this.oldTotalDisplacement = this.totalDisplacement;
return converged || oscilating;
};
FDLayout.prototype.animate = function () {
if (this.animationDuringLayout && !this.isSubLayout) {
if (this.notAnimatedIterations == this.animationPeriod) {
this.update();
this.notAnimatedIterations = 0;
} else {
this.notAnimatedIterations++;
}
}
};
//This method calculates the number of children (weight) for all nodes
FDLayout.prototype.calcNoOfChildrenForAllNodes = function () {
var node;
var allNodes = this.graphManager.getAllNodes();
for (var i = 0; i < allNodes.length; i++) {
node = allNodes[i];
node.noOfChildren = node.getNoOfChildren();
}
};
// -----------------------------------------------------------------------------
// Section: FR-Grid Variant Repulsion Force Calculation
// -----------------------------------------------------------------------------
FDLayout.prototype.calcGrid = function (graph) {
var sizeX = 0;
var sizeY = 0;
sizeX = parseInt(Math.ceil((graph.getRight() - graph.getLeft()) / this.repulsionRange));
sizeY = parseInt(Math.ceil((graph.getBottom() - graph.getTop()) / this.repulsionRange));
var grid = new Array(sizeX);
for (var i = 0; i < sizeX; i++) {
grid[i] = new Array(sizeY);
}
for (var i = 0; i < sizeX; i++) {
for (var j = 0; j < sizeY; j++) {
grid[i][j] = new Array();
}
}
return grid;
};
FDLayout.prototype.addNodeToGrid = function (v, left, top) {
var startX = 0;
var finishX = 0;
var startY = 0;
var finishY = 0;
startX = parseInt(Math.floor((v.getRect().x - left) / this.repulsionRange));
finishX = parseInt(Math.floor((v.getRect().width + v.getRect().x - left) / this.repulsionRange));
startY = parseInt(Math.floor((v.getRect().y - top) / this.repulsionRange));
finishY = parseInt(Math.floor((v.getRect().height + v.getRect().y - top) / this.repulsionRange));
for (var i = startX; i <= finishX; i++) {
for (var j = startY; j <= finishY; j++) {
this.grid[i][j].push(v);
v.setGridCoordinates(startX, finishX, startY, finishY);
}
}
};
FDLayout.prototype.updateGrid = function () {
var i;
var nodeA;
var lNodes = this.getAllNodes();
this.grid = this.calcGrid(this.graphManager.getRoot());
// put all nodes to proper grid cells
for (i = 0; i < lNodes.length; i++) {
nodeA = lNodes[i];
this.addNodeToGrid(nodeA, this.graphManager.getRoot().getLeft(), this.graphManager.getRoot().getTop());
}
};
FDLayout.prototype.calculateRepulsionForceOfANode = function (nodeA, processedNodeSet, gridUpdateAllowed, forceToNodeSurroundingUpdate) {
if (this.totalIterations % FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD == 1 && gridUpdateAllowed || forceToNodeSurroundingUpdate) {
var surrounding = new Set();
nodeA.surrounding = new Array();
var nodeB;
var grid = this.grid;
for (var i = nodeA.startX - 1; i < nodeA.finishX + 2; i++) {
for (var j = nodeA.startY - 1; j < nodeA.finishY + 2; j++) {
if (!(i < 0 || j < 0 || i >= grid.length || j >= grid[0].length)) {
for (var k = 0; k < grid[i][j].length; k++) {
nodeB = grid[i][j][k];
// If both nodes are not members of the same graph,
// or both nodes are the same, skip.
if (nodeA.getOwner() != nodeB.getOwner() || nodeA == nodeB) {
continue;
}
// check if the repulsion force between
// nodeA and nodeB has already been calculated
if (!processedNodeSet.has(nodeB) && !surrounding.has(nodeB)) {
var distanceX = Math.abs(nodeA.getCenterX() - nodeB.getCenterX()) - (nodeA.getWidth() / 2 + nodeB.getWidth() / 2);
var distanceY = Math.abs(nodeA.getCenterY() - nodeB.getCenterY()) - (nodeA.getHeight() / 2 + nodeB.getHeight() / 2);
// if the distance between nodeA and nodeB
// is less then calculation range
if (distanceX <= this.repulsionRange && distanceY <= this.repulsionRange) {
//then add nodeB to surrounding of nodeA
surrounding.add(nodeB);
}
}
}
}
}
}
nodeA.surrounding = [].concat(_toConsumableArray(surrounding));
}
for (i = 0; i < nodeA.surrounding.length; i++) {
this.calcRepulsionForce(nodeA, nodeA.surrounding[i]);
}
};
FDLayout.prototype.calcRepulsionRange = function () {
return 0.0;
};
module.exports = FDLayout;
/***/ }),
/* 19 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var LEdge = __webpack_require__(1);
var FDLayoutConstants = __webpack_require__(7);
function FDLayoutEdge(source, target, vEdge) {
LEdge.call(this, source, target, vEdge);
this.idealLength = FDLayoutConstants.DEFAULT_EDGE_LENGTH;
}
FDLayoutEdge.prototype = Object.create(LEdge.prototype);
for (var prop in LEdge) {
FDLayoutEdge[prop] = LEdge[prop];
}
module.exports = FDLayoutEdge;
/***/ }),
/* 20 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var LNode = __webpack_require__(3);
function FDLayoutNode(gm, loc, size, vNode) {
// alternative constructor is handled inside LNode
LNode.call(this, gm, loc, size, vNode);
//Spring, repulsion and gravitational forces acting on this node
this.springForceX = 0;
this.springForceY = 0;
this.repulsionForceX = 0;
this.repulsionForceY = 0;
this.gravitationForceX = 0;
this.gravitationForceY = 0;
//Amount by which this node is to be moved in this iteration
this.displacementX = 0;
this.displacementY = 0;
//Start and finish grid coordinates that this node is fallen into
this.startX = 0;
this.finishX = 0;
this.startY = 0;
this.finishY = 0;
//Geometric neighbors of this node
this.surrounding = [];
}
FDLayoutNode.prototype = Object.create(LNode.prototype);
for (var prop in LNode) {
FDLayoutNode[prop] = LNode[prop];
}
FDLayoutNode.prototype.setGridCoordinates = function (_startX, _finishX, _startY, _finishY) {
this.startX = _startX;
this.finishX = _finishX;
this.startY = _startY;
this.finishY = _finishY;
};
module.exports = FDLayoutNode;
/***/ }),
/* 21 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
function DimensionD(width, height) {
this.width = 0;
this.height = 0;
if (width !== null && height !== null) {
this.height = height;
this.width = width;
}
}
DimensionD.prototype.getWidth = function () {
return this.width;
};
DimensionD.prototype.setWidth = function (width) {
this.width = width;
};
DimensionD.prototype.getHeight = function () {
return this.height;
};
DimensionD.prototype.setHeight = function (height) {
this.height = height;
};
module.exports = DimensionD;
/***/ }),
/* 22 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var UniqueIDGeneretor = __webpack_require__(14);
function HashMap() {
this.map = {};
this.keys = [];
}
HashMap.prototype.put = function (key, value) {
var theId = UniqueIDGeneretor.createID(key);
if (!this.contains(theId)) {
this.map[theId] = value;
this.keys.push(key);
}
};
HashMap.prototype.contains = function (key) {
var theId = UniqueIDGeneretor.createID(key);
return this.map[key] != null;
};
HashMap.prototype.get = function (key) {
var theId = UniqueIDGeneretor.createID(key);
return this.map[theId];
};
HashMap.prototype.keySet = function () {
return this.keys;
};
module.exports = HashMap;
/***/ }),
/* 23 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var UniqueIDGeneretor = __webpack_require__(14);
function HashSet() {
this.set = {};
}
;
HashSet.prototype.add = function (obj) {
var theId = UniqueIDGeneretor.createID(obj);
if (!this.contains(theId)) this.set[theId] = obj;
};
HashSet.prototype.remove = function (obj) {
delete this.set[UniqueIDGeneretor.createID(obj)];
};
HashSet.prototype.clear = function () {
this.set = {};
};
HashSet.prototype.contains = function (obj) {
return this.set[UniqueIDGeneretor.createID(obj)] == obj;
};
HashSet.prototype.isEmpty = function () {
return this.size() === 0;
};
HashSet.prototype.size = function () {
return Object.keys(this.set).length;
};
//concats this.set to the given list
HashSet.prototype.addAllTo = function (list) {
var keys = Object.keys(this.set);
var length = keys.length;
for (var i = 0; i < length; i++) {
list.push(this.set[keys[i]]);
}
};
HashSet.prototype.size = function () {
return Object.keys(this.set).length;
};
HashSet.prototype.addAll = function (list) {
var s = list.length;
for (var i = 0; i < s; i++) {
var v = list[i];
this.add(v);
}
};
module.exports = HashSet;
/***/ }),
/* 24 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* A classic Quicksort algorithm with Hoare's partition
* - Works also on LinkedList objects
*
* Copyright: i-Vis Research Group, Bilkent University, 2007 - present
*/
var LinkedList = __webpack_require__(11);
var Quicksort = function () {
function Quicksort(A, compareFunction) {
_classCallCheck(this, Quicksort);
if (compareFunction !== null || compareFunction !== undefined) this.compareFunction = this._defaultCompareFunction;
var length = void 0;
if (A instanceof LinkedList) length = A.size();else length = A.length;
this._quicksort(A, 0, length - 1);
}
_createClass(Quicksort, [{
key: '_quicksort',
value: function _quicksort(A, p, r) {
if (p < r) {
var q = this._partition(A, p, r);
this._quicksort(A, p, q);
this._quicksort(A, q + 1, r);
}
}
}, {
key: '_partition',
value: function _partition(A, p, r) {
var x = this._get(A, p);
var i = p;
var j = r;
while (true) {
while (this.compareFunction(x, this._get(A, j))) {
j--;
}while (this.compareFunction(this._get(A, i), x)) {
i++;
}if (i < j) {
this._swap(A, i, j);
i++;
j--;
} else return j;
}
}
}, {
key: '_get',
value: function _get(object, index) {
if (object instanceof LinkedList) return object.get_object_at(index);else return object[index];
}
}, {
key: '_set',
value: function _set(object, index, value) {
if (object instanceof LinkedList) object.set_object_at(index, value);else object[index] = value;
}
}, {
key: '_swap',
value: function _swap(A, i, j) {
var temp = this._get(A, i);
this._set(A, i, this._get(A, j));
this._set(A, j, temp);
}
}, {
key: '_defaultCompareFunction',
value: function _defaultCompareFunction(a, b) {
return b > a;
}
}]);
return Quicksort;
}();
module.exports = Quicksort;
/***/ }),
/* 25 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Needleman-Wunsch algorithm is an procedure to compute the optimal global alignment of two string
* sequences by S.B.Needleman and C.D.Wunsch (1970).
*
* Aside from the inputs, you can assign the scores for,
* - Match: The two characters at the current index are same.
* - Mismatch: The two characters at the current index are different.
* - Insertion/Deletion(gaps): The best alignment involves one letter aligning to a gap in the other string.
*/
var NeedlemanWunsch = function () {
function NeedlemanWunsch(sequence1, sequence2) {
var match_score = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
var mismatch_penalty = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : -1;
var gap_penalty = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : -1;
_classCallCheck(this, NeedlemanWunsch);
this.sequence1 = sequence1;
this.sequence2 = sequence2;
this.match_score = match_score;
this.mismatch_penalty = mismatch_penalty;
this.gap_penalty = gap_penalty;
// Just the remove redundancy
this.iMax = sequence1.length + 1;
this.jMax = sequence2.length + 1;
// Grid matrix of scores
this.grid = new Array(this.iMax);
for (var i = 0; i < this.iMax; i++) {
this.grid[i] = new Array(this.jMax);
for (var j = 0; j < this.jMax; j++) {
this.grid[i][j] = 0;
}
}
// Traceback matrix (2D array, each cell is an array of boolean values for [`Diag`, `Up`, `Left`] positions)
this.tracebackGrid = new Array(this.iMax);
for (var _i = 0; _i < this.iMax; _i++) {
this.tracebackGrid[_i] = new Array(this.jMax);
for (var _j = 0; _j < this.jMax; _j++) {
this.tracebackGrid[_i][_j] = [null, null, null];
}
}
// The aligned sequences (return multiple possibilities)
this.alignments = [];
// Final alignment score
this.score = -1;
// Calculate scores and tracebacks
this.computeGrids();
}
_createClass(NeedlemanWunsch, [{
key: "getScore",
value: function getScore() {
return this.score;
}
}, {
key: "getAlignments",
value: function getAlignments() {
return this.alignments;
}
// Main dynamic programming procedure
}, {
key: "computeGrids",
value: function computeGrids() {
// Fill in the first row
for (var j = 1; j < this.jMax; j++) {
this.grid[0][j] = this.grid[0][j - 1] + this.gap_penalty;
this.tracebackGrid[0][j] = [false, false, true];
}
// Fill in the first column
for (var i = 1; i < this.iMax; i++) {
this.grid[i][0] = this.grid[i - 1][0] + this.gap_penalty;
this.tracebackGrid[i][0] = [false, true, false];
}
// Fill the rest of the grid
for (var _i2 = 1; _i2 < this.iMax; _i2++) {
for (var _j2 = 1; _j2 < this.jMax; _j2++) {
// Find the max score(s) among [`Diag`, `Up`, `Left`]
var diag = void 0;
if (this.sequence1[_i2 - 1] === this.sequence2[_j2 - 1]) diag = this.grid[_i2 - 1][_j2 - 1] + this.match_score;else diag = this.grid[_i2 - 1][_j2 - 1] + this.mismatch_penalty;
var up = this.grid[_i2 - 1][_j2] + this.gap_penalty;
var left = this.grid[_i2][_j2 - 1] + this.gap_penalty;
// If there exists multiple max values, capture them for multiple paths
var maxOf = [diag, up, left];
var indices = this.arrayAllMaxIndexes(maxOf);
// Update Grids
this.grid[_i2][_j2] = maxOf[indices[0]];
this.tracebackGrid[_i2][_j2] = [indices.includes(0), indices.includes(1), indices.includes(2)];
}
}
// Update alignment score
this.score = this.grid[this.iMax - 1][this.jMax - 1];
}
// Gets all possible valid sequence combinations
}, {
key: "alignmentTraceback",
value: function alignmentTraceback() {
var inProcessAlignments = [];
inProcessAlignments.push({ pos: [this.sequence1.length, this.sequence2.length],
seq1: "",
seq2: ""
});
while (inProcessAlignments[0]) {
var current = inProcessAlignments[0];
var directions = this.tracebackGrid[current.pos[0]][current.pos[1]];
if (directions[0]) {
inProcessAlignments.push({ pos: [current.pos[0] - 1, current.pos[1] - 1],
seq1: this.sequence1[current.pos[0] - 1] + current.seq1,
seq2: this.sequence2[current.pos[1] - 1] + current.seq2
});
}
if (directions[1]) {
inProcessAlignments.push({ pos: [current.pos[0] - 1, current.pos[1]],
seq1: this.sequence1[current.pos[0] - 1] + current.seq1,
seq2: '-' + current.seq2
});
}
if (directions[2]) {
inProcessAlignments.push({ pos: [current.pos[0], current.pos[1] - 1],
seq1: '-' + current.seq1,
seq2: this.sequence2[current.pos[1] - 1] + current.seq2
});
}
if (current.pos[0] === 0 && current.pos[1] === 0) this.alignments.push({ sequence1: current.seq1,
sequence2: current.seq2
});
inProcessAlignments.shift();
}
return this.alignments;
}
// Helper Functions
}, {
key: "getAllIndexes",
value: function getAllIndexes(arr, val) {
var indexes = [],
i = -1;
while ((i = arr.indexOf(val, i + 1)) !== -1) {
indexes.push(i);
}
return indexes;
}
}, {
key: "arrayAllMaxIndexes",
value: function arrayAllMaxIndexes(array) {
return this.getAllIndexes(array, Math.max.apply(null, array));
}
}]);
return NeedlemanWunsch;
}();
module.exports = NeedlemanWunsch;
/***/ }),
/* 26 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var layoutBase = function layoutBase() {
return;
};
layoutBase.FDLayout = __webpack_require__(18);
layoutBase.FDLayoutConstants = __webpack_require__(7);
layoutBase.FDLayoutEdge = __webpack_require__(19);
layoutBase.FDLayoutNode = __webpack_require__(20);
layoutBase.DimensionD = __webpack_require__(21);
layoutBase.HashMap = __webpack_require__(22);
layoutBase.HashSet = __webpack_require__(23);
layoutBase.IGeometry = __webpack_require__(8);
layoutBase.IMath = __webpack_require__(9);
layoutBase.Integer = __webpack_require__(10);
layoutBase.Point = __webpack_require__(12);
layoutBase.PointD = __webpack_require__(4);
layoutBase.RandomSeed = __webpack_require__(16);
layoutBase.RectangleD = __webpack_require__(13);
layoutBase.Transform = __webpack_require__(17);
layoutBase.UniqueIDGeneretor = __webpack_require__(14);
layoutBase.Quicksort = __webpack_require__(24);
layoutBase.LinkedList = __webpack_require__(11);
layoutBase.LGraphObject = __webpack_require__(2);
layoutBase.LGraph = __webpack_require__(5);
layoutBase.LEdge = __webpack_require__(1);
layoutBase.LGraphManager = __webpack_require__(6);
layoutBase.LNode = __webpack_require__(3);
layoutBase.Layout = __webpack_require__(15);
layoutBase.LayoutConstants = __webpack_require__(0);
layoutBase.NeedlemanWunsch = __webpack_require__(25);
module.exports = layoutBase;
/***/ }),
/* 27 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
function Emitter() {
this.listeners = [];
}
var p = Emitter.prototype;
p.addListener = function (event, callback) {
this.listeners.push({
event: event,
callback: callback
});
};
p.removeListener = function (event, callback) {
for (var i = this.listeners.length; i >= 0; i--) {
var l = this.listeners[i];
if (l.event === event && l.callback === callback) {
this.listeners.splice(i, 1);
}
}
};
p.emit = function (event, data) {
for (var i = 0; i < this.listeners.length; i++) {
var l = this.listeners[i];
if (event === l.event) {
l.callback(data);
}
}
};
module.exports = Emitter;
/***/ })
/******/ ]);
}); |