Package org.newdawn.slick.svg

Examples of org.newdawn.slick.svg.Gradient


    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));
View Full Code Here


    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.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.reference(ref.substring(1));
        toResolve.add(gradient);
      } else {
        NodeList steps = rad.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);
    }
   
View Full Code Here

TOP

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

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.