View Javadoc
1   package com.jed.actor;
2   
3   import com.jed.util.Vector2f;
4   import org.slf4j.Logger;
5   import org.slf4j.LoggerFactory;
6   
7   /**
8    * Concrete implementation of {@link com.jed.actor.Boundary} which represents a circle.
9    * 
10   * @author jlinde, Peter Colapietro
11   * @since 0.1.0
12   *
13   * @see com.jed.actor.Boundary
14   */
15  public final class CircleBoundary extends Boundary {
16  
17      /**
18       *
19       */
20      private static final Logger LOGGER = LoggerFactory.getLogger(CircleBoundary.class);
21  
22  
23      /**
24       * Radius of the circle.
25       */
26      public int radius;
27  
28      /**
29       * 
30       * @param radius initial radius.
31       */
32      public CircleBoundary(final int radius) {
33          super(new Vector2f(0, 0), new Vector2f[]{});
34          this.radius = radius;
35      }
36  
37      /**
38       * 
39       * @return radius of circle boundary.
40       */
41      public int getRadius() {
42          return radius;
43      }
44  
45      /**
46       * 
47       * @param radius radius to set.
48       */
49      public void setRadius(final int radius) {
50          this.radius = radius;
51      }
52  
53      @Override
54      public double getRightBound() {
55          return getOwner().getPosition().x + radius;
56      }
57  
58      @Override
59      public double getLeftBound() {
60          return getOwner().getPosition().x - radius;
61      }
62  
63      @Override
64      public double getUpperBound() {
65          return getOwner().getPosition().y - radius;
66      }
67  
68      @Override
69      public double getLowerBound() {
70          return getOwner().getPosition().y + radius;
71      }
72  
73      @Override
74      public int getWidth() {
75          return radius * 2;
76      }
77  
78      @Override
79      public int getHeight() {
80          return getWidth();
81      }
82  
83      @Override
84      public void render() {
85          LOGGER.warn("{}","No OP com.jed.actor.CircleBoundary#render");
86      }
87  }