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.IndTestProducer;
import edu.cmu.tetradapp.model.SemGraphWrapper;
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.List;
import java.util.*;
import static edu.cmu.tetradapp.util.GraphUtils.addGraphManipItems;
/**
* 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 SemGraphEditor extends JPanel
implements GraphEditable, LayoutEditable, DelegatesEditing, IndTestProducer {
@Serial
private static final long serialVersionUID = 6837233499169689575L;
/**
* The semGraphWrapper being edited.
*/
private final SemGraphWrapper semGraphWrapper;
/**
* The parameters for the graph.
*/
private final Parameters parameters;
/**
* The scroll pane for the graph editor.
*/
private final JScrollPane graphEditorScroll = new JScrollPane();
/**
* The edge type table.
*/
private final EdgeTypeTable edgeTypeTable;
/**
* The workbench for the graph editor.
*/
private GraphWorkbench workbench;
//===========================CONSTRUCTOR========================//
/**
*
Constructor for SemGraphEditor.
*
* @param semGraphWrapper a {@link edu.cmu.tetradapp.model.SemGraphWrapper} object
*/
public SemGraphEditor(SemGraphWrapper semGraphWrapper) {
if (semGraphWrapper == null) {
throw new NullPointerException();
}
setLayout(new BorderLayout());
this.semGraphWrapper = semGraphWrapper;
this.parameters = semGraphWrapper.getParameters();
this.edgeTypeTable = new EdgeTypeTable();
initUI(semGraphWrapper);
}
//===========================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<>();
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