org.epics.pvmanager.data
Class ValueUtil

java.lang.Object
  extended by org.epics.pvmanager.data.ValueUtil

public class ValueUtil
extends java.lang.Object

Various utility methods for runtime handling of the types defined in this package.

Author:
carcassi

Method Summary
static Alarm alarmOf(java.lang.Object obj)
          Extracts the alarm information if present.
static Display displayOf(java.lang.Object obj)
          Extracts the display information if present.
static java.lang.Double normalize(java.lang.Number value, Display display)
          Normalizes the given value according to the given display information.
static java.lang.Double normalize(java.lang.Number value, java.lang.Number lowValue, java.lang.Number highValue)
          Normalizes the given value according to the given range;
static java.lang.Double normalizedNumericValueOf(java.lang.Object obj)
          Extracts the numericValueOf the object and normalizes according to the display range.
static java.lang.Double numericValueOf(java.lang.Object obj)
          Extracts a numeric value for the object.
static
<T extends Time>
java.util.Comparator<T>
timeComparator()
          Returns a comparator with the order defined by the timestamp.
static Time timeOf(java.lang.Object obj)
          Extracts the time information if present.
static java.awt.image.BufferedImage toImage(VImage vImage)
          Converts a VImage to an AWT BufferedImage, so that it can be displayed.
static VImage toVImage(java.awt.image.BufferedImage image)
          Converts an AWT BufferedImage to a VImage.
static java.lang.Class<?> typeOf(java.lang.Object obj)
          Returns the type of the object by returning the class object of one of the VXxx interfaces.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

typeOf

public static java.lang.Class<?> typeOf(java.lang.Object obj)
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

public static Alarm alarmOf(java.lang.Object obj)
Extracts the alarm information if present.

Parameters:
obj - an object implementing a standard type
Returns:
the alarm information for the object

timeOf

public static Time timeOf(java.lang.Object obj)
Extracts the time information if present.

Parameters:
obj - an object implementing a standard type
Returns:
the time information for the object

displayOf

public static Display displayOf(java.lang.Object obj)
Extracts the display information if present.

Parameters:
obj - an object implementing a standard type
Returns:
the display information for the object

normalizedNumericValueOf

public static java.lang.Double normalizedNumericValueOf(java.lang.Object obj)
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

public static java.lang.Double normalize(java.lang.Number value,
                                         Display display)
Normalizes the given value according to the given display information.

Parameters:
value - a value
display - the display information
Returns:
the normalized value, or null of either value or display is null

normalize

public static java.lang.Double normalize(java.lang.Number value,
                                         java.lang.Number lowValue,
                                         java.lang.Number highValue)
Normalizes the given value according to the given range;

Parameters:
value - a value
lowValue - the lowest value in the range
highValue - the highest value in the range
Returns:
the normalized value, or null if any value is null

numericValueOf

public static java.lang.Double numericValueOf(java.lang.Object obj)
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

public static java.awt.image.BufferedImage toImage(VImage vImage)
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

public static VImage toVImage(java.awt.image.BufferedImage image)
Converts an AWT BufferedImage to a VImage.

Currently, only TYPE_3BYTE_BGR is supported

Parameters:
image -
Returns:
a new image

timeComparator

public static <T extends Time> java.util.Comparator<T> timeComparator()
Returns a comparator with the order defined by the timestamp.

Type Parameters:
T - a Time type
Returns:
a comparator