1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
use crate::Dimensions;
use mcai_types::Coordinates;
#[derive(Clone, Debug)]
pub struct GraphConfiguration {
node: NodeConfiguration,
}
impl GraphConfiguration {
pub fn new(node: NodeConfiguration) -> Self {
Self { node }
}
pub fn node_configuration(&self) -> &NodeConfiguration {
&self.node
}
}
#[derive(Clone, Debug, PartialEq)]
pub struct NodeConfiguration {
width: usize,
height: usize,
x_gap: usize,
y_gap: usize,
}
impl NodeConfiguration {
pub fn new(width: usize, height: usize, x_gap: usize, y_gap: usize) -> Self {
Self {
width,
height,
x_gap,
y_gap,
}
}
pub fn width(&self) -> usize {
self.width
}
pub fn height(&self) -> usize {
self.height
}
pub fn x_gap(&self) -> usize {
self.x_gap
}
pub fn y_gap(&self) -> usize {
self.y_gap
}
pub fn get_dimensions(&self) -> Dimensions {
Dimensions::new(self.width, self.height)
}
pub fn get_coordinates(&self, row: isize, column: isize) -> Coordinates {
let x = column * (self.width + self.x_gap) as isize;
let y = row * (self.height + self.y_gap) as isize;
Coordinates::new(x, y)
}
}