View Javadoc
1   /******************************************************************************
2    * Flasher.java - Flash between two checkers
3    * $Id$
4    * 
5    * BuckoFIBS - Backgammon by BuckoSoft
6    * Copyright© 2011 - Dick Balaska - BuckoSoft, Corp.
7    * 
8    * $Log$
9    * Revision 1.1  2011/05/22 22:56:09  dick
10   * c.b.f.B.g.boardTab.board becomes c.b.f.B.g.boardTab.boardPane .
11   *
12   * Revision 1.1  2011/05/15 02:14:12  dick
13   * gui.board.animator becomes gui.boardTab.board.animateType.
14   *
15   * Revision 1.1  2011/05/13 14:26:16  dick
16   * Flash between two checkers.
17   *
18   */
19  
20  /* 
21   * This program is free software: you can redistribute it and/or modify
22   * it under the terms of the GNU General Public License as published by
23   * the Free Software Foundation, either version 3 of the License, or
24   * (at your option) any later version.
25   *
26   * This program is distributed in the hope that it will be useful,
27   * but WITHOUT ANY WARRANTY; without even the implied warranty of
28   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29   * GNU General Public License for more details.
30   *
31   * You should have received a copy of the GNU General Public License
32   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
33   *
34   * The Original Code is BuckoFIBS, <http://www.buckosoft.com/BuckoFIBS/>.
35   * The Initial Developer of the Original Code is Dick Balaska and BuckoSoft, Corp.
36   * 
37   */
38  package com.buckosoft.fibs.BuckoFIBS.gui.boardTab.boardPane.animateType;
39  
40  import java.awt.Color;
41  
42  import com.buckosoft.fibs.BuckoFIBS.gui.boardTab.boardPane.AnimateEventMove;
43  
44  /** Flash between two checkers.
45   * @author Dick Balaska
46   * @since 2011/05/12
47   * @version $Revision$ <br> $Date$
48   * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/main/java/com/buckosoft/fibs/BuckoFIBS/gui/boardTab/boardPane/animateType/MoveFlasher.java">cvs MoveFlasher.java</a>
49   */
50  public class MoveFlasher extends AnimateEventMove {
51  	int[] start = new int[2];
52  	int[] end	= new int[2];
53  
54  	private	static 	Color	startColor = new Color(255,20,20,190);
55  	private	static 	Color	endColor = new Color(20,255,20,150);
56  
57  	/* (non-Javadoc)
58  	 * @see com.buckosoft.fibs.BuckoFIBS.gui.board.AnimateMove#calculate()
59  	 */
60  	@Override
61  	public void calculate() {		
62  		start[0] = getPointX(pointNumberStart)+bs.c2;
63  		start[1] = getNthCheckerY(pointNumberStart, checkerNumberStart)+bs.c2;
64  		end[0] = getPointX(pointNumberEnd)+bs.c2;
65  		end[1] = getNthCheckerY(pointNumberEnd, checkerNumberEnd)+bs.c2;
66  	}
67  
68  	/** Alternate displaying the start and end positions, 4 flashes per cycle (2 each checker)
69  	 * 0 -> 1 = start, end, start, end.
70  	 */
71  	@Override
72  	public int[] getXY(double offset) {
73  		offset *= 3;
74  		if (offset < 1.0 || (offset > 2.0 && offset < 3.0) || (offset > 4.0 && offset < 5.0)) {
75  			return(start);
76  		}
77  		return(end);
78  	}
79  
80  	/* (non-Javadoc)
81  	 * @see com.buckosoft.fibs.BuckoFIBS.gui.board.AnimateMove#getColor(double)
82  	 */
83  	@Override
84  	public Color getColor(double offset) {
85  		offset *= 2;
86  		if (offset < 1.0 || (offset > 2.0 && offset < 3.0) || (offset > 4.0 && offset < 5.0)) {
87  			return startColor;
88  		}
89  		return endColor;
90  	}
91  
92  	
93  }