Coverage Report - com.buckosoft.fibs.BuckoFIBS.gui.boardTab.boardPane.animateType.MoveSpline2D
 
Classes in this File Line Coverage Branch Coverage Complexity
MoveSpline2D
0%
0/31
0%
0/8
2.333
 
 1  
 /******************************************************************************
 2  
  * Spline2D.java - Move a checker along a spline path
 3  
  * $Id$
 4  
  * 
 5  
  * BuckoFIBS - Backgammon by BuckoSoft
 6  
  * Copyright© 2011 - Dick Balaska - BuckoSoft, Corp.
 7  
  * 
 8  
  * $Log$
 9  
  * Revision 1.1  2013/09/10 00:22:54  dick
 10  
  * Spline2D and Flasher move MoveSpline2D and MoveFlasher
 11  
  *
 12  
  * Revision 1.1  2011/05/22 22:56:09  dick
 13  
  * c.b.f.B.g.boardTab.board becomes c.b.f.B.g.boardTab.boardPane .
 14  
  *
 15  
  * Revision 1.6  2011/05/18 05:54:00  dick
 16  
  * No really fix the move to home animation.
 17  
  *
 18  
  * Revision 1.5  2011/05/17 23:15:41  dick
 19  
  * Again fix the Home move.
 20  
  *
 21  
  * Revision 1.4  2011/05/17 22:48:04  dick
 22  
  * Fix the bear-off anchor points.
 23  
  *
 24  
  * Revision 1.3  2011/05/16 21:26:06  dick
 25  
  * Handle Home and Bar during Move.
 26  
  *
 27  
  * Revision 1.2  2011/05/16 14:16:14  dick
 28  
  * Javadoc.
 29  
  *
 30  
  * Revision 1.1  2011/05/15 02:14:12  dick
 31  
  * gui.board.animator becomes gui.boardTab.board.animateType.
 32  
  *
 33  
  * Revision 1.1  2011/05/13 14:26:35  dick
 34  
  * Spline2D moves to the animator package.
 35  
  *
 36  
  */
 37  
 
 38  
 /* 
 39  
  * This program is free software: you can redistribute it and/or modify
 40  
  * it under the terms of the GNU General Public License as published by
 41  
  * the Free Software Foundation, either version 3 of the License, or
 42  
  * (at your option) any later version.
 43  
  *
 44  
  * This program is distributed in the hope that it will be useful,
 45  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 46  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 47  
  * GNU General Public License for more details.
 48  
  *
 49  
  * You should have received a copy of the GNU General Public License
 50  
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 51  
  *
 52  
  * The Original Code is BuckoFIBS, <http://www.buckosoft.com/BuckoFIBS/>.
 53  
  * The Initial Developer of the Original Code is Dick Balaska and BuckoSoft, Corp.
 54  
  * 
 55  
  */
 56  
 package com.buckosoft.fibs.BuckoFIBS.gui.boardTab.boardPane.animateType;
 57  
 
 58  
 import java.awt.Color;
 59  
 
 60  
 import com.buckosoft.fibs.BuckoFIBS.gui.boardTab.boardPane.AnimateEventMove;
 61  
 import com.buckosoft.fibs.domain.Board;
 62  
 
 63  
 /** Move a point along a spline.
 64  
  * Jave Spline algorithm from <a href="http://www.java2s.com/Code/Java/2D-Graphics-GUI/Spline2D.htm">Spline2D.htm</a>
 65  
  * @author Dick Balaska
 66  
  * @since 2011/05/12
 67  
  * @version $Revision$ <br> $Date$
 68  
  * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/main/java/com/buckosoft/fibs/BuckoFIBS/gui/boardTab/boardPane/animateType/MoveSpline2D.java">cvs MoveSpline2D.java</a>
 69  
  * @see <a href="http://www.java2s.com/Code/Java/2D-Graphics-GUI/Spline2D.htm">Spline2D.htm</a>
 70  
  */
 71  0
 public class MoveSpline2D  extends AnimateEventMove {
 72  
         private _Spline2D spline;
 73  
 
 74  0
         private        static         Color        startColor = new Color(255,20,20,190);
 75  0
         private        static         Color        endColor = new Color(20,255,20,150);
 76  
         //private        Color                        workColor;
 77  
 
 78  
 
 79  
         public int[] getXY(double offset) {
 80  0
                 return(spline.getPoint(offset));
 81  
         }
 82  
 
 83  
         @Override
 84  
         public Color getColor(double offset) {
 85  0
                 return( new Color(
 86  0
                                 (int)(((endColor.getRed()-startColor.getRed())*offset)+startColor.getRed()),
 87  0
                                 (int)(((endColor.getGreen()-startColor.getGreen())*offset)+startColor.getGreen()),
 88  0
                                 (int)(((endColor.getBlue()-startColor.getBlue())*offset)+startColor.getBlue()),
 89  0
                                 (int)(((endColor.getAlpha()-startColor.getAlpha())*offset)+startColor.getAlpha()))
 90  
                         );
 91  
         }
 92  
         
 93  
         public void calculate() {
 94  
 
 95  0
                 x[0] = getPointX(pointNumberStart)+bs.c2;
 96  0
                 y[0] = getNthCheckerY(pointNumberStart, checkerNumberStart)+bs.c2;
 97  0
                 if (pointNumberStart == Board.Bar)
 98  0
                         y[0] = getCheckerYOnBar(this.who, checkerNumberStart)+bs.c2;
 99  0
                 x[1] = x[0];
 100  0
                 y[1] = getNthCheckerY(pointNumberStart, 4)+bs.c2;
 101  0
                 if (pointNumberStart == Board.Bar)
 102  0
                         y[1] = getCheckerYOnBar(this.who, checkerNumberStart)+bs.c2;
 103  0
                 x[2] = x[0];//-bs.checkerSize;
 104  0
                 y[2] = bs.h/2;
 105  
                 
 106  0
                 x[5] = getPointX(pointNumberEnd)+bs.c2;
 107  0
                 y[5] = getNthCheckerY(pointNumberEnd, checkerNumberEnd)+bs.c2;
 108  0
                 if (pointNumberEnd == Board.Home)
 109  0
                         y[5] = this.getCheckerYInHome(this.who, checkerNumberEnd)+bs.checkerHeight/2;
 110  0
                 x[4] = x[5];
 111  0
                 y[4] = getNthCheckerY(pointNumberEnd, 4)-bs.c2;
 112  0
                 if (pointNumberEnd == Board.Home)
 113  0
                         y[4] = (y[5]+y[2])/2;
 114  
                 
 115  0
                 x[3] = x[5];
 116  0
                 y[3] = y[2];
 117  
 
 118  
                 /*
 119  
                 x[0] = boardPane.getPointX(pointNumberStart)+bs.c2;
 120  
                 y[0] = boardPane.getNthCheckerY(pointNumberStart, checkerNumberStart)+bs.c2;
 121  
                 x[3] = boardPane.getPointX(pointNumberEnd)+bs.c2;
 122  
                 y[3] = boardPane.getNthCheckerY(pointNumberEnd, checkerNumberEnd)+bs.c2;
 123  
                 x[1] = x[0];//+bs.checkerSize;
 124  
                 y[1] = bs.h/2;
 125  
                 x[2] = x[3];//-bs.checkerSize;
 126  
                 y[2] = y[1];
 127  
                  */
 128  
                 /*
 129  
                 x[0] = boardPane.getPointX(pointNumberStart);
 130  
                 y[0] = boardPane.getNthCheckerY(pointNumberStart, checkerNumberStart);
 131  
                 x[5] = boardPane.getPointX(pointNumberEnd);
 132  
                 y[5] = boardPane.getNthCheckerY(pointNumberEnd, checkerNumberEnd);                
 133  
                 x[1] = x[0];
 134  
                 y[1] = y[0];
 135  
                 x[2] = x[0];
 136  
                 y[2] = boardPane.bs.h/2;
 137  
                 x[3] = x[3];
 138  
                 y[3] = y[1];
 139  
                 x[4] = x[5];
 140  
                 y[4] = y[4];
 141  
                  */
 142  0
                 spline = new _Spline2D(x, y);
 143  0
         }
 144  
 
 145  
 }