public class DefaultLegacyHooks extends LegacyHooks
LegacyHooks
encapsulating an active LegacyService
for use
within the patched ImageJ 1.x.LegacyHooks.FatJarNameComparator
Constructor and Description |
---|
DefaultLegacyHooks(LegacyService legacyService) |
DefaultLegacyHooks(LegacyService legacyService,
IJ1Helper helper) |
Modifier and Type | Method and Description |
---|---|
void |
addMenuItem(String menuPath,
String command)
Callback for ImageJ 1.x' menu parsing machinery.
|
boolean |
createInEditor(String title,
String content)
Creates the given file in the registered legacy editor, if any.
|
void |
debug(String string)
Logs a debug message (to be shown only in debug mode).
|
void |
dispose()
Disposes of the hooks.
|
boolean |
disposing()
Allows interception of ImageJ 1.x's disposal routine while quitting.
|
void |
error(Throwable t)
Shows an exception.
|
String |
getAppName()
Returns the application name for use with ImageJ 1.x.
|
String |
getAppVersion()
Returns the application version to display in the ImageJ 1.x status bar.
|
Object |
getContext()
Returns the current context, if any.
|
URL |
getIconURL()
Returns the icon for use with ImageJ 1.x.
|
Iterable<Thread> |
getThreadAncestors()
Iterates through the current thread's ancestors.
|
void |
installed()
Runs when the hooks are installed into an existing legacy environment.
|
boolean |
interceptCloseAllWindows()
Allows closing additional windows at the end of
WindowManager.closeAllWindows() . |
Object |
interceptDragAndDropFile(File f)
Optionally override opening drag-and-dropped files via legacy hooks.
|
Object |
interceptFileOpen(String path)
Optionally override opening resources via legacy hooks.
|
void |
interceptImageWindowClose(Object window)
Hook to ensure
ImageWindow s are fully cleaned up when
they are closed. |
boolean |
interceptKeyPressed(KeyEvent e)
Intercepts keyboard events sent to ImageJ 1.x.
|
Object |
interceptOpen(String path,
int planeIndex,
boolean display)
Optionally override opening resources via legacy hooks.
|
Object |
interceptOpenImage(String path,
int planeIndex)
Optionally override opening images via legacy hooks.
|
Object |
interceptOpenRecent(String path)
Optionally override opening recent images via legacy hooks.
|
Object |
interceptRunPlugIn(String className,
String arg)
Intercepts the call to
IJ.runPlugIn(String, String) . |
boolean |
isLegacyMode()
Determines whether the image windows should be displayed or not.
|
void |
log(String message)
Logs a message.
|
boolean |
openInEditor(String path)
Opens the given path in the registered legacy editor, if any.
|
void |
registerImage(Object o)
Registers an image (possibly not seen before).
|
void |
runAfterRefreshMenus()
Extension point to run after Help>Refresh Menus
|
void |
unregisterImage(Object o)
Releases an image.
|
addPluginClasspath, addPluginDirectory, autoGenerateConfigFile, autoGenerateConfigFile, enableIJ1PluginDirs, getClasspathElements, getMenuStructure, handleExtraPluginJars, handleNoSuchMethodError, initialized, newPluginClassLoader, quit, showProgress, showProgress, showStatus
public DefaultLegacyHooks(LegacyService legacyService)
public DefaultLegacyHooks(LegacyService legacyService, IJ1Helper helper)
public boolean isLegacyMode()
LegacyHooks
isLegacyMode
in class LegacyHooks
public Object getContext()
LegacyHooks
For ImageJ2-specific hooks, the returned object will be the current SciJava context, or null if the context is not yet initialized.
getContext
in class LegacyHooks
public void installed()
LegacyHooks
installed
in class LegacyHooks
public void dispose()
LegacyHooks
This method is called when ImageJ 1.x is quitting or when new hooks are installed.
dispose
in class LegacyHooks
public Object interceptRunPlugIn(String className, String arg)
LegacyHooks
IJ.runPlugIn(String, String)
.interceptRunPlugIn
in class LegacyHooks
className
- the class namearg
- the argument passed to the runPlugIn
methodpublic void registerImage(Object o)
LegacyHooks
registerImage
in class LegacyHooks
o
- the new imagepublic void unregisterImage(Object o)
LegacyHooks
unregisterImage
in class LegacyHooks
o
- the imagepublic void debug(String string)
LegacyHooks
debug
in class LegacyHooks
string
- the debug messagepublic void error(Throwable t)
LegacyHooks
error
in class LegacyHooks
t
- the exceptionpublic void log(String message)
LegacyHooks
log
in class LegacyHooks
message
- the messagepublic String getAppName()
getAppName
in class LegacyHooks
public String getAppVersion()
getAppVersion
in class LegacyHooks
public URL getIconURL()
getIconURL
in class LegacyHooks
public void runAfterRefreshMenus()
LegacyHooks
runAfterRefreshMenus
in class LegacyHooks
public boolean openInEditor(String path)
openInEditor
in class LegacyHooks
path
- the path of the file to openpublic boolean createInEditor(String title, String content)
createInEditor
in class LegacyHooks
title
- the title of the file to createcontent
- the text of the file to be createdpublic void addMenuItem(String menuPath, String command)
LegacyHooks
This method is called whenever ImageJ 1.x adds a command to the menu structure.
addMenuItem
in class LegacyHooks
menuPath
- the menu path of the menu item, or null when reinitializingcommand
- the command associated with the menu item, or null when reinitializingpublic Object interceptOpen(String path, int planeIndex, boolean display)
LegacyHooks
This is intended as a "HandleExtraFileTypesPlus".
interceptOpen
in class LegacyHooks
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.public Object interceptFileOpen(String path)
LegacyHooks
This is intended as a "HandleExtraFileTypesPlus".
interceptFileOpen
in class LegacyHooks
path
- the path to the resource to open, or null
if a dialog
needs to be shownnull
to let ImageJ 1.x open the resource.public Object interceptOpenImage(String path, int planeIndex)
LegacyHooks
This is intended as a "HandleExtraFileTypesPlus".
interceptOpenImage
in class LegacyHooks
path
- the path to the image to open, or null
if a dialog
needs to be shownplaneIndex
- If applicable - the index of plane to open or -1 for all planesnull
to let ImageJ 1.x open the image.public Object interceptOpenRecent(String path)
LegacyHooks
interceptOpenRecent
in class LegacyHooks
path
- the path to the recent image to opennull
to let ImageJ 1.x open the image.public Object interceptDragAndDropFile(File f)
LegacyHooks
interceptDragAndDropFile
in class LegacyHooks
f
- the file that was dragged onto the IJ UInull
to let ImageJ 1.x open the file
as normal.public boolean interceptKeyPressed(KeyEvent e)
LegacyHooks
interceptKeyPressed
in class LegacyHooks
e
- the keyboard eventpublic Iterable<Thread> getThreadAncestors()
LegacyHooks
ImageJ 1.x' macro options are thread-local. Unfortunately, this does not take into account thread relationships e.g. when threads are spawned in parallel.
By overriding this method, legacy hooks can force ImageJ 1.x to look harder for macro options.
getThreadAncestors
in class LegacyHooks
public boolean interceptCloseAllWindows()
LegacyHooks
WindowManager.closeAllWindows()
.
When returning false
, ImageJ 1.x will be disallowed from quitting.
interceptCloseAllWindows
in class LegacyHooks
public void interceptImageWindowClose(Object window)
LegacyHooks
ImageWindow
s are fully cleaned up when
they are closed.interceptImageWindowClose
in class LegacyHooks
public boolean disposing()
LegacyHooks
This method is called after it has been confirmed that quitting should proceed. That is, the user OKed all the windows being closed, etc. This method provides one final chance to cancel the quit operation by returning false; otherwise, it performs any needed disposal and cleanup.
disposing
in class LegacyHooks
which is where ImageJ 1.x actually quits
Copyright © 2014–2022 ImageJ. All rights reserved.