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);
}
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;
}
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);
}
}
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;
}
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();
}
Aggregations