e.p0 = doc.createPosition(n0); e.p1 = doc.createPosition(n1); }
  public void changeHighlight(Object tag, int n0, int n1)    throws BadLocationException  {    int o0, o1;        checkPositions(n0, n1);    HighlightEntry entry = (HighlightEntry) tag;    o0 = entry.p0;    o1 = entry.p1;        // Prevent useless write & repaint operations.    if (o0 == n0 && o1 == n1)      return;        entry.p0 = n0;    entry.p1 = n1;        TextUI ui = textComponent.getUI();        // Special situation where the old area has to be cleared simply.    if (n0 == n1)      ui.damageRange(textComponent, o0, o1);    // Calculates the areas where a change is really neccessary    else if ((o1 > n0 && o1 <= n1)        || (n1 > o0 && n1 <= o1))      {        // [fds, fde) - the first damage region        // [sds, sde] - the second damage region        int fds, sds;        int fde, sde;        // Calculate first damaged region.        if(o0 < n0)          {            // Damaged region will be cleared as            // the old highlight region starts first.            fds = o0;            fde = n0;          }        else          {            // Damaged region will be painted as            // the new highlight region starts first.            fds = n0;            fde = o0;          }        if (o1 < n1)          {            // Final region will be painted as the            // old highlight region finishes first            sds = o1;            sde = n1;          }        else          {            // Final region will be cleared as the            // new highlight region finishes first.            sds = n1;            sde = o1;          }                // If there is no undamaged region in between        // call damageRange only once.        if (fde == sds)          ui.damageRange(textComponent, fds, sde);        else          {            if (fds != fde)              ui.damageRange(textComponent, fds, fde);                    if (sds != sde)              ui.damageRange(textComponent, sds, sde);          }      }    else      {        // The two regions do not overlap. So mark        // both areas as damaged.        ui.damageRange(textComponent, o0, o1);        ui.damageRange(textComponent, n0, n1);      }      }