本文整理汇总了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());
}
示例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());
}
}
示例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);
}