예제 #1
0
 /**
  * This is the magical place where the display model is connected with the real UI.
  *
  * @param event
  */
 @Override
 protected void onDisplayCreated(final DisplayCreatedEvent event) {
   final Display<?> display = event.getObject();
   final ImageJ imageJ = display.getContext();
   final PluginService pluginService = imageJ.getService(PluginService.class);
   final EventService eventService = imageJ.getService(EventService.class);
   for (@SuppressWarnings("rawtypes")
   final PluginInfo<DisplayViewer> info : pluginService.getPluginsOfType(DisplayViewer.class)) {
     try {
       final DisplayViewer<?> displayViewer = info.createInstance();
       if (displayViewer.canView(display)) {
         final SwingDisplayWindow displayWindow = new SwingDisplayWindow();
         displayViewer.view(displayWindow, display);
         displayViewers.add(displayViewer);
         // add a copy of the JMenuBar to the new display
         if (displayWindow.getJMenuBar() == null) {
           createMenuBar(displayWindow);
         }
         displayWindow.addEventDispatcher(new AWTWindowEventDispatcher(display, eventService));
         return;
       }
     } catch (final InstantiableException e) {
       Log.warn("Failed to create instance of " + info.getClassName(), e);
     }
   }
   Log.warn("No suitable DisplayViewer found for display");
 }
예제 #2
0
 @Override
 protected void onDisplayDeleted(final DisplayDeletedEvent event) {
   final DisplayViewer<?> displayViewer = getDisplayViewer(event.getObject());
   if (displayViewer != null) {
     final DisplayWindow displayWindow = displayViewer.getDisplayWindow();
     if ((displayWindow != null) && (displayWindow instanceof JFrame)) {
       deleteMenuBar((JFrame) displayWindow);
     }
   }
 }