Search in sources :

Example 1 with GraphSource

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

the class EdgewiseComparisonParamsEditor method setup.

public void setup() {
    List<GraphSource> graphSources = new LinkedList<>();
    for (Object parentModel : parentModels) {
        if (parentModel instanceof GraphSource) {
            graphSources.add((GraphSource) parentModel);
        }
    }
    if (graphSources.size() == 1 && graphSources.get(0) instanceof GeneralAlgorithmRunner) {
        model1 = (GeneralAlgorithmRunner) graphSources.get(0);
        model2 = ((GeneralAlgorithmRunner) model1).getDataWrapper();
    } else if (graphSources.size() == 2) {
        model1 = (SessionModel) graphSources.get(0);
        model2 = (SessionModel) graphSources.get(1);
    } else {
        throw new IllegalArgumentException("Expecting 2 graph source.");
    }
    setLayout(new BorderLayout());
    // Reset?
    JRadioButton resetOnExecute = new JRadioButton("Reset");
    JRadioButton dontResetOnExecute = new JRadioButton("Appended to");
    ButtonGroup group1 = new ButtonGroup();
    group1.add(resetOnExecute);
    group1.add(dontResetOnExecute);
    resetOnExecute.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            getParams().set("resetTableOnExecute", true);
        }
    });
    dontResetOnExecute.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            getParams().set("resetTableOnExecute", false);
        }
    });
    if (getParams().getBoolean("resetTableOnExecute", false)) {
        resetOnExecute.setSelected(true);
    } else {
        dontResetOnExecute.setSelected(true);
    }
    // Latents?
    JRadioButton latents = new JRadioButton("Yes");
    JRadioButton noLatents = new JRadioButton("No");
    ButtonGroup group2 = new ButtonGroup();
    group2.add(latents);
    group2.add(noLatents);
    latents.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            getParams().set("keepLatents", true);
        }
    });
    if (getParams().getBoolean("keepLatents", false)) {
        latents.setSelected(true);
    } else {
        noLatents.setSelected(true);
    }
    // True graph?
    JRadioButton graph1 = new JRadioButton(model1.getName());
    JRadioButton graph2 = new JRadioButton(model2.getName());
    graph1.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            getParams().set("referenceGraphName", model1.getName());
            getParams().set("targetGraphName", model2.getName());
        }
    });
    graph2.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            getParams().set("referenceGraphName", model2.getName());
            getParams().set("targetGraphName", model1.getName());
        }
    });
    ButtonGroup group = new ButtonGroup();
    group.add(graph1);
    group.add(graph2);
    boolean alreadySet = false;
    if (model1 instanceof GeneralAlgorithmRunner) {
        graph1.setSelected(true);
    }
    if (model2 instanceof GeneralAlgorithmRunner) {
        graph2.setSelected(true);
        alreadySet = true;
    }
    if (model2 instanceof Simulation) {
        graph2.setSelected(true);
        alreadySet = true;
    }
    if (!alreadySet) {
        graph1.setSelected(true);
    }
    if (graph1.isSelected()) {
        getParams().set("referenceGraphName", model1.getName());
        getParams().set("targetGraphName", model2.getName());
    } else if (graph2.isSelected()) {
        getParams().set("referenceGraphName", model2.getName());
        getParams().set("targetGraphName", model1.getName());
    }
    Box b1 = Box.createVerticalBox();
    Box b8 = Box.createHorizontalBox();
    b8.add(new JLabel("Which of the two input graphs is the true graph?"));
    b8.add(Box.createHorizontalGlue());
    b1.add(b8);
    Box b9 = Box.createHorizontalBox();
    b9.add(graph1);
    b9.add(Box.createHorizontalGlue());
    b1.add(b9);
    Box b10 = Box.createHorizontalBox();
    b10.add(graph2);
    b10.add(Box.createHorizontalGlue());
    b1.add(b10);
    b1.add(Box.createHorizontalGlue());
    add(b1, BorderLayout.CENTER);
}
Also used : ActionEvent(java.awt.event.ActionEvent) LinkedList(java.util.LinkedList) ActionListener(java.awt.event.ActionListener) Simulation(edu.cmu.tetradapp.model.Simulation) GeneralAlgorithmRunner(edu.cmu.tetradapp.model.GeneralAlgorithmRunner) SessionModel(edu.cmu.tetrad.session.SessionModel) GraphSource(edu.cmu.tetradapp.model.GraphSource)

Example 2 with GraphSource

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

the class GraphAdjacencyIntersectionWrapper method construct.

private void construct(GraphSource... GraphSources) {
    for (GraphSource wrapper : GraphSources) {
        if (wrapper == null) {
            throw new NullPointerException("The given data must not be null");
        }
    }
    List<Graph> graphs = new ArrayList<>();
    for (GraphSource wrapper : GraphSources) {
        graphs.add(wrapper.getGraph());
    }
    this.graphs = graphs;
}
Also used : Graph(edu.cmu.tetrad.graph.Graph) GraphSource(edu.cmu.tetradapp.model.GraphSource) ArrayList(java.util.ArrayList)

Aggregations

GraphSource (edu.cmu.tetradapp.model.GraphSource)2 Graph (edu.cmu.tetrad.graph.Graph)1 SessionModel (edu.cmu.tetrad.session.SessionModel)1 GeneralAlgorithmRunner (edu.cmu.tetradapp.model.GeneralAlgorithmRunner)1 Simulation (edu.cmu.tetradapp.model.Simulation)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1