|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--trex.TRexUtil
This class provides a couple of helper functions commonly used in TRex (and maybe others... ;) Methods are static and can be called from outside without instantiating TRexUtil.
Constructor Summary | |
TRexUtil()
|
Method Summary | |
static int |
bytesToInt(byte[] in)
generate an integer from a byte array with 4 elements |
static String |
bytesToString(byte[] in)
print a byte array as a comma seperated string |
static byte[] |
concatByteArrays(byte[] in1,
byte[] in2)
concatenate two byte arrays. |
static byte |
getBit(byte[] in,
int pos)
Return a bit (0 || 1) from a byte array indexed as pos. |
static BufferedImage |
iitobi(ImageIcon ii,
Frame parent)
create a BufferedImage from an ImageIcon |
static String |
intsToString(int[] in)
print a int array as a comma seperated string |
static byte[] |
intToBytes(int in)
Convert an integer to an array of 4 bytes. |
static Component |
makeImagePanel(ImageIcon img)
Creates a JPanel only containing an ImageIcon . |
static Component |
makeImagePanel(String filename)
Creates a JPanel only containing an ImageIcon
read from a file. |
static Component |
makePanel(ImageIcon img,
String text)
Construct a panel displaying an ImageIcon (if available) or a text (as a fallback). |
static Component |
makePanel(String filename,
String text)
Construct a panel displaying an ImageIcon (if available) or a text (as a fallback). |
static JPanel |
makeTextPanel(String text)
Creates a JPanel only containing a text label. |
static int |
maxArray(int[] array)
Find largest value in an array. |
static void |
printDebug(String x)
|
static void |
setBit(byte[] in,
int pos,
int value)
Set a bit in a byte array. |
static BufferedImage |
simpleAddImages(Frame parent,
ImageIcon img1,
ImageIcon img2)
This method adds two images and returns their "OR" picture. |
static BufferedImage |
simpleAddImages(Frame parent,
Image img1,
Image img2,
int w,
int h)
This method adds two images by returning their "OR" picture. |
static byte[] |
subArray(byte[] in,
int start,
int len)
return a part of an array. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TRexUtil()
Method Detail |
public static JPanel makeTextPanel(String text)
text
- Text to display in panel's label.
public static Component makeImagePanel(ImageIcon img)
ImageIcon
.
img
- Icon to display.
public static Component makeImagePanel(String filename)
ImageIcon
read from a file.
filename
- File containing the image.
public static Component makePanel(ImageIcon img, String text)
img
- Image to display, or nulltext
- Text to display if img is null
public static Component makePanel(String filename, String text)
filename
- File containing image to display, or nulltext
- Text to display if filename is null
public static byte getBit(byte[] in, int pos)
in
- byte array to get bit from.pos
- bit number.
public static void setBit(byte[] in, int pos, int value)
in
- byte array to set bit inpos
- bit number in arrayvalue
- value to set (0 || 1)public static byte[] intToBytes(int in)
in
- integer to transform.
public static int bytesToInt(byte[] in)
in
- Input byte array.
public static byte[] concatByteArrays(byte[] in1, byte[] in2)
in1
- First input array.in2
- Latter input array.
public static byte[] subArray(byte[] in, int start, int len)
in
- Byte array.start
- First element to return.len
- Number of elements to return.
public static String bytesToString(byte[] in)
in
- Byte array.
public static String intsToString(int[] in)
in
- Int array.
public static int maxArray(int[] array)
public static BufferedImage iitobi(ImageIcon ii, Frame parent)
ii
- An ImageIcon
to transformparent
- A Frame to display error messages in
public static BufferedImage simpleAddImages(Frame parent, Image img1, Image img2, int w, int h)
parent
- Parent window.img1
- First image.img2
- Second image.w
- Picture's width.h
- Picutre's height.public static BufferedImage simpleAddImages(Frame parent, ImageIcon img1, ImageIcon img2)
parent
- Parent window.img1
- First image.img2
- Second image.public static void printDebug(String x)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |