Package org.yamcs.studio.data.vtype
Class ValueUtil
java.lang.Object
org.yamcs.studio.data.vtype.ValueUtil
Various utility methods for runtime handling of the types defined in this package.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Alarm
Extracts the alarm information if present.static int
colorFor
(AlarmSeverity severity) Returns the rgb value for the given severity.static List<ArrayDimensionDisplay>
defaultArrayDisplay
(ListInt sizes) Returns the default array dimension display given the size of the n dimensional array and creating cell boundaries based on index.static List<ArrayDimensionDisplay>
defaultArrayDisplay
(VNumberArray array) Returns the default array dimension display by looking at the size of the n dimensional array and creating cell boundaries based on index.static boolean
displayEquals
(Display d1, Display d2) Returns true if the two displays contain the same information.static boolean
displayHasValidDisplayLimits
(Display display) Checks whether the display limits are non-null and non-NaN.static Display
Extracts the display information if present.static NumberFormat
The default format for numbers.static DateTimeFormatter
The default object to format and parse timestamps.static ValueFormat
The default format for VTypes.static Double
Normalizes the given value according to the given range;static Double
Normalizes the given value according to the given display information.static Double
Extracts the numericValueOf the object and normalizes according to the display range.static ListNumber
numericColumnOf
(VTable table, String columnName) Extracts the values of a column, making sure it contains numeric values.static Double
numericValueOf
(Object obj) Extracts a numeric value for the object.static void
Changes the color map for AlarmSeverity.static void
setDefaultNumberFormat
(NumberFormat defaultNumberFormat) Changes the default format for numbers.static void
setDefaultTimestampFormat
(DateTimeFormatter defaultTimestampFormat) Changes the default timestamp format.static void
setDefaultValueFormat
(ValueFormat defaultValueFormat) Changes the default format for VTypes.stringColumnOf
(VTable table, String columnName) Extracts the values of a column, making sure it contains strings.static VNumberArray
subArray
(VNumberArray array, int index) Filters an element of a one-dimensional array.static Time
Extracts the time information if present.static BufferedImage
Converts a VImage to an AWT BufferedImage, so that it can be displayed.static VImage
toVImage
(BufferedImage image) Converts an AWT BufferedImage to a VImage.static Class<?>
Returns the type of the object by returning the class object of one of the VXxx interfaces.
-
Method Details
-
typeOf
Returns the type of the object by returning the class object of one of the VXxx interfaces. The getClass() methods returns the concrete implementation type, which is of little use. If no super-interface is found, Object.class is used.- Parameters:
obj
- an object implementing a standard type- Returns:
- the type is implementing
-
alarmOf
Extracts the alarm information if present.- Parameters:
obj
- an object implementing a standard type- Returns:
- the alarm information for the object
-
timeOf
Extracts the time information if present.- Parameters:
obj
- an object implementing a standard type- Returns:
- the time information for the object
-
displayOf
Extracts the display information if present.- Parameters:
obj
- an object implementing a standard type- Returns:
- the display information for the object
-
displayHasValidDisplayLimits
Checks whether the display limits are non-null and non-NaN.- Parameters:
display
- a display- Returns:
- true if the display limits have actual values
-
normalizedNumericValueOf
Extracts the numericValueOf the object and normalizes according to the display range.- Parameters:
obj
- an object implementing a standard type- Returns:
- the value normalized in its display range, or null if no value or display information is present
-
normalize
Normalizes the given value according to the given display information.- Parameters:
value
- a valuedisplay
- the display information- Returns:
- the normalized value, or null of either value or display is null
-
normalize
Normalizes the given value according to the given range;- Parameters:
value
- a valuelowValue
- the lowest value in the rangehighValue
- the highest value in the range- Returns:
- the normalized value, or null if any value is null
-
numericValueOf
Extracts a numeric value for the object. If it's a numeric scalar, the value is returned. If it's a numeric array, the first element is returned. If it's a numeric multi array, the value of the first element is returned.- Parameters:
obj
- an object implementing a standard type- Returns:
- the numeric value
-
toImage
Converts a VImage to an AWT BufferedImage, so that it can be displayed. The content of the vImage buffer is copied, so further changes to the VImage will not modify the BufferedImage.- Parameters:
vImage
- the image to be converted- Returns:
- a new BufferedImage
-
toVImage
Converts an AWT BufferedImage to a VImage.Currently, only TYPE_3BYTE_BGR is supported
- Parameters:
image
- buffered image- Returns:
- a new image
-
displayEquals
Returns true if the two displays contain the same information.- Parameters:
d1
- the first displayd2
- the second display- Returns:
- true if they match
-
setAlarmSeverityColorMap
Changes the color map for AlarmSeverity. The new color map must be complete and not null;- Parameters:
map
- the new color map
-
colorFor
Returns the rgb value for the given severity.- Parameters:
severity
- an alarm severity- Returns:
- the rgb color
-
getDefaultTimestampFormat
The default object to format and parse timestamps.- Returns:
- the default timestamp format
-
setDefaultTimestampFormat
Changes the default timestamp format.- Parameters:
defaultTimestampFormat
- the new default timestamp format
-
getDefaultNumberFormat
The default format for numbers.- Returns:
- the default number format
-
setDefaultNumberFormat
Changes the default format for numbers.- Parameters:
defaultNumberFormat
- the new default number format
-
getDefaultValueFormat
The default format for VTypes.- Returns:
- the default format
-
setDefaultValueFormat
Changes the default format for VTypes.- Parameters:
defaultValueFormat
- the new default format
-
numericColumnOf
Extracts the values of a column, making sure it contains numeric values.- Parameters:
table
- a tablecolumnName
- the name of the column to extract- Returns:
- the values; null if the columnName is null or is not found
- Throws:
IllegalArgumentException
- if the column is found but does not contain numeric values
-
stringColumnOf
Extracts the values of a column, making sure it contains strings.- Parameters:
table
- a tablecolumnName
- the name of the column to extract- Returns:
- the values; null if the columnName is null or is not found
- Throws:
IllegalArgumentException
- if the column is found but does not contain string values
-
defaultArrayDisplay
Returns the default array dimension display by looking at the size of the n dimensional array and creating cell boundaries based on index.- Parameters:
array
- the array- Returns:
- the array dimension display
-
defaultArrayDisplay
Returns the default array dimension display given the size of the n dimensional array and creating cell boundaries based on index.- Parameters:
sizes
- the shape of the array- Returns:
- the array dimension display
-
subArray
Filters an element of a one-dimensional array.- Parameters:
array
- a 1D arrayindex
- a valid index- Returns:
- the trimmed array to that one index
-