|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectclient.framework.Utils
public abstract class Utils
This class contains utilities used in different parts of the framework. These utilities are static methods that offer functionality that may be needed several times. The utilities are: sorting of a list, drawing list of players to a graphics object, drawing message list, drawing list of settings and creating an image.
Field Summary | |
---|---|
static int |
LINE_HEIGHT
|
Constructor Summary | |
---|---|
Utils()
|
Method Summary | |
---|---|
static java.lang.String |
buildString(java.lang.Object[] objects)
Builds a string using a StringBuffer object. |
static Image |
createImage(int width,
int height,
int red,
int green,
int blue)
Creates a monocolored Image object. |
static void |
drawPlayerList(Graphics graphics,
int screenWidth,
int screenHeight,
AbstractGame model,
boolean inGame)
Draws a list of players to the provided graphics object. |
static java.util.Vector |
sort(java.util.Hashtable list)
Sorts a list of comparable elements so that the element with the highest value is returned at the start of the list and the element with the lowest value is returned at the end (descending). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int LINE_HEIGHT
Constructor Detail |
---|
public Utils()
Method Detail |
---|
public static java.util.Vector sort(java.util.Hashtable list)
list
- The list to sort. All elements must implement the Comparable
interface.
Comparable
public static void drawPlayerList(Graphics graphics, int screenWidth, int screenHeight, AbstractGame model, boolean inGame)
GameView
and
LobbyView
to draw their lists of players.
If the game is drawn in the lobby view, indicators to show
whether the players are ready or not are also drawn.
If teams are enabled, the player list is first sorted according to
the teams, and the players within each team are sorted by their score.
graphics
- The graphics object to use for the drawing.screenWidth
- The available screen width.screenHeight
- The available screen height.model
- The game's model.inGame
- Whether the drawing is performed in-game or not.public static Image createImage(int width, int height, int red, int green, int blue)
Image
object.
This method is used to create user sprites and
background images.
width
- The width of the image.height
- The height of the image.red
- The amound of red.green
- The amount of green.blue
- The amount of blue.
Image
object.public static java.lang.String buildString(java.lang.Object[] objects)
StringBuffer
object. This
method is faster than using the '+' operator when building many
and large strings.
objects
- The contents of the string.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |