Package sc.fiji.snt
Class SNTUtils
java.lang.Object
sc.fiji.snt.SNTUtils
Static utilities for SNT
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidstatic StringRetrieves Sholl Analysis implementation datestatic voidcsvQuoteAndPrint(PrintWriter pw, Object o) static FiledownloadToTempFile(String fileUrl) Downloads a file from the specified URL to a temporary filestatic voidstatic voidstatic StringextractReadableTimeStamp(File file) static booleanfileAvailable(File file) static FilefindClosestPair(File file, String pairExt) static FilefindClosestPair(File file, String[] pairExts) static StringformatDouble(double value, int digits) getBackupCopies(File location) Returns all timestamped backup copies in the specified location.getBackupCopies(File location, String baseName) Returns timestamped backup copies of traces files in the specified location.static org.scijava.ContextConvenience method to access the context of the running Fiji instancestatic DecimalFormatgetDecimalFormat(double value, int digits) static StringgetElapsedTime(long fromStart) static SNTstatic SNTDeprecated.static Stringstatic File[]getReconstructionFiles(File dir, String pattern) Retrieves a list of reconstruction files stored in a common directory matching the specified criteria.static StringgetSanitizedUnit(String unit) static Stringstatic FilegetUniquelySuffixedFile(File referenceFile) static FilegetUniquelySuffixedFile(File referenceFile, String forcedExtension) static FilegetUniquelySuffixedTifFile(File referenceFile) static booleanstatic booleanAssesses if SNT is running in debug modestatic booleanisReconstructionFile(File file) static booleanReturns whether the current context was self-initialized by SNT (i.e., no host application like ImageJ/Fiji provided one).protected static booleanisValidURL(String url) static voidGenerates a list of random paths.static voidremoveViewer(Viewer3D viewer) static voidsetContext(org.scijava.Context context) static voidsetDebugMode(boolean b) Enables/disables debug modestatic voidsetIsLoading(boolean isLoading) protected static voidstatic SNTstartApp()Convenience method to start up SNT's GUI.static StringstripExtension(String filename) static void
-
Field Details
-
TIMESTAMP_REGEX
- See Also:
-
VERSION
-
-
Method Details
-
getReadableVersion
-
addViewer
-
removeViewer
-
getViewers
-
error
-
setPlugin
-
getPluginInstance
Deprecated.usegetInstance()instead -
getInstance
-
error
-
log
-
warn
-
csvQuoteAndPrint
-
stripExtension
-
getUniquelySuffixedTifFile
-
getUniquelySuffixedFile
-
getUniquelySuffixedFile
-
fileAvailable
-
isValidURL
-
formatDouble
-
getDecimalFormat
-
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
-
findClosestPair
-
getSanitizedUnit
-
randomPaths
Generates a list of random paths. Only useful for debugging purposes- Returns:
- the list of random Paths
-
getElapsedTime
-
buildDate
Retrieves Sholl Analysis implementation date- Returns:
- the implementation date or an empty strong if date could not be retrieved.
-
getReconstructionFiles
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 containingpatternwill be imported from the directory.nullallowed.- Returns:
- the array of files. An empty list is retrieved if
diris not a valid, readable directory.
-
isReconstructionFile
-
getBackupCopies
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 filesbaseName- 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
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
-
extractReadableTimeStamp
-
setIsLoading
public static void setIsLoading(boolean isLoading) -
downloadToTempFile
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 occursURISyntaxException- 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
Convenience method to start up SNT's GUI.- Returns:
- a reference to the
SNTinstance just started.s
-
getInstance()instead