src/main/java/com/mxgraph/layout/mxFastOrganicLayout.java
protected void calcRepulsion()
	{
		int vertexCount = vertexArray.length;

		for (int i = 0; i < vertexCount; i++)
		{
			for (int j = i; j < vertexCount; j++)
			{
				// Exits if the layout is no longer allowed to run
				if (!allowedToRun)
				{
					return;
				}

				if (j != i)
				{
					double xDelta = cellLocation[i][0] - cellLocation[j][0];
					double yDelta = cellLocation[i][1] - cellLocation[j][1];

					if (xDelta == 0)
					{
						xDelta = 0.01 + Math.random();
					}

					if (yDelta == 0)
					{
						yDelta = 0.01 + Math.random();
					}

					// Distance between nodes
					double deltaLength = Math.sqrt((xDelta * xDelta)
							+ (yDelta * yDelta));

					double deltaLengthWithRadius = deltaLength - radius[i]
							- radius[j];

					if (deltaLengthWithRadius > maxDistanceLimit)
					{
						// Ignore vertices too far apart
						continue;
					}

					if (deltaLengthWithRadius < minDistanceLimit)
					{
						deltaLengthWithRadius = minDistanceLimit;
					}

					double force = forceConstantSquared / deltaLengthWithRadius;

					double displacementX = (xDelta / deltaLength) * force;
					double displacementY = (yDelta / deltaLength) * force;

					if (isMoveable[i])
					{
						dispX[i] += displacementX;
						dispY[i] += displacementY;
					}

					if (isMoveable[j])
					{
						dispX[j] -= displacementX;
						dispY[j] -= displacementY;
					}
				}
			}
		}
	}
/**
	 * Calculates the repulsive forces between all laid out nodes
	 */
Calculates the repulsive forces between all laid out nodes
Calculates the repulsive forces between all laid out nodes
protected void calcRepulsion()
	{
		int vertexCount = vertexArray.length;
		for (int i = 0; i < vertexCount; i++)
		{
			for (int j = i; j < vertexCount; j++)
			{
				if (!allowedToRun)
				{
					return;
				}
				if (j != i)
				{
					double xDelta = cellLocation[i][0] - cellLocation[j][0];
					double yDelta = cellLocation[i][1] - cellLocation[j][1];
					if (xDelta == 0)
					{
						xDelta = 0.01 + Math.random();
					}
					if (yDelta == 0)
					{
						yDelta = 0.01 + Math.random();
					}
					double deltaLength = Math.sqrt((xDelta * xDelta)
							+ (yDelta * yDelta));
					double deltaLengthWithRadius = deltaLength - radius[i]
							- radius[j];
					if (deltaLengthWithRadius > maxDistanceLimit)
					{
						continue;
					}
					if (deltaLengthWithRadius < minDistanceLimit)
					{
						deltaLengthWithRadius = minDistanceLimit;
					}
					double force = forceConstantSquared / deltaLengthWithRadius;
					double displacementX = (xDelta / deltaLength) * force;
					double displacementY = (yDelta / deltaLength) * force;
					if (isMoveable[i])
					{
						dispX[i] += displacementX;
						dispY[i] += displacementY;
					}
					if (isMoveable[j])
					{
						dispX[j] -= displacementX;
						dispY[j] -= displacementY;
					}
				}
			}
		}
	}
protected void calcRepulsion ( ) { int vertexCount = vertexArray . length ; for ( int i = 0 ; i < vertexCount ; i ++ ) { for ( int j = i ; j < vertexCount ; j ++ ) { if ( ! allowedToRun ) { return ; } if ( j != i ) { double xDelta = cellLocation [ i ] [ 0 ] - cellLocation [ j ] [ 0 ] ; double yDelta = cellLocation [ i ] [ 1 ] - cellLocation [ j ] [ 1 ] ; if ( xDelta == 0 ) { xDelta = 0.01 + Math . random ( ) ; } if ( yDelta == 0 ) { yDelta = 0.01 + Math . random ( ) ; } double deltaLength = Math . sqrt ( ( xDelta * xDelta ) + ( yDelta * yDelta ) ) ; double deltaLengthWithRadius = deltaLength - radius [ i ] - radius [ j ] ; if ( deltaLengthWithRadius > maxDistanceLimit ) { continue ; } if ( deltaLengthWithRadius < minDistanceLimit ) { deltaLengthWithRadius = minDistanceLimit ; } double force = forceConstantSquared / deltaLengthWithRadius ; double displacementX = ( xDelta / deltaLength ) * force ; double displacementY = ( yDelta / deltaLength ) * force ; if ( isMoveable [ i ] ) { dispX [ i ] += displacementX ; dispY [ i ] += displacementY ; } if ( isMoveable [ j ] ) { dispX [ j ] -= displacementX ; dispY [ j ] -= displacementY ; } } } } }
Calculates the repulsive forces between all laid out nodes
Calculates the repulsive forces between all laid out nodes
// Exits if the layout is no longer allowed to run // Distance between nodes // Ignore vertices too far apart