1 / 18

Framework Design

Framework Design. extends. implements. ImageJ’s Plugin-related Classes. Plugin void run(arg). PlugInFilter int setup(ImagePlus) void run(imageProcessor). java.awt.Frame. ExtendedPlugInFilter setup(arg, imp) showDialog(imp, command, pfr) setNPasses(nPasses) run(ip)

Download Presentation

Framework Design

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Framework Design

  2. extends implements ImageJ’s Plugin-related Classes Plugin void run(arg) PlugInFilter int setup(ImagePlus) void run(imageProcessor) java.awt.Frame ExtendedPlugInFilter setup(arg, imp) showDialog(imp, command, pfr) setNPasses(nPasses) run(ip) setup("final", imp) PlugInFrame void run(arg) void close() void focusGained/Lost(FocusEvent e) void windowDe/Activated, Opened/Closed, Closing, De/Iconified(WindowEvent) PlugInFilterRunner boolean dialogItemChanged( GenericDialog, AWTEvent) int getSliceNumber() void run() void setDialog(GenericDialog) invokes ij.plugin.ClassChecker ij.io.PluginClassLoader ij.Executer runs the specified menu command in a separate thread IJ.runPlugin() IJ.runMacroFile() IJ.runUserPlugin() IJ.runMacro() ij.macro.macroRunner

  3. Plugins • Plugin Architecture • Central issue driving ImageJ2 • Declarative Plugin with @Parameters • Widgets • Plugin Manager • Installation / Updates NEW

  4. Declarative Plugin with @Parameters PlugIn AbstractPlugIn implements PlugIn, Runnable, Callable<Map<String, Object> > Map<String, Object> call(); @Parameter label required output Parameter RunnableAdapter PlugInFunctions

  5. Button Option A Option B CheckBox CheckBox value Label Slider Label 123 Label Text… Radio Button Group Label Spinner Label InputWidgets InputWidget AbstractInputWidget StringInputWidget NumericInputWidget IntegerInputWidget DecimalInputWidget DecimalSpinner BooleanInputWidget CheckBox …InputWidget

  6. Modal Dialog Non-Modal Input Close Help Operations Sections HTML Widgets Input Dialogs Help Dialog

  7. LifecycleManagement Update Center (remote) HostApplication Actions Downloader / Updater Built-ins (core) PluginManager Downloader & Updater SPI Commands Directory (\plugins\*.jar) Discovery / Config Classpath Filters Config file Toward a New Design for the Plugins Interface

  8. Install & Update (example source avail.) Add auto update and plugins to your Java application Add auto update and plugins to your Java application (part 2) public interface Pluggable { public String getName(); public String getVersion(); public int getMinimalVersion(); public String getDescription(); public BufferedImage getIcon(); public URI getURI(); public void init(Object... args); public void destroy(); public boolean hasOptions(); public void openOptions(); }

  9. Some ideas… interface Algorithm (Stephan) • boolean checkInput() • should be called before run() to verify input data • boolean run() • computes and returns if the algorithm was successful • String getErrorMessage() • has an error message if checkInput() or run() fails • void close() • algorithms might be reused with new input images, so here we tell the algorithm to close everything (paged images for example where just setting it to null is not enough) TracEM2.Plugin • public boolean setup(Object... params); • Setup with optional parameters (may be null). Returns true of the setup was successful or not interrupted (like by clicking cancel on a dialog) • public Object invoke(Object... params); • Run the plugin directly. • public boolean applies(Object ob); • Returns true if this plugin can be applied to an Object like @param ob. This may or may not be a Displayable object. Validation Error Handling Applicability \

  10. MDIFramework • MDIFramework Project • reads configuration from plugins.xml file • PluginManager with registry public interface Plugin { void register(MDIApplication app); String getPluginName(); Object getPluginProperty(String property); Object getStaticMenuElements(String menuKey); Object getDynamicMenuElements(String menuKey, FileProperties prop); boolean isCompatibleWith(String menuKey, MetaData properties); Configuration getPluginConfiguration(); void modifySettings(); void resetSettings(); boolean setProperty(Object key, Object value); Object getProperty(Object key); Class getPropertyType(Object key); boolean hasProperty(Object key); void dispose(); } Static & Dynamic menus Configuration & settings Properties

  11. Extensions, Add-ons, Plugins… Plug-ins generally rely on the host application's user interface and have a well-defined boundary to their possible set of actions Extensions have fewer restrictions on their actions, and may provide their own user-interfaces

  12. Extensions Architecture • Extension Points • Discovery • Execution / Concurrency

  13. Extension Points • Event Listeners • ImageListener, CommandListener (+ new one) • AWT/SWING events… • Macros (MacroExtension, ExtensionDescriptor) • IO (HandleExtraFileTypes (LOCI Bio-Formats)) • GUI Extension Points • Code Editor • Application Extension Points • Start / Quit

  14. Discovery • How an extention gets discovered and/or announces its presence (mounting, 'registration') • ImageJcurrentlydiscovers and populates menus/commands from: • .jar files in the plugins directory, and sub-dirs. • plugin.config files in .jar files • IJ_Prefs.txt file • Late-Binding Mechanisms • Service Locators • Factories • Dependency Injection

  15. Service Locator • Dynamically loading plugins in Java (without OSGi) • demonstrates a PluginDiscoveryManager that does dynamic jar files discovery using java.util.ServiceLoader (Java 6) from both the classpath and directories. • spiJava Annotation and Processor to simplify the use of the Service Provider Interface • This project allows the programmer to use an Annotation, @ProviderFor, to flag a class as an implementation of a certain interface. During compilation, the necessary files are created at the appropriate locations. Also, the class is inspected to see if it follows all rules applicable to Service Providers. Compile time errors will be generated if those rules are broken, assisting the programmer to create more robust code.

  16. Sezpoz • SezPoz: SezPoz is a lightweight and simple-to-learn library that lets you perform service lookups similar to java.util.ServiceLoader. • Declarative Registration Using Annotations • modular, declarative registration of services, simple syntax verified at compile time, with service metadata inspectable prior to class loading • Service registrations are made just using Java annotations (no configuration files) and APT (or plain javac in JDK 6); • register individual objects instead of whole classes • associate static metadata with each implementation • the actual implementations need not be loaded until the caller has inspected the metadata and decided to load them • Support for declaring, creating, and inspecting indices of annotated Java elements. For example, to permit registration of simple menu items, while making it possible to prepare a menu without loading any of them until they are actually selected: @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD}) @Retention(RetentionPolicy.SOURCE) @Indexable(type=ActionListener.class) public @interface MenuItem { String menuName(); String itemName(); String iconPath() default ""; } • A concrete registration might look like: • @MenuItem(menuName="File", itemName="Print", iconPath=".../print.png") • public class PrintAction extends AbstractAction { • public void actionPerformed(ActionEvent e) {...} • }

  17. Execution / Concurrency • Functional Java • Callables • Parallelization

  18. Imaging… • ImgLib • n-dimensional • Type v. Element v. Accessor • ROI • Area, Shape • jai ROI, ROIShape • Image Display • JAI & AWT/Java2D • ImageProducer / Renderer • Producer-Filter-Consumer • ImageCanvas • Streaming

More Related