Package com.volantis.mcs.themes

Examples of com.volantis.mcs.themes.StyleLength


        StyleEmulationPropertyRenderer borderLeftWidthRenderer =
                  new StyleEmulationElementAppendAttributeRenderer(
                        new String[] {"td"}, "style",
                        new CSSBorderWidthPropertyRenderer("border-left-width"));

        StyleLength borderWidthStyle = StyleValueFactory.getDefaultInstance()
                .getLength(null, 15, LengthUnit.PX);


        borderLeftWidthRenderer.apply(tdElement, borderWidthStyle);
View Full Code Here


        Element td = domFactory.createElement();
        td.setName("td");
        table.addTail(td);

        StyleLength length = StyleValueFactory.getDefaultInstance().getLength(
            null, 5.0, LengthUnit.PX);

        renderer.apply(td, length);

        assertEquals("Cell padding should have been added to the table",
View Full Code Here

    protected static String getStyleValueAsString(StyleValue styleValue) {
        String value = null;

        if (styleValue != null) {
            if (styleValue instanceof StyleLength) {
                StyleLength length = (StyleLength) styleValue;
                if (length.getUnit() == LengthUnit.PX) {
                    value = length.getPixelsAsString();
                }
            } else if (styleValue instanceof StylePercentage) {
                return styleValue.getStandardCSS();
            } else {
                throw new IllegalArgumentException(
View Full Code Here

    private static int getStyleValueAsInt(StyleValue styleValue)
            throws NumberFormatException{

        int i = Integer.MIN_VALUE;
        if (styleValue instanceof StyleLength) {
            StyleLength length = (StyleLength) styleValue;
            if (length.getUnit() == LengthUnit.PX) {
                i = (int) length.getNumber();
            }
        }
        return i;
    }
View Full Code Here

        //   Test when setting attribute values
        // ===================================================================
        checkCanOptimizeWithParticularAttributeValues(BORDER, "0", "10", INNER);
        checkCanOptimizeWithParticularAttributeValues(BORDER, "0", "10", INNER);

        StyleLength length0 =
            STYLE_VALUE_FACTORY.getLength(null, 0, LengthUnit.PX);
        StyleLength length10 =
            STYLE_VALUE_FACTORY.getLength(null, 10, LengthUnit.PX);

        // ===================================================================
        //   Test when setting Styles values
        // ===================================================================
View Full Code Here

        StyleValue styleValue = getStyleValue(StylePropertyDetails.WIDTH);
       
        if (styleValue != null) {
            if (styleValue instanceof StyleLength) {
               
                StyleLength styleInteger = (StyleLength) styleValue;
                if (styleInteger.getUnit() == LengthUnit.PX) {
                    width = (int)styleInteger.getNumber();
                }
            }
        }
        return width;    
    }
View Full Code Here

        //  Case 1. A 'normal' keyword, which means default of 6em/s
        //  Case 2. A length value, which indicates speed per second
        //  Case 3. A fraction value, as length per time.
        if (styleValue instanceof StyleLength) {
            // Case 2.
            StyleLength styleLength = (StyleLength) styleValue;
           
            if (styleLength.getUnit() == LengthUnit.EM) {
                speed = styleLength.getNumber();
            }
        } else if (styleValue instanceof StyleFraction) {
            // Case 3.
            StyleFraction styleFraction = (StyleFraction) styleValue;
           
            StyleValue styleNumerator = styleFraction.getNumerator();
            StyleValue styleDenominator = styleFraction.getDenominator();
           
            if ((styleNumerator instanceof StyleLength) &&
                    (styleDenominator instanceof StyleTime)) {
                StyleLength styleLength = (StyleLength) styleNumerator;
                StyleTime styleTime = (StyleTime) styleDenominator;

                // Convert time to seconds.
                double timeInSeconds = timeConverter.convert(styleTime.getNumber(), styleTime.getUnit(), TimeUnit.S);

                // If conversion succeded...
                if (!Double.isNaN(timeInSeconds)) {
                    // Return speed in em/sec.
                    if (styleLength.getUnit() == LengthUnit.EM) {
                        speed = styleLength.getNumber() / timeInSeconds;
                    }
                }
            }
        }
View Full Code Here

    /**
     * Tests the values rendered for  a number and Top value is correct.
     */
    public void testRenderNumberTopValue() throws Exception {
        StyleLength styleValueXPosition = styleValueFactory.getLength(null, 20.0, LengthUnit.PX);

        StyleKeyword styleValueYPosition = BackgroundYPositionKeywords.TOP;
        stylePairTest(styleValueXPosition, styleValueYPosition, "20px 0%");
    }
View Full Code Here

     * Tests the values rendered for Center and number value is correct.
     */
    public void testRenderCenterNumberValue() throws Exception {
        StyleKeyword styleValueXPosition = BackgroundXPositionKeywords.CENTER;

        StyleLength styleValueYPosition = styleValueFactory.getLength(null, 32.1, LengthUnit.EM);
        stylePairTest(styleValueXPosition, styleValueYPosition, "50% 32.1em");
    }
View Full Code Here

     * Tests the values rendered for Right and number value is correct.
     */
    public void testRenderRightNumberValue() throws Exception {
        StyleKeyword styleValueXPosition = BackgroundXPositionKeywords.RIGHT;

        StyleLength styleValueYPosition = styleValueFactory.getLength(null, 18.1, LengthUnit.MM);
        stylePairTest(styleValueXPosition, styleValueYPosition, "100% 18.1mm");
    }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.themes.StyleLength

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.