use of edu.cmu.tetrad.graph.EdgeTypeProbability in project tetrad by cmu-phil.
the class JsonUtils method parseJSONObjectToEdgeTypeProperty.
public static EdgeTypeProbability parseJSONObjectToEdgeTypeProperty(JSONObject jObj) {
String _edgeType = jObj.getString("edgeType");
EdgeType edgeType = EdgeType.nil;
switch(_edgeType) {
case "ta":
edgeType = EdgeType.ta;
break;
case "at":
edgeType = EdgeType.at;
break;
case "ca":
edgeType = EdgeType.ca;
break;
case "ac":
edgeType = EdgeType.ac;
break;
case "cc":
edgeType = EdgeType.cc;
break;
case "aa":
edgeType = EdgeType.aa;
break;
case "tt":
edgeType = EdgeType.tt;
break;
}
double probability = jObj.getDouble("probability");
EdgeTypeProbability edgeTypeProbability = new EdgeTypeProbability(edgeType, probability);
return edgeTypeProbability;
}
use of edu.cmu.tetrad.graph.EdgeTypeProbability in project tetrad by cmu-phil.
the class AbstractWorkbench method handleMouseEntered.
private void handleMouseEntered(MouseEvent e) {
Object source = e.getSource();
if (source instanceof DisplayEdge) {
IDisplayEdge displayEdge = (DisplayEdge) source;
Edge edge = displayEdge.getModelEdge();
if (graph.containsEdge(edge)) {
// Bootstrapping Distribution
List<EdgeTypeProbability> edgeProb = edge.getEdgeTypeProbabilities();
if (edgeProb != null) {
String endpoint1 = edge.getEndpoint1().toString();
switch(endpoint1) {
case "Tail":
endpoint1 = "-";
break;
case "Arrow":
endpoint1 = "<";
break;
case "Circle":
endpoint1 = "o";
break;
case "Star":
endpoint1 = "*";
break;
case "Null":
endpoint1 = "Null";
break;
}
String endpoint2 = edge.getEndpoint2().toString();
switch(endpoint2) {
case "Tail":
endpoint2 = "-";
break;
case "Arrow":
endpoint2 = ">";
break;
case "Circle":
endpoint2 = "o";
break;
case "Star":
endpoint2 = "*";
break;
case "Null":
endpoint2 = "Null";
break;
}
String text = "<html>" + edge.getNode1().getName() + " " + endpoint1 + "-" + endpoint2 + " " + edge.getNode2().getName() + "<br>";
String n1 = edge.getNode1().getName();
String n2 = edge.getNode2().getName();
List<String> nodes = new ArrayList<>();
nodes.add(n1);
nodes.add(n2);
Collections.sort(nodes);
for (EdgeTypeProbability edgeTypeProb : edgeProb) {
String _type = "" + edgeTypeProb.getEdgeType();
switch(edgeTypeProb.getEdgeType()) {
case nil:
_type = "no edge";
break;
case ta:
_type = "-->";
_type = nodes.get(0) + " " + _type + " " + nodes.get(1);
break;
case at:
_type = "<--";
_type = nodes.get(0) + " " + _type + " " + nodes.get(1);
break;
case ca:
_type = "o->";
_type = nodes.get(0) + " " + _type + " " + nodes.get(1);
break;
case ac:
_type = "<-o";
_type = nodes.get(0) + " " + _type + " " + nodes.get(1);
break;
case cc:
_type = "o-o";
_type = nodes.get(0) + " " + _type + " " + nodes.get(1);
break;
case aa:
_type = "<->";
_type = nodes.get(0) + " " + _type + " " + nodes.get(1);
break;
case tt:
_type = "---";
_type = nodes.get(0) + " " + _type + " " + nodes.get(1);
break;
default:
break;
}
if (edgeTypeProb.getProbability() > 0) {
text += "[" + _type + "]:" + String.format("%.4f", edgeTypeProb.getProbability());
text += "<br>";
}
}
// Commented out by Zhou
// JLabel edgeTypeDistLabel = new JLabel(text);
// edgeTypeDistLabel.setOpaque(true);
// edgeTypeDistLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
// setEdgeLabel(edge, edgeTypeDistLabel);
// Use tooltip instead of label - Added by Zhou
setEdgeToolTip(edge, text);
}
}
}
}
Aggregations