Java 类javax.swing.text.AbstractDocument.LeafElement 实例源码

项目:cn1    文件:AbstractDocumentTest.java   
public void testCreateLeafElement() throws BadLocationException {
    Element leaf = doc.createLeafElement(null, null, 0, 1);
    assertTrue(leaf instanceof LeafElement);
    assertNull(leaf.getParentElement());
    assertEquals(0, leaf.getStartOffset());
    assertEquals(1, leaf.getEndOffset());
    doc.insertString(0, "01234", null);
    Element leaf2 = doc.createLeafElement(leaf, null, 1, 3);
    assertTrue(leaf2 instanceof LeafElement);
    assertSame(leaf, leaf2.getParentElement());
    assertEquals(1, leaf2.getStartOffset());
    assertEquals(3, leaf2.getEndOffset());
    doc.remove(0, 5);
    assertEquals(0, leaf2.getStartOffset());
    assertEquals(0, leaf2.getEndOffset());
}
项目:cn1    文件:AbstractDocumentTest.java   
public void testGetBidiRootElement() {
    Element root = doc.getBidiRootElement();
    assertNotNull(root);
    assertTrue(root instanceof BranchElement);
    assertEquals("bidi root", root.getName());
    assertEquals(0, root.getStartOffset());
    assertEquals(1, root.getEndOffset());
    Enumeration<?> elements = ((BranchElement) root).children();
    Element element = null;
    int count = 0;
    while (elements.hasMoreElements()) {
        count++;
        element = (Element) elements.nextElement();
    }
    // if the document is empty there should be only one child
    assertEquals(1, count);
    assertTrue(element instanceof LeafElement);
    assertEquals("bidi level", element.getName());
    assertSame(AbstractDocument.BidiElementName, element.getName());
    assertEquals(0, element.getStartOffset());
    assertEquals(1, element.getEndOffset());
}
项目:cn1    文件:AbstractDocument_BranchElementTest.java   
/**
 * Test getElementIndex behavior if some elements are zero-length,
 * i.e. start and end offsets are the same.
 */
public void testGetElementIndex02() {
    BranchElement root = doc.new BranchElement(null, null);
    LeafElement[] leaves = { doc.new LeafElement(root, null, 0, 0), // [0]
            doc.new LeafElement(root, null, 0, 1), // [1]
            doc.new LeafElement(root, null, 0, 1), // [2]
            doc.new LeafElement(root, null, 1, 1), // [3]
            doc.new LeafElement(root, null, 1, 1), // [4]
            doc.new LeafElement(root, null, 1, 2), // [5]
            doc.new LeafElement(root, null, 2, 3) // [6]
    };
    root.replace(0, 0, leaves);
    assertEquals(0, root.getElementIndex(-1));
    assertEquals(1, root.getElementIndex(0));
    assertEquals(5 /*2*/, root.getElementIndex(1));
    assertEquals(6, root.getElementIndex(2));
    assertEquals(6, root.getElementIndex(3));
    assertEquals(6, root.getElementIndex(4));
}
项目:cn1    文件:GlyphView_BreakTest.java   
/**
 * Tests <code>breakView</code> uses <code>createFragment</code> to
 * produce the part.
 */
