当前位置: 首页>>代码示例>>Java>>正文


Java ElementChange.getChildrenAdded方法代码示例

本文整理汇总了Java中javax.swing.event.DocumentEvent.ElementChange.getChildrenAdded方法的典型用法代码示例。如果您正苦于以下问题:Java ElementChange.getChildrenAdded方法的具体用法?Java ElementChange.getChildrenAdded怎么用?Java ElementChange.getChildrenAdded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.event.DocumentEvent.ElementChange的用法示例。


在下文中一共展示了ElementChange.getChildrenAdded方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateDamageOnInsert

import javax.swing.event.DocumentEvent.ElementChange; //导入方法依赖的package包/类
private void updateDamageOnInsert(final DocumentEvent event,
                                  final ElementChange change,
                                  final Shape shape) {
    boolean linesAdded = change != null;
    int start = linesAdded
                ? change.getIndex()
                : getElement().getElementIndex(event.getOffset());
    int length = linesAdded ? change.getChildrenAdded().length - 1 : 0;
    int width = widestLineWidth;
    if (widestLine.getEndOffset() < event.getOffset()
        || widestLine.getStartOffset() > event.getOffset()
                                         + event.getLength()) {
        // The previous longest line was not affected
        updateWidestLine(start, start + length);
    } else {
        updateWidestLine();
    }
    preferenceChanged(null, widestLineWidth != width, linesAdded);
    damageLineRange(start,
                    linesAdded ? getElement().getElementCount() - 1 : start,
                    shape, getComponent());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:PlainView.java

示例2: assertChange

import javax.swing.event.DocumentEvent.ElementChange; //导入方法依赖的package包/类
/**
 * Asserts that the removed and/or added children have the expected offsets.
 *
 * @param change the changes performed to an element.
 * @param removedOffsets the offsets of children removed in the form
 *                       <code>{start1, end1, start2, end2, ...}</code>.
 * @param addedOffsets the offsets of children added in the same form as
 *                     <code>removedOffsets</code>.
 */
public static void assertChange(final ElementChange change, final int[] removedOffsets,
        final int[] addedOffsets) {
    final Element[] removed = change.getChildrenRemoved();
    assertEquals("change.removed.length", removedOffsets.length / 2, removed.length);
    for (int i = 0, j = 0; i < removed.length; i++, j += 2) {
        assertEquals("change.removed[" + i + "].start", removedOffsets[j], removed[i]
                .getStartOffset());
        assertEquals("change.removed[" + i + "].end", removedOffsets[j + 1], removed[i]
                .getEndOffset());
    }
    final Element[] added = change.getChildrenAdded();
    assertEquals("change.added.length", addedOffsets.length / 2, added.length);
    for (int i = 0, j = 0; i < added.length; i++, j += 2) {
        assertEquals("change.added[" + i + "].start", addedOffsets[j], added[i]
                .getStartOffset());
        assertEquals("change.added[" + i + "].end", addedOffsets[j + 1], added[i]
                .getEndOffset());
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:29,代码来源:DefStyledDoc_Helpers.java

示例3: testInsertString01

import javax.swing.event.DocumentEvent.ElementChange; //导入方法依赖的package包/类
/**
 * Adds text with no attributes.
 */
public void testInsertString01() throws Exception {
    doc.insertString(insertOffset, "^^^", null);
    assertEquals(2, getEdits(insertEvent).size());
    List<?> edits = getEdits(insertEvent);
    assertChange(edits.get(1), paragraph, 1, 3);
    ElementChange change = (ElementChange) edits.get(1);
    assertSame(leaf, change.getChildrenRemoved()[0]);
    final Element[] added = change.getChildrenAdded();
    for (int i = 0; i < added.length; i++) {
        assertSame("@" + i, paragraph.getElement(i + leafIndex), added[i]);
    }
    ElementAssert[] expected = { new ElementAssert(null, 0, 5),
            new ElementAssert(bold, 5, 7), new ElementAssert(null, 7, 10),
            new ElementAssert(bold, 10, 12), new ElementAssert(italic, 12, 18),
            new ElementAssert(null, 18, 19) };
    assertEquals(expected.length, paragraph.getElementCount());
    for (int i = 0; i < expected.length; i++) {
        expected[i].check(paragraph.getElement(i));
    }
    assertEquals(1, specs.length);
    assertSpec(specs[0], ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, 3);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:26,代码来源:DefaultStyledDocument_ElementBuffer_Specs3Test.java


注:本文中的javax.swing.event.DocumentEvent.ElementChange.getChildrenAdded方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。