Package jme

Class JMEUtil

java.lang.Object
jme.JMEUtil

public abstract class JMEUtil extends Object
  • Field Details

  • Constructor Details

    • JMEUtil

      public JMEUtil()
  • Method Details

    • growArray

      public static int[] growArray(int[] array, int newSize)
    • copyArray

      public static int[] copyArray(int[] array)
    • growArray

      public static <T> T[] growArray(T[] array, int newSize)
    • copyOf

      public static <T> T[] copyOf(T[] original, int newLength)
      Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain null. Such indices will exist if and only if the specified length is greater than that of the original array. The resulting array is of exactly the same class as the original array.
      Type Parameters:
      T - the class of the objects in the array
      Parameters:
      original - the array to be copied
      newLength - the length of the copy to be returned
      Returns:
      a copy of the original array, truncated or padded with nulls to obtain the specified length
      Throws:
      NegativeArraySizeException - if newLength is negative
      NullPointerException - if original is null
      Since:
      1.6
    • copyOf

      public static <T, U> T[] copyOf(U[] original, int newLength, Class<? extends T[]> newType)
      Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain null. Such indices will exist if and only if the specified length is greater than that of the original array. The resulting array is of the class newType.
      Type Parameters:
      T - the class of the objects in the returned array
      U - the class of the objects in the original array
      Parameters:
      original - the array to be copied
      newLength - the length of the copy to be returned
      newType - the class of the copy to be returned
      Returns:
      a copy of the original array, truncated or padded with nulls to obtain the specified length
      Throws:
      NegativeArraySizeException - if newLength is negative
      NullPointerException - if original is null
      ArrayStoreException - if an element copied from original is not of a runtime type that can be stored in an array of class newType
      Since:
      1.6
    • growArray

      public static String[] growArray(String[] array, int newSize)
    • growArray

      public static double[] growArray(double[] array, int newSize)
    • growArray

      public static int[][] growArray(int[][] array, int newSize)
    • equals

      public static boolean equals(int[] a1, int[] a2)
    • intersection

      public static int[] intersection(int[] array1, int[] array2)
    • contains

      public static boolean contains(int[] array, int v)
    • swap

      public static <T> void swap(T[] array, int i, int j)
    • copyArray

      public static int[] copyArray(int[] array, int n)
    • copyArray

      public static String[] copyArray(String[] array)
    • copyArray

      public static double[] copyArray(double[] array)
    • createArray

      public static int[] createArray(int size)
    • createSArray

      public static String[] createSArray(int size)
    • createDArray

      public static double[] createDArray(int size)
    • createLArray

      public static long[] createLArray(int size)
    • createBArray

      public static boolean[] createBArray(int size)
    • createArray

      public static int[][] createArray(int size1, int size2)
    • isHighDPI

      public static boolean isHighDPI()
      Check if the applet is showing in highDPI or not. In a web browser, this can change with the zoom factor, thus this function should be called before each drawing
      Returns:
    • runAsync

      public static void runAsync(JMEUtil.RunAsyncCallback runAsyncCallback)
    • generatePrimes

      public static long[] generatePrimes(int n)
    • nextData

      public static String nextData(StringTokenizer st, String separator)
    • findLineSeparator

      public static String findLineSeparator(String molFile)
    • squareEuclideanDist

      public static double squareEuclideanDist(double x1, double y1, double x2, double y2)
    • dotProduct

      public static double dotProduct(double x1, double y1, double x2, double y2)
    • triangleHeight

      public static double triangleHeight(double a, double b, double c)
      Compute the height of a triangle knowing the length of each side. Use Heron's formula.
      Parameters:
      a -
      b - -base of the triangle
      c -
      Returns:
      height
    • compareAngles

      public static int compareAngles(double sina, double cosa, double sinb, double cosb)
    • stereoTransformation

      public static void stereoTransformation(int[] t, int[] ref)
    • checkAtomicSymbol

      public static int checkAtomicSymbol(String s)
      Return the JME atoming number associated to the given symbol
      Parameters:
      s -
      Returns:
      zLabel index for this symbol
    • getSDFDateLine

      public static String getSDFDateLine(String version)
      See CTFile -- this line is NOT optional. It is critical in showing whether we have a 2D or 3D MOL file.
      Parameters:
      version -
      Returns:
      SDF header line 2 with no \n
    • iformat

      public static String iformat(int number, int len)
      right-justify using spaces
      Parameters:
      number - with no more than len digits
      len - max 8
      Returns:
      right-justified number or ?
    • rightJustify

      public static String rightJustify(String s1, String s2)
    • fformat

      public static String fformat(double number, int len, int dec)
      Truncate to dec digits after the decimal place and left-pad to length len.
      Parameters:
      number -
      len - guaranteed length of string to return
      dec - the number of decimal places or 0 for integer rounding down
      Returns:
      the formatted number or right-justified "?"
    • stringHeight

      public static double stringHeight(FontMetrics fm)
      Provide the ideal height of a string consisting of usual upper case characters. Purpose: centering of String in the center of a box. Does not work for $ , y ; and others
      Parameters:
      fm -
      Returns: