Example #1
0
 public synchronized void toggleLegacyMode(boolean toggle) {
   final Harmonizer harmonizer = new Harmonizer(legacyService, imageTranslator);
   if (toggle) {
     // make sure that all ImageDisplays have a corresponding ImagePlus
     final List<ImageDisplay> imageDisplays = imageDisplayService.getImageDisplays();
     // TODO: this is almost exactly what LegacyCommand does, so it is
     // pretty obvious that it is misplaced in there.
     for (final ImageDisplay display : imageDisplays) {
       ImagePlus imp = lookupImagePlus(display);
       if (imp == null) {
         final Dataset ds = imageDisplayService.getActiveDataset(display);
         if (LegacyUtils.dimensionsIJ1Compatible(ds)) {
           imp = registerDisplay(display);
           final ImageDisplayViewer viewer =
               (ImageDisplayViewer) uiService.getDisplayViewer(display);
           if (viewer != null) {
             final DisplayWindow window = viewer.getWindow();
             if (window != null) window.showDisplay(!toggle);
           }
         }
       } else {
         imp.unlock();
       }
       harmonizer.updateLegacyImage(display, imp);
       harmonizer.registerType(imp);
     }
   } else {
     for (ImagePlus imp : displayTable.keySet()) {
       final ImageWindow window = imp.getWindow();
       final ImageDisplay display = displayTable.get(imp);
       if (window == null || window.isClosed()) {
         unregisterLegacyImage(imp);
         display.close();
       } else {
         harmonizer.updateDisplay(display, imp);
       }
     }
     for (final WeakReference<ImagePlus> ref : legacyModeImages) {
       final ImagePlus imp = ref.get();
       if (imp == null) continue;
       final ImageWindow window = imp.getWindow();
       if (window != null && !window.isClosed()) {
         registerLegacyImage(imp);
       }
     }
   }
   legacyModeImages.clear();
 }
Example #2
0
 @Override
 public SwingMdiDialogPrompt dialogPrompt(
     final String message, final String title, final MessageType msg, final OptionType option) {
   final UserInterface ui = uiService.getDefaultUI();
   return new SwingMdiDialogPrompt(ui, message, title, msg, option);
 }