Package org.newdawn.slick.svg

Examples of org.newdawn.slick.svg.ParsingException


        float y = Float.parseFloat(tokenY);
       
        poly.addPoint(x,y);
        count++;
      } catch (NumberFormatException e) {
        throw new ParsingException(element.getAttribute("id"), "Invalid token in points list", e);
      }
    }
   
    return count;
  }
View Full Code Here


    }
   
    try {
      return Float.parseFloat(cx);
    } catch (NumberFormatException e) {
      throw new ParsingException(element, "Invalid value for: "+attr, e);
    }
  }
View Full Code Here

   
    for (int i=0;i<patterns.getLength();i++) {
      Element pattern = (Element) patterns.item(i);
      NodeList list = pattern.getElementsByTagName("image");
      if (list.getLength() == 0) {
        throw new ParsingException(pattern, "No image specified for pattern");
      }
      Element image = (Element) list.item(0);
     
      String patternName = pattern.getAttribute("id");
      String ref = image.getAttributeNS(Util.XLINK, "href");
      diagram.addPatternDef(patternName, ref);
    }
   
    NodeList linear = element.getElementsByTagName("linearGradient");
    ArrayList toResolve = new ArrayList();
   
    for (int i=0;i<linear.getLength();i++) {
      Element lin = (Element) linear.item(i);
      String name = lin.getAttribute("id");
      Gradient gradient = new Gradient(name, false);

      gradient.setTransform(Util.getTransform(lin, "gradientTransform"));
     
      if (stringLength(lin.getAttribute("x1")) > 0) {
        gradient.setX1(Float.parseFloat(lin.getAttribute("x1")));
      }
      if (stringLength(lin.getAttribute("x2")) > 0) {
        gradient.setX2(Float.parseFloat(lin.getAttribute("x2")));
      }
      if (stringLength(lin.getAttribute("y1")) > 0) {
        gradient.setY1(Float.parseFloat(lin.getAttribute("y1")));
      }
      if (stringLength(lin.getAttribute("y2")) > 0) {
        gradient.setY2(Float.parseFloat(lin.getAttribute("y2")));
      }
     
      String ref = lin.getAttributeNS("http://www.w3.org/1999/xlink", "href");
      if (stringLength(ref) > 0) {
        Gradient grad = diagram.getGradient(ref.substring(1));
        if (grad == null) {
          throw new ParsingException(lin, "Can't find referenced gradient: "+ref);
        }
       
        gradient.reference(ref.substring(1));
        toResolve.add(gradient);
      } else {
        NodeList steps = lin.getElementsByTagName("stop");
        for (int j=0;j<steps.getLength();j++) {
          Element s = (Element) steps.item(j);
          float offset = Float.parseFloat(s.getAttribute("offset"));
   
          String colInt = Util.extractStyle(s.getAttribute("style"),"stop-color");
          String opaInt = Util.extractStyle(s.getAttribute("style"),"stop-opacity");
         
          int col = Integer.parseInt(colInt.substring(1), 16);
          Color stopColor = new Color(col);
          stopColor.a = Float.parseFloat(opaInt);
         
          gradient.addStep(offset, stopColor);
        }
       
        gradient.getImage();
      }
     
      diagram.addGradient(name, gradient);
    }
   
    NodeList radial = element.getElementsByTagName("radialGradient");
    for (int i=0;i<radial.getLength();i++) {
      Element rad = (Element) radial.item(i);
      String name = rad.getAttribute("id");
      Gradient gradient = new Gradient(name, true);
     
      gradient.setTransform(Util.getTransform(rad, "gradientTransform"));
     
      if (stringLength(rad.getAttribute("cx")) > 0) {
        gradient.setX1(Float.parseFloat(rad.getAttribute("cx")));
      }
      if (stringLength(rad.getAttribute("cy")) > 0) {
        gradient.setY1(Float.parseFloat(rad.getAttribute("cy")));
      }
      if (stringLength(rad.getAttribute("fx")) > 0) {
        gradient.setX2(Float.parseFloat(rad.getAttribute("fx")));
      }
      if (stringLength(rad.getAttribute("fy")) > 0) {
        gradient.setY2(Float.parseFloat(rad.getAttribute("fy")));
      }
      if (stringLength(rad.getAttribute("r")) > 0) {
        gradient.setR(Float.parseFloat(rad.getAttribute("r")));
      }
     
      String ref = rad.getAttributeNS("http://www.w3.org/1999/xlink", "href");
      if (stringLength(ref) > 0) {
        Gradient grad = diagram.getGradient(ref.substring(1));
        if (grad == null) {
          throw new ParsingException(rad, "Can't find referenced gradient: "+ref);
        }

        gradient.reference(ref.substring(1));
        toResolve.add(gradient);
      } else {
View Full Code Here

        float y = Float.parseFloat(tokenY);
       
        poly.addPoint(x,y);
        count++;
      } catch (NumberFormatException e) {
        throw new ParsingException(element.getAttribute("id"), "Invalid token in points list", e);
      }
    }
   
    poly.setClosed(closed);
    return count;
View Full Code Here

        float y = Float.parseFloat(tokenY);
       
        poly.addPoint(x,y);
        count++;
      } catch (NumberFormatException e) {
        throw new ParsingException(element.getAttribute("id"), "Invalid token in points list", e);
      }
    }
   
    return count;
  }
View Full Code Here

        float y = Float.parseFloat(tokenY);
       
        poly.addPoint(x,y);
        count++;
      } catch (NumberFormatException e) {
        throw new ParsingException(element.getAttribute("id"), "Invalid token in points list", e);
      }
    }
   
    poly.setClosed(closed);
    return count;
View Full Code Here

    }
   
    try {
      return Float.parseFloat(cx);
    } catch (NumberFormatException e) {
      throw new ParsingException(element, "Invalid value for: "+attr, e);
    }
  }
View Full Code Here

        float y = Float.parseFloat(tokenY);
       
        poly.addPoint(x,y);
        count++;
      } catch (NumberFormatException e) {
        throw new ParsingException(element.getAttribute("id"), "Invalid token in points list", e);
      }
    }
   
    return count;
  }
View Full Code Here

    String ref = element.getAttributeNS("http://www.w3.org/1999/xlink", "href");
    String href = Util.getAsReference(ref);
   
    Figure referenced = diagram.getFigureByID(href);
    if (referenced == null) {
      throw new ParsingException(element, "Unable to locate referenced element: "+href);
    }
   
    Transform local = Util.getTransform(element);
    Transform trans = local.concatenate(referenced.getTransform());
   
View Full Code Here

          float y = Float.parseFloat(tokens.nextToken());
          path.curveTo(x,y,cx1,cy1,cx2,cy2);
          continue;
        }
      } catch (NumberFormatException e) {
        throw new ParsingException(element.getAttribute("id"), "Invalid token in points list", e);
      }
    }
   
    if (!reasonToBePath) {
      return null;
View Full Code Here

TOP

Related Classes of org.newdawn.slick.svg.ParsingException

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.