Search in sources :

Example 6 with DisplayNode

use of edu.cmu.tetradapp.workbench.DisplayNode in project tetrad by cmu-phil.

the class GraphSelectionEditor method resetWorkbenches.

private JButton resetWorkbenches(final GraphSelectionWrapper wrapper) {
    final JButton executeButton = new JButton("Graph It!");
    executeButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Window owner = (Window) getTopLevelAncestor();
            new WatchedProcess(owner) {

                public void watch() {
                    GraphWorkbench workbench = getWorkbench();
                    List<DisplayNode> displayNodes = workbench.getSelectedNodes();
                    List<Node> newSelected = new ArrayList<>();
                    for (DisplayNode node : displayNodes) {
                        newSelected.add(node.getModelNode());
                    }
                    if (!newSelected.isEmpty()) {
                        editorPanel.setSelected(newSelected);
                    }
                    resetGraphs(wrapper);
                }
            };
        }
    });
    forWorkbenchScrolls.validate();
    return executeButton;
}
Also used : Window(java.awt.Window) DisplayNode(edu.cmu.tetradapp.workbench.DisplayNode) ActionListener(java.awt.event.ActionListener) GraphWorkbench(edu.cmu.tetradapp.workbench.GraphWorkbench) ActionEvent(java.awt.event.ActionEvent) WatchedProcess(edu.cmu.tetradapp.util.WatchedProcess) JButton(javax.swing.JButton) List(java.util.List) ArrayList(java.util.ArrayList) JList(javax.swing.JList)

Example 7 with DisplayNode

use of edu.cmu.tetradapp.workbench.DisplayNode in project tetrad by cmu-phil.

the class SessionEditorWorkbench method getNewDisplayEdge.

/**
 * @return a new SessionEditorEdge for the given given edge (cast as
 * indicated).
 */
public IDisplayEdge getNewDisplayEdge(Edge modelEdge) {
    Node modelNodeA = modelEdge.getNode1();
    Node modelNodeB = modelEdge.getNode2();
    DisplayNode displayNodeA = (DisplayNode) (getModelNodesToDisplay().get(modelNodeA));
    DisplayNode displayNodeB = (DisplayNode) (getModelNodesToDisplay().get(modelNodeB));
    if ((displayNodeA == null) || (displayNodeB == null)) {
        return null;
    }
    SessionEditorNode sessionEditorNodeA = (SessionEditorNode) displayNodeA;
    SessionEditorNode sessionEditorNodeB = (SessionEditorNode) displayNodeB;
    return new SessionEditorEdge(sessionEditorNodeA, sessionEditorNodeB, SessionEditorEdge.UNRANDOMIZED);
}
Also used : DisplayNode(edu.cmu.tetradapp.workbench.DisplayNode) DisplayNode(edu.cmu.tetradapp.workbench.DisplayNode)

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