docs: function(terminal, edge, source, defaultValue)
  	{
  		var value = mxUtils.getValue(terminal.style, mxConstants.STYLE_PORT_CONSTRAINT,
  			mxUtils.getValue(edge.style, (source) ? mxConstants.STYLE_SOURCE_PORT_CONSTRAINT :
  				mxConstants.STYLE_TARGET_PORT_CONSTRAINT, null));
  		
  		if (value == null)
  		{
  			return defaultValue;
  		}
  		else
  		{
  			var directions = value.toString();
  			var returnValue = mxConstants.DIRECTION_MASK_NONE;
  			var constraintRotationEnabled = mxUtils.getValue(terminal.style, mxConstants.STYLE_PORT_CONSTRAINT_ROTATION, 0);
  			var rotation = 0;
  			
  			if (constraintRotationEnabled == 1)
  			{
  				rotation = mxUtils.getValue(terminal.style, mxConstants.STYLE_ROTATION, 0);
  			}
  			
  			var quad = 0;
  
  			if (rotation > 45)
  			{
  				quad = 1;
  				
  				if (rotation >= 135)
  				{
  					quad = 2;
  				}
  			}
  			else if (rotation < -45)
  			{
  				quad = 3;
  				
  				if (rotation <= -135)
  				{
  					quad = 2;
  				}
  			}
  
  			if (directions.indexOf(mxConstants.DIRECTION_NORTH) >= 0)
  			{
  				switch (quad)
  				{
  					case 0:
  						returnValue |= mxConstants.DIRECTION_MASK_NORTH;
  						break;
  					case 1:
  						returnValue |= mxConstants.DIRECTION_MASK_EAST;
  						break;
  					case 2:
  						returnValue |= mxConstants.DIRECTION_MASK_SOUTH;
  						break;
  					case 3:
  						returnValue |= mxConstants.DIRECTION_MASK_WEST;
  						break;
  				}
  			}
  			if (directions.indexOf(mxConstants.DIRECTION_WEST) >= 0)
  			{
  				switch (quad)
  				{
  					case 0:
  						returnValue |= mxConstants.DIRECTION_MASK_WEST;
  						break;
  					case 1:
  						returnValue |= mxConstants.DIRECTION_MASK_NORTH;
  						break;
  					case 2:
  						returnValue |= mxConstants.DIRECTION_MASK_EAST;
  						break;
  					case 3:
  						returnValue |= mxConstants.DIRECTION_MASK_SOUTH;
  						break;
  				}
  			}
  			if (directions.indexOf(mxConstants.DIRECTION_SOUTH) >= 0)
  			{
  				switch (quad)
  				{
  					case 0:
  						returnValue |= mxConstants.DIRECTION_MASK_SOUTH;
  						break;
  					case 1:
  						returnValue |= mxConstants.DIRECTION_MASK_WEST;
  						break;
  					case 2:
  						returnValue |= mxConstants.DIRECTION_MASK_NORTH;
  						break;
  					case 3:
  						returnValue |= mxConstants.DIRECTION_MASK_EAST;
  						break;
  				}
  			}
  			if (directions.indexOf(mxConstants.DIRECTION_EAST) >= 0)
  			{
  				switch (quad)
  				{
  					case 0:
  						returnValue |= mxConstants.DIRECTION_MASK_EAST;
  						break;
  					case 1:
  						returnValue |= mxConstants.DIRECTION_MASK_SOUTH;
  						break;
  					case 2:
  						returnValue |= mxConstants.DIRECTION_MASK_WEST;
  						break;
  					case 3:
  						returnValue |= mxConstants.DIRECTION_MASK_NORTH;
  						break;
  				}
  			}
  
  			return returnValue;
  		}
  	}