Package sc.fiji.snt

Class SNTUtils

java.lang.Object
sc.fiji.snt.SNTUtils

public class SNTUtils extends Object
Static utilities for SNT
  • Field Details

  • Method Details

    • getReadableVersion

      public static String getReadableVersion()
    • addViewer

      public static void addViewer(Viewer3D viewer)
    • removeViewer

      public static void removeViewer(Viewer3D viewer)
    • getViewers

      protected static HashMap<Integer,Viewer3D> getViewers()
    • error

      public static void error(String string)
    • setPlugin

      protected static void setPlugin(SNT plugin)
    • getPluginInstance

      @Deprecated public static SNT getPluginInstance()
      Deprecated.
      use getInstance() instead
    • getInstance

      public static SNT getInstance()
    • error

      public static void error(String string, Throwable t)
    • log

      public static void log(String string)
    • warn

      public static void warn(String string)
    • csvQuoteAndPrint

      public static void csvQuoteAndPrint(PrintWriter pw, Object o)
    • stripExtension

      public static String stripExtension(String filename)
    • getUniquelySuffixedTifFile

      public static File getUniquelySuffixedTifFile(File referenceFile)
    • getUniquelySuffixedFile

      public static File getUniquelySuffixedFile(File referenceFile)
    • getUniquelySuffixedFile

      public static File getUniquelySuffixedFile(File referenceFile, String forcedExtension)
    • fileAvailable

      public static boolean fileAvailable(File file)
    • isValidURL

      protected static boolean isValidURL(String url)
    • formatDouble

      public static String formatDouble(double value, int digits)
    • getDecimalFormat

      public static DecimalFormat getDecimalFormat(double value, int digits)
    • isDebugMode

      public static boolean isDebugMode()
      Assesses if SNT is running in debug mode
      Returns:
      the debug flag
    • setDebugMode

      public static void setDebugMode(boolean b)
      Enables/disables debug mode
      Parameters:
      b - verbose flag
    • findClosestPair

      public static File findClosestPair(File file, String[] pairExts)
    • findClosestPair

      public static File findClosestPair(File file, String pairExt)
    • getSanitizedUnit

      public static String getSanitizedUnit(String unit)
    • randomPaths

      public static List<Path> randomPaths()
      Generates a list of random paths. Only useful for debugging purposes
      Returns:
      the list of random Paths
    • getElapsedTime

      public static String getElapsedTime(long fromStart)
    • buildDate

      public static String buildDate()
      Retrieves Sholl Analysis implementation date
      Returns:
      the implementation date or an empty strong if date could not be retrieved.
    • getReconstructionFiles

      public static File[] getReconstructionFiles(File dir, String pattern)
      Retrieves a list of reconstruction files stored in a common directory matching the specified criteria.
      Parameters:
      dir - the directory containing the reconstruction files (.(e)swc, .traces, .json extension)
      pattern - the filename substring (case-sensitive) to be matched. Only filenames containing pattern will be imported from the directory. null allowed.
      Returns:
      the array of files. An empty list is retrieved if dir is not a valid, readable directory.
    • isReconstructionFile

      public static boolean isReconstructionFile(File file)
    • getBackupCopies

      public static List<File> getBackupCopies(File location, String baseName)
      Returns timestamped backup copies of traces files in the specified location. Searches both the given directory (legacy behavior) and the snt_backups subdirectory implemented in SNTv5.
      Parameters:
      location - the directory to search for backup files
      baseName - the base filename prefix to match (e.g., "OP_1" to match "OP_1_2026-01-30_10-00-00.traces"), or null to match all traces files with timestamps
      Returns:
      list of backup files (never null, may be empty), sorted most recent first
    • getBackupCopies

      public static List<File> getBackupCopies(File location)
      Returns all timestamped backup copies in the specified location. Convenience method that matches all traces files with timestamps.
      Parameters:
      location - the directory to search for backup files
      Returns:
      list of backup files (never null, may be empty), sorted most recent first
    • getTimeStamp

      public static String getTimeStamp()
    • extractReadableTimeStamp

      public static String extractReadableTimeStamp(File file)
    • setIsLoading

      public static void setIsLoading(boolean isLoading)
    • downloadToTempFile

      public static File downloadToTempFile(String fileUrl) throws IOException, URISyntaxException
      Downloads a file from the specified URL to a temporary file
      Parameters:
      fileUrl - the URL of the file to download
      Returns:
      the downloaded file
      Throws:
      IOException - if an I/O error occurs
      URISyntaxException - if the URL is malformed
    • getContext

      public static org.scijava.Context getContext()
      Convenience method to access the context of the running Fiji instance
      Returns:
      the context of the active ImageJ instance. Never null
    • isContextSet

      public static boolean isContextSet()
    • isStandaloneContext

      public static boolean isStandaloneContext()
      Returns whether the current context was self-initialized by SNT (i.e., no host application like ImageJ/Fiji provided one). This is useful for determining if it is safe to modify global UI state such as the Look and Feel.
      Returns:
      true if the context was created by SNT itself, false if provided externally
    • setContext

      public static void setContext(org.scijava.Context context)
    • startApp

      public static SNT startApp()
      Convenience method to start up SNT's GUI.
      Returns:
      a reference to the SNT instance just started.s