Drawing a pipeline

Hello friends,

I’m trying to draw a pipeline network for a demo game and I have problems deawing the pipeline pieces (like rectangles) with info loaded from XML file.
The received data include for each pipeline piece the follow: id, status, xStart, yStart, xEnd and yEnd.
I need to calculate the 4 coordinates for draw the rectangle.
With vertical and horizontal rectangles I don’t have problem, but with inclinated rectangles I have problems for calculate the coordinates and obtain a symmetrical rectangle.
See the follow image:

Some suggestion???
Bests!