View Javadoc
1   package com.jed.actor;
2   
3   import com.jed.core.Displayable;
4   import com.jed.util.Vector2f;
5   import org.colapietro.lang.LangConstants;
6   import org.colapietro.lang.NotImplementedException;
7   import org.slf4j.Logger;
8   import org.slf4j.LoggerFactory;
9   
10  import javax.annotation.Nonnull;
11  
12  /**
13   * Abstract class who associates another {@link com.jed.actor.AbstractEntity} as an "owner." The owner's
14   * boundary is defined by a subclass of {@link com.jed.actor.Boundary}'s implementation.
15   * 
16   * @author jlinde, Peter Colapietro
17   * @since 0.1.0
18   *
19   * @see com.jed.core.Displayable
20   *
21   */
22  public abstract class Boundary implements Displayable {
23  
24      /**
25       *
26       */
27      private static final Logger LOGGER = LoggerFactory.getLogger(Boundary.class);
28  
29      /**
30       * 
31       */
32      private AbstractEntity owner;
33      
34      /**
35       * 
36       */
37      private final Vector2f position;
38      
39      /**
40       * 
41       */
42      public final Vector2f[] vertices;
43  
44      /**
45       * 
46       * @return right bound.
47       */
48      public abstract double getRightBound();
49  
50      /**
51       * 
52       * @return left bound.
53       */
54      public abstract double getLeftBound();
55  
56      /**
57       * 
58       * @return upper bound.
59       */
60      public abstract double getUpperBound();
61  
62      /**
63       * 
64       * @return lower bound.
65       */
66      public abstract double getLowerBound();
67  
68      /**
69       * 
70       * @return width.
71       */
72      public abstract int getWidth();
73  
74      /**
75       * 
76       * @return height.
77       */
78      public abstract int getHeight();
79  
80      /**
81       * 
82       * @param position position.
83       * @param vertices vertices.
84       */
85      Boundary(Vector2f position, Vector2f[] vertices) {
86          this.vertices = vertices;
87          this.position = position;
88      }
89  
90      /**
91       * 
92       * @return world position.
93       */
94      @Nonnull
95      public Vector2f getWorldPosition() {
96          return owner.getPosition().add(position);
97      }
98  
99      /**
100      * 
101      * @return next world position.
102      */
103     @Nonnull
104     public Vector2f getNextWorldPosition() {
105         return getWorldPosition().add(owner.getMovement());
106     }
107 
108     /**
109      *
110      * @return position
111      */
112     public Vector2f getPosition() {
113         return position;
114     }
115 
116     /**
117      *
118      * @return owner
119      */
120     public AbstractEntity getOwner() {
121         return owner;
122     }
123 
124     /**
125      *
126      * @param owner owner
127      */
128     public void setOwner(AbstractEntity owner) {
129         this.owner = owner;
130     }
131 
132     @Override
133     public void render() throws NotImplementedException {
134         throw new NotImplementedException(LangConstants.NOT_IMPLEMENTED_YET_MESSAGE);
135     }
136 
137     @Override
138     public void drawChildVertex2f(float x, float y) throws NotImplementedException {
139         throw new NotImplementedException(LangConstants.NOT_IMPLEMENTED_YET_MESSAGE);
140     }
141 }