Edges
src.drawpyo.diagram.edges.Edge
Bases: DiagramBase
The Edge class is the simplest class for defining an edge or an arrow in a Draw.io diagram.
The three primary styling inputs are the waypoints, connections, and pattern. These are how edges are styled in the Draw.io app, with dropdown menus for each one. But it's not how the style string is assembled in the XML. To abstract this, the Edge class loads a database called edge_styles.toml. The database maps the options in each dropdown to the style strings they correspond to. The Edge class then assembles the style strings on export.
More information about edges are in the Usage documents at Usage - Edges.
Source code in src/drawpyo/diagram/edges.py
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 |
|
attributes
property
Returns the XML attributes to be added to the tag for the object
Returns:
Name | Type | Description |
---|---|---|
dict |
Dictionary of object attributes and their values |
baseStyle
property
Generates the baseStyle string from the connection style, waypoint style, pattern style, and base style string.
Returns:
Name | Type | Description |
---|---|---|
str |
Concatenated baseStyle string |
connection
property
writable
The connection style. Checks if the passed in value is in the TOML database of connections before setting and throws a ValueError if not.
Returns:
Name | Type | Description |
---|---|---|
str |
The style of the connections |
endArrow
property
writable
What graphic the edge should be rendered with at the target
Returns:
Name | Type | Description |
---|---|---|
str |
The target edge graphic |
endFill
property
Whether the graphic at the target should be filled
Returns:
Name | Type | Description |
---|---|---|
bool |
The target graphic fill |
label
deletable
property
writable
The text to place on the label, aka its value.
label_offset
deletable
property
writable
How far the label is offset away from the axis of the edge in pixels
label_position
deletable
property
writable
Where along the edge the label is positioned. -1 is the source, 1 is the target, 0 is the center.
pattern
property
writable
The pattern style. Checks if the passed in value is in the TOML database of patterns before setting and throws a ValueError if not.
Returns:
Name | Type | Description |
---|---|---|
str |
The style of the patterns |
source
deletable
property
writable
The source object of the edge. Automatically adds the edge to the object when set and removes it when deleted.
Returns:
Name | Type | Description |
---|---|---|
BaseDiagram |
source object of the edge |
source_id
property
The ID of the source object or 1 if no source is set
Returns:
Name | Type | Description |
---|---|---|
int |
Source object ID |
startArrow
property
writable
What graphic the edge should be rendered with at the source
Returns:
Name | Type | Description |
---|---|---|
str |
The source edge graphic |
startFill
property
Whether the graphic at the source should be filled
Returns:
Name | Type | Description |
---|---|---|
bool |
The source graphic fill |
style_attributes
property
The style attributes to add to the style tag in the XML
Returns:
Name | Type | Description |
---|---|---|
list |
A list of style attributes |
target
deletable
property
writable
The target object of the edge. Automatically adds the edge to the object when set and removes it when deleted.
Returns:
Name | Type | Description |
---|---|---|
BaseDiagram |
target object of the edge |
target_id
property
The ID of the target object or 1 if no target is set
Returns:
Name | Type | Description |
---|---|---|
int |
Target object ID |
waypoints
property
writable
The waypoint style. Checks if the passed in value is in the TOML database of waypoints before setting and throws a ValueError if not.
Returns:
Name | Type | Description |
---|---|---|
str |
The style of the waypoints |
xml
property
The opening and closing XML tags with the styling attributes included.
Returns:
Name | Type | Description |
---|---|---|
str |
description |
__init__(**kwargs)
Edges can be initialized with almost all styling parameters as args. See Usage - Edges for more information and the options for each parameter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source |
DiagramBase
|
The Draw.io object that the edge originates from |
required |
target |
DiagramBase
|
The Draw.io object that the edge points to |
required |
label |
str
|
The text to place on the edge. |
required |
label_position |
float
|
Where along the edge the label is positioned. -1 is the source, 1 is the target, 0 is the center |
required |
label_offset |
int
|
How far the label is offset away from the axis of the edge in pixels |
required |
waypoints |
str
|
How the edge should be styled in Draw.io |
required |
connection |
str
|
What type of style the edge should be rendered with |
required |
pattern |
str
|
How the line of the edge should be rendered |
required |
shadow |
bool
|
Add a shadow to the edge |
required |
rounded |
bool
|
Whether the corner of the line should be rounded |
required |
flowAnimation |
bool
|
Add a marching ants animation along the edge |
required |
sketch |
bool
|
Add sketch styling to the edge |
required |
line_end_target |
str
|
What graphic the edge should be rendered with at the target |
required |
line_end_source |
str
|
What graphic the edge should be rendered with at the source |
required |
endFill_target |
boolean
|
Whether the target graphic should be filled |
required |
endFill_source |
boolean
|
Whether the source graphic should be filled |
required |
endSize |
int
|
The size of the end arrow in points |
required |
startSize |
int
|
The size of the start arrow in points |
required |
jettySize |
str or int
|
Length of the straight sections at the end of the edge. "auto" or a number |
required |
targetPerimeterSpacing |
int
|
The negative or positive spacing between the target and end of the edge (points) |
required |
sourcePerimeterSpacing |
int
|
The negative or positive spacing between the source and end of the edge (points) |
required |
entryX |
int
|
From where along the X axis on the source object the edge originates (0-1) |
required |
entryY |
int
|
From where along the Y axis on the source object the edge originates (0-1) |
required |
entryDx |
int
|
Applies an offset in pixels to the X axis entry point |
required |
entryDy |
int
|
Applies an offset in pixels to the Y axis entry point |
required |
exitX |
int
|
From where along the X axis on the target object the edge originates (0-1) |
required |
exitY |
int
|
From where along the Y axis on the target object the edge originates (0-1) |
required |
exitDx |
int
|
Applies an offset in pixels to the X axis exit point |
required |
exitDy |
int
|
Applies an offset in pixels to the Y axis exit point |
required |
strokeColor |
str
|
The color of the border of the edge ('none', 'default', or hex color code) |
required |
strokeWidth |
int
|
The width of the border of the the edge within range (1-999) |
required |
fillColor |
str
|
The color of the fill of the edge ('none', 'default', or hex color code) |
required |
jumpStyle |
str
|
The line jump style ('arc', 'gap', 'sharp', 'line') |
required |
jumpSize |
int
|
The size of the line jumps in points. |
required |
opacity |
int
|
The opacity of the edge (0-100) |
required |
Source code in src/drawpyo/diagram/edges.py
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 |
|
add_point(x, y)
Add a point to the edge
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
int
|
The x coordinate of the point in pixels |
required |
y |
int
|
The y coordinate of the point in pixels |
required |
Source code in src/drawpyo/diagram/edges.py
245 246 247 248 249 250 251 252 |
|
add_point_pos(position)
Add a point to the edge by position tuple
Parameters:
Name | Type | Description | Default |
---|---|---|---|
position |
tuple
|
A tuple of ints describing the x and y coordinates in pixels |
required |
Source code in src/drawpyo/diagram/edges.py
254 255 256 257 258 259 260 |
|
remove()
This function removes references to the Edge from its source and target objects then deletes the Edge.
Source code in src/drawpyo/diagram/edges.py
148 149 150 151 152 153 154 |
|