de.grogra.ext.x3d.util
Class Util

java.lang.Object
  extended by de.grogra.ext.x3d.util.Util

public class Util
extends java.lang.Object

This class provides usefull static methods for recurring tasks.

Author:
Udo Bischof, Uwe Mannl

Constructor Summary
Util()
           
 
Method Summary
static int colorToInt(Tuple3f color)
          Converts a Tuple3f color object (range from 0-1) to an int color.
static int colorToInt(Tuple4f color)
          Converts a Tuple4f color object (range from 0-1) to an int color.
static AxisAngle4d convertStringToAxisAngle4d(AxisAngle4d result, java.lang.String value)
          Split string and convert into groimp coordinates.
static Tuple3d convertStringToTuple3d(Tuple3d result, java.lang.String value)
          Split string and convert into groimp coordinates.
static Tuple3f convertStringToTuple3f(Tuple3f result, java.lang.String value)
          Split string and convert into groimp coordinates.
static Tuple4f convertStringToTuple4f(Tuple4f result, java.lang.String value)
          Split string and convert into groimp coordinates.
static Vector3d findOrthogonalVector(Vector3d vec1)
          Returns an orthogonal vector to given vector.
static ImageAdapter getImageForURL(java.util.List<java.lang.String> imgURL, java.util.HashMap<java.lang.String,java.lang.String> valueMap, boolean saveInGroIMP)
           
static ImageAdapter getImageForURL(java.lang.String imgUrl, boolean saveInGroIMP)
           
static java.lang.String getRealPath(java.io.File file)
          Extract the path-part as a String from the URL.
static java.lang.String getRealPath(java.net.URL url)
          Extract the path-part as a String from the URL.
static float intToGray(int color)
           
static RGBColor intToRGB(int color)
           
static int overlapPixel(int background, int foreground)
          Calculates to an background pixel a new foreground pixel in consideration of transparency of foreground pixel.
static boolean pointsOnLine(java.util.ArrayList<Point3d> points)
          Checks if given points are on a straight line.
static int round(double value)
          Rounds the value with the Math.round() function and casts the result to int.
static float[] splitStringToArray2f(java.lang.String value)
           
static float[] splitStringToArray2f(java.lang.String value, float default1, float default2)
           
static double[] splitStringToArray3d(java.lang.String value)
           
static double[] splitStringToArray3d(java.lang.String value, double default1, double default2, double default3)
           
static float[] splitStringToArray3f(java.lang.String value)
           
static float[] splitStringToArray3f(java.lang.String value, float default1, float default2, float default3)
           
static double[] splitStringToArray4d(java.lang.String value)
          Split String on Whitespaces and return values as double-Array
static double[] splitStringToArray4d(java.lang.String value, double default1, double default2, double default3, double default4)
          Split String on Whitespaces and return values as double-Array
static float[] splitStringToArray4f(java.lang.String value)
          Split String on Whitespaces and return values as double-Array
static float[] splitStringToArray4f(java.lang.String value, float default1, float default2, float default3, float default4)
          Split String on Whitespaces and return values as double-Array
static double[] splitStringToArrayOfDouble(java.lang.String value)
           
static double[] splitStringToArrayOfDouble(java.lang.String value, double[] def)
           
static float[] splitStringToArrayOfFloat(java.lang.String value)
           
static float[] splitStringToArrayOfFloat(java.lang.String value, float[] defaultArray)
           
static int[] splitStringToArrayOfInt(java.lang.String value)
           
static int[] splitStringToArrayOfInt(java.lang.String value, int[] defaultArray)
           
static java.lang.String[] splitStringToArrayOfString(java.lang.String value)
          Splits a string containing multiple strings to an array of strings.
static java.lang.String[] splitStringToArrayOfString(java.lang.String value, java.lang.String[] def)
          Splits a string containing multiple strings to an array of strings.
static AxisAngle4d splitStringToAxisAngle4d(AxisAngle4d result, java.lang.String value)
          Split string without convert.
static java.util.List<java.lang.String> splitStringToListOfStrings(java.lang.String value)
           
static Tuple2f splitStringToTuple2f(Tuple2f result, java.lang.String value)
           
