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.GraphWrapper;
import edu.cmu.tetradapp.model.IndTestProducer;
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.List;
import java.util.*;
/**
* Displays a workbench editing workbench area together with a toolbench for editing tetrad-style graphs.
*
* @author Aaron Powers
* @author josephramsey
* @author Zhou Yuan 8/22/2018
* @version $Id: $Id
*/
public final class GraphEditor extends JPanel implements GraphEditable, LayoutEditable, IndTestProducer {
@Serial
private static final long serialVersionUID = 5123725895449927539L;
private static final Set EVENTS = new HashSet<>(Arrays.asList(
"graph",
"edgeAdded",
"edgeRemoved",
"nodeRemoved"
));
/**
* 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;
/**
* Flag to indicate if interventional variables are in the graph - Zhou
*/
private boolean hasInterventional;
/**
* Flag to indicate if editing is enabled.
*/
private boolean enableEditing = true;
//===========================CONSTRUCTOR========================//
/**
*
Constructor for GraphEditor.
*
* @param graphWrapper a {@link edu.cmu.tetradapp.model.GraphWrapper} object
*/
public GraphEditor(GraphWrapper graphWrapper) {
// Check if this graph has interventional nodes - Zhou
boolean result = graphWrapper.getGraph().getNodes().stream()
.anyMatch(e -> (e.getNodeVariableType() == NodeVariableType.INTERVENTION_STATUS || e.getNodeVariableType() == NodeVariableType.INTERVENTION_VALUE));
setHasInterventional(result);
setLayout(new BorderLayout());
this.parameters = graphWrapper.getParameters();
this.edgeTypeTable = new EdgeTypeTable();
initUI(graphWrapper);
}
//===========================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 List getSelectedModelComponents() {
List selectedComponents
= getWorkbench().getSelectedComponents();
List selectedModelComponents
= new ArrayList<>();
for (Component comp : selectedComponents) {
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