Search in sources :

Example 1 with SemImWrapper

use of edu.cmu.tetradapp.model.SemImWrapper in project tetrad by cmu-phil.

the class PValueImproverEditor method setGraphWorkbench.

private void setGraphWorkbench(final GraphWorkbench graphWorkbench) {
    JTabbedPane tabbedPane = new JTabbedPane();
    this.graphWorkbench = graphWorkbench;
    if (getOriginalSemIm() != null) {
        setOriginalSemIm(new SemIm(getWrapper().getOriginalSemIm()));
    }
    this.newSemIm = getWrapper().getNewSemIm();
    if (getNewSemIm() != null) {
        SemImEditor newEditor = new SemImEditor(new SemImWrapper(getNewSemIm()));
        final GraphWorkbench workbench = newEditor.getWorkbench();
        workbench.addPropertyChangeListener(new PropertyChangeListener() {

            public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
                if ("modelChanged".equals(propertyChangeEvent.getPropertyName())) {
                    System.out.println(propertyChangeEvent);
                    Graph graph = workbench.getGraph();
                    System.out.println(graph);
                    try {
                        new Dag(graph);
                    } catch (IllegalArgumentException e) {
                        return;
                    }
                    Scorer scorer = new DagScorer((DataSet) getWrapper().getDataModel());
                    scorer.score(graph);
                    getWrapper().setNewSemIm(scorer.getEstSem());
                    setGraphWorkbench(graphWorkbench);
                }
            }
        });
        tabbedPane.addTab("New Model", newEditor);
    }
    if (getOriginalSemIm() != null) {
        SemImEditor originalEditor = new SemImEditor(new SemImWrapper(getOriginalSemIm()));
        tabbedPane.addTab("Original Model", originalEditor);
    }
    if (graphWorkbench != null) {
        tabbedPane.addTab("forbid_latent_common_causes", graphWorkbench);
    }
    panel.removeAll();
    panel.add(tabbedPane, BorderLayout.CENTER);
    panel.revalidate();
    panel.repaint();
    firePropertyChange("modelChanged", null, null);
}
Also used : DagScorer(edu.cmu.tetrad.sem.DagScorer) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) DataSet(edu.cmu.tetrad.data.DataSet) Scorer(edu.cmu.tetrad.sem.Scorer) DagScorer(edu.cmu.tetrad.sem.DagScorer) Dag(edu.cmu.tetrad.graph.Dag) EdgeListGraph(edu.cmu.tetrad.graph.EdgeListGraph) Graph(edu.cmu.tetrad.graph.Graph) GraphWorkbench(edu.cmu.tetradapp.workbench.GraphWorkbench) SemImWrapper(edu.cmu.tetradapp.model.SemImWrapper) SemIm(edu.cmu.tetrad.sem.SemIm)

Example 2 with SemImWrapper

use of edu.cmu.tetradapp.model.SemImWrapper in project tetrad by cmu-phil.

the class SemEstimatorEditor method resetSemImEditor.

private void resetSemImEditor() {
    java.util.List<SemEstimator> semEstimators = wrapper.getMultipleResultList();
    if (semEstimators.size() == 1) {
        SemEstimator estimatedSem = semEstimators.get(0);
        SemImEditor editor = new SemImEditor(new SemImWrapper(estimatedSem.getEstimatedSem()));
        panel.removeAll();
        panel.add(editor, BorderLayout.CENTER);
        panel.revalidate();
        panel.repaint();
    } else {
        JTabbedPane tabs = new JTabbedPane();
        for (int i = 0; i < semEstimators.size(); i++) {
            SemEstimator estimatedSem = semEstimators.get(i);
            SemImEditor editor = new SemImEditor(new SemImWrapper(estimatedSem.getEstimatedSem()));
            JPanel _panel = new JPanel();
            _panel.setLayout(new BorderLayout());
            _panel.add(editor, BorderLayout.CENTER);
            tabs.addTab(estimatedSem.getDataSet().getName(), _panel);
        }
        panel.removeAll();
        panel.add(tabs);
        panel.validate();
    }
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) JTabbedPane(javax.swing.JTabbedPane) SemImWrapper(edu.cmu.tetradapp.model.SemImWrapper) SemEstimator(edu.cmu.tetrad.sem.SemEstimator)

Aggregations

SemImWrapper (edu.cmu.tetradapp.model.SemImWrapper)2 DataSet (edu.cmu.tetrad.data.DataSet)1 Dag (edu.cmu.tetrad.graph.Dag)1 EdgeListGraph (edu.cmu.tetrad.graph.EdgeListGraph)1 Graph (edu.cmu.tetrad.graph.Graph)1 DagScorer (edu.cmu.tetrad.sem.DagScorer)1 Scorer (edu.cmu.tetrad.sem.Scorer)1 SemEstimator (edu.cmu.tetrad.sem.SemEstimator)1 SemIm (edu.cmu.tetrad.sem.SemIm)1 GraphWorkbench (edu.cmu.tetradapp.workbench.GraphWorkbench)1 BorderLayout (java.awt.BorderLayout)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 JPanel (javax.swing.JPanel)1 JTabbedPane (javax.swing.JTabbedPane)1