org.jogre.common.util
Class JogreUtils

java.lang.Object
  extended byorg.jogre.common.util.JogreUtils

public class JogreUtils
extends Object

Bunch of utilities which are used in several classes through the API.

Version:
Alpha 0.2.3
Author:
Bob Marks

Constructor Summary
JogreUtils()
           
 
Method Summary
static int[] convertTo1DArray(int[][] array)
          Helper method for converting a 2 dimensional array to a single array.
static int[][] convertTo2DArray(int[] array, int l1, int l2)
          Helper method for converting a 2 dimensional array to a single array.
static boolean[] convertToBoolArray(String text)
          Convert String to boolean array.
static int[] convertToIntArray(String text)
          Convert String to int array.
static String[] convertToStringArray(String text)
          Convert String to int array.
static Color getColorDelta(Color color, int delta)
          Return a new Color from an existing color by add each of its rgb values with an integer delta amount.
static Color getColour(String colourStr)
          Return a Color object from a String of "r,g,b"
static int invert(int value)
          Get invert of 0 or 1.
static Date readDate(String dateString, String formatString)
          Little helper method which reads as a String and formats it using a specified format String.
static String valueOf(boolean[] values)
          Convert simple boolean array to space delimited String.
static String valueOf(Date date, String formatString)
          Return the data as a String formatted with a specified String.
static String valueOf(int[] values)
          Convert simple integer array to space delimited String.
static String valueOf(String[] values)
          Convert simple String array to space delimited String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JogreUtils

public JogreUtils()
Method Detail

getColour

public static Color getColour(String colourStr)
Return a Color object from a String of "r,g,b"

Parameters:
colourStr - Colour as a comma delimited String.
Returns:
Return a Color object.

getColorDelta

public static Color getColorDelta(Color color,
                                  int delta)
Return a new Color from an existing color by add each of its rgb values with an integer delta amount. E.g. If a color rgb (100, 100, 100), delta = 10 => New Color (110, 110, 110).

Parameters:
color - Original Colour.
delta - Amount to add color to each channel.
Returns:
New Color

readDate

public static Date readDate(String dateString,
                            String formatString)
Little helper method which reads as a String and formats it using a specified format String.

Parameters:
dateString - Date as a String
formatString - Format of the String
Returns:
Date object.
See Also:
SimpleDateFormat

convertToStringArray

public static String[] convertToStringArray(String text)
Convert String to int array.

Parameters:
text - Simple integer array as a spaced delimited String.

convertToIntArray

public static int[] convertToIntArray(String text)
Convert String to int array.

Parameters:
text - Simple integer array as a spaced delimited String.

convertToBoolArray

public static boolean[] convertToBoolArray(String text)
Convert String to boolean array.

Parameters:
text - Simple integer array as a spaced delimited String.
Returns:
Returns a String of booleans of format "t f t".

convertTo1DArray

public static int[] convertTo1DArray(int[][] array)
Helper method for converting a 2 dimensional array to a single array.

Parameters:
array - 2 dimensional array.
Returns:
1 dimensional array with contents of 2d array.

convertTo2DArray

public static int[][] convertTo2DArray(int[] array,
                                       int l1,
                                       int l2)
Helper method for converting a 2 dimensional array to a single array.

Parameters:
array - Single dimension array of data.
l1 - Length 1.
l2 - Length 2
Returns:
Returns a 2d array of size [l1][l2] of type

valueOf

public static String valueOf(int[] values)
Convert simple integer array to space delimited String.

Parameters:
values - Array of integers.
Returns:
String value.

valueOf

public static String valueOf(boolean[] values)
Convert simple boolean array to space delimited String.

Parameters:
values - Array of integers.
Returns:
String value of syntax "t f t ..." where t = true / f = false

valueOf

public static String valueOf(String[] values)
Convert simple String array to space delimited String.

Parameters:
values - Array of strings.
Returns:
String with spaces.

valueOf

public static String valueOf(Date date,
                             String formatString)
Return the data as a String formatted with a specified String.

Parameters:
date - Specified data / time.
formatString - Format of string.
Returns:
String representation of date.

invert

public static int invert(int value)
Get invert of 0 or 1. Especially useful when trying to get opposing player's seat number during a 2 player game.

Parameters:
value -
Returns:
invert of 0 or 1