I've never toured by train in Spain - it does sound like an interesting thing to try though. We have a place near Malaga, and use the high speed AVE (like the French TGV) to visit friends and my wife's relations, mainly in Madrid and Zaragoza. The main cities linked by the AVE are Barcelona, Madrid, Malaga, Sevilla, Cordoba, Valencia, Zaragoza and a whole bunch of others. It's absolutely brilliant watching the world whizz by at 300 km/h. From those main stations (and the intermediate stops) you could get just about anywhere you want on slower trains. That said, you could spend a month visiting the main hub cities and still not see half of what there is to see.
However, to get to Granada for example you'd get on the AVE from Madrid to Malaga, change at Antequera and then on to Granada. Or get a local train from Malaga with a couple of changes.
I think you probably need to decide where you want to go first, and then plan from there. Just a word of caution regarding Granada - and probably some other places you want to visit - you can't just pitch up at the Alhambra - you need to book in advance. June is a good month I think. It'll be hot but not too hot. Probably!
The RENFE (Spanish version of British Rail) site is horrible to navigate, so here's a link to some network maps. Post up what you decide to do!
http://www.getspain-spain.com/renfe-train-maps.html