I would have used a table with materials (see this link here), but what you've done is serviceable. Since the icons are all basically the same, just differentiated by material/type of junction, I'd have a for loop that goes through all the materials, checks if the pipe exists, and then makes the three types for that material. Use less code that way.
But then, I abuse for loops. So. :D
The valve, I see you've made static sprites with the colors you want, but it was be just as easy to reference the graphics and use code-defined tints, e.g. how it's done here. You could easily replicate the same sort of picture function.