Search in sources :

Example 11 with SessionNodeWrapper

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

the class SessionWrappers method addEdge.

public static void addEdge(SessionWrapper sessionWrapper, String nodeName1, String nodeName2) {
    // Retrieve the nodes from the session wrapper.
    Node node1 = sessionWrapper.getNode(nodeName1);
    Node node2 = sessionWrapper.getNode(nodeName2);
    // Make sure nodes existed in the session wrapper by these names.
    if (node1 == null) {
        throw new RuntimeException("There was no node by name nodeName1 in " + "the session wrapper: " + nodeName1);
    }
    if (node2 == null) {
        throw new RuntimeException("There was no node by name nodeName2 in " + "the session wrapper: " + nodeName2);
    }
    // Construct an edge.
    SessionNodeWrapper nodeWrapper1 = (SessionNodeWrapper) node1;
    SessionNodeWrapper nodeWrapper2 = (SessionNodeWrapper) node2;
    Edge edge = new Edge(nodeWrapper1, nodeWrapper2, Endpoint.TAIL, Endpoint.ARROW);
    // Add the edge.
    sessionWrapper.addEdge(edge);
}
Also used : SessionNodeWrapper(edu.cmu.tetradapp.model.SessionNodeWrapper) SessionNode(edu.cmu.tetrad.session.SessionNode) Node(edu.cmu.tetrad.graph.Node) Edge(edu.cmu.tetrad.graph.Edge)

Example 12 with SessionNodeWrapper

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

the class SessionEditorWorkbench method getNewModelNode.

// ==========================PUBLIC METHODS===========================//
/**
 * @return a SessionNodeWrapper for a new SessionNode, the type of which is
 * determined by the next button type, and the name of which is the next
 * button type (a String) appended with the next available positive integer.
 *
 * @see #getNextButtonType
 */
public Node getNewModelNode() {
    if (this.nextButtonType == null) {
        throw new NullPointerException("Next button type must be a " + "non-null string.");
    }
    String name = nextUniqueName(this.nextButtonType, getGraph());
    Class[] modelClasses = getModelClasses(this.nextButtonType);
    SessionNode newNode = new SessionNode(this.nextButtonType, name, modelClasses);
    SessionNodeWrapper nodeWrapper = new SessionNodeWrapper(newNode);
    nodeWrapper.setButtonType(this.nextButtonType);
    return nodeWrapper;
}
Also used : SessionNodeWrapper(edu.cmu.tetradapp.model.SessionNodeWrapper)

Example 13 with SessionNodeWrapper

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

the class SessionEditorWorkbench method setRepetitionLabel.

// ===========================PRIVATE METHODS========================//
/**
 * Adds a label to the session editor node for the given session node
 * indicating how many times the simulation edu.cmu.tetrad.study will run that node. If the
 * number is one, the label is removed.
 */
private void setRepetitionLabel(SessionNode sessionNode) {
    if (sessionNode == null) {
        throw new NullPointerException("Node must not be null.");
    }
    SessionNodeWrapper sessionNodeWrapper = getSessionNodeWrapper(sessionNode);
    int repetitions = sessionNode.getRepetition();
    if (repetitions > 1) {
        JLabel label = new JLabel("x " + repetitions);
        label.setForeground(Color.red);
        setNodeLabel(sessionNodeWrapper, label, 0, 0);
    } else {
        setNodeLabel(sessionNodeWrapper, null, 0, 0);
    }
}
Also used : SessionNodeWrapper(edu.cmu.tetradapp.model.SessionNodeWrapper)

Example 14 with SessionNodeWrapper

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

the class SessionEditorWorkbench method getNewDisplayNode.

/**
 * @return a new SessionEditorNode for the given SessionNodeWrapper (cast as
 * indicated).
 */
public DisplayNode getNewDisplayNode(Node modelNode) {
    SessionNodeWrapper wrapper = (SessionNodeWrapper) modelNode;
    SessionEditorNode displayNode = new SessionEditorNode(wrapper, getSimulationStudy());
    displayNode.adjustToModel();
    return displayNode;
}
Also used : SessionNodeWrapper(edu.cmu.tetradapp.model.SessionNodeWrapper)

Example 15 with SessionNodeWrapper

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

the class SessionEditorNode method getChildren.

public Set<SessionNode> getChildren() {
    SessionNodeWrapper _sessionNodeWrapper = (SessionNodeWrapper) getModelNode();
    SessionNode _sessionNode = _sessionNodeWrapper.getSessionNode();
    return _sessionNode.getChildren();
}
Also used : SessionNodeWrapper(edu.cmu.tetradapp.model.SessionNodeWrapper) SessionNode(edu.cmu.tetrad.session.SessionNode)

Aggregations

SessionNodeWrapper (edu.cmu.tetradapp.model.SessionNodeWrapper)17 SessionNode (edu.cmu.tetrad.session.SessionNode)11 Component (java.awt.Component)5 Point (java.awt.Point)5 JComponent (javax.swing.JComponent)5 Edge (edu.cmu.tetrad.graph.Edge)3 JMenuItem (javax.swing.JMenuItem)3 Node (edu.cmu.tetrad.graph.Node)2 FinalizingParameterEditor (edu.cmu.tetradapp.editor.FinalizingParameterEditor)2 ParameterEditor (edu.cmu.tetradapp.editor.ParameterEditor)2 JPopupMenu (javax.swing.JPopupMenu)2 CouldNotCreateModelException (edu.cmu.tetrad.session.CouldNotCreateModelException)1 SessionModel (edu.cmu.tetrad.session.SessionModel)1 Parameters (edu.cmu.tetrad.util.Parameters)1 TetradLoggerConfig (edu.cmu.tetrad.util.TetradLoggerConfig)1 UnlistedSessionModel (edu.cmu.tetradapp.model.UnlistedSessionModel)1 LinkedList (java.util.LinkedList)1 JDialog (javax.swing.JDialog)1