Consider the nilpotent orbit, $\mathcal{O}_X$, of a semi-simple Lie algebra, $\mathfrak{g}$, represented by a nilpotent element $X\in \mathfrak{g}$. We can then always find a triplet $\{H,X,Y\}$ generating an $\mathfrak{sl}_2$ algebra (in particular $[H,X]=2X$). The element $H$ then generates a $\mathbb{Z}$-grading of the algebra: \begin{equation} \mathfrak{g} = \bigoplus_{\lambda\in\mathbb{Z}}\mathfrak{g}_\lambda\,,\qquad\mathfrak{g}_\lambda= \left\{ Z\in\mathfrak{g}|[H,Z]= \lambda Z \right\} \end{equation}
For type A algebras, $\mathfrak{g}=\mathfrak{sl}(n)$, there is a one-to-one correspondence between partitions of $n$ and the nilpotent orbits: given a partition $[p_1, \dots, p_k]$, the representative of the orbit can be taken in its Jordan form: \begin{equation} X = \bigoplus_i J_{p_i-1} \end{equation} where $J_{k}$ is the Jordan block of size $k\times k$. The element $H$ is then found to be \begin{equation} H = \bigoplus_i H_{p_i-1}\,,\qquad H_k = \text{Diag}(k,k-1,\dots,-(k-1),-k) \end{equation} Is there a closed-form formula for the dimension of each $\mathfrak{g}_\lambda$ in terms of the partition?
I can compute the above decomposition deduce $\text{dim}\mathfrak{g}_\lambda$ algorithmically by finding the commutator of $H$ with all the roots, but I'm interested in a general formula (if it exists). I have checked Collingwood and McGovern's Nilpotent Orbits in Semisimple Lie Algebras, but they only give a formula for the dimension of the orbit $\text{dim}\mathfrak{g}-\text{dim}\mathfrak{g}_0-\text{dim}\mathfrak{g}_1$.
If there's indeed a formula, is there an equivalent for $\mathfrak{so}(2n)$? They also have a classification in terms of partitions.