|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object visad.util.DataUtility
public class DataUtility
A general utility class for VisAD Data objects
Nested Class Summary | |
---|---|
static class |
DataUtility.RealTupleComparator
Provides support for comparing RealTuple-s of the same RealTupleType. |
Constructor Summary | |
---|---|
DataUtility()
|
Method Summary | |
---|---|
static String |
cleanTypeName(String name)
Make a valid VisAD RealType name from the string. |
static Field |
consolidate(Field[] fields)
Consolidates fields. |
static String |
convertMapsToString(ScalarMap[] sm)
Converts the given array of mappings to an easy-to-read String form. |
static String |
convertMapsToString(Vector v)
Converts the given vector of mappings to an easy-to-read String form. |
static ScalarMap[] |
convertStringToMaps(String mapString,
Data[] data,
boolean showErrors)
Converts the given map string to its corresponding array of mappings. |
static ScalarMap[] |
convertStringToMaps(String mapString,
Data data,
boolean showErrors)
Converts the given map string to its corresponding array of mappings. |
static ScalarMap[] |
convertStringToMaps(String mapString,
Vector types,
boolean showErrors)
Converts the given map string to its corresponding array of mappings. |
static GriddedSet |
createGriddedSet(FlatField field,
boolean copy)
Creates a GriddedSet from a FlatField. |
static Field |
ensureRange(Field field,
MathType newRangeType)
Ensures that the range of a Field is a given type. |
static RealTupleType |
ensureRealTupleType(MathType type)
Ensures that a MathType is a RealTupleType. |
static TupleIface |
ensureTuple(Data datum)
Ensures that a Data is a Tuple. |
static TupleType |
ensureTupleType(MathType type)
Ensures that a MathType is a TupleType. |
static Image |
extractImage(FlatField field,
boolean reverse)
Converts a flat field of the form ((x, y) -> (r, g, b)) to an AWT Image. |
static int |
getComponentIndex(Function function,
MathType componentType)
Gets the index of a component in the range of a Function. |
static int |
getComponentIndex(Set set,
MathType componentType)
Gets the index of a component in a Set. |
static int |
getComponentIndex(TupleType tupleType,
MathType componentType)
Gets the index of a component in a TupleType. |
static RealTupleType |
getDomainType(Function function)
Gets the MathType of the domain of a Function. |
static RealTupleType |
getDomainType(Set set)
Gets the MathType of the domain of a Set. |
static RealTupleType |
getFlatRangeType(Function function)
Gets the MathType of the flat-range of a Function. |
static FlatField[] |
getImageFields(Data data)
|
static float[][] |
getPixels(FlatField image)
|
static int |
getRangeDimension(Function function)
Gets the number of components in the range of a Function. |
static TupleType |
getRangeTupleType(Function function)
Gets the TupleType of the range of a Function. |
static MathType |
getRangeType(Function function)
Gets the MathType of the range of a Function. |
static Unit[] |
getRangeUnits(FlatField field)
Gets the units of the (flat) components of the range of a FlatField. |
static int |
getRealTypes(Data[] data,
Vector v,
boolean keepDupl,
boolean doCoordSys)
Deprecated. Use getScalarTypes(Data[], Vector, boolean, boolean) instead. |
static int |
getRealTypes(Data data,
Vector v)
Deprecated. Use getScalarTypes(Data, Vector) instead. |
static RealTuple |
getSample(Set set,
int index)
Gets the specified sample of a VisAD Set. |
static int |
getScalarTypes(Data[] data,
Vector v,
boolean keepDupl,
boolean doCoordSys)
Obtains a Vector consisting of all ScalarTypes present in an array of Data objects' MathTypes. |
static int |
getScalarTypes(Data data,
Vector v)
Obtains a Vector consisting of all ScalarTypes present in a Data object's MathType. |
static RealType |
getUniqueRealType(String name,
Unit unit)
Make a RealType with a unique name for the given unit |
static RealType |
getUniqueRealType(String name,
Unit unit,
Set set,
int attrMask)
Make a RealType with a unique name for the given unit |
static ScalarMap[] |
guessMaps(MathType[] types,
boolean allow3d)
Attempts to guess a good set of mappings for a display containing Data objects of the given types. |
static boolean |
isSerializable(Object obj)
Verify that an object is Serializable by attempting to serialize it. |
static boolean |
isSerializable(Object obj,
boolean printStackTraces)
Verify that an object is Serializable by attempting to serialize it. |
static void |
main(String[] argv)
|
static FlatField |
makeField(Image image)
Create a VisAD Data object from the given Image |
static FlatField |
makeField(Image image,
boolean withAlpha)
Create a VisAD Data object from the given Image |
static FlatField |
makeImage(float[][] values)
return a FlatField for a simple image from values[nlines][nelements] |
static DataImpl |
makeLocal(Data data)
Converts a remote Data object to a local Data object. |
static DataImpl |
makeLocal(Data data,
boolean printStackTraces)
Converts a remote Data object to a local Data object. |
static DisplayImpl |
makeSimpleDisplay(DataImpl data)
|
static void |
setPixels(FlatField image,
float[][] values)
set pixel values in a simple image, indexed as values[line][element] |
static MathType |
simplify(MathType type)
Simplifies a MathType. |
static Tuple |
stringsToTuple(String[] s)
Converts an array of strings into a VisAD Tuple. |
static Tuple |
stringsToTuple(String[] s,
boolean printStackTraces)
Converts an array of strings into a VisAD Tuple. |
static String[] |
tupleToStrings(Tuple t)
Converts a VisAD tuple into an array of strings. |
static String[] |
tupleToStrings(Tuple t,
boolean printStackTraces)
Converts a VisAD tuple into an array of strings. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DataUtility()
Method Detail |
---|
public static FlatField makeImage(float[][] values) throws VisADException, RemoteException
VisADException
RemoteException
public static void setPixels(FlatField image, float[][] values) throws VisADException, RemoteException
VisADException
RemoteException
public static float[][] getPixels(FlatField image) throws VisADException, RemoteException
VisADException
RemoteException
public static FlatField makeField(Image image) throws IOException, VisADException
image
- image to use
IOException
VisADException
public static FlatField makeField(Image image, boolean withAlpha) throws IOException, VisADException
image
- image to usewithAlpha
- include Alpha in the field if the image ColorModel
supports it and the image is not opaque.
IOException
VisADException
public static Image extractImage(FlatField field, boolean reverse)
public static FlatField[] getImageFields(Data data)
public static DisplayImpl makeSimpleDisplay(DataImpl data) throws VisADException, RemoteException
VisADException
RemoteException
public static void main(String[] argv) throws VisADException, RemoteException
VisADException
RemoteException
public static RealTupleType ensureRealTupleType(MathType type) throws TypeException, VisADException
type
- The math type to be "converted" to a
RealTupleType. It shall be either a RealType,
a RealTupleType, or a SetType.
type
.
If type
is a RealTupleType, then
it is returned; otherwise, if type
is a RealType, then a RealTupleType
containing type
as the
only component is returned; otherwise,
if type
is a SetType, then
((SetType)type).getDomain()
is
returned.
TypeException
- type
is the wrong type: it can't
be converted into a RealTupleType.
VisADException
- Couldn't create necessary VisAD object.public static TupleType ensureTupleType(MathType type) throws VisADException
type
- The math type to be "converted" to a TupleType.
type
.
If type
is a TupleType,
then it is returned; otherwise, if
type
is a SetType, then
((SetType)type).getDomain()
is
returned; otherwise, a TupleType containing
type
as the only component is
returned (if type
is a RealType,
then the returned TupleType is a RealTupleType);
VisADException
- Couldn't create necessary VisAD object.public static TupleIface ensureTuple(Data datum) throws VisADException, RemoteException
datum
- The math type to be "converted" to a Tuple.
datum
. If
datum
is a Tuple, then it is
returned; otherwise, if datum
is
a Real, then a RealTuple containing
datum
as the only component is returned;
otherwise, a Tuple containing datum
as the only component is returned.
VisADException
- Couldn't create necessary VisAD object.
RemoteException
- Java RMI failure.public static RealTupleType getDomainType(Set set)
set
- A set.
public static RealTupleType getDomainType(Function function) throws VisADException, RemoteException
function
- A function.
VisADException
- Couldn't create necessary VisAD object.
RemoteException
- Java RMI failure.public static MathType getRangeType(Function function) throws VisADException, RemoteException
function
- A function.
VisADException
- Couldn't create necessary VisAD object.
RemoteException
- Java RMI failure.public static TupleType getRangeTupleType(Function function) throws VisADException, RemoteException
function
- A function.
VisADException
- Couldn't create necessary VisAD object.
RemoteException
- Java RMI failure.public static RealTupleType getFlatRangeType(Function function) throws VisADException, RemoteException
function
- A function.
VisADException
- Couldn't create necessary VisAD object.
RemoteException
- Java RMI failure.public static int getRangeDimension(Function function) throws VisADException, RemoteException
function
- A function.
VisADException
- Couldn't create necessary VisAD object.
RemoteException
- Java RMI failure.public static int getComponentIndex(TupleType tupleType, MathType componentType) throws VisADException, RemoteException
equals(Object)
method. If none is
found, then this method looks for an approximate match based on the
equalsExceptNameButUnits(MathType)
method.
tupleType
- The type of the tuple.componentType
- The MathType of the component.
VisADException
- Couldn't create necessary VisAD object.
RemoteException
- Java RMI failure.public static int getComponentIndex(Set set, MathType componentType) throws VisADException, RemoteException
set
- The Set.componentType
- The MathType of the component.
VisADException
- Couldn't create necessary VisAD object.
RemoteException
- Java RMI failure.public static int getComponentIndex(Function function, MathType componentType) throws VisADException, RemoteException
function
- The Function.componentType
- The MathType of the component.
VisADException
- Couldn't create necessary VisAD object.
RemoteException
- Java RMI failure.public static Field ensureRange(Field field, MathType newRangeType) throws UnimplementedException, TypeException, VisADException, RemoteException
field
- The input field.newRangeType
- The desired type of range for the resulting
field.
.isMissing()
will be
true.
UnimplementedException
- The desired range type is a TupleType and not
a RealTupleType.
TypeException
- The new range type cannot be the range of a
field.
VisADException
- Couldn't create necessary VisAD object.
RemoteException
- Java RMI failure.public static Field consolidate(Field[] fields) throws FieldException, TypeException, VisADException, RemoteException
fields
- The fields to consolidate. Each field shall
have the same FunctionType.
FieldException
- The Field array has zero length.
TypeException
- Input Field-s not all same type.
VisADException
- Couldn't create necessary VisAD object.
RemoteException
- Java RMI failure.public static GriddedSet createGriddedSet(FlatField field, boolean copy) throws VisADException, RemoteException
field
- The FlatField from which to create a GriddedSet.copy
- Whether or not to copy the range values from
the field (i.e. field.getFloats(copy)
).
VisADException
- Couldn't create necessary VisAD object.
RemoteException
- Java RMI failure.public static MathType simplify(MathType type) throws VisADException
type
- The MathType to be simplified.
type
.
VisADException
- Couldn't create necessary VisAD object.public static int getRealTypes(Data data, Vector v) throws VisADException, RemoteException
VisADException
RemoteException
public static int getRealTypes(Data[] data, Vector v, boolean keepDupl, boolean doCoordSys) throws VisADException, RemoteException
VisADException
RemoteException
public static int getScalarTypes(Data data, Vector v) throws VisADException, RemoteException
data
- The Data from which to extract the ScalarTypes.v
- The Vector in which to store the ScalarTypes.
VisADException
- Couldn't parse the Data's MathType.
RemoteException
- Couldn't obtain the remote Data's MathType.public static int getScalarTypes(Data[] data, Vector v, boolean keepDupl, boolean doCoordSys) throws VisADException, RemoteException
data
- The array of Data from which to extract the
ScalarTypes.v
- The Vector in which to store the ScalarTypes.keepDupl
- Whether to add a RealType to the Vector when
it is already present there.doCoordSys
- Whether to include ScalarTypes from
CoordinateSystem references.
VisADException
- Couldn't parse a Data's MathType.
RemoteException
- Couldn't obtain a remote Data's MathType.public static ScalarMap[] guessMaps(MathType[] types, boolean allow3d)
public static String convertMapsToString(Vector v)
public static String convertMapsToString(ScalarMap[] sm)
public static ScalarMap[] convertStringToMaps(String mapString, Data data, boolean showErrors)
mapString
- The String from which to extract the ScalarMaps.data
- The Data object to search for valid ScalarTypes.showErrors
- Whether to output errors to stdout.public static ScalarMap[] convertStringToMaps(String mapString, Data[] data, boolean showErrors)
mapString
- The String from which to extract the ScalarMaps.data
- The Data objects to search for valid ScalarTypes.showErrors
- Whether to output errors to stdout.public static ScalarMap[] convertStringToMaps(String mapString, Vector types, boolean showErrors)
mapString
- The String from which to extract the ScalarMaps.types
- List of valid ScalarTypes.showErrors
- Whether to output errors to stdout.public static Tuple stringsToTuple(String[] s)
s
- The array of strings to be converted to a VisAD Tuple.
public static Tuple stringsToTuple(String[] s, boolean printStackTraces)
s
- The array of strings to be converted to a VisAD Tuple.printStackTraces
- true if the stack trace for
any exception should be printed.
public static String[] tupleToStrings(Tuple t)
t
- The VisAD Tuple to be converted to an array of strings.
public static String[] tupleToStrings(Tuple t, boolean printStackTraces)
t
- The VisAD Tuple to be converted to an array of strings.printStackTraces
- true if the stack trace for
any exception should be printed.
public static boolean isSerializable(Object obj)
obj
- An object which needs to be serialized
public static boolean isSerializable(Object obj, boolean printStackTraces)
obj
- An object which needs to be serializedprintStackTraces
- true if the stack trace for
any exception should be printed.
public static DataImpl makeLocal(Data data)
data
- The Data object to be made local.
public static DataImpl makeLocal(Data data, boolean printStackTraces)
data
- The Data object to be made local.printStackTraces
- true if the stack trace for
any exception should be printed.
public static RealTuple getSample(Set set, int index) throws VisADException, RemoteException
set
- The set to have a sample returned.index
- The index of the sample to be returned.
VisADException
- Couldn't create necessary VisAD object.
RemoteException
- Java RMI failure.public static Unit[] getRangeUnits(FlatField field)
field
- The FlatField.
null
.public static RealType getUniqueRealType(String name, Unit unit)
name
- name of the RealTypeunit
- the default unit
VisADException
- problem creating the RealTypepublic static RealType getUniqueRealType(String name, Unit unit, Set set, int attrMask)
name
- name of the RealTypeunit
- the default unitset
- the default setattrMask
- the attribute mask
public static String cleanTypeName(String name)
name
- name to clean
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |