예제 #1
0
  private synchronized void display(ExtSed sed) {

    manageAssociatedManagerWindows(sed);

    try {

      SpectrumContainer container =
          (SpectrumContainer) sed.getAttachment(IrisDisplayManager.FIT_MODEL);

      // There is no Sed attachment, so build a model manager and attach it.

      if (container == null) {
        if (buildAttachment(sed)) {
          return;
        }
      }

      // VAOPD-879: spectrum name must be identical with Sed name.
      if (container != null) {
        container.getSpectrum().setName(sed.getId());
      }

      // Now display the Sed.

      idm.display(sed, sed.getId());

      // and add its frame to the workspace.

      JInternalFrame frame = idm.getInternalFrame();

      // VAOPD-863
      frame.setTitle(sed.getId());

      if (container != null) {
        JFrame modelManagerFrame = container.getModelManager().getFrame();
        if (modelManagerFrame != null) {
          modelManagerFrame.setTitle(sed.getId());
        }
      }

      if (frame != currentFrame) {
        lastLocation = null;
        disposeCurrentFrame();
        currentFrame = frame;
        currentFrame.setDefaultCloseOperation(JInternalFrame.HIDE_ON_CLOSE);
        if (lastLocation != null) {
          currentFrame.setLocation(lastLocation);
        }
        frame.setTitle("Iris Visualizer");
        ws.addFrame(frame);
      }

    } catch (Exception ex) {
      LogEvent.getInstance().fire(this, new LogEntry("Error: " + ex.getMessage(), sed));
      Logger.getLogger("IrisVisualizer").log(Level.SEVERE, null, ex);
    }
  }
예제 #2
0
  private void manageAssociatedManagerWindows(ExtSed sed) {

    ExtSed displaying = idm.getDisplaying();

    if (displaying != null) {
      if (!sed.getId().equals(displaying.getId())) {

        // displayed Sed is exiting: make its model manager and metadata windows invisible.

        SpectrumContainer container =
            (SpectrumContainer) displaying.getAttachment(IrisDisplayManager.FIT_MODEL);

        if (container != null) {

          ModelManager2 modelManager = container.getModelManager();
          modelManager.setVisible(false);
          SpectrumVisualEditor editor = idm.getVisualEditor();

          if (editor != null) {
            editor.getJFrame().setVisible(false);
          }
        }

        // new Sed is entering display: make its model manager window visible if active.

        if (sed != null) {

          container = (SpectrumContainer) sed.getAttachment(IrisDisplayManager.FIT_MODEL);

          if (container != null) {
            ModelManager2 modelManager = container.getModelManager();
            modelManager.setVisible(modelManager.isActive());
          }
        }
      }
    }
  }
예제 #3
0
  public boolean buildAttachment(ExtSed sed)
      throws SedNoDataException, SedInconsistentException, SpectrumException {

    Spectrum sp = factory.readAllSegments(null, sed);

    if (sp == null) {
      return true;
    }

    sp.setName(sed.getId());

    JDesktopPane desktop = ws.getDesktop();
    SherpaModelManager modelManager = new SherpaModelManager(sp, idm.getSAMPConnector(), desktop);
    modelManager.setActive(false);

    SpectrumContainer container = new SpectrumContainer(sp, modelManager);
    sed.addAttachment(IrisDisplayManager.FIT_MODEL, container);

    // This is needed to capture the 'Quit' button action
    // that comes from the model manager GUI.
    modelManager.setCallbackOnDispose(new OnDisposeCommand(sed));

    return false;
  }
예제 #4
0
 private void remove(ExtSed source) {
   invalidateModel(source); // Might be needed in the future?
   idm.remove(source.getId());
 }
예제 #5
0
  public void init(IrisApplication app, IWorkspace workspace) {

    visualizer = this;

    sedManager = (SedlibSedManager) workspace.getSedManager();

    SpvInitialization spvinit = new SpvInitialization(new String[] {}, null);

    SpvProperties.SetProperty(Include.APP_NAME, Include.IRIS_APP_NAME);
    SpvProperties.SetProperty(Include.APP_VERSION, Include.IRIS_VERSION);
    spvinit.initialize(null, false);

    FunctionFactorySherpaHelper.initialize();

    this.app = app;
    ws = workspace;

    idm = new IrisDisplayManager(sedManager, ws, this);
    idm.setDesktopMode(true);
    idm.setConnection(app.getSAMPController());

    File rootDir =
        new File(
            app.getConfigurationDir()
                + File.separator
                + "analysis"
                + File.separator
                + "custom_models");

    try {

      customManager = new CustomModelsManager(rootDir);

      TreeRefresher treeRefresher = new TreeRefresher();
      treeRefresher.execute(null);
      FunctionFactorySherpaHelper.SetTreeRefresher(treeRefresher);

    } catch (Exception ex) {
      Logger.getLogger(IrisVisualizer.class.getName()).log(Level.SEVERE, null, ex);
      int ans =
          NarrowOptionPane.showConfirmDialog(
              ws.getRootFrame(),
              "Error initializing Custom Fit Component Manager: "
                  + ex.getMessage()
                  + "\nDo you want to reset custom models?",
              "Iris Visualizer",
              NarrowOptionPane.ERROR_MESSAGE);
      if (ans == NarrowOptionPane.OK_OPTION) {
        try {
          if (rootDir.isDirectory()) {
            deleteDirectory(rootDir);
          } else {
            rootDir.delete();
          }
          rootDir.mkdir();
          customManager = new CustomModelsManager(rootDir);

        } catch (IOException ex1) {
          Logger.getLogger(IrisVisualizer.class.getName()).log(Level.SEVERE, null, ex1);
        }
      }
    }

    SedEvent.getInstance()
        .add(
            new SedListener() {

              public void process(final ExtSed source, SedCommand payload) {

                if (payload == SedCommand.SELECTED || payload == SedCommand.CHANGED) {

                  if (source.getNumberOfSegments() > 0) {
                    display(source);
                  }

                } else if (payload == SedCommand.REMOVED) {

                  remove(source);
                }
              }
            });

    SegmentEvent.getInstance()
        .add(
            new SegmentListener() {

              public void process(Segment source, final SegmentPayload payload) {

                if (payload.getSedCommand() == SedCommand.REMOVED) {
                  return;
                }

                ExtSed sed = payload.getSed();

                // If the sed structure was modified, invalidate
                // any model associated with it.

                invalidateModel(sed);

                display(payload.getSed());
              }
            });

    MultipleSegmentEvent.getInstance()
        .add(
            new MultipleSegmentListener() {

              public void process(List<Segment> source, final SegmentPayload payload) {
                ExtSed sed = payload.getSed();

                // If the sed structure was modified, invalidate
                // any model associated with it.

                invalidateModel(sed);

                display(payload.getSed());
              }
            });
  }