After just a few minutes looking at the code, I'd say the draw() function is called by the Processing runtime system each time the image should be redrawn. This just paints a black background, then renders the globe with the renderGlobe() function.
The renderGlobe() function sets up the environment for drawing the globe, calculating position, turing on lights, setting the texture to IMAGE, etc. Then it calls texturedSphere to draw the globe. After that, it cleans up and adjusts the position variables for the next time through.
The initializeSphere() function calculates the vertex locations for the sphere. This is simple trigonometry.
The texturedSphere() function draws the sphere. First it draws the southern cap, which is really a cone, a very flat cone. Next it draws rings for each section of the sphere, and then tops it off with another cone for the northern cap.
Although I haven't gone through the Processing learning materials, the headings indicate that if you start from the beginning, and try everything in order, you'll easily understand this code.