Search in sources :

Example 1 with LayoutMenu

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

the class LofsSearchEditorNew method addSpecialMenus.

protected void addSpecialMenus(JMenuBar menuBar) {
    if (!(getAlgorithmRunner() instanceof IGesRunner)) {
        JMenu test = new JMenu("Independence");
        menuBar.add(test);
        IndTestMenuItems.addIndependenceTestChoices(test, this);
    // test.addSeparator();
    // 
    // AlgorithmRunner algorithmRunner = getAlgorithmRunner();
    // if (algorithmRunner instanceof IndTestProducer) {
    // IndTestProducer p = (IndTestProducer) algorithmRunner;
    // IndependenceFactsAction action =
    // new IndependenceFactsAction(this, p, "Independence Facts...");
    // test.add(action);
    // }
    }
    JMenu graph = new JMenu("Graph");
    JMenuItem showDags = new JMenuItem("Show DAGs in forbid_latent_common_causes");
    // JMenuItem meekOrient = new JMenuItem("Meek Orientation");
    JMenuItem dagInPattern = new JMenuItem("Choose DAG in forbid_latent_common_causes");
    JMenuItem gesOrient = new JMenuItem("Global Score-based Reorientation");
    JMenuItem nextGraph = new JMenuItem("Next Graph");
    JMenuItem previousGraph = new JMenuItem("Previous Graph");
    graph.add(new GraphPropertiesAction(getWorkbench()));
    graph.add(new PathsAction(getWorkbench()));
    graph.add(new TriplesAction(getWorkbench().getGraph(), getAlgorithmRunner()));
    graph.addSeparator();
    // graph.add(meekOrient);
    graph.add(dagInPattern);
    graph.add(gesOrient);
    graph.addSeparator();
    graph.add(previousGraph);
    graph.add(nextGraph);
    graph.addSeparator();
    graph.add(showDags);
    graph.addSeparator();
    graph.add(new JMenuItem(new SelectBidirectedAction(getWorkbench())));
    graph.add(new JMenuItem(new SelectUndirectedAction(getWorkbench())));
    menuBar.add(graph);
    showDags.addActionListener(new ActionListener() {

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

                public void watch() {
                    // Needs to be a pattern search; this isn't checked
                    // before running the algorithm because of allowable
                    // "slop"--e.g. bidirected edges.
                    AlgorithmRunner runner = getAlgorithmRunner();
                    Graph graph = runner.getGraph();
                    if (graph == null) {
                        JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), "No result gaph.");
                        return;
                    }
                    PatternDisplay display = new PatternDisplay(graph);
                    GraphWorkbench workbench = getWorkbench();
                    EditorWindow editorWindow = new EditorWindow(display, "Independence Facts", "Close", false, workbench);
                    DesktopController.getInstance().addEditorWindow(editorWindow, JLayeredPane.PALETTE_LAYER);
                    editorWindow.setVisible(true);
                }
            };
        }
    });
    // meekOrient.addActionListener(new ActionListener() {
    // public void actionPerformed(ActionEvent e) {
    // ImpliedOrientation rules = getAlgorithmRunner().getMeekRules();
    // rules.setKnowledge((IKnowledge) getAlgorithmRunner().getParams().get("knowledge", new Knowledge2()));
    // rules.orientImplied(getGraph());
    // getGraphHistory().add(getGraph());
    // getWorkbench().setGraph(getGraph());
    // firePropertyChange("modelChanged", null, null);
    // }
    // });
    dagInPattern.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Graph graph = new EdgeListGraph(getGraph());
            // Removing bidirected edges from the pattern before selecting a DAG.                                   4
            for (Edge edge : graph.getEdges()) {
                if (Edges.isBidirectedEdge(edge)) {
                    graph.removeEdge(edge);
                }
            }
            PatternToDag search = new PatternToDag(new EdgeListGraphSingleConnections(graph));
            Graph dag = search.patternToDagMeek();
            getGraphHistory().add(dag);
            getWorkbench().setGraph(dag);
            ((AbstractAlgorithmRunner) getAlgorithmRunner()).setResultGraph(dag);
            firePropertyChange("modelChanged", null, null);
        }
    });
    gesOrient.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            DataModel dataModel = getAlgorithmRunner().getDataModel();
            final Graph graph = SearchGraphUtils.reorient(getGraph(), dataModel, getKnowledge());
            getGraphHistory().add(graph);
            getWorkbench().setGraph(graph);
            firePropertyChange("modelChanged", null, null);
        }
    });
    nextGraph.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Graph next = getGraphHistory().next();
            getWorkbench().setGraph(next);
            ((AbstractAlgorithmRunner) getAlgorithmRunner()).setResultGraph(next);
            firePropertyChange("modelChanged", null, null);
        }
    });
    previousGraph.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Graph previous = getGraphHistory().previous();
            getWorkbench().setGraph(previous);
            ((AbstractAlgorithmRunner) getAlgorithmRunner()).setResultGraph(previous);
            firePropertyChange("modelChanged", null, null);
        }
    });
    menuBar.add(new LayoutMenu(this));
}
Also used : LayoutMenu(edu.cmu.tetradapp.workbench.LayoutMenu) ActionEvent(java.awt.event.ActionEvent) WatchedProcess(edu.cmu.tetradapp.util.WatchedProcess) ActionListener(java.awt.event.ActionListener) GraphWorkbench(edu.cmu.tetradapp.workbench.GraphWorkbench) DataModel(edu.cmu.tetrad.data.DataModel)

