Package javax.swing.text.DefaultStyledDocument

Examples of javax.swing.text.DefaultStyledDocument.ElementSpec


    public void testInsertDiffAttrsDocStart() throws Exception {
        insertOffset = 0;
        // doc.insertString(insertOffset, newLine, italic);
        content.insertString(insertOffset, newLine);
        event = doc.new DefaultDocumentEvent(insertOffset, newLineLen, EventType.INSERT);
        ElementSpec[] specs = { new ElementSpec(italic, ElementSpec.ContentType, newLineLen),
                new ElementSpec(null, ElementSpec.EndTagType),
                new ElementSpec(null, ElementSpec.StartTagType) };
        specs[2].setDirection(ElementSpec.JoinFractureDirection);
        buf.insert(insertOffset, newLineLen, specs, event);
        List<?> edits = getEdits(event);
        assertEquals(2, edits.size());
        assertChange(edits.get(0), new int[] { 0, 6, 6, 10, 10, 16, 16, 17 },
View Full Code Here


     */
    public void testInsertSameAttrsMiddle() throws Exception {
        // doc.insertString(insertOffset, newLine, bold);
        content.insertString(insertOffset, newLine);
        event = doc.new DefaultDocumentEvent(insertOffset, newLineLen, EventType.INSERT);
        ElementSpec[] specs = { new ElementSpec(null, ElementSpec.ContentType, newLineLen),
                new ElementSpec(null, ElementSpec.EndTagType),
                new ElementSpec(null, ElementSpec.StartTagType) };
        specs[0].setDirection(ElementSpec.JoinPreviousDirection);
        specs[2].setDirection(ElementSpec.JoinFractureDirection);
        buf.insert(insertOffset, newLineLen, specs, event);
        List<?> edits = getEdits(event);
        assertEquals(2, edits.size());
View Full Code Here

    public void testInsertSameAttrsEnd() throws Exception {
        insertOffset += 2;
        // doc.insertString(insertOffset, newLine, bold);
        content.insertString(insertOffset, newLine);
        event = doc.new DefaultDocumentEvent(insertOffset, newLineLen, EventType.INSERT);
        ElementSpec[] specs = { new ElementSpec(null, ElementSpec.ContentType, newLineLen),
                new ElementSpec(null, ElementSpec.EndTagType),
                new ElementSpec(null, ElementSpec.StartTagType) };
        specs[0].setDirection(ElementSpec.JoinPreviousDirection);
        specs[2].setDirection(ElementSpec.JoinFractureDirection);
        // Spec [0] has wrong attributes (should be bold) but everything works
        // the way it supposed to.
        buf.insert(insertOffset, newLineLen, specs, event);
View Full Code Here

     */
    public void testInsertDiffAttrsMiddle() throws Exception {
        // doc.insertString(insertOffset, newLine, null);
        content.insertString(insertOffset, newLine);
        event = doc.new DefaultDocumentEvent(insertOffset, newLineLen, EventType.INSERT);
        ElementSpec[] specs = { new ElementSpec(null, ElementSpec.ContentType, newLineLen),
                new ElementSpec(null, ElementSpec.EndTagType),
                new ElementSpec(null, ElementSpec.StartTagType) };
        specs[2].setDirection(ElementSpec.JoinFractureDirection);
        buf.insert(insertOffset, newLineLen, specs, event);
        List<?> edits = getEdits(event);
        assertEquals(2, edits.size());
        assertChange(edits.get(0), new int[] { 5, 10, 10, 16, 16, 17 },
View Full Code Here

    public void testInsertDiffAttrsEnd() throws Exception {
        insertOffset += 2;
        // doc.insertString(insertOffset, newLine, null);
        content.insertString(insertOffset, newLine);
        event = doc.new DefaultDocumentEvent(insertOffset, newLineLen, EventType.INSERT);
        ElementSpec[] specs = { new ElementSpec(null, ElementSpec.ContentType, newLineLen),
                new ElementSpec(null, ElementSpec.EndTagType),
                new ElementSpec(null, ElementSpec.StartTagType) };
        specs[2].setDirection(ElementSpec.JoinFractureDirection);
        buf.insert(insertOffset, newLineLen, specs, event);
        List<?> edits = getEdits(event);
        assertEquals(2, edits.size());
        assertChange(edits.get(0), new int[] { 5, 10, 10, 16, 16, 17 },
View Full Code Here

    public void testInsertDiffSameAttrsEnd() throws Exception {
        insertOffset += 2;
        // doc.insertString(insertOffset, newLine, italic);
        content.insertString(insertOffset, newLine);
        event = doc.new DefaultDocumentEvent(insertOffset, newLineLen, EventType.INSERT);
        ElementSpec[] specs = { new ElementSpec(italic, ElementSpec.ContentType, newLineLen),
                new ElementSpec(null, ElementSpec.EndTagType),
                new ElementSpec(null, ElementSpec.StartTagType) };
        specs[2].setDirection(ElementSpec.JoinFractureDirection);
        buf.insert(insertOffset, newLineLen, specs, event);
        List<?> edits = getEdits(event);
        assertEquals(2, edits.size());
        assertChange(edits.get(0), new int[] { 5, 10, 10, 16, 16, 17 },
View Full Code Here

    public void testInsertSameAttrsParStart() throws Exception {
        insertOffset = paragraph.getEndOffset();
        // doc.insertString(insertOffset, newLine, null);
        content.insertString(insertOffset, newLine);
        event = doc.new DefaultDocumentEvent(insertOffset, newLineLen, EventType.INSERT);
        ElementSpec[] specs = { new ElementSpec(null, ElementSpec.EndTagType),
                new ElementSpec(null, ElementSpec.StartTagType),
                new ElementSpec(null, ElementSpec.ContentType, newLineLen),
                new ElementSpec(null, ElementSpec.EndTagType),
                new ElementSpec(null, ElementSpec.StartTagType) };
        specs[4].setDirection(ElementSpec.JoinNextDirection);
        buf.insert(insertOffset, newLineLen, specs, event);
        List<?> edits = getEdits(event);
        assertEquals(3, edits.size());
        assertChange(edits.get(0), new int[] { 15, 17 }, new int[] { 15, 16 });
View Full Code Here

    public void testInsertDiffAttrsParStart() throws Exception {
        insertOffset = paragraph.getEndOffset();
        // doc.insertString(insertOffset, newLine, italic);
        content.insertString(insertOffset, newLine);
        event = doc.new DefaultDocumentEvent(insertOffset, newLineLen, EventType.INSERT);
        ElementSpec[] specs = { new ElementSpec(null, ElementSpec.EndTagType),
                new ElementSpec(null, ElementSpec.StartTagType),
                new ElementSpec(italic, ElementSpec.ContentType, newLineLen),
                new ElementSpec(null, ElementSpec.EndTagType),
                new ElementSpec(null, ElementSpec.StartTagType) };
        specs[4].setDirection(ElementSpec.JoinNextDirection);
        buf.insert(insertOffset, newLineLen, specs, event);
        List<?> edits = getEdits(event);
        assertEquals(3, edits.size());
        assertChange(edits.get(0), new int[] { 15, 17 }, new int[] { 15, 16 });
View Full Code Here

    public void testInsertSameAttrsDocEnd() throws Exception {
        insertOffset = doc.getLength();
        // doc.insertString(insertOffset, newLine, null);
        content.insertString(insertOffset, newLine);
        event = doc.new DefaultDocumentEvent(insertOffset, newLineLen, EventType.INSERT);
        ElementSpec[] specs = { new ElementSpec(null, ElementSpec.ContentType, newLineLen),
                new ElementSpec(null, ElementSpec.EndTagType),
                new ElementSpec(null, ElementSpec.StartTagType) };
        specs[0].setDirection(ElementSpec.JoinPreviousDirection);
        specs[2].setDirection(ElementSpec.JoinFractureDirection);
        buf.insert(insertOffset, newLineLen, specs, event);
        List<?> edits = getEdits(event);
        assertEquals(2, edits.size());
View Full Code Here

    public void testInsertDiffAttrsDocEnd() throws Exception {
        insertOffset = doc.getLength();
        // doc.insertString(insertOffset, newLine, italic);
        content.insertString(insertOffset, newLine);
        event = doc.new DefaultDocumentEvent(insertOffset, newLineLen, EventType.INSERT);
        ElementSpec[] specs = { new ElementSpec(italic, ElementSpec.ContentType, newLineLen),
                new ElementSpec(null, ElementSpec.EndTagType),
                new ElementSpec(null, ElementSpec.StartTagType) };
        specs[2].setDirection(ElementSpec.JoinFractureDirection);
        buf.insert(insertOffset, newLineLen, specs, event);
        List<?> edits = getEdits(event);
        assertEquals(2, edits.size());
        assertChange(edits.get(0), new int[] { 16, 22 }, new int[] { 16, 20, 20, 21 });
View Full Code Here

TOP

Related Classes of javax.swing.text.DefaultStyledDocument.ElementSpec

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.