Package javax.swing.text

Examples of javax.swing.text.MutableAttributeSet.addAttribute()


    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);
View Full Code Here


        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());
View Full Code Here

        assertTrue(simple.isEqual(attr));
    }

    public void testIsEqualMutable() throws Exception {
        final MutableAttributeSet simple = new SimpleAttributeSet();
        simple.addAttribute(scAttribute, scValue);

        assertTrue(attr.isEqual(simple));
        if (isHarmony()) {
            assertTrue(simple.isEqual(attr));
        } else {
View Full Code Here

        assertTrue(simple.containsAttributes(attr));
    }

    public void testContainsAttributesMutable() throws Exception {
        final MutableAttributeSet simple = new SimpleAttributeSet();
        simple.addAttribute(scAttribute, scValue);

        assertTrue(attr.containsAttributes(simple));
        assertFalse(simple.containsAttributes(attr));
    }
View Full Code Here

                   HTML.getAttributeKey("width"));
    }

    public void testGetIntegerAttributeValue() {
        MutableAttributeSet attrs = new SimpleAttributeSet();
        attrs.addAttribute(Attribute.COLSPAN, new String("11"));
        assertEquals(11,
                     HTML.getIntegerAttributeValue(attrs,
                                                   Attribute.COLSPAN, -1));

        attrs = new SimpleAttributeSet();
View Full Code Here

        assertEquals(11,
                     HTML.getIntegerAttributeValue(attrs,
                                                   Attribute.COLSPAN, -1));

        attrs = new SimpleAttributeSet();
        attrs.addAttribute(Attribute.HREF, new String("10101"));
        assertEquals(10101,
                     HTML.getIntegerAttributeValue(attrs,
                                                   Attribute.HREF, -1));

        attrs = new SimpleAttributeSet();
View Full Code Here

        assertEquals(10101,
                     HTML.getIntegerAttributeValue(attrs,
                                                   Attribute.HREF, -1));

        attrs = new SimpleAttributeSet();
        attrs.addAttribute(Attribute.HREF, new String("not a number"));
        assertEquals(-1,
                     HTML.getIntegerAttributeValue(attrs,
                                                   Attribute.HREF, -1));

        attrs = new SimpleAttributeSet();
View Full Code Here

        assertEquals(-1,
                     HTML.getIntegerAttributeValue(attrs,
                                                   Attribute.HREF, -1));

        final MutableAttributeSet wrongValue = new SimpleAttributeSet();
        wrongValue.addAttribute(Attribute.HREF, new Integer("10101"));
        testExceptionalCase(new ClassCastCase() {
            public void exceptionalAction() throws Exception {
                HTML.getIntegerAttributeValue(wrongValue, Attribute.HREF, -1);
            }
        });
View Full Code Here

        assertTrue(simple.containsAttributes(attr));
    }

    public void testContainsAttributesMutable() throws Exception {
        final MutableAttributeSet simple = new SimpleAttributeSet();
        simple.addAttribute(scAttribute, scValue);

        assertTrue(attr.containsAttributes(simple));
        assertFalse(simple.containsAttributes(attr));
    }
View Full Code Here

        assertItalicButNotBold();
    }

    public void testAddAttributes() throws Exception {
        MutableAttributeSet simple = new SimpleAttributeSet();
        simple.addAttribute(StyleConstants.Bold, Boolean.TRUE);

        mutable.addAttributes(simple);
        assertEquals(count + 1, mutable.getAttributeCount());
        assertItalicButNotBold();
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.