/
attribute.go
2853 lines (2601 loc) · 122 KB
/
attribute.go
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
package cgraph
import "fmt"
type attribute string
const (
dampingAttr attribute = "Damping"
kAttr attribute = "K"
urlAttr attribute = "URL"
backgroundAttr attribute = "_background"
areaAttr attribute = "area"
arrowHeadAttr attribute = "arrowhead"
arrowSizeAttr attribute = "arrowsize"
arrowTailAttr attribute = "arrowtail"
bbAttr attribute = "bb"
bgcolorAttr attribute = "bgcolor"
centerAttr attribute = "center"
charsetAttr attribute = "charset"
clusterRankAttr attribute = "clusterrank"
colorAttr attribute = "color"
colorSchemeAttr attribute = "colorscheme"
commentAttr attribute = "comment"
compoundAttr attribute = "compound"
concentrateAttr attribute = "concentrate"
constraintAttr attribute = "constraint"
decorateAttr attribute = "decorate"
defaultDistAttr attribute = "defaultdist"
dimAttr attribute = "dim"
dimenAttr attribute = "dimen"
dirAttr attribute = "dir"
dirEdgeConstraintsAttr attribute = "diredgeconstraints"
distortionAttr attribute = "distortion"
dpiAttr attribute = "dpi"
edgeURLAttr attribute = "edgeURL"
edgeHrefAttr attribute = "edgehref"
edgeTargetAttr attribute = "edgetarget"
edgeTooltipAttr attribute = "edgetooltip"
epsilonAttr attribute = "epsilon"
esepAttr attribute = "esep"
fillColorAttr attribute = "fillcolor"
fixedSizeAttr attribute = "fixedsize"
fontColorAttr attribute = "fontcolor"
fontNameAttr attribute = "fontname"
fontNamesAttr attribute = "fontnames"
fontPathAttr attribute = "fontpath"
fontSizeAttr attribute = "fontsize"
forceLabelsAttr attribute = "forcelabels"
gradientAngleAttr attribute = "gradientangle"
groupAttr attribute = "group"
headURLAttr attribute = "headURL"
headLpAttr attribute = "head_lp"
headClipAttr attribute = "headclip"
headHrefAttr attribute = "headhref"
headLabelAttr attribute = "headlabel"
headPortAttr attribute = "headport"
headTargetAttr attribute = "headtarget"
headTooltipAttr attribute = "headtooltip"
heightAttr attribute = "height"
hrefAttr attribute = "href"
idAttr attribute = "id"
imageAttr attribute = "image"
imagePathAttr attribute = "imagepath"
imagePosAttr attribute = "imagepos"
imageScaleAttr attribute = "imagescale"
inputScaleAttr attribute = "inputscale"
labelAttr attribute = "label"
labelURLAttr attribute = "labelURL"
labelSchemeAttr attribute = "label_scheme"
labelAngleAttr attribute = "labelangle"
labelDistanceAttr attribute = "labeldistance"
labelFloatAttr attribute = "labelfloat"
labelFontColorAttr attribute = "labelfontcolor"
labelFontNameAttr attribute = "labelfontname"
labelFontSizeAttr attribute = "labelfontsize"
labelHrefAttr attribute = "labelhref"
labelJustAttr attribute = "labeljust"
labelLocAttr attribute = "labelloc"
labelTargetAttr attribute = "labeltarget"
labelTooltipAttr attribute = "labeltooltip"
landscapeAttr attribute = "landscape"
layerAttr attribute = "layer"
layerListSepAttr attribute = "layerlistsep"
layersAttr attribute = "layers"
layerSelectAttr attribute = "layerselect"
layerSepAttr attribute = "layersep"
layoutAttr attribute = "layout"
lenAttr attribute = "len"
levelsAttr attribute = "levels"
levelsGapAttr attribute = "levelsgap"
lHeadAttr attribute = "lhead"
lHeightAttr attribute = "lheight"
lpAttr attribute = "lp"
lTailAttr attribute = "ltail"
lWidthAttr attribute = "lwidth"
marginAttr attribute = "margin"
maxIterAttr attribute = "maxiter"
mcLimitAttr attribute = "mclimit"
minDistAttr attribute = "mindist"
minLenAttr attribute = "minlen"
modeAttr attribute = "mode"
modelAttr attribute = "model"
mosekAttr attribute = "mosek"
newRankAttr attribute = "newrank"
nodeSepAttr attribute = "nodesep"
noJustifyAttr attribute = "nojustify"
normalizeAttr attribute = "normalize"
noTranslateAttr attribute = "notranslate"
nsLimitAttr attribute = "nslimit"
nsLimit1Attr attribute = "nslimit1"
orderingAttr attribute = "ordering"
orientationAttr attribute = "orientation"
outputOrderAttr attribute = "outputorder"
overlapAttr attribute = "overlap"
overlapScalingAttr attribute = "overlap_scaling"
overlapShrinkAttr attribute = "overlap_shrink"
packAttr attribute = "pack"
packModeAttr attribute = "packmode"
padAttr attribute = "pad"
pageAttr attribute = "page"
pageDirAttr attribute = "pagedir"
penColorAttr attribute = "pencolor"
penWidthAttr attribute = "penwidth"
peripheriesAttr attribute = "peripheries"
pinAttr attribute = "pin"
posAttr attribute = "pos"
quadTreeAttr attribute = "quadtree"
quantumAttr attribute = "quantum"
rankAttr attribute = "rank"
rankDirAttr attribute = "rankdir"
rankSepAttr attribute = "ranksep"
ratioAttr attribute = "ratio"
rectsAttr attribute = "rects"
regularAttr attribute = "regular"
remincrossAttr attribute = "remincross"
repulsiveforceAttr attribute = "repulsiveforce"
resolutionAttr attribute = "resolution"
rootAttr attribute = "root"
rotateAttr attribute = "rotate"
rotationAttr attribute = "rotation"
sameHeadAttr attribute = "samehead"
sameTailAttr attribute = "sametail"
samplePointsAttr attribute = "samplepoints"
scaleAttr attribute = "scale"
searchSizeAttr attribute = "searchsize"
sepAttr attribute = "sep"
shapeAttr attribute = "shape"
shapeFileAttr attribute = "shapefile"
showBoxesAttr attribute = "showboxes"
sidesAttr attribute = "sides"
sizeAttr attribute = "size"
skewAttr attribute = "skew"
smoothingAttr attribute = "smoothing"
sortvAttr attribute = "sortv"
splinesAttr attribute = "splines"
startAttr attribute = "start"
styleAttr attribute = "style"
stylesheetAttr attribute = "stylesheet"
tailURLAttr attribute = "tailURL"
tailLpAttr attribute = "tail_lp"
tailClipAttr attribute = "tailclip"
tailHrefAttr attribute = "tailhref"
tailLabelAttr attribute = "taillabel"
tailPortAttr attribute = "tailport"
tailTargetAttr attribute = "tailtarget"
tailTooltipAttr attribute = "tailtooltip"
targetAttr attribute = "target"
tooltipAttr attribute = "tooltip"
trueColorAttr attribute = "truecolor"
verticesAttr attribute = "vertices"
viewportAttr attribute = "viewport"
voroMarginAttr attribute = "voro_margin"
weightAttr attribute = "weight"
widthAttr attribute = "width"
xdotVersionAttr attribute = "xdotversion"
xlabelAttr attribute = "xlabel"
xlpAttr attribute = "xlp"
zAttr attribute = "z"
)
var (
trueStr = toBoolString(true)
falseStr = toBoolString(false)
)
func toBoolString(v bool) string {
return fmt.Sprintf("%t", v)
}
// SetDamping
// Factor damping force motions.
// On each iteration, a nodes movement is limited to this factor of its potential motion.
// By being less than 1.0, the system tends to ``cool'', thereby preventing cycling.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:Damping
func (g *Graph) SetDamping(v float64) *Graph {
g.SafeSet(string(dampingAttr), fmt.Sprint(v), "0.99")
return g
}
// SetK
// Spring constant used in virtual physical model.
// It roughly corresponds to an ideal edge length (in inches), in that increasing K tends to increase the distance between nodes.
// Note that the edge attribute len can be used to override this value for adjacent nodes.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:K
func (g *Graph) SetK(v float64) *Graph {
g.SafeSet(string(kAttr), fmt.Sprint(v), "0.3")
return g
}
// SetURL
// Hyperlinks incorporated into device-dependent output.
// At present, used in ps2, cmap, i*map and svg formats.
// For all these formats, URLs can be attached to nodes, edges and clusters.
// URL attributes can also be attached to the root graph in ps2, cmap and i*map formats.
// This serves as the base URL for relative URLs in the former, and as the default image map file in the latter.
// For svg, cmapx and imap output, the active area for a node is its visible image.
// For example, an unfilled node with no drawn boundary will only be active on its label.
// For other output, the active area is its bounding box.
// The active area for a cluster is its bounding box.
// For edges, the active areas are small circles where the edge contacts its head and tail nodes.
// In addition, for svg, cmapx and imap, the active area includes a thin polygon approximating the edge.
// The circles may overlap the related node, and the edge URL dominates.
// If the edge has a label, this will also be active.
// Finally, if the edge has a head or tail label, this will also be active.
//
// Note that, for edges, the attributes headURL, tailURL, labelURL and edgeURL allow control of various parts of an edge.
// Also note that, if active areas of two edges overlap, it is unspecified which area dominates.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:URL
func (g *Graph) SetURL(v string) *Graph {
g.SafeSet(string(urlAttr), v, "")
return g
}
// SetURL
// Hyperlinks incorporated into device-dependent output.
// At present, used in ps2, cmap, i*map and svg formats.
// For all these formats, URLs can be attached to nodes, edges and clusters.
// URL attributes can also be attached to the root graph in ps2, cmap and i*map formats.
// This serves as the base URL for relative URLs in the former, and as the default image map file in the latter.
// For svg, cmapx and imap output, the active area for a node is its visible image.
// For example, an unfilled node with no drawn boundary will only be active on its label.
// For other output, the active area is its bounding box.
// The active area for a cluster is its bounding box.
// For edges, the active areas are small circles where the edge contacts its head and tail nodes.
// In addition, for svg, cmapx and imap, the active area includes a thin polygon approximating the edge.
// The circles may overlap the related node, and the edge URL dominates.
// If the edge has a label, this will also be active.
// Finally, if the edge has a head or tail label, this will also be active.
//
// Note that, for edges, the attributes headURL, tailURL, labelURL and edgeURL allow control of various parts of an edge.
// Also note that, if active areas of two edges overlap, it is unspecified which area dominates.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:URL
func (n *Node) SetURL(v string) *Node {
n.SafeSet(string(urlAttr), v, "")
return n
}
// SetURL
// Hyperlinks incorporated into device-dependent output.
// At present, used in ps2, cmap, i*map and svg formats.
// For all these formats, URLs can be attached to nodes, edges and clusters.
// URL attributes can also be attached to the root graph in ps2, cmap and i*map formats.
// This serves as the base URL for relative URLs in the former, and as the default image map file in the latter.
// For svg, cmapx and imap output, the active area for a node is its visible image.
// For example, an unfilled node with no drawn boundary will only be active on its label.
// For other output, the active area is its bounding box.
// The active area for a cluster is its bounding box.
// For edges, the active areas are small circles where the edge contacts its head and tail nodes.
// In addition, for svg, cmapx and imap, the active area includes a thin polygon approximating the edge.
// The circles may overlap the related node, and the edge URL dominates.
// If the edge has a label, this will also be active.
// Finally, if the edge has a head or tail label, this will also be active.
//
// Note that, for edges, the attributes headURL, tailURL, labelURL and edgeURL allow control of various parts of an edge.
// Also note that, if active areas of two edges overlap, it is unspecified which area dominates.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:URL
func (e *Edge) SetURL(v string) *Edge {
e.SafeSet(string(urlAttr), v, "")
return e
}
// SetBackground
// A string in the xdot format specifying an arbitrary background.
// During rendering, the canvas is first filled as described in the bgcolor attribute.
// Then, if _background is defined, the graphics operations described in the string are performed on the canvas.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:_background
func (g *Graph) SetBackground(v string) *Graph {
g.SafeSet(string(backgroundAttr), v, "")
return g
}
// SetArea
// Indicates the preferred area for a node or empty cluster when laid out by patchwork.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:area
func (n *Node) SetArea(v float64) *Node {
n.SafeSet(string(areaAttr), fmt.Sprint(v), "1.0")
return n
}
type ArrowType string
const (
NormalArrow ArrowType = "normal"
InvArrow ArrowType = "inv"
DotArrow ArrowType = "dot"
InvDotArrow ArrowType = "invdot"
ODotArrow ArrowType = "odot"
InvODotArrow ArrowType = "invodot"
NoneArrow ArrowType = "none"
TeeArrow ArrowType = "tee"
EmptyArrow ArrowType = "empty"
InvEmptyArrow ArrowType = "invempty"
DiamondArrow ArrowType = "diamond"
ODiamondArrow ArrowType = "odiamond"
EDiamondArrow ArrowType = "ediamond"
CrowArrow ArrowType = "crow"
BoxArrow ArrowType = "box"
OBoxArrow ArrowType = "obox"
OpenArrow ArrowType = "open"
HalfOpenArrow ArrowType = "halfopen"
VeeArrow ArrowType = "vee"
)
// SetArrowHead
// Style of arrowhead on the head node of an edge.
// This will only appear if the dir attribute is "forward" or "both".
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:arrowhead
func (e *Edge) SetArrowHead(v ArrowType) *Edge {
e.SafeSet(string(arrowHeadAttr), string(v), string(NormalArrow))
return e
}
// SetArrowSize
// Multiplicative scale factor for arrowheads.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:arrowsize
func (e *Edge) SetArrowSize(v float64) *Edge {
e.SafeSet(string(arrowSizeAttr), fmt.Sprint(v), "1.0")
return e
}
// SetArrowTail
// Style of arrowhead on the tail node of an edge.
// This will only appear if the dir attribute is "back" or "both".
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:arrowtail
func (e *Edge) SetArrowTail(v ArrowType) *Edge {
e.SafeSet(string(arrowTailAttr), string(v), string(NormalArrow))
return e
}
// SetBB
// Bounding box of drawing in points.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:bb
func (g *Graph) SetBB(llx, lly, urx, ury float64) *Graph {
g.SafeSet(string(bbAttr), fmt.Sprintf("%f,%f,%f,%f", llx, lly, urx, ury), "")
return g
}
// SetBackgroundColor
// When attached to the root graph, this color is used as the background for entire canvas.
// When a cluster attribute, it is used as the initial background for the cluster.
// If a cluster has a filled style, the cluster's fillcolor will overlay the background color.
// If the value is a colorList, a gradient fill is used.
// By default, this is a linear fill; setting style=radial will cause a radial fill.
// At present, only two colors are used.
// If the second color (after a colon) is missing, the default color is used for it.
// See also the gradientangle attribute for setting the gradient angle.
//
// For certain output formats, such as PostScript, no fill is done for the root graph unless bgcolor is explicitly set.
// For bitmap formats, however, the bits need to be initialized to something, so the canvas is filled with white by default.
// This means that if the bitmap output is included in some other document,
// all of the bits within the bitmap's bounding box will be set, overwriting whatever color or graphics were already on the page.
// If this effect is not desired, and you only want to set bits explicitly assigned in drawing the graph, set bgcolor="transparent".
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:bgcolor
func (g *Graph) SetBackgroundColor(v string) *Graph {
g.SafeSet(string(bgcolorAttr), v, "")
return g
}
// SetCenter
// If true, the drawing is centered in the output canvas.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:center
func (g *Graph) SetCenter(v bool) *Graph {
g.SafeSet(string(centerAttr), toBoolString(v), falseStr)
return g
}
// SetCharset
// Specifies the character encoding used when interpreting string input as a text label.
// The default value is "UTF-8".
// The other legal value is "iso-8859-1" or, equivalently, "Latin1".
// The charset attribute is case-insensitive.
// Note that if the character encoding used in the input does not match the charset value, the resulting output may be very strange.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:charset
func (g *Graph) SetCharset(v string) *Graph {
g.SafeSet(string(charsetAttr), v, "UTF-8")
return g
}
type ClusterMode string
const (
LocalCluster ClusterMode = "local"
GlobalCluster ClusterMode = "global"
NoneCluster ClusterMode = "none"
)
// SetClusterRank
// Mode used for handling clusters.
// If clusterrank is "local", a subgraph whose name begins with "cluster" is given special treatment.
// The subgraph is laid out separately, and then integrated as a unit into its parent graph, with a bounding rectangle drawn about it.
// If the cluster has a label parameter, this label is displayed within the rectangle.
// Note also that there can be clusters within clusters.
// At present, the modes "global" and "none" appear to be identical, both turning off the special cluster processing.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:clusterrank
func (g *Graph) SetClusterRank(v ClusterMode) *Graph {
g.SafeSet(string(clusterRankAttr), string(v), string(LocalCluster))
return g
}
// SetColor
// Basic drawing color for graphics, not text.
// For the latter, use the fontcolor attribute.
// For edges, the value can either be a single color or a colorList.
// In the latter case, if colorList has no fractions,
// the edge is drawn using parallel splines or lines, one for each color in the list, in the order given.
// The head arrow, if any, is drawn using the first color in the list, and the tail arrow, if any, the second color.
// This supports the common case of drawing opposing edges, but using parallel splines instead of separately routed multiedges.
// If any fraction is used, the colors are drawn in series, with each color being given roughly its specified fraction of the edge.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:color
func (n *Node) SetColor(v string) *Node {
n.SafeSet(string(colorAttr), v, "black")
return n
}
// SetColor
// Basic drawing color for graphics, not text.
// For the latter, use the fontcolor attribute.
// For edges, the value can either be a single color or a colorList.
// In the latter case, if colorList has no fractions,
// the edge is drawn using parallel splines or lines, one for each color in the list, in the order given.
// The head arrow, if any, is drawn using the first color in the list, and the tail arrow, if any, the second color.
// This supports the common case of drawing opposing edges, but using parallel splines instead of separately routed multiedges.
// If any fraction is used, the colors are drawn in series, with each color being given roughly its specified fraction of the edge.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:color
func (e *Edge) SetColor(v string) *Edge {
e.SafeSet(string(colorAttr), v, "black")
return e
}
// SetColorScheme
// This attribute specifies a color scheme namespace.
// If defined, it specifies the context for interpreting color names.
// In particular, if a color value has form "xxx" or "//xxx", then the color xxx will be evaluated according to the current color scheme.
// If no color scheme is set, the standard X11 naming is used.
// For example, if colorscheme=bugn9, then color=7 is interpreted as "/bugn9/7".
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:colorscheme
func (g *Graph) SetColorScheme(v string) *Graph {
g.SafeSet(string(colorSchemeAttr), v, "")
return g
}
// SetColorScheme
// This attribute specifies a color scheme namespace.
// If defined, it specifies the context for interpreting color names.
// In particular, if a color value has form "xxx" or "//xxx", then the color xxx will be evaluated according to the current color scheme.
// If no color scheme is set, the standard X11 naming is used.
// For example, if colorscheme=bugn9, then color=7 is interpreted as "/bugn9/7".
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:colorscheme
func (n *Node) SetColorScheme(v string) *Node {
n.SafeSet(string(colorSchemeAttr), v, "")
return n
}
// SetColorScheme
// This attribute specifies a color scheme namespace.
// If defined, it specifies the context for interpreting color names.
// In particular, if a color value has form "xxx" or "//xxx", then the color xxx will be evaluated according to the current color scheme.
// If no color scheme is set, the standard X11 naming is used.
// For example, if colorscheme=bugn9, then color=7 is interpreted as "/bugn9/7".
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:colorscheme
func (e *Edge) SetColorScheme(v string) *Edge {
e.SafeSet(string(colorSchemeAttr), v, "")
return e
}
// SetComment
// Comments are inserted into output. Device-dependent
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:comment
func (g *Graph) SetComment(v string) *Graph {
g.SafeSet(string(commentAttr), v, "")
return g
}
// SetComment
// Comments are inserted into output. Device-dependent
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:comment
func (n *Node) SetComment(v string) *Node {
n.SafeSet(string(commentAttr), v, "")
return n
}
// SetComment
// Comments are inserted into output. Device-dependent
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:comment
func (e *Edge) SetComment(v string) *Edge {
e.SafeSet(string(commentAttr), v, "")
return e
}
// SetCompound
// If true, allow edges between clusters. (See lhead and ltail below.)
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:compound
func (g *Graph) SetCompound(v bool) *Graph {
g.SafeSet(string(compoundAttr), toBoolString(v), falseStr)
return g
}
// SetConcentrate
// If true, use edge concentrators.
// This merges multiedges into a single edge and causes partially parallel edges to share part of their paths.
// The latter feature is not yet available outside of dot.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:concentrate
func (g *Graph) SetConcentrate(v bool) *Graph {
g.SafeSet(string(concentrateAttr), toBoolString(v), falseStr)
return g
}
// SetConstraint
// If false, the edge is not used in ranking the nodes.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:constraint
func (e *Edge) SetConstraint(v bool) *Edge {
e.SafeSet(string(constraintAttr), toBoolString(v), trueStr)
return e
}
// SetDecorate
// If true, attach edge label to edge by a 2-segment polyline, underlining the label, then going to the closest point of spline.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:decorate
func (e *Edge) SetDecorate(v bool) *Edge {
e.SafeSet(string(decorateAttr), toBoolString(v), falseStr)
return e
}
// SetDefaultDist
// This specifies the distance between nodes in separate connected components.
// If set too small, connected components may overlap.
// Only applicable if pack=false.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:defaultdist
func (g *Graph) SetDefaultDist(v float64) *Graph {
g.SafeSet(string(defaultDistAttr), fmt.Sprint(v), "1.0")
return g
}
// SetDim
// Set the number of dimensions used for the layout.
// The maximum value allowed is 10.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:dim
func (g *Graph) SetDim(v int) *Graph {
g.SafeSet(string(dimAttr), fmt.Sprint(v), "2")
return g
}
// SetDimen
// Set the number of dimensions used for rendering.
// The maximum value allowed is 10.
// If both dimen and dim are set, the latter specifies the dimension used for layout, and the former for rendering.
// If only dimen is set, this is used for both layout and rendering dimensions.
// Note that, at present, all aspects of rendering are 2D.
// This includes the shape and size of nodes, overlap removal, and edge routing.
// Thus, for dimen > 2, the only valid information is the pos attribute of the nodes.
// All other coordinates will be 2D and, at best, will reflect a projection of a higher-dimensional point onto the plane.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:dimen
func (g *Graph) SetDimen(v int) *Graph {
g.SafeSet(string(dimAttr), fmt.Sprint(v), "2")
return g
}
type DirType string
const (
ForwardDir DirType = "forward"
BackDir DirType = "back"
BothDir DirType = "both"
NoneDir DirType = "none"
)
// SetDir
// Set edge type for drawing arrowheads.
// This indicates which ends of the edge should be decorated with an arrowhead.
// The actual style of the arrowhead can be specified using the arrowhead and arrowtail attributes.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:dir
func (e *Edge) SetDir(v DirType) *Edge {
e.SafeSet(string(dirAttr), string(v), string(ForwardDir))
return e
}
// SetDirEdgeConstraints
// Only valid when mode="ipsep".
// If true, constraints are generated for each edge in the largest (heuristic) directed acyclic subgraph such that the edge must point downwards.
// If "hier", generates level constraints similar to those used with mode="hier".
// The main difference is that, in the latter case, only these constraints are involved, so a faster solver can be used.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:diredgeconstraints
func (g *Graph) SetDirEdgeConstraints(v string) *Graph {
g.SafeSet(string(dirEdgeConstraintsAttr), v, falseStr)
return g
}
// SetDistortion
// Distortion factor for shape=polygon.
// Positive values cause top part to be larger than bottom; negative values do the opposite.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:distortion
func (n *Node) SetDistortion(v float64) *Node {
n.SafeSet(string(distortionAttr), fmt.Sprint(v), "0.0")
return n
}
// SetDPI
// This specifies the expected number of pixels per inch on a display device.
// For bitmap output, this guarantees that text rendering will be done more accurately, both in size and in placement.
// For SVG output, it is used to guarantee that the dimensions in the output correspond to the correct number of points or inches.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:dpi
func (g *Graph) SetDPI(v float64) *Graph {
g.SafeSet(string(dpiAttr), fmt.Sprint(v), "96.0")
return g
}
// SetEdgeURL
// If edgeURL is defined, this is the link used for the non-label parts of an edge.
// This value overrides any URL defined for the edge.
// Also, this value is used near the head or tail node unless overridden by a headURL or tailURL value, respectively.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:edgeURL
func (e *Edge) SetEdgeURL(v string) *Edge {
e.SafeSet(string(edgeURLAttr), v, "")
return e
}
// SetEdgeHref
// Synonym for edgeURL.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:edgehref
func (e *Edge) SetEdgeHref(v string) *Edge {
e.SafeSet(string(edgeHrefAttr), v, "")
return e
}
// SetEdgeTarget
// If the edge has a URL or edgeURL attribute,
// this attribute determines which window of the browser is used for the URL attached to the non-label part of the edge.
// Setting it to "_graphviz" will open a new window if it doesn't already exist, or reuse it if it does.
// If undefined, the value of the target is used.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:edgetarget
func (e *Edge) SetEdgeTarget(v string) *Edge {
e.SafeSet(string(edgeTargetAttr), v, "")
return e
}
// SetEdgeTooltip
// Tooltip annotation attached to the non-label part of an edge.
// This is used only if the edge has a URL or edgeURL attribute.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:edgetooltip
func (e *Edge) SetEdgeTooltip(v string) *Edge {
e.SafeSet(string(edgeTooltipAttr), v, "")
return e
}
// SetEpsilon
// Terminating condition.
// If the length squared of all energy gradients are < epsilon, the algorithm stops.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:epsilon
func (g *Graph) SetEpsilon(v float64) *Graph {
g.SafeSet(string(epsilonAttr), fmt.Sprint(v), ".0001")
return g
}
// SetESep
// Margin used around polygons for purposes of spline edge routing.
// The interpretation is the same as given for sep.
// This should normally be strictly less than sep.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:esep
func (g *Graph) SetESep(v float64) *Graph {
g.SafeSet(string(esepAttr), fmt.Sprintf("+%f", v), "+3")
return g
}
// SetFillColor
// Color used to fill the background of a node or cluster assuming style=filled, or a filled arrowhead.
// If fillcolor is not defined, color is used. (For clusters, if color is not defined, bgcolor is used.)
// If this is not defined, the default is used, except for shape=point or when the output format is MIF, which use black by default.
// If the value is a colorList, a gradient fill is used. By default, this is a linear fill; setting style=radial will cause a radial fill.
// At present, only two colors are used.
// If the second color (after a colon) is missing, the default color is used for it.
// See also the gradientangle attribute for setting the gradient angle.
//
// Note that a cluster inherits the root graph's attributes if defined.
// Thus, if the root graph has defined a fillcolor, this will override a color or bgcolor attribute set for the cluster.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:fillcolor
func (n *Node) SetFillColor(v string) *Node {
n.SafeSet(string(fillColorAttr), v, "lightgrey")
return n
}
// SetFixedSize
// If false, the size of a node is determined by smallest width and height needed to contain its label and image,
// if any, with a margin specified by the margin attribute.
// The width and height must also be at least as large as the sizes specified by the width and height attributes, which specify the minimum values for these parameters.
// If true, the node size is specified by the values of the width and height attributes only and is not expanded to contain the text label.
// There will be a warning if the label (with margin) cannot fit within these limits.
//
// If the fixedsize attribute is set to shape,
// the width and height attributes also determine the size of the node shape, but the label can be much larger.
// Both the label and shape sizes are used when avoiding node overlap,
// but all edges to the node ignore the label and only contact the node shape.
// No warning is given if the label is too large.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:fixedsize
func (n *Node) SetFixedSize(v bool) *Node {
n.SafeSet(string(fixedSizeAttr), toBoolString(v), falseStr)
return n
}
// SetFontColor
// Color used for text.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:fontcolor
func (g *Graph) SetFontColor(v string) *Graph {
g.SafeSet(string(fontColorAttr), v, "black")
return g
}
// SetFontColor
// Color used for text.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:fontcolor
func (n *Node) SetFontColor(v string) *Node {
n.SafeSet(string(fontColorAttr), v, "black")
return n
}
// SetFontColor
// Color used for text.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:fontcolor
func (e *Edge) SetFontColor(v string) *Edge {
e.SafeSet(string(fontColorAttr), v, "black")
return e
}
// SetFontSize
// Font size, in points, used for text.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:fontsize
func (g *Graph) SetFontSize(v float64) *Graph {
g.SafeSet(string(fontSizeAttr), fmt.Sprint(v), "14.0")
return g
}
// SetFontSize
// Font size, in points, used for text.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:fontsize
func (n *Node) SetFontSize(v float64) *Node {
n.SafeSet(string(fontSizeAttr), fmt.Sprint(v), "14.0")
return n
}
// SetFontSize
// Font size, in points, used for text.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:fontsize
func (e *Edge) SetFontSize(v float64) *Edge {
e.SafeSet(string(fontSizeAttr), fmt.Sprint(v), "14.0")
return e
}
// SetForceLabels
// If true, all xlabel attributes are placed, even if there is some overlap with nodes or other labels.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:forcelabels
func (g *Graph) SetForceLabels(v bool) *Graph {
g.SafeSet(string(forceLabelsAttr), toBoolString(v), trueStr)
return g
}
// SetGradientAngle
// If a gradient fill is being used, this determines the angle of the fill.
// For linear fills, the colors transform along a line specified by the angle and the center of the object.
// For radial fills, a value of zero causes the colors to transform radially from the center;
// for non-zero values, the colors transform from a point near the object's periphery as specified by the value.
// If unset, the default angle is 0.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:gradientangle
func (g *Graph) SetGradientAngle(v int) *Graph {
g.SafeSet(string(gradientAngleAttr), fmt.Sprint(v), "")
return g
}
// SetGradientAngle
// If a gradient fill is being used, this determines the angle of the fill.
// For linear fills, the colors transform along a line specified by the angle and the center of the object.
// For radial fills, a value of zero causes the colors to transform radially from the center;
// for non-zero values, the colors transform from a point near the object's periphery as specified by the value.
// If unset, the default angle is 0.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:gradientangle
func (n *Node) SetGradientAngle(v int) *Node {
n.SafeSet(string(gradientAngleAttr), fmt.Sprint(v), "")
return n
}
// SetGroup
// If the end points of an edge belong to the same group,
// i.e., have the same group attribute, parameters are set to avoid crossings and keep the edges straight.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:group
func (n *Node) SetGroup(v string) *Node {
n.SafeSet(string(groupAttr), v, "")
return n
}
// SetHeadURL
// If headURL is defined, it is output as part of the head label of the edge.
// Also, this value is used near the head node, overriding any URL value.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:headURL
func (e *Edge) SetHeadURL(v string) *Edge {
e.SafeSet(string(headURLAttr), v, "")
return e
}
// SetHeadLabelPoint
// Position of an edge's head label, in points.
// The position indicates the center of the label.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:head_lp
func (e *Edge) SetHeadLabelPoint(x, y float64) *Edge {
e.SafeSet(string(headLpAttr), fmt.Sprintf("%f,%f", x, y), "")
return e
}
// SetHeadClip
// If true, the head of an edge is clipped to the boundary of the head node;
// otherwise, the end of the edge goes to the center of the node, or the center of a port, if applicable.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:headclip
func (e *Edge) SetHeadClip(v bool) *Edge {
e.SafeSet(string(headClipAttr), toBoolString(v), trueStr)
return e
}
// SetHeadHref
// Synonym for headURL.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:headhref
func (e *Edge) SetHeadHref(v string) *Edge {
e.SafeSet(string(headHrefAttr), v, "")
return e
}
// SetHeadLabel
// Text label to be placed near head of edge
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:headlabel
func (e *Edge) SetHeadLabel(v string) *Edge {
e.SafeSet(string(headLabelAttr), v, "")
return e
}
// SetHeadPort
// Indicates where on the head node to attach the head of the edge.
// In the default case, the edge is aimed towards the center of the node, and then clipped at the node boundary.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:headport
func (e *Edge) SetHeadPort(v string) *Edge {
e.SafeSet(string(headPortAttr), v, "")
return e
}
// SetHeadTarget
// If the edge has a headURL, this attribute determines which window of the browser is used for the URL.
// Setting it to "_graphviz" will open a new window if it doesn't already exist,
// or reuse it if it does. If undefined, the value of the target is used.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:headtarget
func (e *Edge) SetHeadTarget(v string) *Edge {
e.SafeSet(string(headTargetAttr), v, "")
return e
}
// SetHeadTooltip
// Tooltip annotation attached to the head of an edge.
// This is used only if the edge has a headURL attribute.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:headtooltip
func (e *Edge) SetHeadTooltip(v string) *Edge {
e.SafeSet(string(headTooltipAttr), v, "")
return e
}
// SetHeight
// Height of node, in inches.
// This is taken as the initial, minimum height of the node.
// If fixedsize is true, this will be the final height of the node.
// Otherwise, if the node label requires more height to fit, the node's height will be increased to contain the label.
// Note also that, if the output format is dot, the value given to height will be the final value.
// If the node shape is regular, the width and height are made identical.
// In this case, if either the width or the height is set explicitly, that value is used.
// In this case, if both the width or the height are set explicitly, the maximum of the two values is used.
// If neither is set explicitly, the minimum of the two default values is used.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:height
func (n *Node) SetHeight(v float64) *Node {
n.SafeSet(string(heightAttr), fmt.Sprint(v), "0.5")
return n
}
// SetHref
// Synonym for URL.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:href
func (g *Graph) SetHref(v string) *Graph {
g.SafeSet(string(hrefAttr), v, "")
return g
}
// SetHref
// Synonym for URL.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:href
func (n *Node) SetHref(v string) *Node {
n.SafeSet(string(hrefAttr), v, "")
return n
}
// SetHref
// Synonym for URL.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:href
func (e *Edge) SetHref(v string) *Edge {
e.SafeSet(string(hrefAttr), v, "")
return e
}
// SetID
// Allows the graph author to provide an id for graph objects which is to be included in the output.
// Normal "\N", "\E", "\G" substitutions are applied.
// If provided, it is the responsibility of the provider to keep its values sufficiently unique for its intended downstream use.
// Note, in particular, that "\E" does not provide a unique id for multi-edges.
// If no id attribute is provided, then a unique internal id is used.
// However, this value is unpredictable by the graph writer.
// An externally provided id is not used internally.
// If the graph provides an id attribute, this will be used as a prefix for internally generated attributes.
// By making these distinct, the user can include multiple image maps in the same document.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:id
func (g *Graph) SetID(v string) *Graph {
g.SafeSet(string(idAttr), v, "")
return g
}
// SetID
// Allows the graph author to provide an id for graph objects which is to be included in the output.
// Normal "\N", "\E", "\G" substitutions are applied.
// If provided, it is the responsibility of the provider to keep its values sufficiently unique for its intended downstream use.
// Note, in particular, that "\E" does not provide a unique id for multi-edges.
// If no id attribute is provided, then a unique internal id is used.
// However, this value is unpredictable by the graph writer.
// An externally provided id is not used internally.
// If the graph provides an id attribute, this will be used as a prefix for internally generated attributes.
// By making these distinct, the user can include multiple image maps in the same document.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:id
func (n *Node) SetID(v string) *Node {
n.SafeSet(string(idAttr), v, "")
return n
}
// SetID
// Allows the graph author to provide an id for graph objects which is to be included in the output.
// Normal "\N", "\E", "\G" substitutions are applied.
// If provided, it is the responsibility of the provider to keep its values sufficiently unique for its intended downstream use.
// Note, in particular, that "\E" does not provide a unique id for multi-edges.
// If no id attribute is provided, then a unique internal id is used.
// However, this value is unpredictable by the graph writer.
// An externally provided id is not used internally.
// If the graph provides an id attribute, this will be used as a prefix for internally generated attributes.
// By making these distinct, the user can include multiple image maps in the same document.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:id
func (e *Edge) SetID(v string) *Edge {
e.SafeSet(string(idAttr), v, "")
return e
}
// SetImage
// Gives the name of a file containing an image to be displayed inside a node.
// The image file must be in one of the recognized formats,
// typically JPEG, PNG, GIF, BMP, SVG or Postscript, and be able to be converted into the desired output format.
// The file must contain the image size information.
// This is usually trivially true for the bitmap formats.
// For PostScript, the file must contain a line starting with %%BoundingBox:
// followed by four integers specifying the lower left x and y coordinates
// and the upper right x and y coordinates of the bounding box for the image, the coordinates being in points.
// An SVG image file must contain width and height attributes, typically as part of the svg element.
// The values for these should have the form of a floating point number, followed by optional units,
// e.g., width="76pt".
// Recognized units are in, px, pc, pt, cm and mm for inches, pixels, picas, points, centimeters and millimeters, respectively.
// The default unit is points.
//
// Unlike with the shapefile attribute, the image is treated as node content rather than the entire node.
// In particular, an image can be contained in a node of any shape, not just a rectangle.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:image
func (n *Node) SetImage(v string) *Node {
n.SafeSet(string(imageAttr), v, "")
return n
}
// SetImagePath
// Specifies a list of directories in which to look for image files as specified by the image attribute or using the IMG element in HTML-like labels.
// The string should be a list of (absolute or relative) pathnames, each separated by a semicolon (for Windows) or a colon (all other OS).
// The first directory in which a file of the given name is found will be used to load the image.
// If imagepath is not set, relative pathnames for the image file will be interpreted with respect to the current working directory.
// https://graphviz.gitlab.io/_pages/doc/info/attrs.html#a:imagepath
func (g *Graph) SetImagePath(v string) *Graph {
g.SafeSet(string(imagePathAttr), v, "")
return g
}