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;
}
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();
}
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;
}
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);
}
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);
}
Aggregations