-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1443 from cmu-phil/final_7_1_3_merge
Final merge for 7.1.3
- Loading branch information
Showing
18 changed files
with
320 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LoadGraphPcalg.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/////////////////////////////////////////////////////////////////////////////// | ||
// 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.graph.Graph; | ||
import edu.cmu.tetrad.graph.GraphUtils; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.awt.event.ActionEvent; | ||
import java.io.File; | ||
import java.util.prefs.Preferences; | ||
|
||
/** | ||
* @author Joseph Ramsey [email protected] | ||
*/ | ||
class LoadGraphPcalg extends AbstractAction { | ||
|
||
/** | ||
* The component whose image is to be saved. | ||
*/ | ||
private final GraphEditable graphEditable; | ||
|
||
public LoadGraphPcalg(GraphEditable graphEditable, String title) { | ||
super(title); | ||
|
||
if (graphEditable == null) { | ||
throw new NullPointerException("Component must not be null."); | ||
} | ||
|
||
this.graphEditable = graphEditable; | ||
} | ||
|
||
/** | ||
* Performs the action of loading a session from a file. | ||
*/ | ||
public void actionPerformed(ActionEvent e) { | ||
JFileChooser chooser = LoadGraphPcalg.getJFileChooser(); | ||
chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); | ||
chooser.showOpenDialog((Component) this.graphEditable); | ||
|
||
File file = chooser.getSelectedFile(); | ||
|
||
if (file == null) { | ||
System.out.println("File was null."); | ||
return; | ||
} | ||
|
||
Preferences.userRoot().put("fileSaveLocation", file.getParent()); | ||
|
||
Graph graph = GraphUtils.loadGraphPcalg(file); | ||
GraphUtils.circleLayout(graph, 200, 200, 150); | ||
this.graphEditable.setGraph(graph); | ||
} | ||
|
||
private static JFileChooser getJFileChooser() { | ||
JFileChooser chooser = new JFileChooser(); | ||
String sessionSaveLocation = | ||
Preferences.userRoot().get("fileSaveLocation", ""); | ||
chooser.setCurrentDirectory(new File(sessionSaveLocation)); | ||
chooser.resetChoosableFileFilters(); | ||
chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); | ||
return chooser; | ||
} | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.