View Javadoc

1   /*
2    * AI Soccer Project - network gaming environment for AI warriors.
3    * Copyright (C) 2001-2004  Marcin Werla, Pawel Widera
4    *
5    * This program is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU General Public License
7    * as published by the Free Software Foundation; either version 2
8    * of the License, or (at your option) any later version.
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License
16   * along with this program; if not, you can find it here:
17   * http://www.gnu.org/licenses/gpl.html
18   */
19  
20  package aigames.soccer.field;
21  
22  
23  /***
24   * @version $Id: FieldPoint.java,v 1.6 2004/05/08 21:55:25 mwerla Exp $
25   */
26  public class FieldPoint {
27      /*** There is no edge */
28      public static final int NO_EDGE = -2;
29  
30      /*** The edge is field edge */
31      public static final int FIELD_EDGE = -1;
32  
33      /*** The edge is blank edge */
34      public static final int BLANK_EDGE = 0;
35      private int[] edges;
36  
37      /***
38       * Constructor which creates point with given edges.
39       * @param edges The edges to set.
40       */
41      public FieldPoint(int[] edges) {
42          this.edges = new int[4];
43  
44          for (int i = 0; i < edges.length; i++) {
45              this.edges[i] = edges[i];
46          }
47      }
48  
49      /***
50       * Default constructor which creates point without edges.
51       */
52      public FieldPoint() {
53          edges = new int[] { NO_EDGE, NO_EDGE, NO_EDGE, NO_EDGE };
54      }
55  
56      /***
57       * Sets color of na edge.
58       * @param edgeNumber Edge to set color.
59       * @param color Color to set.
60       */
61      public void setEdgeColor(Integer edgeNumber, int color) {
62          setEdgeColor(edgeNumber.intValue(), color);
63      }
64  
65      /***
66       * Sets color of na edge.
67       * @param edgeNumber Edge to set color.
68       * @param color Color to set.
69       */
70      public void setEdgeColor(int edgeNumber, int color) {
71          edges[edgeNumber - 1] = color;
72      }
73  
74      /***
75       * Returns edge color for a given edge.
76       * @param edgeNumber Number of edge to check.
77       * @return Edge color.
78       */
79      public int getEdgeColor(int edgeNumber) {
80          return edges[edgeNumber - 1];
81      }
82  }