Package net.sf.latexdraw.parsers.svg

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


  }


  @Test
  public void testItem() {
    SVGElement elt = (SVGElement)doc.createElement("elt"); //$NON-NLS-1$

    list.getNodes().clear();
    assertNull(list.item(0));
    assertNull(list.item(-1));
    assertNull(list.item(1));
View Full Code Here


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

      doc1.createElement(null);
      fail();
    }
    catch(DOMException e) { /* ok */ }

    SVGElement elt = (SVGElement)doc1.createElement("test"); //$NON-NLS-1$
    assertEquals(elt.getNodeName(), "test"); //$NON-NLS-1$
    assertEquals(doc1, elt.getOwnerDocument());
  }
View Full Code Here

  }


  @Test
  public void testSetParent() {
    SVGElement elt = (SVGElement)doc.createElement("elt"); //$NON-NLS-1$

    node.setParent(null);
    assertNull(node.getParent());
    node.setParent(elt);
    assertEquals(elt, node.getParent());
    SVGNodeList list = elt.getChildren(getNameNode());
    assertEquals(1, list.getLength());
    node.setParent(null);
    list = elt.getChildren(getNameNode());
    assertEquals(0, list.getLength());
  }
View Full Code Here

      fail();
    }
    catch(DOMException e) { /* ok */ }


    SVGElement elt = (SVGElement)doc.createElement("eltAppendChild"); //$NON-NLS-1$
    assertEquals(node.appendChild(elt), elt);
    assertEquals(node.getChildren("eltAppendChild").getLength(), 1); //$NON-NLS-1$
  }
View Full Code Here


  @Test
  public void testGetNamespaceURI() {
    SVGAttr attr   = new SVGAttr("pref:n", "", node); //$NON-NLS-1$ //$NON-NLS-2$
    SVGElement elt = (SVGElement)node.getOwnerDocument().createElement("tag2"); //$NON-NLS-1$

    assertNull(attr.getNamespaceURI());
    elt.setAttribute("xmlns:pref", "namespace"); //$NON-NLS-1$ //$NON-NLS-2$
    elt.appendChild(node);
    assertEquals(attr.getNamespaceURI(), "namespace"); //$NON-NLS-1$
  }
View Full Code Here


  @Test
  public void testLookupNamespaceURI() {
    SVGAttr attr   = new SVGAttr("pref:n", "", node); //$NON-NLS-1$ //$NON-NLS-2$
    SVGElement elt = (SVGElement)node.getOwnerDocument().createElement("tag2"); //$NON-NLS-1$

    assertNull(attr.getNamespaceURI());
    elt.setAttribute("xmlns:pref", "namespace"); //$NON-NLS-1$ //$NON-NLS-2$
    elt.appendChild(node);
    assertEquals(attr.getNamespaceURI(), "namespace"); //$NON-NLS-1$
  }
View Full Code Here

   * @since 2.0.0
   */
  protected LEllipseSVGGenerator(final SVGGElement elt, final boolean withTransformation) {
    this(ShapeFactory.createEllipse());

    final SVGElement elt2 = getLaTeXDrawElement(elt, null);

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

    setSVGLatexdrawParameters(elt);
View Full Code Here

    final IPoint br = shape.getBottomRightPoint();
    final double tlx = tl.getX();
    final double tly = tl.getY();
    final double brx = br.getX();
    final double bry = br.getY();
    SVGElement elt;
    final SVGElement root = new SVGGElement(doc);
        root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_TYPE, LNamespace.XML_TYPE_ELLIPSE);
        root.setAttribute(SVGAttributes.SVG_ID, getSVGID());
        final double gap   = getPositionGap();
        final double width  = Math.max(1., (brx-tlx+gap)/2.);
        final double height = Math.max(1., (bry-tly+gap)/2.);
        final double x    = (brx+tlx)/2.;
        final double y    = (bry+tly)/2.;

        if(shape.hasShadow()) {
          elt = new SVGEllipseElement(x, y, width, height, doc);
          setSVGShadowAttributes(elt, true);
          root.appendChild(elt);
        }

        if(shape.hasShadow() && !shape.getLineStyle().getLatexToken().equals(PSTricksConstants.LINE_NONE_STYLE)) {
          // The background of the borders must be filled is there is a shadow.
          elt = new SVGEllipseElement(x, y, width, height, doc);
          setSVGBorderBackground(elt, root);
        }

        elt = new SVGEllipseElement(x, y, width, height, doc);
        setSVGAttributes(doc, elt, true);
        root.appendChild(elt);

        if(shape.hasDbleBord())  {
          elt = new SVGEllipseElement(x, y, width, height, doc);
          setSVGDoubleBordersAttributes(elt);
          root.appendChild(elt);
        }

        setSVGRotationAttribute(root);

    return root;
View Full Code Here

    if(elt==null)
      throw new IllegalArgumentException();

    String v = elt.getAttribute(elt.getUsablePrefix(LNamespace.LATEXDRAW_NAMESPACE_URI)+LNamespace.XML_SIZE);
    final SVGElement main = getLaTeXDrawElement(elt, null);

    try { shape.setDotStyle(DotStyle.getStyle(elt.getAttribute(elt.getUsablePrefix(LNamespace.LATEXDRAW_NAMESPACE_URI)+LNamespace.XML_DOT_SHAPE))); }
    catch(final IllegalArgumentException e) { BadaboomCollector.INSTANCE.add(e); }

    if(v!=null)
      try { shape.setDiametre(Double.parseDouble(v)); }
      catch(final NumberFormatException e) { BadaboomCollector.INSTANCE.add(e); }

    v = elt.getAttribute(elt.getUsablePrefix(LNamespace.LATEXDRAW_NAMESPACE_URI)+LNamespace.XML_POSITION);

    final List<Point2D> pos = SVGPointsParser.getPoints(v);

    if(pos!=null && !pos.isEmpty())
      shape.setPosition(pos.get(0).getX(), pos.get(0).getY());

    setSVGLatexdrawParameters(elt);
    setSVGParameters(main);

    if(withTransformation)
      applyTransformations(elt);

    if(!shape.isFillable() && shape.isFilled())
      shape.setLineColour(CSSColors.INSTANCE.getRGBColour(main.getFill()));
  }
View Full Code Here

TOP

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

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.