Effective control of the charge and magnetic states of transition-metal atoms on single-layer boron nitride.