View Javadoc

1   package erland.game.tetris;
2   /*
3    * Copyright (C) 2003 Erland Isaksson (erland_i@hotmail.com)
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, write to the Free Software
17   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18   *
19   */
20  
21  import java.awt.Color;
22  
23  /***
24   * Represents a container with squares, where each square may
25   * be (active/not active) and each square also has a colour
26   * @author Erland Isaksson
27   */
28  interface BlockMatrix
29  {
30  	/***
31  	 * Get the number of horisontal squares in the container
32  	 * @return Number of horisontal squares
33  	 */
34  	public int getWidth();
35  	
36  	/***
37  	 * Get the number of vertical squares in the container
38  	 * @return Number of vertical squares
39  	 */
40  	public int getHeight();
41  	
42  	/***
43  	 * Get the color of a specific square
44  	 * @param x The x position of the square
45  	 * @param y The y position of the square
46  	 * @return The color of the square, Color.black if it is outside the container
47  	 */
48  	public Color getColor(int x, int y);
49  	
50  	/***
51  	 * Checks if a specific square is active or not
52  	 * @param x The x position of the square
53  	 * @param y The y position of the square
54  	 * @return true/false (active/not active)
55  	 */
56  	public boolean isUsed(int x, int y); 
57  	
58  	/***
59  	 * Change the state to active for a specific square
60  	 * @param x The x position of the square
61  	 * @param y The y position of the square
62  	 * @param c The colour of the square
63  	 */
64  	public void setUsed(int x, int y, Color c);
65  	
66  	/***
67  	 * Change the state to not active for a specific square
68  	 * @param x The x position of the square
69  	 * @param y The y position of the square
70  	 */
71  	public void setUnused(int x, int y);
72  }