/** * Allows exploration of a reflected universe in an interactive environment. */ public static void main(String[] args) throws IOException { ReflectedUniverse r = new ReflectedUniverse(); System.out.println("Reflected universe test environment. " + "Type commands, or press ^D to quit."); if (args.length > 0) { r.setAccessibilityIgnored(true); System.out.println("Ignoring accessibility modifiers."); } BufferedReader in = new BufferedReader(new InputStreamReader(System.in, Constants.ENCODING)); while (true) { System.out.print("> "); String line = in.readLine(); if (line == null) break; try { r.exec(line); } catch (ReflectException exc) { LOGGER.debug("Could not execute '{}'", line, exc); } } System.out.println(); }
/** * Allows exploration of a reflected universe in an interactive environment. * * @param args if non-empty, access modifiers will be ignored * @throws IOException if there is an error reading from stdin */ public static void main(String[] args) throws IOException { ReflectedUniverse r = new ReflectedUniverse(); System.out.println("Reflected universe test environment. " + "Type commands, or press ^D to quit."); if (args.length > 0) { r.setAccessibilityIgnored(true); System.out.println("Ignoring accessibility modifiers."); } BufferedReader in = new BufferedReader(new InputStreamReader(System.in, Constants.ENCODING)); while (true) { System.out.print("> "); String line = in.readLine(); if (line == null) break; try { r.exec(line); } catch (ReflectException exc) { LOGGER.debug("Could not execute '{}'", line, exc); } } System.out.println(); }
/** * Checks whether the log4j framework was successfully enabled * * @return {@code true} if logging was successfully enabled */ public static synchronized boolean isEnabled() { try { ReflectedUniverse r = new ReflectedUniverse(); r.exec("import org.apache.log4j.Level"); r.exec("import org.apache.log4j.Logger"); r.exec("root = Logger.getRootLogger()"); Enumeration en = (Enumeration) r.exec("root.getAllAppenders()"); return en.hasMoreElements(); } catch (ReflectException exc) { return false; } }
/** * Checks whether the log4j framework was successfully enabled * * @return {@code true} if logging was successfully enabled */ public static synchronized boolean isEnabled() { try { ReflectedUniverse r = new ReflectedUniverse(); r.exec("import org.apache.log4j.Level"); r.exec("import org.apache.log4j.Logger"); r.exec("root = Logger.getRootLogger()"); Enumeration en = (Enumeration) r.exec("root.getAllAppenders()"); return en.hasMoreElements(); } catch (ReflectException exc) { return false; } }
/** * Sets the level of the root logger * * @param level A string indicating the desired level * (i.e.: ALL, DEBUG, ERROR, FATAL, INFO, OFF, TRACE, WARN). */ public static synchronized void setRootLevel(String level) { try { ReflectedUniverse r = new ReflectedUniverse(); r.exec("import org.apache.log4j.Level"); r.exec("import org.apache.log4j.Logger"); r.exec("root = Logger.getRootLogger()"); r.exec("root.setLevel(Level." + level + ")"); } catch (ReflectException exc) { return; } return; }
/** * Sets the level of the root logger * * @param level A string indicating the desired level * (i.e.: ALL, DEBUG, ERROR, FATAL, INFO, OFF, TRACE, WARN). */ public static synchronized void setRootLevel(String level) { try { ReflectedUniverse r = new ReflectedUniverse(); r.exec("import org.apache.log4j.Level"); r.exec("import org.apache.log4j.Logger"); r.exec("root = Logger.getRootLogger()"); r.exec("root.setLevel(Level." + level + ")"); } catch (ReflectException exc) { return; } return; }
/** * Enable SLF4J logging using logback, in the context of ImageJ. * * This allows logging events to be echoed to the ImageJ status bar, * regardless of how the logging configuration file was set up. * * @param debug true if debug-level output should be shown * @return whether or not ImageJ log enabling was successful */ public static synchronized boolean enableIJLogging(boolean debug) { ReflectedUniverse r = new ReflectedUniverse(); try { r.exec("import loci.common.LogbackTools"); r.exec("import loci.plugins.util.IJStatusEchoer"); r.exec("appender = new IJStatusEchoer()"); r.setVar("debug", debug); r.exec("LogbackTools.enableIJLogging(debug, appender)"); } catch (ReflectException exc) { return false; } return true; }
/** * Enable SLF4J logging using logback, in the context of ImageJ. * * This allows logging events to be echoed to the ImageJ status bar, * regardless of how the logging configuration file was set up. * * @param debug true if debug-level output should be shown * @return whether or not ImageJ log enabling was successful */ public static synchronized boolean enableIJLogging(boolean debug) { ReflectedUniverse r = new ReflectedUniverse(); try { r.exec("import loci.common.LogbackTools"); r.exec("import loci.plugins.util.IJStatusEchoer"); r.exec("appender = new IJStatusEchoer()"); r.setVar("debug", debug); r.exec("LogbackTools.enableIJLogging(debug, appender)"); } catch (ReflectException exc) { return false; } return true; }
LOGGER.info("Checking for JAI"); try { r = new ReflectedUniverse(); r.exec("import javax.media.jai.NullOpImage"); r.exec("import javax.media.jai.OpImage");
LOGGER.info("Checking for JAI"); try { r = new ReflectedUniverse(); r.exec("import javax.media.jai.NullOpImage"); r.exec("import javax.media.jai.OpImage");
/** * Attempts to enable SLF4J logging via log4j * without an external configuration file. * * @return {@code true} if logging was successfully enabled */ public static synchronized boolean enableLogging() { try { ReflectedUniverse r = new ReflectedUniverse(); r.exec("import org.apache.log4j.Level"); r.exec("import org.apache.log4j.Logger"); r.exec("root = Logger.getRootLogger()"); Enumeration en = (Enumeration) r.exec("root.getAllAppenders()"); if (!en.hasMoreElements()) { // no appenders yet; attach a simple console appender r.exec("import org.apache.log4j.ConsoleAppender"); r.exec("import org.apache.log4j.PatternLayout"); r.setVar("pattern", "%m%n"); r.exec("layout = new PatternLayout(pattern)"); r.exec("appender = new ConsoleAppender(layout)"); r.exec("root.addAppender(appender)"); } } catch (ReflectException exc) { return false; } return true; } }
/** * Attempts to enable SLF4J logging via log4j * without an external configuration file. * * @return {@code true} if logging was successfully enabled */ public static synchronized boolean enableLogging() { try { ReflectedUniverse r = new ReflectedUniverse(); r.exec("import org.apache.log4j.Level"); r.exec("import org.apache.log4j.Logger"); r.exec("root = Logger.getRootLogger()"); Enumeration en = (Enumeration) r.exec("root.getAllAppenders()"); if (!en.hasMoreElements()) { // no appenders yet; attach a simple console appender r.exec("import org.apache.log4j.ConsoleAppender"); r.exec("import org.apache.log4j.PatternLayout"); r.setVar("pattern", "%m%n"); r.exec("layout = new PatternLayout(pattern)"); r.exec("appender = new ConsoleAppender(layout)"); r.exec("root.addAppender(appender)"); } } catch (ReflectException exc) { return false; } return true; } }
r = new ReflectedUniverse(LOADER); try { r.exec("import quicktime.QTSession");
r = new ReflectedUniverse(LOADER); try { r.exec("import quicktime.QTSession");
ReflectedUniverse r = new ReflectedUniverse(); byte[][] bytes = null; try {
ReflectedUniverse r = new ReflectedUniverse(); byte[][] bytes = null; try {
public void displayImage5D(ImagePlus imp) { WindowManager.setTempCurrentImage(imp); IFormatReader r = process.getReader(); ReflectedUniverse ru = new ReflectedUniverse(); try { ru.exec("import i5d.Image5D"); ru.setVar("title", imp.getTitle()); ru.setVar("stack", imp.getStack()); ru.setVar("sizeC", imp.getNChannels()); ru.setVar("sizeZ", imp.getNSlices()); ru.setVar("sizeT", imp.getNFrames()); ru.exec("i5d = new Image5D(title, stack, sizeC, sizeZ, sizeT)"); ru.setVar("cal", imp.getCalibration()); ru.setVar("fi", imp.getOriginalFileInfo()); ru.exec("i5d.setCalibration(cal)"); ru.exec("i5d.setFileInfo(fi)"); //ru.exec("i5d.setDimensions(sizeC, sizeZ, sizeT)"); ru.exec("i5d.show()"); } catch (ReflectException exc) { WindowTools.reportException(exc, options.isQuiet(), "Sorry, there was a problem interfacing with Image5D"); } }
public void displayImage5D(ImagePlus imp) { WindowManager.setTempCurrentImage(imp); IFormatReader r = process.getReader(); ReflectedUniverse ru = new ReflectedUniverse(); try { ru.exec("import i5d.Image5D"); ru.setVar("title", imp.getTitle()); ru.setVar("stack", imp.getStack()); ru.setVar("sizeC", imp.getNChannels()); ru.setVar("sizeZ", imp.getNSlices()); ru.setVar("sizeT", imp.getNFrames()); ru.exec("i5d = new Image5D(title, stack, sizeC, sizeZ, sizeT)"); ru.setVar("cal", imp.getCalibration()); ru.setVar("fi", imp.getOriginalFileInfo()); ru.exec("i5d.setCalibration(cal)"); ru.exec("i5d.setFileInfo(fi)"); //ru.exec("i5d.setDimensions(sizeC, sizeZ, sizeT)"); ru.exec("i5d.show()"); } catch (ReflectException exc) { WindowTools.reportException(exc, options.isQuiet(), "Sorry, there was a problem interfacing with Image5D"); } }
BF.status(options.isQuiet(), "Establishing server connection"); try { ReflectedUniverse r = new ReflectedUniverse(); r.exec("import loci.ome.io.OmeroReader"); r.exec("baseReader = new OmeroReader()");
BF.status(options.isQuiet(), "Establishing server connection"); try { ReflectedUniverse r = new ReflectedUniverse(); r.exec("import loci.ome.io.OmeroReader"); r.exec("baseReader = new OmeroReader()");