Module x3d

Class Util

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

public class Util extends Object
This class provides usefull static methods for recurring tasks.
Author:
Udo Bischof, Uwe Mannl
  • Constructor Details

    • Util

      public Util()
  • Method Details

    • splitStringToArray2f

      public static float[] splitStringToArray2f(String value)
      Parameters:
      value -
      Returns:
    • splitStringToArray2f

      public static float[] splitStringToArray2f(String value, float default1, float default2)
      Parameters:
      value - String value
      default1 -
      default2 -
      Returns:
    • splitStringToArray3d

      public static double[] splitStringToArray3d(String value)
      Parameters:
      value -
      Returns:
    • splitStringToArray3f

      public static float[] splitStringToArray3f(String value)
      Parameters:
      value -
      Returns:
    • splitStringToArray3d

      public static double[] splitStringToArray3d(String value, double default1, double default2, double default3)
      Parameters:
      value - String value
      default1 -
      default2 -
      default3 -
      Returns:
    • splitStringToArray3f

      public static float[] splitStringToArray3f(String value, float default1, float default2, float default3)
      Parameters:
      value - String value
      default1 -
      default2 -
      default3 -
      Returns:
    • splitStringToTuple2f

      public static Tuple2f splitStringToTuple2f(Tuple2f result, String value)
      Parameters:
      result - Tuple2f result
      value - String value (must not be null!)
      Returns:
    • convertStringToTuple3f

      public static Tuple3f convertStringToTuple3f(Tuple3f result, String value)
      Split string and convert into groimp coordinates.
      Parameters:
      result - Tuple3f result
      value - String value (must not be null!)
      Returns:
    • splitStringToTuple3f

      public static Tuple3f splitStringToTuple3f(Tuple3f result, String value)
      Split string without convert.
      Parameters:
      result - Tuple3f result
      value - String value (must not be null!)
      Returns:
    • convertStringToTuple3d

      public static Tuple3d convertStringToTuple3d(Tuple3d result, String value)
      Split string and convert into groimp coordinates.
      Parameters:
      result - Tuple3d result
      value - String value (must not be null!)
      Returns:
    • splitStringToTuple3d

      public static Tuple3d splitStringToTuple3d(Tuple3d result, String value)
      Split string without convert.
      Parameters:
      result - Tuple3d result
      value - String value (must not be null!)
      Returns:
    • splitStringToTuple4f

      public static Tuple4f splitStringToTuple4f(Tuple4f result, String value)
      Split string without convert.
      Parameters:
      result - Tuple4f result
      value - String value (must not be null!)
      Returns:
    • convertStringToTuple4f

      public static Tuple4f convertStringToTuple4f(Tuple4f result, String value)
      Split string and convert into groimp coordinates.
      Parameters:
      result - Tuple4f result
      value - String value (must not be null!)
      Returns:
    • convertStringToAxisAngle4d

      public static AxisAngle4d convertStringToAxisAngle4d(AxisAngle4d result, String value)
      Split string and convert into groimp coordinates.
      Parameters:
      result - AxisAngle4d result
      value - String value (must not be null!)
      Returns:
    • splitStringToAxisAngle4d

      public static AxisAngle4d splitStringToAxisAngle4d(AxisAngle4d result, String value)
      Split string without convert.
      Parameters:
      result - AxisAngle4d result
      value - String value (must not be null!)
      Returns:
    • splitStringToArrayOfInt

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

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

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

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

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

      public static double[] splitStringToArrayOfDouble(String value, double[] def)
      Parameters:
      value - String with double values
      def - default values
      Returns:
    • splitStringToArrayOfString

      public static String[] splitStringToArrayOfString(String value)
      Splits a string containing multiple strings to an array of strings. The original string can have one of the following forms:
      • '"bla" "ble"'
      • '"bla","ble"'
      • '"bla"'
      • 'bla'
      • "bla"
      Parameters:
      value - String with String values
      def - default values
      Returns:
    • splitStringToArrayOfString

      public static String[] splitStringToArrayOfString(String value, String[] def)
      Splits a string containing multiple strings to an array of strings. The original string can have one of the following forms:
      • '"bla" "ble"'
      • '"bla","ble"'
      • '"bla"'
      • 'bla'
      • "bla"
      Parameters:
      value - String with String values
      def - default values
      Returns:
    • splitStringToArray4d

      public static double[] splitStringToArray4d(String value)
      Split String on Whitespaces and return values as double-Array
      Parameters:
      value -
      Returns:
    • splitStringToArray4f

      public static float[] splitStringToArray4f(String value)
      Split String on Whitespaces and return values as double-Array
      Parameters:
      value -
      Returns:
    • splitStringToArray4d

      public static double[] splitStringToArray4d(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(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:
    • getRealPath

      public static String getRealPath(URL url)
      Extract the path-part as a String from the URL.
      Parameters:
      URL - url
      Returns:
      String path without the filename
    • getRealPath

      public static String getRealPath(File file)
      Extract the path-part as a String from the URL.
      Parameters:
      File - file
      Returns:
      String path without the filename
    • getRealPath

      public static String getRealPath(FileSource file)
      Extract the path-part as a String from the FileSource.
      Returns:
      String path without the filename
    • 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:
    • 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:
    • pointsOnLine

      public static boolean pointsOnLine(ArrayList<Point3d> points)
      Checks if given points are on a straight line.
      Parameters:
      vectors -
      Returns:
    • splitStringToListOfStrings

      public static List<String> splitStringToListOfStrings(String value)
    • intToRGB

      public static RGBColor intToRGB(int color)
    • intToGray

      public static float intToGray(int color)
    • getImageForURL

      public static ImageAdapter getImageForURL(String imgUrl, boolean saveInGroIMP)
    • getImageForURL

      public static ImageAdapter getImageForURL(List<String> imgURL, HashMap<String,String> valueMap, boolean saveInGroIMP)
    • colorToInt

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

      public static int colorToInt(Tuple3f color)
      Converts a Tuple3f color object (range from 0-1) to an int color.
      Parameters:
      color -
      Returns:
    • 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:
    • round

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