Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
///////////////////////////////////////////////////////////////////////////////
// For information as to what this class does, see the Javadoc, below. //
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, //
// 2007, 2008, 2009, 2010, 2014, 2015, 2022 by Peter Spirtes, Richard //
// Scheines, Joseph Ramsey, and Clark Glymour. //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
///////////////////////////////////////////////////////////////////////////////
package edu.cmu.tetradapp.editor;
import edu.cmu.tetrad.data.Knowledge;
import edu.cmu.tetrad.graph.*;
import edu.cmu.tetrad.search.IndependenceTest;
import edu.cmu.tetrad.search.test.MsepTest;
import edu.cmu.tetrad.util.Parameters;
import edu.cmu.tetrad.util.TetradSerializable;
import edu.cmu.tetradapp.model.DagWrapper;
import edu.cmu.tetradapp.model.IndTestProducer;
import edu.cmu.tetradapp.session.DelegatesEditing;
import edu.cmu.tetradapp.ui.PaddingPanel;
import edu.cmu.tetradapp.util.DesktopController;
import edu.cmu.tetradapp.util.GraphUtils;
import edu.cmu.tetradapp.util.LayoutEditable;
import edu.cmu.tetradapp.workbench.DisplayEdge;
import edu.cmu.tetradapp.workbench.DisplayNode;
import edu.cmu.tetradapp.workbench.GraphWorkbench;
import edu.cmu.tetradapp.workbench.LayoutMenu;
import javax.swing.*;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent;
import java.io.Serial;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* Displays a workbench editing workbench area together with a toolbench for editing tetrad-style graphs.
*
* @author Aaron Powers
* @author josephramsey
* @author Zhou Yuan
* @version $Id: $Id
*/
public final class DagEditor extends JPanel
implements GraphEditable, LayoutEditable, DelegatesEditing, IndTestProducer {
@Serial
private static final long serialVersionUID = -6082746735835257666L;
/**
* The parameters for the graph.
*/
private final Parameters parameters;
/**
* The scroll pane for the graph editor.
*/
private final JScrollPane graphEditorScroll = new JScrollPane();
/**
* The table for the edge types.
*/
private final EdgeTypeTable edgeTypeTable;
/**
* The workbench for the graph.
*/
private GraphWorkbench workbench;
/**
*
Constructor for DagEditor.
*
* @param dagWrapper a {@link edu.cmu.tetradapp.model.DagWrapper} object
*/
public DagEditor(DagWrapper dagWrapper) {
setLayout(new BorderLayout());
this.parameters = dagWrapper.getParameters();
this.edgeTypeTable = new EdgeTypeTable();
initUI(dagWrapper);
}
//===========================PUBLIC METHODS======================//
/**
* {@inheritDoc}
*
* Sets the name of this editor.
*/
@Override
public void setName(String name) {
String oldName = getName();
super.setName(name);
firePropertyChange("name", oldName, getName());
}
/**
* {@inheritDoc}
*/
@Override
public JComponent getEditDelegate() {
return getWorkbench();
}
/**
* {@inheritDoc}
*/
@Override
public GraphWorkbench getWorkbench() {
return this.workbench;
}
/**
* {@inheritDoc}
*
* Returns a list of all the SessionNodeWrappers (TetradNodes) and SessionNodeEdges that are model components for
* the respective SessionNodes and SessionEdges selected in the workbench. Note that the workbench, not the
* SessionEditorNodes themselves, keeps track of the selection.
*/
@Override
public List getSelectedModelComponents() {
List selectedComponents
= getWorkbench().getSelectedComponents();
List selectedModelComponents
= new ArrayList<>();
selectedComponents.forEach(comp -> {
if (comp instanceof DisplayNode) {
selectedModelComponents.add(
((DisplayNode) comp).getModelNode());
} else if (comp instanceof DisplayEdge) {
selectedModelComponents.add(
((DisplayEdge) comp).getModelEdge());
}
});
return selectedModelComponents;
}
/**
* {@inheritDoc}
*
* Pastes list of session elements into the workbench.
*/
@Override
public void pasteSubsession(List