Portrait of James Hamilton, Lord Pencaitland, 1659 - 1729, Judge