• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java BranchElement类的典型用法和代码示例

java 3次浏览

本文整理汇总了Java中javax.swing.text.AbstractDocument.BranchElement的典型用法代码示例。如果您正苦于以下问题:Java BranchElement类的具体用法?Java BranchElement怎么用?Java BranchElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

BranchElement类属于javax.swing.text.AbstractDocument包,在下文中一共展示了BranchElement类的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testGetBidiRootElement

点赞 3

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
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());
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:23,
代码来源:AbstractDocumentTest.java

示例2: setUp

点赞 3

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    doc = new DefaultStyledDocument();
    doc.insertString(0, "this is the test text with some long words in p2\n"
    //                   |              |
            //  0123456789012345678901234567890123456789012345678
            //  0         1         2         3         4
            + "Long words: internationalization, localization", null);
    root = doc.getDefaultRootElement();
    p1 = root.getElement(0);
    // Break the first paragraph into several
    doc.writeLock();
    Element[] leaves = new Element[] { doc.createLeafElement(p1, null, 0, 17),
            doc.createLeafElement(p1, null, 17, 32),
            doc.createLeafElement(p1, null, 32, 49) };
    ((BranchElement) p1).replace(0, p1.getElementCount(), leaves);
    doc.writeUnlock();
    p1L = p1.getElement(0);
    // Initialize the view
    view = new FlowViewImplWithFactory(p1, Y_AXIS, new PartFactory());
    strategy = view.strategy = new TestStrategy();
    view.loadChildren(null);
    row = view.createRow();
    view.append(row);
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:27,
代码来源:FlowView_FlowStrategyTest.java

示例3: testGetElementIndex02

点赞 3

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
/**
 * 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));
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:23,
代码来源:AbstractDocument_BranchElementTest.java

示例4: testGetElementIndex06

点赞 3

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
/**
 * Tests getElementIndex behavior when there are no child elements, but
 * <code>getStartOffset</code> and <code>getEndOffset</code> are overridden
 * to prevent <code>{@link NullPointerException}</code>.
 */
