|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object
|
+--java.awt.Component
|
+--au.com.solidsoftware.multimahjong.shared.Tile
Representation of a physical Mahjong tile. The Chinese game of Mahjong is played with a set of 136 tiles. The tiles are arranged into two categories: Suits and Honours. There are 3 Suits: Character, Circle and Bamboo. Each of these has 4 duplicates of the numbers 1 to 9, so each Suit consists of 36 tiles. Honour tiles consist of Winds and Dragons. The Wind tiles consist of East, South, West and North Winds, while the Dragon tiles consist of Green, Red and White Dragons. There are 4 duplicates of each tile.
This class extends the Component class as it has a graphical
representation that can be displayed on the screen and that can interact
with the user.
This class implements the Comparable interface by defining the
compareTo method. This allows an array of tiles to be sorted
according to the suit, and then the number, of the tiles.
| Inner classes inherited from class java.awt.Component |
java.awt.Component.AWTTreeLock |
| Field Summary | |
static int |
BAMBOO
Symbolic constant used to refer to the Bamboo suit. |
static int |
CHARACTER
Symbolic constant used to refer to the Character suit. |
static int |
CIRCLE
Symbolic constant used to refer to the Circle suit. |
static int |
DRAGON
Symbolic constant used to refer to the Dragon suit. |
static int |
EAST
Symbolic constant used to refer to the East Wind tile. |
static int |
GREEN
Symbolic constant used to refer to the Green Dragon tile. |
static int |
NORTH
Symbolic constant used to refer to the North Wind tile. |
protected int |
number
The number of this tile. |
static int |
RED
Symbolic constant used to refer to the Red Dragon tile. |
static int |
SOUTH
Symbolic constant used to refer to the South Wind tile. |
protected int |
suit
The suit of this tile. |
static int |
TILE_H
The height of a tile image in pixels. |
static int |
TILE_W
The width of a tile image in pixels. |
private static java.awt.Image[] |
tileImages
An array containing the images of all the tiles. |
private static java.awt.MediaTracker |
tracker
Keeps track of the loading status of the tile images. |
static int |
WEST
Symbolic constant used to refer to the West Wind tile. |
static int |
WHITE
Symbolic constant used to refer to the White Dragon tile. |
static int |
WIND
Symbolic constant used to refer to the Wind suit. |
| Fields inherited from class java.awt.Component |
actionListenerK,
adjustmentListenerK,
appContext,
assert,
background,
BOTTOM_ALIGNMENT,
CENTER_ALIGNMENT,
changeSupport,
componentListener,
componentListenerK,
componentOrientation,
componentSerializedDataVersion,
containerListenerK,
cursor,
dropTarget,
enabled,
eventMask,
focusListener,
focusListenerK,
font,
foreground,
hasFocus,
height,
incRate,
inputMethodListener,
inputMethodListenerK,
isInc,
isPacked,
itemListenerK,
keyListener,
keyListenerK,
LEFT_ALIGNMENT,
locale,
LOCK,
minSize,
mouseListener,
mouseListenerK,
mouseMotionListener,
mouseMotionListenerK,
name,
nameExplicitlySet,
newEventsOnly,
ownedWindowK,
parent,
peer,
peerFont,
popups,
prefSize,
RIGHT_ALIGNMENT,
serialVersionUID,
textListenerK,
TOP_ALIGNMENT,
valid,
visible,
width,
windowListenerK,
x,
y |
| Constructor Summary | |
Tile(int number,
int suit)
Creates an instance of Tile with a specific number and
suit. |
|
| Method Summary | |
java.awt.Image |
backImage()
Obtains the Image corresponding to the back of a tile. |
int |
compareTo(java.lang.Object tile)
Compares this object with the specified object for order. |
static void |
ensureImagesLoaded()
Waits until all tile images are loaded completely into memory. |
java.awt.Image |
faceImage()
Obtains the Image corresponding to the face of this tile. |
int |
getNumber()
Access method - returns the number of this Tile object. |
java.lang.String |
getString()
|
int |
getSuit()
Access method - returns the suit of this Tile object. |
static void |
loadImages(UserGUI userGUI)
Begin loading all the tile images into memory. |
static void |
main(java.lang.String[] args)
|
| Methods inherited from class java.awt.Component |
|
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
wait,
wait,
wait |
| Field Detail |
public static final int CHARACTER
public static final int CIRCLE
public static final int BAMBOO
public static final int WIND
public static final int DRAGON
public static final int EAST
public static final int SOUTH
public static final int WEST
public static final int NORTH
public static final int GREEN
public static final int RED
public static final int WHITE
public static final int TILE_W
public static final int TILE_H
private static java.awt.Image[] tileImages
static so that the same images are used by every single
Tile object, decreasing memory usage and increasing
performance.private static java.awt.MediaTracker tracker
protected final int number
protected final int suit
| Constructor Detail |
public Tile(int number,
int suit)
Tile with a specific number and
suit. Both of these fields are declared final and cannot
be modified once the object is instantiated.number - The number of the tile.suit - The suit of the tile.| Method Detail |
public static void loadImages(UserGUI userGUI)
createImage method is asynchronous, tile images may not
be completely loaded when this function returns. This is desirable from
a performance point of view.public static void ensureImagesLoaded()
public int getNumber()
Tile object.public int getSuit()
Tile object.public java.lang.String getString()
public java.awt.Image faceImage()
Image corresponding to the face of this tile.Image corresponding to the face of this tile.public java.awt.Image backImage()
Image corresponding to the back of a tile.Image corresponding to the back of a tile.public int compareTo(java.lang.Object tile)
Tile objects to enable the
automatic sorting of lists and arrays.tile - The Object to be compared.public static void main(java.lang.String[] args)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||