Search in sources :

Example 46 with GraphWorkbench

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

the class GlassoSearchEditor method dagWorkbenchScroll.

private JScrollPane dagWorkbenchScroll(String resultLabel, Graph dag) {
    GraphWorkbench dagWorkbench = new GraphWorkbench(dag);
    dagWorkbench.setAllowDoubleClickActions(false);
    dagWorkbench.setAllowNodeEdgeSelection(true);
    JScrollPane dagWorkbenchScroll = new JScrollPane(dagWorkbench);
    dagWorkbenchScroll.setPreferredSize(new Dimension(450, 450));
    // dagWorkbenchScroll.setBorder(new TitledBorder(resultLabel));
    dagWorkbench.addMouseListener(new MouseAdapter() {

        public void mouseExited(MouseEvent e) {
            storeLatestWorkbenchGraph();
        }
    });
    return dagWorkbenchScroll;
}
Also used : MouseEvent(java.awt.event.MouseEvent) GraphWorkbench(edu.cmu.tetradapp.workbench.GraphWorkbench) MouseAdapter(java.awt.event.MouseAdapter)

Example 47 with GraphWorkbench

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

the class GraphEditor method editGraph.

// public GraphEditor(DagInPatternWrapper wrapper) {
// this(wrapper.getGraph());
// }
// 
// public GraphEditor(CompletedPatternWrapper wrapper) {
// this(wrapper.getGraph());
// }
// ===========================PRIVATE METHODS======================//
private void editGraph(Graph graph) {
    this.workbench = new GraphWorkbench(graph);
    GraphToolbar toolbar = new GraphToolbar(getWorkbench());
    JMenuBar menuBar = createGraphMenuBar();
    JScrollPane scroll = new JScrollPane();
    scroll.setPreferredSize(new Dimension(450, 450));
    scroll.setViewportView(getWorkbench());
    add(scroll, BorderLayout.CENTER);
    add(toolbar, BorderLayout.WEST);
    add(menuBar, BorderLayout.NORTH);
    JLabel label = new JLabel("Double click variable to change name. More information on graph edge types");
    label.setFont(new Font("SansSerif", Font.PLAIN, 12));
    // Info button added by Zhou to show edge types
    JButton infoBtn = new JButton(new ImageIcon(ImageUtils.getImage(this, "info.png")));
    infoBtn.setBorder(new EmptyBorder(0, 0, 0, 0));
    // Clock info button to show edge types instructions - Zhou
    infoBtn.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            helpSet.setHomeID("graph_edge_types");
            HelpBroker broker = helpSet.createHelpBroker();
            ActionListener listener = new CSH.DisplayHelpFromSource(broker);
            listener.actionPerformed(e);
        }
    });
    Box b = Box.createHorizontalBox();
    b.add(Box.createHorizontalStrut(2));
    b.add(label);
    b.add(infoBtn);
    b.add(Box.createHorizontalGlue());
    b.setBorder(new MatteBorder(0, 0, 1, 0, Color.GRAY));
    add(b, BorderLayout.SOUTH);
    validate();
}
Also used : HelpBroker(javax.help.HelpBroker) ActionEvent(java.awt.event.ActionEvent) MatteBorder(javax.swing.border.MatteBorder) GraphWorkbench(edu.cmu.tetradapp.workbench.GraphWorkbench) ActionListener(java.awt.event.ActionListener) CSH(javax.help.CSH) EmptyBorder(javax.swing.border.EmptyBorder)

Example 48 with GraphWorkbench

use of edu.cmu.tetradapp.workbench.GraphWorkbench 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 49 with GraphWorkbench

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

the class BayesPmEditor method setEditorPanel.

private void setEditorPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    if (wrapper.getBayesPm().getDag().getNumNodes() == 0) {
        throw new IllegalArgumentException("There are no nodes in that Bayes PM.");
    }
    setLayout(new BorderLayout());
    Graph graph = wrapper.getBayesPm().getDag();
    GraphWorkbench workbench = new GraphWorkbench(graph);
    BayesPmEditorWizard wizard = new BayesPmEditorWizard(wrapper.getBayesPm(), workbench);
    JScrollPane workbenchScroll = new JScrollPane(workbench);
    JScrollPane wizardScroll = new JScrollPane(wizard);
    workbenchScroll.setPreferredSize(new Dimension(450, 450));
    wizardScroll.setPreferredSize(new Dimension(450, 450));
    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, workbenchScroll, wizardScroll);
    splitPane.setOneTouchExpandable(true);
    splitPane.setDividerLocation(workbenchScroll.getPreferredSize().width);
    panel.add(splitPane, BorderLayout.CENTER);
    JMenuBar menuBar = new JMenuBar();
    JMenu file = new JMenu("File");
    menuBar.add(file);
    // file.add(new SaveScreenshot(this, true, "Save Screenshot..."));
    file.add(new SaveComponentImage(workbench, "Save Graph Image..."));
    panel.add(menuBar, BorderLayout.NORTH);
    setName("Bayes PM Editor");
    wizard.addPropertyChangeListener(this);
    wizard.setEditingLatentVariablesAllowed(isEditingLatentVariablesAllowed());
    wizard.setEditingMeasuredVariablesAllowed(isEditingMeasuredVariablesAllowed());
    this.wizard = wizard;
    targetPanel.add(panel, BorderLayout.CENTER);
}
Also used : Graph(edu.cmu.tetrad.graph.Graph) GraphWorkbench(edu.cmu.tetradapp.workbench.GraphWorkbench)

Example 50 with GraphWorkbench

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

the class BayesUpdaterClassifierEditor method getGraphPanel.

private Component getGraphPanel() {
    Graph graph = getClassifier().getBayesIm().getDag();
    workbench = new GraphWorkbench(graph);
    return new JScrollPane(workbench);
}
Also used : Graph(edu.cmu.tetrad.graph.Graph) GraphWorkbench(edu.cmu.tetradapp.workbench.GraphWorkbench)

Aggregations

GraphWorkbench (edu.cmu.tetradapp.workbench.GraphWorkbench)53 Graph (edu.cmu.tetrad.graph.Graph)24 EdgeListGraph (edu.cmu.tetrad.graph.EdgeListGraph)13 ActionEvent (java.awt.event.ActionEvent)11 ActionListener (java.awt.event.ActionListener)11 IKnowledge (edu.cmu.tetrad.data.IKnowledge)8 Knowledge2 (edu.cmu.tetrad.data.Knowledge2)8 WatchedProcess (edu.cmu.tetradapp.util.WatchedProcess)8 LayoutMenu (edu.cmu.tetradapp.workbench.LayoutMenu)7 MouseAdapter (java.awt.event.MouseAdapter)7 MouseEvent (java.awt.event.MouseEvent)7 PropertyChangeEvent (java.beans.PropertyChangeEvent)6 PropertyChangeListener (java.beans.PropertyChangeListener)6 TitledBorder (javax.swing.border.TitledBorder)6 DataModel (edu.cmu.tetrad.data.DataModel)4 PatternToDag (edu.cmu.tetrad.search.PatternToDag)3 CSH (javax.help.CSH)3 HelpBroker (javax.help.HelpBroker)3 EmptyBorder (javax.swing.border.EmptyBorder)3 MatteBorder (javax.swing.border.MatteBorder)3