public void testBreakViewCreate() throws Exception {
    view = new GlyphView(root) {
        @Override
        public View createFragment(int startOffset, int endOffset) {
            final Element part = ((AbstractDocument) doc).new LeafElement(null, null,
                    startOffset, endOffset);
            return new LabelView(part);
        };
    };
    final float width = metrics.stringWidth(FULL_TEXT.substring(0, 2));
    final View fragment = view.breakView(X_AXIS, 0, 0, width);
    assertTrue(fragment instanceof LabelView);
    assertFalse(view instanceof LabelView);
    assertEquals(view.getStartOffset(), fragment.getStartOffset());
    assertEquals(view.getStartOffset() + 2, fragment.getEndOffset());
    assertTrue(fragment.getElement() instanceof LeafElement);
    assertTrue(view.getElement() instanceof BranchElement);
}
项目:freeVM    文件:AbstractDocumentTest.java   
public void testCreateLeafElement() throws BadLocationException {
    Element leaf = doc.createLeafElement(null, null, 0, 1);
    assertTrue(leaf instanceof LeafElement);
    assertNull(leaf.getParentElement());
    assertEquals(0, leaf.getStartOffset());
    assertEquals(1, leaf.getEndOffset());
    doc.insertString(0, "01234", null);
    Element leaf2 = doc.createLeafElement(leaf, null, 1, 3);
    assertTrue(leaf2 instanceof LeafElement);
    assertSame(leaf, leaf2.getParentElement());
    assertEquals(1, leaf2.getStartOffset());
    assertEquals(3, leaf2.getEndOffset());
    doc.remove(0, 5);
    assertEquals(0, leaf2.getStartOffset());
    assertEquals(0, leaf2.getEndOffset());
}
项目:freeVM    文件:AbstractDocumentTest.java   
public void testGetBidiRootElement() {
    Element root = doc.getBidiRootElement();
    assertNotNull(root);
    assertTrue(root instanceof BranchElement);
    assertEquals("bidi root", root.getName());
    assertEquals(0, root.getStartOffset());
    assertEquals(1, root.getEndOffset());
    Enumeration<?> elements = ((BranchElement) root).children();
    Element element = null;
    int count = 0;
    while (elements.hasMoreElements()) {
        count++;
        element = (Element) elements.nextElement();
    }
    // if the document is empty there should be only one child
    assertEquals(1, count);
    assertTrue(element instanceof LeafElement);
    assertEquals("bidi level", element.getName());
    assertSame(AbstractDocument.BidiElementName, element.getName());
    assertEquals(0, element.getStartOffset());
    assertEquals(1, element.getEndOffset());
}
项目:freeVM    文件:AbstractDocument_BranchElementTest.java   
/**
 * Test getElementIndex behavior if some elements are zero-length,
 * i.e. start and end offsets are the same.
 */
public void testGetElementIndex02() {
    BranchElement root = doc.new BranchElement(null, null);
    LeafElement[] leaves = { doc.new LeafElement(root, null, 0, 0), // [0]
            doc.new LeafElement(root, null, 0, 1), // [1]
            doc.new LeafElement(root, null, 0, 1), // [2]
            doc.new LeafElement(root, null, 1, 1), // [3]
            doc.new LeafElement(root, null, 1, 1), // [4]
            doc.new LeafElement(root, null, 1, 2), // [5]
            doc.new LeafElement(root, null, 2, 3) // [6]
    };
    root.replace(0, 0, leaves);
    assertEquals(0, root.getElementIndex(-1));
    assertEquals(1, root.getElementIndex(0));
    assertEquals(5 /*2*/, root.getElementIndex(1));
    assertEquals(6, root.getElementIndex(2));
    assertEquals(6, root.getElementIndex(3));
    assertEquals(6, root.getElementIndex(4));
}
项目:freeVM    文件:GlyphView_BreakTest.java   
/**
 * Tests <code>breakView</code> uses <code>createFragment</code> to
 * produce the part.
 */