// Regression for HARMONY-2756
public void testGetElementIndex06() {
    par = doc.new BranchElement(null, null) {
        private static final long serialVersionUID = 1L;

        @Override
        public int getStartOffset() {
            return 10;
        }

        @Override
        public int getEndOffset() {
            return 20;
        }
    };
    assertEquals(0, par.getElementIndex(-1));
    assertEquals(0, par.getElementIndex(0));
    assertEquals(0, par.getElementIndex(10));
    assertEquals(0, par.getElementIndex(15));
    assertEquals(0, par.getElementIndex(20));
    assertEquals(0, par.getElementIndex(25));
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:28,
代码来源:AbstractDocument_BranchElementTest.java

示例5: testCreateDefaultRoot01

点赞 3

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
/**
 * Generic assertions upon element return by createDefaultRoot.
 */
public void testCreateDefaultRoot01() throws BadLocationException {
    Element root = doc.createDefaultRoot();
    assertTrue(root instanceof BranchElement);
    assertEquals(AbstractDocument.ParagraphElementName, root.getName());
    assertEquals(1, root.getElementCount());
    checkOffsets(root.getElement(0), 0, 1);
    doc.insertString(0, paragraphs, null);
    root = doc.createDefaultRoot();
    assertEquals(1, root.getElementCount());
    if (BasicSwingTestCase.isHarmony()) {
        checkOffsets(root.getElement(0), doc.getStartPosition().getOffset(), doc
                .getEndPosition().getOffset());
    } else {
        checkOffsets(root.getElement(0), 0, 1);
    }
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:20,
代码来源:PlainDocumentTest.java

示例6: testBreakViewCreate

点赞 3

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
/**
 * 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);
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:23,
代码来源:GlyphView_BreakTest.java

示例7: setBreakpointToEOLAt

点赞 2

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
public void setBreakpointToEOLAt(int byteOffset, int lineNumber) {
	final StyledDocument doc = (StyledDocument)editPane.getDocument();
	final Element paragraphElement = doc.getParagraphElement(byteOffset);
	if (paragraphElement.getClass() == BranchElement.class) {
		final SimpleAttributeSet sas = new SimpleAttributeSet(); 
		StyleConstants.setBackground(sas, Color.cyan);
		
		// Look for ending delimiter
		int length = 1;
		try {
			for (int i = byteOffset; ; i++) {
				if (i >= doc.getLength()) {
					length = i - byteOffset + 1;
					break;
				} else if (doc.getText(i, 1).equals("\n")) {
					length = i - byteOffset;
					break;
				}
			}
		} catch (BadLocationException ble) {
			length = 0;
		}
		if (0 < length) {
			doc.setCharacterAttributes(byteOffset, length, sas, false);
		}
	}
}
 

开发者ID:jcoplien,
项目名称:trygve,
代码行数:28,
代码来源:TextEditorGUI.java

示例8: setUp

点赞 2

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    doc = new DefaultStyledDocument();
    root = doc.getDefaultRootElement();
    buf = new DefStyledDoc_Helpers.ElementBufferWithLogging(doc, root);
    doc.buffer = buf;
    paragraph = root.getElement(0);
    content = doc.getContent();
    content.insertString(0, "plainbolditalic\ntext");
    // Create the structure equivalent to this sequence:
    //doc.insertString(doc.getLength(), "plain", null);    // 5 chars
    //doc.insertString(doc.getLength(), "bold", bold);     // 4 chars
    //doc.insertString(doc.getLength(), "italic", italic); // 6 chars
    //doc.insertString(doc.getLength(), "\ntext", null);   // 5 chars
    doc.writeLock(); // Write lock needed to modify document structure
    Element[] leaves = new Element[4];
    leaves[0] = doc.createLeafElement(paragraph, null, 0, 5);
    leaves[1] = doc.createLeafElement(paragraph, bold, 5, 9);
    leaves[2] = doc.createLeafElement(paragraph, italic, 9, 15);
    leaves[3] = doc.createLeafElement(paragraph, null, 15, 16);
    ((BranchElement) paragraph).replace(0, 1, leaves);
    BranchElement branch = (BranchElement) doc.createBranchElement(root, null);
    leaves = new Element[1];
    leaves[0] = doc.createLeafElement(branch, null, 16, 21);
    branch.replace(0, 0, leaves);
    ((BranchElement) root).replace(1, 0, new Element[] { branch });
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:29,
代码来源:DefaultStyledDocument_ElementBuffer_ChangeTest.java

示例9: testDefaultStyledDocumentContentStyleContext

点赞 2

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
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());
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:16,
代码来源:DefaultStyledDocumentTest.java

示例10: testCreateDefaultRoot

点赞 2

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
public void testCreateDefaultRoot() {
    AbstractElement defRoot = doc.createDefaultRoot();
    assertTrue(defRoot instanceof SectionElement);
    assertEquals(0, defRoot.getAttributeCount());
    assertEquals(1, defRoot.getElementCount());
    assertTrue(defRoot.getElement(0) instanceof BranchElement);
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:8,
代码来源:DefaultStyledDocumentTest.java

示例11: testGetNameBranch

点赞 2

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
public void testGetNameBranch() throws Exception {
    final String name = "Ast";
    attrs.addAttribute(AbstractDocument.ElementNameAttribute, name);
    element = doc.new BranchElement(root, attrs);
    assertSame(name, element.getName());
    assertSame(root, element.getParentElement());
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:8,
代码来源:AbstractDocument_AbstractElementRTest.java

示例12: testGetNameParent

点赞 2

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
public void testGetNameParent() throws Exception {
    final String parentName = "parentName";
    attrs.addAttribute(AbstractDocument.ElementNameAttribute, parentName);
    BranchElement parent = doc.new BranchElement(null, attrs);
    AbstractElement element = new AbstractElementImpl(doc, parent, null);
    assertTrue(parent.isDefined(AbstractDocument.ElementNameAttribute));
    assertEquals(parentName, parent.getName());
    assertFalse(element.isDefined(AbstractDocument.ElementNameAttribute));
    assertNull(element.getName());
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:11,
代码来源:AbstractDocument_AbstractElementRTest.java

示例13: setUp

点赞 2

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    doc = new DefaultStyledDocument();
    root = doc.getDefaultRootElement();
    buf = new DefStyledDoc_Helpers.ElementBufferWithLogging(doc, root);
    doc.buffer = buf;
    paragraph = root.getElement(0);
    content = doc.getContent();
    content.insertString(0, "plainbolditalic\ntext");
    // Create the structure equivalent to this sequence:
    //doc.insertString(doc.getLength(), "plain", null);    // 5 chars
    //doc.insertString(doc.getLength(), "bold", bold);     // 4 chars
    //doc.insertString(doc.getLength(), "italic", italic); // 6 chars
    //doc.insertString(doc.getLength(), "\ntext", null);   // 5 chars
    doc.writeLock(); // Write lock needed to modify document structure
    Element[] leaves = new Element[4];
    leaves[0] = doc.createLeafElement(paragraph, null, 0, 5);
    leaves[1] = doc.createLeafElement(paragraph, bold, 5, 9);
    leaves[2] = doc.createLeafElement(paragraph, italic, 9, 15);
    leaves[3] = doc.createLeafElement(paragraph, null, 15, 16);
    ((BranchElement) paragraph).replace(0, 1, leaves);
    BranchElement branch = (BranchElement) doc.createBranchElement(root, null);
    leaves = new Element[1];
    leaves[0] = doc.createLeafElement(branch, null, 16, 21);
    branch.replace(0, 0, leaves);
    branch.addAttributes(boldFalse);
    branch.addAttributes(italicFalse);
    // Add this branch to the root
    ((BranchElement) root).replace(1, 0, new Element[] { branch });
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:32,
代码来源:DefaultStyledDocument_ElementBuffer_RemoveTest.java

示例14: setUp

点赞 2

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
@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();
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:16,
代码来源:AbstractDocument_LeafElementTest.java

示例15: setUp

点赞 2

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    doc = new DefaultStyledDocument();
    root = doc.getDefaultRootElement();
    buf = new DefStyledDoc_Helpers.ElementBufferWithLogging(doc, root);
    doc.buffer = buf;
    paragraph = root.getElement(0);
    content = doc.getContent();
    paragraph = root.getElement(0);
    content.insertString(0, "plainbolditalic\ntext");
    // Create the structure equivalent to this sequence:
    //doc.insertString(doc.getLength(), "plain", null);    // 5 chars
    //doc.insertString(doc.getLength(), "bold", bold);     // 4 chars
    //doc.insertString(doc.getLength(), "italic", italic); // 6 chars
    //doc.insertString(doc.getLength(), "\ntext", null);   // 5 chars
    doc.writeLock(); // Write lock needed to modify document structure
    Element[] leaves = new Element[4];
    leaves[0] = doc.createLeafElement(paragraph, null, 0, 5);
    leaves[1] = doc.createLeafElement(paragraph, bold, 5, 9);
    leaves[2] = doc.createLeafElement(paragraph, italic, 9, 15);
    leaves[3] = doc.createLeafElement(paragraph, null, 15, 16);
    ((BranchElement) paragraph).replace(0, 1, leaves);
    BranchElement branch = (BranchElement) doc.createBranchElement(root, null);
    leaves = new Element[1];
    leaves[0] = doc.createLeafElement(branch, null, 16, 21);
    branch.replace(0, 0, leaves);
    // Add this branch to the root
    ((BranchElement) root).replace(1, 0, new Element[] { branch });
    insertOffset = 5 + 2;
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:32,
代码来源:DefaultStyledDocument_ElementBuffer_InsertSeveralNewLinesTest.java

示例16: setUp

点赞 2

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    StyleContextTest.sc = StyleContext.getDefaultStyleContext();
    as = new AttributeSet[] { StyleContextTest.addAttribute(1),
            StyleContextTest.addAttribute(2), StyleContextTest.addAttribute(null, 3, 2) };
    doc = new PlainDocument();
    doc.insertString(0, LTR + RTL + LTR + RTL + "\n01234", as[0]);
    bidi = (BranchElement) doc.getBidiRootElement();
    leaf1 = bidi.getElement(0).getElement(0);
    par = (BranchElement) doc.getDefaultRootElement();
    leaf2 = par.getElement(0);
    leaf3 = par.getElement(1);
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:15,
代码来源:AbstractDocument_BranchElementTest.java

示例17: testGetStartOffsetNoChildren

点赞 2

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
public void testGetStartOffsetNoChildren() {
    par = doc.new BranchElement(null, null);
    try {
        par.getStartOffset();
        fail("NullPointerException is expected");
    } catch (NullPointerException e) {
        // expected
    }
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:10,
代码来源:AbstractDocument_BranchElementTest.java

示例18: testGetEndOffsetNoChildren

点赞 2

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
public void testGetEndOffsetNoChildren() {
    par = doc.new BranchElement(null, null);
    try {
        par.getEndOffset();
        fail("NullPointerException is expected");
    } catch (NullPointerException e) {
        // expected
    }
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:10,
代码来源:AbstractDocument_BranchElementTest.java

示例19: testBranchElement

点赞 2

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
public void testBranchElement() {
    doc.writeLock();
    bidi = doc.new BranchElement(par, as[2]);
    doc.writeUnlock();
    assertNotSame(as[2], bidi.getAttributes());
    assertEquals(as[2], bidi.getAttributes());
    assertSame(par, bidi.getParentElement());
    assertEquals(0, bidi.getElementCount());
    assertNull(bidi.getElement(0));
    Enumeration<?> elements = bidi.children();
    assertNull(elements);
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:13,
代码来源:AbstractDocument_BranchElementTest.java

示例20: createBranchElement

点赞 2

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
/**
 * Creates <code>BranchElement</code> which doesn't span over the whole document.
 * <code>DefaultStyledDocument</code> is used to prepare the structure.
 */
private BranchElement createBranchElement() throws BadLocationException {
    final DefaultStyledDocument styledDoc = new DefaultStyledDocument(); 
    doc = styledDoc;
    doc.insertString(doc.getLength(), "1 line\nonetwothree\n3 line", null);
    //                                 0123456 789012345678 901234
    //                                 0          1          2
    styledDoc.setCharacterAttributes(7, 3, SimpleAttributeSet.EMPTY, false);
    styledDoc.setCharacterAttributes(10, 3, SimpleAttributeSet.EMPTY, false);
    styledDoc.setCharacterAttributes(13, 5, SimpleAttributeSet.EMPTY, false);
    return (BranchElement)doc.getDefaultRootElement().getElement(1);
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:16,
代码来源:AbstractDocument_BranchElementTest.java

示例21: createEmptyHTMLStructure

点赞 2

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
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();
    }
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:31,
代码来源:DefaultStyledDocumentRTest.java

示例22: testViewToModel04

点赞 2

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
/**
 * Tests viewToModel(float, float, Shape, Bias[]).
 * For isBefore, isAfter the Y is used only. In this test either
 * isBefore or isAfter is true.
 * <p>In this test modified <code>root</code> is used so that
 * <code>view.getStartOffset() != 0</code> and
 * <code>view.getEndOffset() != doc.getLength()</code>.
 */
public void testViewToModel04() {
    // Modify the root
    final int oldCount = root.getElementCount();
    BranchElement docRoot = (BranchElement) root;
    final Element[] empty = new Element[0];
    docRoot.replace(0, 1, empty);
    docRoot.replace(docRoot.getElementCount() - 1, 1, empty);
    final int newCount = root.getElementCount();
    assertEquals(oldCount - 2, newCount);
    // Re-load children
    view.removeAll();
    view.loadChildren(factory);
    CompositeViewTest.useBoth = false;
    CompositeViewTest.useX = false;
    int x, y;
    // Before the allocation
    x = bounds.x;
    y = bounds.y - 1;
    assertTrue(view.isBefore(x, y, bounds));
    int offset = view.viewToModel(x, y, shape, bias);
    assertEquals(view.getStartOffset(), offset);
    assertEquals(root.getElement(0).getStartOffset(), offset);
    // After the allocation
    y = bounds.y + bounds.height + 1;
    assertTrue(view.isAfter(x, y, bounds));
    bias[0] = null;
    offset = view.viewToModel(x, y, shape, bias);
    assertEquals(view.getEndOffset() - 1, offset);
    assertEquals(root.getElement(root.getElementCount() - 1).getEndOffset() - 1, offset);
    if (BasicSwingTestCase.isHarmony()) {
        assertSame(Bias.Backward, bias[0]);
    }
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:42,
代码来源:CompositeView_ModelViewTest.java

示例23: setUp

点赞 2

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    doc = new DisAbstractedDocument(new GapContent());
    doc.writeLock();
    BranchElement branch = doc.new BranchElement(null, null);
    aElement = doc.new LeafElement(null, null, 0, 3);
    parented = doc.new LeafElement(parent = branch, null, 5, 8);
    doc.writeUnlock();
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:10,
代码来源:AbstractDocument_LeafElement_TreeNodeTest.java

示例24: setUp

点赞 2

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
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;
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:15,
代码来源:HTMLDocument_BlockElementTest.java

示例25: setUp

点赞 2

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
protected void setUp() throws Exception {
    super.setUp();

    htmlDoc = new LockableHTMLDocument();
    doc = htmlDoc;

    doc.insertString(0, "0123456789", as[0]);

    htmlDoc.lockWrite();
    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);
    htmlDoc.unlockWrite();
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:15,
代码来源:HTMLDocument_RunElementTest.java

示例26: testTranslateHTMLToCSSStyledDocument

点赞 2

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
public void testTranslateHTMLToCSSStyledDocument() throws Exception {
    StyledDocument doc = new DefaultStyledDocument();
    doc.insertString(0, "line1\nline2", null);

    MutableAttributeSet mas = new SimpleAttributeSet();
    mas.addAttribute(HTML.Attribute.BGCOLOR, "#ffffff");
    mas.addAttribute(HTML.Attribute.TEXT, "black");
    doc.setParagraphAttributes(0, 1, mas, false);

    AbstractElement branch =
        (AbstractElement)doc.getDefaultRootElement().getElement(0);
    assertEquals("paragraph", branch.getName());
    assertTrue(branch instanceof BranchElement);
    assertSame(BranchElement.class, branch.getClass());


    attr = ss.translateHTMLToCSS(branch);
    assertSame(NamedStyle.class, attr.getClass());
    assertNull(((NamedStyle)attr).getName());

    assertEquals(2, attr.getAttributeCount());
    assertEquals("#ffffff",
                 attr.getAttribute(CSS.Attribute.BACKGROUND_COLOR)
                 .toString());
    assertEquals("black",
                 attr.getAttribute(CSS.Attribute.COLOR).toString());
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:28,
代码来源:StyleSheet_TranslateHTMLToCSS.java

示例27: setUp

点赞 2

import javax.swing.text.AbstractDocument.BranchElement; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    doc = new DefaultStyledDocument();
    root = doc.getDefaultRootElement();
    buf = new DefStyledDoc_Helpers.ElementBufferWithLogging(doc, root);
    doc.buffer = buf;
    paragraph = root.getElement(0);
    content = doc.getContent();
    content.insertString(0, "plainbolditalic\ntext");
    // Create the structure equivalent to this sequence:
    //doc.insertString(doc.getLength(), "plain", null);    // 5 chars
    //doc.insertString(doc.getLength(), "bold", bold);     // 4 chars
    //doc.insertString(doc.getLength(), "italic", italic); // 6 chars
    //doc.insertString(doc.getLength(), "\ntext", null);   // 5 chars
    doc.writeLock(); // Write lock needed to modify document structure
    Element[] leaves = new Element[4];
    leaves[0] = doc.createLeafElement(paragraph, null, 0, 5);
    leaves[1] = doc.createLeafElement(paragraph, bold, 5, 9);
    leaves[2] = doc.createLeafElement(paragraph, italic, 9, 15);
    leaves[3] = doc.createLeafElement(paragraph, null, 15, 16);
    ((BranchElement) paragraph).replace(0, 1, leaves);
    BranchElement branch = (BranchElement) doc.createBranchElement(root, null);
    leaves = new Element[1];
    leaves[0] = doc.createLeafElement(branch, null, 16, 21);
    branch.replace(0, 0, leaves);
    // Add this branch to the root
    ((BranchElement) root).replace(1, 0, new Element[] { branch });
    insertOffset = 5 + 2;
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:31,
代码来源:DefaultStyledDocument_ElementBuffer_InsertNewLineTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)