Examples of SVGPathElement


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

public class TestSVGPathElement extends AbstractTestSVGElement {
  @SuppressWarnings("unused")
  @Test
  public void testContructor() throws MalformedSVGDocument {
    try {
      new SVGPathElement(null, null);
      fail();
    }
    catch(Exception e){/**/}

    try {
      new SVGPathElement(node, null);
      fail();
    }
    catch(MalformedSVGDocument e){ /**/ }

    node.setAttribute(SVGAttributes.SVG_D, "test"); //$NON-NLS-1$
    new SVGPathElement(node, null);
  }
View Full Code Here

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


  @Test
  public void testGetPathData() throws MalformedSVGDocument {
    node.setAttribute(SVGAttributes.SVG_D, "M 0 0 L 10 10"); //$NON-NLS-1$
    SVGPathElement e = new SVGPathElement(node, null);
    assertEquals(e.getPathData(), "M 0 0 L 10 10"); //$NON-NLS-1$
  }
View Full Code Here

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



  private void toSVGBar(final SVGDocument doc, final double lineWidth, final boolean isShadow, final SVGElement marker) {
    final IShape shape      = arrow.getShape();
    final SVGPathElement bar  = new SVGPathElement(doc);
    final double width       = arrow.getTBarSizeDim() + arrow.getTBarSizeNum()*lineWidth;
    final SVGPathSegList path   = new SVGPathSegList();
    final double x         = arrow.getArrowStyle()==ArrowStyle.BAR_IN ? arrow.isLeftArrow() ? 0.5 : -0.5 : 0.;

    bar.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_ARROW_TBAR_SIZE_NUM, String.valueOf(arrow.getTBarSizeNum()));
    path.add(new SVGPathSegMoveto(x, -width/(lineWidth*2.), false));
    path.add(new SVGPathSegLineto(x, width/(lineWidth*2.), false));
    bar.setPathData(path);
    bar.setAttribute(SVGAttributes.SVG_STROKE, CSSColors.INSTANCE.getColorName(isShadow ? shape.getShadowCol() : shape.getLineColour(), true));
    bar.setAttribute(SVGAttributes.SVG_FILL, SVGAttributes.SVG_VALUE_NONE);
    bar.setPathData(path);
    bar.setStrokeWidth(1.);
    marker.appendChild(bar);
  }
View Full Code Here

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



  private double toSVGSquareBracket(final SVGDocument doc, final double lineWidth, final boolean isShadow, final SVGElement marker) {
    final IShape shape      = arrow.getShape();
    final SVGPathElement bar   = new SVGPathElement(doc);
    final double width       = arrow.getTBarSizeDim() + arrow.getTBarSizeNum()*lineWidth;
    final SVGPathSegList path   = new SVGPathSegList();
    final double lgth       = arrow.getBracketNum()*(arrow.getTBarSizeDim()/IShape.PPC + arrow.getTBarSizeNum()*lineWidth)/lineWidth;
    final boolean isInverted    = arrow.isInverted();//FIXME shape.PPC
    final double gapPostion;

    if(arrow.getArrowStyle()==ArrowStyle.LEFT_SQUARE_BRACKET) {
      final double lgth2 = isInverted ? -lgth : 0.;
      path.add(new SVGPathSegMoveto(lgth+lgth2+0.5, -width/(lineWidth*2)+0.5, false));
      path.add(new SVGPathSegLineto(lgth2, -width/(lineWidth*2)+0.5, false));
      path.add(new SVGPathSegLineto(lgth2, width/(lineWidth*2)-0.5, false));
      path.add(new SVGPathSegLineto(lgth+lgth2+0.5, width/(lineWidth*2)-0.5, false));
      gapPostion = isInverted ? -lineWidth/4. : -lineWidth/2.;
    }
    else {
      final double lgth2 = isInverted ? lgth : 0.;
      path.add(new SVGPathSegMoveto(-lgth+lgth2-0.5, -width/(lineWidth*2)+0.5, false));
      path.add(new SVGPathSegLineto(lgth2, -width/(lineWidth*2)+0.5, false));
      path.add(new SVGPathSegLineto(lgth2, width/(lineWidth*2)-0.5, false));
      path.add(new SVGPathSegLineto(-lgth+lgth2-0.5, width/(lineWidth*2)-0.5, false));
      gapPostion = isInverted ? lineWidth/4. : lineWidth/2.;
    }

    marker.appendChild(bar);
    bar.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_ARROW_TBAR_SIZE_NUM, String.valueOf(arrow.getTBarSizeNum()));
    bar.setAttribute(SVGAttributes.SVG_STROKE, CSSColors.INSTANCE.getColorName(isShadow ? shape.getShadowCol() : shape.getLineColour(), true));
    bar.setAttribute(SVGAttributes.SVG_FILL, SVGAttributes.SVG_VALUE_NONE);
    bar.setPathData(path);
    bar.setAttribute(SVGAttributes.SVG_STROKE_WIDTH, "1"); //$NON-NLS-1$

    return gapPostion;
  }
