Blackjack

com.amoebacode.blackjack.display
Class Coordinate

java.lang.Object
  |
  +--com.amoebacode.blackjack.display.Coordinate

public class Coordinate
extends java.lang.Object

Coordinate manages one point on a two-dimensional plane.

Version:
0.9
Author:
Jason Gurney

Field Summary
private  int xPos
          The horizontal position of this coordinate
private  int yPos
          The vertical position of this coordinate
 
Constructor Summary
Coordinate(int xPos, int yPos)
          Default public constructor.
 
Method Summary
 boolean equals(Coordinate otherCoordinate)
          Indicates whether this coordinate is in the same position as the specified coordinate.
 Coordinate getCopy()
          Returns a copy of this coordinate.
private  double getXPercentDifference(Coordinate otherCoordinate)
          Returns the horizontal percentage of the overall difference between this coordinate and the specified coordinate.
 int getXPos()
          Returns the horizontal position of this coordinate.
private  double getYPercentDifference(Coordinate otherCoordinate)
          Returns the vertical percentage of the overall difference between this coordinate and the specified coordinate.
 int getYPos()
          Returns the vertical position of this coordinate.
private  int minus(Coordinate otherCoordinate)
          Returns the sum of the horizontal and vertical differences between this coordinate and the specified coordinate.
 void move(Coordinate destCoordinate, int pixels)
          Moves this coordinate the specified number of pixels toward the specified desination, or if it is closer than the specified number of pixels, sets its position at the destination.
private  void movePixels(Coordinate destCoordinate, int pixels)
          Moves this coordinate the specified number of pixels toward the specified desination.
private  void setCoordinate(Coordinate otherCoordinate)
          Sets this coordinate's position at the position of the specified coordinate.
private  int xMinus(Coordinate otherCoordinate)
          Returns the horizontal difference between this coordinate and the specified coordinate.
private  int yMinus(Coordinate otherCoordinate)
          Returns the vertical difference between this coordinate and the specified coordinate.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

xPos

private int xPos
The horizontal position of this coordinate

yPos

private int yPos
The vertical position of this coordinate
Constructor Detail

Coordinate

public Coordinate(int xPos,
                  int yPos)
Default public constructor.
Parameters:
xPos - the horizontal position of this coordinate
yPos - the vertical position of this coordinate
Method Detail

getXPos

public int getXPos()
Returns the horizontal position of this coordinate.
Returns:
the horizontal position of this coordinate

getYPos

public int getYPos()
Returns the vertical position of this coordinate.
Returns:
the vertical position of this coordinate

getCopy

public Coordinate getCopy()
Returns a copy of this coordinate.
Returns:
a copy of this coordinate

move

public void move(Coordinate destCoordinate,
                 int pixels)
Moves this coordinate the specified number of pixels toward the specified desination, or if it is closer than the specified number of pixels, sets its position at the destination.
Parameters:
destCoordinate - the destination for the move
pixels - the number of pixels to move

equals

public boolean equals(Coordinate otherCoordinate)
Indicates whether this coordinate is in the same position as the specified coordinate.
Parameters:
otherCoordinate - the other coordinate to compare
Returns:
true if the coordinates are in the same position

minus

private int minus(Coordinate otherCoordinate)
Returns the sum of the horizontal and vertical differences between this coordinate and the specified coordinate.
Parameters:
otherCoordinate - the other coordinate to compare
Returns:
the sum of the horizontal and vertical differences

yMinus

private int yMinus(Coordinate otherCoordinate)
Returns the vertical difference between this coordinate and the specified coordinate.
Parameters:
otherCoordinate - the other coordinate to compare
Returns:
the vertical difference

xMinus

private int xMinus(Coordinate otherCoordinate)
Returns the horizontal difference between this coordinate and the specified coordinate.
Parameters:
otherCoordinate - the other coordinate to compare
Returns:
the horizontal difference

movePixels

private void movePixels(Coordinate destCoordinate,
                        int pixels)
Moves this coordinate the specified number of pixels toward the specified desination.
Parameters:
destCoordinate - the destination for the move
pixels - the number of pixels to move

getXPercentDifference

private double getXPercentDifference(Coordinate otherCoordinate)
Returns the horizontal percentage of the overall difference between this coordinate and the specified coordinate.
Parameters:
otherCoordinate - the other coordinate to compare
Returns:
the horizontal percentage of the difference

getYPercentDifference

private double getYPercentDifference(Coordinate otherCoordinate)
Returns the vertical percentage of the overall difference between this coordinate and the specified coordinate.
Parameters:
otherCoordinate - the other coordinate to compare
Returns:
the vertical percentage of the difference

setCoordinate

private void setCoordinate(Coordinate otherCoordinate)
Sets this coordinate's position at the position of the specified coordinate.
Parameters:
otherCoordinate - the destination position

Blackjack

Copyright © 2002 amoebacode.com.