Package net.sf.latexdraw.parsers.svg

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


    /* Looking for the two axe in order to get the position of the axes. */
    final SVGNodeList nl = elt.getChildren(SVGElements.SVG_G);
    int i=0;
        final int size = nl.getLength();
        SVGGElement l1=null;
        SVGGElement l2=null;
        SVGElement element;

    while((l1==null || l2==null) && i<size) {
      element = nl.item(i);

View Full Code Here


//    final Graphics2D2SVG graphics = new Graphics2D2SVG(doc);
//    IViewShape view = View2DTK.getFactory().createView(shape);

//        view.paint(graphics);
        //  graphics.getElement();
        final SVGElement root = new SVGGElement(doc);
    final String pref = LNamespace.LATEXDRAW_NAMESPACE+':';
    setThickness(root, shape.getThickness(), false, 0.);
    root.setStroke(shape.getLineColour());

    root.setAttribute(pref+LNamespace.XML_STYLE, shape.getAxesStyle().toString());
    root.setAttribute(pref+LNamespace.XML_GRID_START, shape.getGridStartX() + " " + shape.getGridStartY()); //$NON-NLS-1$
    root.setAttribute(pref+LNamespace.XML_GRID_END, shape.getGridEndX() + " " + shape.getGridEndY());//$NON-NLS-1$
    root.setAttribute(pref+LNamespace.XML_GRID_ORIGIN, shape.getOriginX() + " " + shape.getOriginY());//$NON-NLS-1$
    root.setAttribute(pref+LNamespace.XML_AXE_INCREMENT, shape.getIncrementX() + " " + shape.getIncrementY());//$NON-NLS-1$
    root.setAttribute(pref+LNamespace.XML_AXE_DIST_LABELS, shape.getDistLabelsX() + " " + shape.getDistLabelsY());//$NON-NLS-1$
    root.setAttribute(pref+LNamespace.XML_AXE_TICKS_SIZE, String.valueOf(shape.getTicksSize()));
    root.setAttribute(pref+LNamespace.XML_AXE_SHOW_ORIGIN, String.valueOf(shape.isShowOrigin()));
    root.setAttribute(pref+LNamespace.XML_AXE_SHOW_TICKS, shape.getTicksDisplayed().toString());
    root.setAttribute(pref+LNamespace.XML_AXE_LABELS_STYLE, shape.getLabelsDisplayed().toString());
    root.setAttribute(pref+LNamespace.XML_AXE_TICKS_STYLE, shape.getTicksStyle().toString());
    root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_TYPE, LNamespace.XML_TYPE_AXE);
    root.setAttribute(SVGAttributes.SVG_ID, getSVGID());
    createSVGAxe(root, doc);
    setSVGRotationAttribute(root);

//    view.flush();
//    graphics.dispose();
View Full Code Here

    final double gap = getPositionGap();
    final IPoint tl  = shape.getTopLeftPoint();
    final IPoint br  = shape.getBottomRightPoint();
    SVGElement elt;
        final SVGElement root = new SVGGElement(document);
        final double width  = Math.max(1, br.getX()-tl.getX()+gap);
        final double height = Math.max(1., br.getY()-tl.getY()+gap);
        final double x    = tl.getX()-gap/2.;
        final double y    = tl.getY()-gap/2.;

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

        if(shape.hasShadow()) {
          elt = new SVGRectElement(x, y, width, height, document);
          setSVGShadowAttributes(elt, true);
          root.appendChild(elt);
          setSVGRoundCorner(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 SVGRectElement(x, y, width, height, document);
          setSVGBorderBackground(elt, root);
          setSVGRoundCorner(elt);
        }

        elt = new SVGRectElement(x, y, width, height, document);
        root.appendChild(elt);
        setSVGAttributes(document, elt, true);
        setSVGRoundCorner(elt);

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

        setSVGRotationAttribute(root);

    return root;
View Full Code Here

  @Override
  public SVGElement toSVG(final SVGDocument doc) {
    if(doc==null)
      return null;

    final SVGElement root = new SVGGElement(doc);
    SVGElement elt;

    root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_TYPE, LNamespace.XML_TYPE_FREEHAND);
    root.setAttribute(SVGAttributes.SVG_ID, getSVGID());
    root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_PATH_TYPE, String.valueOf(shape.getType()));
    root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_INTERVAL, String.valueOf(shape.getInterval()));
    final String path = getPath().toString();
    final StringBuilder pts = new StringBuilder();

    for(int i = 0, size = shape.getNbPoints(); i < size; i++)
        pts.append(shape.getPtAt(i).getX()).append(' ').append(shape.getPtAt(i).getY()).append(' ');

    root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_POINTS, pts.toString());

    if(shape.hasShadow()) {
      final SVGElement shad = new SVGPathElement(doc);
      shad.setAttribute(SVGAttributes.SVG_D, path);
      setSVGShadowAttributes(shad, false);
      root.appendChild(shad);
    }

        if(shape.hasShadow() && shape.getLineStyle()!=LineStyle.NONE && shape.isFilled())
        {// The background of the borders must be filled is there is a shadow.
        elt = new SVGPathElement(doc);
        elt.setAttribute(SVGAttributes.SVG_D, path);
        setSVGBorderBackground(elt, root);
        }

    elt = new SVGPathElement(doc);
    elt.setAttribute(SVGAttributes.SVG_D, path);
    root.appendChild(elt);

    setSVGAttributes(doc, elt, false);
    elt.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_ROTATION, String.valueOf(shape.getRotationAngle()));

    return root;
View Full Code Here

    final double brx = br.getX();
    final double bry = br.getY();
    SVGElement elt;
        final SVGElement shad;
        final SVGElement dblBord;
        final SVGElement root = new SVGGElement(doc);
        root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_TYPE, LNamespace.XML_TYPE_CIRCLE);
        root.setAttribute(SVGAttributes.SVG_ID, getSVGID());
        final double gap = getPositionGap();

        if(shape.hasShadow()) {
          shad = new SVGCircleElement((brx+tlx)/2., (bry+tly)/2., (brx-tlx+gap)/2., doc);
          setSVGShadowAttributes(shad, true);
          root.appendChild(shad);
        }

        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 SVGCircleElement((brx+tlx)/2., (bry+tly)/2., (brx-tlx+gap)/2., doc);
          setSVGBorderBackground(elt, root);
        }

        elt = new SVGCircleElement((brx+tlx)/2., (bry+tly)/2., (brx-tlx+gap)/2., doc);// FIXME Should use prototype design pattern to reduce re-creation.
        root.appendChild(elt);

        if(shape.hasDbleBord()) {
          dblBord = new SVGCircleElement((brx+tlx)/2., (bry+tly)/2., (brx-tlx+gap)/2., doc);
          setSVGDoubleBordersAttributes(dblBord);
          root.appendChild(dblBord);
        }

        setSVGAttributes(doc, elt, true);
        setSVGRotationAttribute(root);
View Full Code Here

   * @since 3.0
   */
  public Graphics2D2SVG(final SVGDocument document) {
    super();
    this.document = Objects.requireNonNull(document);
    element     = new SVGGElement(document);
  }
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$
View Full Code Here

TOP

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

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.