Example 2 with LayoutMenu

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

the class SemGraphEditor method createMenuBar.

// ===========================PRIVATE METHODS========================//
private JMenuBar createMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = new GraphFileMenu(this, getWorkbench());
    // JMenu fileMenu = createFileMenu();
    JMenu editMenu = createEditMenu();
    JMenu graphMenu = createGraphMenu();
    menuBar.add(fileMenu);
    menuBar.add(editMenu);
    menuBar.add(graphMenu);
    menuBar.add(new LayoutMenu(this));
    return menuBar;
}
Also used : LayoutMenu(edu.cmu.tetradapp.workbench.LayoutMenu)

Example 3 with LayoutMenu

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

the class MbSearchEditor method addSpecialMenus.

protected void addSpecialMenus(JMenuBar menuBar) {
    JMenu test = new JMenu("Independence");
    menuBar.add(test);
    IndTestMenuItems.addIndependenceTestChoices(test, this);
    if (getAlgorithmRunner() instanceof MbfsRunner) {
        JMenu graph = new JMenu("Graph");
        JMenuItem showDags = new JMenuItem("Show DAG's Consistent with forbid_latent_common_causes");
        // JMenuItem meekOrient = new JMenuItem("Meek Orientation");
        JMenuItem gesOrient = new JMenuItem("Global Score-based Reorientation");
        JMenuItem nextGraph = new JMenuItem("Next Graph");
        JMenuItem previousGraph = new JMenuItem("Previous Graph");
        graph.add(new GraphPropertiesAction(getWorkbench()));
        graph.add(new PathsAction(getWorkbench()));
        // graph.add(new DirectedPathsAction(getWorkbench()));
        // graph.add(new TreksAction(getWorkbench()));
        // graph.add(new AllPathsAction(getWorkbench()));
        // graph.add(new NeighborhoodsAction(getWorkbench()));
        graph.addSeparator();
        // graph.add(meekOrient);
        graph.add(gesOrient);
        graph.addSeparator();
        graph.add(previousGraph);
        graph.add(nextGraph);
        graph.addSeparator();
        graph.add(showDags);
        menuBar.add(graph);
        showDags.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                AlgorithmRunner runner = getAlgorithmRunner();
                if (!(runner instanceof MbfsRunner)) {
                    return;
                }
                MbfsRunner mbRunner = (MbfsRunner) runner;
                final Mbfs search = mbRunner.getMbFanSearch();
                if (search == null) {
                    JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), "The search was not stored.");
                    return;
                }
                MbPatternDisplay display = new MbPatternDisplay(search);
                JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), display, "MB DAG's Consistent with forbid_latent_common_causes", JOptionPane.PLAIN_MESSAGE);
            }
        });
        // meekOrient.addActionListener(new ActionListener() {
        // public void actionPerformed(ActionEvent e) {
        // ImpliedOrientation rules = getAlgorithmRunner().getMeekRules();
        // rules.setKnowledge((IKnowledge) getAlgorithmRunner().getParams().get("knowledge", new Knowledge2()));
        // rules.orientImplied(getGraph());
        // getWorkbench().setGraph(getGraph());
        // }
        // });
        gesOrient.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                DataModel dataModel = getAlgorithmRunner().getDataModel();
                final Graph graph = SearchGraphUtils.reorient(getGraph(), dataModel, getKnowledge());
                getGraphHistory().add(graph);
                getWorkbench().setGraph(graph);
                firePropertyChange("modelChanged", null, null);
            }
        });
    }
    // if (getAlgorithmRunner().supportsKnowledge()) {
    // menuBar.add(new Knowledge2Menu(this));
    // }
    menuBar.add(new LayoutMenu(this));
}
Also used : LayoutMenu(edu.cmu.tetradapp.workbench.LayoutMenu) ActionEvent(java.awt.event.ActionEvent) Mbfs(edu.cmu.tetrad.search.Mbfs) Graph(edu.cmu.tetrad.graph.Graph) ActionListener(java.awt.event.ActionListener) DataModel(edu.cmu.tetrad.data.DataModel)

