Skip to content

Commit

Permalink
Merge pull request #18 from MerrimanInd/dev
Browse files Browse the repository at this point in the history
Completed docs, implemented pytest/tox, added more formatting to Edge, added TextFormat
  • Loading branch information
MerrimanInd authored Apr 1, 2024
2 parents ad23c54 + 51bd111 commit 707c87f
Show file tree
Hide file tree
Showing 57 changed files with 2,251 additions and 603 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ __pycache__/
build/
develop-eggs/
dist/
site/
downloads/
eggs/
.eggs/
Expand Down
16 changes: 0 additions & 16 deletions Test Draw.io Charts/container.drawio

This file was deleted.

89 changes: 0 additions & 89 deletions development scripts/test_edge_creation.py

This file was deleted.

14 changes: 0 additions & 14 deletions development scripts/test_objects_from_base.py

This file was deleted.

4 changes: 2 additions & 2 deletions docs/api/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Drawpyo provides two high level classes to define critical methods and attribute

## XMLBase

::: drawpyo.xml_base.XMLBase
::: src.drawpyo.xml_base.XMLBase

-----

## DiagramBase

::: drawpyo.diagram.base_diagram.DiagramBase
::: src.drawpyo.diagram.base_diagram.DiagramBase
2 changes: 1 addition & 1 deletion docs/api/edges.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Edges

::: drawpyo.diagram.edges.Edge
::: src.drawpyo.diagram.edges.Edge
options:
show_root_heading: true
2 changes: 1 addition & 1 deletion docs/api/file.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# File

::: drawpyo.file.File
::: src.drawpyo.file.File
options:
show_root_heading: true
6 changes: 3 additions & 3 deletions docs/api/objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@

### object_from_library

::: drawpyo.diagram.objects.object_from_library
::: src.drawpyo.diagram.objects.object_from_library
options:
show_root_heading: true

-----
## Object

::: drawpyo.diagram.objects.Object
::: src.drawpyo.diagram.objects.Object
options:
show_root_heading: true

-----
## Group

::: drawpyo.diagram.objects.Group
::: src.drawpyo.diagram.objects.Group
options:
show_root_heading: true
2 changes: 1 addition & 1 deletion docs/api/page.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Page

::: drawpyo.page.Page
::: src.drawpyo.page.Page
options:
show_root_heading: true
6 changes: 6 additions & 0 deletions docs/api/text_format.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Text Format

## TextFormat
::: src.drawpyo.diagram.text_format.TextFormat
options:
show_root_heading: true
2 changes: 1 addition & 1 deletion docs/api/tree_diagram/nodeobject.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# NodeObject

::: drawpyo.diagram_types.tree.NodeObject
::: src.drawpyo.diagram_types.tree.NodeObject
options:
show_root_heading: true
4 changes: 2 additions & 2 deletions docs/api/tree_diagram/treediagram.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# TreeDiagram

::: drawpyo.diagram_types.tree.TreeDiagram
::: src.drawpyo.diagram_types.tree.TreeDiagram
options:
show_root_heading: true

-----

# TreeGroup

