use of edu.cmu.tetradapp.workbench.DisplayNode in project tetrad by cmu-phil.
the class KnowledgeWorkbench method getNewDisplayEdge.
/**
* Creates a new display edge for the workbench based on the given model
* edge.
*
* @param modelEdge the model edge.
* @return the new display edge.
*/
public IDisplayEdge getNewDisplayEdge(Edge modelEdge) {
Node node1 = modelEdge.getNode1();
Node node2 = modelEdge.getNode2();
if (node1 == node2) {
throw new IllegalArgumentException("Edges to self not supported.");
}
DisplayNode displayNodeA = (DisplayNode) getModelNodesToDisplay().get(node1);
DisplayNode displayNodeB = (DisplayNode) getModelNodesToDisplay().get(node2);
if ((displayNodeA == null) || (displayNodeB == null)) {
return null;
}
return new KnowledgeDisplayEdge(modelEdge, displayNodeA, displayNodeB);
}
use of edu.cmu.tetradapp.workbench.DisplayNode in project tetrad by cmu-phil.
the class KnowledgeWorkbench method getNewDisplayNode.
/**
* Creates a new display node for the workbench based on the given model
* node.
*
* @param modelNode the model node.
* @return the new display node.
*/
public DisplayNode getNewDisplayNode(Node modelNode) {
DisplayNode displayNode = new KnowledgeDisplayNode(modelNode);
displayNode.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if ("resetGraph".equals(evt.getPropertyName())) {
setGraph(getGraph());
} else if ("editingValueChanged".equals(evt.getPropertyName())) {
firePropertyChange("modelChanged", null, null);
}
}
});
return displayNode;
}
use of edu.cmu.tetradapp.workbench.DisplayNode in project tetrad by cmu-phil.
the class SemPmGraphicalEditor method addMouseListenerToGraphNodesMeasured.
private void addMouseListenerToGraphNodesMeasured() {
List nodes = graph().getNodes();
for (Object node : nodes) {
Object displayNode = workbench().getModelNodesToDisplay().get(node);
if (displayNode instanceof GraphNodeMeasured) {
DisplayNode _displayNode = (DisplayNode) displayNode;
_displayNode.setToolTipText(getEquationOfNode(_displayNode.getModelNode()));
}
}
}
use of edu.cmu.tetradapp.workbench.DisplayNode in project tetrad by cmu-phil.
the class TestDisplayNode method testSetLocation.
@Test
public void testSetLocation() {
// When constructing a display node without a model node, must check
// make sure its position can be set. This at one point threw a
// null pointer exception.
DisplayNode displayNode = new GraphNodeMeasured("X");
displayNode.setLocation(10, 10);
}
use of edu.cmu.tetradapp.workbench.DisplayNode in project tetrad by cmu-phil.
the class GraphSelectionEditor method getSelectedModelComponents.
@Override
public List getSelectedModelComponents() {
List<Component> selectedComponents = getWorkbench().getSelectedComponents();
List<TetradSerializable> selectedModelComponents = new ArrayList<>();
for (Component comp : selectedComponents) {
if (comp instanceof DisplayNode) {
selectedModelComponents.add(((DisplayNode) comp).getModelNode());
} else if (comp instanceof DisplayEdge) {
selectedModelComponents.add(((DisplayEdge) comp).getModelEdge());
}
}
return selectedModelComponents;
}
Aggregations