Package org.newdawn.slick.geom

Examples of org.newdawn.slick.geom.Transform


  /**
   * @see org.newdawn.slick.svg.inkscape.ElementProcessor#process(org.newdawn.slick.svg.Loader, org.w3c.dom.Element, org.newdawn.slick.svg.Diagram, org.newdawn.slick.geom.Transform)
   */
  public void process(Loader loader, Element element, Diagram diagram, Transform t) throws ParsingException {
    Transform transform = Util.getTransform(element);
      transform = new Transform(t, transform);
   
    float width = Float.parseFloat(element.getAttribute("width"));
    float height = Float.parseFloat(element.getAttribute("height"));
    float x = Float.parseFloat(element.getAttribute("x"));
    float y = Float.parseFloat(element.getAttribute("y"));
View Full Code Here


   * @return The transform to be applied
   */
  static Transform getTransform(Element element, String attribute) {
    String str = element.getAttribute(attribute);
    if (str == null) {
      return new Transform();
    }
   
    if (str.equals("")) {
      return new Transform();
    } else if (str.startsWith("translate")) {
      str = str.substring(0, str.length()-1);
      str = str.substring("translate(".length());
      StringTokenizer tokens = new StringTokenizer(str, ", ");
      float x = Float.parseFloat(tokens.nextToken());
      float y = Float.parseFloat(tokens.nextToken());
     
      return Transform.createTranslateTransform(x,y);
    } else if (str.startsWith("matrix")) {
      float[] pose = new float[6];
      str = str.substring(0, str.length()-1);
      str = str.substring("matrix(".length());
      StringTokenizer tokens = new StringTokenizer(str, ", ");
      float[] tr = new float[6];
      for (int j=0;j<tr.length;j++) {
        tr[j] = Float.parseFloat(tokens.nextToken());
      }
     
      pose[0] = tr[0];
      pose[1] = tr[2];
      pose[2] = tr[4];
      pose[3] = tr[1];
      pose[4] = tr[3];
      pose[5] = tr[5];
     
      return new Transform(pose);
    }
   
    return new Transform();
  }
View Full Code Here

  /**
   * @see org.newdawn.slick.svg.inkscape.ElementProcessor#process(org.newdawn.slick.svg.Loader, org.w3c.dom.Element, org.newdawn.slick.svg.Diagram, org.newdawn.slick.geom.Transform)
   */
  public void process(Loader loader, Element element, Diagram diagram, Transform t) throws ParsingException {
    Transform transform = Util.getTransform(element);
      transform = new Transform(t, transform);
   
    float x1;
    float y1;
    float x2;
    float y2;
   
    if (element.getNodeName().equals("line")) {
      x1 = Float.parseFloat(element.getAttribute("x1"));
      x2 = Float.parseFloat(element.getAttribute("x2"));
      y1 = Float.parseFloat(element.getAttribute("y1"));
      y2 = Float.parseFloat(element.getAttribute("y2"));
    } else {
      String points = element.getAttribute("d");
      StringTokenizer tokens = new StringTokenizer(points, ", ");
      Polygon poly = new Polygon();
      if (processPoly(poly, element, tokens) == 2) {
        x1 = poly.getPoint(0)[0];
        y1 = poly.getPoint(0)[1];
        x2 = poly.getPoint(1)[0];
        y2 = poly.getPoint(1)[1];
      } else {
        return;
      }
    }
   
    float[] in = new float[] {x1,y1,x2,y2};
    float[] out = new float[4];
   
    transform.transform(in,0,out,0,2);
    Line line = new Line(out[0],out[1],out[2],out[3]);
   
    NonGeometricData data = Util.getNonGeometricData(element);
    data.addAttribute("x1",""+x1);
    data.addAttribute("x2",""+x2);
View Full Code Here

 
  /**
   * @see org.newdawn.slick.svg.inkscape.ElementProcessor#process(org.newdawn.slick.svg.Loader, org.w3c.dom.Element, org.newdawn.slick.svg.Diagram, org.newdawn.slick.geom.Transform)
   */
  public void process(Loader loader, Element element, Diagram diagram, Transform t) throws ParsingException {
    Transform transform = Util.getTransform(element);
    transform = new Transform(t, transform);
   
    float x = Util.getFloatAttribute(element,"cx");
    float y = Util.getFloatAttribute(element,"cy");
    float rx = Util.getFloatAttribute(element,"rx");
    float ry = Util.getFloatAttribute(element,"ry");
View Full Code Here

    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());
   
    NonGeometricData data = Util.getNonGeometricData(element);
    Shape shape = referenced.getShape().transform(trans);
    data.addAttribute(NonGeometricData.FILL, referenced.getData().getAttribute(NonGeometricData.FILL));
    data.addAttribute(NonGeometricData.STROKE, referenced.getData().getAttribute(NonGeometricData.STROKE));
View Full Code Here

  /**
   * @see org.newdawn.slick.svg.inkscape.ElementProcessor#process(org.newdawn.slick.svg.Loader, org.w3c.dom.Element, org.newdawn.slick.svg.Diagram, org.newdawn.slick.geom.Transform)
   */
  public void process(Loader loader, Element element, Diagram diagram, Transform t) throws ParsingException {
    Transform transform = Util.getTransform(element);
    transform = new Transform(t, transform);
   
    String points = element.getAttribute("points");
    if (element.getNodeName().equals("path")) {
      points = element.getAttribute("d");
    }
View Full Code Here

TOP

Related Classes of org.newdawn.slick.geom.Transform

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.