use of edu.cmu.tetradapp.model.GraphWrapper in project tetrad by cmu-phil.
the class MisclassificationsEditor method setup.
private void setup() {
java.util.List<Graph> referenceGraphs = comparison.getReferenceGraphs();
JTabbedPane pane = new JTabbedPane(JTabbedPane.LEFT);
for (int i = 0; i < referenceGraphs.size(); i++) {
JTabbedPane pane2 = new JTabbedPane(JTabbedPane.TOP);
String compareString = comparison.getComparisonString(i);
JPanel panel = new JPanel();
Font font = new Font("Monospaced", Font.PLAIN, 14);
final JTextArea textPane = new JTextArea();
textPane.setText(compareString);
textPane.setFont(font);
JScrollPane scroll = new JScrollPane(textPane);
scroll.setPreferredSize(new Dimension(400, 400));
panel.add(Box.createVerticalStrut(10));
Box box = Box.createHorizontalBox();
panel.add(box);
panel.add(Box.createVerticalStrut(10));
Box box1 = Box.createHorizontalBox();
box1.add(new JLabel("Graph Comparison: "));
box1.add(Box.createHorizontalGlue());
add(box1);
setLayout(new BorderLayout());
pane2.add("Comparison", scroll);
pane2.add("Target Graph", new GraphEditor(new GraphWrapper(comparison.getTargetGraphs().get(i))).getWorkbench());
pane2.add("True Graph", new GraphEditor(new GraphWrapper(comparison.getReferenceGraphs().get(i))).getWorkbench());
pane.add("" + (i + 1), pane2);
}
add(pane);
}
use of edu.cmu.tetradapp.model.GraphWrapper in project tetrad by cmu-phil.
the class PcSearchParamEditor method setup.
public void setup() {
/*
The variable names from the object being searched over (usually data).
*/
List<String> varNames = (List<String>) params.get("varNames", null);
DataModel dataModel1 = null;
Graph graph = null;
for (Object parentModel1 : this.parentModels) {
if (parentModel1 instanceof DataWrapper) {
DataWrapper dataWrapper = (DataWrapper) parentModel1;
dataModel1 = dataWrapper.getSelectedDataModel();
}
if (parentModel1 instanceof GraphWrapper) {
GraphWrapper graphWrapper = (GraphWrapper) parentModel1;
graph = graphWrapper.getGraph();
}
if (parentModel1 instanceof DagWrapper) {
DagWrapper dagWrapper = (DagWrapper) parentModel1;
graph = dagWrapper.getDag();
}
if (parentModel1 instanceof SemGraphWrapper) {
SemGraphWrapper semGraphWrapper = (SemGraphWrapper) parentModel1;
graph = semGraphWrapper.getGraph();
}
}
if (dataModel1 != null) {
varNames = new ArrayList<>(dataModel1.getVariableNames());
} else if (graph != null) {
Iterator<Node> it = graph.getNodes().iterator();
varNames = new ArrayList();
Node temp;
while (it.hasNext()) {
temp = it.next();
if (temp.getNodeType() == NodeType.MEASURED) {
varNames.add(temp.getName());
}
}
} else {
throw new NullPointerException("Null model (no graph or data model " + "passed to the search).");
}
this.params.set("varNames", varNames);
IntTextField depthField = new IntTextField(this.params.getInt("depth", -1), 4);
depthField.setFilter(new IntTextField.Filter() {
public int filter(int value, int oldValue) {
try {
PcSearchParamEditor.this.params.set("depth", value);
Preferences.userRoot().putInt("depth", value);
return value;
} catch (Exception e) {
return oldValue;
}
}
});
double alpha = params.getDouble("alpha", 0.001);
if (!Double.isNaN(alpha)) {
alphaField = new DoubleTextField(alpha, 4, NumberFormatUtil.getInstance().getNumberFormat());
alphaField.setFilter(new DoubleTextField.Filter() {
public double filter(double value, double oldValue) {
try {
PcSearchParamEditor.this.params.set("alpha", 0.001);
Preferences.userRoot().putDouble("alpha", value);
return value;
} catch (Exception e) {
return oldValue;
}
}
});
}
setBorder(new MatteBorder(10, 10, 10, 10, super.getBackground()));
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
if (!Double.isNaN(alpha)) {
Box b2 = Box.createHorizontalBox();
b2.add(new JLabel("Alpha Value:"));
b2.add(Box.createGlue());
b2.add(alphaField);
add(b2);
add(Box.createVerticalStrut(10));
}
Box b3 = Box.createHorizontalBox();
b3.add(new JLabel("Search Depth:"));
b3.add(Box.createGlue());
b3.add(depthField);
add(b3);
add(Box.createVerticalStrut(10));
}
use of edu.cmu.tetradapp.model.GraphWrapper in project tetrad by cmu-phil.
the class FciSearchParamEditor method setup.
public void setup() {
/*
The variable names from the object being searched over (usually data).
*/
List varNames = (List<String>) params.get("varNames", null);
DataModel dataModel1 = null;
Graph graph = null;
for (Object parentModel1 : parentModels) {
if (parentModel1 instanceof DataWrapper) {
DataWrapper dataWrapper = (DataWrapper) parentModel1;
dataModel1 = dataWrapper.getSelectedDataModel();
}
if (parentModel1 instanceof GraphWrapper) {
GraphWrapper graphWrapper = (GraphWrapper) parentModel1;
graph = graphWrapper.getGraph();
}
if (parentModel1 instanceof DagWrapper) {
DagWrapper dagWrapper = (DagWrapper) parentModel1;
graph = dagWrapper.getDag();
}
if (parentModel1 instanceof SemGraphWrapper) {
SemGraphWrapper semGraphWrapper = (SemGraphWrapper) parentModel1;
graph = semGraphWrapper.getGraph();
}
}
if (dataModel1 != null) {
varNames = new ArrayList(dataModel1.getVariableNames());
} else if (graph != null) {
Iterator<Node> it = graph.getNodes().iterator();
varNames = new ArrayList();
Node temp;
while (it.hasNext()) {
temp = it.next();
if (temp.getNodeType() == NodeType.MEASURED) {
varNames.add(temp.getName());
}
}
} else {
throw new NullPointerException("Null model (no graph or data model " + "passed to the search).");
}
params.set("varNames", varNames);
IntTextField depthField = new IntTextField(params.getInt("depth", -1), 4);
depthField.setFilter(new IntTextField.Filter() {
public int filter(int value, int oldValue) {
try {
params.set("depth", value);
return value;
} catch (Exception e) {
return oldValue;
}
}
});
double alpha = params.getDouble("alpha", 0.001);
if (!Double.isNaN(alpha)) {
alphaField = new DoubleTextField(alpha, 4, NumberFormatUtil.getInstance().getNumberFormat());
alphaField.setFilter(new DoubleTextField.Filter() {
public double filter(double value, double oldValue) {
try {
params.set("alpha", 0.001);
Preferences.userRoot().putDouble("alpha", value);
return value;
} catch (Exception e) {
return oldValue;
}
}
});
}
setBorder(new MatteBorder(10, 10, 10, 10, super.getBackground()));
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
Box b1 = Box.createHorizontalBox();
b1.add(new JLabel("Knowledge:"));
b1.add(Box.createGlue());
add(b1);
add(Box.createVerticalStrut(10));
if (!Double.isNaN(alpha)) {
Box b2 = Box.createHorizontalBox();
b2.add(new JLabel("Alpha Value:"));
b2.add(Box.createGlue());
b2.add(alphaField);
add(b2);
add(Box.createVerticalStrut(10));
}
Box b3 = Box.createHorizontalBox();
b3.add(new JLabel("Search Depth:"));
b3.add(Box.createGlue());
b3.add(depthField);
add(b3);
add(Box.createVerticalStrut(10));
}
use of edu.cmu.tetradapp.model.GraphWrapper in project tetrad by cmu-phil.
the class EdgewiseComparisonEditor method setup.
// ============================ Private Methods =========================//
private void setup() {
java.util.List<Graph> referenceGraphs = comparison.getReferenceGraphs();
JTabbedPane pane = new JTabbedPane(JTabbedPane.LEFT);
for (int i = 0; i < referenceGraphs.size(); i++) {
JTabbedPane pane2 = new JTabbedPane(JTabbedPane.TOP);
String compareString = comparison.getComparisonString(i);
JPanel panel = new JPanel();
Font font = new Font("Monospaced", Font.PLAIN, 14);
final JTextArea textPane = new JTextArea();
textPane.setText(compareString);
textPane.setFont(font);
JScrollPane scroll = new JScrollPane(textPane);
scroll.setPreferredSize(new Dimension(400, 400));
panel.add(Box.createVerticalStrut(10));
Box box = Box.createHorizontalBox();
panel.add(box);
panel.add(Box.createVerticalStrut(10));
Box box1 = Box.createHorizontalBox();
box1.add(new JLabel("Graph Comparison: "));
box1.add(Box.createHorizontalGlue());
add(box1);
setLayout(new BorderLayout());
pane2.add("Comparison", scroll);
pane2.add("Target Graph", new GraphEditor(new GraphWrapper(comparison.getTargetGraphs().get(i))).getWorkbench());
pane2.add("True Graph", new GraphEditor(new GraphWrapper(comparison.getReferenceGraphs().get(i))).getWorkbench());
pane.add("" + (i + 1), pane2);
}
add(pane);
}
use of edu.cmu.tetradapp.model.GraphWrapper in project tetrad by cmu-phil.
the class LogisticRegressionParamsPanel method getVarsFromGraph.
private List<String> getVarsFromGraph(Object[] parentModels) {
Object graphWrapper = null;
for (Object parentModel : parentModels) {
if (parentModel instanceof GraphWrapper) {
graphWrapper = parentModel;
} else if (parentModel instanceof DagWrapper) {
graphWrapper = parentModel;
}
}
if (graphWrapper == null) {
return null;
} else {
Graph graph = null;
if (graphWrapper instanceof GraphWrapper) {
graph = ((GraphWrapper) graphWrapper).getGraph();
} else if (graphWrapper instanceof DagWrapper) {
graph = ((DagWrapper) graphWrapper).getDag();
}
List<Node> nodes = graph.getNodes();
List<String> nodeNames = new LinkedList<>();
for (Node node : nodes) {
nodeNames.add(node.getName());
}
return nodeNames;
}
}
Aggregations