Package net.sf.latexdraw.parsers.svg

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




  @Test
  public void testAdoptNode() {
    SVGSVGElement elt = new SVGSVGElement(doc2);

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

    try {
      doc1.adoptNode(new SVGComment("", doc2)); //$NON-NLS-1$
      fail();
    }
    catch(DOMException e){ /* ok */ }

    doc1.adoptNode(elt);
    assertEquals(doc1, elt.getOwnerDocument());
    assertEquals(doc1.getFirstChild(), elt);
  }
View Full Code Here


     */
    private SVGDocument toSVG(final IDrawing drawing, final double incr) {
      // Creation of the SVG document.
      final List<IShape> shapes;
      final SVGDocument doc     = new SVGDocument();
      final SVGSVGElement root   = doc.getFirstChild();
      final SVGGElement g     = new SVGGElement(doc);
      SVGElement elt;

      if(onlySelection)
        shapes  = drawing.getSelection().getShapes();
      else shapes = drawing.getShapes();

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

      try {
            for(final IShape sh : shapes) {
              // For each shape an SVG element is created.
              elt = SVGShapesFactory.INSTANCE.createSVGElement(sh, doc);
              if(elt!=null)
                g.appendChild(elt);
              setProgress((int)Math.min(100., getProgress()+incr));
            }
      }catch(final Exception ex) { BadaboomCollector.INSTANCE.add(ex); }
      // 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

      // Creation of the SVG document.
      final Instrument[] instruments   = ui.getInstruments();
      final double incr        = 100./(drawing.size() + instruments.length + ui.getPresentations().size());
      final SVGDocument doc       = toSVG(drawing, incr);
      final SVGMetadataElement meta  = new SVGMetadataElement(doc);
      final SVGSVGElement root     = doc.getFirstChild();
      final SVGElement metaLTD    = (SVGElement)doc.createElement(LNamespace.LATEXDRAW_NAMESPACE+':'+SVGElements.SVG_METADATA);

      // Creation of the SVG meta data tag.
      meta.appendChild(metaLTD);
      root.appendChild(meta);

      if(saveParameters) {
        // The parameters of the instruments are now saved.
        for(final Instrument instrument : instruments) {
          instrument.save(false, LNamespace.LATEXDRAW_NAMESPACE, doc, metaLTD);
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.