src/main/java/com/mxgraph/layout/mxFastOrganicLayout.java
protected void calcAttraction()
	{
		// Check the neighbours of each vertex and calculate the attractive
		// force of the edge connecting them
		for (int i = 0; i < vertexArray.length; i++)
		{
			for (int k = 0; k < neighbours[i].length; k++)
			{
				// Get the index of the othe cell in the vertex array
				int j = neighbours[i][k];

				// Do not proceed self-loops
				if (i != j)
				{
					double xDelta = cellLocation[i][0] - cellLocation[j][0];
					double yDelta = cellLocation[i][1] - cellLocation[j][1];

					// The distance between the nodes
					double deltaLengthSquared = xDelta * xDelta + yDelta
							* yDelta - radiusSquared[i] - radiusSquared[j];

					if (deltaLengthSquared < minDistanceLimitSquared)
					{
						deltaLengthSquared = minDistanceLimitSquared;
					}

					double deltaLength = Math.sqrt(deltaLengthSquared);
					double force = (deltaLengthSquared) / forceConstant;

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

					if (isMoveable[i])
					{
						this.dispX[i] -= displacementX;
						this.dispY[i] -= displacementY;
					}

					if (isMoveable[j])
					{
						dispX[j] += displacementX;
						dispY[j] += displacementY;
					}
				}
			}
		}
	}
/**
	 * Calculates the attractive forces between all laid out nodes linked by
	 * edges
	 */
Calculates the attractive forces between all laid out nodes linked by
edges
Calculates the attractive forces between all laid out nodes linked by edges
protected void calcAttraction()
	{
		for (int i = 0; i < vertexArray.length; i++)
		{
			for (int k = 0; k < neighbours[i].length; k++)
			{
				int j = neighbours[i][k];
				if (i != j)
				{
					double xDelta = cellLocation[i][0] - cellLocation[j][0];
					double yDelta = cellLocation[i][1] - cellLocation[j][1];
					double deltaLengthSquared = xDelta * xDelta + yDelta
							* yDelta - radiusSquared[i] - radiusSquared[j];
					if (deltaLengthSquared < minDistanceLimitSquared)
					{
						deltaLengthSquared = minDistanceLimitSquared;
					}
					double deltaLength = Math.sqrt(deltaLengthSquared);
					double force = (deltaLengthSquared) / forceConstant;
					double displacementX = (xDelta / deltaLength) * force;
					double displacementY = (yDelta / deltaLength) * force;
					if (isMoveable[i])
					{
						this.dispX[i] -= displacementX;
						this.dispY[i] -= displacementY;
					}
					if (isMoveable[j])
					{
						dispX[j] += displacementX;
						dispY[j] += displacementY;
					}
				}
			}
		}
	}
protected void calcAttraction ( ) { for ( int i = 0 ; i < vertexArray . length ; i ++ ) { for ( int k = 0 ; k < neighbours [ i ] . length ; k ++ ) { int j = neighbours [ i ] [ k ] ; if ( i != j ) { double xDelta = cellLocation [ i ] [ 0 ] - cellLocation [ j ] [ 0 ] ; double yDelta = cellLocation [ i ] [ 1 ] - cellLocation [ j ] [ 1 ] ; double deltaLengthSquared = xDelta * xDelta + yDelta * yDelta - radiusSquared [ i ] - radiusSquared [ j ] ; if ( deltaLengthSquared < minDistanceLimitSquared ) { deltaLengthSquared = minDistanceLimitSquared ; } double deltaLength = Math . sqrt ( deltaLengthSquared ) ; double force = ( deltaLengthSquared ) / forceConstant ; double displacementX = ( xDelta / deltaLength ) * force ; double displacementY = ( yDelta / deltaLength ) * force ; if ( isMoveable [ i ] ) { this . dispX [ i ] -= displacementX ; this . dispY [ i ] -= displacementY ; } if ( isMoveable [ j ] ) { dispX [ j ] += displacementX ; dispY [ j ] += displacementY ; } } } } }
Calculates the attractive forces between all laid out nodes linked by
 edges
Calculates the attractive forces between all laid out nodes linked by edges
// Check the neighbours of each vertex and calculate the attractive // force of the edge connecting them // Get the index of the othe cell in the vertex array // Do not proceed self-loops // The distance between the nodes