View Javadoc
1   /*
2    * The coLAB project
3    * Copyright (C) 2022-2023 AlbaSim, MEI, HEIG-VD, HES-SO
4    *
5    * Licensed under the MIT License
6    */
7   package ch.colabproject.colab.api.controller.card.grid;
8   
9   import ch.colabproject.colab.generator.model.annotations.ExtractJavaDoc;
10  import javax.validation.constraints.NotNull;
11  
12  /**
13   * Simple grid cell implementation
14   *
15   * @author maxence
16   */
17  @ExtractJavaDoc
18  public class GridPosition implements GridCell {
19  
20      /**
21       * The x coordinate of the card within its parent
22       */
23      @NotNull
24      private Integer x;
25  
26      /**
27       * The y coordinate of the card within its parent
28       */
29      @NotNull
30      private Integer y;
31  
32      /**
33       * The width of the card within its parent
34       */
35      @NotNull
36      private Integer width;
37  
38      /**
39       * The height of the card within its parent
40       */
41      @NotNull
42      private Integer height;
43  
44      /**
45       * Build a default grid position, Cell size is 1x1 and position is (1,1).
46       */
47      public GridPosition() {
48          this.x = 1;
49          this.y = 1;
50          this.width = 1;
51          this.height = 1;
52      }
53  
54      /**
55       * Build a cell
56       *
57       * @param x      x coord
58       * @param y      y coord
59       * @param width  width
60       * @param height height
61       */
62      public GridPosition(Integer x, Integer y, Integer width, Integer height) {
63          this.x = x;
64          this.y = y;
65          this.width = width;
66          this.height = height;
67      }
68  
69      @Override
70      public Integer getX() {
71          return x;
72      }
73  
74      @Override
75      public void setX(Integer x) {
76          this.x = x;
77      }
78  
79      @Override
80      public Integer getY() {
81          return y;
82      }
83  
84      @Override
85      public void setY(Integer y) {
86          this.y = y;
87      }
88  
89      @Override
90      public Integer getWidth() {
91          return width;
92      }
93  
94      @Override
95      public void setWidth(Integer width) {
96          this.width = width;
97      }
98  
99      @Override
100     public Integer getHeight() {
101         return height;
102     }
103 
104     @Override
105     public void setHeight(Integer height) {
106         this.height = height;
107     }
108 }