-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.d.ts
4733 lines (4395 loc) · 188 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
// Type definitions for Cytoscape.js 2.4.2
// Project: http://js.cytoscape.org/
// Definitions by: Fabian Schmidt and Fred Eisele <https://github.com/phreed>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Translation from Objects in help to Typescript interface.
// http://js.cytoscape.org/#notation/functions
//
/**
* cy --> Cy.Instance
* the core
* ele --> Cy.CollectionFirst
* a collection of a single element (node or edge)
* eles --> Cy.Collection
* a collection of one or more elements (nodes and edges)
* node --> Cy.CollectionFirstNode
* a collection of a single node
* nodes -> Cy.CollectionNodes
* a collection of one or more nodes
* edge --> Cy.CollectionFirstEdge
* a collection of a single edge
* edges -> Cy.CollectionEdges
* a collection of one or more edges
*
* The library makes a distinction between input and output parameters
* due to the dynamic behaviour of the Cytoscape library.
*
* For a input parameter it will always expect:
* - Cy.Collection
* The input can be any element (node and edge) collection.
* - Cy.CollectionNodes
* The input must be a node collection.
* - Cy.CollectionEdges
* The input must be a edge collection.
* - Cy.CollectionFirst
* The input must be a single element.
* - Cy.CollectionFirstNode
* The inut must be a single node.
* - Cy.CollectionFirstEdge
* The input must be a single edge.
*
* For a output of a function it will always give:
* - Cy.CollectionElements
* The output is a collection of node and edge elements OR single element.
* - Cy.CollectionEdges
* The output is a collection of edge elements OR single edge.
* - Cy.CollectionNodes
* The output is a collection of node elements OR single node.
*/
declare namespace Cy {
/**
* See http://js.cytoscape.org/#selectors for details about writing selectors.
*/
type Selector = string;
/**
* Possbile values are 'additive' or 'single'.
*/
type SelectionType = string;
/**
* Possible values are 'nodes' or 'edges'.
*/
type ElementGroup = string;
/**
* Possible values are 'x' or 'y'.
*/
type PositionDimension = string;
/**
* Usually temp or nonserialisable data can be stored.
*/
type Scratchpad = any;
type MinumumSpanningTree = any;
/**
* The output is a collection of node and edge elements OR single element.
*/
interface CollectionElements extends
CollectionEdges, CollectionNodes, CollectionFirstElement {
//Intentionally empty.
}
/**
* edges -> Cy.CollectionEdges
* a collection of one or more edges
*
* The output is a collection of edge elements OR single edge.
*/
interface CollectionEdges extends Collection, CollectionFirstEdge,
CollectionEdgesTraversing { }
/**
* nodes -> Cy.CollectionNodes
* a collection of one or more nodes
*
* The output is a collection of node elements OR single node.
*/
interface CollectionNodes extends Collection, CollectionFirstNode,
CollectionNodesMetadata, CollectionNodesPosition, CollectionNodesTraversing, CollectionNodesCompound { }
/**
* eles --> Cy.Collection
* a collection of one or more elements (nodes and edges)
*
* The input can be any element (node and edge) collection.
*/
interface Collection extends CollectionFirst,
CollectionManipulation, CollectionEvents, CollectionData, CollectionPosition,
CollectionLayout, CollectionSelection, CollectionStyle, CollectionAnimation,
CollectionComparision, CollectionIteration, CollectionBuildingUnion, CollectionAlgorithms { }
interface CollectionFirstElement extends CollectionFirstEdge, CollectionFirstNode {
//Intentionally empty.
}
/**
* edge --> Cy.CollectionFirstEdge
* a collection of a single edge
*/
interface CollectionFirstEdge extends CollectionFirst,
CollectionFirstEdgeData, CollectionFirstEdgeTraversing { }
/**
* node --> Cy.CollectionFirstNode
* a collection of a single node
*/
interface CollectionFirstNode extends CollectionFirst,
CollectionFirstNodeMetadata, CollectionFirstNodePosition, CollectionFirstNodeCompound { }
/**
* ele --> Cy.CollectionFirst
* a collection of a single element (node or edge)
*/
interface CollectionFirst extends
CollectionFirstManipulation, CollectionFirstData, CollectionFirstPosition,
CollectionFirstSelection, CollectionFirstStyle, CollectionFirtsAnimation { }
/**
* http://js.cytoscape.org/#collection/graph-manipulation
*/
interface CollectionManipulation {
/**
* Remove the elements from the graph.
* http://js.cytoscape.org/#eles.remove
*/
remove(): CollectionElements;
/**
* Put removed elements back into the graph.
* http://js.cytoscape.org/#eles.restore
*/
restore(): CollectionElements;
/**
* Get a new collection containing clones (i.e. copies) of the elements in the calling collection.
* http://js.cytoscape.org/#eles.clone
*/
clone(): CollectionElements;
/**
* Get a new collection containing clones (i.e. copies) of the elements in the calling collection.
* http://js.cytoscape.org/#eles.clone
*/
copy(): CollectionElements;
/**
* Effectively move edges to different nodes. The modified (actually new) elements are returned.
* http://js.cytoscape.org/#eles.move
*/
move(location: { source?: string, target?: string }): CollectionEdges;
/**
* Effectively move nodes to different parent node. The modified (actually new) elements are returned.
* http://js.cytoscape.org/#eles.move
*/
move(location: { parent: string }): CollectionNodes;
}
/**
*
* http://js.cytoscape.org/#collection/events
*/
interface CollectionEvents {
/**
* http://js.cytoscape.org/#eles.on
*/
on(events: string, selector: string, data: any, handler: EventHandler): void;
on(events: string, selector: string, handler: EventHandler): void;
on(events: string, data: any, handler: EventHandler): void;
on(events: string, handler: EventHandler): void;
/**
* http://js.cytoscape.org/#eles.promiseOn
* alias: pon
*/
promiseOn(events: string, selector?: string): Promise<EventHandler>;
pon(events: string, selector?: string): Promise<EventHandler>;
/**
* @param events A space separated list of event names.
* @param selector [optional] A delegate selector to specify child elements for which the handler is triggered.
* @param data [optional] A plain object which is passed to the handler in the event object argument.
* @param function(event) The handler function that is called when one of the specified events occurs.
* @param event The event object.
* http://js.cytoscape.org/#eles.one
*/
one(events: string, selector: string, data: any, handler: EventHandler): void;
one(events: string, selector: string, handler: EventHandler): void;
one(events: string, data: any, handler: EventHandler): void;
one(events: string, handler: EventHandler): void;
/**
* http://js.cytoscape.org/#eles.once
*/
once(events: string, selector: string, data: any, handler: EventHandler): void;
once(events: string, selector: string, handler: EventHandler): void;
once(events: string, data: any, handler: EventHandler): void;
once(events: string, handler: EventHandler): void;
/**
* http://js.cytoscape.org/#eles.off
* alias unbind, unlisten, removeListener
*/
off(events: string, selector?: string, handler?: EventHandler): void;
/**
* http://js.cytoscape.org/#eles.trigger
* alias: emit
*/
trigger(events: string, extra?: string[]): void;
}
/**
* http://js.cytoscape.org/#collection/data
*
* The following fields are immutable:
* id: The id field is used to uniquely identify an element in the graph.
* source & target : These fields define an edge's relationship to nodes, and this relationship can not be changed after creation.
* parent: The parent field defines the parent (compound) node.
*
*
*/
interface CollectionData {
/**
* Remove developer-defined data associated with the elements.
* http://js.cytoscape.org/#eles.removeData
*/
removeData(): CollectionElements;
/**
* Remove developer-defined data associated with the elements.
*
* @param names A space-separated list of fields to delete.
*/
removeData(names: string): CollectionElements;
/**
* Remove developer-defined data associated with the elements.
*/
removeAttr(): CollectionElements;
/**
* Remove developer-defined data associated with the elements.
*
* @param names A space-separated list of fields to delete.
*/
removeAttr(names: string): CollectionElements;
/**
* Get an array of the plain JavaScript object representation of all elements in the collection.
*/
jsons(): string[];
}
interface CollectionNodesMetadata {
//http://js.cytoscape.org/#collection/metadata
/**
* Get the maximum degree of the nodes in the collection.
*
* For a node, the degree is the number of edge connections it has. Each time a node is referenced as source or target of an edge in the graph, that counts as an edge connection.
*
* For a set of nodes, the the total degree is the total number of edge connections to nodes in the set.
*
* @param includeLoops A boolean, indicating whether loops are to be included in degree calculations.
*/
maxDegree(includeLoops: boolean): number;
/**
* Get the minimum indegree of the nodes in the collection.
*
* For a node, the indegree is the number of incoming edge connections it has. Each time a node is referred to as target of an edge in the graph, that counts as an incoming edge connection.
*
* For a set of nodes, the the total degree is the total number of edge connections to nodes in the set.
*
* @param includeLoops A boolean, indicating whether loops are to be included in degree calculations.
*/
minIndegree(includeLoops: boolean): number;
/**
* Get the maximum indegree of the nodes in the collection.
*
* For a node, the indegree is the number of incoming edge connections it has. Each time a node is referred to as target of an edge in the graph, that counts as an incoming edge connection.
*
* For a set of nodes, the the total degree is the total number of edge connections to nodes in the set.
*
* @param includeLoops A boolean, indicating whether loops are to be included in degree calculations.
*/
maxIndegree(includeLoops: boolean): number;
/**
* Get the minimum outdegree of the nodes in the collection.
*
* For a node, the outdegree is the number of outgoing edge connections it has. Each time a node is referred to as source of an edge in the graph, that counts as an outgoing edge connection.
*
* For a set of nodes, the the total degree is the total number of edge connections to nodes in the set.
*
* @param includeLoops A boolean, indicating whether loops are to be included in degree calculations.
*/
minOutdegree(includeLoops: boolean): number;
/**
* Get the maximum outdegree of the nodes in the collection.
*
* For a node, the outdegree is the number of outgoing edge connections it has. Each time a node is referred to as source of an edge in the graph, that counts as an outgoing edge connection.
*
* For a set of nodes, the the total degree is the total number of edge connections to nodes in the set.
*
* @param includeLoops A boolean, indicating whether loops are to be included in degree calculations.
*/
maxOutdegree(includeLoops: boolean): number;
}
interface CollectionPosition {
//http://js.cytoscape.org/#collection/position--dimensions
/**
* Get the bounding box of the elements in model coordinates.
*
* @param options An object containing options for the function.
*/
boundingBox(options: BoundingBoxOptions): { x1: number, x2: number, y1: number, y2: number, w: number, h: number };
/**
* Get the bounding box of the elements in model coordinates.
*
* @param options An object containing options for the function.
*/
boundingbox(options: BoundingBoxOptions): { x1: number, x2: number, y1: number, y2: number, w: number, h: number };
/**
* Get the bounding box of the elements in rendered coordinates.
*
* @param options An object containing options for the function.
*/
renderedBoundingBox(options: BoundingBoxOptions): { x1: number, x2: number, y1: number, y2: number, w: number, h: number };
/**
* Get the bounding box of the elements in rendered coordinates.
*
* @param options An object containing options for the function.
*/
renderedBoundingbox(options: BoundingBoxOptions): { x1: number, x2: number, y1: number, y2: number, w: number, h: number };
}
interface CollectionNodesPosition {
//http://js.cytoscape.org/#collection/position--dimensions
/**
* Set the positions functionally.
*
* @param callback A callback function that returns the position to set for each element.
* i - The index of the element when iterating over the elements in the collection.
* ele - The element being iterated over for which the function should return a position to set.
*/
positions(callback: (i: number, ele: CollectionNodes) => Position): CollectionNodes;
/**
* Set positions for all nodes based on a single position object.
*
* @param pos An object specifying name-value pairs representing dimensions to set.
*/
positions(pos: Position): CollectionNodes;
/**
* Set the positions functionally.
*
* @param callback A callback function that returns the position to set for each element.
* i - The index of the element when iterating over the elements in the collection.
* ele - The element being iterated over for which the function should return a position to set.
*/
modelPositions(callback: (i: number, ele: CollectionNodes) => Position): CollectionNodes;
/**
* Set positions for all nodes based on a single position object.
*
* @param pos An object specifying name-value pairs representing dimensions to set.
*/
modelPositions(pos: Position): CollectionNodes;
/**
* Set the positions functionally.
*
* @param callback A callback function that returns the position to set for each element.
* i - The index of the element when iterating over the elements in the collection.
* ele - The element being iterated over for which the function should return a position to set.
*/
points(callback: (i: number, ele: CollectionNodes) => Position): CollectionNodes;
/**
* Set positions for all nodes based on a single position object.
*
* @param pos An object specifying name-value pairs representing dimensions to set.
*/
points(pos: Position): CollectionNodes;
/**
* Allow the user to grab the nodes.
*/
grabify(): CollectionNodes;
/**
* Disallow the user to grab the nodes.
*/
ungrabify(): CollectionNodes;
/**
* Lock the nodes such that their positions can not be changed.
*/
lock(): CollectionNodes;
/**
* Unlock the nodes such that their positions can be changed.
*/
unlock(): CollectionNodes;
}
/**
* http://js.cytoscape.org/#collection/layout
*/
interface CollectionLayout {
/**
* Run a layout on the elements in the calling collection, algorithmically positioning the nodes.
* This function is useful for running a layout on a subset of the elements in the graph.
*
* @param options The layout options.
*/
layout(options: LayoutOptions): CollectionElements;
/**
* Get a new layout, which can be used to algorithmically position the nodes in the collection.
* This function is useful for running a layout on a subset of the elements in the graph, perhaps in parallel to other layouts.
*
* You must specify options.name with the name of the layout you wish to use.
*
* Note: that you must call layout.run() in order for it to affect the graph.
*
* @param options The layout options.
*/
makeLayout(options: LayoutOptions): LayoutInstance;
/**
* Get a new layout, which can be used to algorithmically position the nodes in the collection.
* This function is useful for running a layout on a subset of the elements in the graph, perhaps in parallel to other layouts.
*
* You must specify options.name with the name of the layout you wish to use.
*
* Note: that you must call layout.run() in order for it to affect the graph.
*
* @param options The layout options.
*/
createLayout(options: LayoutOptions): LayoutInstance;
}
interface CollectionSelection {
// http://js.cytoscape.org/#collection/selection
/**
* Make the elements selected (NB other elements outside the collection are not affected).
*/
select(): CollectionElements;
/**
* Make the elements not selected (NB other elements outside the collection are not affected).
*/
unselect(): CollectionElements;
/**
* Make the elements not selected (NB other elements outside the collection are not affected).
*/
deselect(): CollectionElements;
/**
* Make the selection states of the elements mutable.
*/
selectify(): CollectionElements;
/**
* Make the selection states of the elements immutable.
*/
unselectify(): CollectionElements;
}
/**
* http://js.cytoscape.org/#collection/style
*/
interface CollectionStyle {
/**
* Add classes to elements.
*
* @param classes A space-separated list of class names to add to the elements.
*/
addClass(classes: string): CollectionElements;
/**
* Remove classes from elements.
*
* @param classes A space-separated list of class names to remove from the elements.
*/
removeClass(classes: string): CollectionElements;
/**
* Toggle whether the elements have the specified classes.
*
* @param classes A space-separated list of class names to toggle on the elements.
* @param toggle [optional] Instead of automatically toggling, adds the classes on truthy values or removes them on falsey values.
*/
toggleClass(classes: string, toggle?: boolean): CollectionElements;
/**
* Add classes to the elements, and then remove the classes after a specified duration.
*
* @param classes A space-separated list of class names to flash on the elements.
* @param duration [optional] The duration in milliseconds that the classes should be added on the elements. After the duration, the classes are removed.
*/
flashClass(classes: string, duration?: number): CollectionElements;
/**
* Get a name-value pair object containing visual style properties and their values for the element.
*/
style(): Css.Node | Css.Edge;
/**
* Get a particular style property value.
*
* @param name The name of the visual style property to get.
*/
style(name: string): Css.Node | Css.Edge;
/**
* Get a name-value pair object containing visual style properties and their values for the element.
*/
css(): Css.Node | Css.Edge;
/**
* Get a particular style property value.
*
* @param name The name of the visual style property to get.
*/
css(name: string): Css.Node | Css.Edge;
/**
* Get a name-value pair object containing visual style properties and their values for the element.
*/
bypass(): Css.Node | Css.Edge;
/**
* Get a particular style property value.
*
* @param name The name of the visual style property to get.
*/
bypass(name: string): Css.Node | Css.Edge;
/**
* Set the specified visual style property for the elements.
*
* You should use this function very sparingly, because it overrides the style of an element, despite the state and classes that it has. In general, it's much better to specify a better stylesheet at initialisation that reflects your application state rather than programmatically modifying style.
*
* If you would like to remove a particular overridden style property, set null to it.
*
* @param name The name of the property to set.
* @param value The value to set to the visual style property.
*/
style(name: string, value: string): CollectionElements;
/**
* Set several visual style properties at once for the elements.
*
* You should use this function very sparingly, because it overrides the style of an element, despite the state and classes that it has. In general, it's much better to specify a better stylesheet at initialisation that reflects your application state rather than programmatically modifying style.
*
* If you would like to remove a particular overridden style property, set null to it.
*
* @param props An object with name-value pairs representing properties to set on the elements.
*/
style(props: Css.Node | Css.Edge): CollectionElements;
/**
* Set the specified visual style property for the elements.
*
* You should use this function very sparingly, because it overrides the style of an element, despite the state and classes that it has. In general, it's much better to specify a better stylesheet at initialisation that reflects your application state rather than programmatically modifying style.
*
* If you would like to remove a particular overridden style property, set null to it.
*
* @param name The name of the property to set.
* @param value The value to set to the visual style property.
*/
css(name: string, value: string): CollectionElements;
/**
* Set several visual style properties at once for the elements.
*
* You should use this function very sparingly, because it overrides the style of an element, despite the state and classes that it has. In general, it's much better to specify a better stylesheet at initialisation that reflects your application state rather than programmatically modifying style.
*
* If you would like to remove a particular overridden style property, set null to it.
*
* @param props An object with name-value pairs representing properties to set on the elements.
*/
css(props: Css.Node | Css.Edge): CollectionElements;
/**
* Set the specified visual style property for the elements.
*
* You should use this function very sparingly, because it overrides the style of an element, despite the state and classes that it has. In general, it's much better to specify a better stylesheet at initialisation that reflects your application state rather than programmatically modifying style.
*
* If you would like to remove a particular overridden style property, set null to it.
*
* @param name The name of the property to set.
* @param value The value to set to the visual style property.
*/
bypass(name: string, value: string): CollectionElements;
/**
* Set several visual style properties at once for the elements.
*
* You should use this function very sparingly, because it overrides the style of an element, despite the state and classes that it has. In general, it's much better to specify a better stylesheet at initialisation that reflects your application state rather than programmatically modifying style.
*
* If you would like to remove a particular overridden style property, set null to it.
*
* @param props An object with name-value pairs representing properties to set on the elements.
*/
bypass(props: Css.Node | Css.Edge): CollectionElements;
/**
* Removes all overridden style of the elements.
*/
removeStyle(): CollectionElements;
/**
* Removes particular overridden style properties of the elements.
*
* @param names A space-separated list of property names for which overridden styles will be removed.
*/
removeStyle(names: string): CollectionElements;
/**
* Removes all overridden style of the elements.
*/
removeCss(): CollectionElements;
/**
* Removes particular overridden style properties of the elements.
*
* @param names A space-separated list of property names for which overridden styles will be removed.
*/
removeCss(names: string): CollectionElements;
/**
* Removes all overridden style of the elements.
*/
removeBypass(): CollectionElements;
/**
* Removes particular overridden style properties of the elements.
*
* @param names A space-separated list of property names for which overridden styles will be removed.
*/
removeBypass(names: string): CollectionElements;
}
interface CollectionAnimation {
// http://js.cytoscape.org/#collection/animation
/**
* Animate the elements.
*
* Note that you can specify only one of position and renderedPosition: You can not animate to two positions at once.
*
* @param anis An object containing the details of the animation.
* position - A position to which the elements will be animated.
* renderedPosition - A rendered position to which the elements will be animated.
* style - An object containing name-value pairs of style properties to animate.
* @param options An object containing animation options.
* duration - The duration of the animation in milliseconds.
* queue - A boolean indicating whether to queue the animation.
* complete - A function to call when the animation is done.
* step - A function to call each time the animation steps.
*/
animate(anis: {
postion?: Position,
renderedPosition?: Position,
style?: Css.Node | Css.Edge
}, options?: {
duration?: number,
queue?: boolean,
complete?: () => void,
step?: () => void
}): CollectionElements;
/**
* Add a delay between animations for the elements.
*
* @param duration How long the delay should be in milliseconds.
* @param complete A function to call when the delay is complete.
*/
delay(duration: number, complete?: () => void): CollectionElements;
/**
* Stop all animations that are currently running.
*
* @param clearQueue A boolean, indicating whether the queue of animations should be emptied.
* @param jumpToEnd A boolean, indicating whether the currently-running animations should jump to their ends rather than just stopping midway.
*/
stop(clearQueue?: boolean, jumpToEnd?: boolean): CollectionElements;
/**
* Remove all queued animations for the elements.
*/
clearQueue(): CollectionElements;
}
interface CollectionComparision {
// http://js.cytoscape.org/#collection/comparison
/**
* Determine whether this collection contains exactly the same elements as another collection.
*
* @param eles The other elements to compare to.
*/
same(eles: Collection): boolean;
/**
* Determine whether this collection contains any of the same elements as another collection.
*
* @param eles The other elements to compare to.
*/
anySame(eles: Collection): boolean;
/**
* Determine whether all elements in the specified collection are in the neighbourhood of the calling collection.
*
* @param eles The other elements to compare to.
*/
allAreNeighbors(eles: Collection): boolean;
/**
* Determine whether all elements in the specified collection are in the neighbourhood of the calling collection.
*
* @param eles The other elements to compare to.
*/
allAreNeighbours(eles: Collection): boolean;
/**
* Determine whether any element in this collection matches a selector.
*
* @param selector The selector to match against.
*/
is(selector: Selector): boolean;
/**
* Determine whether all elements in the collection match a selector.
* @param selector The selector to match against.
*/
allAre(selector: Selector): boolean;
/**
* Determine whether any element in this collection satisfies the specified test function.
*
* @param test The test function that returns truthy values for elements that satisfy the test and falsey values for elements that do not satisfy the test.
* ele - The current element.
* i - The index of the current element.
* eles - The collection of elements being tested.
* @param thisArg [optional] The value for this within the test function.
*/
some(test: (ele: CollectionElements, i: number, eles: CollectionElements) => boolean, thisArg?: any): boolean;
/**
* Determine whether all elements in this collection satisfy the specified test function.
*
* @param test The test function that returns truthy values for elements that satisfy the test and falsey values for elements that do not satisfy the test.
* ele - The current element.
* i - The index of the current element.
* eles - The collection of elements being tested.
* @param thisArg [optional] The value for this within the test function.
*/
every(test: (ele: CollectionElements, i: number, eles: CollectionElements) => boolean, thisArg?: any): boolean;
}
interface CollectionIteration {
// http://js.cytoscape.org/#collection/iteration
/**
* Get the number of elements in the collection.
*/
size(): number;
/**
* Get the number of elements in the collection.
*/
length: number;
/**
* Get whether the collection is empty, meaning it has no elements.
*/
empty(): boolean;
/**
* Get whether the collection is nonempty, meaning it has elements.
*/
nonempty(): boolean;
/**
* Iterate over the elements in the collection.
*
* Note that although this function is convenient in some cases, it is less efficient than making your own loop.
*
* @param each The function executed each iteration.
* i - The index of the element in the collection.
* ele - The element at the current index.
*/
each(each: (i: number, ele: CollectionElements) => void): void;
/**
* Iterate over the elements in the collection using an implementation like the native array function namesake.
*
* This function behaves like Array.prototype.forEach() with minor changes for convenience:
* You can exit the iteration early by returning false in the iterating function. The Array.prototype.forEach() implementation does not support this, but it is included anyway on account of its utility.
*
* @param each The function executed each iteration.
* ele - The current element.
* i - The index of the current element.
* eles - The collection of elements being iterated.
* @param thisArg [optional] The value for this within the iterating function.
*/
forEach(each: (ele: CollectionElements, i: number, eles: CollectionElements) => void | boolean, thisArg?: any): void;
/**
* Get an element at a particular index in the collection.
*
* You may use eles[i] in place of eles.eq(i) as a more performant alternative.
*
* @param index The index of the element to get.
*/
eq(index: number): CollectionElements;
/**
* Get an element at a particular index in the collection.
*
* @param index The index of the element to get.
*/
[index: number]: CollectionElements;
/**
* Get the first element in the collection.
*/
first(): CollectionElements;
/**
* Get the last element in the collection.
*/
last(): CollectionElements;
/**
* Get a subset of the elements in the collection based on specified indices.
*
* @param start [optional] An integer that specifies where to start the selection. The first element has an index of 0. Use negative numbers to select from the end of an array.
* @param end [optional] An integer that specifies where to end the selection. If omitted, all elements from the start position and to the end of the array will be selected. Use negative numbers to select from the end of an array.
*/
slice(start?: number, end?: number): CollectionElements;
}
interface CollectionBuildingUnion {
/**
* Get a new collection, resulting from adding the collection with another one
*
* @param eles The elements to add.
*/
(eles: Collection): CollectionElements;
/**
* Get a new collection, resulting from adding the collection with another one
*
* @param elesArray An array of elements to add.
*/
(elesArray: Collection[]): CollectionElements;
/**
* Get a new collection, resulting from adding the collection with another one
*
* @param selector Elements in the graph matching this selector are added.
*/
(selector: Selector): CollectionElements;
}
interface CollectionBuildingDifference {
/**
* Get a new collection, resulting from the collection without some specified elements.
*
* @param eles The elements that will not be in the resultant collection.
*/
(eles: Collection): CollectionElements;
/**
* Get a new collection, resulting from the collection without some specified elements.
*
* @param selector Elements from the calling collection matching this selector will not be in the resultant collection.
*/
(selector: Selector): CollectionElements;
}
interface CollectionBuildingIntersection {
/**
* Get the elements in both this collection and another specified collection.
*
* @param eles The elements to intersect with.
*/
(eles: Collection): CollectionElements;
/**
* Get the elements in both this collection and another specified collection.
*
* @param selector A selector representing the elements to intersect with. All elements in the graph matching the selector are used as the passed collection.
*/
(selector: Selector): CollectionElements;
}
interface CollectionSymmetricDifference {
/**
* Get the elements that are in the calling collection or the passed collection but not in both.
*
* @param eles The elements to apply the symmetric difference with.
*/
(eles: Collection): CollectionElements;
/**
* Get the elements that are in the calling collection or the passed collection but not in both.
*
* @param selector A selector representing the elements to apply the symmetric difference with. All elements in the graph matching the selector are used as the passed collection.
*/
(selector: Selector): CollectionElements;
}
interface CollectionBuildingUnion {
// http://js.cytoscape.org/#collection/building--filtering
union: CollectionBuildingUnion;
//[index: "u"]: CollectionBuildingUnion;
add: CollectionBuildingUnion;
//[index: "+"]: CollectionBuildingUnion;
or: CollectionBuildingUnion;
//[index: "|"]: CollectionBuildingUnion;
difference: CollectionBuildingDifference;
//[index: "\\"]: CollectionBuildingDifference;
not: CollectionBuildingDifference;
//[index: "!"]: CollectionBuildingDifference;
relativeComplement(): CollectionBuildingDifference;
//[index: "-"]: CollectionBuildingDifference;
/**
* Get all elements in the graph that are not in the calling collection.
*/
absoluteComplement(): CollectionElements;
/**
* Get all elements in the graph that are not in the calling collection.
*/
abscomp(): CollectionElements;
/**
* Get all elements in the graph that are not in the calling collection.
*/
complement(): CollectionElements;
intersection: CollectionBuildingIntersection;
intersect: CollectionBuildingIntersection;
and: CollectionBuildingIntersection;
//[index: "n"]: CollectionBuildingIntersection;
//[index: "&"]: CollectionBuildingIntersection;
//[index: "."]: CollectionBuildingIntersection;
symmetricDifference: CollectionSymmetricDifference;
symdiff: CollectionSymmetricDifference;
xor: CollectionSymmetricDifference;
//[index: "^"]: CollectionSymmetricDifference;
//[index: "(+)"]: CollectionSymmetricDifference;
//[index: "(-)"]: CollectionSymmetricDifference;
//[index: string]: CollectionBuildingDifference |CollectionBuildingUnion | CollectionBuildingIntersection | CollectionSymmetricDifference;
/**
* Perform a traditional left/right diff on the two collections.
*
* @param eles The elements on the right side of the diff.
*/
diff(eles: Collection): CollectionElements;
/**
* Perform a traditional left/right diff on the two collections.
*
* @param selector A selector representing the elements on the right side of the diff. All elements in the graph matching the selector are used as the passed collection.
* @return This function returns a plain object of the form { left, right, both } where
* left - is the set of elements only in the calling (i.e. left) collection,
* right - is the set of elements only in the passed (i.e. right) collection, and
* both - is the set of elements in both collections.
*/
diff(selector: Selector): {
left: CollectionElements,
right: CollectionElements,
both: CollectionElements
};
/**
* Get a new collection containing elements that are accepted by the specified filter.
*
* @param selector The selector to match against.
*/
filter(selector: Selector): CollectionElements;
/**
* Get a new collection containing elements that are accepted by the specified filter.
*
* @filter selector The filter function that returns true for elements to include.
* i - The index of the current element being considered.
* ele - The element being considered.
*/
filter(filter: (i: number, ele: CollectionElements) => boolean): CollectionElements;
/**
* Get the nodes that match the specified selector.
*
* @param selector The selector to match against.
*/
nodes(selector: Selector): CollectionNodes;
/**
* Get the edges that match the specified selector.
*
* @param selector The selector to match against.
*/
edges(selector: Selector): CollectionEdges;
/**
* Get a new collection containing elements that are accepted by the specified filter, using an implementation like the standard array namesake.
*
* @param filter The filter function that returns truthy values for elements to include and falsey values for elements to exclude.