Class ToolBox

java.lang.Object
bdsup2sub.utils.ToolBox

public final class ToolBox extends Object
  • Field Details

    • FPS_FORMATTER

      private static final DecimalFormat FPS_FORMATTER
  • Constructor Details

    • ToolBox

      public ToolBox()
  • Method Details

    • leftZeroPad

      public static String leftZeroPad(int value, int width)
    • toHexLeftZeroPadded

      public static String toHexLeftZeroPadded(long value, int width)
    • formatDouble

      public static String formatDouble(double value)
    • setString

      public static void setString(byte[] buffer, int index, String s)
      Write ASCII string to buffer[index] (no special handling for multi-byte characters)
      Parameters:
      buffer - Byte array
      index - Index to write to
      s - String containing ASCII characters
      Throws:
      ArrayIndexOutOfBoundsException
    • showException

      public static void showException(Throwable ex)
      Show a dialog with details about an exception
      Parameters:
      ex - Throwable/Exception to display
    • getFilename

      public static String getFilename(String path, String filename, List<String> extensions, boolean loadDialog, Component parent)
      Get file name via "file chooser" dialog
      Parameters:
      path - Default path (without file name).
      filename - Default file name (without path).
      extensions - Array of allowed extensions (without ".")
      loadDialog - If true, this is a load dialog, else it's a save dialog
      parent - Parent component (Frame, Window)
      Returns:
      Selected filename or null if canceled
    • getFileID

      public static byte[] getFileID(String fname, int num)
      Returns the first few bytes of a file to check it's type
      Parameters:
      fname - Filename of the file
      num - Number of bytes to return
      Returns:
      Array of bytes (size num) from the beginning of the file
    • getInt

      public static int getInt(String s)
      Convert String to integer
      Parameters:
      s - String containing integer (assumed: positive)
      Returns:
      Integer value or -1.0 if no valid numerical value
    • getDouble

      public static double getDouble(String s)
      Convert String to double
      Parameters:
      s - String containing double
      Returns:
      Double value or -1.0 if no valid numerical value