View Javadoc
1   /******************************************************************************
2    * AnimateEventMove.java - Manage the dice move animation.
3    * $Id$
4    * 
5    * BuckoFIBS - Backgammon by BuckoSoft
6    * Copyright© 2011 - Dick Balaska - BuckoSoft, Corp.
7    * 
8    * $Log$
9    * Revision 1.3  2013/09/10 00:22:54  dick
10   * Spline2D and Flasher move MoveSpline2D and MoveFlasher
11   *
12   * Revision 1.2  2011/06/02 19:13:34  dick
13   * Need to define isGui().
14   *
15   * Revision 1.1  2011/05/22 22:56:09  dick
16   * c.b.f.B.g.boardTab.board becomes c.b.f.B.g.boardTab.boardPane .
17   *
18   * Revision 1.4  2011/05/17 22:50:04  dick
19   * AnimateEvent moves to c.b.f.B.g.b.b which is where it is used.
20   *
21   * Revision 1.3  2011/05/16 21:21:29  dick
22   * Add passthrues for getCheckerYOnBar() and getCheckerYInHome().
23   *
24   * Revision 1.2  2011/05/16 11:42:02  dick
25   * Offset moves to the base class.
26   *
27   * Revision 1.1  2011/05/15 02:17:54  dick
28   * Move the AnimateEvents to their own package.
29   *
30   * Revision 1.4  2011/05/13 18:25:46  dick
31   * Whitespace.
32   *
33   * Revision 1.3  2011/05/13 14:55:44  dick
34   * Javadoc.
35   *
36   * Revision 1.2  2011/05/13 14:25:09  dick
37   * Base class for the animation motion algorithms.
38   *
39   */
40  
41  /* 
42   * This program is free software: you can redistribute it and/or modify
43   * it under the terms of the GNU General Public License as published by
44   * the Free Software Foundation, either version 3 of the License, or
45   * (at your option) any later version.
46   *
47   * This program is distributed in the hope that it will be useful,
48   * but WITHOUT ANY WARRANTY; without even the implied warranty of
49   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
50   * GNU General Public License for more details.
51   *
52   * You should have received a copy of the GNU General Public License
53   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
54   *
55   * The Original Code is BuckoFIBS, <http://www.buckosoft.com/BuckoFIBS/>.
56   * The Initial Developer of the Original Code is Dick Balaska and BuckoSoft, Corp.
57   * 
58   */
59  package com.buckosoft.fibs.BuckoFIBS.gui.boardTab.boardPane;
60  
61  import java.awt.Color;
62  
63  import com.buckosoft.fibs.BuckoFIBS.gui.boardTab.boardPane.BoardPane.BoardSpecs;
64  import com.buckosoft.fibs.BuckoFIBS.gui.boardTab.boardPane.animateType.MoveFlasher;
65  import com.buckosoft.fibs.BuckoFIBS.gui.boardTab.boardPane.animateType.MoveSpline2D;
66  
67  
68  /** Run the dice move animation.
69   * @author Dick Balaska
70   * @since 2011/05/12
71   * @version $Revision$ <br> $Date$
72   * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/main/java/com/buckosoft/fibs/BuckoFIBS/gui/boardTab/boardPane/AnimateEventMove.java">cvs AnimateEventMove.java</a>
73   */
74  public abstract class AnimateEventMove extends AnimateEvent {
75  	/** Define an index that is a {@link MoveFlasher} */
76  	public final static int ANIMATE_FLASHER  = 0;
77  	/** Define an index that is a {@link MoveSpline2D} */
78  	public final static int ANIMATE_SPLINE2D = 1;
79  	
80  	protected double	x[] = new double[6];
81  	protected double	y[] = new double[6];
82  	
83  	protected	BoardPane		boardPane;
84  	public		BoardSpecs		bs;
85  	
86  	protected	int	pointNumberStart;
87  	protected	int	checkerNumberStart;
88  	protected	int	pointNumberEnd;
89  	protected	int	checkerNumberEnd;
90  	
91  	abstract public	void	calculate();
92  	abstract public int[]	getXY(double offset);
93  	abstract public	Color	getColor(double offset); 
94  
95  	@Override
96  	public Type getType() {
97  		return(Type.Move);
98  	}
99  
100 	/** Default 1000ms for a Move
101 	 */
102 	@Override
103 	public int getDuration() {
104 		return 1000;
105 	}
106 
107 	
108 	@Override
109 	public boolean isGui() {
110 		return false;
111 	}
112 
113 	public	void setBoardPane(BoardPane boardPane) {
114 		this.boardPane = boardPane;
115 		this.bs = boardPane.bs;
116 	}
117 
118 	public void setStartPointAndOffset(int pointNumber, int checkerNumber) {
119 		this.pointNumberStart = pointNumber;
120 		this.checkerNumberStart = checkerNumber;
121 	}
122 
123 	public void setEndPointAndOffset(int pointNumber, int checkerNumber) {
124 		this.pointNumberEnd = pointNumber;
125 		this.checkerNumberEnd = checkerNumber;
126 	}
127 
128 	protected int getPointX(int point) {
129 		return(boardPane.getPointX(point));
130 	}
131 	protected int getNthCheckerY(int point, int checker) {
132 		return(boardPane.getNthCheckerY(point, checker));
133 	}
134 	protected int getCheckerYOnBar(int who, int checker) {
135 		return(boardPane.getCheckerYOnBar(who, checker));
136 	}
137 	protected int getCheckerYInHome(int who, int checker) {
138 		return(boardPane.getCheckerYInHome(who, checker));
139 	}
140 }