int minX = 0; int maxX = 0; int minY = 0; int maxY = 0; int p0 = -1; int p1 = -1; for (Iterator i = highlights.iterator(); i.hasNext();) { HighlightEntry e = (HighlightEntry) i.next(); if (e instanceof LayerHighlightEntry) { LayerHighlightEntry le = (LayerHighlightEntry) e; Rectangle r = le.paintRect; minX = Math.min(r.x, minX); maxX = Math.max(r.x + r.width, maxX); minY = Math.min(r.y, minY); maxY = Math.max(r.y + r.height, maxY); } else { if (p0 == -1 || p1 == -1) { p0 = e.getStartOffset(); p1 = e.getEndOffset(); } else { p0 = Math.min(p0, e.getStartOffset()); p1 = Math.max(p1, e.getEndOffset()); } } if (minX != maxX && minY != maxY) textComponent.repaint(minX, minY, maxX - minX, maxY - minY); if (p0 != -1 && p1 != -1) { TextUI ui = textComponent.getUI(); ui.damageRange(textComponent, p0, p1); }  }
  public void removeAllHighlights()  {    highlights.clear();  }