Example 4 with LayoutMenu

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

the class PcGesSearchEditor method addSpecialMenus.

protected void addSpecialMenus(JMenuBar menuBar) {
    if (!(getAlgorithmRunner() instanceof IGesRunner)) {
        JMenu test = new JMenu("Independence");
        menuBar.add(test);
        IndTestMenuItems.addIndependenceTestChoices(test, this);
    // test.addSeparator();
    // 
    // AlgorithmRunner algorithmRunner = getAlgorithmRunner();
    // if (algorithmRunner instanceof IndTestProducer) {
    // IndTestProducer p = (IndTestProducer) algorithmRunner;
    // IndependenceFactsAction action =
    // new IndependenceFactsAction(this, p, "Independence Facts...");
    // test.add(action);
    // }
    }
    JMenu graph = new JMenu("Graph");
    JMenuItem showDags = new JMenuItem("Show DAGs in forbid_latent_common_causes");
    // JMenuItem meekOrient = new JMenuItem("Meek Orientation");
    JMenuItem dagInPattern = new JMenuItem("Choose DAG in forbid_latent_common_causes");
    JMenuItem gesOrient = new JMenuItem("Global Score-based Reorientation");
    JMenuItem nextGraph = new JMenuItem("Next Graph");
    JMenuItem previousGraph = new JMenuItem("Previous Graph");
    // graph.add(new LayoutMenu(this));
    graph.add(new GraphPropertiesAction(getWorkbench()));
    graph.add(new PathsAction(getWorkbench()));
    // graph.add(new DirectedPathsAction(getWorkbench()));
    // graph.add(new TreksAction(getWorkbench()));
    // graph.add(new AllPathsAction(getWorkbench()));
    // graph.add(new NeighborhoodsAction(getWorkbench()));
    graph.add(new TriplesAction(getWorkbench().getGraph(), getAlgorithmRunner()));
    graph.addSeparator();
    // graph.add(meekOrient);
    graph.add(dagInPattern);
    graph.add(gesOrient);
    graph.addSeparator();
    graph.add(previousGraph);
    graph.add(nextGraph);
    graph.addSeparator();
    graph.add(showDags);
    graph.addSeparator();
    graph.add(new JMenuItem(new SelectBidirectedAction(getWorkbench())));
    graph.add(new JMenuItem(new SelectUndirectedAction(getWorkbench())));
    menuBar.add(graph);
    showDags.addActionListener(new ActionListener() {

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

                public void watch() {
                    // Needs to be a pattern search; this isn't checked
                    // before running the algorithm because of allowable
                    // "slop"--e.g. bidirected edges.
                    AlgorithmRunner runner = getAlgorithmRunner();
                    Graph graph = runner.getGraph();
                    if (graph == null) {
                        JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), "No result gaph.");
                        return;
                    }
                    // if (runner instanceof ImagesRunner) {
                    // GraphScorer scorer = ((ImagesRunner) runner).getGraphScorer();
                    // Graph _graph = ((ImagesRunner) runner).getTopGraphs().get(getIndex()).getGraph();
                    // 
                    // ScoredGraphsDisplay display = new ScoredGraphsDisplay(_graph, scorer);
                    // GraphWorkbench workbench = getWorkbench();
                    // 
                    // EditorWindow editorWindow =
                    // new EditorWindow(display, "Independence Facts",
                    // "Close", false, workbench);
                    // DesktopController.getInstance().addEditorWindow(editorWindow, JLayeredPane.PALETTE_LAYER);
                    // editorWindow.setVisible(true);
                    // }
                    // else {
                    PatternDisplay display = new PatternDisplay(graph);
                    GraphWorkbench workbench = getWorkbench();
                    EditorWindow editorWindow = new EditorWindow(display, "Independence Facts", "Close", false, workbench);
                    DesktopController.getInstance().addEditorWindow(editorWindow, JLayeredPane.PALETTE_LAYER);
                    editorWindow.setVisible(true);
                // }
                }
            };
        }
    });
    // meekOrient.addActionListener(new ActionListener() {
    // public void actionPerformed(ActionEvent e) {
    // ImpliedOrientation rules = getAlgorithmRunner().getMeekRules();
    // rules.setKnowledge((IKnowledge) getAlgorithmRunner().getParams().get("knowledge", new Knowledge2()));
    // rules.orientImplied(getGraph());
    // getGraphHistory().add(getGraph());
    // getWorkbench().setGraph(getGraph());
    // firePropertyChange("modelChanged", null, null);
    // }
    // });
    dagInPattern.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Graph graph = new EdgeListGraph(getGraph());
            // // Removing bidirected edges from the pattern before selecting a DAG.                                   4
            // for (Edge edge : graph.getEdges()) {
            // if (Edges.isBidirectedEdge(edge)) {
            // graph.removeEdge(edge);
            // }
            // }
            Graph dag = SearchGraphUtils.dagFromPattern(graph);
            // PatternToDag search = new PatternToDag(new forbid_latent_common_causes(graph));
            // Graph dag = search.patternToDagMeek();
            getGraphHistory().add(dag);
            getWorkbench().setGraph(dag);
            ((AbstractAlgorithmRunner) getAlgorithmRunner()).setResultGraph(dag);
            firePropertyChange("modelChanged", null, null);
        }
    });
    gesOrient.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            DataModel dataModel = getAlgorithmRunner().getDataModel();
            final Graph graph = SearchGraphUtils.reorient(getGraph(), dataModel, getKnowledge());
            getGraphHistory().add(graph);
            getWorkbench().setGraph(graph);
            firePropertyChange("modelChanged", null, null);
        }
    });
    nextGraph.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Graph next = getGraphHistory().next();
            getWorkbench().setGraph(next);
            ((AbstractAlgorithmRunner) getAlgorithmRunner()).setResultGraph(next);
            firePropertyChange("modelChanged", null, null);
        }
    });
    previousGraph.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Graph previous = getGraphHistory().previous();
            getWorkbench().setGraph(previous);
            ((AbstractAlgorithmRunner) getAlgorithmRunner()).setResultGraph(previous);
            firePropertyChange("modelChanged", null, null);
        }
    });
    // if (getAlgorithmRunner().supportsKnowledge()) {
    // menuBar.add(new Knowledge2Menu(this));
    // }
    menuBar.add(new LayoutMenu(this));
}
Also used : LayoutMenu(edu.cmu.tetradapp.workbench.LayoutMenu) ActionEvent(java.awt.event.ActionEvent) WatchedProcess(edu.cmu.tetradapp.util.WatchedProcess) ActionListener(java.awt.event.ActionListener) GraphWorkbench(edu.cmu.tetradapp.workbench.GraphWorkbench)

Example 5 with LayoutMenu

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

the class DagEditor method createGraphMenuBar.

private JMenuBar createGraphMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = new GraphFileMenu(this, getWorkbench());
    // JMenu fileMenu = createFileMenu();
    JMenu editMenu = createEditMenu();
    JMenu graphMenu = createGraphMenu();
    menuBar.add(fileMenu);
    menuBar.add(editMenu);
    menuBar.add(graphMenu);
    menuBar.add(new LayoutMenu(this));
    return menuBar;
}
Also used : LayoutMenu(edu.cmu.tetradapp.workbench.LayoutMenu)

Aggregations

LayoutMenu (edu.cmu.tetradapp.workbench.LayoutMenu)11 ActionEvent (java.awt.event.ActionEvent)8 ActionListener (java.awt.event.ActionListener)8 WatchedProcess (edu.cmu.tetradapp.util.WatchedProcess)7 GraphWorkbench (edu.cmu.tetradapp.workbench.GraphWorkbench)7 DataModel (edu.cmu.tetrad.data.DataModel)5 PatternToDag (edu.cmu.tetrad.search.PatternToDag)3 Graph (edu.cmu.tetrad.graph.Graph)1 Mbfs (edu.cmu.tetrad.search.Mbfs)1