My function is:
private void addEdges(mxICell mainObject, List<Object> edgesList) {
if (mainObject.getEdgeCount() > 0) {
// for (int i = 0; i < mainObject.getEdgeCount(); i++) {
edgesList.add(mainObject.getEdgeAt(0));
addEdges(((Line) mainObject.getEdgeAt(0)).getSource(), edgesList);
}
// }
else
return;
}
BEGING UPDATE The function calling is here:
for (Object obj : map.values()) {
if (obj instanceof Port
&& ((Port) obj).getParent().getStyle().equals("POWER")) {
String Feeder = ((Port) obj).getParent().getValue()
.toString();
List<Object> edgesList = new ArrayList<Object>();
Port p = (Port) obj;
mxICell mainObject = p;
addEdges(mainObject, edgesList);
//staff
}}
END UPDATE it gives me a
Exception occurred during event dispatching:
java.lang.StackOverflowError
This is because once the edge count of your
mainObject
is greater than zero the function calls itself over and over again, resulting in a stackoverflow exception. You need to define a proper termination condition.There is most likely a circle in your datastructure.
For example:
Or something like that. Fact is, your recursive call never terminates.