summaryrefslogtreecommitdiff
path: root/src/attributes/output_mode.rs
diff options
context:
space:
mode:
authorseancarroll <seanc28@gmail.com>2021-01-06 21:11:57 -0600
committerseancarroll <seanc28@gmail.com>2021-01-06 21:11:57 -0600
commitc95ff86e2c8fbdd8e0cf6550aadc7ffc676dcc16 (patch)
treecfc0db9248e14f2ea675cf3b6dc67bf7243d1701 /src/attributes/output_mode.rs
parent0c8eb45449e578cae1f27e93df3f9cc92ba68219 (diff)
downloaddotavious-c95ff86e2c8fbdd8e0cf6550aadc7ffc676dcc16.zip
trying to organize files and use declarations
Diffstat (limited to 'src/attributes/output_mode.rs')
-rw-r--r--src/attributes/output_mode.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/attributes/output_mode.rs b/src/attributes/output_mode.rs
new file mode 100644
index 0000000..5a6ab45
--- /dev/null
+++ b/src/attributes/output_mode.rs
@@ -0,0 +1,29 @@
+use crate::dot::DotString;
+use std::borrow::Cow;
+
+/// These specify the order in which nodes and edges are drawn in concrete output.
+///
+/// The default "breadthfirst" is the simplest, but when the graph layout does not avoid edge-node
+/// overlap, this mode will sometimes have edges drawn over nodes and sometimes on top of nodes.
+///
+/// If the mode "nodesfirst" is chosen, all nodes are drawn first, followed by the edges.
+/// This guarantees an edge-node overlap will not be mistaken for an edge ending at a node.
+///
+/// On the other hand, usually for aesthetic reasons, it may be desirable that all edges appear
+/// beneath nodes, even if the resulting drawing is ambiguous.
+/// This can be achieved by choosing "edgesfirst".
+pub enum OutputMode {
+ BreadthFirst,
+ NodesFirst,
+ EdgesFirst,
+}
+
+impl<'a> DotString<'a> for OutputMode {
+ fn dot_string(&self) -> Cow<'a, str> {
+ match self {
+ OutputMode::BreadthFirst => "breadthfirst".into(),
+ OutputMode::NodesFirst => "nodesfirst".into(),
+ OutputMode::EdgesFirst => "edgesfirst".into(),
+ }
+ }
+}