mcai_graph/
configuration.rs

1use crate::Dimensions;
2use mcai_types::Coordinates;
3
4#[derive(Clone, Debug)]
5pub struct GraphConfiguration {
6  node: NodeConfiguration,
7}
8
9impl GraphConfiguration {
10  pub fn new(node: NodeConfiguration) -> Self {
11    Self { node }
12  }
13
14  pub fn node_configuration(&self) -> &NodeConfiguration {
15    &self.node
16  }
17}
18
19#[derive(Clone, Debug, PartialEq)]
20pub struct NodeConfiguration {
21  width: usize,
22  height: usize,
23  x_gap: usize,
24  y_gap: usize,
25}
26
27impl NodeConfiguration {
28  pub fn new(width: usize, height: usize, x_gap: usize, y_gap: usize) -> Self {
29    Self {
30      width,
31      height,
32      x_gap,
33      y_gap,
34    }
35  }
36
37  pub fn width(&self) -> usize {
38    self.width
39  }
40
41  pub fn height(&self) -> usize {
42    self.height
43  }
44
45  pub fn x_gap(&self) -> usize {
46    self.x_gap
47  }
48
49  pub fn y_gap(&self) -> usize {
50    self.y_gap
51  }
52
53  pub fn get_dimensions(&self) -> Dimensions {
54    Dimensions::new(self.width, self.height)
55  }
56
57  pub fn get_coordinates(&self, row: isize, column: isize) -> Coordinates {
58    let x = column * (self.width + self.x_gap) as isize;
59    let y = row * (self.height + self.y_gap) as isize;
60
61    Coordinates::new(x, y)
62  }
63}