@Deprecated public abstract class LegacyHooks extends Object
These extension points will be patched into ImageJ 1.x by the
CodeHacker
. To override the behavior of ImageJ 1.x, a new instance of
this interface needs to be installed into ij.IJ._hooks
.
The essential functionality of the hooks is provided in the
EssentialLegacyHooks
class, which makes an excellent base class for
project-specific implementations.
Modifier and Type | Class and Description |
---|---|
static class |
LegacyHooks.FatJarNameComparator
Deprecated.
|
Constructor and Description |
---|
LegacyHooks()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
addMenuItem(String menuPath,
String command)
Deprecated.
Callback for ImageJ 1.x' menu parsing machinery.
|
protected void |
addPluginClasspath(File file)
Deprecated.
|
String[] |
addPluginDirectory(File directory,
String[] names)
Deprecated.
Extension point to modify the order in which .jar files are added to the
PluginClassLoader.
|
InputStream |
autoGenerateConfigFile(File directory)
Deprecated.
|
protected StringBuilder |
autoGenerateConfigFile(File topLevelDirectory,
File directory,
String menuPath,
String packageName,
StringBuilder builder)
Deprecated.
|
boolean |
createInEditor(String fileName,
String content)
Deprecated.
Extension point to override ImageJ 1.x' editor.
|
void |
debug(String string)
Deprecated.
Logs a debug message (to be shown only in debug mode).
|
void |
dispose()
Deprecated.
Disposes of the hooks.
|
protected void |
enableIJ1PluginDirs(boolean enable)
Deprecated.
|
void |
error(Throwable t)
Deprecated.
Shows an exception.
|
String |
getAppName()
Deprecated.
Returns the name to use in place of "ImageJ".
|
Object |
getContext()
Deprecated.
Return the current context, if any.
|
URL |
getIconURL()
Deprecated.
Returns the icon to use in place of the ImageJ microscope.
|
Map<String,String> |
getMenuStructure()
Deprecated.
Returns ImageJ 1.x' menu structure as a map.
|
List<File> |
handleExtraPluginJars()
Deprecated.
Extension point to add to ImageJ 1.x' PluginClassLoader's class path.
|
boolean |
handleNoSuchMethodError(NoSuchMethodError e)
Deprecated.
Extension point to enhance ImageJ 1.x' error reporting upon
NoSuchMethodError . |
void |
initialized()
Deprecated.
First extension point to run just after ImageJ 1.x spun up.
|
void |
installed()
Deprecated.
Runs when the hooks are installed into an existing legacy environment.
|
Object |
interceptOpen(String path,
int planeIndex,
boolean display)
Deprecated.
Optionally override opening resources via legacy hooks.
|
Object |
interceptRunPlugIn(String className,
String arg)
Deprecated.
Intercepts the call to
IJ.runPlugIn(String, String) . |
boolean |
isLegacyMode()
Deprecated.
Determines whether the image windows should be displayed or not.
|
void |
log(String message)
Deprecated.
Logs a message.
|
void |
newPluginClassLoader(ClassLoader loader)
Deprecated.
Extension point to run after a new PluginClassLoader was initialized.
|
boolean |
openInEditor(String path)
Deprecated.
Extension point to override ImageJ 1.x' editor.
|
boolean |
quit()
Deprecated.
Disposes and prepares for quitting.
|
void |
registerImage(Object image)
Deprecated.
Registers an image (possibly not seen before).
|
void |
runAfterRefreshMenus()
Deprecated.
Extension point to run after Help>Refresh Menus
|
void |
showProgress(double progress)
Deprecated.
Updates the progress bar, where 0 <= progress <= 1.0.
|
void |
showProgress(int currentIndex,
int finalIndex)
Deprecated.
Updates the progress bar, where the length of the bar is set to (
currentValue + 1) / finalValue of the maximum bar length. |
void |
showStatus(String status)
Deprecated.
Shows a status message.
|
void |
unregisterImage(Object image)
Deprecated.
Releases an image.
|
public boolean isLegacyMode()
public Object getContext()
For ImageJ2-specific hooks, the returned object will be the current SciJava context, or null if the context is not yet initialized.
public boolean quit()
public void installed()
public void dispose()
This method is called when ImageJ 1.x is quitting or when new hooks are installed.
public Object interceptRunPlugIn(String className, String arg)
IJ.runPlugIn(String, String)
.className
- the class namearg
- the argument passed to the runPlugIn
methodpublic void showProgress(double progress)
progress
- between 0.0 and 1.0public void showProgress(int currentIndex, int finalIndex)
currentValue + 1) / finalValue
of the maximum bar length. The
bar is erased if currentValue >= finalValue
.currentIndex
- the step that was just startedfinalIndex
- the final step.public void showStatus(String status)
status
- the messagepublic void log(String message)
message
- the messagepublic void registerImage(Object image)
image
- the new imagepublic void unregisterImage(Object image)
image
- the imagepublic void debug(String string)
string
- the debug messagepublic void error(Throwable t)
t
- the exceptionpublic String getAppName()
public URL getIconURL()
public boolean openInEditor(String path)
path
- the path to the file to openpublic boolean createInEditor(String fileName, String content)
fileName
- the name of the new filecontent
- the initial contentprotected void enableIJ1PluginDirs(boolean enable)
protected void addPluginClasspath(File file)
public List<File> handleExtraPluginJars()
public void runAfterRefreshMenus()
public boolean handleNoSuchMethodError(NoSuchMethodError e)
NoSuchMethodError
.e
- the exception to handlepublic void newPluginClassLoader(ClassLoader loader)
loader
- the PluginClassLoader instancepublic String[] addPluginDirectory(File directory, String[] names)
There is a problem which only strikes large distributions of ImageJ such as Fiji: some .jar files try to be helpful and bundle classes which are actually not theirs, causing problems when newer versions of those .jar files which they shadow are present in the plugins/ or jars/ directory but are not respected by the class loader.
The default hook of this extension point therefore hard-codes a few file names of known offenders (which we politely will call fat .jar files normally) and just pushes them back to the end of the list.
directory
- the directory which ImageJ 1.x looked atnames
- the list of file names in the order ImageJ 1.x discovered thempublic void initialized()
public InputStream autoGenerateConfigFile(File directory)
protected StringBuilder autoGenerateConfigFile(File topLevelDirectory, File directory, String menuPath, String packageName, StringBuilder builder)
public void addMenuItem(String menuPath, String command)
This method is called whenever ImageJ 1.x adds a command to the menu structure.
menuPath
- the menu path of the menu item, or null when reinitializingcommand
- the command associated with the menu item, or null when reinitializingpublic Map<String,String> getMenuStructure()
public Object interceptOpen(String path, int planeIndex, boolean display)
This is intended as a "HandleExtraFileTypesPlus".
path
- the path to the resource to open, or null
if a dialog
needs to be shownplaneIndex
- If applicable - the index of plane to open or -1 for all planesdisplay
- if true, the opened object should be displayed before returningnull
to let ImageJ 1.x open the path.Copyright © 2014–2022 ImageJ. All rights reserved.