public void testBreakViewCreate() throws Exception {
    view = new GlyphView(root) {
        @Override
        public View createFragment(int startOffset, int endOffset) {
            final Element part = ((AbstractDocument) doc).new LeafElement(null, null,
                    startOffset, endOffset);
            return new LabelView(part);
        };
    };
    final float width = metrics.stringWidth(FULL_TEXT.substring(0, 2));
    final View fragment = view.breakView(X_AXIS, 0, 0, width);
    assertTrue(fragment instanceof LabelView);
    assertFalse(view instanceof LabelView);
    assertEquals(view.getStartOffset(), fragment.getStartOffset());
    assertEquals(view.getStartOffset() + 2, fragment.getEndOffset());
    assertTrue(fragment.getElement() instanceof LeafElement);
    assertTrue(view.getElement() instanceof BranchElement);
}
项目:freeVM    文件:AbstractDocumentTest.java   
public void testCreateLeafElement() throws BadLocationException {
    Element leaf = doc.createLeafElement(null, null, 0, 1);
    assertTrue(leaf instanceof LeafElement);
    assertNull(leaf.getParentElement());
    assertEquals(0, leaf.getStartOffset());
    assertEquals(1, leaf.getEndOffset());
    doc.insertString(0, "01234", null);
    Element leaf2 = doc.createLeafElement(leaf, null, 1, 3);
    assertTrue(leaf2 instanceof LeafElement);
    assertSame(leaf, leaf2.getParentElement());
    assertEquals(1, leaf2.getStartOffset());
    assertEquals(3, leaf2.getEndOffset());
    doc.remove(0, 5);
    assertEquals(0, leaf2.getStartOffset());
    assertEquals(0, leaf2.getEndOffset());
}
项目:freeVM    文件:AbstractDocumentTest.java   
public void testGetBidiRootElement() {
    Element root = doc.getBidiRootElement();
    assertNotNull(root);
    assertTrue(root instanceof BranchElement);
    assertEquals("bidi root", root.getName());
    assertEquals(0, root.getStartOffset());
    assertEquals(1, root.getEndOffset());
    Enumeration<?> elements = ((BranchElement) root).children();
    Element element = null;
    int count = 0;
    while (elements.hasMoreElements()) {
        count++;
        element = (Element) elements.nextElement();
    }
    // if the document is empty there should be only one child
    assertEquals(1, count);
    assertTrue(element instanceof LeafElement);
    assertEquals("bidi level", element.getName());
    assertSame(AbstractDocument.BidiElementName, element.getName());
    assertEquals(0, element.getStartOffset());
    assertEquals(1, element.getEndOffset());
}
项目:freeVM    文件:AbstractDocument_BranchElementTest.java   
/**
 * Test getElementIndex behavior if some elements are zero-length,
 * i.e. start and end offsets are the same.
 */
public void testGetElementIndex02() {
    BranchElement root = doc.new BranchElement(null, null);
    LeafElement[] leaves = { doc.new LeafElement(root, null, 0, 0), // [0]
            doc.new LeafElement(root, null, 0, 1), // [1]
            doc.new LeafElement(root, null, 0, 1), // [2]
            doc.new LeafElement(root, null, 1, 1), // [3]
            doc.new LeafElement(root, null, 1, 1), // [4]
            doc.new LeafElement(root, null, 1, 2), // [5]
            doc.new LeafElement(root, null, 2, 3) // [6]
    };
    root.replace(0, 0, leaves);
    assertEquals(0, root.getElementIndex(-1));
    assertEquals(1, root.getElementIndex(0));
    assertEquals(5 /*2*/, root.getElementIndex(1));
    assertEquals(6, root.getElementIndex(2));
    assertEquals(6, root.getElementIndex(3));
    assertEquals(6, root.getElementIndex(4));
}
项目:freeVM    文件:GlyphView_BreakTest.java   
/**
 * Tests <code>breakView</code> uses <code>createFragment</code> to
 * produce the part.
 */
public void testBreakViewCreate() throws Exception {
    view = new GlyphView(root) {
        @Override
        public View createFragment(int startOffset, int endOffset) {
            final Element part = ((AbstractDocument) doc).new LeafElement(null, null,
                    startOffset, endOffset);
            return new LabelView(part);
        };
    };
    final float width = metrics.stringWidth(FULL_TEXT.substring(0, 2));
    final View fragment = view.breakView(X_AXIS, 0, 0, width);
    assertTrue(fragment instanceof LabelView);
    assertFalse(view instanceof LabelView);
    assertEquals(view.getStartOffset(), fragment.getStartOffset());
    assertEquals(view.getStartOffset() + 2, fragment.getEndOffset());
    assertTrue(fragment.getElement() instanceof LeafElement);
    assertTrue(view.getElement() instanceof BranchElement);
}
项目:jasperreports    文件:JEditorPaneRtfMarkupProcessor.java   
/**
 * 
 */
