Ejemplo n.º 1
0
 public LegacyImageMap(final DefaultLegacyService legacyService) {
   setContext(legacyService.getContext());
   this.legacyService = legacyService;
   imagePlusTable = new ConcurrentHashMap<ImageDisplay, ImagePlus>();
   displayTable = new ConcurrentHashMap<ImagePlus, ImageDisplay>();
   imageTranslator = new DefaultImageTranslator(legacyService);
 }
Ejemplo n.º 2
0
 static {
   /*
    * We absolutely require that the LegacyInjector did its job before we
    * use the ImageJ 1.x classes here, just in case somebody wants to use
    * the LegacyService later (and hence requires the ImageJ 1.x classes to
    * be patched appropriately).
    *
    * Just loading the class is not enough; it will not get initialized. So
    * we call the preinit() method just to force class initialization (and
    * thereby the LegacyInjector to patch ImageJ 1.x).
    */
   DefaultLegacyService.preinit();
 }
Ejemplo n.º 3
0
  /**
   * Ensures that the given legacy image has a corresponding {@link ImageDisplay}.
   *
   * @return the {@link ImageDisplay} object shadowing the given {@link ImagePlus}, creating it if
   *     necessary using the {@link ImageTranslator}.
   */
  public ImageDisplay registerLegacyImage(final ImagePlus imp) {
    if (legacyService.isLegacyMode()) {
      legacyModeImages.add(new WeakReference<ImagePlus>(imp));
      return null;
    }
    ImageDisplay display = lookupDisplay(imp);
    if (display == null) {
      // mapping does not exist; mirror legacy image to display
      display = imageTranslator.createDisplay(imp);
      addMapping(display, imp);
    }

    // record resultant ImagePlus as a legacy command output
    LegacyOutputTracker.addOutput(imp);

    return display;
  }