''''exec "$(dirname "$0")"/../ImageJ --jython "$0" "$@" # (call again with fiji)''' # Test whether any menu items contain pointers to non-existent classes which # likely indicate a missconfiguration of a plugins.config file in a .jar plugin. from ij import IJ, ImageJ, Menus from java.lang import Class, ClassNotFoundException, NoClassDefFoundError import sys # Launch ImageJ ImageJ() if len(sys.argv) > 1 and sys.argv[1] == '-v': for key in Menus.getCommands(): command = Menus.getCommands().get(key) print key, '->', command sys.exit() ok = 1 def doesClassExist(name): try: IJ.getClassLoader().loadClass(name) return True except ClassNotFoundException: return False except NoClassDefFoundError: return False
from os import makedirs, rename, stat from os.path import exists, isdir from sys import stderr from time import sleep import urllib # force initialization IJ.runMacro("", "") menu = User_Plugins.getMenuItem('File>Open Samples') commands = Menus.getCommands() plugin = 'ij.plugin.URLOpener("' samples = System.getProperty('fiji.dir') + '/samples' class FileSizeReporter(Thread): def __init__(self, name, path): self.name = name self.path = path self.canceled = False def run(self): while self.canceled == False: if exists(self.path): stderr.write('\rDownload ' + self.name \ + ': ' + str(stat(self.path).st_size) \ + ' bytes')
z = [0]*len(x) # Calculate distances for all positions. Retrieve NNs distances for i in range(len(x)): minDx = sys.maxint nearest = 0 for j in range(len(x)): if i==j: continue dx = (x[i]-x[j])**2 dy = (y[i]-y[j])**2 dz = (z[i]-z[j])**2 dst = math.sqrt(dx+dy+dz) if dst>0 and dst<minDx: minDx = dst nearest = j+1 rt.setValue("NN pair", i, nearest) rt.setValue("NN distance", i, minDx); # Display appended results rt.showRowNumbers(True) rt.show("Results") # Display distributions dp = "Distribution Plotter" if dp in Menus.getCommands().keySet().toArray(): IJ.run(dp, "parameter=[NN distance] automatic=Freedman-Diaconis"); else: IJ.error("File missing", dp+" not found.\nPlease check your BAR installation.") else: IJ.error("Invalid Results Table","Data for X,Y positions not found.")
from os import makedirs, rename, stat from os.path import exists, isdir from sys import stderr from time import sleep import urllib # force initialization IJ.runMacro("", "") menu = User_Plugins.getMenuItem('File>Open Samples') commands = Menus.getCommands() plugin = 'ij.plugin.URLOpener("' samples = System.getProperty('ij.dir') + '/samples' class FileSizeReporter(Thread): def __init__(self, name, path): self.name = name self.path = path self.canceled = False def run(self): while self.canceled == False: if exists(self.path): stderr.write('\rDownload ' + self.name \ + ': ' + str(stat(self.path).st_size) \
from java.awt import Color from java.awt.event import TextListener from ij import IJ from ij import Menus from ij.gui import GenericDialog #commands = [c for c in ij.Menus.getCommands().keySet()] # Above, equivalent list as below: commands = Menus.getCommands().keySet().toArray() gd = GenericDialog('Command Launcher') gd.addStringField('Command: ', ''); prompt = gd.getStringFields().get(0) prompt.setForeground(Color.red) class TypeListener(TextListener): def textValueChanged(self, tvc): if prompt.getText() in commands: prompt.setForeground(Color.black) return prompt.setForeground(Color.red) # or loop: #for c in commands: # if c == text: # prompt.setForeground(Color.black) # return # #prompt.setForeground(Color.red) prompt.addTextListener(TypeListener()) gd.showDialog() if not gd.wasCanceled(): IJ.doCommand(gd.getNextString())