Package net.sf.latexdraw.parsers.svg

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


public class TestSVGSVGElement extends AbstractTestSVGElement {
  @SuppressWarnings("unused")
  @Test
  public void testContructor() throws MalformedSVGDocument {
    try {
      new SVGSVGElement(null);
      fail();
    }
    catch(Exception e){/**/}

    new SVGSVGElement(node, null);
  }
View Full Code Here


  public void testGetDefs() throws MalformedSVGDocument, ParserConfigurationException {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document document = builder.newDocument();
    Element elt, n;
        SVGSVGElement e = new SVGSVGElement(node, null);

    assertNull(e.getMeta());

    n = document.createElement(SVGElements.SVG_SVG);
    n.setAttribute("xmlns", SVGDocument.SVG_NAMESPACE); //$NON-NLS-1$
    elt = document.createElement(SVGElements.SVG_DEFS);
    n.appendChild(elt);
    e = new SVGSVGElement(n, null);
    assertNotNull(e.getDefs());
  }
View Full Code Here

      return null;

    // Creation of the SVG document.
    final List<IShape> shapes  = drawing.getShapes();
    final SVGDocument doc     = new SVGDocument();
    final SVGSVGElement root   = doc.getFirstChild();
    final SVGGElement g     = new SVGGElement(doc);
    final SVGDefsElement defs  = new SVGDefsElement(doc);
    SVGElement elt;

    root.appendChild(defs);
    root.appendChild(g);
    root.setAttribute("xmlns:"+LNamespace.LATEXDRAW_NAMESPACE, LNamespace.LATEXDRAW_NAMESPACE_URI);//$NON-NLS-1$

        for(final IShape sh : shapes)
          if(sh!=null) {
            // For each shape an SVG element is created.
            elt = SVGShapesFactory.INSTANCE.createSVGElement(sh, doc);

            if(elt!=null)
              g.appendChild(elt);
          }

    // Setting SVG attributes to the created document.
    root.setAttribute(SVGAttributes.SVG_VERSION, "1.1");//$NON-NLS-1$
    root.setAttribute(SVGAttributes.SVG_BASE_PROFILE, "full");//$NON-NLS-1$

    return doc;
  }
View Full Code Here

  public void testGetMeta() throws MalformedSVGDocument, ParserConfigurationException {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document document = builder.newDocument();
    Element elt, n;
        SVGSVGElement e = new SVGSVGElement(node, null);

    assertNull(e.getMeta());

    n = document.createElement(SVGElements.SVG_SVG);
    n.setAttribute("xmlns", SVGDocument.SVG_NAMESPACE); //$NON-NLS-1$
    elt = document.createElement(SVGElements.SVG_METADATA);
    n.appendChild(elt);
    e = new SVGSVGElement(n, null);
    assertNotNull(e.getMeta());
  }
View Full Code Here


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



  @Test
  public void testEnableRendering() throws MalformedSVGDocument {
    SVGSVGElement e = new SVGSVGElement(node, null);
    assertTrue(e.enableRendering());

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

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

    node.setAttribute(SVGAttributes.SVG_WIDTH, "10"); //$NON-NLS-1$
    node.setAttribute(SVGAttributes.SVG_HEIGHT, "10"); //$NON-NLS-1$
    e = new SVGSVGElement(node, null);
    assertTrue(e.enableRendering());
  }
View Full Code Here

  }


  @Test
  public void testGetY() throws MalformedSVGDocument {
    SVGSVGElement e = new SVGSVGElement(node, null);
    assertEquals(e.getY(), 0., 0.0001);

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



  @Test
  public void testGetX() throws MalformedSVGDocument {
    SVGSVGElement e = new SVGSVGElement(node, null);
    assertEquals(e.getX(), 0., 0.0001);

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


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


  @Test
  public void testVersion() throws MalformedSVGDocument {
    node.setAttribute(SVGAttributes.SVG_VERSION, "1.1"); //$NON-NLS-1$
    SVGSVGElement e = new SVGSVGElement(node, null);
    assertEquals(e.getVersion(), "1.1"); //$NON-NLS-1$
  }
View Full Code Here

TOP

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

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.