コード例 #1
0
ファイル: VMManager.java プロジェクト: nbearson/IDV
  /** 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));
    }
  }
コード例 #2
0
ファイル: VMManager.java プロジェクト: nbearson/IDV
 /**
  * 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);
   }
 }
コード例 #3
0
ファイル: VMManager.java プロジェクト: nbearson/IDV
 /**
  * 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);
   }
 }
コード例 #4
0
ファイル: VMManager.java プロジェクト: nbearson/IDV
 /**
  * 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();
     }
   }
 }
コード例 #5
0
ファイル: VMManager.java プロジェクト: nbearson/IDV
 /**
  * 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;
 }
コード例 #6
0
ファイル: VMManager.java プロジェクト: nbearson/IDV
 /**
  * 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;
 }
コード例 #7
0
ファイル: CutPanelView.java プロジェクト: OceanAtlas/JOA
  public void actionPerformed(java.awt.event.ActionEvent event) {
    if (TRACE) System.out.println("CutPanelView actionPerformed: view: " + viewName);

    if (event.getSource() == closeButn) {
      JToggleButton jtb = (JToggleButton) event.getSource();
      jtb.setSelected(false);
      // System.out.println("Close!");
      vm.hideView(this);
      toolbarButton.setSelected(false);
    } else if (toolbarButton.isSelected()) {
      vm.showView(this);
    } else vm.hideView(this);
  }
コード例 #8
0
ファイル: VMManager.java プロジェクト: nbearson/IDV
  /**
   * 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);
  }
コード例 #9
0
ファイル: VMManager.java プロジェクト: nbearson/IDV
  /**
   * 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);
  }
コード例 #10
0
ファイル: VMManager.java プロジェクト: nbearson/IDV
 /**
  * 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);
   }
 }
コード例 #11
0
  /**
   * Creates a new dockable.
   *
   * @param manager the manager used to handle all operations concerning dockables.
   */
  public PictureRepositoryDockable(final ViewManager manager) {
    super("PictureListDockable");
    pictures = manager.getPictures();

    setCloseable(true);
    setMinimizable(true);
    setMaximizable(true);
    setExternalizable(true);
    setTitleText("Pictures");
    setTitleIcon(Resources.getIcon("dockable.list"));

    pictureListModel = new DefaultListModel();
    list = new JList(pictureListModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    Container content = getContentPane();
    content.setLayout(new GridBagLayout());
    content.add(
        new JScrollPane(list),
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1.0,
            100.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(1, 1, 1, 1),
            0,
            0));

    pictureNew =
        new CButton() {
          @Override
          protected void action() {
            String name = askForName();
            if (name != null) {
              pictures.add(new Picture(name));
            }
          }
        };
    pictureNew.setText("New picture");
    pictureNew.setTooltip("Creates a new picture");
    pictureNew.setIcon(Resources.getIcon("picture.add"));

    pictureDelete =
        new CButton() {
          @Override
          protected void action() {
            Picture picture = (Picture) list.getSelectedValue();
            if (picture != null) {
              pictures.remove(picture);
            }
          }
        };
    pictureDelete.setText("Delete picture");
    pictureDelete.setTooltip("Delete the selected picture");
    pictureDelete.setIcon(Resources.getIcon("picture.remove"));
    pictureDelete.setEnabled(false);

    pictureShow =
        new CButton() {
          @Override
          protected void action() {
            Picture picture = (Picture) list.getSelectedValue();
            if (picture != null) manager.open(picture);
          }
        };
    pictureShow.setText("Show picture");
    pictureShow.setTooltip("Open a new view displaying the selected picture");
    pictureShow.setIcon(Resources.getIcon("picture.show"));
    pictureShow.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
    pictureShow.setEnabled(false);

    addAction(pictureNew);
    addAction(pictureDelete);
    addAction(pictureShow);
    addSeparator();

    pictures.addListener(
        new PictureRepositoryListener() {
          public void pictureAdded(Picture picture) {
            pictureListModel.addElement(picture);
          }

          public void pictureRemoved(Picture picture) {
            pictureListModel.removeElement(picture);
          }
        });
    list.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            boolean enable = list.getSelectedValue() != null;
            pictureDelete.setEnabled(enable);
            pictureShow.setEnabled(enable);
          }
        });
  }
コード例 #12
0
ファイル: VMManager.java プロジェクト: nbearson/IDV
 /** _more_ */
 public void updateAllLegends() {
   for (int i = 0; i < viewManagers.size(); i++) {
     ViewManager vm = (ViewManager) viewManagers.get(i);
     vm.fillLegends();
   }
 }