graph.addEdge(parentStack.get(0), node);
}
private JGraph createJGraph() {
// create a visualization using JGraph, via an adapter
JGraphModelAdapter m_jgAdapter = new JGraphModelAdapter(graph, JGraphModelAdapter.createDefaultVertexAttributes(), createDefaultEdgeAttributes());
this.jgraph = new JGraph(m_jgAdapter);
// layout setting
JGraphUtils.applyOrderedTreeLayout(graph, m_jgAdapter, jgraph);
// vertex color setting
Iterator vertexIter = graph.vertexSet().iterator();
while(vertexIter.hasNext()) {
String vertex = (String) vertexIter.next();
if(vertex.indexOf("QuantifiedExpr") > 0 || vertex.indexOf("FLWRExpr") > 0
|| vertex.indexOf("PromoteJoinExpression") > 0) {
DefaultGraphCell cell = m_jgAdapter.getVertexCell(vertex);
AttributeMap attr = cell.getAttributes();
GraphConstants.setBackground(attr, RED_NODE_COLOR);
AttributeMap cellAttr = new AttributeMap();
cellAttr.put(cell, attr);
m_jgAdapter.edit(cellAttr, null, null, null);
} else if(vertex.indexOf("DistinctSortExpr") > 0) {
DefaultGraphCell cell = m_jgAdapter.getVertexCell(vertex);
AttributeMap attr = cell.getAttributes();
GraphConstants.setBackground(attr, GREEN_NODE_COLOR);
AttributeMap cellAttr = new AttributeMap();
cellAttr.put(cell, attr);
m_jgAdapter.edit(cellAttr, null, null, null);
} else if(vertex.indexOf("PathIndexAccessExpr") > 0) {
DefaultGraphCell cell = m_jgAdapter.getVertexCell(vertex);
AttributeMap attr = cell.getAttributes();
GraphConstants.setBackground(attr, BLUE_NODE_COLOR);
AttributeMap cellAttr = new AttributeMap();
cellAttr.put(cell, attr);
m_jgAdapter.edit(cellAttr, null, null, null);
}
}
// mouseClicked event handling
jgraph.addMouseListener(new MyMouseListener());
return jgraph;