public final class FCOCUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.awt.Color |
m_MEDIUMGREEN
Medium green color #00BE00
|
static java.awt.Color |
m_ORANGEWARNING
Orange color for warning message on grey #FF870F
|
Constructor and Description |
---|
FCOCUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
addChecksum(byte[] acBuffer,
int nBufferLength)
Add std checksum to a FiveCo packet buffer.
|
static int |
bcd2Int(byte chBcdValue)
Convert a BCD value to the corresponding byte value.
|
static int |
byteArrayBEToInt(java.lang.Byte[] aArray,
int nIndex)
Return an int value from a Byte[] array.
|
static int |
byteArrayBEToInt(byte[] achArray,
int nIndex,
int nLength)
Return an int value from a byte[] array.
|
static int |
byteArrayBEToInt(java.lang.Byte[] aArray,
int nIndex,
int nLength)
Return an int value from a Byte[] array.
|
static int |
byteArrayBEToUnsignedInt(byte[] achArray,
int nIndex,
int nLength)
Return an int value from a byte[] array.
|
static int |
byteArrayLEToInt(java.lang.Byte[] aArray,
int nIndex)
Return an int value from a Byte[] array.
|
static int |
byteArrayLEToInt(java.lang.Byte[] aArray,
int nIndex,
int nLength)
Return an int value from a Byte[] array.
|
static java.lang.String |
byteArrayLEToString(byte[] achArray,
int nOffset,
int nMaxLength)
Convert part of a byte array to a String object in little endian order
|
static long |
byteArrayLEToUnsignedInt(java.lang.Byte[] aArray,
int nIndex)
Return a long value from a Byte[] array.
|
static long |
byteArrayLEToUnsignedInt(byte[] achArray,
int nIndex,
int nLength)
Return a long value from a byte[] array.
|
static long |
byteArrayLEToUnsignedInt(java.lang.Byte[] aArray,
int nIndex,
int nLength)
Return a long value from a Byte[] array.
|
static java.lang.String |
byteArrayToString(byte[] achArray,
int nOffset,
int nMaxLength)
Convert part of a byte array to a String object
|
static java.lang.String |
byteArrayToString(java.lang.Byte[] aArray,
int nOffset,
int nMaxLength)
Convert part of a byte array to a String object
|
static void |
centerFrame(javax.swing.JFrame FrameToCenter)
Center a frame on the screen.
|
static <T> T[] |
concatArrays(T[] aFirst,
T[] aSecond)
Concatenate two arrays into one.
|
static javax.swing.ImageIcon |
createImageIcon(java.lang.String szPath) |
static java.util.List<java.awt.image.BufferedImage> |
getAppIconImages(java.lang.Class<?> ThisClass) |
static int |
getChecksum(byte[] acBuffer,
int nBufferLength)
FiveCo's packet checksum calculation
|
static java.awt.Rectangle |
getDisplayBounds() |
static java.awt.Dimension |
getDisplaySize() |
static byte |
int2Bcd(int nBinValue)
Convert a byte value to its BCD representation.
|
static void |
intToByteArrayBE(int nValue,
java.lang.Byte[] aArray,
int nIndex)
Fill a Byte[] array with an int value.
|
static void |
intToByteArrayBE(int nValue,
java.lang.Byte[] aArray,
int nIndex,
int nLength)
Fill a Byte[] array with an int value.
|
static void |
intToByteArrayLE(int nValue,
java.lang.Byte[] aArray,
int nIndex)
Fill a Byte[] array with an int value.
|
static void |
intToByteArrayLE(int nValue,
java.lang.Byte[] aArray,
int nIndex,
int nLength)
Fill a Byte[] array with an int value.
|
static java.lang.String |
padHexString(java.lang.String szValue)
A multiple of 2 digits string representation of the Hex String argument.
|
static void |
setContainerEnabled(java.awt.Component Comp,
boolean isEnabled)
Enable or disable a Container and all its children.
|
static void |
setMouseListenerRecursively(javax.swing.JComponent Comp,
java.awt.event.MouseAdapter MouseAdapt) |
static void |
setToolTipRecursively(javax.swing.JComponent Comp,
java.lang.String szText,
java.awt.event.MouseAdapter MouseAdapt) |
static java.lang.String |
toHexString(int nValue)
Returns a string representation of the integer argument as an unsigned integer in base 16.
|
static java.lang.String |
toHexString(int nValue,
int nLength)
A string representation of the integer argument as an unsigned integer in base 16.
|
static void |
unsignedIntToByteArrayLE(long lValue,
java.lang.Byte[] aArray,
int nIndex)
Fill a Byte[] array with an int value.
|
static void |
unsignedIntToByteArrayLE(long lValue,
java.lang.Byte[] aArray,
int nIndex,
int nLength)
Fill a Byte[] array with an long value.
|
public static final java.awt.Color m_MEDIUMGREEN
Medium green color #00BE00
public static final java.awt.Color m_ORANGEWARNING
Orange color for warning message on grey #FF870F
public static final int getChecksum(byte[] acBuffer, int nBufferLength)
FiveCo's packet checksum calculation
acBuffer
- Buffer with FiveCo's packetnBufferLength
- Number of byte before checksumpublic static final void addChecksum(byte[] acBuffer, int nBufferLength)
Add std checksum to a FiveCo packet buffer.
acBuffer
- Buffer in which checksum must be addednBufferLength
- Number of bytes before checksumpublic static final void centerFrame(javax.swing.JFrame FrameToCenter)
Center a frame on the screen.
FrameToCenter
- Frame to center on screenpublic static final void setContainerEnabled(java.awt.Component Comp, boolean isEnabled)
Enable or disable a Container and all its children.
Comp
- ContainerisEnabled
- True to enable the container and it's children, false for the inversepublic static void intToByteArrayLE(int nValue, java.lang.Byte[] aArray, int nIndex)
Fill a Byte[] array with an int value.
nValue
- The value to be converted in byte value in array in Little Endian representation.aArray
- The array to fill in.nIndex
- The index in the array for the LSBpublic static void intToByteArrayLE(int nValue, java.lang.Byte[] aArray, int nIndex, int nLength) throws java.lang.IllegalArgumentException
Fill a Byte[] array with an int value.
nValue
- The value to be converted in byte value in array in Little Endian representation.aArray
- The array to fill in.nIndex
- The index in the array for the LSBnLength
- Byte count for the conversion (1-4)java.lang.IllegalArgumentException
- if nLength not between 1 and 4.public static void unsignedIntToByteArrayLE(long lValue, java.lang.Byte[] aArray, int nIndex)
Fill a Byte[] array with an int value.
lValue
- The value to be converted in byte value in array in Little Endian representation.aArray
- The array to fill in.nIndex
- The index in the array for the LSBpublic static void unsignedIntToByteArrayLE(long lValue, java.lang.Byte[] aArray, int nIndex, int nLength) throws java.lang.IllegalArgumentException
Fill a Byte[] array with an long value.
lValue
- The value to be converted in byte value in array in Little Endian representation.aArray
- The array to fill in.nIndex
- The index in the array for the LSBnLength
- Byte count for the conversion (1-4)java.lang.IllegalArgumentException
- if nLength not between 1 and 7.public static void intToByteArrayBE(int nValue, java.lang.Byte[] aArray, int nIndex)
Fill a Byte[] array with an int value.
nValue
- The value to be converted in byte value in array in Big Endian representation.aArray
- The array to fill in.nIndex
- The index in the array for the MSBpublic static void intToByteArrayBE(int nValue, java.lang.Byte[] aArray, int nIndex, int nLength) throws java.lang.IllegalArgumentException
Fill a Byte[] array with an int value.
nValue
- The value to be converted in byte value in array in Big Endian representation.aArray
- The array to fill in.nIndex
- The index in the array for the MSBnLength
- Byte count for the conversion (1-4)java.lang.IllegalArgumentException
- if nLength not between 1 and 4.public static final int byteArrayLEToInt(java.lang.Byte[] aArray, int nIndex)
Return an int value from a Byte[] array.
aArray
- The array with data.nIndex
- The index in the array for the MSBpublic static final int byteArrayLEToInt(java.lang.Byte[] aArray, int nIndex, int nLength) throws java.lang.IllegalArgumentException
Return an int value from a Byte[] array.
aArray
- The array with data.nIndex
- The index in the array for the MSBnLength
- Byte count for the conversion (1-4)java.lang.IllegalArgumentException
- if nLength not between 1 and 4.public static final long byteArrayLEToUnsignedInt(java.lang.Byte[] aArray, int nIndex)
Return a long value from a Byte[] array.
aArray
- The array with data.nIndex
- The index in the array for the MSBpublic static final long byteArrayLEToUnsignedInt(java.lang.Byte[] aArray, int nIndex, int nLength) throws java.lang.IllegalArgumentException
Return a long value from a Byte[] array.
aArray
- The array with data.nIndex
- The index in the array for the MSBnLength
- Byte count for the conversion (1-4)java.lang.IllegalArgumentException
- if nLength not between 1 and 7.public static final long byteArrayLEToUnsignedInt(byte[] achArray, int nIndex, int nLength) throws java.lang.IllegalArgumentException
Return a long value from a byte[] array.
achArray
- The array with data.nIndex
- The index in the array for the MSBnLength
- Byte count for the conversion (1-4)java.lang.IllegalArgumentException
- if nLength not between 1 and 7.public static final int byteArrayBEToInt(java.lang.Byte[] aArray, int nIndex)
Return an int value from a Byte[] array.
aArray
- The array to fill in.nIndex
- The index in the array for the MSBpublic static final int byteArrayBEToInt(java.lang.Byte[] aArray, int nIndex, int nLength) throws java.lang.IllegalArgumentException
Return an int value from a Byte[] array.
aArray
- The array to fill in.nIndex
- The index in the array for the MSBnLength
- Byte count for the conversion (1-4)java.lang.IllegalArgumentException
- if nLength not between 1 and 4.public static final int byteArrayBEToInt(byte[] achArray, int nIndex, int nLength) throws java.lang.IllegalArgumentException
Return an int value from a byte[] array.
achArray
- The array to fill in.nIndex
- The index in the array for the MSBnLength
- Byte count for the conversion (1-4)java.lang.IllegalArgumentException
- if nLength not between 1 and 4.public static final int byteArrayBEToUnsignedInt(byte[] achArray, int nIndex, int nLength) throws java.lang.IllegalArgumentException
Return an int value from a byte[] array.
achArray
- The array to fill in.nIndex
- The index in the array for the MSBnLength
- Byte count for the conversion (1-4)java.lang.IllegalArgumentException
- if nLength not between 1 and 4.public static final byte int2Bcd(int nBinValue) throws java.lang.IllegalArgumentException
Convert a byte value to its BCD representation.
nBinValue
- The value to convert (0-99).java.lang.IllegalArgumentException
- if nLength not between 0 and 99.public static final int bcd2Int(byte chBcdValue)
Convert a BCD value to the corresponding byte value.
chBcdValue
- The BCD value to convert.public static final java.lang.String toHexString(int nValue)
Returns a string representation of the integer argument as an unsigned integer in base 16.
The unsigned integer value is the argument plus 232 if the argument is negative; otherwise, it is equal to the argument. This value is converted to a string of ASCII digits in hexadecimal (base 16) with leading 0s
nValue
- The value to be converted in Hex Stringpublic static final java.lang.String toHexString(int nValue, int nLength)
A string representation of the integer argument as an unsigned integer in base 16.
The unsigned integer value is the argument plus 232 if the argument is negative; otherwise, it is equal to the argument. This value is converted to a string of ASCII digits in hexadecimal (base 16) with leading 0s
nValue
- The value to be converted in Hex StringnLength
- Minimum of digits for 0s paddingpublic static final java.lang.String padHexString(java.lang.String szValue)
A multiple of 2 digits string representation of the Hex String argument.
In other word, this method add simply 0's padding.
szValue
- The hex string value to be converted in multiple of 2 digits Hex Stringpublic static final java.lang.String byteArrayToString(byte[] achArray, int nOffset, int nMaxLength)
Convert part of a byte array to a String object
achArray
- The byte array with data.nOffset
- Offset of string in byte array.nMaxLength
- Max char count in byte array.public static final java.lang.String byteArrayToString(java.lang.Byte[] aArray, int nOffset, int nMaxLength)
Convert part of a byte array to a String object
aArray
- The Byte array with data.nOffset
- Offset of string in byte array.nMaxLength
- Max char count in byte array.public static final java.lang.String byteArrayLEToString(byte[] achArray, int nOffset, int nMaxLength)
Convert part of a byte array to a String object in little endian order
achArray
- The byte array with data.nOffset
- Offset of string in byte array.nMaxLength
- Max char count in byte array.public static final <T> T[] concatArrays(T[] aFirst, T[] aSecond)
Concatenate two arrays into one.
T
- Return array typeaFirst
- First arrayaSecond
- Second arraypublic static javax.swing.ImageIcon createImageIcon(java.lang.String szPath)
szPath
- Path to iconpublic static java.util.List<java.awt.image.BufferedImage> getAppIconImages(java.lang.Class<?> ThisClass) throws java.io.IOException
ThisClass
- App class to find icon locationjava.io.IOException
- If file not found or not readablepublic static void setMouseListenerRecursively(javax.swing.JComponent Comp, java.awt.event.MouseAdapter MouseAdapt)
Comp
- Main JComponent to set mouse listenerMouseAdapt
- An mouse adapter to catch mousePressed and mouseReleased eventspublic static void setToolTipRecursively(javax.swing.JComponent Comp, java.lang.String szText, java.awt.event.MouseAdapter MouseAdapt)
Comp
- Main JComponent to set tooltip textszText
- Text of tooltipMouseAdapt
- An optional mouse adapter to catch mousePressed and mouseReleased eventspublic static java.awt.Dimension getDisplaySize()
public static java.awt.Rectangle getDisplayBounds()