Examples of SVGGElement


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

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

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

    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

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

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

    final SVGElement root = new SVGGElement(doc);
    final String ltdPref  = LNamespace.LATEXDRAW_NAMESPACE + ':';
    final Element txt     = new SVGTextElement(doc);

    root.setAttribute(ltdPref + LNamespace.XML_TYPE, LNamespace.XML_TYPE_TEXT);
    root.setAttribute(SVGAttributes.SVG_ID, getSVGID());
    root.setAttribute(SVGAttributes.SVG_FILL, CSSColors.INSTANCE.getColorName(shape.getLineColour(), true));
    root.setAttribute(ltdPref + LNamespace.XML_POSITION, String.valueOf(shape.getTextPosition().getLatexToken()));

    txt.setAttribute(SVGAttributes.SVG_X, String.valueOf(shape.getX()));
    txt.setAttribute(SVGAttributes.SVG_Y, String.valueOf(shape.getY()));
    txt.appendChild(doc.createCDATASection(shape.getText()));
    root.appendChild(txt);

    setSVGRotationAttribute(root);

    return root;
  }
View Full Code Here

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

  @Override
  public SVGElement toSVG(final SVGDocument doc) {
    if(doc==null)
      throw new IllegalArgumentException();

    final SVGElement root = new SVGGElement(doc);
    SVGPolygonElement elt;
    final StringBuilder pointsBuilder = new StringBuilder();

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

        for(final IPoint pt : shape.getPoints())
          pointsBuilder.append(pt.getX()).append(',').append(pt.getY()).append(' ');

        final String points = pointsBuilder.toString();

        if(shape.hasShadow()) {
          final SVGPolygonElement shad = new SVGPolygonElement(doc);
          try { shad.setPoints(points); }catch(final ParseException ex) { BadaboomCollector.INSTANCE.add(ex); }
          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 SVGPolygonElement(doc);
          try { elt.setPoints(points); }catch(final ParseException ex) { BadaboomCollector.INSTANCE.add(ex); }
          setSVGBorderBackground(elt, root);
        }

        elt = new SVGPolygonElement(doc);
        try { elt.setPoints(points); }catch(final ParseException ex) { BadaboomCollector.INSTANCE.add(ex); }
        root.appendChild(elt);
        setSVGAttributes(doc, elt, true);
        elt.setAttribute(LNamespace.LATEXDRAW_NAMESPACE +':'+ LNamespace.XML_ROTATION, String.valueOf(shape.getRotationAngle()));

        if(shape.hasDbleBord()) {
          final SVGPolygonElement dblBord = new SVGPolygonElement(doc);
          try { dblBord.setPoints(points); }catch(final ParseException ex) { BadaboomCollector.INSTANCE.add(ex); }
          setSVGDoubleBordersAttributes(dblBord);
          root.appendChild(dblBord);
        }

        return root;
  }
View Full Code Here

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

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

    if(!shape.isEmpty()) {
       final SVGElement root     = new SVGGElement(doc);
       final List<IShape> shapes   = shape.getShapes();

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

       for(final IShape f : shapes)
         root.appendChild(SVGShapesFactory.INSTANCE.createSVGElement(f, doc));

       return root;
    }

    return null;
View Full Code Here

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

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

    final SVGElement root = new SVGGElement(doc);
        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);
    root.appendChild(img);

    return root;
  }
View Full Code Here

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

    final SVGDefsElement defs  = doc.getFirstChild().getDefs();
    final double rotationAngle = shape.getRotationAngle();
    final double startAngle    = shape.getAngleStart()%(2.*Math.PI);
    final double endAngle      = shape.getAngleEnd()%(2.*Math.PI);
    final ArcStyle type      = shape.getArcStyle();
        final SVGElement root    = new SVGGElement(doc);
        final IPoint start      = shape.getStartPoint();
        final IPoint end        = shape.getEndPoint();
        final double radius      = shape.getWidth()/2.0;
        final boolean largeArcFlag = Math.abs(startAngle-endAngle)>=Math.PI || startAngle>endAngle;
        final SVGPathSegList path  = new SVGPathSegList();
        SVGElement elt;

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

        path.add(new SVGPathSegMoveto(start.getX(), start.getY(), false));
        path.add(new SVGPathSegArc(end.getX(), end.getY(), radius, radius, 0, largeArcFlag, false, false));

        if(type==ArcStyle.CHORD)
          path.add(new SVGPathSegClosePath());
        else
          if(type==ArcStyle.WEDGE) {
            final IPoint gravityCenter = shape.getGravityCentre();
            path.add(new SVGPathSegLineto(gravityCenter.getX(), gravityCenter.getY(), false));
            path.add(new SVGPathSegClosePath());
          }

        if(shape.hasShadow())  {
          final SVGElement shad = new SVGPathElement(doc);

          shad.setAttribute(SVGAttributes.SVG_D, path.toString());
          setSVGShadowAttributes(shad, true);
          root.appendChild(shad);
          setSVGArrow(shape, shad, 0, true, doc, defs);
      setSVGArrow(shape, shad, 1, true, doc, defs);
        }

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

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

        if(shape.hasDbleBord()) {
            final SVGElement dble = new SVGPathElement(doc);
            dble.setAttribute(SVGAttributes.SVG_D, path.toString());
          setSVGDoubleBordersAttributes(dble);
          root.appendChild(dble);
        }

        setSVGRotationAttribute(root);
        setSVGAttributes(doc, elt, true);
        elt.setAttribute(LNamespace.LATEXDRAW_NAMESPACE +':'+ LNamespace.XML_ROTATION, String.valueOf(rotationAngle));

    setSVGArrow(shape, elt, 0, false, doc, defs);
    setSVGArrow(shape, elt, 1, false, doc, defs);

        if(shape.isShowPts())
          root.appendChild(getShowPointsElement(doc));

        return root;
  }
