-
Notifications
You must be signed in to change notification settings - Fork 286
/
SimpleGraphBuilder.js
4083 lines (3615 loc) · 177 KB
/
SimpleGraphBuilder.js
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
/****************************************************************************
** @license
** This demo file is part of yFiles for HTML 2.6.
** Copyright (c) 2000-2024 by yWorks GmbH, Vor dem Kreuzberg 28,
** 72070 Tuebingen, Germany. All rights reserved.
**
** yFiles demo files exhibit yFiles for HTML functionalities. Any redistribution
** of demo files in source code or binary form, with or without
** modification, is not permitted.
**
** Owners of a valid software license for a yFiles for HTML version that this
** demo is shipped with are allowed to use the demo source code as basis
** for their own yFiles for HTML powered applications. Use of such programs is
** governed by the rights and conditions as set out in the yFiles for HTML
** license agreement.
**
** THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESS OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
** NO EVENT SHALL yWorks BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
** TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
***************************************************************************/
import {
AdjacencyGraphBuilder,
AdjacencyNodesSource,
Class,
DefaultGraph,
EdgeCreator,
EdgesSource,
GraphBuilder,
IEdge,
IEnumerable,
IGraph,
ILabelDefaults,
ILabelOwner,
IModelItem,
INode,
ITagOwner,
ItemEventArgs,
NodeCreator,
NodesSource,
Point,
Rect
} from 'yfiles'
/**
* @typedef {Object} GraphBuilderOptionArgs
* @property {IGraph} [graph]
* @property {boolean} [lazyNodeDefinition]
* @property {*} [nodesSource]
* @property {*} [edgesSource]
* @property {*} [groupsSource]
* @property {*} [nodeIdBinding]
* @property {*} [edgeIdBinding]
* @property {*} [nodeLabelBinding]
* @property {*} [groupBinding]
* @property {*} [edgeLabelBinding]
* @property {*} [sourceNodeBinding]
* @property {*} [targetNodeBinding]
* @property {*} [groupIdBinding]
* @property {*} [groupLabelBinding]
* @property {*} [parentGroupBinding]
* @property {*} [locationXBinding]
* @property {*} [locationYBinding]
*/
/**
* @typedef {function} SimpleNodeListener
*/
/**
* @typedef {function} SimpleEdgeListener
*/
/**
Populates a graph from custom data.
This class can be used when the data specifies a collection of nodes, a collection of edges, and optionally a collection
of groups. The properties {@link SimpleGraphBuilder.nodesSource}, {@link SimpleGraphBuilder.groupsSource}, and {@link SimpleGraphBuilder.edgesSource} define the source collections from which nodes, groups, and edges will be created.
Generally, using the {@link SimpleGraphBuilder} class consists of a few basic steps:
1. Set up the {@link SimpleGraphBuilder.graph} with the proper defaults for items ({@link IGraph.nodeDefaults}, {@link IGraph.groupNodeDefaults}, {@link IGraph.edgeDefaults})
2. Create a {@link SimpleGraphBuilder}.
3. Set the items sources. At the very least the {@link SimpleGraphBuilder.nodesSource} (unless using {@link SimpleGraphBuilder.lazyNodeDefinition}) and {@link SimpleGraphBuilder.edgesSource} are needed. If the items in the nodes collection are
grouped somehow, then also set the {@link SimpleGraphBuilder.groupsSource} property.
4. Set up the bindings so that a graph structure can actually be created from the items sources. This involves at least
setting up the {@link SimpleGraphBuilder.sourceNodeBinding} and {@link SimpleGraphBuilder.targetNodeBinding} properties so that edges can be created. If the edge objects don't actually contain the node
objects as source and target, but instead an identifier of the node objects, then {@link SimpleGraphBuilder.sourceNodeBinding} and {@link SimpleGraphBuilder.targetNodeBinding} would return those identifiers
and {@link SimpleGraphBuilder.nodeIdBinding} must be set to return that identifier when given a node object.
5. If {@link SimpleGraphBuilder.groupsSource} is set, then you also need to set the {@link SimpleGraphBuilder.groupBinding} property to enable mapping nodes to groups. Just like with edges and their
source and target nodes, if the node object only contains an identifier for a group node and not the actual group
object, then return the identifier in the {@link SimpleGraphBuilder.groupBinding} and set up the {@link SimpleGraphBuilder.groupIdBinding} to map group node objects to their identifiers. If group
nodes can nest, you also need the {@link SimpleGraphBuilder.parentGroupBinding}.
6. You can also easily create labels for nodes, groups, and edges by using the {@link SimpleGraphBuilder.nodeLabelBinding}, {@link SimpleGraphBuilder.groupLabelBinding}, and {@link SimpleGraphBuilder.edgeLabelBinding} properties.
7. Call {@link SimpleGraphBuilder.buildGraph} to populate the graph. You can apply a layout algorithm afterward to make the graph look nice.
8. If your items or collections change later, call {@link SimpleGraphBuilder.updateGraph} to make those changes visible in the graph.
You can further customize how nodes, groups, and edges are created by adding event handlers to the various events and
modifying the items there. This can be used to modify items in ways that are not directly supported by the available
bindings or defaults. This includes scenarios such as the following:
- Setting node positions or adding bends to edges. Often a layout is applied to the graph after building it, so these
things are only rarely needed.
- Modifying individual items, such as setting a different style for every nodes, depending on the bound object.
- Adding more than one label for an item, as the {@link SimpleGraphBuilder.nodeLabelBinding} and {@link SimpleGraphBuilder.edgeLabelBinding} will only create a single label, or adding labels to group nodes.
There are creation and update events for all three types of items, which allows separate customization when nodes,
groups, and edges are created or updated. For completely static graphs where {@link SimpleGraphBuilder.updateGraph} is
not needed, the update events can be safely ignored.
Depending on how the source data is laid out, you may also consider using {@link SimpleAdjacentNodesGraphBuilder},
where node objects know their neighbors, or {@link SimpleTreeBuilder} where the graph is a tree and node objects know
their children. Both of those other graph builders make edges implicit through the relationships between nodes and thus
have no {@link SimpleGraphBuilder.edgesSource}.
## Note
This class serves as a convenient way to create general graphs and has some limitations:
- When populating the graph for the first time it will be cleared of all existing items.
- Elements manually created on the graph in between calls to {@link SimpleGraphBuilder.updateGraph} may not be preserved.
- Edge objects in {@link SimpleGraphBuilder.edgesSource} cannot change their source or target node.
{@link SimpleGraphBuilder.sourceNodeBinding} and {@link SimpleGraphBuilder.targetNodeBinding} are only used during edge creation.
If updates get too complex it's often better to write the code interfacing with the graph by hand instead of relying on
{@link SimpleGraphBuilder}.
The different graph builders are discussed in the section {@link https://docs.yworks.com/yfileshtml/#/dguide/graph_builder Creating a Graph from Business Data}. Class {@link GraphBuilder}, in
particular, is topic of section {@link https://docs.yworks.com/yfileshtml/#/dguide/graph_builder-GraphBuilder GraphBuilder}.
@see {@link SimpleAdjacentNodesGraphBuilder}
@see {@link SimpleTreeBuilder}
*/
export class SimpleGraphBuilder {
$graphBuilder
$builderNodesSource
$builderGroupsSource
$builderEdgesSource
$graphBuilderHelper
$sourceIdProvider
$targetIdProvider
/**
Initializes a new instance of the {@link SimpleGraphBuilder} class that operates on the given graph.
The `graph` will be {@link IGraph.clear cleared} and re-built from the data in {@link SimpleGraphBuilder.nodesSource}, {@link SimpleGraphBuilder.groupsSource}, and {@link SimpleGraphBuilder.edgesSource} when {@link SimpleGraphBuilder.buildGraph} is called.
@param graphOrOptions The parameters to pass.
@param [graphOrOptions.graph=null] The graph
@param [graphOrOptions.lazyNodeDefinition] A value indicating whether or not to automatically create nodes for values returned from {@link SimpleGraphBuilder.sourceNodeBinding} and {@link SimpleGraphBuilder.targetNodeBinding} that don't exist in {@link SimpleGraphBuilder.nodesSource}. This option sets the {@link SimpleGraphBuilder.lazyNodeDefinition} property on the created object.
@param [graphOrOptions.nodesSource] The objects to be represented as nodes of the {@link SimpleGraphBuilder.graph}. This option sets the {@link SimpleGraphBuilder.nodesSource} property on the created object.
@param [graphOrOptions.edgesSource] The objects to be represented as edges of the {@link SimpleGraphBuilder.graph}. This option sets the {@link SimpleGraphBuilder.edgesSource} property on the created object.
@param [graphOrOptions.groupsSource] The objects to be represented as group nodes of the {@link SimpleGraphBuilder.graph}. This option sets the {@link SimpleGraphBuilder.groupsSource} property on the created object.
@param [graphOrOptions.nodeIdBinding] A binding that maps node objects to their identifier. This option sets the {@link SimpleGraphBuilder.nodeIdBinding} property on the created object.
@param [graphOrOptions.edgeIdBinding] A binding that maps edge objects to their identifier. This option sets the {@link SimpleGraphBuilder.edgeIdBinding} property on the created object.
@param [graphOrOptions.nodeLabelBinding] A binding that maps a node object to a label. This option sets the {@link SimpleGraphBuilder.nodeLabelBinding} property on the created object.
@param [graphOrOptions.groupBinding] A binding that maps node objects to their containing groups. This option sets the {@link SimpleGraphBuilder.groupBinding} property on the created object.
@param [graphOrOptions.edgeLabelBinding] A binding that maps an edge object to a label. This option sets the {@link SimpleGraphBuilder.edgeLabelBinding} property on the created object.
@param [graphOrOptions.sourceNodeBinding] A binding that maps edge objects to their source node. This option sets the {@link SimpleGraphBuilder.sourceNodeBinding} property on the created object.
@param [graphOrOptions.targetNodeBinding] A binding that maps edge objects to their target node. This option sets the {@link SimpleGraphBuilder.targetNodeBinding} property on the created object.
@param [graphOrOptions.groupIdBinding] A binding that maps group objects to their identifier. This option sets the {@link SimpleGraphBuilder.groupIdBinding} property on the created object.
@param [graphOrOptions.groupLabelBinding] A binding that maps a group object to a label. This option sets the {@link SimpleGraphBuilder.groupLabelBinding} property on the created object.
@param [graphOrOptions.parentGroupBinding] A binding that maps group objects to their containing groups. This option sets the {@link SimpleGraphBuilder.parentGroupBinding} property on the created object.
@param [graphOrOptions.locationXBinding] The binding for determining a node's position on the x-axis. This option sets the {@link SimpleGraphBuilder.locationXBinding} property on the created object.
@param [graphOrOptions.locationYBinding] The binding for determining a node's position on the y-axis. This option sets the {@link SimpleGraphBuilder.locationYBinding} property on the created object.
* @param {?(IGraph|GraphBuilderOptionArgs)} [graphOrOptions]
*/
constructor(graphOrOptions) {
let options = null
let graph
if (!graphOrOptions) {
graph = new DefaultGraph()
} else if (IGraph.isInstance(graphOrOptions)) {
graph = graphOrOptions
} else {
options = graphOrOptions
graph = options.graph || new DefaultGraph()
}
this.$graphBuilderHelper = new GraphBuilderHelper(
this,
graph,
(graph, parent, location, labelData, nodeObject) =>
this.createNode(graph, parent, location, labelData, nodeObject),
(graph, node, parent, location, labelData, nodeObject) =>
this.updateNode(graph, node, parent, location, labelData, nodeObject),
(graph, labelData, groupObject) => this.createGroupNode(graph, labelData, groupObject),
(graph, groupNode, labelData, groupObject) =>
this.updateGroupNode(graph, groupNode, labelData, groupObject),
(graph, source, target, labelData, edgeObject) =>
this.createEdge(graph, source, target, labelData, edgeObject),
(graph, edge, labelData, edgeObject) => this.updateEdge(graph, edge, labelData, edgeObject)
)
this.$lazyNodeDefinition = false
this.$nodesSource = null
this.$edgesSource = null
this.$groupsSource = null
this.$edgeIdBinding = null
this.$sourceNodeBinding = null
this.$targetNodeBinding = null
this.$graphBuilder = new GraphBuilder(graph)
this.$builderNodesSource = this.$graphBuilder.createNodesSource([], null)
this.$builderNodesSource.nodeCreator = this.$graphBuilderHelper.createNodeCreator()
this.$builderGroupsSource = this.$graphBuilder.createGroupNodesSource([], null)
this.$builderGroupsSource.nodeCreator = this.$graphBuilderHelper.createGroupCreator()
this.$builderEdgesSource = this.$graphBuilder.createEdgesSource(
[],
(dataItem) => this.$sourceIdProvider && this.$sourceIdProvider(dataItem),
(dataItem) => this.$targetIdProvider && this.$targetIdProvider(dataItem)
)
this.$builderEdgesSource.edgeCreator = this.$graphBuilderHelper.createEdgeCreator()
if (options) {
this.$applyOptions(options)
}
}
/**
* @param {!GraphBuilderOptionArgs} options
*/
$applyOptions(options) {
if (options.lazyNodeDefinition) this.lazyNodeDefinition = options.lazyNodeDefinition
if (options.nodesSource) this.nodesSource = options.nodesSource
if (options.edgesSource) this.edgesSource = options.edgesSource
if (options.groupsSource) this.groupsSource = options.groupsSource
if (options.nodeIdBinding) this.nodeIdBinding = options.nodeIdBinding
if (options.edgeIdBinding) this.edgeIdBinding = options.edgeIdBinding
if (options.nodeLabelBinding) this.nodeLabelBinding = options.nodeLabelBinding
if (options.groupBinding) this.groupBinding = options.groupBinding
if (options.edgeLabelBinding) this.edgeLabelBinding = options.edgeLabelBinding
if (options.sourceNodeBinding) this.sourceNodeBinding = options.sourceNodeBinding
if (options.targetNodeBinding) this.targetNodeBinding = options.targetNodeBinding
if (options.groupIdBinding) this.groupIdBinding = options.groupIdBinding
if (options.groupLabelBinding) this.groupLabelBinding = options.groupLabelBinding
if (options.parentGroupBinding) this.parentGroupBinding = options.parentGroupBinding
if (options.locationXBinding) this.locationXBinding = options.locationXBinding
if (options.locationYBinding) this.locationYBinding = options.locationYBinding
}
/**
Populates the graph with items generated from the bound data.
The graph is cleared, and then new nodes, groups, and edges are created as defined by the source collections.
@returns {!IGraph} The created graph.
@see {@link SimpleGraphBuilder.updateGraph} */
buildGraph() {
this.graph.clear()
this.$initialize()
return this.$graphBuilder.buildGraph()
}
/**
Updates the graph after changes in the bound data.
In contrast to
{@link SimpleGraphBuilder.buildGraph}, the graph is not cleared. Instead, graph elements corresponding to objects that
are still present in the source collections are kept, new graph elements are created for new objects in the collections,
and obsolete ones are removed.
*/
updateGraph() {
this.$initialize()
this.$graphBuilder.updateGraph()
}
$initialize() {
if (this.$nodesSource == null) {
throw new Error('nodesSource must be set.')
}
if (
this.$edgesSource != null &&
(this.sourceNodeBinding == null || this.targetNodeBinding == null)
) {
throw new Error(
'Since edgesSource is set, sourceNodeBinding and targetNodeBinding must be set, too.'
)
}
if (this.$lazyNodeDefinition && this.nodeIdBinding != null) {
throw new Error('LazyNodeDefinition cannot be used with nodeIdBinding.')
}
this.$initializeProviders()
this.$prepareData()
}
$initializeProviders() {
this.$graphBuilderHelper.initializeProviders()
this.$builderNodesSource.idProvider = GraphBuilderHelper.createIdProvider(this.nodeIdBinding)
this.$builderGroupsSource.idProvider = GraphBuilderHelper.createIdProvider(this.groupIdBinding)
this.$builderEdgesSource.idProvider = GraphBuilderHelper.createIdProvider(this.edgeIdBinding)
this.$builderEdgesSource.edgeCreator.tagProvider = (e) => e
this.$builderNodesSource.parentIdProvider = GraphBuilderHelper.createBinding(this.groupBinding)
this.$builderGroupsSource.parentIdProvider = GraphBuilderHelper.createBinding(
this.parentGroupBinding
)
this.$sourceIdProvider = GraphBuilderHelper.createBinding(this.sourceNodeBinding)
this.$targetIdProvider = GraphBuilderHelper.createBinding(this.targetNodeBinding)
}
$prepareData() {
const { nodeCollection, edgeCollection } = this.$maybeExtractLazyNodes()
this.$graphBuilder.setData(this.$builderNodesSource, nodeCollection)
this.$graphBuilder.setData(this.$builderEdgesSource, edgeCollection || [])
this.$graphBuilder.setData(this.$builderGroupsSource, this.$groupsSource || [])
}
/**
* @returns {!object}
*/
$maybeExtractLazyNodes() {
if (!this.$lazyNodeDefinition || !this.$edgesSource) {
return { nodeCollection: this.$nodesSource, edgeCollection: this.$edgesSource }
}
const nodeCollectionCloner = createNodeCollectionCloner(this.$nodesSource)
if (nodeCollectionCloner instanceof ObjectNodeCollectionCloner) {
const edgeCollectionCloner = createEdgeCollectionCloner(this.$edgesSource)
const iterator = edgeCollectionCloner.generator()
let iteratorResult = iterator.next()
while (!iteratorResult.done) {
const edgeDataItem = iteratorResult.value
const sourceNodeDataItem = this.$sourceIdProvider(edgeDataItem)
const newSource = nodeCollectionCloner.has(sourceNodeDataItem)
? sourceNodeDataItem
: nodeCollectionCloner.add(sourceNodeDataItem)
const targetNodeDataItem = this.$targetIdProvider(edgeDataItem)
const newTarget = !nodeCollectionCloner.has(targetNodeDataItem)
? nodeCollectionCloner.add(targetNodeDataItem)
: targetNodeDataItem
const newEdgeDataItem = { dataItem: edgeDataItem, source: newSource, target: newTarget }
iteratorResult = iterator.next(newEdgeDataItem)
}
this.$sourceIdProvider = (e) => e.source
this.$targetIdProvider = (e) => e.target
const tagProvider = (e) => e.dataItem
const edgesSource = this.$builderEdgesSource
const helper = this.$graphBuilderHelper
if (edgesSource.idProvider) {
edgesSource.idProvider = compose((e) => edgesSource.idProvider(e, null), tagProvider)
}
helper.edgeLabelProvider = compose(helper.edgeLabelProvider, tagProvider)
edgesSource.edgeCreator.tagProvider = tagProvider
return {
nodeCollection: nodeCollectionCloner.collection,
edgeCollection: edgeCollectionCloner.collection
}
} else {
for (const edgeDataItem of createIterable(this.$edgesSource)) {
const sourceNodeDataItem = this.$sourceIdProvider(edgeDataItem)
if (!nodeCollectionCloner.has(sourceNodeDataItem)) {
nodeCollectionCloner.add(sourceNodeDataItem)
}
const targetNodeDataItem = this.$targetIdProvider(edgeDataItem)
if (!nodeCollectionCloner.has(targetNodeDataItem)) {
nodeCollectionCloner.add(targetNodeDataItem)
}
}
return { nodeCollection: nodeCollectionCloner.collection, edgeCollection: this.$edgesSource }
}
}
/**
Creates an edge from the given `edgeObject` and `labelData`.
This method is called for every edge that is created either when {@link SimpleGraphBuilder.buildGraph building the graph}, or when new items appear in the {@link SimpleGraphBuilder.edgesSource}
when {@link SimpleGraphBuilder.updateGraph updating it}.
The default behavior is to create the edge, assign the `edgeObject` to the edge's {@link ITagOwner.tag} property, and create a label from
`labelData`, if present.
Customizing how edges are created is usually easier by adding an event handler to the {@link SimpleGraphBuilder.addEdgeCreatedListener EdgeCreated}
event than by overriding this method.
@param {!IGraph} graph The graph in which to create the edge.
@param {?INode} source The source node for the edge.
@param {?INode} target The target node for the edge.
@param {*} labelData The optional label data of the edge if an {@link SimpleGraphBuilder.edgeLabelBinding} is specified.
@param {*} edgeObject The object from {@link SimpleGraphBuilder.edgesSource} from which to create the edge.
@returns {?IEdge} The created edge.
*/
createEdge(graph, source, target, labelData, edgeObject) {
return this.$graphBuilderHelper.createEdge(graph, source, target, labelData, edgeObject)
}
/**
Creates a group node from the given `groupObject` and `labelData`.
This method is called for every group node that is created either when {@link SimpleGraphBuilder.buildGraph building the graph}, or when new items appear in
the {@link SimpleGraphBuilder.groupsSource} when {@link SimpleGraphBuilder.updateGraph updating it}.
The default behavior is to create the group node, assign the `groupObject` to the group node's {@link ITagOwner.tag} property, and create a
label from `labelData`, if present.
Customizing how group nodes are created is usually easier by adding an event handler to the {@link SimpleGraphBuilder.addGroupNodeCreatedListener GroupNodeCreated}
event than by overriding this method.
@param {!IGraph} graph The graph in which to create the group node.
@param {*} labelData The optional label data of the group node if an {@link SimpleGraphBuilder.groupLabelBinding} is specified.
@param {*} groupObject The object from {@link SimpleGraphBuilder.groupsSource} from which to create the group node.
@returns {!INode} The created group node.
*/
createGroupNode(graph, labelData, groupObject) {
return this.$graphBuilderHelper.createGroupNode(graph, labelData, groupObject)
}
/**
Creates a node with the specified parent from the given `nodeObject` and `labelData`.
This method is called for every node that is created either when {@link SimpleGraphBuilder.buildGraph building the graph}, or when new items appear in the {@link SimpleGraphBuilder.nodesSource}
when {@link SimpleGraphBuilder.updateGraph updating it}.
The default behavior is to create the node with the given parent node, assign the `nodeObject` to the node's {@link ITagOwner.tag} property,
and create a label from `labelData`, if present.
Customizing how nodes are created is usually easier by adding an event handler to the {@link SimpleGraphBuilder.addNodeCreatedListener NodeCreated}
event than by overriding this method.
@param {!IGraph} graph The graph in which to create the node.
@param {?INode} parent The node's parent node.
@param {!Point} location The location of the node.
@param {*} labelData The optional label data of the node if an {@link SimpleGraphBuilder.nodeLabelBinding} is specified.
@param {*} nodeObject The object from {@link SimpleGraphBuilder.nodesSource} from which to create the node.
@returns {!INode} The created node.
*/
createNode(graph, parent, location, labelData, nodeObject) {
return this.$graphBuilderHelper.createNode(graph, parent, location, labelData, nodeObject)
}
/**
Retrieves the object from which a given item has been created.
@param {!IModelItem} item The item to get the object for.
@returns {*} The object from which the graph item has been created.
@see SimpleGraphBuilder#getNode
@see SimpleGraphBuilder#getEdge
@see SimpleGraphBuilder#getGroup
*/
getBusinessObject(item) {
return this.$graphBuilderHelper.getBusinessObject(item)
}
/**
Retrieves the edge associated with an object from the {@link SimpleGraphBuilder.edgesSource}.
@param {*} businessObject An object from the {@link SimpleGraphBuilder.edgesSource}.
@returns {?IEdge} The edge associated with `businessObject`, or `null` in case there is no edge associated with that object. This can happen
if `businessObject` is new since the last call to {@link SimpleGraphBuilder.updateGraph}.
@see SimpleGraphBuilder#getNode
@see SimpleGraphBuilder#getGroup
@see SimpleGraphBuilder#getBusinessObject
*/
getEdge(businessObject) {
return this.$graphBuilderHelper.getEdge(businessObject)
}
/**
Retrieves the group node associated with an object from the {@link SimpleGraphBuilder.groupsSource}.
@param {*} groupObject An object from the {@link SimpleGraphBuilder.groupsSource}.
@returns {?INode} The group node associated with `groupObject`, or `null` in case there is no group node associated with that object. This can
happen if `groupObject` is new since the last call to {@link SimpleGraphBuilder.updateGraph}.
@see SimpleGraphBuilder#getNode
@see SimpleGraphBuilder#getEdge
@see SimpleGraphBuilder#getBusinessObject
*/
getGroup(groupObject) {
return this.$graphBuilderHelper.getGroup(groupObject)
}
/**
Retrieves the node associated with an object from the {@link SimpleGraphBuilder.nodesSource}.
@param {*} nodeObject An object from the {@link SimpleGraphBuilder.nodesSource}.
@returns {?INode} The node associated with `nodeObject`, or `null` in case there is no node associated with that object. This can happen if `nodeObject`
is new since the last call to {@link SimpleGraphBuilder.updateGraph}.
@see SimpleGraphBuilder#getEdge
@see SimpleGraphBuilder#getGroup
@see SimpleGraphBuilder#getBusinessObject */
getNode(nodeObject) {
return this.$graphBuilderHelper.getNode(nodeObject)
}
/**
Updates an existing edge when the {@link SimpleGraphBuilder.updateGraph graph is updated}.
This method is called during {@link SimpleGraphBuilder.updateGraph updating the graph} for every edge that already exists in the graph where its corresponding
object from {@link SimpleGraphBuilder.edgesSource} is also still present.
Customizing how edges are updated is usually easier by adding an event handler to the {@link SimpleGraphBuilder.addEdgeUpdatedListener EdgeUpdated}
event than by overriding this method.
@param {!IGraph} graph The edge's containing graph.
@param {!IEdge} edge The edge to update.
@param {*} labelData The optional label data of the edge if an {@link SimpleGraphBuilder.edgeLabelBinding} is specified.
@param {*} edgeObject The object from {@link SimpleGraphBuilder.edgesSource} from which the edge has been created.
*/
updateEdge(graph, edge, labelData, edgeObject) {
this.$graphBuilderHelper.updateEdge(graph, edge, labelData, edgeObject)
}
/**
Updates an existing group node when the {@link SimpleGraphBuilder.updateGraph graph is updated}.
This method is called during {@link SimpleGraphBuilder.updateGraph updating the graph} for every group node that already exists in the graph where its
corresponding object from {@link SimpleGraphBuilder.groupsSource} is also still present.
Customizing how group nodes are updated is usually easier by adding an event handler to the {@link SimpleGraphBuilder.addGroupNodeUpdatedListener GroupNodeUpdated}
event than by overriding this method.
@param {!IGraph} graph The group node's containing graph.
@param {!INode} groupNode The group node to update.
@param {*} labelData The optional label data of the group node if an {@link SimpleGraphBuilder.groupLabelBinding} is specified.
@param {*} groupObject The object from {@link SimpleGraphBuilder.groupsSource} from which the group node has been created.
*/
updateGroupNode(graph, groupNode, labelData, groupObject) {
this.$graphBuilderHelper.updateGroupNode(graph, groupNode, labelData, groupObject)
}
/**
Updates an existing node when the {@link SimpleGraphBuilder.updateGraph graph is updated}.
This method is called during {@link SimpleGraphBuilder.updateGraph updating the graph} for every node that already exists in the graph where its corresponding
object from {@link SimpleGraphBuilder.nodesSource} is also still present.
Customizing how nodes are updated is usually easier by adding an event handler to the {@link SimpleGraphBuilder.addNodeUpdatedListener NodeUpdated}
event than by overriding this method.
@param {!IGraph} graph The node's containing graph.
@param {!INode} node The node to update.
@param {?INode} parent The node's parent node.
@param {!Point} location The location of the node.
@param {*} labelData The optional label data of the node if an {@link SimpleGraphBuilder.nodeLabelBinding} is specified.
@param {*} nodeObject The object from {@link SimpleGraphBuilder.nodesSource} from which the node has been created.
*/
updateNode(graph, node, parent, location, labelData, nodeObject) {
this.$graphBuilderHelper.updateNode(graph, node, parent, location, labelData, nodeObject)
}
/**
* Gets the {@link IGraph graph} used by this class.
* @type {!IGraph}
*/
get graph() {
return this.$graphBuilder.graph
}
$lazyNodeDefinition
/**
Gets or sets a value indicating whether or not to automatically create nodes for values returned from {@link SimpleGraphBuilder.sourceNodeBinding} and {@link SimpleGraphBuilder.targetNodeBinding} that don't
exist in {@link SimpleGraphBuilder.nodesSource}.
When this property is set to `false`, nodes in the graph are __only__ created from {@link SimpleGraphBuilder.nodesSource}, and edge objects that result in source or
target nodes not in {@link SimpleGraphBuilder.nodesSource} will have no edge created.
If this property is set to `true`, edges will always be created, and if {@link SimpleGraphBuilder.sourceNodeBinding} or {@link SimpleGraphBuilder.targetNodeBinding} return values not in
{@link SimpleGraphBuilder.nodesSource}, additional nodes are created as needed.
@see SimpleGraphBuilder#nodesSource
@see SimpleGraphBuilder#edgesSource * @type {boolean}
*/
get lazyNodeDefinition() {
return this.$lazyNodeDefinition
}
/**
* @type {boolean}
*/
set lazyNodeDefinition(value) {
this.$lazyNodeDefinition = value
}
$nodesSource
/**
* Gets or sets the objects to be represented as nodes of the {@link SimpleGraphBuilder.graph}.
* @type {*}
*/
get nodesSource() {
return this.$nodesSource
}
/**
* @type {*}
*/
set nodesSource(value) {
this.$nodesSource = value
}
$edgesSource
/**
* Gets or sets the objects to be represented as edges of the {@link SimpleGraphBuilder.graph}.
* @type {*}
*/
get edgesSource() {
return this.$edgesSource
}
/**
* @type {*}
*/
set edgesSource(value) {
this.$edgesSource = value
}
$groupsSource
/**
* Gets or sets the objects to be represented as group nodes of the {@link SimpleGraphBuilder.graph}.
* @type {*}
*/
get groupsSource() {
return this.$groupsSource
}
/**
* @type {*}
*/
set groupsSource(value) {
this.$groupsSource = value
}
/**
Gets or sets a binding that maps node objects to their identifier.
This maps an business object that represents a node to its identifier. This is needed when {@link SimpleGraphBuilder.edgesSource edge objects} only contain an
identifier to specify their source and target nodes instead of pointing directly to the respective node object.
The binding can either be a plain JavaScript function, a String, `null`, or an array which contains the same types
recursively. A function is called with the business object to convert as first and only parameter, and the function's `this`
is set to the business object, too.
__Warning:__ The identifiers returned by the binding must be stable and not change over time. Otherwise the {@link SimpleGraphBuilder.updateGraph update mechanism} cannot
determine whether nodes have been added or updated. For the same reason this property must not be changed after having
built the graph once.
@see SimpleGraphBuilder#nodesSource
@see SimpleGraphBuilder#sourceNodeBinding
@see SimpleGraphBuilder#targetNodeBinding * @type {*}
*/
get nodeIdBinding() {
return this.$graphBuilderHelper.nodeIdBinding
}
/**
* @type {*}
*/
set nodeIdBinding(value) {
this.$graphBuilderHelper.nodeIdBinding = value
}
$edgeIdBinding
/**
Gets or sets a binding that maps edge objects to their identifier.
This maps an business object that represents a edge to its identifier. This can be used to improve the performance of
the {@link SimpleGraphBuilder} because internal maps can use a primitive id as key to store the business object instead
of the JavaScript object itself.
The binding can either be a plain JavaScript function, a String, `null`, or an array which contains the same types
recursively. A function is called with the business object to convert as first and only parameter, and the function's `this`
is set to the business object, too.
__Warning:__ The identifiers returned by the binding must be stable and not change over time.
* @type {*}
*/
get edgeIdBinding() {
return this.$edgeIdBinding
}
/**
* @type {*}
*/
set edgeIdBinding(value) {
this.$edgeIdBinding = value
}
/**
Gets or sets a binding that maps a node object to a label.
This maps a business object that represents a node to an object that represents the label for the node.
The resulting object will be converted into a string to be displayed as the label's text. If this is insufficient, a
label can also be created directly in an event handler of the {@link SimpleGraphBuilder.addNodeCreatedListener NodeCreated}
event.
The binding can either be a plain JavaScript function, a String, `null`, or an array which contains the same types
recursively. A function is called with the business object to convert as first and only parameter, and the function's `this`
is set to the business object, too.
Returning `null` from the binding will not create a label for that node.
@see SimpleGraphBuilder#nodesSource
* @type {*}
*/
get nodeLabelBinding() {
return this.$graphBuilderHelper.nodeLabelBinding
}
/**
* @type {*}
*/
set nodeLabelBinding(value) {
this.$graphBuilderHelper.nodeLabelBinding = value
}
/**
Gets or sets a binding that maps node objects to their containing groups.
This maps an object _N_ that represents a node to another object _G_ that specifies the containing group of _N_. If _G_ is contained
in {@link SimpleGraphBuilder.groupsSource}, then the node for _N_ becomes a child node of the group for _G_.
If a {@link SimpleGraphBuilder.groupIdBinding} is set, the returned object _G_ must be the ID of the object that specifies the group instead of that object itself.
The binding can either be a plain JavaScript function, a String, `null`, or an array which contains the same types
recursively. A function is called with the business object to convert as first and only parameter, and the function's `this`
is set to the business object, too.
@see SimpleGraphBuilder#nodesSource
@see SimpleGraphBuilder#groupsSource
@see SimpleGraphBuilder#groupIdBinding
* @type {*}
*/
get groupBinding() {
return this.$graphBuilderHelper.groupBinding
}
/**
* @type {*}
*/
set groupBinding(value) {
this.$graphBuilderHelper.groupBinding = value
}
/**
Gets or sets a binding that maps an edge object to a label.
This maps an object that represents an edge to an object that represents the label for the edge.
The resulting object will be converted into a string to be displayed as the label's text. If this is insufficient, a
label can also be created directly in an event handler of the {@link SimpleGraphBuilder.addEdgeCreatedListener EdgeCreated}
event.
The binding can either be a plain JavaScript function, a String, `null`, or an array which contains the same types
recursively. A function is called with the business object to convert as first and only parameter, and the function's `this`
is set to the business object, too.
Returning `null` from the binding will not create a label for that edge.
@see SimpleGraphBuilder#edgesSource
* @type {*}
*/
get edgeLabelBinding() {
return this.$graphBuilderHelper.edgeLabelBinding
}
/**
* @type {*}
*/
set edgeLabelBinding(value) {
this.$graphBuilderHelper.edgeLabelBinding = value
}
$sourceNodeBinding
/**
Gets or sets a binding that maps edge objects to their source node.
This maps an object _E_ that represents an edge to another object _N_ that specifies the source node of _E_.
If a {@link SimpleGraphBuilder.nodeIdBinding} is set, the returned object _N_ must be the ID of the object that specifies the node instead of that object itself.
If {@link SimpleGraphBuilder.lazyNodeDefinition} is `true`, the resulting node object does not have to exist in {@link SimpleGraphBuilder.nodesSource}; instead, nodes are created as needed.
The binding can either be a plain JavaScript function, a String, `null`, or an array which contains the same types
recursively. A function is called with the business object to convert as first and only parameter, and the function's `this`
is set to the business object, too.
@see SimpleGraphBuilder#nodesSource
@see SimpleGraphBuilder#targetNodeBinding
@see SimpleGraphBuilder#nodeIdBinding
@see SimpleGraphBuilder#lazyNodeDefinition
* @type {*}
*/
get sourceNodeBinding() {
return this.$sourceNodeBinding
}
/**
* @type {*}
*/
set sourceNodeBinding(value) {
this.$sourceNodeBinding = value
}
$targetNodeBinding
/**
Gets or sets a binding that maps edge objects to their target node.
This maps an object _E_ that represents an edge to another object _N_ that specifies the target node of _E_.
If a {@link SimpleGraphBuilder.nodeIdBinding} is set, the returned object _N_ must be the ID of the object that specifies the node instead of that object itself.
If {@link SimpleGraphBuilder.lazyNodeDefinition} is `true`, the resulting node object does not have to exist in {@link SimpleGraphBuilder.nodesSource}; instead, nodes are created as needed.
The binding can either be a plain JavaScript function, a String, `null`, or an array which contains the same types
recursively. A function is called with the business object to convert as first and only parameter, and the function's `this`
is set to the business object, too.
@see SimpleGraphBuilder#nodesSource
@see SimpleGraphBuilder#sourceNodeBinding
@see SimpleGraphBuilder#nodeIdBinding
@see SimpleGraphBuilder#lazyNodeDefinition
* @type {*}
*/
get targetNodeBinding() {
return this.$targetNodeBinding
}
/**
* @type {*}
*/
set targetNodeBinding(value) {
this.$targetNodeBinding = value
}
/**
Gets or sets a binding that maps group objects to their identifier.
This maps an object that represents a group node to its identifier. This is needed when {@link SimpleGraphBuilder.nodesSource node objects} only contain an
identifier to specify the group they belong to instead of pointing directly to the respective group object. The same
goes for the parent group in group objects.
The binding can either be a plain JavaScript function, a String, `null`, or an array which contains the same types
recursively. Functions will be called with both `this` and the first and only argument as the value to convert.
__Warning:__ The identifiers returned by the binding must be stable and not change over time. Otherwise the {@link SimpleGraphBuilder.updateGraph update mechanism} cannot
determine whether groups have been added or updated. For the same reason this property must not be changed after having
built the graph once.
@see SimpleGraphBuilder#groupsSource
@see SimpleGraphBuilder#groupBinding
@see SimpleGraphBuilder#parentGroupBinding
* @type {*}
*/
get groupIdBinding() {
return this.$graphBuilderHelper.groupIdBinding
}
/**
* @type {*}
*/
set groupIdBinding(value) {
this.$graphBuilderHelper.groupIdBinding = value
}
/**
Gets or sets a binding that maps a group object to a label.
This maps an object that represents a group node to an object that represents the label for the group node.
The resulting object will be converted into a string to be displayed as the label's text. If this is insufficient, a
label can also be created directly in an event handler of the {@link SimpleGraphBuilder.addGroupNodeCreatedListener GroupNodeCreated}
event.
Returning `null` from the binding will not create a label for that group node.
The binding can either be a plain JavaScript function, a String, `null`, or an array which contains the same types
recursively. Functions will be called with both `this` and the first and only argument as the value to convert.
@see SimpleGraphBuilder#groupsSource
* @type {*}
*/
get groupLabelBinding() {
return this.$graphBuilderHelper.groupLabelBinding
}
/**
* @type {*}
*/
set groupLabelBinding(value) {
this.$graphBuilderHelper.groupLabelBinding = value
}
/**
Gets or sets a binding that maps group objects to their containing groups.
This maps an object _G_ that represents a group node to another object _P_ that specifies the containing group of _G_. If _P_ is
contained in {@link SimpleGraphBuilder.groupsSource}, then the group node for _G_ becomes a child node of the group for _P_.
If a {@link SimpleGraphBuilder.groupIdBinding} is set, the returned object _P_ must be the ID of the object that specifies the group instead of that object itself.
The binding can either be a plain JavaScript function, a String, `null`, or an array which contains the same types
recursively. A function is called with the business object to convert as first and only parameter, and the function's `this`
is set to the business object, too.
@see SimpleGraphBuilder#groupsSource
@see SimpleGraphBuilder#groupIdBinding
* @type {*}
*/
get parentGroupBinding() {
return this.$graphBuilderHelper.parentGroupBinding
}
/**
* @type {*}
*/
set parentGroupBinding(value) {
this.$graphBuilderHelper.parentGroupBinding = value
}
/**
Gets or sets the binding for determining a node's position on the x-axis.
This binding maps a business object that represents a node to a number that specifies the x-coordinate of that node.
The binding can either be a plain JavaScript function, a String, `null`, or an array which contains the same types
recursively. A function is called with the business object to convert as first and only parameter, and the function's `this`
is set to the business object, too.
@see SimpleGraphBuilder#nodesSource
* @type {*}
*/
get locationXBinding() {
return this.$graphBuilderHelper.locationXBinding
}
/**
* @type {*}
*/
set locationXBinding(value) {
this.$graphBuilderHelper.locationXBinding = value
}
/**
Gets or sets the binding for determining a node's position on the y-axis.
This binding maps a business object that represents a node to a number that specifies the y-coordinate of that node.
The binding can either be a plain JavaScript function, a String, `null`, or an array which contains the same types
recursively. A function is called with the business object to convert as first and only parameter, and the function's `this`
is set to the business object, too.
@see SimpleGraphBuilder#nodesSource
* @type {*}
*/
get locationYBinding() {
return this.$graphBuilderHelper.locationYBinding
}
/**
* @type {*}
*/
set locationYBinding(value) {
this.$graphBuilderHelper.locationYBinding = value
}
/**
Adds the given listener for the `NodeCreated` event that occurs when a node has been created.
This event can be used to further customize the created node.
New nodes are created either in response to calling {@link SimpleGraphBuilder.buildGraph}, or in response to calling {@link SimpleGraphBuilder.updateGraph}
when there are new items in {@link SimpleGraphBuilder.nodesSource}.
@param {!SimpleNodeListener} listener The listener to add.
@see SimpleGraphBuilder#addNodeUpdatedListener
@see SimpleGraphBuilder#removeNodeCreatedListener
*/
addNodeCreatedListener(listener) {
this.$graphBuilderHelper.addNodeCreatedListener(listener)
}
/**
Removes the given listener for the `NodeCreated` event that occurs when a node has been created.
This event can be used to further customize the created node.
New nodes are created either in response to calling {@link SimpleGraphBuilder.buildGraph}, or in response to calling {@link SimpleGraphBuilder.updateGraph}
when there are new items in {@link SimpleGraphBuilder.nodesSource}.
@param {!SimpleNodeListener} listener The listener to remove.
@see SimpleGraphBuilder#addNodeUpdatedListener
@see SimpleGraphBuilder#addNodeCreatedListener
*/
removeNodeCreatedListener(listener) {
this.$graphBuilderHelper.removeNodeCreatedListener(listener)
}
/**
Adds the given listener for the `NodeUpdated` event that occurs when a node has been updated.
This event can be used to update customizations added in an event handler for
{@link SimpleGraphBuilder.addNodeCreatedListener NodeCreated}.
Nodes are updated in response to calling {@link SimpleGraphBuilder.updateGraph} for items that haven't been added anew
in {@link SimpleGraphBuilder.nodesSource} since the last call to {@link SimpleGraphBuilder.buildGraph} or {@link SimpleGraphBuilder.updateGraph}.
@param {!SimpleNodeListener} listener The listener to add.
@see SimpleGraphBuilder#addNodeCreatedListener
@see SimpleGraphBuilder#removeNodeUpdatedListener
*/
addNodeUpdatedListener(listener) {
this.$graphBuilderHelper.addNodeUpdatedListener(listener)
}
/**
Removes the given listener for the `NodeUpdated` event that occurs when a node has been updated.
This event can be used to update customizations added in an event handler for
{@link SimpleGraphBuilder.addNodeCreatedListener NodeCreated}.
Nodes are updated in response to calling {@link SimpleGraphBuilder.updateGraph} for items that haven't been added anew
in {@link SimpleGraphBuilder.nodesSource} since the last call to {@link SimpleGraphBuilder.buildGraph} or {@link SimpleGraphBuilder.updateGraph}.
@param {!SimpleNodeListener} listener The listener to remove.
@see SimpleGraphBuilder#addNodeCreatedListener
@see SimpleGraphBuilder#addNodeUpdatedListener
*/
removeNodeUpdatedListener(listener) {
this.$graphBuilderHelper.removeNodeUpdatedListener(listener)
}
/**
Adds the given listener for the `EdgeCreated` event that occurs when an edge has been created.
This event can be used to further customize the created edge.
New edges are created either in response to calling {@link SimpleGraphBuilder.buildGraph}, or in response to calling {@link SimpleGraphBuilder.updateGraph}
when there are new items in {@link SimpleGraphBuilder.edgesSource}.
@param {!SimpleEdgeListener} listener The listener to add.
@see SimpleGraphBuilder#addEdgeUpdatedListener
@see SimpleGraphBuilder#removeEdgeCreatedListener
*/
addEdgeCreatedListener(listener) {
this.$graphBuilderHelper.addEdgeCreatedListener(listener)
}
/**
Removes the given listener for the `EdgeCreated` event that occurs when an edge has been created.
This event can be used to further customize the created edge.
New edges are created either in response to calling {@link SimpleGraphBuilder.buildGraph}, or in response to calling {@link SimpleGraphBuilder.updateGraph}
when there are new items in {@link SimpleGraphBuilder.edgesSource}.
@param {!SimpleEdgeListener} listener The listener to remove.
@see SimpleGraphBuilder#addEdgeUpdatedListener
@see SimpleGraphBuilder#addEdgeCreatedListener
*/
removeEdgeCreatedListener(listener) {
this.$graphBuilderHelper.removeEdgeCreatedListener(listener)
}
/**
Adds the given listener for the `EdgeUpdated` event that occurs when an edge has been updated.
This event can be used to update customizations added in an event handler for
{@link SimpleGraphBuilder.addEdgeCreatedListener EdgeCreated}.
Edges are updated in response to calling {@link SimpleGraphBuilder.updateGraph} for items that haven't been added anew
in {@link SimpleGraphBuilder.edgesSource} since the last call to {@link SimpleGraphBuilder.buildGraph} or {@link SimpleGraphBuilder.updateGraph}.
@param {!SimpleEdgeListener} listener The listener to add.
@see SimpleGraphBuilder#addEdgeCreatedListener
@see SimpleGraphBuilder#removeEdgeUpdatedListener
*/
addEdgeUpdatedListener(listener) {
this.$graphBuilderHelper.addEdgeUpdatedListener(listener)
}
/**