static Tuple3d splitStringToTuple3d(Tuple3d result, java.lang.String value)
          Split string without convert.
static Tuple3f splitStringToTuple3f(Tuple3f result, java.lang.String value)
          Split string without convert.
static Tuple4f splitStringToTuple4f(Tuple4f result, java.lang.String value)
          Split string without convert.
static Matrix4d vectorsToTransMatrix(Vector3d vec1, Vector3d vec2)
          This methode returns a transformation matrix with a rotational component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

colorToInt

public static int colorToInt(Tuple3f color)
Converts a Tuple3f color object (range from 0-1) to an int color.

Parameters:
color -
Returns:

colorToInt

public static int colorToInt(Tuple4f color)
Converts a Tuple4f color object (range from 0-1) to an int color.

Parameters:
color -
Returns:

convertStringToAxisAngle4d

public static AxisAngle4d convertStringToAxisAngle4d(AxisAngle4d result,
                                                     java.lang.String value)
Split string and convert into groimp coordinates.

Parameters:
result - AxisAngle4d result
value - String value (must not be null!)
Returns:

convertStringToTuple3d

public static Tuple3d convertStringToTuple3d(Tuple3d result,
                                             java.lang.String value)
Split string and convert into groimp coordinates.

Parameters:
result - Tuple3d result
value - String value (must not be null!)
Returns:

convertStringToTuple3f

public static Tuple3f convertStringToTuple3f(Tuple3f result,
                                             java.lang.String value)
Split string and convert into groimp coordinates.

Parameters:
result - Tuple3f result
value - String value (must not be null!)
Returns:

convertStringToTuple4f

public static Tuple4f convertStringToTuple4f(Tuple4f result,
                                             java.lang.String value)
Split string and convert into groimp coordinates.

Parameters:
result - Tuple4f result
value - String value (must not be null!)
Returns:

findOrthogonalVector

public static Vector3d findOrthogonalVector(Vector3d vec1)
Returns an orthogonal vector to given vector. This is undefined in any direction and not normalized.

Parameters:
vec1 -
Returns:

getImageForURL

public static ImageAdapter getImageForURL(java.util.List<java.lang.String> imgURL,
                                          java.util.HashMap<java.lang.String,java.lang.String> valueMap,
                                          boolean saveInGroIMP)

getImageForURL

public static ImageAdapter getImageForURL(java.lang.String imgUrl,
                                          boolean saveInGroIMP)

getRealPath

public static java.lang.String getRealPath(java.io.File file)
Extract the path-part as a String from the URL.

Parameters:
File - file
Returns:
String path without the filename

getRealPath

public static java.lang.String getRealPath(java.net.URL url)
Extract the path-part as a String from the URL.

Parameters:
URL - url
Returns:
String path without the filename

intToGray

public static float intToGray(int color)

intToRGB

public static RGBColor intToRGB(int color)

overlapPixel

public static int overlapPixel(int background,
                               int foreground)
Calculates to an background pixel a new foreground pixel in consideration of transparency of foreground pixel.

Parameters:
background -
foreground -
Returns:

pointsOnLine

public static boolean pointsOnLine(java.util.ArrayList<Point3d> points)
Checks if given points are on a straight line.

Parameters:
vectors -
Returns:

round

public static int round(double value)
Rounds the value with the Math.round() function and casts the result to int.

Parameters:
value -
Returns:

splitStringToArray2f

public static float[] splitStringToArray2f(java.lang.String value)
Parameters:
value -
Returns:

splitStringToArray2f

public static float[] splitStringToArray2f(java.lang.String value,
                                           float default1,
                                           float default2)
Parameters:
value - String value
default1 -
default2 -
Returns:

splitStringToArray3d

public static double[] splitStringToArray3d(java.lang.String value)
Parameters:
value -
Returns:

splitStringToArray3d

public static double[] splitStringToArray3d(java.lang.String value,
                                            double default1,
                                            double default2,
                                            double default3)
Parameters:
value - String value
default1 -
default2 -
default3 -
Returns:

splitStringToArray3f

public static float[] splitStringToArray3f(java.lang.String value)
Parameters:
value -
Returns:

splitStringToArray3f

public static float[] splitStringToArray3f(java.lang.String value,
                                           float default1,
                                           float default2,
                                           float default3)
