@Deprecated public class LegacyEnvironment extends Object
This class is a partner to the LegacyClassLoader
, intended to make
sure that the ImageJ 1.x contained in a given class loader is patched and can
be accessed conveniently.
Constructor and Description |
---|
LegacyEnvironment(ClassLoader loader,
boolean headless)
Deprecated.
Constructs a new legacy environment.
|
Modifier and Type | Method and Description |
---|---|
void |
addPluginClasspath(ClassLoader fromClassLoader)
Deprecated.
Adds the class path of a given
ClassLoader to the plugin class
loader. |
void |
addPluginClasspath(File... classpathEntries)
Deprecated.
Adds extra elements to the class path of ImageJ 1.x' plugin class loader.
|
void |
disableIJ1PluginDirs()
Deprecated.
|
ClassLoader |
getClassLoader()
Deprecated.
Gets the class loader containing the ImageJ 1.x classes used in this legacy
environment.
|
Map<String,String> |
getMenuStructure()
Deprecated.
Gets the ImageJ 1.x menu structure as a map
|
static LegacyEnvironment |
getPatchedImageJ1()
Deprecated.
Launches a fully-patched, self-contained ImageJ 1.x.
|
void |
main(String... args)
Deprecated.
Runs
ImageJ.main(args) in the legacy environment. |
void |
run(String command,
String options)
Deprecated.
Runs
IJ.run(command, options) in the legacy environment. |
void |
runMacro(String macro,
String arg)
Deprecated.
Runs
IJ.runMacro(macro, arg) in the legacy environment. |
Object |
runPlugIn(String className,
String arg)
Deprecated.
Runs
IJ.runPlugIn(className, arg) in the legacy environment. |
void |
setMacroOptions(String options)
Deprecated.
Sets the macro options.
|
public LegacyEnvironment(ClassLoader loader, boolean headless) throws ClassNotFoundException
loader
- the ClassLoader
to use for loading the (patched)
ImageJ 1.x classes; if null
, a LegacyClassLoader
is constructed.headless
- whether to patch in support for headless operation
(compatible only with "well-behaved" plugins, i.e. plugins that do
not use graphical components directly)ClassNotFoundException
public void disableIJ1PluginDirs()
public void addPluginClasspath(ClassLoader fromClassLoader)
ClassLoader
to the plugin class
loader.
This method is intended to be used in unit tests as well as interactive
debugging from inside an Integrated Development Environment where the
plugin's classes are not available inside a .jar
file.
At the moment, the only supported parameters are URLClassLoader
s.
fromClassLoader
- the class path donorpublic void addPluginClasspath(File... classpathEntries)
The typical use case for a LegacyEnvironment
is to run specific
plugins in an encapsulated environment. However, in the case of multiple
one wants to use multiple legacy environments with separate sets of plugins
enabled, it becomes impractical to pass the location of the plugins'
.jar
files via the plugins.dir
system property (because of
threading issues).
In other cases, the plugins' .jar
files are not located in a single
directory, or worse: they might be contained in a directory among
.jar
files one might not want to add to the plugin class
loader's class path.
This method addresses that need by allowing to add individual .jar
files to the class path of the plugin class loader and ensuring that their
plugins.config
files are parsed.
classpathEntries
- the class path entries containing ImageJ 1.x
pluginspublic void setMacroOptions(String options)
Both run(String, String)
and runMacro(String, String)
take an argument that is typically recorded by the macro recorder. For
runPlugIn(String, String)
, however, only the arg
parameter
that is to be passed to the plugins run()
or setup()
method
can be specified. For those use cases where one wants to call a plugin
class directly, but still provide macro options, this method is the
solution.
options
- the macro options to use for the next call to
runPlugIn(String, String)
public void run(String command, String options)
IJ.run(command, options)
in the legacy environment.command
- the command to runoptions
- the options to pass to the commandpublic void runMacro(String macro, String arg)
IJ.runMacro(macro, arg)
in the legacy environment.macro
- the macro code to runarg
- an optional argument (which can be retrieved in the macro code
via getArgument()
)public Object runPlugIn(String className, String arg)
IJ.runPlugIn(className, arg)
in the legacy environment.className
- the plugin class to runarg
- an optional argument (which get passed to the run()
or
setup()
method of the plugin)public void main(String... args)
ImageJ.main(args)
in the legacy environment.args
- the arguments to pass to the main() methodpublic ClassLoader getClassLoader()
public Map<String,String> getMenuStructure()
public static LegacyEnvironment getPatchedImageJ1() throws ClassNotFoundException
ClassNotFoundException
Copyright © 2014–2022 ImageJ. All rights reserved.