View Full Code Here

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



  private void toSVGArrow(final SVGDocument doc, final double lineWidth, final boolean isShadow, final SVGElement marker) {
    final IShape shape      = arrow.getShape();
    final SVGElement arrowSVG   = new SVGPathElement(doc);
    final double width      = (arrow.getArrowSizeNum()*lineWidth + arrow.getArrowSizeDim())/lineWidth;
    double length         = arrow.getArrowLength()*width;
        double inset                = arrow.getArrowInset()*length;
        final SVGPathSegList path   = new SVGPathSegList();

    if(arrow.getArrowStyle()==ArrowStyle.LEFT_ARROW) {
      length *= -1.;
      inset *= -1.;
    }

    final double lgth2 = arrow.isInverted() ? length : 0.;
    path.add(new SVGPathSegMoveto(lgth2, 0., false));
    path.add(new SVGPathSegLineto(-length+lgth2, width/2., false));
    path.add(new SVGPathSegLineto(-length+inset+lgth2, 0.false));
    path.add(new SVGPathSegLineto(-length+lgth2, -width/2., false));
    path.add(new SVGPathSegClosePath());

    marker.appendChild(arrowSVG);
    arrowSVG.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_ARROW_SIZE_NUM, String.valueOf(arrow.getArrowSizeNum()));
    arrowSVG.setAttribute(SVGAttributes.SVG_FILL, CSSColors.INSTANCE.getColorName(isShadow ? shape.getShadowCol() : shape.getLineColour(), true));
    arrowSVG.setAttribute(SVGAttributes.SVG_D, path.toString());
  }
View Full Code Here

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



  private void toSVGRoundBracket(final SVGDocument doc, final double lineWidth, final boolean isShadow, final SVGElement marker) {
    final IShape shape        = arrow.getShape();
    final SVGPathElement rbracket   = new SVGPathElement(doc);
    final double width         = (arrow.getTBarSizeDim() + arrow.getTBarSizeNum()*lineWidth)/lineWidth;
    double lgth            = arrow.getRBracketNum()*width;
    final SVGPathSegList path     = new SVGPathSegList();
    double gap            = 0.5;

    if(arrow.getArrowStyle()==ArrowStyle.LEFT_ROUND_BRACKET) {
      lgth *= -1.;
      gap *= -1.;
    }

    final double lgth2 = arrow.isInverted() ? lgth : 0.;
    path.add(new SVGPathSegMoveto(-lgth+lgth2-gap, width/2., false));
    path.add(new SVGPathSegCurvetoCubic(-lgth+lgth2-gap, -width/2., 0., width/2., 0., -width/2., false));

    marker.appendChild(rbracket);
    rbracket.setAttribute(SVGAttributes.SVG_STROKE, CSSColors.INSTANCE.getColorName(isShadow ? shape.getShadowCol() : shape.getLineColour(), true));
    rbracket.setAttribute(SVGAttributes.SVG_FILL, SVGAttributes.SVG_VALUE_NONE);
    rbracket.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_ARROW_TBAR_SIZE_NUM, String.valueOf(arrow.getTBarSizeNum()));
    rbracket.setPathData(path);
    rbracket.setStrokeWidth(1);
  }
