458 super.insertUpdate(chng, attr);
459 }
460
461 /**
462 * Replaces the contents of the document with the given
463 * element specifications. This is called before insert if
464 * the loading is done in bursts. This is the only method called
465 * if loading the document entirely in one burst.
466 *
467 * @param data the new contents of the document
468 */
469 protected void create(ElementSpec[] data) {
470 super.create(data);
471 }
472
473 /**
474 * Sets attributes for a paragraph.
475 * <p>
476 * This method is thread safe, although most Swing methods
477 * are not. Please see
478 * <A HREF="http://download.oracle.com/javase/tutorial/uiswing/concurrency/index.html">Concurrency
479 * in Swing</A> for more information.
480 *
481 * @param offset the offset into the paragraph (must be at least 0)
482 * @param length the number of characters affected (must be at least 0)
483 * @param s the attributes
484 * @param replace whether to replace existing attributes, or merge them
485 */
486 public void setParagraphAttributes(int offset, int length, AttributeSet s,
487 boolean replace) {
488 try {
489 writeLock();
490 // Make sure we send out a change for the length of the paragraph.
491 int end = Math.min(offset + length, getLength());
492 Element e = getParagraphElement(offset);
493 offset = e.getStartOffset();
494 e = getParagraphElement(end);
495 length = Math.max(0, e.getEndOffset() - offset);
496 DefaultDocumentEvent changes =
497 new DefaultDocumentEvent(offset, length,
498 DocumentEvent.EventType.CHANGE);
|
458 super.insertUpdate(chng, attr);
459 }
460
461 /**
462 * Replaces the contents of the document with the given
463 * element specifications. This is called before insert if
464 * the loading is done in bursts. This is the only method called
465 * if loading the document entirely in one burst.
466 *
467 * @param data the new contents of the document
468 */
469 protected void create(ElementSpec[] data) {
470 super.create(data);
471 }
472
473 /**
474 * Sets attributes for a paragraph.
475 * <p>
476 * This method is thread safe, although most Swing methods
477 * are not. Please see
478 * <A HREF="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html">Concurrency
479 * in Swing</A> for more information.
480 *
481 * @param offset the offset into the paragraph (must be at least 0)
482 * @param length the number of characters affected (must be at least 0)
483 * @param s the attributes
484 * @param replace whether to replace existing attributes, or merge them
485 */
486 public void setParagraphAttributes(int offset, int length, AttributeSet s,
487 boolean replace) {
488 try {
489 writeLock();
490 // Make sure we send out a change for the length of the paragraph.
491 int end = Math.min(offset + length, getLength());
492 Element e = getParagraphElement(offset);
493 offset = e.getStartOffset();
494 e = getParagraphElement(end);
495 length = Math.max(0, e.getEndOffset() - offset);
496 DefaultDocumentEvent changes =
497 new DefaultDocumentEvent(offset, length,
498 DocumentEvent.EventType.CHANGE);
|