Package org.apache.batik.parser

Examples of org.apache.batik.parser.LengthParser


    public static float svgToObjectBoundingBox(String s,
                                               String attr,
                                               short d,
                                               Context ctx) {
        try {
            LengthParser lengthParser = new LengthParser();
            UnitResolver ur = new UnitResolver();
            lengthParser.setLengthHandler(ur);
            lengthParser.parse(s);
            return svgToObjectBoundingBox(ur.value, ur.unit, d, ctx);
        } catch (ParseException ex) {
            throw new BridgeException(ctx.getElement(),
                                   ErrorConstants.ERR_ATTRIBUTE_VALUE_MALFORMED,
                                      new Object[] {attr, s, ex});
View Full Code Here


    public static float svgToUserSpace(String s,
                                       String attr,
                                       short d,
                                       Context ctx) {
        try {
            LengthParser lengthParser = new LengthParser();
            UnitResolver ur = new UnitResolver();
            lengthParser.setLengthHandler(ur);
            lengthParser.parse(s);
            return svgToUserSpace(ur.value, ur.unit, d, ctx);
        } catch (ParseException ex) {
            throw new BridgeException(ctx.getElement(),
                                   ErrorConstants.ERR_ATTRIBUTE_VALUE_MALFORMED,
                                      new Object[] {attr, s, ex});
View Full Code Here

     * of the parsing of this value.
     * @param s String representation of a SVGlength.
     */
    protected void parse(String s) {
        try {
            LengthParser lengthParser = new LengthParser();
            UnitProcessor.UnitResolver ur =
                new UnitProcessor.UnitResolver();
            lengthParser.setLengthHandler(ur);
            lengthParser.parse(s);
            unitType = ur.unit;
            value = ur.value;
        } catch (ParseException e) {
            unitType = SVG_LENGTHTYPE_UNKNOWN;
            value = 0;
View Full Code Here

    public static float svgToUserSpace(String value, SVGElement e, short d,
                                       Context c) {
        if (value.length() == 0) {
            return 0;
        }
        LengthParser p = new LengthParser();
        UnitResolver ur = new UnitResolver();
        p.setLengthHandler(ur);
        p.parse(new StringReader(value));
        return svgToUserSpace(ur.unit, ur.value, e, d, c);
    }
View Full Code Here

        SVGSVGElement svg = element.getOwnerSVGElement();
        if (svg == null) {
            return (float)context.getViewportWidth(element);
        }
        String s = svg.getAttributeNS(null, SVG_WIDTH_ATTRIBUTE);
        LengthParser p = new LengthParser();
        UnitProcessor.UnitResolver ur = new UnitProcessor.UnitResolver();
        p.setLengthHandler(ur);
        p.parse(new StringReader(s));
        return UnitProcessor.svgToUserSpace(ur.unit,
                                            ur.value,
                                            svg,
                                            UnitProcessor.HORIZONTAL_LENGTH,
                                            this);
View Full Code Here

        SVGSVGElement svg = element.getOwnerSVGElement();
        if (svg == null) {
            return (float)context.getViewportHeight(element);
        }
        String s = svg.getAttributeNS(null, SVG_HEIGHT_ATTRIBUTE);
        LengthParser p = new LengthParser();
        UnitProcessor.UnitResolver ur = new UnitProcessor.UnitResolver();
        p.setLengthHandler(ur);
        p.parse(new StringReader(s));
        return UnitProcessor.svgToUserSpace(ur.unit,
                                            ur.value,
                                            svg,
                                            UnitProcessor.VERTICAL_LENGTH,
                                            this);
View Full Code Here

    public static float svgToObjectBoundingBox(String s,
                                               String attr,
                                               short d,
                                               Context ctx) {
        try {
            LengthParser lengthParser = new LengthParser();
            UnitResolver ur = new UnitResolver();
            lengthParser.setLengthHandler(ur);
            lengthParser.parse(new StringReader(s));
            return svgToObjectBoundingBox(ur.value, ur.unit, d, ctx);
        } catch (ParseException ex) {
            throw new BridgeException(ctx.getElement(),
                                   ErrorConstants.ERR_ATTRIBUTE_VALUE_MALFORMED,
                                      new Object[] {attr, s, ex});
View Full Code Here

    public static float svgToUserSpace(String s,
                                       String attr,
                                       short d,
                                       Context ctx) {
        try {
            LengthParser lengthParser = new LengthParser();
            UnitResolver ur = new UnitResolver();
            lengthParser.setLengthHandler(ur);
            lengthParser.parse(new StringReader(s));
            return svgToUserSpace(ur.value, ur.unit, d, ctx);
        } catch (ParseException ex) {
            throw new BridgeException(ctx.getElement(),
                                   ErrorConstants.ERR_ATTRIBUTE_VALUE_MALFORMED,
                                      new Object[] {attr, s, ex});
View Full Code Here

    /**
     * Parses the given length representation.
     */
    public void parseLength(String text) {
  LengthParser lp = new LengthParser();
  lp.setLengthHandler(this);
  try {
      lp.parse(new StringReader(text));
  } catch (ParseException e) {
      throw new DOMException(DOMException.SYNTAX_ERR, e.getMessage());
  }
    }
View Full Code Here

     * of the parsing of this value.
     * @param s String representation of a SVGlength.
     */
    protected void parse(String s){
        try {
            LengthParser lengthParser = new LengthParser();
            UnitProcessor.UnitResolver ur =
                new UnitProcessor.UnitResolver();
            lengthParser.setLengthHandler(ur);
            lengthParser.parse(s);
            unitType = ur.unit;
            value = ur.value;
        } catch (ParseException e) {
            unitType = SVG_LENGTHTYPE_UNKNOWN;
            value = 0;
View Full Code Here

TOP

Related Classes of org.apache.batik.parser.LengthParser

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.