• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SVGLength类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.w3c.dom.svg.SVGLength的典型用法代码示例。如果您正苦于以下问题:Java SVGLength类的具体用法?Java SVGLength怎么用?Java SVGLength使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: getUnderlyingValue

import org.w3c.dom.svg.SVGLength; //导入依赖的package包/类
/**
 * Returns the base value of the attribute as an {@link AnimatableValue}.
 */
public AnimatableValue getUnderlyingValue(AnimationTarget target) {
    SVGLengthList ll = getBaseVal();
    int n = ll.getNumberOfItems();
    short[] types = new short[n];
    float[] values = new float[n];
    for (int i = 0; i < n; i++) {
        SVGLength l = ll.getItem(i);
        types[i] = l.getUnitType();
        values[i] = l.getValueInSpecifiedUnits();
    }
    return new AnimatableLengthListValue
        (target, types, values,
         target.getPercentageInterpretation
             (getNamespaceURI(), getLocalName(), false));
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:19,代码来源:SVGOMAnimatedLengthList.java


示例2: svgToObjectBoundingBox

import org.w3c.dom.svg.SVGLength; //导入依赖的package包/类
/**
 * Returns the specified value with the specified direction in
 * objectBoundingBox units.
 *
 * @param value the value
 * @param type the type of the value
 * @param d the direction of the value
 * @param ctx the context used to resolve relative value
 */
public static float svgToObjectBoundingBox(float value,
                                           short type,
                                           short d,
                                           Context ctx) {
    switch (type) {
    case SVGLength.SVG_LENGTHTYPE_NUMBER:
        // as is
        return value;
    case SVGLength.SVG_LENGTHTYPE_PERCENTAGE:
        // If a percentage value is used, it is converted to a
        // 'bounding box' space coordinate by division by 100
        return value / 100f;
    case SVGLength.SVG_LENGTHTYPE_PX:
    case SVGLength.SVG_LENGTHTYPE_MM:
    case SVGLength.SVG_LENGTHTYPE_CM:
    case SVGLength.SVG_LENGTHTYPE_IN:
    case SVGLength.SVG_LENGTHTYPE_PT:
    case SVGLength.SVG_LENGTHTYPE_PC:
    case SVGLength.SVG_LENGTHTYPE_EMS:
    case SVGLength.SVG_LENGTHTYPE_EXS:
        // <!> FIXME: resolve units in userSpace but consider them
        // in the objectBoundingBox coordinate system
        return svgToUserSpace(value, type, d, ctx);
    default:
        throw new IllegalArgumentException("Length has unknown type");
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:37,代码来源:UnitProcessor.java


示例3: svgToUserSpace

import org.w3c.dom.svg.SVGLength; //导入依赖的package包/类
/**
 * Converts the specified value of the specified type and
 * direction to user units.
 *
 * @param v the value to convert
 * @param type the type of the value
 * @param d HORIZONTAL_LENGTH, VERTICAL_LENGTH, or OTHER_LENGTH
 * @param ctx the context used to resolve relative value
 */
public static float svgToUserSpace(float v,
                                   short type,
                                   short d,
                                   Context ctx) {
    switch (type) {
    case SVGLength.SVG_LENGTHTYPE_NUMBER:
    case SVGLength.SVG_LENGTHTYPE_PX:
        return v;
    case SVGLength.SVG_LENGTHTYPE_MM:
        return (v / ctx.getPixelUnitToMillimeter());
    case SVGLength.SVG_LENGTHTYPE_CM:
        return (v * 10f / ctx.getPixelUnitToMillimeter());
    case SVGLength.SVG_LENGTHTYPE_IN:
        return (v * 25.4f / ctx.getPixelUnitToMillimeter());
    case SVGLength.SVG_LENGTHTYPE_PT:
        return (v * 25.4f / (72f * ctx.getPixelUnitToMillimeter()));
    case SVGLength.SVG_LENGTHTYPE_PC:
        return (v * 25.4f / (6f * ctx.getPixelUnitToMillimeter()));
    case SVGLength.SVG_LENGTHTYPE_EMS:
        return emsToPixels(v, d, ctx);
    case SVGLength.SVG_LENGTHTYPE_EXS:
        return exsToPixels(v, d, ctx);
    case SVGLength.SVG_LENGTHTYPE_PERCENTAGE:
        return percentagesToPixels(v, d, ctx);
    default:
        throw new IllegalArgumentException("Length has unknown type");
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:38,代码来源:UnitProcessor.java


示例4: userSpaceToSVG

import org.w3c.dom.svg.SVGLength; //导入依赖的package包/类
/**
 * Converts the specified value of the specified type and
 * direction to SVG units.
 *
 * @param v the value to convert
 * @param type the type of the value
 * @param d HORIZONTAL_LENGTH, VERTICAL_LENGTH, or OTHER_LENGTH
 * @param ctx the context used to resolve relative value
 */
public static float userSpaceToSVG(float v,
                                   short type,
                                   short d,
                                   Context ctx) {
    switch (type) {
    case SVGLength.SVG_LENGTHTYPE_NUMBER:
    case SVGLength.SVG_LENGTHTYPE_PX:
        return v;
    case SVGLength.SVG_LENGTHTYPE_MM:
        return (v * ctx.getPixelUnitToMillimeter());
    case SVGLength.SVG_LENGTHTYPE_CM:
        return (v * ctx.getPixelUnitToMillimeter() / 10f);
    case SVGLength.SVG_LENGTHTYPE_IN:
        return (v * ctx.getPixelUnitToMillimeter() / 25.4f);
    case SVGLength.SVG_LENGTHTYPE_PT:
        return (v * (72f * ctx.getPixelUnitToMillimeter()) / 25.4f);
    case SVGLength.SVG_LENGTHTYPE_PC:
        return (v * (6f * ctx.getPixelUnitToMillimeter()) / 25.4f);
    case SVGLength.SVG_LENGTHTYPE_EMS:
        return pixelsToEms(v, d, ctx);
    case SVGLength.SVG_LENGTHTYPE_EXS:
        return pixelsToExs(v, d, ctx);
    case SVGLength.SVG_LENGTHTYPE_PERCENTAGE:
        return pixelsToPercentages(v, d, ctx);
    default:
        throw new IllegalArgumentException("Length has unknown type");
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:38,代码来源:UnitProcessor.java


示例5: AbstractSVGLength

import org.w3c.dom.svg.SVGLength; //导入依赖的package包/类
/**
 * Creates a new AbstractSVGLength.
 */
public AbstractSVGLength(short direction) {
    context = new DefaultContext();
    this.direction = direction;
    this.value = 0.0f;
    this.unitType = SVGLength.SVG_LENGTHTYPE_NUMBER;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:10,代码来源:AbstractSVGLength.java


示例6: getValueAsString

import org.w3c.dom.svg.SVGLength; //导入依赖的package包/类
/**
 * <b>DOM</b>: Implements {@link SVGLength#getValueAsString()}.
 */
public String getValueAsString() {
    revalidate();
    if (unitType == SVGLength.SVG_LENGTHTYPE_UNKNOWN) {
        return "";
    }
    return Float.toString(value) + UNITS[unitType];
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:11,代码来源:AbstractSVGLength.java


示例7: getItem

import org.w3c.dom.svg.SVGLength; //导入依赖的package包/类
/**
 * <b>DOM</b>: Implements {@link SVGLengthList#getItem(int)}.
 */
public SVGLength getItem(int index) throws DOMException {
    if (hasAnimVal) {
        return super.getItem(index);
    }
    return getBaseVal().getItem(index);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:10,代码来源:SVGOMAnimatedLengthList.java


示例8: initialize

import org.w3c.dom.svg.SVGLength; //导入依赖的package包/类
/**
 * <b>DOM</b>: Implements {@link SVGLengthList#initialize(SVGLength)}.
 */
public SVGLength initialize(SVGLength newItem)
        throws DOMException, SVGException {
    throw element.createDOMException
        (DOMException.NO_MODIFICATION_ALLOWED_ERR,
         "readonly.length.list", null);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:10,代码来源:SVGOMAnimatedLengthList.java


示例9: insertItemBefore

import org.w3c.dom.svg.SVGLength; //导入依赖的package包/类
/**
 * <b>DOM</b>: Implements {@link
 * SVGLengthList#insertItemBefore(SVGLength, int)}.
 */
public SVGLength insertItemBefore(SVGLength newItem, int index)
        throws DOMException, SVGException {
    throw element.createDOMException
        (DOMException.NO_MODIFICATION_ALLOWED_ERR,
         "readonly.length.list", null);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:11,代码来源:SVGOMAnimatedLengthList.java


示例10: replaceItem

import org.w3c.dom.svg.SVGLength; //导入依赖的package包/类
/**
 * <b>DOM</b>: Implements {@link
 * SVGLengthList#replaceItem(SVGLength, int)}.
 */
public SVGLength replaceItem(SVGLength newItem, int index)
        throws DOMException, SVGException {
    throw element.createDOMException
        (DOMException.NO_MODIFICATION_ALLOWED_ERR,
         "readonly.length.list", null);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:11,代码来源:SVGOMAnimatedLengthList.java


示例11: checkItemType

import org.w3c.dom.svg.SVGLength; //导入依赖的package包/类
/**
 * Asserts that the given item is an {@link SVGLengthList}.
 */
protected void checkItemType(Object newItem) throws SVGException {
    if (!(newItem instanceof SVGLength)) {
        createSVGException(SVGException.SVG_WRONG_TYPE_ERR,
                           "expected.length", null);
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:10,代码来源:AbstractSVGLengthList.java


示例12: getBaseVal

import org.w3c.dom.svg.SVGLength; //导入依赖的package包/类
/**
 * <b>DOM</b>: Implements {@link SVGAnimatedLength#getBaseVal()}.
 */
public SVGLength getBaseVal() {
    if (baseVal == null) {
        baseVal = new BaseSVGLength(direction);
    }
    return baseVal;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:10,代码来源:AbstractSVGAnimatedLength.java


示例13: getAnimVal

import org.w3c.dom.svg.SVGLength; //导入依赖的package包/类
/**
 * <b>DOM</b>: Implements {@link SVGAnimatedLength#getAnimVal()}.
 */
public SVGLength getAnimVal() {
    if (animVal == null) {
        animVal = new AnimSVGLength(direction);
    }
    return animVal;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:10,代码来源:AbstractSVGAnimatedLength.java


示例14: getCheckedValue

import org.w3c.dom.svg.SVGLength; //导入依赖的package包/类
/**
 * Gets the current animated length value.  If the attribute is missing
 * or malformed, an exception is thrown.
 */
public float getCheckedValue() {
    if (hasAnimVal) {
        if (animVal == null) {
            animVal = new AnimSVGLength(direction);
        }
        if (nonNegative && animVal.value < 0) {
            throw new LiveAttributeException
                (element, localName,
                 LiveAttributeException.ERR_ATTRIBUTE_NEGATIVE,
                 animVal.getValueAsString());
        }
        return animVal.getValue();
    } else {
        if (baseVal == null) {
            baseVal = new BaseSVGLength(direction);
        }
        baseVal.revalidate();
        if (baseVal.missing) {
            throw new LiveAttributeException
                (element, localName,
                 LiveAttributeException.ERR_ATTRIBUTE_MISSING, null);
        } else if (baseVal.unitType ==
                    SVGLength.SVG_LENGTHTYPE_UNKNOWN) {
            throw new LiveAttributeException
                (element, localName,
                 LiveAttributeException.ERR_ATTRIBUTE_MALFORMED,
                 baseVal.getValueAsString());
        }
        if (nonNegative && baseVal.value < 0) {
            throw new LiveAttributeException
                (element, localName,
                 LiveAttributeException.ERR_ATTRIBUTE_NEGATIVE,
                 baseVal.getValueAsString());
        }
        return baseVal.getValue();
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:42,代码来源:AbstractSVGAnimatedLength.java


示例15: getUnderlyingValue

import org.w3c.dom.svg.SVGLength; //导入依赖的package包/类
/**
 * Returns the base value of the attribute as an {@link AnimatableValue}.
 */
public AnimatableValue getUnderlyingValue(AnimationTarget target) {
    SVGLength base = getBaseVal();
    return new AnimatableLengthValue
        (target, base.getUnitType(), base.getValueInSpecifiedUnits(),
         target.getPercentageInterpretation
             (getNamespaceURI(), getLocalName(), false));
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:11,代码来源:AbstractSVGAnimatedLength.java


示例16: svgToUserSpace

import org.w3c.dom.svg.SVGLength; //导入依赖的package包/类
/**
 * Converts the given SVG length into user units.
 * @param v the SVG length value
 * @param type the SVG length units (one of the
 *             {@link SVGLength}.SVG_LENGTH_* constants)
 * @param pcInterp how to interpretet percentage values (one of the
 *             {@link SVGContext}.PERCENTAGE_* constants)
 * @return the SVG value in user units
 */
public float svgToUserSpace(float v, short type, short pcInterp) {
    if (unitContext == null) {
        unitContext = new UnitContext();
    }
    if (pcInterp == PERCENTAGE_FONT_SIZE
            && type == SVGLength.SVG_LENGTHTYPE_PERCENTAGE) {
        // XXX
        return 0f;
    } else {
        return UnitProcessor.svgToUserSpace(v, type, (short) (3 - pcInterp),
                                            unitContext);
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:23,代码来源:SVGOMElement.java


示例17: compatibleTypes

import org.w3c.dom.svg.SVGLength; //导入依赖的package包/类
/**
 * Determines if two SVG length types are compatible.
 * @param t1 the first SVG length type
 * @param pi1 the first percentage interpretation type
 * @param t2 the second SVG length type
 * @param pi2 the second percentage interpretation type
 */
public static boolean compatibleTypes(short t1, short pi1, short t2,
                                      short pi2) {
    return t1 == t2
        && (t1 != SVGLength.SVG_LENGTHTYPE_PERCENTAGE || pi1 == pi2)
        || t1 == SVGLength.SVG_LENGTHTYPE_NUMBER
            && t2 == SVGLength.SVG_LENGTHTYPE_PX
        || t1 == SVGLength.SVG_LENGTHTYPE_PX
            && t2 == SVGLength.SVG_LENGTHTYPE_NUMBER;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:17,代码来源:AnimatableLengthValue.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java KillableProcess类代码示例发布时间:2022-05-22
下一篇:
Java Timer类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap