本文整理汇总了Java中org.w3c.dom.svg.SVGLength.SVG_LENGTHTYPE_NUMBER属性的典型用法代码示例。如果您正苦于以下问题:Java SVGLength.SVG_LENGTHTYPE_NUMBER属性的具体用法?Java SVGLength.SVG_LENGTHTYPE_NUMBER怎么用?Java SVGLength.SVG_LENGTHTYPE_NUMBER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.w3c.dom.svg.SVGLength
的用法示例。
在下文中一共展示了SVGLength.SVG_LENGTHTYPE_NUMBER属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: svgToObjectBoundingBox
/**
* 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");
}
}
示例2: svgToUserSpace
/**
* 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");
}
}
示例3: userSpaceToSVG
/**
* 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");
}
}
示例4: AbstractSVGLength
/**
* Creates a new AbstractSVGLength.
*/
public AbstractSVGLength(short direction) {
context = new DefaultContext();
this.direction = direction;
this.value = 0.0f;
this.unitType = SVGLength.SVG_LENGTHTYPE_NUMBER;
}
示例5: compatibleTypes
/**
* 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;
}
示例6: startLength
/**
* Implements {@link LengthHandler#startLength()}.
*/
public void startLength() throws ParseException {
currentUnit = SVGLength.SVG_LENGTHTYPE_NUMBER;
}
示例7: startLength
public void startLength() throws ParseException {
type = SVGLength.SVG_LENGTHTYPE_NUMBER;
}
示例8: startLength
/**
* Implements {@link LengthListHandler#startLength()}.
*/
public void startLength() throws ParseException {
currentType = SVGLength.SVG_LENGTHTYPE_NUMBER;
currentValue = 0.0f;
}
示例9: getZeroValue
/**
* Returns a zero value of this AnimatableValue's type.
*/
public AnimatableValue getZeroValue() {
return new AnimatableLengthOrIdentValue
(target, SVGLength.SVG_LENGTHTYPE_NUMBER, 0f,
percentageInterpretation);
}
示例10: interpolate
/**
* Performs interpolation to the given value.
*/
public AnimatableValue interpolate(AnimatableValue result,
AnimatableValue to,
float interpolation,
AnimatableValue accumulation,
int multiplier) {
AnimatableLengthValue res;
if (result == null) {
res = new AnimatableLengthValue(target);
} else {
res = (AnimatableLengthValue) result;
}
short oldLengthType = res.lengthType;
float oldLengthValue = res.lengthValue;
short oldPercentageInterpretation = res.percentageInterpretation;
res.lengthType = lengthType;
res.lengthValue = lengthValue;
res.percentageInterpretation = percentageInterpretation;
if (to != null) {
AnimatableLengthValue toLength = (AnimatableLengthValue) to;
float toValue;
if (!compatibleTypes
(res.lengthType, res.percentageInterpretation,
toLength.lengthType, toLength.percentageInterpretation)) {
res.lengthValue = target.svgToUserSpace
(res.lengthValue, res.lengthType,
res.percentageInterpretation);
res.lengthType = SVGLength.SVG_LENGTHTYPE_NUMBER;
toValue = toLength.target.svgToUserSpace
(toLength.lengthValue, toLength.lengthType,
toLength.percentageInterpretation);
} else {
toValue = toLength.lengthValue;
}
res.lengthValue += interpolation * (toValue - res.lengthValue);
}
if (accumulation != null) {
AnimatableLengthValue accLength = (AnimatableLengthValue) accumulation;
float accValue;
if (!compatibleTypes
(res.lengthType, res.percentageInterpretation,
accLength.lengthType,
accLength.percentageInterpretation)) {
res.lengthValue = target.svgToUserSpace
(res.lengthValue, res.lengthType,
res.percentageInterpretation);
res.lengthType = SVGLength.SVG_LENGTHTYPE_NUMBER;
accValue = accLength.target.svgToUserSpace
(accLength.lengthValue, accLength.lengthType,
accLength.percentageInterpretation);
} else {
accValue = accLength.lengthValue;
}
res.lengthValue += multiplier * accValue;
}
if (oldPercentageInterpretation != res.percentageInterpretation
|| oldLengthType != res.lengthType
|| oldLengthValue != res.lengthValue) {
res.hasChanged = true;
}
return res;
}
示例11: getZeroValue
/**
* Returns a zero value of this AnimatableValue's type.
*/
public AnimatableValue getZeroValue() {
return new AnimatableLengthValue
(target, SVGLength.SVG_LENGTHTYPE_NUMBER, 0f,
percentageInterpretation);
}