Search in sources :

Example 1 with DisplayNode

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);
}
Also used : DisplayNode(edu.cmu.tetradapp.workbench.DisplayNode) Node(edu.cmu.tetrad.graph.Node) DisplayNode(edu.cmu.tetradapp.workbench.DisplayNode)

Example 2 with DisplayNode

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;
}
Also used : DisplayNode(edu.cmu.tetradapp.workbench.DisplayNode) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener)

Example 3 with 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()));
        }
    }
}
Also used : DisplayNode(edu.cmu.tetradapp.workbench.DisplayNode) GraphNodeMeasured(edu.cmu.tetradapp.workbench.GraphNodeMeasured) List(java.util.List)

Example 4 with DisplayNode

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);
}
Also used : DisplayNode(edu.cmu.tetradapp.workbench.DisplayNode) GraphNodeMeasured(edu.cmu.tetradapp.workbench.GraphNodeMeasured) Test(org.junit.Test)

Example 5 with DisplayNode

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;
}
Also used : DisplayNode(edu.cmu.tetradapp.workbench.DisplayNode) TetradSerializable(edu.cmu.tetrad.util.TetradSerializable) ArrayList(java.util.ArrayList) Component(java.awt.Component) JComponent(javax.swing.JComponent) DisplayEdge(edu.cmu.tetradapp.workbench.DisplayEdge)

Aggregations

DisplayNode (edu.cmu.tetradapp.workbench.DisplayNode)7 GraphNodeMeasured (edu.cmu.tetradapp.workbench.GraphNodeMeasured)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Node (edu.cmu.tetrad.graph.Node)1 TetradSerializable (edu.cmu.tetrad.util.TetradSerializable)1 WatchedProcess (edu.cmu.tetradapp.util.WatchedProcess)1 DisplayEdge (edu.cmu.tetradapp.workbench.DisplayEdge)1 GraphWorkbench (edu.cmu.tetradapp.workbench.GraphWorkbench)1 Component (java.awt.Component)1 Window (java.awt.Window)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 JButton (javax.swing.JButton)1 JComponent (javax.swing.JComponent)1 JList (javax.swing.JList)1 Test (org.junit.Test)1