Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
AnimateEvent |
|
| 1.0;1 | ||||
AnimateEvent$Type |
|
| 1.0;1 |
1 | /****************************************************************************** | |
2 | * AnimateEvent.java - Base class for the animate events. | |
3 | * $Id$ | |
4 | * | |
5 | * BuckoFIBS - Backgammon by BuckoSoft | |
6 | * Copyright© 2011 - Dick Balaska - BuckoSoft, Corp. | |
7 | * | |
8 | * $Log$ | |
9 | * Revision 1.7 2011/07/16 02:43:45 dick | |
10 | * Add the Double type. | |
11 | * | |
12 | * Revision 1.6 2011/07/04 03:39:31 dick | |
13 | * Add FirstRoll. | |
14 | * | |
15 | * Revision 1.5 2011/06/18 19:31:15 dick | |
16 | * spelling | |
17 | * | |
18 | * Revision 1.4 2011/06/05 06:54:02 dick | |
19 | * Define AcceptAndWin. | |
20 | * | |
21 | * Revision 1.3 2011/06/02 19:12:34 dick | |
22 | * isGui() says that this event requires user interaction. (accept/decline, etc). | |
23 | * Deal with resign events. | |
24 | * | |
25 | * Revision 1.2 2011/05/31 19:45:37 dick | |
26 | * Javadoc. | |
27 | * | |
28 | * Revision 1.1 2011/05/22 22:56:08 dick | |
29 | * c.b.f.B.g.boardTab.board becomes c.b.f.B.g.boardTab.boardPane . | |
30 | * | |
31 | * Revision 1.4 2011/05/22 05:21:48 dick | |
32 | * Add Type.PleaseAcceptOrRejectDouble. | |
33 | * | |
34 | * Revision 1.3 2011/05/21 06:09:25 dick | |
35 | * Javadoc. | |
36 | * | |
37 | * Revision 1.2 2011/05/21 05:03:34 dick | |
38 | * Add GUI support, PleaseRollOrDouble and PleaseMove. | |
39 | * | |
40 | * Revision 1.1 2011/05/17 22:50:04 dick | |
41 | * AnimateEvent moves to c.b.f.B.g.b.b which is where it is used. | |
42 | * | |
43 | * Revision 1.6 2011/05/16 22:04:13 dick | |
44 | * More Javadoc tests (can we get to Board.X). | |
45 | * | |
46 | * Revision 1.5 2011/05/16 21:45:05 dick | |
47 | * Javadoc test. | |
48 | * | |
49 | * Revision 1.4 2011/05/16 21:37:39 dick | |
50 | * Javadoc. | |
51 | * | |
52 | * Revision 1.3 2011/05/16 14:17:30 dick | |
53 | * Add Type.CantMove. | |
54 | * | |
55 | * Revision 1.2 2011/05/16 11:36:24 dick | |
56 | * offset manages position in an animation. | |
57 | * who manages direction of the animation. | |
58 | * | |
59 | * Revision 1.1 2011/05/15 02:17:34 dick | |
60 | * c.b.f.B.gui.board becomes c.b.f.B.gui.boardTab. | |
61 | * | |
62 | * Revision 1.2 2011/05/13 17:16:17 dick | |
63 | * Fix enum cvs location. | |
64 | * | |
65 | * Revision 1.1 2011/05/13 14:55:30 dick | |
66 | * Base class for the animation events. | |
67 | * | |
68 | */ | |
69 | ||
70 | /* | |
71 | * This program is free software: you can redistribute it and/or modify | |
72 | * it under the terms of the GNU General Public License as published by | |
73 | * the Free Software Foundation, either version 3 of the License, or | |
74 | * (at your option) any later version. | |
75 | * | |
76 | * This program is distributed in the hope that it will be useful, | |
77 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
78 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
79 | * GNU General Public License for more details. | |
80 | * | |
81 | * You should have received a copy of the GNU General Public License | |
82 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
83 | * | |
84 | * The Original Code is BuckoFIBS, <http://www.buckosoft.com/BuckoFIBS/>. | |
85 | * The Initial Developer of the Original Code is Dick Balaska and BuckoSoft, Corp. | |
86 | * | |
87 | */ | |
88 | package com.buckosoft.fibs.BuckoFIBS.gui.boardTab.boardPane; | |
89 | ||
90 | /** Abstract Base Class for the animation events. | |
91 | * @author Dick Balaska | |
92 | * @since 2011/05/12 | |
93 | * @version $Revision$ <br> $Date$ | |
94 | * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/main/java/com/buckosoft/fibs/BuckoFIBS/gui/boardTab/boardPane/AnimateEvent.java">cvs AnimateEvent.java</a> | |
95 | */ | |
96 | public abstract class AnimateEvent { | |
97 | /** 0 -> 1 offset into the animation */ | |
98 | 0 | protected double offset = 0; |
99 | /** Board.X or Board.O */ | |
100 | protected int who; | |
101 | ||
102 | /** A game event type. | |
103 | * Events get Listed in GameManager and Type tells the different kinds apart. | |
104 | * @author Dick Balaska | |
105 | * @since 2011/05/11 | |
106 | * @version $Revision$ <br> $Date$ | |
107 | * @see com.buckosoft.fibs.BuckoFIBS.GameManager | |
108 | * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/main/java/com/buckosoft/fibs/BuckoFIBS/gui/boardTab/board/AnimateEvent.java">cvs GameEvent.java</a> | |
109 | */ | |
110 | 0 | public enum Type { |
111 | /** Board state. */ | |
112 | 0 | Board, |
113 | /** Move these pieces to their new positions */ | |
114 | 0 | Move, |
115 | /** Player rolled these dice */ | |
116 | 0 | Roll, |
117 | /** Player can't move based on the last roll of the dice */ | |
118 | 0 | CantMove, |
119 | /** Player wants to resign */ | |
120 | 0 | Resign, |
121 | /** GUI should ask the player to either Roll or Double */ | |
122 | 0 | PleaseRollOrDouble, |
123 | /** GUI should ask the player to move n number of pieces */ | |
124 | 0 | PleaseMove, |
125 | /** You Double */ | |
126 | 0 | Double, |
127 | /** GUI should ask the player to accept or reject the double */ | |
128 | 0 | PleaseAcceptOrRejectDouble, |
129 | /** GUI should ask the player to accept or reject the resign */ | |
130 | 0 | PleaseAcceptOrRejectResign, |
131 | /** Player rejected the resign offer */ | |
132 | 0 | RejectResign, |
133 | /** Player accepted the resign offer */ | |
134 | 0 | AcceptAndWin, |
135 | /** First roll of the game */ | |
136 | 0 | FirstRoll, |
137 | } | |
138 | ||
139 | /** Do not instantiate. Must subclass */ | |
140 | 0 | protected AnimateEvent() {} |
141 | ||
142 | /** Get the {@link Type} of this AnimateEvent | |
143 | * @return The Type of this AnimateEvent | |
144 | */ | |
145 | public abstract Type getType(); | |
146 | ||
147 | /** Is this a Gui event? That is, is the game waiting for user input? | |
148 | * @return true if this event needs user input | |
149 | */ | |
150 | public abstract boolean isGui(); | |
151 | ||
152 | /** Get the number of milliseconds to execute this AnimateEvent | |
153 | * @return The time it takes to execute this event | |
154 | */ | |
155 | public abstract int getDuration(); | |
156 | ||
157 | ||
158 | /** Set how far along the animation we are (0.0 -> 1.0) | |
159 | * @param offset the offset to set | |
160 | */ | |
161 | public void setOffset(double offset) { | |
162 | 0 | this.offset = offset; |
163 | 0 | } |
164 | ||
165 | /** Get how far along the animation we are (0.0 -> 1.0) | |
166 | * @return the offset | |
167 | */ | |
168 | public double getOffset() { | |
169 | 0 | return offset; |
170 | } | |
171 | ||
172 | /** Who's event is this? | |
173 | * @param xo Either Board.X or Board.O | |
174 | */ | |
175 | public void setWho(int xo) { | |
176 | 0 | this.who = xo; |
177 | 0 | } |
178 | ||
179 | /** Whose event is this? | |
180 | * @return Either Board.X or Board.O | |
181 | */ | |
182 | public int getWho() { | |
183 | 0 | return(this.who); |
184 | } | |
185 | } |