1 /****************************************************************************** 2 * DoubleSpline2D.java - Move the double cube along a spline path 3 * $Id$ 4 * 5 * BuckoFIBS - Backgammon by BuckoSoft 6 * Copyright© 2013 - Dick Balaska - BuckoSoft, Corp. 7 * 8 * $Log$ 9 * Revision 1.1 2013/09/12 06:40:07 dick 10 * Animating the double cube. 11 * 12 */ 13 14 /* 15 * This program is free software: you can redistribute it and/or modify 16 * it under the terms of the GNU General Public License as published by 17 * the Free Software Foundation, either version 3 of the License, or 18 * (at your option) any later version. 19 * 20 * This program is distributed in the hope that it will be useful, 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 * GNU General Public License for more details. 24 * 25 * You should have received a copy of the GNU General Public License 26 * along with this program. If not, see <http://www.gnu.org/licenses/>. 27 * 28 * The Original Code is BuckoFIBS, <http://www.buckosoft.com/BuckoFIBS/>. 29 * The Initial Developer of the Original Code is Dick Balaska and BuckoSoft, Corp. 30 * 31 */ 32 package com.buckosoft.fibs.BuckoFIBS.gui.boardTab.boardPane.animateType; 33 34 import java.awt.Point; 35 36 import com.buckosoft.fibs.BuckoFIBS.gui.boardTab.boardPane.AnimateEventDouble; 37 import com.buckosoft.fibs.domain.Board; 38 39 /** Move the double cube along a spline path. 40 * @author Dick Balaska 41 * @since 2013/09/10 42 * @version $Revision$ <br> $Date$ 43 * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/main/java/com/buckosoft/fibs/BuckoFIBS/gui/boardTab/boardPane/animateType/DoubleSpline2D.java">cvs DoubleSpline2D.java</a> 44 */ 45 public class DoubleSpline2D extends AnimateEventDouble { 46 private _Spline2D spline; 47 48 // private static Color startColor = new Color(255,20,20,190); 49 // private static Color endColor = new Color(20,255,20,150); 50 //private Color workColor; 51 52 53 public int[] getXY(double offset) { 54 return(spline.getPoint(offset)); 55 } 56 /* 57 @Override 58 public Color getColor(double offset) { 59 return( new Color( 60 (int)(((endColor.getRed()-startColor.getRed())*offset)+startColor.getRed()), 61 (int)(((endColor.getGreen()-startColor.getGreen())*offset)+startColor.getGreen()), 62 (int)(((endColor.getBlue()-startColor.getBlue())*offset)+startColor.getBlue()), 63 (int)(((endColor.getAlpha()-startColor.getAlpha())*offset)+startColor.getAlpha())) 64 ); 65 } 66 */ 67 public void calculate(Board board) { 68 Point sxy = getDoubleCubeXY(); 69 int w2 = getDoubleCubeWidth()/2; 70 int h2 = boardPane.getHeight()/2; 71 x[0] = sxy.x+w2; 72 y[0] = sxy.y+w2; 73 74 x[1] = x[0]; 75 y[1] = h2-getDoubleCubeWidth()*-Board.xoToTurn(this.whoDoubled); 76 77 x[2] = x[0]; 78 y[2] = h2; 79 80 sxy = getDoubleCubePushXY(); 81 x[3] = sxy.x; 82 y[3] = y[2]; 83 84 x[4] = x[3]; 85 y[4] = h2+getDoubleCubeWidth()*-Board.xoToTurn(this.whoDoubled); 86 87 x[5] = sxy.x; 88 y[5] = sxy.y; 89 90 if (board.getHasCube() == -1) { 91 x[1] = x[0] + 10; 92 y[1] = y[0]; 93 x[2] = (x[3]-x[0])/2 + x[0]; 94 y[2] = y[0] + 20*-this.whoDoubled; 95 } 96 97 98 spline = new _Spline2D(x, y); 99 } 100 101 }