use of edu.cmu.tetrad.search.XdslXmlParser in project tetrad by cmu-phil.
the class LoadBayesImXsdlXmlAction method actionPerformed.
public void actionPerformed(ActionEvent e) {
if (bayesImWrapper == null) {
throw new RuntimeException("Not a Bayes IM.");
}
JFileChooser chooser = getJFileChooser();
chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
chooser.showOpenDialog(null);
File file = chooser.getSelectedFile();
if (file != null) {
Preferences.userRoot().put("fileSaveLocation", file.getParent());
}
try {
Builder builder = new Builder();
Document document = builder.build(file);
printDocument(document);
XdslXmlParser parser = new XdslXmlParser();
BayesIm bayesIm = parser.getBayesIm(document.getRootElement());
System.out.println(bayesIm);
boolean allSpecified = true;
for (edu.cmu.tetrad.graph.Node node : bayesIm.getBayesPm().getDag().getNodes()) {
if (node.getCenterX() == -1 || node.getCenterY() == -1) {
allSpecified = false;
}
}
if (!allSpecified) {
GraphUtils.circleLayout(bayesIm.getBayesPm().getDag(), 200, 200, 150);
}
bayesImWrapper.setBayesIm(bayesIm);
bayesImEditor.getBayesIm(bayesIm);
} catch (ParsingException e2) {
e2.printStackTrace();
throw new RuntimeException("Had trouble parsing that...");
} catch (IOException e2) {
e2.printStackTrace();
throw new RuntimeException("Had trouble reading the file...");
}
}
Aggregations