protected void addElements(List<Element> elements, Element element) 
{
    if(element instanceof LeafElement)
    {
        elements.add(element);
    }
    for(int i = 0; i < element.getElementCount(); i++)
    {
        Element child = element.getElement(i);
        addElements(elements, child);
    }
}
项目:cn1    文件:DefaultStyledDocumentTest.java   
public void testDefaultStyledDocumentContentStyleContext() {
    StyleContext styles = new StyleContext();
    doc = new DefaultStyledDocument(new GapContent(10), styles);
    assertEquals(10, ((GapContent) doc.getContent()).getArrayLength());
    Element root = doc.getDefaultRootElement();
    assertTrue(root instanceof SectionElement);
    assertEquals(1, root.getElementCount());
    Element child = root.getElement(0);
    assertTrue(child instanceof BranchElement);
    assertEquals(1, child.getElementCount());
    assertTrue(child.getElement(0) instanceof LeafElement);
    assertSame(styles, doc.getAttributeContext());
    assertSame(styles.getStyle(StyleContext.DEFAULT_STYLE), child.getAttributes()
            .getResolveParent());
}
项目:cn1    文件:AbstractDocument_LeafElementTest.java   
@Override
protected void setUp() throws Exception {
    super.setUp();
    StyleContextTest.sc = StyleContext.getDefaultStyleContext();
    as = new AttributeSet[] { StyleContextTest.addAttribute(1),
            StyleContextTest.addAttribute(null, 2, 2),
            StyleContextTest.addAttribute(null, 5, 2) };
    doc = new DisAbstractedDocument(new GapContent());
    doc.insertString(0, "0123456789", as[0]);
    doc.writeLock();
    BranchElement branch = doc.new BranchElement(null, as[1]);
    leaf1 = doc.new LeafElement(null, as[2], 0, 3);
    leaf2 = doc.new LeafElement(branch, as[2], 5, 8);
    doc.writeUnlock();
}
项目:cn1    文件:DefaultStyledDocumentRTest.java   
private void createEmptyHTMLStructure() {
    doc = new DefStyledDoc_Helpers.DefStyledDocWithLogging();
    root = doc.getDefaultRootElement();
    buf = new DefStyledDoc_Helpers.ElementBufferWithLogging(doc, root) {
        private static final long serialVersionUID = 1L;

        @Override
        public void insert(int offset, int length, ElementSpec[] spec,
                DefaultDocumentEvent event) {
            super.insert(offset, length, specs = spec, event);
        }
    };
    doc.buffer = buf;
    doc.writeLock();
    try {
        final BranchElement html = (BranchElement) root;
        html.addAttribute(ELEMENT_NAME, "html");
        final BranchElement body = createBranch(html);
        body.addAttribute(ELEMENT_NAME, "body");
        final BranchElement p = createBranch(body);
        p.addAttribute(ELEMENT_NAME, "p");
        final LeafElement content = createLeaf(p, 0, 1);
        content.addAttribute(ELEMENT_NAME, "leaf1");
        p.replace(0, 0, new Element[] { content });
        body.replace(0, 0, new Element[] { p });
        html.replace(0, 1, new Element[] { body });
    } finally {
        doc.writeUnlock();
    }
}
项目:cn1    文件:HTMLDocument_BlockElementTest.java   
protected void setUp() throws Exception {
    super.setUp();

    htmlDoc = new LockableHTMLDocument();
    doc = htmlDoc;

    doc.insertString(0, LTR + RTL + LTR + RTL + "\n01234", as[0]);

    bidi  = (BranchElement)doc.getBidiRootElement();
    leaf1 = (LeafElement)bidi.getElement(0).getElement(0);
    par   = (BranchElement)doc.getDefaultRootElement();
    leaf2 = par != null ? par.getElement(0) : null;
    leaf3 = leaf2;
}
项目:freeVM    文件:DefaultStyledDocumentTest.java   
public void testDefaultStyledDocumentContentStyleContext() {
    StyleContext styles = new StyleContext();
    doc = new DefaultStyledDocument(new GapContent(10), styles);
    assertEquals(10, ((GapContent) doc.getContent()).getArrayLength());
    Element root = doc.getDefaultRootElement();
    assertTrue(root instanceof SectionElement);
    assertEquals(1, root.getElementCount());
    Element child = root.getElement(0);
    assertTrue(child instanceof BranchElement);
    assertEquals(1, child.getElementCount());
    assertTrue(child.getElement(0) instanceof LeafElement);
    assertSame(styles, doc.getAttributeContext());
    assertSame(styles.getStyle(StyleContext.DEFAULT_STYLE), child.getAttributes()
            .getResolveParent());
}
项目:freeVM    文件:AbstractDocument_LeafElementTest.java   
@Override
protected void setUp() throws Exception {
    super.setUp();
    StyleContextTest.sc = StyleContext.getDefaultStyleContext();
    as = new AttributeSet[] { StyleContextTest.addAttribute(1),
            StyleContextTest.addAttribute(null, 2, 2),
            StyleContextTest.addAttribute(null, 5, 2) };
    doc = new DisAbstractedDocument(new GapContent());
    doc.insertString(0, "0123456789", as[0]);
    doc.writeLock();
    BranchElement branch = doc.new BranchElement(null, as[1]);
    leaf1 = doc.new LeafElement(null, as[2], 0, 3);
    leaf2 = doc.new LeafElement(branch, as[2], 5, 8);
    doc.writeUnlock();
}
项目:freeVM    文件:DefaultStyledDocumentRTest.java   
private void createEmptyHTMLStructure() {
    doc = new DefStyledDoc_Helpers.DefStyledDocWithLogging();
    root = doc.getDefaultRootElement();
    buf = new DefStyledDoc_Helpers.ElementBufferWithLogging(doc, root) {
        private static final long serialVersionUID = 1L;

        @Override
        public void insert(int offset, int length, ElementSpec[] spec,
                DefaultDocumentEvent event) {
            super.insert(offset, length, specs = spec, event);
        }
    };
    doc.buffer = buf;
    doc.writeLock();
    try {
        final BranchElement html = (BranchElement) root;
        html.addAttribute(ELEMENT_NAME, "html");
        final BranchElement body = createBranch(html);
        body.addAttribute(ELEMENT_NAME, "body");
        final BranchElement p = createBranch(body);
        p.addAttribute(ELEMENT_NAME, "p");
        final LeafElement content = createLeaf(p, 0, 1);
        content.addAttribute(ELEMENT_NAME, "leaf1");
        p.replace(0, 0, new Element[] { content });
        body.replace(0, 0, new Element[] { p });
        html.replace(0, 1, new Element[] { body });
    } finally {
        doc.writeUnlock();
    }
}
项目:freeVM    文件:HTMLDocument_BlockElementTest.java   
protected void setUp() throws Exception {
    super.setUp();

    htmlDoc = new LockableHTMLDocument();
    doc = htmlDoc;

    doc.insertString(0, LTR + RTL + LTR + RTL + "\n01234", as[0]);

    bidi  = (BranchElement)doc.getBidiRootElement();
    leaf1 = (LeafElement)bidi.getElement(0).getElement(0);
    par   = (BranchElement)doc.getDefaultRootElement();
    leaf2 = par != null ? par.getElement(0) : null;
    leaf3 = leaf2;
}
项目:freeVM    文件:DefaultStyledDocumentTest.java   
public void testDefaultStyledDocumentContentStyleContext() {
    StyleContext styles = new StyleContext();
    doc = new DefaultStyledDocument(new GapContent(10), styles);
    assertEquals(10, ((GapContent) doc.getContent()).getArrayLength());
    Element root = doc.getDefaultRootElement();
    assertTrue(root instanceof SectionElement);
    assertEquals(1, root.getElementCount());
    Element child = root.getElement(0);
    assertTrue(child instanceof BranchElement);
    assertEquals(1, child.getElementCount());
    assertTrue(child.getElement(0) instanceof LeafElement);
    assertSame(styles, doc.getAttributeContext());
    assertSame(styles.getStyle(StyleContext.DEFAULT_STYLE), child.getAttributes()
            .getResolveParent());
}
项目:freeVM    文件:AbstractDocument_LeafElementTest.java   
@Override
protected void setUp() throws Exception {
    super.setUp();
    StyleContextTest.sc = StyleContext.getDefaultStyleContext();
    as = new AttributeSet[] { StyleContextTest.addAttribute(1),
            StyleContextTest.addAttribute(null, 2, 2),
            StyleContextTest.addAttribute(null, 5, 2) };
    doc = new DisAbstractedDocument(new GapContent());
    doc.insertString(0, "0123456789", as[0]);
    doc.writeLock();
    BranchElement branch = doc.new BranchElement(null, as[1]);
    leaf1 = doc.new LeafElement(null, as[2], 0, 3);
    leaf2 = doc.new LeafElement(branch, as[2], 5, 8);
    doc.writeUnlock();
}
项目:freeVM    文件:DefaultStyledDocumentRTest.java   
private void createEmptyHTMLStructure() {
    doc = new DefStyledDoc_Helpers.DefStyledDocWithLogging();
    root = doc.getDefaultRootElement();
    buf = new DefStyledDoc_Helpers.ElementBufferWithLogging(doc, root) {
        private static final long serialVersionUID = 1L;

        @Override
        public void insert(int offset, int length, ElementSpec[] spec,
                DefaultDocumentEvent event) {
            super.insert(offset, length, specs = spec, event);
        }
    };
    doc.buffer = buf;
    doc.writeLock();
    try {
        final BranchElement html = (BranchElement) root;
        html.addAttribute(ELEMENT_NAME, "html");
        final BranchElement body = createBranch(html);
        body.addAttribute(ELEMENT_NAME, "body");
        final BranchElement p = createBranch(body);
        p.addAttribute(ELEMENT_NAME, "p");
        final LeafElement content = createLeaf(p, 0, 1);
        content.addAttribute(ELEMENT_NAME, "leaf1");
        p.replace(0, 0, new Element[] { content });
        body.replace(0, 0, new Element[] { p });
        html.replace(0, 1, new Element[] { body });
    } finally {
        doc.writeUnlock();
    }
}
项目:freeVM    文件:HTMLDocument_BlockElementTest.java   
protected void setUp() throws Exception {
    super.setUp();

    htmlDoc = new LockableHTMLDocument();
    doc = htmlDoc;

    doc.insertString(0, LTR + RTL + LTR + RTL + "\n01234", as[0]);

    bidi  = (BranchElement)doc.getBidiRootElement();
    leaf1 = (LeafElement)bidi.getElement(0).getElement(0);
    par   = (BranchElement)doc.getDefaultRootElement();
    leaf2 = par != null ? par.getElement(0) : null;
    leaf3 = leaf2;
}
项目:cn1    文件:AbstractDocumentTest.java   
protected void createRoot() {
    writeLock();
    defRoot = new BranchElement(null, null);
    defRoot.replace(0, 0, new Element[] { new LeafElement(defRoot, null, 0, 1) });
    writeUnlock();
}
项目:cn1    文件:AbstractDocument_BranchElementTest.java   
private Element createLeaf(final int start, final int end) {
    return doc.new LeafElement(par, null, start, end);
}
项目:cn1    文件:DefaultStyledDocumentRTest.java   
private void initStructure() throws BadLocationException {
    doc = new DefStyledDoc_Helpers.DefStyledDocWithLogging();
    root = doc.getDefaultRootElement();
    buf = new DefStyledDoc_Helpers.ElementBufferWithLogging(doc, root) {
        private static final long serialVersionUID = 1L;

        @Override
        public void insert(int offset, int length, ElementSpec[] spec,
                DefaultDocumentEvent event) {
            super.insert(offset, length, specs = spec, event);
        }
    };
    doc.buffer = buf;
    doc.writeLock();
    try {
        doc.getContent().insertString(0, "\n0000");
        final BranchElement html = (BranchElement) root;
        html.addAttribute(ELEMENT_NAME, "html");
        final BranchElement head = createBranch(html);
        head.addAttribute(ELEMENT_NAME, "head");
        final BranchElement implied = createBranch(head);
        implied.addAttribute(ELEMENT_NAME, "p-implied");
        final LeafElement content0 = createLeaf(implied, 0, 1);
        content0.addAttribute(ELEMENT_NAME, "head-content");
        final BranchElement body = createBranch(html);
        body.addAttribute(ELEMENT_NAME, "body");
        final BranchElement p1 = createBranch(body);
        p1.addAttribute(ELEMENT_NAME, "p1");
        final LeafElement content1 = createLeaf(p1, 1, 5);
        content1.addAttribute(ELEMENT_NAME, "leaf1");
        final LeafElement content2 = createLeaf(p1, 5, 6);
        content2.addAttribute(ELEMENT_NAME, "leaf2");
        implied.replace(0, 0, new Element[] { content0 });
        p1.replace(0, 0, new Element[] { content1, content2 });
        head.replace(0, 0, new Element[] { implied });
        body.replace(0, 0, new Element[] { p1 });
        html.replace(0, 1, new Element[] { head, body });
    } finally {
        doc.writeUnlock();
    }
}
项目:cn1    文件:DefaultStyledDocumentRTest.java   
private LeafElement createLeaf(final Element parent, final int start, final int end) {
    return (LeafElement) doc.createLeafElement(parent, null, start, end);
}
项目:freeVM    文件:AbstractDocumentTest.java   
protected void createRoot() {
    writeLock();
    defRoot = new BranchElement(null, null);
    defRoot.replace(0, 0, new Element[] { new LeafElement(defRoot, null, 0, 1) });
    writeUnlock();
}
项目:freeVM    文件:AbstractDocument_BranchElementTest.java   
private Element createLeaf(final int start, final int end) {
    return doc.new LeafElement(par, null, start, end);
}
项目:freeVM    文件:DefaultStyledDocumentRTest.java   
private void initStructure() throws BadLocationException {
    doc = new DefStyledDoc_Helpers.DefStyledDocWithLogging();
    root = doc.getDefaultRootElement();
    buf = new DefStyledDoc_Helpers.ElementBufferWithLogging(doc, root) {
        private static final long serialVersionUID = 1L;

        @Override
        public void insert(int offset, int length, ElementSpec[] spec,
                DefaultDocumentEvent event) {
            super.insert(offset, length, specs = spec, event);
        }
    };
    doc.buffer = buf;
    doc.writeLock();
    try {
        doc.getContent().insertString(0, "\n0000");
        final BranchElement html = (BranchElement) root;
        html.addAttribute(ELEMENT_NAME, "html");
        final BranchElement head = createBranch(html);
        head.addAttribute(ELEMENT_NAME, "head");
        final BranchElement implied = createBranch(head);
        implied.addAttribute(ELEMENT_NAME, "p-implied");
        final LeafElement content0 = createLeaf(implied, 0, 1);
        content0.addAttribute(ELEMENT_NAME, "head-content");
        final BranchElement body = createBranch(html);
        body.addAttribute(ELEMENT_NAME, "body");
        final BranchElement p1 = createBranch(body);
        p1.addAttribute(ELEMENT_NAME, "p1");
        final LeafElement content1 = createLeaf(p1, 1, 5);
        content1.addAttribute(ELEMENT_NAME, "leaf1");
        final LeafElement content2 = createLeaf(p1, 5, 6);
        content2.addAttribute(ELEMENT_NAME, "leaf2");
        implied.replace(0, 0, new Element[] { content0 });
        p1.replace(0, 0, new Element[] { content1, content2 });
        head.replace(0, 0, new Element[] { implied });
        body.replace(0, 0, new Element[] { p1 });
        html.replace(0, 1, new Element[] { head, body });
    } finally {
        doc.writeUnlock();
    }
}
项目:freeVM    文件:DefaultStyledDocumentRTest.java   
private LeafElement createLeaf(final Element parent, final int start, final int end) {
    return (LeafElement) doc.createLeafElement(parent, null, start, end);
}
项目:freeVM    文件:AbstractDocumentTest.java   
protected void createRoot() {
    writeLock();
    defRoot = new BranchElement(null, null);
    defRoot.replace(0, 0, new Element[] { new LeafElement(defRoot, null, 0, 1) });
    writeUnlock();
}
项目:freeVM    文件:AbstractDocument_BranchElementTest.java   
private Element createLeaf(final int start, final int end) {
    return doc.new LeafElement(par, null, start, end);
}
项目:freeVM    文件:DefaultStyledDocumentRTest.java   
private void initStructure() throws BadLocationException {
    doc = new DefStyledDoc_Helpers.DefStyledDocWithLogging();
    root = doc.getDefaultRootElement();
    buf = new DefStyledDoc_Helpers.ElementBufferWithLogging(doc, root) {
        private static final long serialVersionUID = 1L;

        @Override
        public void insert(int offset, int length, ElementSpec[] spec,
                DefaultDocumentEvent event) {
            super.insert(offset, length, specs = spec, event);
        }
    };
    doc.buffer = buf;
    doc.writeLock();
    try {
        doc.getContent().insertString(0, "\n0000");
        final BranchElement html = (BranchElement) root;
        html.addAttribute(ELEMENT_NAME, "html");
        final BranchElement head = createBranch(html);
        head.addAttribute(ELEMENT_NAME, "head");
        final BranchElement implied = createBranch(head);
        implied.addAttribute(ELEMENT_NAME, "p-implied");
        final LeafElement content0 = createLeaf(implied, 0, 1);
        content0.addAttribute(ELEMENT_NAME, "head-content");
        final BranchElement body = createBranch(html);
        body.addAttribute(ELEMENT_NAME, "body");
        final BranchElement p1 = createBranch(body);
        p1.addAttribute(ELEMENT_NAME, "p1");
        final LeafElement content1 = createLeaf(p1, 1, 5);
        content1.addAttribute(ELEMENT_NAME, "leaf1");
        final LeafElement content2 = createLeaf(p1, 5, 6);
        content2.addAttribute(ELEMENT_NAME, "leaf2");
        implied.replace(0, 0, new Element[] { content0 });
        p1.replace(0, 0, new Element[] { content1, content2 });
        head.replace(0, 0, new Element[] { implied });
        body.replace(0, 0, new Element[] { p1 });
        html.replace(0, 1, new Element[] { head, body });
    } finally {
        doc.writeUnlock();
    }
}
项目:freeVM    文件:DefaultStyledDocumentRTest.java   
private LeafElement createLeaf(final Element parent, final int start, final int end) {
    return (LeafElement) doc.createLeafElement(parent, null, start, end);
}