当前位置: 首页>>代码示例>>Java>>正文


Java LexicalUnit.SAC_RECT_FUNCTION属性代码示例

本文整理汇总了Java中org.w3c.css.sac.LexicalUnit.SAC_RECT_FUNCTION属性的典型用法代码示例。如果您正苦于以下问题:Java LexicalUnit.SAC_RECT_FUNCTION属性的具体用法?Java LexicalUnit.SAC_RECT_FUNCTION怎么用?Java LexicalUnit.SAC_RECT_FUNCTION使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.w3c.css.sac.LexicalUnit的用法示例。


在下文中一共展示了LexicalUnit.SAC_RECT_FUNCTION属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createValue

/**
 * Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}.
 */
public Value createValue(LexicalUnit lu, CSSEngine engine)
    throws DOMException {
    switch (lu.getLexicalUnitType()) {
    case LexicalUnit.SAC_FUNCTION:
        if (!lu.getFunctionName().equalsIgnoreCase("rect")) {
            break;
        }
    case LexicalUnit.SAC_RECT_FUNCTION:
        lu = lu.getParameters();
        Value top = createRectComponent(lu);
        lu = lu.getNextLexicalUnit();
        if (lu == null ||
            lu.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) {
            throw createMalformedRectDOMException();
        }
        lu = lu.getNextLexicalUnit();
        Value right = createRectComponent(lu);
        lu = lu.getNextLexicalUnit();
        if (lu == null ||
            lu.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) {
            throw createMalformedRectDOMException();
        }
        lu = lu.getNextLexicalUnit();
        Value bottom = createRectComponent(lu);
        lu = lu.getNextLexicalUnit();
        if (lu == null ||
            lu.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) {
            throw createMalformedRectDOMException();
        }
        lu = lu.getNextLexicalUnit();
        Value left = createRectComponent(lu);
        return new RectValue(top, right, bottom, left);
    }
    throw createMalformedRectDOMException();
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:38,代码来源:RectManager.java

示例2: buildString

@Override
public String buildString(BuildStringStrategy strategy) {
    short type = getLexicalUnitType();
    String text = simpleAsString();
    if (text == null) {
        switch (type) {
        case LexicalUnit.SAC_URI:
            text = "url(" + getStringValue() + ")";
            break;
        case LexicalUnit.SAC_RGBCOLOR:
            int[] rgb = getRgb();
            if (rgb != null) {
                text = ColorUtil.rgbToColorString(rgb);
                break;
            }
            // else fall through to the function branch
        case LexicalUnit.SAC_COUNTER_FUNCTION:
        case LexicalUnit.SAC_COUNTERS_FUNCTION:
        case LexicalUnit.SAC_RECT_FUNCTION:
        case LexicalUnit.SAC_FUNCTION:
            if (ColorUtil.isColor(this)) {
                text = ColorUtil.rgbToColorString(ColorUtil
                        .colorToRgb(this));
                break;
            } else if (ColorUtil.isRgba(this) || ColorUtil.isHsla(this)) {
                float alpha = params.get(params.size() - 1)
                        .getContainedValue().getFloatValue();
                rgb = ColorUtil.colorToRgb(this);
                if (alpha == 0.0f && rgb[0] == 0 && rgb[1] == 0
                        && rgb[2] == 0) {
                    text = "transparent";
                    break;
                } else if (alpha == 1.0f) {
                    text = ColorUtil.rgbToColorString(ColorUtil
                            .colorToRgb(this));
                    break;
                } else if (params.size() == 2 || ColorUtil.isHsla(this)) {

                    String alphaText = alpha == 0.0f ? "0"
                            : CSS_FLOAT_FORMAT.format(alpha);
                    text = "rgba(" + rgb[0] + ", " + rgb[1] + ", " + rgb[2]
                            + ", " + alphaText + ")";
                    break;
                }
            }
            text = fname + "(" + params.buildString(strategy) + ")";
            break;
        case LexicalUnit.SAC_IDENT:
            text = getStringValue();
            break;
        case LexicalUnit.SAC_STRING_VALUE:
            // @@SEEME. not exact
            text = "\"" + getStringValue() + "\"";
            break;
        case LexicalUnit.SAC_ATTR:
            text = "attr(" + getStringValue() + ")";
            break;
        case LexicalUnit.SAC_UNICODERANGE:
            text = "@@TODO";
            break;
        case LexicalUnit.SAC_SUB_EXPRESSION:
            text = strategy.build(getParameterList());
            break;
        default:
            text = "@unknown";
            break;
        }
    }
    return text;
}
 
开发者ID:fjalvingh,项目名称:domui,代码行数:70,代码来源:LexicalUnitImpl.java


注:本文中的org.w3c.css.sac.LexicalUnit.SAC_RECT_FUNCTION属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。