  We investigate the main physical mechanisms that shape the intensity and
polarization of the Ba II D1 line at 4934 angstroms via radiative transfer
numerical experiments. We focus especially on the scattering linear
polarization arising from the spectral structure of the anisotropic radiation
in the wavelength interval spanned by the line's hyperfine structure (HFS)
components in the odd isotopes of barium. After verifying that the presence of
the low-energy metastable levels only impacts the amplitude, but not the shape,
of the D1 linear polarization, we relied on a two-term atomic model that
neglects such metastable levels but includes HFS. The D1 fractional linear
polarization shows a very small variation with the choice of atmospheric model,
enhancing its suitability for solar magnetic field diagnostics. Tangled
magnetic fields with strengths of tens of gauss reduce the linear polarization
and saturation is reached at roughly 300 G. Deterministic inclined magnetic
fields produce a U/I profile and, if they have a significant longitudinal
component, a V/I profile, whose modeling requires accounting for HFS and the
Paschen-Back effect. Because of the overlap between HFS components, the
magnetograph formula cannot be applied to infer the longitudinal magnetic
field. Accurately modeling the D1 intensity and polarization requires an atomic
system that includes the metastable levels and the HFS, the detailed spectral
structure of the radiation field, the incomplete Paschen-Back regime for
magnetic fields, and an accurate treatment of collisions.
