Package com.volantis.mcs.css.renderer

Examples of com.volantis.mcs.css.renderer.RendererContext


                String expectedCSS)
                throws Exception {

            StringWriter writer = new StringWriter();
            StyleSheetRenderer styleSheetRenderer = CSSStyleSheetRenderer.getSingleton();
            RendererContext context = new RendererContext(writer,
                    styleSheetRenderer);

            final StyleValuesMock parentValuesMock =
                    new StyleValuesMock("parentValuesMock", expectations);

            StylingFactory stylingFactory = StylingFactory.getDefaultInstance();

            final MutableStyleProperties inputProperties =
                    parser.parseDeclarations(inputCSS);
            final MutablePropertyValues inputValues = stylingFactory.createPropertyValues(
                    StylePropertyDetails.getDefinitions());
            inputProperties.iteratePropertyValues(new PropertyValueIteratee() {
                public IterationAction next(PropertyValue propertyValue) {
                    inputValues.setComputedValue(propertyValue.getProperty(),
                            propertyValue.getValue());
                    return IterationAction.CONTINUE;
                }
            });

            final MutableStyleProperties outputValues =
                ThemeFactory.getDefaultInstance().createMutableStyleProperties();

            checker.setInputValues(inputValues);

            if (normalizer != null) {
                normalizer.normalize(inputValues);
            }

//            // Create output properties and populate with the computed values.
//            PropertyDetailsSet detailsSet = StylePropertyDetails
//                    .getDefinitions().getStandardDetailsSet();
//            detailsSet.iterateStyleProperties(new StylePropertyIteratee() {
//                public IterationAction next(StyleProperty property) {
//                    StyleValue value = inputValues.getComputedValue(property);
//
//                    outputValues.setStyleValue(property, value);
//                    return IterationAction.CONTINUE;
//                }
//            });
//
            final DeviceValuesMock deviceValuesMock =
                    DeviceStylingTestHelper.createDeviceValuesMock(mockFactory,
                            expectations, DeviceValues.UNKNOWN);

            optimizer.optimize(TargetEntity.ELEMENT, inputValues, outputValues,
                    deviceValuesMock);

            renderer.render(outputValues, context);
            context.flushStyleSheet();

            String actualCSS = writer.getBuffer().toString();

            assertEquals(expectedCSS, actualCSS);
        }
View Full Code Here


            StyleValue value = propertyValue.getValue();
            StyleProperty property = propertyValue.getProperty();

            StringWriter writer = new StringWriter();
            String rendered = "";
            RendererContext context = new RendererContext(
                    writer, CSSStyleSheetRenderer.getSingleton());
            StyleSheetRenderer renderer = CSSStyleSheetRenderer.getSingleton();
            try {
                MutableStyleProperties properties =
                    ThemeFactory.getDefaultInstance().createMutableStyleProperties();
                properties.setStyleValue(property, value);
                renderer.renderStyleProperties(properties, context);
                context.flushStyleSheet();
                rendered = writer.toString();
                int firstColon = rendered.indexOf(':');
                if (firstColon > 0) {
                    rendered = rendered.substring(firstColon + 1);
                }
View Full Code Here

         * @return The string representation of the selectors
         */
        private String selectorToString(List selectors) {
            StringWriter writer = new StringWriter();
            String rendered = "";
            RendererContext context = new RendererContext(
                    writer, CSSStyleSheetRenderer.getSingleton());
            StyleSheetRenderer renderer = CSSStyleSheetRenderer.getSingleton();
            try {
                renderer.renderStyleSelectors(selectors, context);
                context.flushStyleSheet();
                rendered = writer.toString();
            } catch (IOException ioe) {
            }
            return rendered;
        }
View Full Code Here

     */
    private String renderProperties(
            StyleProperties properties) throws IOException {
        StyleSheetRenderer renderer = CSSStyleSheetRenderer.getSingleton();
        StringWriter writer = new StringWriter();
        RendererContext context = new RendererContext(writer, renderer);
        renderer.renderStyleProperties(properties, context);
        context.flushStyleSheet();
        return writer.getBuffer().toString();
    }
View Full Code Here

     */
    public String render(StyleValue value) {
        StringWriter writer = new StringWriter();
        StyleSheetRenderer styleSheetRenderer =
                CSSStyleSheetRenderer.getSingleton();
        RendererContext context =
                new RendererContext(writer, styleSheetRenderer);

        // Don't forget to setup the css keyword mapper
        setKeywordMapper(context);

        String styleProperty = "";
        try{
            context.renderValue(value);
            styleProperty = context.getWriter().toString();
        } catch(IOException e) {
            // This should never really happen.  However, log a warning
            // if it does.
            logger.warn("unable-to-write-style-value",new Object[]{value});
        }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.css.renderer.RendererContext

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.