Example #1
0
  /** Capture an image for all ViewManagers */
  public void captureAll() {
    List vms = getViewManagers();

    String filename = FileManager.getWriteFile(FileManager.FILTER_IMAGE, FileManager.SUFFIX_JPG);
    if (filename == null) {
      return;
    }
    String root = IOUtil.stripExtension(filename);
    String ext = IOUtil.getFileExtension(filename);

    StringBuffer sb = new StringBuffer("<html>");
    sb.append("Since there were multiple images they were written out as:<ul>");
    for (int i = 0; i < vms.size(); i++) {
      ViewManager vm = (ViewManager) vms.get(i);
      String name = vm.getName();
      if ((name == null) || (name.trim().length() == 0)) {
        name = "" + (i + 1);
      }
      if (vms.size() != 1) {
        filename = root + name + ext;
      }

      sb.append("<li> " + filename);
      vm.writeImage(filename);
    }
    sb.append("</ul></html>");
    if (vms.size() > 1) {
      GuiUtils.showDialog("Captured Images", GuiUtils.inset(new JLabel(sb.toString()), 5));
    }
  }
Example #2
0
 /**
  * Set the {@link ViewManager} whose window was last active.
  *
  * @param viewManager The last active view manager
  */
 public void setLastActiveViewManager(ViewManager viewManager) {
   if (lastActiveViewManager != null) {
     lastActiveViewManager.setLastActive(false);
   }
   lastActiveViewManager = viewManager;
   if (lastActiveViewManager != null) {
     lastActiveViewManager.setLastActive(true);
   }
 }
Example #3
0
 /**
  * Do the initialization of the unpersisted {@link ViewManager}.
  *
  * @param newViewManagers List of view managers to unpersist
  */
 public void unpersistViewManagers(List newViewManagers) {
   try {
     for (int i = 0; i < newViewManagers.size(); i++) {
       ViewManager newViewManager = (ViewManager) newViewManagers.get(i);
       newViewManager.initAfterUnPersistence(getIdv());
     }
   } catch (Exception exc) {
     logException("Unpersisting view manager", exc);
   }
 }
Example #4
0
 /**
  * Remove all view managers
  *
  * @param andDestroyThem If true then also call destroy
  */
 public void removeAllViewManagers(boolean andDestroyThem) {
   List local = new ArrayList(viewManagers);
   for (int i = 0; i < local.size(); i++) {
     ViewManager vm = (ViewManager) local.get(i);
     removeViewManager(vm);
     if (andDestroyThem) {
       vm.destroy();
     }
   }
 }
Example #5
0
 /**
  * Find the view manager in the given list that is defined by the given view descriptor.
  *
  * @param viewDescriptor The view descriptor
  * @param vms List of ViewManagers
  * @return The view manager or null if none found
  */
 public static ViewManager findViewManagerInList(ViewDescriptor viewDescriptor, List vms) {
   for (int i = 0; i < vms.size(); i++) {
     ViewManager vm = (ViewManager) vms.get(i);
     if (vm.isDefinedBy(viewDescriptor)) {
       return vm;
     } else {
     }
   }
   return null;
 }
Example #6
0
 /**
  * Get all of the view managers of the given class
  *
  * @param c ViewManager class
  * @return List of ViewManagers
  */
 public List getViewManagers(Class c) {
   List result = new ArrayList();
   List vms = getViewManagers();
   for (int i = 0; i < vms.size(); i++) {
     ViewManager vm = (ViewManager) vms.get(i);
     if (c.isAssignableFrom(vm.getClass())) {
       result.add(vm);
     }
   }
   return result;
 }
Example #7
0
  /**
   * Add the new view manager into the list if we don't have one with the {@link ViewDescriptor} of
   * the new view manager already.
   *
   * @param newViewManager The new view manager
   */
  public void addViewManager(ViewManager newViewManager) {

    ViewManager vm = findViewManagerInList(newViewManager.getViewDescriptor());

    if (vm == null) {
      synchronized (viewManagers) {
        viewManagers.add(newViewManager);
      }
      try {
        Trace.call1("VMManager calling ViewManager.init");
        newViewManager.init();
        Trace.call2("VMManager calling ViewManager.init");
      } catch (Exception exc) {
        logException("Adding view manager", exc);
      }
      setLastActiveViewManager(newViewManager);
    }
    getIdvUIManager().viewManagerAdded(newViewManager);
  }
Example #8
0
  /**
   * Find the view manager identified by the given view descriptor
   *
   * @param viewDescriptor The id of the VM
   * @return The VM or null if none found
   */
  public ViewManager findViewManager(ViewDescriptor viewDescriptor) {
    ViewManager viewManager = null;
    if (viewDescriptor == null) {
      viewDescriptor = new ViewDescriptor(ViewDescriptor.LASTACTIVE);
    }

    if (viewDescriptor.nameEquals(ViewDescriptor.LASTACTIVE)) {
      viewManager = getLastActiveViewManager();
      if (viewManager != null) {
        if (viewManager.isClassOk(viewDescriptor)) {
          return viewManager;
        }
      }
      List local = new ArrayList(viewManagers);
      for (int i = 0; i < local.size(); i++) {
        ViewManager vm = (ViewManager) local.get(i);
        if (vm.isClassOk(viewDescriptor)) {
          return vm;
        }
      }
    }
    return findViewManagerInList(viewDescriptor);
  }
Example #9
0
 /**
  * Popup a dialog asking the user for the name of the saved ViewManager. If provided, add a new
  * TwoFacedObject to the list of saved ViewManagers and write the list to disk.
  *
  * @param vm The view manager to save
  */
 protected void saveViewManagerState(ViewManager vm) {
   try {
     String name = ((vm instanceof MapViewManager) ? "Map View" : "View");
     name = GuiUtils.getInput(null, "Name for saved view: ", name);
     if (name == null) {
       return;
     }
     ViewState viewState = vm.doMakeViewState();
     viewState.setName(name);
     getVMState().add(viewState);
     writeVMState();
   } catch (Exception exc) {
     logException("Saving view state", exc);
   }
 }
Example #10
0
 /** _more_ */
 public void updateAllLegends() {
   for (int i = 0; i < viewManagers.size(); i++) {
     ViewManager vm = (ViewManager) viewManagers.get(i);
     vm.fillLegends();
   }
 }