Parameters:
value - String value
default1 -
default2 -
default3 -
Returns:

splitStringToArray4d

public static double[] splitStringToArray4d(java.lang.String value)
Split String on Whitespaces and return values as double-Array

Parameters:
value -
Returns:

splitStringToArray4d

public static double[] splitStringToArray4d(java.lang.String value,
                                            double default1,
                                            double default2,
                                            double default3,
                                            double default4)
Split String on Whitespaces and return values as double-Array

Parameters:
value - String value
default1 -
default2 -
default3 -
default4 -
Returns:

splitStringToArray4f

public static float[] splitStringToArray4f(java.lang.String value)
Split String on Whitespaces and return values as double-Array

Parameters:
value -
Returns:

splitStringToArray4f

public static float[] splitStringToArray4f(java.lang.String value,
                                           float default1,
                                           float default2,
                                           float default3,
                                           float default4)
Split String on Whitespaces and return values as double-Array

Parameters:
value - String value
default1 -
default2 -
default3 -
default4 -
Returns:

splitStringToArrayOfDouble

public static double[] splitStringToArrayOfDouble(java.lang.String value)
Parameters:
value - String with double values
Returns:

splitStringToArrayOfDouble

public static double[] splitStringToArrayOfDouble(java.lang.String value,
                                                  double[] def)
Parameters:
value - String with double values
def - default values
Returns:

splitStringToArrayOfFloat

public static float[] splitStringToArrayOfFloat(java.lang.String value)
Parameters:
value - String with float values
def - default values
Returns:

splitStringToArrayOfFloat

public static float[] splitStringToArrayOfFloat(java.lang.String value,
                                                float[] defaultArray)
Parameters:
value - String with float values
def - default values
Returns:

splitStringToArrayOfInt

public static int[] splitStringToArrayOfInt(java.lang.String value)
Parameters:
value - String with int values
def - default values
Returns:

splitStringToArrayOfInt

public static int[] splitStringToArrayOfInt(java.lang.String value,
                                            int[] defaultArray)
Parameters:
value - String with int values
def - default values
Returns:

splitStringToArrayOfString

public static java.lang.String[] splitStringToArrayOfString(java.lang.String value)
Splits a string containing multiple strings to an array of strings. The original string can have one of the following forms:

Parameters:
value - String with String values
def - default values
Returns:

splitStringToArrayOfString

public static java.lang.String[] splitStringToArrayOfString(java.lang.String value,
                                                            java.lang.String[] def)
Splits a string containing multiple strings to an array of strings. The original string can have one of the following forms:

Parameters:
value - String with String values
def - default values
Returns:

splitStringToAxisAngle4d

public static AxisAngle4d splitStringToAxisAngle4d(AxisAngle4d result,
                                                   java.lang.String value)
Split string without convert.

Parameters:
result - AxisAngle4d result
value - String value (must not be null!)
Returns:

splitStringToListOfStrings

public static java.util.List<java.lang.String> splitStringToListOfStrings(java.lang.String value)

splitStringToTuple2f

public static Tuple2f splitStringToTuple2f(Tuple2f result,
                                           java.lang.String value)
Parameters:
result - Tuple2f result
value - String value (must not be null!)
Returns:

splitStringToTuple3d

public static Tuple3d splitStringToTuple3d(Tuple3d result,
                                           java.lang.String value)
Split string without convert.

Parameters:
result - Tuple3d result
value - String value (must not be null!)
Returns:

splitStringToTuple3f

public static Tuple3f splitStringToTuple3f(Tuple3f result,
                                           java.lang.String value)
Split string without convert.

Parameters:
result - Tuple3f result
value - String value (must not be null!)
Returns:

splitStringToTuple4f

public static Tuple4f splitStringToTuple4f(Tuple4f result,
                                           java.lang.String value)
Split string without convert.

Parameters:
result - Tuple4f result
value - String value (must not be null!)
Returns:

vectorsToTransMatrix

public static Matrix4d vectorsToTransMatrix(Vector3d vec1,
                                            Vector3d vec2)
This methode returns a transformation matrix with a rotational component. The rotation transforms the vec1 to vec2.

Parameters:
vec1 -
vec2 -
Returns: