Package com.volantis.styling

Examples of com.volantis.styling.Styles


     * @param winner    Styles to merge, may be null.
     * @param luser     Styles to merge, may be null.
     * @return merged Styles. Will be null if both parameters are null.
     */
    public Styles merge(Styles winner, Styles luser) {
        Styles result = winner;

        if (winner != null && luser != null) {

            result = factory.createStyles(null);
            mergePropertyValues(result.getPropertyValues(),
                    winner.getPropertyValues(), luser.getPropertyValues());

        } else if (luser != null) {
            result = luser;
        }
View Full Code Here


        // iterate over the dom, extracting all the elements into a list
        final OutputStylesFactory factory = new OutputStylesFactory();
        WalkingDOMVisitor visitor = new WalkingDOMVisitorStub() {
            public void visit(Element element) {
                OutputStyles outputStyles = null;
                Styles styles = element.getStyles();
                if (styles != null) {
                    outputStyles = factory.create(element.getName(), styles);
                }
                OutputStyledElement outputElement =
                        new OutputStyledElement(element, outputStyles);
View Full Code Here

    }

    public void testMergeWinnerAndLoser() {

        StylingFactory stylingFactory = StylingFactory.getDefaultInstance();
        Styles expectedResult = stylingFactory.createStyles(null);
        factoryMock.expects.createStyles(null)
                .returns(expectedResult);

        Styles winner = StylesBuilder.getCompleteStyles(
                "background-color: green; font-size: medium");
        Styles loser = StylesBuilder.getCompleteStyles(
                "background-color: red; color: red");

        Styles result = merger.merge(winner, loser);
        assertSame(expectedResult, result);

        MutableStylePropertySet set = new MutableStylePropertySetImpl();
        set.add(StylePropertyDetails.BACKGROUND_COLOR);
        set.add(StylePropertyDetails.COLOR);
View Full Code Here

        assertEquals("{background-color: green; color: red; font-size: medium}",
                resultCSS);
    }

    public void testMergeWinnerNoLoser() {
        Styles winner = StylesBuilder.getCompleteStyles(
                "background-color: green; font-size: medium", true);

        Styles result = merger.merge(winner, null);
        assertSame(winner, result);

        MutableStylePropertySet set = new MutableStylePropertySetImpl();
        set.add(StylePropertyDetails.BACKGROUND_COLOR);
        set.add(StylePropertyDetails.COLOR);
View Full Code Here

        assertEquals("{background-color: green; font-size: medium}",
                resultCSS);
    }

    public void testMergeLoserNoWinner() {
        Styles loser = StylesBuilder.getCompleteStyles(
                "background-color: red; color: red", true);

        Styles result = merger.merge(null, loser);
        assertSame(loser, result);

        MutableStylePropertySet set = new MutableStylePropertySetImpl();
        set.add(StylePropertyDetails.BACKGROUND_COLOR);
        set.add(StylePropertyDetails.COLOR);
View Full Code Here

     * Test an (implicit reset and) increment.
     */
    public void testImplicit() {

        final String name = "implicit";
        Styles increment =
                StylesBuilder.getStyles("counter-increment: " + name);

        engine.startElement(increment);
        {
            assertEquals(1, counter(name));
View Full Code Here

     * Test an explicit reset and increment.
     */
    public void testExplicit() {

        final String name = "explicit";
        Styles reset = StylesBuilder.getStyles("counter-reset: " + name);
        Styles increment = StylesBuilder.getStyles("counter-increment: " + name);

        engine.startElement(reset);
        {
            assertEquals(0, counter(name));
            engine.startElement(increment);
View Full Code Here

    /**
     * Test a counter going out of scope.
     */
    public void testOutOfScope() {
        final String name = "counter";
        Styles increment =
                StylesBuilder.getStyles("counter-increment: " + name);
        Styles none = StylesBuilder.getEmptyStyles();
        engine.startElement(none);
        {
            assertNull("Counter should be out of scope",
                    engine.getCounter(name, false));
            engine.startElement(increment);
View Full Code Here

     * Test a complex-ish nested scenario.
     */
    public void testNested() {

        final String name = "nested";
        Styles reset = StylesBuilder.getStyles("counter-reset: " + name);
        Styles increment =
                StylesBuilder.getStyles("counter-increment: " + name);
        Styles none = StylesBuilder.getEmptyStyles();
        Styles reset2 =
                StylesBuilder.getStyles("counter-reset: " + name + " 2");
        Styles increment2 =
                StylesBuilder.getStyles("counter-increment: " + name + " 2");

        engine.startElement(reset);
        {
            assertEquals(0, counter(name));
View Full Code Here

     * emulated elements are correctly captured on the emulating elements.
     */
    public void testFlattenTableCellWithStylesAndNamedUnstyledParent()
            throws IOException, SAXException, ParserConfigurationException {

        Styles expectedStyles = generateTestColorStyles();

        Element newParent = doFlattenTableCell(expectedStyles,
                false, true, false, true);

        assertNotNull(newParent.getStyles());
        Styles actualStyles = newParent.getStyles();
        checkFlattenedValues(expectedStyles, actualStyles, true);

        newParent = doFlattenTableCell(expectedStyles,
                true, true, false, true);
        assertNotNull(newParent.getStyles());
View Full Code Here

TOP

Related Classes of com.volantis.styling.Styles

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.