Paletto implementation in java