::: drawpyo.diagram_types.tree.TreeGroup
::: src.drawpyo.diagram_types.tree.TreeGroup
options:
show_root_heading: true
72 changes: 61 additions & 11 deletions docs/usage/edges.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,82 @@ link = drawpyo.diagram.Edge(
)
```

## Edge Labels

The value of an edge is the label that appears on it. It can be set using the `label` value.

The position of the label can be fine tuned with two parameters:

| Parameter | Effect |
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `label_position` | The position along the edge's axis where the label appears. This is float value between -1 and 1. 0 is neutral/in the center, -1 is at the source, and 1 is at the target. |
| `label_offset` | The offset in pixels perpendicular to the axis of the edge. |

## Edge Geometry

Besides the source and target, the edge geometry can be very finely tuned. There are eight parameters that control where and how the edge meets the source and target objects:

| Parameter | Definition |
| --------- | -------------------------------------------------------------------------- |
| `entryX` | From where along the X axis on the source object the edge originates (0-1) |
| `entryY` | From where along the Y axis on the source object the edge originates (0-1) |
| `entryDx` | Applies an offset in pixels to the X axis entry point |
| `entryDy` | Applies an offset in pixels to the Y axis entry point |
| `exitX` | From where along the X axis on the target object the edge originates (0-1) |
| `exitY` | From where along the Y axis on the target object the edge originates (0-1) |
| `exitDx` | Applies an offset in pixels to the X axis exit point |
| `exitDy` | Applies an offset in pixels to the Y axis exit point |
| Parameter | Definition |
| ------------------------ | --------------------------------------------------------------------------------- |
| `entryX` | From where along the X axis on the source object the edge originates (0-1) |
| `entryY` | From where along the Y axis on the source object the edge originates (0-1) |
| `entryDx` | Applies an offset in pixels to the X axis entry point |
| `entryDy` | Applies an offset in pixels to the Y axis entry point |
| `exitX` | From where along the X axis on the target object the edge originates (0-1) |
| `exitY` | From where along the Y axis on the target object the edge originates (0-1) |
| `exitDx` | Applies an offset in pixels to the X axis exit point |
| `exitDy` | Applies an offset in pixels to the Y axis exit point |
| `targetPerimeterSpacing` | The negative or positive spacing between the target and end of the edge in points |
| `sourcePerimeterSpacing` | The negative or positive spacing between the source and end of the edge in points |

If these parameters are set to `None` then the Draw.io rendering engine will place the origination and direction of the edge wherever makes the most sense based on the layout of the objects. This is the same as the behavior in the app when an edge is dragged to the center of a shape (highlighting the whole object green) instead of to a specific node on the border (and seeing just that node highlighted in green).

Other attributes for controlling the general shape of the object are:

| Parameter | Definition |
| ----------- | ------------------------------------------------------------------------------------------------------------ |
| `rounded` | Sets whether the corners of a line are set to sharp or rounded off (0-1) |
| `jettySize` | Defines the length of the straight line coming out of or into an object before the edge makes its first turn |

## Styling edges

Just about every edge styling option from the Draw.io app is implemented in Drawpyo. It's easiest to just play with all of the different line styling options in Draw.io to understand how they render but the major options are listed here.

### Text Styling

The styling within an an edge label is contained inside of a `TextFormat` object. All styling parameters can be accessed at the attribute `Edge.text_format`, which contains a `TextFormat` object.

For more information about styling text, see [Formatting Text](/drawpyo/usage/text_format) for mor information.

### Color and Shading

Edge coloring can be set with a stroke and fill color, though only the stroke applies to a simple edge.

| Parameter | Effect |
| ------------- | -------------------------------------------------------------------------------------------------- |
| `opacity` | The opacity of the edge (0-100) |
| `strokeColor` | The color of the edge or the stroke around the edge shape ('default', 'none', or a hex color code) |
| `fillColor` | The fill color of the edge shape ('default', 'none', or a hex color code) |

### Effects

Draw.io has four effects that can be set on an edge.

| Paramater | Effect |
| --------------- | ------------------------------------------------------------------------- |
| `rounded` | Sets whether the corners of a line are set to sharp or rounded off (bool) |
| `shadow` | Add a shadow to the edge (bool) |
| `sketch` | Renders the edge with a handsketch style (bool) |
| `flowAnimation` | Add a marching ants animation along the edge from source to target (bool) |

### Jumps

By default, when an edge crosses another edge they'll just be rendered as a cross. You can also enable line jumps; the top edge will 'jump' over the bottom edge. There are different styles of line jumps and they can have variable sizes as well.

| Parameter | Effect |
| ----------- | -------------------------------------------------------------------- |
| `jumpStyle` | The style of the line jump. Can be 'arc', 'gap', 'sharp', or 'line'. |
| `jumpSize` | The size of the rendered line jumps in points. |

### Waypoints

The `waypoint` parameter controls how the line is routed from the source to the target. For example, a straight line is just point to point. A curved line tries to maintain gentle curves and perpendicularity to the source and target objects. Options are:
Expand Down Expand Up @@ -86,6 +134,8 @@ The `pattern` parameter controls how the line stroke is rendered. Options are:

The `line_end_target` and `line_end_source` parameter sets whatever is rendered where the edge meets the objects. There are secondary boolean parameters for the fill of the ends (`endFill_target` and `endFill_source`) but not all ends can be filled.

The line end size can also be adjusted with `endSize` and `startSize` parameters, both set in points.

| Parameter | Rendered Unfilled | Rendered Filled |
| -------------- | ----------------- | --------------- |
| `classic` | | |
Expand Down
Loading

0 comments on commit 707c87f

Please sign in to comment.