com.oxfordmathcenter.breadboards
Class GCardImage

java.lang.Object
  extended by acm.graphics.GObject
      extended by acm.graphics.GImage
          extended by com.oxfordmathcenter.breadboards.GCardImage
All Implemented Interfaces:
acm.graphics.GResizable, acm.graphics.GScalable, java.io.Serializable, java.lang.Cloneable

public class GCardImage
extends acm.graphics.GImage

An extension of GImage that displays as a playing card of a given rank and suit. Note: given that the cards shown have white edges, it is advisable to set the canvas color of the central drawing region to something dark. For example, to set the canvas color to poker-felt-green we could use: this.getGCanvas().setBackground(new Color(71,113,72));

Author:
paul
See Also:
Serialized Form

Field Summary
static int ACE
           
static int BLUE
           
static int CARD_HEIGHT
           
static int CARD_WIDTH
           
static int CLUBS
           
static int DIAMONDS
           
static int HEARTS
           
static int JACK
           
static int KING
           
static int NUM_CARDS_IN_DECK
           
static int NUMBER_OF_RANKS
           
static int NUMBER_OF_SUITS
           
static int QUEEN
           
static int RED
           
static int SPADES
           
 
Constructor Summary
GCardImage()
          Create a card GObject showing a red cardback by default that can be added to an ACM GraphicsProgram
GCardImage(int backColor)
          Create a card GObject showing a a red or blue cardback (as determined by backColor) that can be added to an ACM GraphicsProgram
GCardImage(int rank, int suit)
          Create a card GObject that can be added to an ACM GraphicsProgram
GCardImage(int rank, int suit, double x, double y)
          Similar to GCard(rank,suit), except that it places the card GObject at coordinates (x,y)
 
Method Summary
 void displayBackOfCard(int backColor)
          This method changes the image of the card to that of a card's back (of a given color)
 void displayCard(int rank, int suit)
          This method changes the image of the card to one with a given rank and suit
 
Methods inherited from class acm.graphics.GImage
createRGBPixel, createRGBPixel, getAlpha, getBlue, getBounds, getGreen, getImage, getPixelArray, getRed, getSize, paint, saveImage, saveImage, scale, scale, setBounds, setBounds, setImage, setImage, setSize, setSize
 
Methods inherited from class acm.graphics.GObject
addActionListener, addMouseListener, addMouseMotionListener, contains, contains, fireActionEvent, fireActionEvent, getColor, getHeight, getLocation, getParent, getWidth, getX, getY, isVisible, move, movePolar, pause, removeActionListener, removeMouseListener, removeMouseMotionListener, sendBackward, sendForward, sendToBack, sendToFront, setColor, setLocation, setLocation, setParent, setVisible, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NUM_CARDS_IN_DECK

public static final int NUM_CARDS_IN_DECK
See Also:
Constant Field Values

NUMBER_OF_SUITS

public static final int NUMBER_OF_SUITS
See Also:
Constant Field Values

NUMBER_OF_RANKS

public static final int NUMBER_OF_RANKS
See Also:
Constant Field Values

CARD_WIDTH

public static final int CARD_WIDTH
See Also:
Constant Field Values

CARD_HEIGHT

public static final int CARD_HEIGHT
See Also:
Constant Field Values

ACE

public static final int ACE
See Also:
Constant Field Values

JACK

public static final int JACK
See Also:
Constant Field Values

QUEEN

public static final int QUEEN
See Also:
Constant Field Values

KING

public static final int KING
See Also:
Constant Field Values

CLUBS

public static final int CLUBS
See Also:
Constant Field Values

SPADES

public static final int SPADES
See Also:
Constant Field Values

HEARTS

public static final int HEARTS
See Also:
Constant Field Values

DIAMONDS

public static final int DIAMONDS
See Also:
Constant Field Values

RED

public static final int RED
See Also:
Constant Field Values

BLUE

public static final int BLUE
See Also:
Constant Field Values
Constructor Detail

GCardImage

public GCardImage()
Create a card GObject showing a red cardback by default that can be added to an ACM GraphicsProgram


GCardImage

public GCardImage(int backColor)
Create a card GObject showing a a red or blue cardback (as determined by backColor) that can be added to an ACM GraphicsProgram

Parameters:
backColor - the cardback color to be used (either GCardImage.RED or GCardImage.BLUE)

GCardImage

public GCardImage(int rank,
                  int suit)
Create a card GObject that can be added to an ACM GraphicsProgram

Parameters:
rank - the rank of the card (for Ace, Jack, Queen, and King, see static constants of this class)
suit - the suit of the card (see the static constants of this class for possible values)

GCardImage

public GCardImage(int rank,
                  int suit,
                  double x,
                  double y)
Similar to GCard(rank,suit), except that it places the card GObject at coordinates (x,y)

Parameters:
rank - the rank of the card to be displayed
suit - the suit of the card to be displayed
x - the x-coordinate of the upper left corner of the image
y - the y-coordinate of the upper left corner of the image
Method Detail

displayBackOfCard

public void displayBackOfCard(int backColor)
This method changes the image of the card to that of a card's back (of a given color)

Parameters:
backColor - the color of the card's back

displayCard

public void displayCard(int rank,
                        int suit)
This method changes the image of the card to one with a given rank and suit

Parameters:
rank - the rank to be shown on the card
suit - the suit to be shown on the card