}
mxGraph graph = aGraph.getGraph();
Object parent = graph.getDefaultParent();
Object[] vertices = aGraph.getChildVertices(parent);
mxIGraphModel model = graph.getModel();
int vertexNum = vertices.length;
double centerX = graphSize / 2f;
double centerY = centerX;
boolean isBranchSizeEven = ((numVerticesInBranch) % 2 == 0);
int middleIndex = (int) Math.ceil(numVerticesInBranch / 2f);
//create the circle
for (int i = 0; i < numBranches; i++)
{
for (int j = 0; j < numVerticesInBranch; j++)
{
double currSize = this.getRingSize(j + 1, numVerticesInBranch, graphSize);
//calc the position
double x = 0;
double y = 0;
int numVertexesInPerimeter = 0;
double currRatio = 0;
numVertexesInPerimeter = numBranches;
// need to detect the 2 middle vertices for even sized branches
if (isBranchSizeEven && j == middleIndex - 1)
{
//full size
currRatio = ((double) i - (0.0005f * graphSize / Math.pow(numVerticesInBranch, 1))) / (double) numVertexesInPerimeter;
}
else if (isBranchSizeEven && j == middleIndex)
{
currRatio = ((double) i + (0.0005f * graphSize / Math.pow(numVerticesInBranch, 1))) / (double) numVertexesInPerimeter;
}
else if (!isBranchSizeEven && currSize == graphSize)
{
currRatio = ((double) i / (double) numVertexesInPerimeter);
}
else
{
if (j + 1 < middleIndex)
{
//before middle
currRatio = ((double) (i - 1f / Math.pow(currSize, 0.25) + 0.00000000000015f * Math.pow(currSize, 4)) / (double) numVertexesInPerimeter);
}
else
{
//after middle
currRatio = ((double) (i + 1f / Math.pow(currSize, 0.25) - 0.00000000000015f * Math.pow(currSize, 4)) / (double) numVertexesInPerimeter);
}
}
currRatio = currRatio * 2;
currRatio = currRatio * (double) Math.PI;
x = Math.round(centerX + Math.round(currSize * Math.sin(currRatio) / 2));
y = Math.round(centerY - Math.round(currSize * Math.cos(currRatio) / 2));
//shoot
int currIndex = i * (numVerticesInBranch) + j;
Object currVertex = vertices[currIndex];
mxGeometry geometry = model.getGeometry(currVertex);
geometry.setX(x);
geometry.setY(y);
}
}
//the center vertex is the last one
Object currVertex = vertices[vertexNum - 1];
mxGeometry geometry = model.getGeometry(currVertex);
geometry.setX(centerX);
geometry.setY(centerY);
};