Пример #1
0
def printAllMenus():
	mbar = Menus.getMenuBar()
	n = mbar.getMenuCount()
	for i in range(0, n):
		menu = mbar.getMenu(i)
		print menu.getLabel()
		printMenu(menu, '    ')
	print 'Help'
	printMenu(mbar.getHelpMenu(), '    ')
Пример #2
0
def check_dependencies():
    installed_plugins = os.listdir(Menus.getPlugInsPath())
    for dependency, site in _dependencies.iteritems():
        if not any(dependency in x for x in installed_plugins):
            msg = GenericDialog("Missing dependency")
            msg.addMessage(
                "Missing dependency {}, \n go to {} for installation instructions. "
                .format(dependency, site))
            msg.showDialog()
            raise RuntimeError(
                "Missing dependency {}, \n go to {} for installation instructions. "
                .format(dependency, site))
Пример #3
0
def getMenuEntry(path):
	if isinstance(path, str):
		path = path.split('>')
	try:
		menu = None
		mbar = Menus.getMenuBar()
		for i in range(0, mbar.getMenuCount()):
			if path[0] == mbar.getMenu(i).getLabel():
				menu = mbar.getMenu(i)
				break
		for j in range(1, len(path)):
			entry = None
			for i in range(0, menu.getItemCount()):
				if path[j] == menu.getItem(i).getLabel():
					entry = menu.getItem(i)
					break
			menu = entry
		return menu
	except:
		return None
Пример #4
0
''''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
Пример #5
0
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')
Пример #6
0
''''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
Пример #7
0
        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.")
Пример #8
0
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) \
Пример #9
0
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())