Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
BoardTab |
|
| 1.6;1.6 |
1 | /****************************************************************************** | |
2 | * BoardTab.java - The board as it appears under the "Board Tab" of the main dialog. | |
3 | * $Id$ | |
4 | * | |
5 | * BuckoFIBS - Backgammon by BuckoSoft | |
6 | * Copyright© 2009,2010 - Dick Balaska - BuckoSoft, Corp. | |
7 | * | |
8 | * $Log$ | |
9 | * Revision 1.4 2011/06/10 20:37:11 dick | |
10 | * yourMove() is not public anymore as it only comes from the AnimateManager. | |
11 | * | |
12 | * Revision 1.3 2011/05/31 19:45:15 dick | |
13 | * Javadoc. | |
14 | * | |
15 | * Revision 1.2 2011/05/21 05:02:10 dick | |
16 | * BoardGui doesn't want the document? | |
17 | * | |
18 | * Revision 1.1 2011/05/15 02:17:33 dick | |
19 | * c.b.f.B.gui.board becomes c.b.f.B.gui.boardTab. | |
20 | * | |
21 | * Revision 1.7 2011/05/14 04:43:01 dick | |
22 | * I needed to deal with some lightweight Boards. | |
23 | * So finally make the primary document Document | |
24 | * and demote just the Board handling to a domain object. | |
25 | * | |
26 | * Revision 1.6 2011/05/13 14:56:15 dick | |
27 | * Add support for animating checkers on the board. | |
28 | * | |
29 | * Revision 1.5 2010/12/31 05:30:11 dick | |
30 | * cvsweb loc has changed. | |
31 | * | |
32 | * Revision 1.4 2010/12/22 04:37:45 dick | |
33 | * matchStatusPanel now needs a reference to the mainDialog. | |
34 | * | |
35 | * Revision 1.3 2010/03/03 13:12:21 inim | |
36 | * Replaced (c) sign in comment mangled by CVS default encoding back to UTF-8 | |
37 | * | |
38 | * Revision 1.2 2010/03/03 12:19:49 inim | |
39 | * 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. | |
40 | * | |
41 | * Revision 1.1 2010/02/04 05:57:53 inim | |
42 | * Mavenized project folder layout | |
43 | * | |
44 | * Revision 1.7 2009/02/14 15:24:21 dick | |
45 | * BuckoFIBS is released under the GNU license. | |
46 | * Javadoc. | |
47 | * | |
48 | * Revision 1.6 2009/02/09 22:42:36 dick | |
49 | * getBoardGui() is public. | |
50 | * | |
51 | * Revision 1.5 2009/02/05 06:00:54 dick | |
52 | * getGameToolBar needs to be public. | |
53 | * | |
54 | * Revision 1.4 2009/01/31 08:50:43 dick | |
55 | * yourMove(int) takes the number of checkers to move. | |
56 | * | |
57 | * Revision 1.3 2009/01/31 06:06:10 dick | |
58 | * Move the local toolbar foo to GameToolbar. | |
59 | * | |
60 | * Revision 1.2 2009/01/28 22:10:17 dick | |
61 | * Add the ReplayToolbar. | |
62 | * | |
63 | * Revision 1.1 2009/01/28 19:37:28 dick | |
64 | * package com.buckosoft.fibs.gui.board becomes com.buckosoft.fibs.BuckoFIBS.gui.board. | |
65 | * | |
66 | * Revision 1.4 2009/01/24 17:07:41 dick | |
67 | * Add the "game" toolbar. | |
68 | * | |
69 | * Revision 1.3 2009/01/22 05:05:01 dick | |
70 | * yourMove() doesn't need an argument. | |
71 | * | |
72 | * Revision 1.2 2009/01/18 05:06:56 dick | |
73 | * the BoardPanel child becomes a BoardGui. | |
74 | * | |
75 | * Revision 1.1 2009/01/08 18:31:51 dick | |
76 | * The board as it appears under the "Board Tab" of the main dialog. | |
77 | */ | |
78 | ||
79 | /* | |
80 | * This program is free software: you can redistribute it and/or modify | |
81 | * it under the terms of the GNU General Public License as published by | |
82 | * the Free Software Foundation, either version 3 of the License, or | |
83 | * (at your option) any later version. | |
84 | * | |
85 | * This program is distributed in the hope that it will be useful, | |
86 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
87 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
88 | * GNU General Public License for more details. | |
89 | * | |
90 | * You should have received a copy of the GNU General Public License | |
91 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
92 | * | |
93 | * The Original Code is BuckoFIBS, <http://www.buckosoft.com/BuckoFIBS/>. | |
94 | * The Initial Developer of the Original Code is Dick Balaska and BuckoSoft, Corp. | |
95 | * | |
96 | */ | |
97 | package com.buckosoft.fibs.BuckoFIBS.gui.boardTab; | |
98 | ||
99 | import java.awt.Dimension; | |
100 | import java.awt.GridBagConstraints; | |
101 | import java.awt.GridBagLayout; | |
102 | ||
103 | import javax.swing.JPanel; | |
104 | ||
105 | import com.buckosoft.fibs.BuckoFIBS.CommandDispatcher; | |
106 | import com.buckosoft.fibs.document.Document; | |
107 | import com.buckosoft.fibs.domain.Board; | |
108 | ||
109 | /** The board as it appears under the "Board Tab" of the main dialog. | |
110 | * @author Dick Balaska | |
111 | * @since 2009/01/08 | |
112 | * @version $Revision$ <br> $Date$ | |
113 | * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/main/java/com/buckosoft/fibs/BuckoFIBS/gui/board/BoardTab.java">cvs BoardTab.java</a> | |
114 | */ | |
115 | public class BoardTab extends JPanel { | |
116 | private static final long serialVersionUID = 1L; | |
117 | 0 | private MatchStatusPanel matchStatusPanel = null; |
118 | 0 | private BoardGui boardGui = null; |
119 | 0 | private Document document = new Document(); |
120 | //private Board board = new Board(); // @jve:decl-index=0: | |
121 | 0 | private GameToolbar gameToolbar = null; |
122 | 0 | private ReplayToolbar replayToolbar = null; |
123 | ||
124 | /** Create and initialize a BoardTab | |
125 | */ | |
126 | public BoardTab() { | |
127 | 0 | super(); |
128 | 0 | initialize(); |
129 | 0 | } |
130 | ||
131 | /** Set the reference to our Board | |
132 | * @param document Reference to our document | |
133 | */ | |
134 | public void setDocument(Document document) { | |
135 | 0 | this.document = document; |
136 | //this.board = document.getBoard(); | |
137 | //if (boardGui != null) | |
138 | // boardGui.setDocument(document); | |
139 | 0 | if (this.matchStatusPanel != null) |
140 | 0 | this.matchStatusPanel.setDocument(document); |
141 | 0 | } |
142 | ||
143 | /** Update the board in the matchStatusPanel | |
144 | * @param board The board to display (scores, names, and pip-counts) | |
145 | */ | |
146 | public void setMatchStatusPanelBoard(Board board) { | |
147 | 0 | this.matchStatusPanel.setBoard(board); |
148 | 0 | } |
149 | ||
150 | /** Set the reference to the CommandDispatcher | |
151 | * @param commandDispatcher The application CommandDispatcher | |
152 | */ | |
153 | public void setCommandDispatcher(CommandDispatcher commandDispatcher) { | |
154 | 0 | this.boardGui.setCommandDispatcher(commandDispatcher); |
155 | 0 | this.replayToolbar.setToolbarHandler(commandDispatcher); |
156 | 0 | this.gameToolbar.setToolbarHandler(commandDispatcher); |
157 | 0 | this.matchStatusPanel.setMainDialog(commandDispatcher.getMainDialog()); |
158 | 0 | } |
159 | ||
160 | /** Repaint the board | |
161 | */ | |
162 | public void updateBoard() { | |
163 | 0 | this.boardGui.updateBoard(); |
164 | 0 | this.boardGui.repaint(); |
165 | 0 | if (this.matchStatusPanel != null) |
166 | 0 | this.matchStatusPanel.updateStatus(); |
167 | 0 | } |
168 | /** | |
169 | * This method initializes this | |
170 | * | |
171 | */ | |
172 | private void initialize() { | |
173 | 0 | GridBagConstraints gridBagConstraints12 = new GridBagConstraints(); |
174 | 0 | gridBagConstraints12.fill = GridBagConstraints.VERTICAL; |
175 | 0 | gridBagConstraints12.weightx = 1.0; |
176 | 0 | gridBagConstraints12.gridx = 1; |
177 | 0 | gridBagConstraints12.anchor = GridBagConstraints.EAST; |
178 | 0 | gridBagConstraints12.gridy = 0; |
179 | 0 | GridBagConstraints gridBagConstraints11 = new GridBagConstraints(); |
180 | 0 | gridBagConstraints11.fill = GridBagConstraints.VERTICAL; |
181 | 0 | gridBagConstraints11.weightx = 1.0; |
182 | 0 | gridBagConstraints11.gridx = 0; |
183 | 0 | gridBagConstraints11.gridy = 0; |
184 | 0 | gridBagConstraints11.anchor = GridBagConstraints.WEST; |
185 | 0 | GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
186 | 0 | gridBagConstraints.anchor = GridBagConstraints.NORTH; |
187 | 0 | gridBagConstraints.fill = GridBagConstraints.BOTH; |
188 | 0 | gridBagConstraints.weightx = 1.0; |
189 | 0 | gridBagConstraints.weighty = 0.2; |
190 | 0 | gridBagConstraints.gridx = 0; |
191 | 0 | gridBagConstraints.gridy = 1; |
192 | 0 | gridBagConstraints.gridwidth = 2; |
193 | 0 | GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
194 | 0 | gridBagConstraints1.weighty = 10.0; |
195 | 0 | gridBagConstraints1.weightx = 1.0; |
196 | 0 | gridBagConstraints1.gridx = 0; |
197 | 0 | gridBagConstraints1.gridy = 2; |
198 | 0 | gridBagConstraints1.fill = GridBagConstraints.BOTH; |
199 | 0 | gridBagConstraints1.gridwidth = 2; |
200 | 0 | gridBagConstraints1.anchor = GridBagConstraints.SOUTH; |
201 | 0 | this.setLayout(new GridBagLayout()); |
202 | 0 | this.setSize(new Dimension(450, 246)); |
203 | 0 | this.add(getMatchStatusPanel(), gridBagConstraints); |
204 | 0 | this.add(getBoardGui(), gridBagConstraints1); |
205 | 0 | this.add(getGameToolBar(), gridBagConstraints11); |
206 | 0 | this.add(getJToolBarReplay(), gridBagConstraints12); |
207 | ||
208 | 0 | } |
209 | ||
210 | /** | |
211 | * This method initializes matchStatusPanel | |
212 | * | |
213 | * @return javax.swing.JPanel | |
214 | */ | |
215 | private JPanel getMatchStatusPanel() { | |
216 | 0 | if (matchStatusPanel == null) { |
217 | 0 | matchStatusPanel = new MatchStatusPanel(); |
218 | 0 | matchStatusPanel.setDocument(document); |
219 | } | |
220 | 0 | return matchStatusPanel; |
221 | } | |
222 | ||
223 | /** Return a handle to the BoardGui | |
224 | * This method initializes boardGui | |
225 | * @return javax.swing.JPanel | |
226 | */ | |
227 | public BoardGui getBoardGui() { | |
228 | 0 | if (boardGui== null) { |
229 | 0 | boardGui = new BoardGui(); |
230 | //boardGui.setDocument(document); | |
231 | 0 | boardGui.setBoardTab(this); |
232 | } | |
233 | 0 | return boardGui; |
234 | } | |
235 | ||
236 | /** | |
237 | * This method initializes jToolBar | |
238 | * | |
239 | * @return javax.swing.JToolBar | |
240 | */ | |
241 | public GameToolbar getGameToolBar() { | |
242 | 0 | if (gameToolbar == null) { |
243 | 0 | gameToolbar = new GameToolbar(); |
244 | 0 | gameToolbar.setFloatable(false); |
245 | } | |
246 | 0 | return gameToolbar; |
247 | } | |
248 | ||
249 | /** | |
250 | * This method initializes jToolBarReplay | |
251 | * | |
252 | * @return javax.swing.JToolBar | |
253 | */ | |
254 | public ReplayToolbar getJToolBarReplay() { | |
255 | 0 | if (replayToolbar == null) { |
256 | 0 | replayToolbar = new ReplayToolbar(); |
257 | 0 | replayToolbar.setFloatable(false); |
258 | } | |
259 | 0 | return replayToolbar; |
260 | } | |
261 | ||
262 | } // @jve:decl-index=0:visual-constraint="6,11" |