Examples of SVGElement


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

  public SVGElement toSVG(final SVGDocument doc, final boolean isShadow) {
    if(doc==null || !arrow.hasStyle())
      return null;

    final ArrowStyle arrowStyle = arrow.getArrowStyle();
    final SVGElement marker   = new SVGMarkerElement(doc);
    final double lineWidth    = arrow.getShape().getFullThickness();
    double gapPostion       = 0.;

    if(arrowStyle==ArrowStyle.CIRCLE_END || arrowStyle==ArrowStyle.CIRCLE_IN)
      gapPostion = toSVGCircle(doc, lineWidth, isShadow, marker);
    else
    if(arrowStyle==ArrowStyle.DISK_END || arrowStyle==ArrowStyle.DISK_IN)
      gapPostion = toSVGDisk(doc, lineWidth, isShadow, marker);
    else
    if(arrowStyle.isBar())
      toSVGBar(doc, lineWidth, isShadow, marker);
    else if(arrowStyle.isSquareBracket())
      toSVGSquareBracket(doc, lineWidth, isShadow, marker);
    else
    if(arrowStyle==ArrowStyle.RIGHT_ARROW || arrowStyle==ArrowStyle.LEFT_ARROW)
      toSVGArrow(doc, lineWidth, isShadow, marker);
    else
    if(arrowStyle.isRoundBracket())
      toSVGRoundBracket(doc, lineWidth, isShadow, marker);
    else
    if(arrowStyle==ArrowStyle.LEFT_DBLE_ARROW || arrowStyle==ArrowStyle.RIGHT_DBLE_ARROW)
      toSVGDoubleArrow(doc, lineWidth, isShadow, marker);
    else
    if(arrowStyle==ArrowStyle.ROUND_IN)
      toSVGRoundIn(doc, isShadow, marker);

    if(!LNumber.equalsDouble(gapPostion,0.))
      marker.setAttribute(SVGAttributes.SVG_REF_X, String.valueOf(gapPostion/lineWidth));

    marker.setAttribute(SVGAttributes.SVG_OVERFLOW, SVGAttributes.SVG_VALUE_VISIBLE);
    marker.setAttribute(SVGAttributes.SVG_ORIENT, SVGAttributes.SVG_VALUE_AUTO);

    return marker;
  }
View Full Code Here

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

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

    final SVGElement elt2 = getLaTeXDrawElement(elt, null);

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

    final SVGPolygonElement main = (SVGPolygonElement)elt2;
View Full Code Here

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

  @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.SVGElement

  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.SVGElement

   * @since 2.0.0
   */
  protected LPictureSVGGenerator(final SVGGElement elt, final boolean withTransformation) throws IOException {
    this(ShapeFactory.createPicture(ShapeFactory.createPoint()));

    final SVGElement elt2 = getLaTeXDrawElement(elt, null);

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

    final SVGImageElement main = (SVGImageElement)elt2;
View Full Code Here

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

  @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.SVGElement

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

    final SVGElement elt2 = getLaTeXDrawElement(elt, null);
    final IArrow arr1  = shape.getArrowAt(0);
    final IArrow arr2  = shape.getArrowAt(-1);

    if(elt==null || !(elt2 instanceof SVGPathElement))
      throw new IllegalArgumentException();
View Full Code Here

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

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

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

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

    final SVGElement elt2 = getLaTeXDrawElement(elt, null);

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

    final SVGPolygonElement main = (SVGPolygonElement)elt2;
View Full Code Here

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

    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);
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.