View Javadoc
1   /******************************************************************************
2    * AnimateEventDouble - Run the double animation.
3    * $Id$
4    * 
5    * BuckoFIBS - Backgammon by BuckoSoft
6    * Copyright© 2011 - Dick Balaska - BuckoSoft, Corp.
7    * 
8    * $Log$
9    * Revision 1.2  2013/09/12 06:39:03  dick
10   * Animating the double cube.
11   *
12   * Revision 1.1  2011/07/16 03:51:20  dick
13   * Run the double animation.
14   *
15   */
16  
17  /* 
18   * This program is free software: you can redistribute it and/or modify
19   * it under the terms of the GNU General Public License as published by
20   * the Free Software Foundation, either version 3 of the License, or
21   * (at your option) any later version.
22   *
23   * This program is distributed in the hope that it will be useful,
24   * but WITHOUT ANY WARRANTY; without even the implied warranty of
25   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26   * GNU General Public License for more details.
27   *
28   * You should have received a copy of the GNU General Public License
29   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
30   *
31   * The Original Code is BuckoFIBS, <http://www.buckosoft.com/BuckoFIBS/>.
32   * The Initial Developer of the Original Code is Dick Balaska and BuckoSoft, Corp.
33   * 
34   */
35  package com.buckosoft.fibs.BuckoFIBS.gui.boardTab.boardPane;
36  
37  import java.awt.Point;
38  
39  import com.buckosoft.fibs.BuckoFIBS.gui.boardTab.boardPane.BoardPane.BoardSpecs;
40  import com.buckosoft.fibs.domain.Board;
41  
42  /** Run the double animation
43   * @author Dick Balaska
44   * @since 2011/07/14
45   * @version $Revision$ <br> $Date$
46   * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/main/java/com/buckosoft/fibs/BuckoFIBS/gui/boardTab/boardPane/AnimateEventDouble.java">cvs AnimateEventDouble.java</a>
47   */
48  public abstract class AnimateEventDouble extends AnimateEvent {
49  	protected	BoardPane		boardPane;
50  	public		BoardSpecs		bs;
51  	
52  	/** Spline coordinates in the base class so we can draw the markers for the blue debug spline outline */ 
53  	protected double	x[] = new double[6];
54  	protected double	y[] = new double[6];
55  	
56  	private		int	cubeBefore;
57  	private		int	cubeAfter;
58  	protected	int	whoDoubled;
59  
60  	abstract public	void	calculate(Board board);
61  	abstract public int[]	getXY(double offset);
62  
63  	@Override
64  	public int getDuration() {
65  		return 1500;
66  	}
67  
68  	@Override
69  	public Type getType() {
70  		return Type.Double;
71  	}
72  
73  	@Override
74  	public boolean isGui() {
75  		return false;
76  	}
77  
78  	public	void setBoardPane(BoardPane boardPane) {
79  		this.boardPane = boardPane;
80  		this.bs = boardPane.bs;
81  	}
82  
83  	/** Who doubled?
84  	 * @param xo {@link Board#X} or {@link Board#O}
85  	 */
86  	public void setWhoDoubled(int xo) {
87  		this.whoDoubled = xo;
88  	}
89  
90  	/** Who is doubling?
91  	 * @return {@link Board#X} or {@link Board#O}
92  	 */
93  	public int getWhoDoubled() {
94  		return(this.whoDoubled);
95  	}
96  
97  	/** Get the value of the cube before the double
98  	 * @return the cubeBefore
99  	 */
100 	public int getCubeBefore() {
101 		return cubeBefore;
102 	}
103 
104 	/** Set the current value of cube as well as the derived, next value of the cube (if accepted). 
105 	 * @param cubeBefore the value of the cube (from the last board) to set
106 	 */
107 	public void setCubeBefore(int cubeBefore) {
108 		this.cubeBefore = cubeBefore;
109 		this.cubeAfter = this.cubeBefore * 2;
110 		if (this.cubeAfter > 64)
111 			this.cubeAfter = 1;
112 	}
113 
114 	/** Get the value of the cube after the double
115 	 * @return the cubeAfter
116 	 */
117 	public int getCubeAfter() {
118 		return cubeAfter;
119 	}
120 
121 	protected Point getDoubleCubeXY() {
122 		return(boardPane.getDoubleCubeXY());
123 	}
124 	protected int getDoubleCubeWidth() {
125 		return(boardPane.getDoubleCubeWidth());
126 	}
127 	protected int getPointX(int point) {
128 		return(boardPane.getPointX(point));
129 	}
130 	protected int getNthCheckerY(int point, int checker) {
131 		return(boardPane.getNthCheckerY(point, checker));
132 	}
133 	protected Point getDoubleCubePushXY() {
134 		return(boardPane.getDoubleCubePushXY());
135 	}
136 
137 }