TreeDiagram
src.drawpyo.diagram_types.tree.TreeDiagram
The TreeDiagram contains a File object, a Page object, and all the NodeObjects in the tree.
Source code in src/drawpyo/diagram_types/tree.py
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 |
|
direction
property
writable
The direction the tree diagram should grow. Options are "up", "down", "left", or "right".
Returns:
Type | Description |
---|---|
str |
file_name
property
writable
The file name of the TreeDiagram
Returns:
Type | Description |
---|---|
str |
file_path
property
writable
The file path where the TreeDiagram will be saved
Returns:
Type | Description |
---|---|
str |
link_style
property
writable
The style of the links in the TreeDiagram
Returns:
Type | Description |
---|---|
str |
link_style_dict
property
Returns the correct waypoint style for the set link_style
Returns:
Name | Type | Description |
---|---|---|
dict |
A dict with 'waypoint' as a key then the set link_style |
origin
property
The origin points of the TreeDiagram. This is the point where the center of the top level of the TreeDiagram starts from. By default it's set to the top center of an edge of the page. Which edge depends on the direction of the tree diagram.
Returns:
Name | Type | Description |
---|---|---|
tuple |
A tuple of ints |
__init__(**kwargs)
The TreeDiagram initiates its own File and Page objects. There are a number of formatting parameters that can be set to fine tune the rendering of the tree.
Other Parameters:
Name | Type | Description |
---|---|---|
direction |
str
|
Direction that the tree grows from the root. Options are 'up', 'down', 'left', and 'right'. Defaults to 'down'. |
link_style |
str
|
Connection style of the edges. Options are 'orthogonal', 'straight', and 'curved'. Defaults to 'orthogonal'. |
level_spacing |
int
|
Spacing in pixels between levels. Defaults to 60. |
item_spacing |
int
|
Spacing in pixels between groups within a level. Defaults to 15. |
padding |
int
|
Spacing in pixels between objects within a group. Defaults to 10. |
file_name |
str
|
The name of the tree diagram. |
file_path |
str
|
The path where the tree diagram should be saved. |
Source code in src/drawpyo/diagram_types/tree.py
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 |
|
abs_move_between_levels(start, position)
The functions takes in a starting position and an absolute position along the coordinates between levels. It outputs a tuple with the final absolute position in the correct direction (horizontal or vertical) depending on the direction of the tree diagram.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start |
tuple
|
The starting position, a tuple of ints |
required |
move |
int
|
The direction to move between levels. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
"No direction defined!" |
Returns:
Name | Type | Description |
---|---|---|
tuple |
The final position, a tuple of ints |
Source code in src/drawpyo/diagram_types/tree.py
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
|
abs_move_in_level(start, position)
The functions takes in a starting position and an absolute position along the coordinates within a level. It outputs a tuple with the final absolute position in the correct direction (horizontal or vertical) depending on the direction of the tree diagram.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start |
tuple
|
The starting position, a tuple of ints |
required |
move |
int
|
The direction to move between levels. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
"No direction defined!" |
Returns:
Name | Type | Description |
---|---|---|
tuple |
The final position, a tuple of ints |
Source code in src/drawpyo/diagram_types/tree.py
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
|
level_move(move)
The functions takes in a relative distance to move within levels. It outputs a tuple with the relative move in the correct direction (horizontal or vertical) depending on the direction of the tree diagram.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
move |
int
|
The amount to move within levels |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple |
A tuple containing a 0 and the move, in the right orientation. |
Source code in src/drawpyo/diagram_types/tree.py
279 280 281 282 283 284 285 286 287 288 289 290 291 |
|
move_between_levels(start, move)
The functions takes in a starting position and a relative distance to move between levels. It outputs a tuple with the final absolute position in the correct direction (horizontal or vertical) depending on the direction of the tree diagram.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start |
tuple
|
The starting position, a tuple of ints |
required |
move |
int
|
The direction to move between levels. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
"No direction defined!" |
Returns:
Name | Type | Description |
---|---|---|
tuple |
The final position, a tuple of ints |
Source code in src/drawpyo/diagram_types/tree.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
|
move_in_level(start, move)
The functions takes in a starting position and a relative distance to move within a level. It outputs a tuple with the final absolute position in the correct direction (horizontal or vertical) depending on the direction of the tree diagram.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start |
tuple
|
The starting position, a tuple of ints |
required |
move |
int
|
The direction to move between levels. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
"No direction defined!" |
Returns:
Name | Type | Description |
---|---|---|
tuple |
The final position, a tuple of ints |
Source code in src/drawpyo/diagram_types/tree.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
|
TreeGroup
src.drawpyo.diagram_types.tree.TreeGroup
Bases: Group
This class defines a group within a TreeDiagram. When a set of NodeObjects share the same parent they're grouped together for auto positioning. Each level of a TreeDiagram is a set of groups.
Source code in src/drawpyo/diagram_types/tree.py
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 |
|
parent_object
property
writable
The object that defines the parent of the group.
Returns:
Type | Description |
---|---|
NodeObject |
size_in_level
property
The size of the object within its level, either its width or height depending on tree orientation.
Returns:
Type | Description |
---|---|
int |
size_of_level
property
The height or the width of the level, depending on tree orientation.
Returns:
Type | Description |
---|---|
int |
__init__(tree=None, parent_object=None, **kwargs)
The TreeGroup is instantiated with all the arguments of the Group. Additionally, the owning tree and the parent_object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tree |
TreeDiagram
|
The TreeDiagram that owns the group. Defaults to None. |
None
|
parent_object |
NodeObject
|
The parent object in the group. Defaults to None. |
None
|
Source code in src/drawpyo/diagram_types/tree.py
103 104 105 106 107 108 109 110 111 112 |
|
center_parent()
This function centers the parent_objects along the group and then offsets it by the level spacing.
Source code in src/drawpyo/diagram_types/tree.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
|