well,
firstly you have the hearing- if its an indictable offence it starts in local court to see if a prime facie case exists (enough evidence to go to a higher court) and if it does then it goes to a higher court. summary offences are dealt with in local court.
then, after the trial they have to give a decision (sentence) and they have to take into account:
1. the purpose of the punishment, circumstances of the offender, circumstances of the offence, aggravting/mitigating facotrs.
and also things like judges discretion- their guidelines and maximum penalties and such influence the sentencing process.
(refer to crime syllabus) =]