View Full Code Here

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

  }


  private void toSVGDoubleArrow(final SVGDocument doc, final double lineWidth, final boolean isShadow, final SVGElement marker) {
    final IShape shape      = arrow.getShape();
    final SVGElement arrowSVG   = new SVGPathElement(doc);
    final double width      = (arrow.getArrowSizeNum()*lineWidth + arrow.getArrowSizeDim())/lineWidth;
    double length         = arrow.getArrowLength()*width;
        double inset                = arrow.getArrowInset()*length;
        final SVGPathSegList path   = new SVGPathSegList();

    if(arrow.getArrowStyle()==ArrowStyle.LEFT_DBLE_ARROW) {
      inset *= -1.;
      length *= -1.;
    }

    final double lgth2 = arrow.isInverted() ? length*2 : 0.;
    path.add(new SVGPathSegMoveto(lgth2, 0., false));
    path.add(new SVGPathSegLineto(-length+lgth2, width/2., false));
    path.add(new SVGPathSegLineto(-length+inset+lgth2, 0., false));
    path.add(new SVGPathSegLineto(-length+lgth2, -width/2., false));
    path.add(new SVGPathSegClosePath());
    path.add(new SVGPathSegMoveto(-length+lgth2, 0., false));
    path.add(new SVGPathSegLineto(-length*2+lgth2, width/2., false));
    path.add(new SVGPathSegLineto(-length*2+inset+lgth2, 0., false));
    path.add(new SVGPathSegLineto(-length*2+lgth2, -width/2., false));
    path.add(new SVGPathSegClosePath());

    marker.appendChild(arrowSVG);
    arrowSVG.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_ARROW_SIZE_NUM, String.valueOf(arrow.getArrowSizeNum()));
    arrowSVG.setAttribute(SVGAttributes.SVG_FILL, CSSColors.INSTANCE.getColorName(isShadow ? shape.getShadowCol() : shape.getLineColour(), true));
    arrowSVG.setAttribute(SVGAttributes.SVG_D, path.toString());
  }
View Full Code Here

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

    final IArrow arr2  = shape.getArrowAt(-1);

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

    final SVGPathElement main = (SVGPathElement)elt2;
    final SVGPathSegList l = main.getSegList();
    final double sx;
        final double sy;

        if(l.size()<2 && !(l.get(0) instanceof SVGPathSegMoveto) && !(l.get(1) instanceof SVGPathSegArc))
      throw new IllegalArgumentException();

    sx = ((SVGPathSegMoveto)l.get(0)).getX();
    sy = ((SVGPathSegMoveto)l.get(0)).getY();
    final Arc2D arc = ((SVGPathSegArc)l.get(1)).getArc2D(sx, sy);
    double angle = Math.toRadians(arc.getAngleStart())%(Math.PI*2);
    shape.setAngleStart(angle);
    angle = Math.toRadians(arc.getAngleExtent()+arc.getAngleStart())%(Math.PI*2);
    shape.setAngleEnd(angle);
    shape.setPosition(arc.getMinX(), arc.getMaxY());
    shape.setWidth(arc.getMaxX()-arc.getMinX());

    if(l.size()>2)
      if(l.get(2) instanceof SVGPathSegClosePath)
        shape.setArcStyle(ArcStyle.CHORD);
      else
        if(l.size()==4 && l.get(2) instanceof SVGPathSegLineto && l.get(3) instanceof SVGPathSegClosePath)
          shape.setArcStyle(ArcStyle.WEDGE);

    shape.setShowPts(getLaTeXDrawElement(elt, LNamespace.XML_TYPE_SHOW_PTS)!=null);

    setSVGParameters(main);
    setSVGArrow(arr1, main.getAttribute(main.getUsablePrefix()+SVGAttributes.SVG_MARKER_START), main, SVGAttributes.SVG_MARKER_START);
    setSVGArrow(arr2, main.getAttribute(main.getUsablePrefix()+SVGAttributes.SVG_MARKER_END), main, SVGAttributes.SVG_MARKER_END);
    homogeniseArrows(arr1, arr2);
    setSVGLatexdrawParameters(elt);
    setSVGShadowParameters(getLaTeXDrawElement(elt, LNamespace.XML_TYPE_SHADOW));
    setSVGDbleBordersParameters(getLaTeXDrawElement(elt, LNamespace.XML_TYPE_DBLE_BORDERS));

View Full Code Here

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

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

    final SVGElement elt2 = getLaTeXDrawElement(elt, null);

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

    final SVGPathElement main = (SVGPathElement)elt2;
    setPath(main.getSegList());
    setSVGParameters(main);
    setSVGShadowParameters(getLaTeXDrawElement(elt, LNamespace.XML_TYPE_SHADOW));
    setSVGDbleBordersParameters(getLaTeXDrawElement(elt, LNamespace.XML_TYPE_DBLE_BORDERS));
    final IArrow arrow1 = shape.getArrowAt(0);
    final IArrow arrow2 = shape.getArrowAt(-1);
    setSVGArrow(arrow1, main.getAttribute(main.getUsablePrefix()+SVGAttributes.SVG_MARKER_START), main, SVGAttributes.SVG_MARKER_START);
    setSVGArrow(arrow2, main.getAttribute(main.getUsablePrefix()+SVGAttributes.SVG_MARKER_END), main, SVGAttributes.SVG_MARKER_END);
    homogeniseArrows(arrow1, arrow2);

    shape.setShowPts(getLaTeXDrawElement(elt, LNamespace.XML_TYPE_SHOW_PTS)!=null);

    if(withTransformation)
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.