Examples of MutableStyleProperties


Examples of com.volantis.mcs.themes.MutableStyleProperties

    // todo: make into factory class for testing and sharing?
    private MutableStyleProperties createPropertiesFromValues(
            final PropertyValues values) {

        // todo: don't create unless necessary. then no need for empty check above?
        final MutableStyleProperties properties =
            ThemeFactory.getDefaultInstance().createMutableStyleProperties();

        // todo: better to use values.iterateComputed() and StyleValueIteratee?
        values.iterateStyleProperties(new StylePropertyIteratee() {
            public IterationAction next(StyleProperty property) {
                StyleValue value = values.getComputedValue(property);
                properties.setStyleValue(property, value);
                return IterationAction.CONTINUE;
            }
        });

        return properties;
View Full Code Here

Examples of com.volantis.mcs.themes.MutableStyleProperties

     * all others.
     * @return newly created initialised MutablePropertyValuesMock
     */
    private MutablePropertyValuesMock createWinnerPropertyValues() {

        MutableStyleProperties winnerProperties =
            ThemeFactory.getDefaultInstance().createMutableStyleProperties();
        winnerProperties.setStyleValue(StylePropertyDetails.BORDER_BOTTOM_WIDTH,
                winnerValue);
        winnerProperties.setStyleValue(StylePropertyDetails.BORDER_BOTTOM_WIDTH,
                winnerValue);
        winnerProperties.setStyleValue(StylePropertyDetails.BORDER_TOP_WIDTH,
                winnerValue);
        winnerProperties.setStyleValue(StylePropertyDetails.BORDER_LEFT_WIDTH,
                winnerValue);
        winnerProperties.setStyleValue(StylePropertyDetails.BORDER_RIGHT_WIDTH,
                winnerValue);
        winnerProperties.setStyleValue(StylePropertyDetails.COLOR, red);

        MutablePropertyValuesMock winnerProps =
                createTestablePropertyValues(winnerProperties);
        return winnerProps;
    }
View Full Code Here

Examples of com.volantis.mcs.themes.MutableStyleProperties

     * FONT_STYLE properties, and null for all others.
     *
     * @return newly created initialised MutablePropertyValuesMock
     */
    private MutablePropertyValuesMock createLuserPropertyValues() {
        MutableStyleProperties luserProperties =
            ThemeFactory.getDefaultInstance().createMutableStyleProperties();
        luserProperties.setStyleValue(StylePropertyDetails.BORDER_BOTTOM_WIDTH,
                luserValue);
        luserProperties.setStyleValue(StylePropertyDetails.BORDER_TOP_WIDTH,
                luserValue);
        luserProperties.setStyleValue(StylePropertyDetails.BORDER_LEFT_WIDTH,
                luserValue);
        luserProperties.setStyleValue(StylePropertyDetails.BORDER_RIGHT_WIDTH,
                luserValue);
        luserProperties.setStyleValue(StylePropertyDetails.PADDING_BOTTOM,
                luserValue);
        luserProperties.setStyleValue(StylePropertyDetails.PADDING_TOP,
                luserValue);
        luserProperties.setStyleValue(StylePropertyDetails.PADDING_LEFT,
                luserValue);
        luserProperties.setStyleValue(StylePropertyDetails.PADDING_RIGHT,
                luserValue);
        luserProperties.setStyleValue(StylePropertyDetails.BORDER_LEFT_COLOR,
                red);
        luserProperties.setStyleValue(StylePropertyDetails.BORDER_RIGHT_COLOR,
                red);
        luserProperties.setStyleValue(StylePropertyDetails.BACKGROUND_COLOR,
                green);
        luserProperties.setStyleValue(StylePropertyDetails.COLOR, white);
        luserProperties.setStyleValue(StylePropertyDetails.WIDTH, luserValue);
        luserProperties.setStyleValue(StylePropertyDetails.HEIGHT, luserValue);
        luserProperties.setStyleValue(StylePropertyDetails.FONT_STYLE, italic);

        MutablePropertyValuesMock luserProps =
                createTestablePropertyValues(luserProperties);
        return luserProps;
    }
View Full Code Here

Examples of com.volantis.mcs.themes.MutableStyleProperties

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

Examples of com.volantis.mcs.themes.MutableStyleProperties

        // Create a new output properties if needed, or use the saved one.
        if (savedOutputValues == null) {
            savedOutputValues =
                ThemeFactory.getDefaultInstance().createMutableStyleProperties();
        }
        MutableStyleProperties outputValues = savedOutputValues;

        // Optimize the shorthand based properties.
        for (int i = 0; i < optimizers.length; i++) {
            ShorthandOptimizer optimizer = optimizers[i];
            optimizer.optimize(target, inputValues, outputValues,
                    deviceValues);
        }

        // Optimize the individual properties.
        individualOptimizer.optimize(target, inputValues, outputValues,
                deviceValues);

        // If there are no properties in the output then return null, otherwise
        // make sure that the saved values is not used again.
        if (outputValues.isEmpty()) {
            outputValues = null;
        } else {
            savedOutputValues = null;
        }
View Full Code Here

Examples of com.volantis.mcs.themes.MutableStyleProperties

        // The mcs-system-font property is equivalent to setting all properties
        // set by the font shorthand to unknown user agent specific values.
        PropertyValue systemFont = properties.getPropertyValue(MCS_SYSTEM_FONT);
        if (systemFont != null) {
            Priority systemFontPriority = systemFont.getPriority();
            MutableStyleProperties copy =
                ThemeFactory.getDefaultInstance().createMutableStyleProperties(
                    properties);

            // The system font is set so make sure that all the other font
            // properties are set with equal or greater priority.
            for (int i = 0; i < UNKNOWN_FONT_PROPERTIES.length; i++) {
                PropertyValue value = UNKNOWN_FONT_PROPERTIES[i];
                StyleProperty property = value.getProperty();

                PropertyValue propertyValue = properties.getPropertyValue(
                        property);
                if (propertyValue == null ||
                        systemFontPriority.isGreaterThan(
                                propertyValue.getPriority())) {

                    propertyValue =
                        ThemeFactory.getDefaultInstance().createPropertyValue(
                            property, UnknownFontValue.INSTANCE,
                            systemFontPriority);
                    copy.setPropertyValue(propertyValue);
                }
            }

            properties = copy;
        }
View Full Code Here

Examples of com.volantis.mcs.themes.MutableStyleProperties

        String type = selectorSequence.getType();
        if (type == null || type.equals(element.getName())) {

            // Then extract the appropriate properties from the styles.

            MutableStyleProperties properties = null;
            PseudoStylePath pseudoPath = selectorSequence.getPath();
            // If the element has styles
            OutputStyles styles = element.getStyles();
            if (styles != null) {
                // Then we might have some style properties.
                properties = styles.getPathProperties(pseudoPath);
            }
            // else, no styles. This means the properties are empty.

            action = filtered.next(properties);

            // the filtered may remove property values, so we need to check
            // to see if the containing objects are still required.
            if (properties != null && properties.isEmpty()) {
                // if the properties is now empty, remove it.
                styles.removePathProperties(pseudoPath);
                if (styles.isEmpty()) {
                    element.clearStyles();
                }
View Full Code Here

Examples of com.volantis.mcs.themes.MutableStyleProperties

    public void emulate(Element element,
                        OutputStyles outputStyles) {

        // Only need to emulate the output styles if there are some...
        if (outputStyles != null) {
            MutableStyleProperties hoverProperties =
                    outputStyles.getPathProperties(
                            PseudoStylePath.EMPTY_PATH.addPseudoClassSet(
                                    StatefulPseudoClassImpl.HOVER.getSet()));

            if (hoverProperties != null && !hoverProperties.isEmpty()) {
                final String previousOnMouseOver =
                        element.getAttributeValue(ON_MOUSE_OVER);
                final String previousOnMouseOut =
                        element.getAttributeValue(ON_MOUSE_OUT);

                StringBuffer mouseOverBuffer = previousOnMouseOver == null?
                        new StringBuffer(): new StringBuffer(previousOnMouseOver);
                StringBuffer mouseOutBuffer = previousOnMouseOut == null?
                        new StringBuffer(): new StringBuffer(previousOnMouseOut);
                final HoverStylePropertyIteratee iteratee =
                        new HoverStylePropertyIteratee(mouseOverBuffer,
                                mouseOutBuffer);
                hoverProperties.iteratePropertyValues(iteratee);
                // emulate onmouseover styles (those when hovering).
                element.setAttribute(ON_MOUSE_OVER, mouseOverBuffer.toString());
                // emulate onmouseout styles (those when not hovering).
                element.setAttribute(ON_MOUSE_OUT, mouseOutBuffer.toString());
            }
View Full Code Here

Examples of com.volantis.mcs.themes.MutableStyleProperties

                    null, 0,LengthUnit.PX),
                PropertyStatus.REQUIRED,
                PropertyStatus.REQUIRED,
                PropertyStatus.REQUIRED);

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

        ShorthandAnalyzer analyzer = new BasicShorthandAnalyzer(
                StyleShorthands.BORDER_LEFT, checkerMock, shorthandSetMock);
        analyzer.analyze(TargetEntity.ELEMENT, inputValues, deviceValuesMock);
        analyzer.updateShorthand(outputValues);

        assertTrue("Should be able to use shorthand",
                analyzer.canUseShorthand());

        // red should be the color overide
        // none was specified
        // initial value was got for width as style is none
        assertEquals("Shorthand should match:",
                "border-left:red none 0",
                outputValues.getShorthandValue(
                StyleShorthands.BORDER_LEFT).toString());
    }
View Full Code Here

Examples of com.volantis.mcs.themes.MutableStyleProperties

                BorderWidthKeywords.THICK,
                PropertyStatus.REQUIRED,
                PropertyStatus.REQUIRED,
                PropertyStatus.REQUIRED);

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

        ShorthandAnalyzer analyzer = new BasicShorthandAnalyzer(
                StyleShorthands.BORDER_LEFT, checkerMock, shorthandSetMock);
        analyzer.analyze(TargetEntity.ELEMENT, inputValues, deviceValuesMock);

        assertTrue("Should be able to use shorthand",
                analyzer.canUseShorthand());

        analyzer.updateShorthand(outputValues);

        assertEquals("Shorthand should match:",
                "border-left:red dashed thick !important",
                outputValues.getShorthandValue(
                StyleShorthands.BORDER_LEFT).getStandardCSS());
    }
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.