View Javadoc
1   /******************************************************************************
2    * BoardTest.java - Test backgammon board drawing
3    * $Id$
4    * 
5    * BuckoFIBS - Backgammon by BuckoSoft
6    * Copyright© 2009,2010 - Dick Balaska - BuckoSoft, Corp.
7    * 
8    * $Log$
9    * Revision 1.1  2013/09/08 08:59:03  dick
10   * Move tests to the same name as the testing package.
11   * (remove 'test' subpackage) so we can get at protected methods.
12   *
13   * Revision 1.8  2011/06/10 20:37:56  dick
14   * yourMove() is not public anymore as it only comes from the AnimateManager.
15   *
16   * Revision 1.7  2011/05/22 22:58:39  dick
17   * c.b.f.B.g.boardTab.board becomes c.b.f.B.g.boardTab.boardPane .
18   *
19   * Revision 1.6  2011/05/15 02:20:12  dick
20   * Move a whole bunch of packages around.
21   *
22   * Revision 1.5  2011/05/14 05:20:01  dick
23   * I needed to deal with some lightweight Boards.
24   * So finally make the primary document Document
25   * and demote just the Board handling to a domain object.
26   *
27   * Revision 1.4  2011/05/13 15:06:41  dick
28   * AnimateMove becomes Spline2D.
29   *
30   * Revision 1.3  2011/05/11 22:20:59  dick
31   * Testing animation
32   *
33   * Revision 1.2  2011/05/08 18:32:41  dick
34   * Annotate as Ignore so JUnit doesn't try to run this file.
35   *
36   * Revision 1.1  2011/05/07 15:11:29  dick
37   * Move BoardTest to the test system.
38   *
39   * Revision 1.1  2011/05/06 23:15:43  dick
40   * BoardTest moves to the test directory.
41   *
42   * Revision 1.6  2011/01/04 20:06:23  dick
43   * Playing with 3 column points.
44   *
45   * Revision 1.5  2010/12/30 04:09:22  dick
46   * test6 = 41 bearoff.  test7 = 55 bearoff.
47   *
48   * Revision 1.4  2010/12/29 07:50:05  dick
49   * Display the dice in grey as they are used up.
50   *
51   * Revision 1.3  2010/03/03 13:12:21  inim
52   * Replaced (c) sign in comment mangled by CVS default encoding back to UTF-8
53   *
54   * Revision 1.2  2010/03/03 12:19:49  inim
55   * Moved source to UTF8 encoding from CP1252 encoding. To this end all source files' (c) message was updated to "Copyright© 2009,2010 - Dick Balaska - BuckoSoft, Corp.". This replaces the (c) sign to UTF8, and adds the new year 2010.
56   *
57   * Revision 1.1  2010/02/04 05:57:53  inim
58   * Mavenized project folder layout
59   *
60   * Revision 1.5  2009/02/14 15:24:43  dick
61   * BuckoFIBS is released under the GNU license.
62   *
63   * Revision 1.4  2009/02/12 06:28:17  dick
64   * A bearing off test board.
65   *
66   * Revision 1.3  2009/02/06 07:56:49  dick
67   * Working on doubles.
68   *
69   * Revision 1.2  2009/01/31 08:50:54  dick
70   * yourMove(int) takes the number of checkers to move.
71   *
72   * Revision 1.1  2009/01/28 19:37:28  dick
73   * package com.buckosoft.fibs.gui.board becomes com.buckosoft.fibs.BuckoFIBS.gui.board.
74   *
75   * Revision 1.17  2009/01/28 08:31:14  dick
76   * Javadoc.
77   *
78   * Revision 1.16  2009/01/22 05:05:22  dick
79   * More test frameworks.
80   *
81   * Revision 1.15  2009/01/18 05:26:24  dick
82   * Javadoc.
83   *
84   * Revision 1.14  2009/01/18 05:07:30  dick
85   * BoardTest needs a BFProperties and a CommandDispatcher now.
86   *
87   * Revision 1.13  2009/01/10 05:06:39  dick
88   * development foo.
89   *
90   * Revision 1.12  2009/01/08 18:56:29  dick
91   * Use BoardTab instead of just BoardPane.
92   *
93   * Revision 1.11  2008/12/20 23:03:02  dick
94   * Add fibsBoard1 for testing.
95   *
96   * Revision 1.10  2008/12/16 20:08:35  dick
97   * Testing painting on the bar.
98   *
99   * Revision 1.9  2008/12/12 14:46:11  dick
100  * Update drawing to the new FIBS based board (based on points instead of checkers).
101  *
102  * Revision 1.8  2008/12/10 23:46:59  dick
103  * Drawing nice dice.
104  *
105  * Revision 1.7  2008/12/10 21:56:31  dick
106  * Dice testing.
107  *
108  * Revision 1.6  2008/12/09 19:38:32  dick
109  * Commentality.
110  *
111  * Revision 1.5  2008/12/08 10:17:35  dick
112  * Debugging stuff.
113  *
114  * Revision 1.4  2008/12/08 06:46:08  dick
115  * Initialize a Board and assign checker positions to it.
116  *
117  * Revision 1.3  2008/04/07 06:13:40  dick
118  * Use a bigger test board.
119  *
120  * Revision 1.2  2008/04/05 01:43:42  dick
121  * Commentality.
122  */
123 
124 /* 
125  * This program is free software: you can redistribute it and/or modify
126  * it under the terms of the GNU General Public License as published by
127  * the Free Software Foundation, either version 3 of the License, or
128  * (at your option) any later version.
129  *
130  * This program is distributed in the hope that it will be useful,
131  * but WITHOUT ANY WARRANTY; without even the implied warranty of
132  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
133  * GNU General Public License for more details.
134  *
135  * You should have received a copy of the GNU General Public License
136  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
137  *
138  * The Original Code is BuckoFIBS, <http://www.buckosoft.com/BuckoFIBS/>.
139  * The Initial Developer of the Original Code is Dick Balaska and BuckoSoft, Corp.
140  * 
141  */
142 package com.buckosoft.fibs.gui.board;
143 
144 import java.awt.BorderLayout;
145 
146 import javax.swing.JDialog;
147 import javax.swing.JPanel;
148 
149 import org.junit.Ignore;
150 
151 import com.buckosoft.fibs.BuckoFIBS.BFProperties;
152 import com.buckosoft.fibs.BuckoFIBS.CommandDispatcher;
153 import com.buckosoft.fibs.BuckoFIBS.gui.boardTab.BoardTab;
154 import com.buckosoft.fibs.BuckoFIBS.gui.boardTab.boardPane.animateType.MoveSpline2D;
155 import com.buckosoft.fibs.document.Document;
156 import com.buckosoft.fibs.domain.Board;
157 
158 /** Test backgammon board drawing
159  * @author Dick Balaska
160  * @since 2008/04/01
161  * @version $Revision$ <br> $Date$
162  * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/com/buckosoft/fibs/BuckoFIBS/gui/board/BoardTest.java">old cvs BoardTest.java</a>
163  * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/test/java/com/buckosoft/fibs/test/gui/board/BoardTest.java">new cvs BoardTest.java</a>
164  */
165 @Ignore
166 @SuppressWarnings("unused")
167 public class BoardTest extends JDialog {
168 	private static final long serialVersionUID = 1L;
169 
170 	BFProperties		properties;
171 	CommandDispatcher	commandDispatcher;
172 
173 	private JPanel 		jContentPane = null;
174 	//private BoardPane boardPane = null;
175 	private BoardTab 	boardTab = null;
176 	private	Document	document = new Document();
177 	private Board		board;
178 
179 	private	int[] checkerTest0 = new int[] { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,24,24,24,25};
180 	private	int[] checkerTest1 = new int[] { 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,25,25,25};
181 	// standard opening board
182 	private String fibsBoard = "board:You:someplayer:3:0:0:1:-2:0:0:0:0:5:0:3:0:0:0:-5:5:0:0:0:-3:0:-5:0:0:0:0:2:2:1:4:4:0:0:1:1:1:0:1:-1:0:25:0:0:0:0:2:0:0:0";
183 	private	String fibsBoard1 = "board:janana:daveyp:5:1:1:0:-2:0:0:0:-1:5:0:3:0:2:0:-4:3:-1:0:0:-2:0:-2:-1:-2:0:0:1:1:1:0:0:6:1:1:0:1:0:-1:1:25:0:0:0:0:1:2:6:0:0";
184 	// blotslot = 1 blitzxz = 0
185 	private	String fibsBoard2 = "board:blitzxz:blotsalot:5:0:1:0:0:2:-2:0:2:3:3:2:3:0:0:0:0:0:0:0:-1:-1:-3:-2:-2:-2:-2:0:0:-1:0:0:0:0:2:1:0:0:-1:1:25:0:0:0:0:0:2:3:0:0";
186 	// playing backwards
187 	private String fibsBoard3 = "board:You:JavaFIBS:5:0:0:0:-2:0:0:0:0:5:0:3:0:0:0:-5:5:0:0:0:-3:0:-5:0:0:0:0:2:0:-1:2:1:0:0:1:1:1:0:-1:1:25:0:0:0:0:0:2:0:0:0";
188 	private String fibsBoard4 = "board:You:someplayer:3:0:0:1:-2:0:0:0:0:5:0:3:0:0:0:-5:5:0:0:0:-3:0:-5:0:0:0:0:2:2:1:5:2:0:0:1:1:1:0:1:-1:0:25:0:0:0:0:2:0:0:0";
189 	// opponent has doubled
190 	private String fibsBoard5 = "board:You:JavaFIBS:6:0:0:0:-2:0:0:0:0:5:0:3:0:0:0:-11:6:0:0:0:-3:0:-5:0:0:0:0:2:0:-1:0:0:0:0:1:1:1:1:-1:1:25:0:0:0:0:0:2:0:0:0";
191 	private String fibsBoard6 = "board:You:JavaFIBS:6:0:0:0:-2:0:0:0:0:5:0:3:0:0:-9:-11:6:0:0:0:-3:0:-5:0:0:0:0:2:0:-1:0:0:0:0:1:1:1:0:-1:1:25:0:0:0:0:0:2:0:0:0";
192 	// bearing off
193 	private String fibsBoard7 = "board:You:dickbalaska:35:5:7:0:3:3:2:1:3:1:0:0:0:0:0:0:0:0:0:0:0:0:-4:-3:-2:-1:-3:-2:0:-1:1:4:0:0:1:1:1:0:-1:1:25:0:0:2:0:0:2:0:0:0";
194 	// bearing off w/55
195 	private String fibsBoard8 = "board:You:dickbalaska:35:5:7:0:3:3:2:1:3:1:0:0:0:0:0:0:0:0:0:0:0:0:-4:-3:-2:-1:-3:-2:0:-1:5:5:0:0:1:1:1:0:-1:1:25:0:0:2:0:0:2:0:0:0";
196 	
197 	MoveSpline2D am = new MoveSpline2D();
198 	
199 	/**
200 	 * This method initializes boardPanel	
201 	 * @return javax.swing.JPanel	
202 	 */
203 	private JPanel getBoardPanel() {
204 		if (boardTab == null) {
205 			boardTab = new BoardTab();
206 			boardTab.setCommandDispatcher(commandDispatcher);
207 			board.parseFibsBoard(fibsBoard);
208 //			board.setAcceptDeclineDouble();
209 //			board.setYourTurnToRollOrDouble(true);
210 //			board.setYouDouble(true);
211 			boardTab.setDocument(document);
212 //			boardTab.yourMove(4);
213 //			boardTab.getBoardGui().diceUsed[3] = true;
214 //			boardTab.getBoardGui().diceUsed[0] = true;
215 //			boardTab.getBoardGui().diceUsed[1] = true;
216 			boardTab.updateBoard();
217 			am.setBoardPane(boardTab.getBoardGui());
218 			am.setStartPointAndOffset(11, 0);
219 			am.setEndPointAndOffset(16, 2);
220 			am.calculate();
221 			// boardTab.getBoardGui().setAnimateMove(am);
222 		}
223 		return boardTab;
224 	}
225 
226 	/** Start the BoardTest
227 	 * @param args
228 	 */
229 	public static void main(String[] args) {
230 		javax.swing.SwingUtilities.invokeLater(new Runnable() {
231 			public void run() {
232 				BoardTest bt = new BoardTest();
233 				bt.setVisible(true);
234 			}
235 		});
236 	}
237 
238 	/** Default constructor
239 	 */
240 	public BoardTest() {
241 		super();
242 		this.properties = new BFProperties();
243 		this.board = document.getBoard();
244 		this.commandDispatcher = new BoardTestCommandDispatcher();
245 		this.commandDispatcher.setProperties(properties);
246 		initialize();
247 	}
248 
249 	/**
250 	 * This method initializes this
251 	 * 
252 	 * @return void
253 	 */
254 	private void initialize() {
255 		this.setSize(500, 400);
256 		this.setContentPane(getJContentPane());
257 		this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
258 	}
259 
260 	/**
261 	 * This method initializes jContentPane
262 	 * 
263 	 * @return javax.swing.JPanel
264 	 */
265 	private JPanel getJContentPane() {
266 		if (jContentPane == null) {
267 			jContentPane = new JPanel();
268 			jContentPane.setLayout(new BorderLayout());
269 			jContentPane.add(getBoardPanel(), BorderLayout.CENTER);
270 		}
271 		return jContentPane;
272 	}
273 
274 }