[ImageJ-devel] how to get current ImageJ context in ImageJ 2

Albert Cardona sapristi at gmail.com
Tue Apr 10 14:01:14 CDT 2012


This below is nice: no more global variables.
Does this mean that a scripting interpreter will have to declare,
internally, a variable that points to the ImageJ context? Otherwise
the script cannot know where to reach for the currently active
Dataset, or get the list of existing, open Dataset instances.

Albert


  /**
   * Gets the static ImageJ application context.
   *
   * @deprecated Avoid using this method. If you are writing a plugin,
you can
   *             declare the {@link ImageJ} or {@link IService} you
want as a
   *             parameter, with required=true and persist=false. If
you are
   *             writing a tool, you can obtain the {@link ImageJ}
context by
   *             calling {@link ImageJEvent#getContext()}, and then
asking that
   *             context for needed {@link IService} instances by
calling
   *             {@link ImageJ#getService(Class)}. See the classes in
   *             core/plugins and core/tools for many examples.
   */
  @Deprecated
  public static ImageJ getContext() {
    return staticContext;
  }

-- 
http://albert.rierol.net
http://www.ini.uzh.ch/~acardona/



More information about the ImageJ-devel mailing list