There are quite a few traditions surrounding the night of San Juan and they differ from region to region. The fire is supposed to burn away all of the badness and the swim is to cleanse the soul.
The night to me seemed much like Guy Fawkes night in terms of fires and fireworks, also whole families were in groups on the beach with picnic tables, sandwiches, snacks for the night while they camped out some til 4 or 5 in the morning.
Bonfires, fire and water are the protagonists of the night. Men and women, young people and children, all dedicate their days and afternoons to the preparation of bonfires. According to tradition, if people jump three times over a bonfire on San Juan's night, they will be cleansed and purified, and their problems burned away.DonQuijote.org
So if you know somebody called Juan, on June 24th you can tell him "Felicidades" as this is his special day, apart from his birthday.