private float svgLengthInPixels(SVGLength length, UnitProcessor.Context context) { return UnitProcessor.svgToUserSpace(length.getValueAsString(), "px", UnitProcessor.OTHER_LENGTH, context); }
/** * <b>DOM</b>: Implements {@link SVGLength#setValue(float)}. */ public void setValue(float value) throws DOMException { this.value = UnitProcessor.userSpaceToSVG(value, unitType, direction, context); reset(); }
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");
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");
/** * Returns the specified value with the specified direction in * objectBoundingBox units. * * @param s the value * @param attr the attribute name that represents the value * @param d the direction of the value * @param ctx the context used to resolve relative value */ public static float svgToObjectBoundingBox(String s, String attr, short d, Context ctx) { try { return org.apache.batik.parser.UnitProcessor. svgToObjectBoundingBox(s, attr, d, ctx); } catch (ParseException pEx ) { throw new BridgeException (getBridgeContext(ctx), ctx.getElement(), pEx, ErrorConstants.ERR_ATTRIBUTE_VALUE_MALFORMED, new Object[] {attr, s, pEx }); } }
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");
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");
/** * Returns the specified value with the specified direction in * objectBoundingBox units. * * @param s the value * @param attr the attribute name that represents the value * @param d the direction of the value * @param ctx the context used to resolve relative value */ public static float svgToObjectBoundingBox(String s, String attr, short d, Context ctx) { try { return org.apache.batik.parser.UnitProcessor. svgToObjectBoundingBox(s, attr, d, ctx); } catch (ParseException pEx ) { throw new BridgeException (getBridgeContext(ctx), ctx.getElement(), pEx, ErrorConstants.ERR_ATTRIBUTE_VALUE_MALFORMED, new Object[] {attr, s, pEx }); } }
return svgToUserSpace(value, type, d, ctx); default: throw new IllegalArgumentException("Length has unknown type");
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");
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");
/** * Returns the specified value with the specified direction in * objectBoundingBox units. * * @param s the value * @param attr the attribute name that represents the value * @param d the direction of the value * @param ctx the context used to resolve relative value */ public static float svgToObjectBoundingBox(String s, String attr, short d, Context ctx) { try { return org.apache.batik.parser.UnitProcessor. svgToObjectBoundingBox(s, attr, d, ctx); } catch (ParseException pEx ) { throw new BridgeException (getBridgeContext(ctx), ctx.getElement(), pEx, ErrorConstants.ERR_ATTRIBUTE_VALUE_MALFORMED, new Object[] {attr, s, pEx }); } }
/** * <b>DOM</b>: Implements {@link SVGLength#setValue(float)}. */ public void setValue(float value) throws DOMException { this.value = UnitProcessor.userSpaceToSVG(value, unitType, direction, context); reset(); }
return svgToUserSpace(value, type, d, ctx); default: throw new IllegalArgumentException("Length has unknown type");
/** * Returns the specified value with the specified direction in * objectBoundingBox units. * * @param s the value * @param attr the attribute name that represents the value * @param d the direction of the value * @param ctx the context used to resolve relative value */ public static float svgToObjectBoundingBox(String s, String attr, short d, Context ctx) throws ParseException { LengthParser lengthParser = new LengthParser(); UnitResolver ur = new UnitResolver(); lengthParser.setLengthHandler(ur); lengthParser.parse(s); return svgToObjectBoundingBox(ur.value, ur.unit, d, ctx); }
/** * <b>DOM</b>: Implements {@link SVGLength#setValue(float)}. */ public void setValue(float value) throws DOMException { this.value = UnitProcessor.userSpaceToSVG(value, unitType, direction, context); reset(); }
return svgToUserSpace(value, type, d, ctx); default: throw new IllegalArgumentException("Length has unknown type");
/** * Returns the specified value with the specified direction in * objectBoundingBox units. * * @param s the value * @param attr the attribute name that represents the value * @param d the direction of the value * @param ctx the context used to resolve relative value */ public static float svgToObjectBoundingBox(String s, String attr, short d, Context ctx) throws ParseException { LengthParser lengthParser = new LengthParser(); UnitResolver ur = new UnitResolver(); lengthParser.setLengthHandler(ur); lengthParser.parse(s); return svgToObjectBoundingBox(ur.value, ur.unit, d, ctx); }
/** * <b>DOM</b>: Implements {@link SVGLength#getValue()}. */ public float getValue() { revalidate(); try { return UnitProcessor.svgToUserSpace(value, unitType, direction, context); } catch (IllegalArgumentException ex) { // XXX Should we throw an exception here when the length // type is unknown? return 0f; } }
/** * Returns the specified value with the specified direction in * objectBoundingBox units. * * @param s the value * @param attr the attribute name that represents the value * @param d the direction of the value * @param ctx the context used to resolve relative value */ public static float svgToObjectBoundingBox(String s, String attr, short d, Context ctx) throws ParseException { LengthParser lengthParser = new LengthParser(); UnitResolver ur = new UnitResolver(); lengthParser.setLengthHandler(ur); lengthParser.parse(s); return svgToObjectBoundingBox(ur.value, ur.unit, d, ctx); }