I am trying use exisitng Expand collapse feature associated with a TREE ( Graph2D ), to present the same Expand collpase features in a Directed Cyclic Graph.
The yFiles Methods(): = 1) getNodeArray() 2)createEdge() 3)getEdgeArray() which are part of Graph2D( that support Tree Like Structure ).
---
Problem : CreateEdge() DOES NOT support creating Edge with Nodes that already exist in the Yfiles getNodeArray().
what changes would you recomend to Support these feature for a Graph.
To demonstracte my evaluation, here is code snippet.
------START CODE-------
Iterator relationIterator = sortedMap.keySet().iterator();
/*
* The Following Code Creates a Graph structure based on
* the TreeMap<String, List>(parentChildMap);
* 1 [2, 3, 4]
* 2 [3, 4]
* 3 [4]
* 4 []
* while keeping the "key" as the Root Node, will create Child Nodes bases on the elements in the "List"
* While repeating this Processes, the Code also looks for Nodes that have already been create.
* Hence if a Node already exist within a YFiles getNodeArray(). then a new node will NOT be create BUT
* a CreateEdge() Method will be called between the two already exiting Nodes will be called.
*
*/
while (relationIterator.hasNext()) {
String key = relationIterator.next().toString();
Node company = null;
NodeRealizer companyRealizer = null;
// set the label of this node
for (int docIdParent = 0; docIdParent < relatedDocList.size(); docIdParent++) {
if (relatedDocList.get(docIdParent).getId().equals(key)) {
String parentRelation = relatedDocList.get(docIdParent)
.getDocNo();
if (graph.getNodeArray().length > 1) {
for (int k = 0; k < graph.getNodeArray().length; k++) {
if (graph.getNodeArray()[k].toString().equals(
parentRelation)) {
company = graph.getNodeArray()[k];
}
}
} else {
// start block - ROOT
company = graph.createNode();
companyRealizer = graph.getRealizer(company);
companyRealizer.getLabel().setText(parentRelation);
companyRealizer.setFillColor(new Color(255, 102, 51));
// end block
}
}
}
childList = sortedMap.get(key);
boolean flag = true;
// Create child Nodes
for (int j = 0; j < childList.size(); j++) {
for (int docIdChildren = 0; docIdChildren < relatedDocList
.size(); docIdChildren++) {
if (childList.get(j).equals(
relatedDocList.get(docIdChildren).getId())) {
String childNodeName = relatedDocList
.get(docIdChildren).getDocNo();
Node docNo = null;
NodeRealizer realizer = null;
for (int k = 0; k < graph.getNodeArray().length; k++) {
if (graph.getNodeArray()[k].toString().equals(
childNodeName)) {
docNo = graph.getNodeArray()[k];
graph.createEdge(company, docNo);
flag = false;
}
}
if (flag) {
// start Block - child
docNo = graph.createNode();
realizer = graph.getRealizer(docNo);
// set the label of this node
// System.out.println("nodeName :"+childNodeName);
realizer.getLabel().setText(childNodeName);
// some style customization
realizer.setFillColor(new Color(255, 204, 51));
// end Block - child
graph.createEdge(company, docNo);
}
}
}
}
}
------END CODE-------
For the Approach Needed :
I have seen lazyloading using GraphML. PLease Dont direct me towards that solution.
I am looking for changes in the Datastructure, ( during Runtime ) that support the states or such kind of events.