View Full Code Here

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

   */
  protected SVGGElement getShowPointsElement(final SVGDocument doc) {
    if(!shape.isShowPts() || doc==null)
      return null;

    final SVGGElement showPts = new SVGGElement(doc);
    final double thickness  = shape.getThickness()/2.;

    showPts.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_TYPE, LNamespace.XML_TYPE_SHOW_PTS);

    showPts.appendChild(getShowPointsLine(doc, thickness, shape.getLineColour(), shape.getGravityCentre(),
        shape.getStartPoint(), shape.getDashSepBlack(), shape.getDashSepWhite(), false, 1, 0));
    showPts.appendChild(getShowPointsLine(doc, thickness, shape.getLineColour(), shape.getGravityCentre(),
        shape.getEndPoint(), shape.getDashSepBlack(), shape.getDashSepWhite(), false, 1, 0));

    return showPts;
  }
View Full Code Here

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

    final IPoint br  = shape.getBottomRightPoint();
    final IPoint gc = shape.getGravityCentre();
    final IPoint p1 = ShapeFactory.createPoint((tl.getX()+br.getX())/2., tl.getY());
    final IPoint p2 = ShapeFactory.createPoint(br.getX(), (tl.getY()+br.getY())/2.);
    final IPoint p3 = ShapeFactory.createPoint((tl.getX()+br.getX())/2., br.getY());
    final SVGElement root = new SVGGElement(doc);
    SVGElement elt;
      final double gap = getPositionGap()/2.;
      final double cornerGap1 = GLibUtilities.getCornerGap(gc, p1, p2, gap);
      double cornerGap2 = GLibUtilities.getCornerGap(gc, p2, p3, gap);

      if(p2.getX()<p3.getX())
        cornerGap2*=-1;

        final String points = String.valueOf(p1.getX()) + ',' + (p1.getY() - cornerGap1) + ' ' + (p2.getX() + cornerGap2) + ',' + p2.getY() + ' ' + p3.getX() + ',' + (p3.getY() + cornerGap1) + ' ' + (tl.getX() - cornerGap2) + ',' + p2.getY();

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

        if(shape.hasShadow()) {
          elt = new SVGPolygonElement(doc);
          elt.setAttribute(SVGAttributes.SVG_POINTS, points);
          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 SVGPolygonElement(doc);
        elt.setAttribute(SVGAttributes.SVG_POINTS, points);
        setSVGBorderBackground(elt, root);
        }

    elt = new SVGPolygonElement(doc);
    elt.setAttribute(SVGAttributes.SVG_POINTS, points);
    root.appendChild(elt);
    root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_POINTS, String.valueOf(tl.getX()) + ' ' +
                tl.getY() + ' ' + br.getX() + ' ' + tl.getY() + ' ' + tl.getX() + ' ' + br.getY() + ' ' + br.getX() + ' ' + br.getY());

    if(shape.hasDbleBord()) {
      final SVGElement dblBord = new SVGPolygonElement(doc);
      dblBord.setAttribute(SVGAttributes.SVG_POINTS, points);
      setSVGDoubleBordersAttributes(dblBord);
      root.appendChild(dblBord);
    }

    setSVGAttributes(doc, elt, true);
    setSVGRotationAttribute(root);

View Full Code Here

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

  public SVGElement toSVG(final SVGDocument doc) {
    if(doc==null || doc.getFirstChild().getDefs()==null)
      return null;

    final SVGDefsElement defs = doc.getFirstChild().getDefs();
    final SVGElement root   = new SVGGElement(doc);
        SVGElement elt;
        final String path     = getPathSegList().toString();

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

         if(shape.hasShadow()) {
           final SVGElement shad = new SVGPathElement(doc);

      shad.setAttribute(SVGAttributes.SVG_D, path);
      setSVGShadowAttributes(shad, false);
      root.appendChild(shad);

      if(!shape.isClosed()) {
        setSVGArrow(shape, shad, 0, true, doc, defs);
        setSVGArrow(shape, shad, 1, true, doc, defs);
      }
    }

        if(shape.hasShadow() && !shape.getLineStyle().getLatexToken().equals(PSTricksConstants.LINE_NONE_STYLE) && 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);

    if(shape.hasDbleBord()) {
      final SVGElement dblBord = new SVGPathElement(doc);
      dblBord.setAttribute(SVGAttributes.SVG_D, path);
      setSVGDoubleBordersAttributes(dblBord);
      root.appendChild(dblBord);
    }

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

    if(!shape.isClosed()) {
      setSVGArrow(shape, elt, 0, false, doc, defs);
      setSVGArrow(shape, elt, 1, false, doc, defs);
    }

    if(shape.isShowPts())
      root.appendChild(getShowPointsElement(doc));

    return root;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.