Full text justification algorithm in Java