painted while hockney was a student at the royal college of art in london , the theatrical parade of strange personages was inspired by constantine cavafy 's 1904 poem , `` waiting for the barbarians . ''