Examples of SVGPolyLineElement


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


  @Test
  public void testEnableRendering() throws MalformedSVGDocument, ParseException {
    node.setAttribute(SVGAttributes.SVG_POINTS, "10,10 20,20"); //$NON-NLS-1$
    SVGPolyLineElement pl = new SVGPolyLineElement(node, null);
    assertTrue(pl.enableRendering());
  }
View Full Code Here

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

  @Test
  public void testSetPoints() throws MalformedSVGDocument, ParseException {
    String path = "10,10 20,20"; //$NON-NLS-1$
    node.setAttribute(SVGAttributes.SVG_POINTS, "10,10 20,20"); //$NON-NLS-1$
    SVGPolyLineElement pl = new SVGPolyLineElement(node, null);

    assertEquals(pl.getPoints(), path);
    pl.setPoints("10,10 20,20"); //$NON-NLS-1$
    assertEquals(2, pl.getPoints2D().size());
    assertEquals(new Point2D.Double(10, 10), pl.getPoints2D().get(0));
    assertEquals(new Point2D.Double(20, 20), pl.getPoints2D().get(pl.getPoints2D().size()-1));

    try {
      pl.setPoints("10,,20fdsf"); //$NON-NLS-1$
      fail();
    }
    catch(ParseException e) { /* */ }
  }
View Full Code Here

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

  @Test
  public void testGetPoints2D() throws MalformedSVGDocument, ParseException {
    String path = "    10\t ,\n  10   \t   20 \t\n\t\r,  \n20   \r30,30  \n"; //$NON-NLS-1$

    node.setAttribute(SVGAttributes.SVG_POINTS, path);
    SVGPolyLineElement pl = new SVGPolyLineElement(node, null);
    List<Point2D> pts;

    pts = pl.getPoints2D();
    assertNotNull(pts);
    assertEquals(3, pts.size());
    assertEquals(new Point2D.Double(10, 10), pts.get(0));
    assertEquals(new Point2D.Double(20, 20), pts.get(1));
    assertEquals(new Point2D.Double(30, 30), pts.get(pts.size()-1));
View Full Code Here

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

  @SuppressWarnings("unused")
  @Test
  public void testContructor() throws MalformedSVGDocument, ParseException {
    try {
      new SVGPolyLineElement(null, null);
      fail();
    }
    catch(Exception e){/**/}

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

    node.setAttribute(SVGAttributes.SVG_POINTS, ""); //$NON-NLS-1$
    new SVGPolyLineElement(node, null);

    try {
      node.setAttribute(SVGAttributes.SVG_POINTS, "dsqdgfd"); //$NON-NLS-1$
      new SVGPolyLineElement(node, null);
      fail();
    }
    catch(MalformedSVGDocument e){/**/}
    catch(ParseException e)      {/**/}

    node.setAttribute(SVGAttributes.SVG_POINTS, "10,10"); //$NON-NLS-1$
    new SVGPolyLineElement(node, null);

    try {
      node.setAttribute(SVGAttributes.SVG_POINTS, ","); //$NON-NLS-1$
      new SVGPolyLineElement(node, null);
      fail();
    }
    catch(MalformedSVGDocument e){/**/}
    catch(ParseException e)      {/**/}

    node.setAttribute(SVGAttributes.SVG_POINTS, "10,10 20,20"); //$NON-NLS-1$
    new SVGPolyLineElement(node, null);
  }
View Full Code Here

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

public class TestSVGPolylineElement extends AbstractTestSVGElement {
  @Test
  public void testGetPoints() throws MalformedSVGDocument, ParseException {
    String path = "10,10 20,20"; //$NON-NLS-1$
    node.setAttribute(SVGAttributes.SVG_POINTS, path);
    SVGPolyLineElement pl = new SVGPolyLineElement(node, null);

    assertEquals(pl.getPoints(), path);
  }
View Full Code Here

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

        final SVGElement root     = new SVGGElement(doc);
    final SVGDefsElement defs   = doc.getFirstChild().getDefs();
    final StringBuilder points   = new StringBuilder();
    final List<IPoint> pts    = shape.getPoints();
    SVGPolyLineElement elt;

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

    for(final IPoint pt : pts)
      points.append(pt.getX()).append(',').append(pt.getY()).append(' ');

    final String pointsStr = points.toString();

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

    elt = new SVGPolyLineElement(doc);
    try { elt.setPoints(pointsStr); }catch(final ParseException ex) { BadaboomCollector.INSTANCE.add(ex); }
    root.appendChild(elt);

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

    setSVGAttributes(doc, elt, false);
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.