Skip to main content

libpetri_export/
styles.rs

1/// Node visual style.
2pub struct NodeVisual {
3    pub shape: &'static str,
4    pub fill: &'static str,
5    pub stroke: &'static str,
6    pub penwidth: f64,
7    pub style: Option<&'static str>,
8}
9
10/// Edge visual style.
11pub struct EdgeVisual {
12    pub color: &'static str,
13    pub style: &'static str,
14    pub penwidth: f64,
15    pub arrowhead: &'static str,
16}
17
18// Node styles (from spec/petri-net-styles.json)
19pub const PLACE: NodeVisual = NodeVisual {
20    shape: "circle",
21    fill: "#ffffff",
22    stroke: "#333333",
23    penwidth: 1.5,
24    style: None,
25};
26
27pub const START_PLACE: NodeVisual = NodeVisual {
28    shape: "circle",
29    fill: "#d4edda",
30    stroke: "#28a745",
31    penwidth: 2.0,
32    style: None,
33};
34
35pub const END_PLACE: NodeVisual = NodeVisual {
36    shape: "doublecircle",
37    fill: "#cce5ff",
38    stroke: "#007bff",
39    penwidth: 2.0,
40    style: None,
41};
42
43pub const ENVIRONMENT_PLACE: NodeVisual = NodeVisual {
44    shape: "circle",
45    fill: "#ffe6e6",
46    stroke: "#dc3545",
47    penwidth: 2.0,
48    style: Some("dashed"),
49};
50
51pub const TRANSITION: NodeVisual = NodeVisual {
52    shape: "box",
53    fill: "#fff3cd",
54    stroke: "#ffc107",
55    penwidth: 1.5,
56    style: None,
57};
58
59// Edge styles
60pub const INPUT_EDGE: EdgeVisual = EdgeVisual {
61    color: "#333333",
62    style: "solid",
63    penwidth: 1.0,
64    arrowhead: "normal",
65};
66
67pub const OUTPUT_EDGE: EdgeVisual = EdgeVisual {
68    color: "#333333",
69    style: "solid",
70    penwidth: 1.0,
71    arrowhead: "normal",
72};
73
74pub const INHIBITOR_EDGE: EdgeVisual = EdgeVisual {
75    color: "#dc3545",
76    style: "solid",
77    penwidth: 1.5,
78    arrowhead: "odot",
79};
80
81pub const READ_EDGE: EdgeVisual = EdgeVisual {
82    color: "#6c757d",
83    style: "dashed",
84    penwidth: 1.0,
85    arrowhead: "normal",
86};
87
88pub const RESET_EDGE: EdgeVisual = EdgeVisual {
89    color: "#fd7e14",
90    style: "bold",
91    penwidth: 2.0,
92    arrowhead: "normal",
93};
94
95// Font settings
96pub const FONT_FAMILY: &str = "Helvetica";
97pub const FONT_NODE_SIZE: f64 = 11.0;
98pub const FONT_EDGE_SIZE: f64 = 9.0;
99
100// Graph spacing
101pub const NODESEP: f64 = 0.5;
102pub const RANKSEP: f64 = 0.75;
103pub const FORCE_LABELS: &str = "true";
104pub const OVERLAP: &str = "false";