private void createMatrix() {
		// Current coordinates
		int x, y;
		// Current value
		int k = 0;
		// Dimensions of the sub-matrix we are working on during our spiral tracing
		int subMatrixLeft;
		int subMatrixTop;
		int subMatrixRight;
		int subMatrixBottom;
		int subMatrixSize = 1;
		
		// What number will trigger the next sub-matrix
		int nextExpansionAt = 1;

		// Get total memory requirement and allocate an array
		matrixSize = getMatrixWidth();
		matrix = new int[matrixSize][matrixSize];
		
		// Default all cells to -1 to indicate that they are blank
		for (int i = 0; i < matrixSize; i++) {
			for (int j = 0; j < matrixSize; j++) {
				matrix[i][j] = -1;
			}
		}
		
		// Get the dimensions for the initial sub-matrix (just the center cell)
		x = matrixSize/2;
		y = matrixSize/2;
		subMatrixLeft = x;
		subMatrixTop = y;
		subMatrixRight = x;
		subMatrixBottom = y;
		
		while (k <= maximum) {
			// Plot this number
			matrix[x][y] = k;
			
			k++;
			
			// If we have filled our submatrix, create the next part of the spiral 
			if (k == nextExpansionAt) {
				// Expand out one in each direction
				subMatrixSize += 2;
				subMatrixLeft--;
				subMatrixRight++;
				subMatrixTop--;
				subMatrixBottom++;
				
				// The next expansion occurs when we have filled all the cells in our sub-matrix
				nextExpansionAt = subMatrixSize * subMatrixSize;
			}

			if (x == subMatrixRight) {
				if (y < subMatrixBottom)
					// Move down the right side
					y++;
				else
					// Move left from the bottom-right corner
					x--;
			}
			else if (x == subMatrixLeft) {
				if (y > subMatrixTop)
					// Move up the left side
					y--;
				else
					// Move right from the top-left corner
					x++;
			}
			else if (y == subMatrixBottom) {
				// Move left along the bottom
				x--;
			}
			else {
				// Move right along the top
				x++;
			}
			
		}
		
	}