Package net.sf.latexdraw.parsers.svg

Examples of net.sf.latexdraw.parsers.svg.SVGImageElement


public class TestSVGImageElement extends AbstractTestSVGElement {
  @SuppressWarnings("unused")
  @Test
  public void testContructor() throws MalformedSVGDocument {
    try {
      new SVGImageElement(null, ""); //$NON-NLS-1$
      fail();
    }
    catch(Exception e){/**/}

    try {
      new SVGImageElement(node, null);
      fail();
    }
    catch(MalformedSVGDocument e){/**/}

    try {
      node.setAttribute(SVGAttributes.SVG_WIDTH, "dsd"); //$NON-NLS-1$
      node.setAttribute(SVGAttributes.SVG_HEIGHT, "dsd"); //$NON-NLS-1$
      new SVGImageElement(node, null);
      fail();
    }
    catch(MalformedSVGDocument e){/**/}

    try {
      node.setAttribute(SVGAttributes.SVG_WIDTH, "1"); //$NON-NLS-1$
      new SVGImageElement(node, null);
      fail();
    }
    catch(MalformedSVGDocument e){/**/}

    try {
      node.setAttribute(SVGAttributes.SVG_WIDTH, "-1"); //$NON-NLS-1$
      node.setAttribute(SVGAttributes.SVG_HEIGHT, "10"); //$NON-NLS-1$
      new SVGImageElement(node, null);
      fail();
    }
    catch(MalformedSVGDocument e){/**/}

    try {
      node.setAttribute(SVGAttributes.SVG_WIDTH, "10"); //$NON-NLS-1$
      node.setAttribute(SVGAttributes.SVG_HEIGHT, "-1"); //$NON-NLS-1$
      new SVGImageElement(node, null);
      fail();
    }
    catch(MalformedSVGDocument e){/**/}

    node.setAttribute(SVGAttributes.SVG_HEIGHT, "20"); //$NON-NLS-1$
    new SVGImageElement(node, null);
  }
View Full Code Here


  @Test
  public void testGetHeight() throws MalformedSVGDocument {
    node.setAttribute(SVGAttributes.SVG_WIDTH, "10"); //$NON-NLS-1$
    node.setAttribute(SVGAttributes.SVG_HEIGHT, "20"); //$NON-NLS-1$
    SVGImageElement e = new SVGImageElement(node, null);
    assertEquals(e.getHeight(), 20., 0.0001);
  }
View Full Code Here

  @Test
  public void testGetWidth() throws MalformedSVGDocument {
    node.setAttribute(SVGAttributes.SVG_WIDTH, "10"); //$NON-NLS-1$
    node.setAttribute(SVGAttributes.SVG_HEIGHT, "20"); //$NON-NLS-1$
    SVGImageElement e = new SVGImageElement(node, null);
    assertEquals(e.getWidth(), 10., 0.0001);
  }
View Full Code Here

  @Test
  public void testGetURI() throws MalformedSVGDocument {
    node.setAttribute(SVGAttributes.SVG_WIDTH, "10"); //$NON-NLS-1$
    node.setAttribute(SVGAttributes.SVG_HEIGHT, "20"); //$NON-NLS-1$
    SVGImageElement e = new SVGImageElement(node, null);
    assertNull(e.getURI());

    node.setAttribute("xlink:href", "/dir/file"); //$NON-NLS-1$ //$NON-NLS-2$
    e = new SVGImageElement(node, null);
    assertEquals(e.getURI(), "/dir/file"); //$NON-NLS-1$
  }
View Full Code Here

  @Test
  public void testEnableRendering() {
    try {
      node.setAttribute(SVGAttributes.SVG_WIDTH, "10"); //$NON-NLS-1$
      node.setAttribute(SVGAttributes.SVG_HEIGHT, "20"); //$NON-NLS-1$
      SVGImageElement e = new SVGImageElement(node, null);
      assertFalse(e.enableRendering());

      node.setAttribute("xlink:href", "/rerzerojcsf/dsqdsdfgdre"); //$NON-NLS-1$ //$NON-NLS-2$
      e = new SVGImageElement(node, null);
      assertFalse(e.enableRendering());

      node.setAttribute("xlink:href", "build.xml"); //$NON-NLS-1$ //$NON-NLS-2$
      e = new SVGImageElement(node, null);
      assertFalse(e.enableRendering());

      node.setAttribute(SVGAttributes.SVG_WIDTH, "0"); //$NON-NLS-1$
      e = new SVGImageElement(node, null);
      assertFalse(e.enableRendering());

      node.setAttribute(SVGAttributes.SVG_HEIGHT, "0"); //$NON-NLS-1$
      e = new SVGImageElement(node, null);
      assertFalse(e.enableRendering());

      node.setAttribute(SVGAttributes.SVG_WIDTH, "20"); //$NON-NLS-1$
      e = new SVGImageElement(node, null);
      assertFalse(e.enableRendering());
    }
    catch(MalformedSVGDocument e) { fail(); }
  }
View Full Code Here

  @Test
  public void testGetY() {
    try {
      node.setAttribute(SVGAttributes.SVG_WIDTH, "10"); //$NON-NLS-1$
      node.setAttribute(SVGAttributes.SVG_HEIGHT, "20"); //$NON-NLS-1$
      SVGImageElement e = new SVGImageElement(node, null);
      assertEquals(e.getY(), 0., 0.0001);

      node.setAttribute(SVGAttributes.SVG_Y, "1"); //$NON-NLS-1$
      e = new SVGImageElement(node, null);
      assertEquals(1., e.getY(), 0.0001);
    }
    catch(MalformedSVGDocument e) { fail(); }
  }
View Full Code Here

  @Test
  public void testGetX() {
    try {
      node.setAttribute(SVGAttributes.SVG_WIDTH, "10"); //$NON-NLS-1$
      node.setAttribute(SVGAttributes.SVG_HEIGHT, "20"); //$NON-NLS-1$
      SVGImageElement e = new SVGImageElement(node, null);
      assertEquals(e.getX(), 0., 0.0001);

      node.setAttribute(SVGAttributes.SVG_X, "1"); //$NON-NLS-1$
      e = new SVGImageElement(node, null);
      assertEquals(1., e.getX(), 0.0001);
    }
    catch(MalformedSVGDocument e) { fail(); }
  }
View Full Code Here

    final SVGElement elt2 = getLaTeXDrawElement(elt, null);

    if(elt==null || !(elt2 instanceof SVGImageElement))
      throw new IllegalArgumentException();

    final SVGImageElement main = (SVGImageElement)elt2;

    shape.setPathSource(main.getURI());
    shape.setPosition(main.getX(), main.getY());

    if(withTransformation)
      applyTransformations(elt);
  }
View Full Code Here

        final SVGElement img;

        root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_TYPE, LNamespace.XML_TYPE_PICTURE);
    root.setAttribute(SVGAttributes.SVG_ID, getSVGID());

    img = new SVGImageElement(doc, shape.getPathSource());
    img.setAttribute(SVGAttributes.SVG_X, String.valueOf(shape.getPosition().getX()));
    img.setAttribute(SVGAttributes.SVG_Y, String.valueOf(shape.getPosition().getY()));
    img.setAttribute(SVGAttributes.SVG_HEIGHT, String.valueOf(shape.getImage().getHeight(null)));
    img.setAttribute(SVGAttributes.SVG_WIDTH, String.valueOf(shape.getImage().getWidth(null)));
    setSVGRotationAttribute(root);
View Full Code Here

TOP

Related Classes of net.sf.latexdraw.parsers.svg.SVGImageElement

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.