{
int acp, bcp;
acp = road.getAlphaNode().isConnectedAt(road);
bcp = road.getBetaNode().isConnectedAt(road);
Node alphaNode = road.getAlphaNode();
Node betaNode = road.getBetaNode();
int alphaMaxWidth = alphaNode.getWidth();
int betaMaxWidth = betaNode.getWidth();
int cax=0,cay=0,cbx=0,cby=0;
double alphaAngle, betaAngle;
// calculate the starting positions of the road
if(acp == 0) // alpha top
{
cax = alphaNode.getCoord().x;
cay = alphaNode.getCoord().y - alphaMaxWidth * 5 - 1;
alphaAngle = Math.toRadians(90);
}
else if(acp == 1) // alpha right
{
cax = alphaNode.getCoord().x + alphaMaxWidth * 5 + 1;
cay = alphaNode.getCoord().y;
alphaAngle = 0.0;
}
else if(acp == 2) // alpha bottom
{
cax = alphaNode.getCoord().x;
cay = alphaNode.getCoord().y + alphaMaxWidth * 5 + 1;
alphaAngle = Math.toRadians(270);
}
else // alpha left
{
cax = alphaNode.getCoord().x - alphaMaxWidth * 5 - 1;
cay = alphaNode.getCoord().y;
alphaAngle = Math.toRadians(180);
}
if(bcp == 0) // beta top
{
cbx = betaNode.getCoord().x;
cby = betaNode.getCoord().y - betaMaxWidth * 5 - 1;
betaAngle = Math.toRadians(270);
}
else if(bcp == 1) // beta right
{
cbx = betaNode.getCoord().x + betaMaxWidth * 5 + 1;
cby = betaNode.getCoord().y;
betaAngle = Math.toRadians(180);
}
else if(bcp == 2) // beta bottom
{
cbx = betaNode.getCoord().x;
cby = betaNode.getCoord().y + betaMaxWidth * 5 + 1;
betaAngle = Math.toRadians(90);
}
else // beta left
{
cbx = betaNode.getCoord().x - betaMaxWidth * 5 - 1;
cby = betaNode.getCoord().y;
betaAngle = 0.0;
}
Point alphaCoord = new Point(cax,cay);
Point betaCoord = new Point(cbx,cby);