300 calories represents the 100% of calories on the piece of cake.
If you want to know the percentage that represents 135 calories from fat, then you have to multiply 135 calories by 100%, and then divide the outcome by 300 calories:
(135 cal *100%)/300cal= 45%