/* BARlib.bsh * IJ BAR: https://github.com/tferr/Scripts#scripts * * Common BAR library (https://github.com/tferr/Scripts/tree/master/lib#lib) to be * placed in BAR/lib. This file hosts functions to be used across all your scripts. * To load these scripting additions, append the following to your BeanShell files: * * addClassPath(bar.Utils.getBARDir()); * importCommands("lib/"); * BARlib(); * * Then, initiate the BARlib class, calling methods as usual: * lib = new BARlib(); * lib.confirmLoading(); */ BARlib() { public class BARlib { /////////// UTILITIES /////////// /** Acknowledges accessibility to this file */ void confirmLoading() { ij.IJ.showMessage("BAR lib successfully loaded!"); } /** Returns text from the system clipboard or an empty string if no text was found */ String getClipboardText() { return bar.Utils.getClipboardText(); } /** Returns a random uuid */ String randomString() { import java.util.UUID; return UUID.randomUUID().toString(); } /////////// CALCULATIONS /////////// /** * Smooths 1D data according to the specified window. Returns the original * data if window is not a positive integrer. */ double[] getSimpleMovingAverage(double[] values, int window) { if (window<1) return values; svalues = new double[values.length]; for (i=0; i