예제 #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
  public ExtSed interpolate(ExtSed sed, InterpolationConfig interpConf) throws Exception {

    if (sed.getNumberOfSegments() == 0) {
      throw new SedNoDataException();
    }

    ExtSed newsed = ExtSed.flatten(sed, "Angstrom", "Jy");

    String intervUnits = interpConf.getUnits();
    Double xmin = interpConf.getXMin();
    Double xmax = interpConf.getXMax();

    if (xmin > Double.NEGATIVE_INFINITY)
      xmin = um.convertX(new double[] {xmin}, intervUnits, "Angstrom")[0];

    if (xmax < Double.POSITIVE_INFINITY)
      xmax = um.convertX(new double[] {xmax}, intervUnits, "Angstrom")[0];

    interpConf.setXMin(Math.min(xmin, xmax));
    interpConf.setXMax(Math.max(xmin, xmax));

    interpConf.setX(newsed.getSegment(0).getSpectralAxisValues());
    interpConf.setY(newsed.getSegment(0).getFluxAxisValues());
    SAMPMessage message =
        SAMPFactory.createMessage(INTERPOLATE_MTYPE, interpConf, InterpolationPayload.class);
    Response rspns = client.sendMessage(message);

    InterpolationPayload response =
        (InterpolationPayload) SAMPFactory.get(rspns.getResult(), InterpolationPayload.class);

    if (xmin > Double.NEGATIVE_INFINITY)
      xmin = um.convertX(new double[] {xmin}, "Angstrom", intervUnits)[0];

    if (xmax < Double.POSITIVE_INFINITY)
      xmax = um.convertX(new double[] {xmax}, "Angstrom", intervUnits)[0];

    interpConf.setXMin(Math.min(xmin, xmax));
    interpConf.setXMax(Math.max(xmin, xmax));

    double[] x = um.convertX(response.getX(), "Angstrom", intervUnits);

    Segment segment = new Segment();
    segment.setSpectralAxisValues(x);
    segment.setFluxAxisValues(response.getY());
    segment.setTarget(sed.getSegment(0).getTarget());
    segment.setSpectralAxisUnits(intervUnits);
    segment.setFluxAxisUnits("Jy");
    String ucd = "em.wl";
    if (intervUnits.equals("Hz")) ucd = "em.freq";
    else if (intervUnits.equals("keV")) ucd = "em.energy";
    segment.createChar().createSpectralAxis().setUcd(ucd);
    segment.createChar().createFluxAxis().setUcd("phot.flux.density;" + ucd);

    ExtSed newSed = manager.newSed(sed.getId() + "_" + interpConf.getMethod().replaceAll(" ", ""));
    newSed.addSegment(segment);
    newSed.checkChar();

    return newSed;
  }
예제 #3
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());
          }
        }
      }
    }
  }
예제 #4
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;
  }
예제 #5
0
 private void remove(ExtSed source) {
   invalidateModel(source); // Might be needed in the future?
   idm.remove(source.getId());
 }