/** Performs the action of loading a session from a file. */
  public void actionPerformed(ActionEvent e) {
    DataModel dataModel = getDataEditor().getSelectedDataModel();

    if (!(dataModel instanceof DataSet)) {
      JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), "Must be a tabular data set.");
      return;
    }

    this.dataSet = (DataSet) dataModel;

    SpinnerNumberModel spinnerNumberModel = new SpinnerNumberModel(getNumLags(), 0, 20, 1);
    JSpinner jSpinner = new JSpinner(spinnerNumberModel);
    jSpinner.setPreferredSize(jSpinner.getPreferredSize());

    spinnerNumberModel.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            SpinnerNumberModel model = (SpinnerNumberModel) e.getSource();
            setNumLags(model.getNumber().intValue());
          }
        });

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());

    Box b = Box.createVerticalBox();
    Box b1 = Box.createHorizontalBox();
    b1.add(new JLabel("Number of time lags: "));
    b1.add(Box.createHorizontalGlue());
    b1.add(Box.createHorizontalStrut(15));
    b1.add(jSpinner);
    b1.setBorder(new EmptyBorder(10, 10, 10, 10));
    b.add(b1);

    panel.add(b, BorderLayout.CENTER);

    EditorWindow editorWindow = new EditorWindow(panel, "Create time series data", "Save", true);
    DesktopController.getInstance().addEditorWindow(editorWindow);
    editorWindow.setVisible(true);

    editorWindow.addInternalFrameListener(
        new InternalFrameAdapter() {
          public void internalFrameClosed(InternalFrameEvent e) {
            EditorWindow window = (EditorWindow) e.getSource();

            if (!window.isCanceled()) {
              if (dataSet.isContinuous()) {
                createContinuousTimeSeriesData();
              } else if (dataSet.isDiscrete()) {
                createDiscreteTimeSeriesData();
              } else {
                JOptionPane.showMessageDialog(
                    JOptionUtils.centeringComp(),
                    "Data set must be either continuous or discrete.");
              }
            }
          }
        });
  }
  /** Must pass knowledge from getMappings. If null, creates new Knowledge2 object. */
  private void openKnowledgeEditor() {
    if (this.getParams() == null) {
      throw new NullPointerException(
          "Parameter object must not be " + "null if you want to launch a OldKnowledgeEditor.");
    }

    IKnowledge knowledge = this.getParams().getKnowledge();

    KnowledgeEditor knowledgeEditor =
        new KnowledgeEditor(knowledge, varNames, params.getSourceGraph());
    EditorWindow window =
        new EditorWindow(knowledgeEditor, knowledgeEditor.getName(), "Save", false, this);
    DesktopController.getInstance().addEditorWindow(window, JLayeredPane.PALETTE_LAYER);
    window.setVisible(true);
  }
Exemple #3
0
  public void actionPerformed(ActionEvent e) {
    DataSet dataSet = (DataSet) dataEditor.getSelectedDataModel();
    if (dataSet == null || dataSet.getNumColumns() == 0) {
      JOptionPane.showMessageDialog(
          findOwner(), "Cannot display a scatter plot for an empty data set.");
      return;
    }

    JPanel panel = new ScatterPlotView(dataSet);
    EditorWindow editorWindow = new EditorWindow(panel, "Scatter Plots", "Save", true, dataEditor);

    //        JPanel dialog = createScatterPlotDialog(null, null);
    //        EditorWindow editorWindow = new EditorWindow(dialog, "Scatter Plots", "Save", true,
    // dataEditor);

    DesktopController.getInstance().addEditorWindow(editorWindow, JLayeredPane.PALETTE_LAYER);
    editorWindow.pack();
    editorWindow.setVisible(true);
  }
Exemple #4
0
  public void actionPerformed(ActionEvent e) {
    DataSet dataSet = (DataSet) dataEditor.getSelectedDataModel();
    if (dataSet == null || dataSet.getNumColumns() == 0) {
      JOptionPane.showMessageDialog(
          findOwner(), "Cannot run normality tests on an empty data set.");
      return;
    }
    // if there are missing values warn and don't display q-q plot.
    //        if(DataUtils.containsMissingValue(dataSet)){
    //            JOptionPane.showMessageDialog(findOwner(), new JLabel("<html>Data has missing
    // values, " +
    //                    "remove all missing values before<br>" +
    //                    "running normality tests.</html>"));
    //            return;
    //        }

    JPanel panel = createNormalityTestDialog(null);

    EditorWindow window = new EditorWindow(panel, "Normality Tests", "Close", false, dataEditor);
    DesktopController.getInstance().addEditorWindow(window, JLayeredPane.PALETTE_LAYER);
    window.setVisible(true);
  }
  /** Performs the action of saving a session to a file. */
  public void actionPerformed(ActionEvent e) {

    // Get the frontmost SessionWrapper.
    SessionEditorIndirectRef sessionEditorRef =
        DesktopController.getInstance().getFrontmostSessionEditor();
    SessionEditor sessionEditor = (SessionEditor) sessionEditorRef;
    SessionEditorWorkbench workbench = sessionEditor.getSessionWorkbench();
    SessionWrapper sessionWrapper = workbench.getSessionWrapper();
    TetradMetadata metadata = new TetradMetadata();

    // Select the file to save this to.
    File file =
        EditorUtils.getSaveFile(
            sessionEditor.getName(),
            "tet",
            JOptionUtils.centeringComp(),
            true,
            "Save Session As...");

    if (file == null) {
      this.saved = false;
      return;
    }

    if ((DesktopController.getInstance().existsSessionByName(file.getName())
        && !(sessionWrapper.getName().equals(file.getName())))) {
      this.saved = false;
      JOptionPane.showMessageDialog(
          JOptionUtils.centeringComp(),
          "Another session by that name is currently open. Please "
              + "\nclose that session first.");
      return;
    }

    sessionWrapper.setName(file.getName());
    sessionEditor.setName(file.getName());

    // Save it.
    try {
      FileOutputStream out = new FileOutputStream(file);
      ObjectOutputStream objOut = new ObjectOutputStream(out);
      objOut.writeObject(metadata);
      objOut.writeObject(sessionWrapper);
      out.close();

      FileInputStream in = new FileInputStream(file);
      ObjectInputStream objIn = new ObjectInputStream(in);
      objIn.readObject();

      sessionWrapper.setSessionChanged(false);
      sessionWrapper.setNewSession(false);
      this.saved = true;
    } catch (Exception e2) {
      this.saved = false;
      e2.printStackTrace();
      JOptionPane.showMessageDialog(
          JOptionUtils.centeringComp(), "An error occurred while attempting to save the session.");
    }

    DesktopController.getInstance().putMetadata(sessionWrapper, metadata);
    sessionEditor.firePropertyChange("name", null, file.getName());
  }