If you know the direction of gas flow, you can determine the direction of rotation of axial flow components (like the fan and turbine in the example) by the angle of attack of the blades. Think of it intuitively--if you were to blow air through the engine in the same direction it flows during operation, which way would the blades windmill? The direction of windmilling is the same as the direction of powered operation, as long as the airflow is in the same direction.
Because their angle of attack, of the blades of the fan would deflect air flowing into the engine counterclockwise when viewed from the front, meaning the fan rotates clockwise when viewed from the front (or counterclockwise from the rear looking forward, which is the conventional way of expressing rotation).
For this particular engine, all other turbomechanical components rotate in the opposite direction as the fan, indicating that the low pressure shaft is connected to the fan using a gearbox that reverses the rotation direction.
This is the low pressure turbine and shaft:
The compressor rotates in the same direction as the high and low pressure turbines, and is attached directly to the high pressure turbine shaft with no gearbox. The high pressure turbine is axial flow and looks like a smaller version of the low pressure turbine, but the compressor is not an axial flow component, which makes the analysis slightly different.
Unlike in axial flow components, in radial flow components like this compressor (a synonym for a radial flow compressor is a centrifugal compressor), the airflow enters and exits in a different direction. The direction of flow also differs between energy-absorbing (turbine) and energy-dissipating (compressor) components. Gas enters radial flow turbines at the edge and flows inward, exiting at the center. In radial flow compressors, gas enters at the center and exits at the edge. You can determine the direction of rotation by imagining the forces the air would exert as it changes direction, similar to the windmilling axial flow components: